@@ -577,21 +577,16 @@ const underbarPrefix = new RegExp('^_');
577577 *
578578 * applyRules( 'cows', singular_rules ); // === 'cow'
579579 */
580- function applyRules ( str , rules , skip , override ) {
581- if ( override ) {
582- return override ;
580+ function applyRules ( str , rules , skip ) {
581+ if ( skip . includes ( str . toLocaleLowerCase ( ) ) ) {
582+ return str ;
583583 }
584- else {
585- if ( skip . includes ( str . toLocaleLowerCase ( ) ) ) {
586- return str ;
587- }
588- for ( const rule of rules ) {
589- if ( str . match ( rule [ 0 ] ) ) {
590- if ( rule [ 1 ] !== undefined ) {
591- return str . replace ( rule [ 0 ] , rule [ 1 ] ) ;
592- }
593- return str ;
584+ for ( const rule of rules ) {
585+ if ( str . match ( rule [ 0 ] ) ) {
586+ if ( rule [ 1 ] !== undefined ) {
587+ return str . replace ( rule [ 0 ] , rule [ 1 ] ) ;
594588 }
589+ return str ;
595590 }
596591 }
597592 return str ;
@@ -608,10 +603,9 @@ function applyRules(str, rules, skip, override) {
608603 * inflection.pluralize( 'person' ); // === 'people'
609604 * inflection.pluralize( 'octopus' ); // === 'octopuses'
610605 * inflection.pluralize( 'Hat' ); // === 'Hats'
611- * inflection.pluralize( 'person', 'guys' ); // === 'guys'
612606 */
613- function pluralize ( str , plural ) {
614- return applyRules ( str , pluralRules , uncountableWords , plural ) ;
607+ function pluralize ( str ) {
608+ return applyRules ( str , pluralRules , uncountableWords ) ;
615609}
616610/**
617611 * This function adds singularization support to every String object.
@@ -625,10 +619,9 @@ function pluralize(str, plural) {
625619 * inflection.singularize( 'people' ); // === 'person'
626620 * inflection.singularize( 'octopuses' ); // === 'octopus'
627621 * inflection.singularize( 'Hats' ); // === 'Hat'
628- * inflection.singularize( 'guys', 'person' ); // === 'person'
629622 */
630- function singularize ( str , singular ) {
631- return applyRules ( str , singularRules , uncountableWords , singular ) ;
623+ function singularize ( str ) {
624+ return applyRules ( str , singularRules , uncountableWords ) ;
632625}
633626/**
634627 * This function will pluralize or singularlize a String appropriately based on a number value
@@ -649,16 +642,15 @@ function singularize(str, singular) {
649642 * inflection.inflect( 'person', 2 ); // === 'people'
650643 * inflection.inflect( 'octopus', 2 ); // === 'octopuses'
651644 * inflection.inflect( 'Hat', 2 ); // === 'Hats'
652- * inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys'
653645 */
654- function inflect ( str , count , singular , plural ) {
646+ function inflect ( str , count ) {
655647 if ( isNaN ( count ) )
656648 return str ;
657649 if ( count === 1 ) {
658- return applyRules ( str , singularRules , uncountableWords , singular ) ;
650+ return applyRules ( str , singularRules , uncountableWords ) ;
659651 }
660652 else {
661- return applyRules ( str , pluralRules , uncountableWords , plural ) ;
653+ return applyRules ( str , pluralRules , uncountableWords ) ;
662654 }
663655}
664656/**
0 commit comments