moment-duration-format
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "moment-duration-format", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A moment.js plugin for formatting durations.", | ||
@@ -5,0 +5,0 @@ "main": "lib/moment-duration-format.js", |
@@ -1,4 +0,4 @@ | ||
/*! Moment Duration Format v2.1.0 | ||
/*! Moment Duration Format v2.1.1 | ||
* https://github.com/jsmreese/moment-duration-format | ||
* Date: 2017-12-21 | ||
* Date: 2017-12-29 | ||
* | ||
@@ -36,2 +36,11 @@ * Duration format plugin function for the Moment.js library | ||
// stringIncludes | ||
function stringIncludes(str, search) { | ||
if (search.length > str.length) { | ||
return false; | ||
} | ||
return str.indexOf(search) !== -1; | ||
} | ||
// durationLabelCompare | ||
@@ -307,3 +316,3 @@ function durationLabelCompare(a, b) { | ||
each(array, function(child) { | ||
ret = ret.concat(child) | ||
ret = ret.concat(child); | ||
}); | ||
@@ -817,3 +826,3 @@ | ||
if (!foundFirst && (momentType.value > 0 || find(stopTrim, momentType.type) || find(outputTypes, momentType.type))) { | ||
if (!foundFirst && (momentType.value > 0 || trim === "" /* trim: false */ || find(stopTrim, momentType.type) || find(outputTypes, momentType.type))) { | ||
foundFirst = true; | ||
@@ -1050,3 +1059,3 @@ } | ||
if (token.text.includes(labelType.string)) { | ||
if (stringIncludes(token.text, labelType.string)) { | ||
token.text = token.text.replace(labelType.string, label.label); | ||
@@ -1064,3 +1073,3 @@ autoLocalized = true; | ||
if (pluralizedLabels[label.type] === label.label) { | ||
if (token.text.includes(label.label)) { | ||
if (stringIncludes(token.text, label.label)) { | ||
// Stop checking this token if its label is already | ||
@@ -1076,3 +1085,3 @@ // correctly pluralized. | ||
if (token.text.includes(label.label)) { | ||
if (stringIncludes(token.text, label.label)) { | ||
// Replece this token's label and stop checking. | ||
@@ -1165,3 +1174,3 @@ token.text = token.text.replace(label.label, pluralizedLabels[label.type]); | ||
} | ||
case "weeks": // Possible Fallthrough. | ||
case "weeks": | ||
if (firstType === lastType) { | ||
@@ -1180,3 +1189,3 @@ return "w __"; | ||
} | ||
case "years": // Possible Fallthrough. | ||
case "years": | ||
if (firstType === lastType) { | ||
@@ -1183,0 +1192,0 @@ return "y __"; |
{ | ||
"name": "moment-duration-format", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A moment.js plugin for formatting durations.", | ||
@@ -5,0 +5,0 @@ "main": "lib/moment-duration-format.js", |
@@ -59,5 +59,5 @@ # Moment Duration Format | ||
momentDurationFormatSetup(moment); | ||
typeof moment.duration.fn.format === "function" | ||
typeof moment.duration.fn.format === "function"; | ||
// true | ||
typeof moment.duration.format === "function" | ||
typeof moment.duration.format === "function"; | ||
// true | ||
@@ -271,3 +271,4 @@ ``` | ||
The default precison value is `0`. | ||
The default precision value is `0`. | ||
```javascript | ||
@@ -617,3 +618,3 @@ moment.duration(123, "minutes").format("h [hrs]"); | ||
The minimun value will bubble up to larger-magnitude units if they are present in the format template. | ||
The minimum value will bubble up to larger-magnitude units if they are present in the format template. | ||
@@ -1028,3 +1029,3 @@ ```javascript | ||
This locale uses a single token `"s"` for the singular label, a double token `"ss"` for the plural label when the value is `2`, and a triple token `"sss"` for the plural lable for values greater than `3`. For brevity, only labels for the `seconds` type are included. | ||
This locale uses a single token `"s"` for the singular label, a double token `"ss"` for the plural label when the value is `2`, and a triple token `"sss"` for the plural label for values greater than `3`. For brevity, only labels for the `seconds` type are included. | ||
@@ -1031,0 +1032,0 @@ Unit labels are replaced after the format template string is tokenized, so they need not be escaped. Time-notation templates are replaced before the format template string is tokenized, so they must be escaped. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
597475
16348
1104