Skip to content

Commit

Permalink
Improved Number.pluralize() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Jul 2, 2024
1 parent 8c07bb5 commit 608039f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- extended icon validator by adding support for `tic` keyword
- fixed link generator for email and phone numbers in `Markdown`
- improved `Number.pluralize()` method

========================
0.0.96
Expand Down
10 changes: 10 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4896,6 +4896,16 @@ NP.pluralize = function(zero, one, few, other) {
var num = this;
var value = '';

if (!one && typeof(zero) === 'string') {
zero = zero.split(',');
if (zero instanceof Array) {
one = zero[1];
few = zero[2];
other = zero[3];
zero = zero[0];
}
}

if (num == 0)
value = zero || '';
else if (num == 1)
Expand Down

0 comments on commit 608039f

Please sign in to comment.