Skip to content

Commit e90bfb7

Browse files
committed
chore: build
1 parent e16b411 commit e90bfb7

2 files changed

Lines changed: 18 additions & 29 deletions

File tree

lib/inflection.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
* inflection.pluralize( 'person' ); // === 'people'
1919
* inflection.pluralize( 'octopus' ); // === 'octopuses'
2020
* inflection.pluralize( 'Hat' ); // === 'Hats'
21-
* inflection.pluralize( 'person', 'guys' ); // === 'guys'
2221
*/
23-
export declare function pluralize(str: string, plural?: string): string;
22+
export declare function pluralize(str: string): string;
2423
/**
2524
* This function adds singularization support to every String object.
2625
* @param str The subject string.
@@ -33,9 +32,8 @@ export declare function pluralize(str: string, plural?: string): string;
3332
* inflection.singularize( 'people' ); // === 'person'
3433
* inflection.singularize( 'octopuses' ); // === 'octopus'
3534
* inflection.singularize( 'Hats' ); // === 'Hat'
36-
* inflection.singularize( 'guys', 'person' ); // === 'person'
3735
*/
38-
export declare function singularize(str: string, singular?: string): string;
36+
export declare function singularize(str: string): string;
3937
/**
4038
* This function will pluralize or singularlize a String appropriately based on a number value
4139
* @param str The subject string.
@@ -55,9 +53,8 @@ export declare function singularize(str: string, singular?: string): string;
5553
* inflection.inflect( 'person', 2 ); // === 'people'
5654
* inflection.inflect( 'octopus', 2 ); // === 'octopuses'
5755
* inflection.inflect( 'Hat', 2 ); // === 'Hats'
58-
* inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys'
5956
*/
60-
export declare function inflect(str: string, count: number, singular?: string, plural?: string): string;
57+
export declare function inflect(str: string, count: number): string;
6158
/**
6259
* This function adds camelization support to every String object.
6360
* @param str The subject string.

lib/inflection.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -560,21 +560,16 @@ const underbarPrefix = new RegExp('^_');
560560
*
561561
* applyRules( 'cows', singular_rules ); // === 'cow'
562562
*/
563-
function applyRules(str, rules, skip, override) {
564-
if (override) {
565-
return override;
563+
function applyRules(str, rules, skip) {
564+
if (skip.includes(str.toLocaleLowerCase())) {
565+
return str;
566566
}
567-
else {
568-
if (skip.includes(str.toLocaleLowerCase())) {
569-
return str;
570-
}
571-
for (const rule of rules) {
572-
if (str.match(rule[0])) {
573-
if (rule[1] !== undefined) {
574-
return str.replace(rule[0], rule[1]);
575-
}
576-
return str;
567+
for (const rule of rules) {
568+
if (str.match(rule[0])) {
569+
if (rule[1] !== undefined) {
570+
return str.replace(rule[0], rule[1]);
577571
}
572+
return str;
578573
}
579574
}
580575
return str;
@@ -591,10 +586,9 @@ function applyRules(str, rules, skip, override) {
591586
* inflection.pluralize( 'person' ); // === 'people'
592587
* inflection.pluralize( 'octopus' ); // === 'octopuses'
593588
* inflection.pluralize( 'Hat' ); // === 'Hats'
594-
* inflection.pluralize( 'person', 'guys' ); // === 'guys'
595589
*/
596-
function pluralize(str, plural) {
597-
return applyRules(str, pluralRules, uncountableWords, plural);
590+
function pluralize(str) {
591+
return applyRules(str, pluralRules, uncountableWords);
598592
}
599593
exports.pluralize = pluralize;
600594
/**
@@ -609,10 +603,9 @@ exports.pluralize = pluralize;
609603
* inflection.singularize( 'people' ); // === 'person'
610604
* inflection.singularize( 'octopuses' ); // === 'octopus'
611605
* inflection.singularize( 'Hats' ); // === 'Hat'
612-
* inflection.singularize( 'guys', 'person' ); // === 'person'
613606
*/
614-
function singularize(str, singular) {
615-
return applyRules(str, singularRules, uncountableWords, singular);
607+
function singularize(str) {
608+
return applyRules(str, singularRules, uncountableWords);
616609
}
617610
exports.singularize = singularize;
618611
/**
@@ -634,16 +627,15 @@ exports.singularize = singularize;
634627
* inflection.inflect( 'person', 2 ); // === 'people'
635628
* inflection.inflect( 'octopus', 2 ); // === 'octopuses'
636629
* inflection.inflect( 'Hat', 2 ); // === 'Hats'
637-
* inflection.inflect( 'person', 2, null, 'guys' ); // === 'guys'
638630
*/
639-
function inflect(str, count, singular, plural) {
631+
function inflect(str, count) {
640632
if (isNaN(count))
641633
return str;
642634
if (count === 1) {
643-
return applyRules(str, singularRules, uncountableWords, singular);
635+
return applyRules(str, singularRules, uncountableWords);
644636
}
645637
else {
646-
return applyRules(str, pluralRules, uncountableWords, plural);
638+
return applyRules(str, pluralRules, uncountableWords);
647639
}
648640
}
649641
exports.inflect = inflect;

0 commit comments

Comments
 (0)