@@ -597,27 +597,18 @@ const underbarPrefix = new RegExp('^_');
597597 *
598598 * applyRules( 'cows', singular_rules ); // === 'cow'
599599 */
600- function applyRules (
601- str : string ,
602- rules : [ RegExp , string ?] [ ] ,
603- skip : string [ ] ,
604- override ?: string
605- ) {
606- if ( override ) {
607- return override ;
608- } else {
609- if ( skip . includes ( str . toLocaleLowerCase ( ) ) ) {
610- return str ;
611- }
612-
613- for ( const rule of rules ) {
614- if ( str . match ( rule [ 0 ] ) ) {
615- if ( rule [ 1 ] !== undefined ) {
616- return str . replace ( rule [ 0 ] , rule [ 1 ] ) ;
617- }
600+ function applyRules ( str : string , rules : [ RegExp , string ?] [ ] , skip : string [ ] ) {
601+ if ( skip . includes ( str . toLocaleLowerCase ( ) ) ) {
602+ return str ;
603+ }
618604
619- return str ;
605+ for ( const rule of rules ) {
606+ if ( str . match ( rule [ 0 ] ) ) {
607+ if ( rule [ 1 ] !== undefined ) {
608+ return str . replace ( rule [ 0 ] , rule [ 1 ] ) ;
620609 }
610+
611+ return str ;
621612 }
622613 }
623614
@@ -636,10 +627,9 @@ function applyRules(
636627 * inflection.pluralize( 'person' ); // === 'people'
637628 * inflection.pluralize( 'octopus' ); // === 'octopuses'
638629 * inflection.pluralize( 'Hat' ); // === 'Hats'
639- * inflection.pluralize( 'person', 'guys' ); // === 'guys'
640630 */
641- export function pluralize ( str : string , plural ?: string ) {
642- return applyRules ( str , pluralRules , uncountableWords , plural ) ;
631+ export function pluralize ( str : string ) {
632+ return applyRules ( str , pluralRules , uncountableWords ) ;
643633}
644634
645635/**
@@ -654,10 +644,9 @@ export function pluralize(str: string, plural?: string) {
654644 * inflection.singularize( 'people' ); // === 'person'
655645 * inflection.singularize( 'octopuses' ); // === 'octopus'
656646 * inflection.singularize( 'Hats' ); // === 'Hat'
657- * inflection.singularize( 'guys', 'person' ); // === 'person'
658647 */
659- export function singularize ( str : string , singular ?: string ) {
660- return applyRules ( str , singularRules , uncountableWords , singular ) ;
648+ export function singularize ( str : string ) {
649+ return applyRules ( str , singularRules , uncountableWords ) ;
661650}
662651
663652/**
@@ -679,20 +668,14 @@ export function singularize(str: string, singular?: string) {
679668 * inflection.inflect( 'person', 2 ); // === 'people'
680669 * inflection.inflect( 'octopus', 2 ); // === 'octopuses'
681670 * inflection.inflect( 'Hat', 2 ); // === 'Hats'
682- * inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys'
683671 */
684- export function inflect (
685- str : string ,
686- count : number ,
687- singular ?: string ,
688- plural ?: string
689- ) {
672+ export function inflect ( str : string , count : number ) {
690673 if ( isNaN ( count ) ) return str ;
691674
692675 if ( count === 1 ) {
693- return applyRules ( str , singularRules , uncountableWords , singular ) ;
676+ return applyRules ( str , singularRules , uncountableWords ) ;
694677 } else {
695- return applyRules ( str , pluralRules , uncountableWords , plural ) ;
678+ return applyRules ( str , pluralRules , uncountableWords ) ;
696679 }
697680}
698681
0 commit comments