shelving 1.62.1 → 1.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/util/number.d.ts +4 -0
- package/util/number.js +7 -0
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"state-management",
|
|
12
12
|
"query-builder"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.63.0",
|
|
15
15
|
"repository": "https://github.com/dhoulb/shelving",
|
|
16
16
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
17
17
|
"license": "0BSD",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"test:prettier": "prettier --check './**/*.{md,json}'",
|
|
52
52
|
"test:eslint": "eslint --cache './**/*.{ts,tsx}'",
|
|
53
53
|
"test:typescript": "tsc --noEmit",
|
|
54
|
-
"test:dpdm": "dpdm ./modules/index.ts --transform",
|
|
54
|
+
"test:dpdm": "dpdm ./modules/index.ts --transform --tree=false --warning=false",
|
|
55
55
|
"test:jest": "jest",
|
|
56
56
|
"test:jest:watch": "jest --watchAll",
|
|
57
57
|
"build": "npm run build:typescript && npm run build:copy && npm run build:jest",
|
package/util/number.d.ts
CHANGED
|
@@ -95,6 +95,10 @@ export declare function formatFullQuantity(num: number, singular: string, plural
|
|
|
95
95
|
* @returns The number formatted as a crammed string.
|
|
96
96
|
*/
|
|
97
97
|
export declare function cramNumber(num: number): string;
|
|
98
|
+
/** Cram a number with a short suffix. */
|
|
99
|
+
export declare const cramQuantity: (num: number, suffix: string) => string;
|
|
100
|
+
/** Cram a number with a longer full-word suffix. */
|
|
101
|
+
export declare function cramFullQuantity(num: number, singular: string, plural: string): string;
|
|
98
102
|
/**
|
|
99
103
|
* Is a number within a specified range?
|
|
100
104
|
*
|
package/util/number.js
CHANGED
|
@@ -140,6 +140,13 @@ function _significance(num) {
|
|
|
140
140
|
const digits = num >= 100 ? 0 : num >= 10 ? 1 : 2;
|
|
141
141
|
return truncateNumber(num, digits).toFixed(digits);
|
|
142
142
|
}
|
|
143
|
+
/** Cram a number with a short suffix. */
|
|
144
|
+
export const cramQuantity = (num, suffix) => `${cramNumber(num)}${suffix}`;
|
|
145
|
+
/** Cram a number with a longer full-word suffix. */
|
|
146
|
+
export function cramFullQuantity(num, singular, plural) {
|
|
147
|
+
const qty = cramNumber(num);
|
|
148
|
+
return `${qty} ${qty === "1" ? singular : plural}`;
|
|
149
|
+
}
|
|
143
150
|
/**
|
|
144
151
|
* Is a number within a specified range?
|
|
145
152
|
*
|