@valkyriestudios/utils 12.3.0 → 12.5.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/README.md +15 -4
- package/array/dedupe.d.ts +2 -1
- package/array/dedupe.js +3 -1
- package/array/index.d.ts +10 -0
- package/array/index.js +25 -0
- package/array/is.d.ts +2 -1
- package/array/is.js +2 -0
- package/array/isNotEmpty.d.ts +2 -1
- package/array/isNotEmpty.js +2 -0
- package/array/join.d.ts +2 -2
- package/array/join.js +3 -1
- package/array/mapFn.d.ts +4 -7
- package/array/mapFn.js +2 -0
- package/array/mapKey.d.ts +3 -4
- package/array/mapKey.js +2 -0
- package/array/mapPrimitive.d.ts +2 -2
- package/array/mapPrimitive.js +3 -1
- package/array/shuffle.d.ts +2 -1
- package/array/shuffle.js +2 -0
- package/array/sort.d.ts +2 -2
- package/array/sort.js +4 -2
- package/boolean/index.d.ts +2 -0
- package/boolean/index.js +6 -0
- package/boolean/is.d.ts +2 -1
- package/boolean/is.js +2 -0
- package/caching/index.d.ts +2 -0
- package/caching/index.js +5 -0
- package/caching/memoize.d.ts +2 -1
- package/caching/memoize.js +2 -0
- package/date/addUTC.d.ts +2 -1
- package/date/addUTC.js +3 -3
- package/date/diff.d.ts +2 -1
- package/date/diff.js +4 -2
- package/date/endOfUTC.d.ts +2 -1
- package/date/endOfUTC.js +3 -3
- package/date/format.d.ts +2 -1
- package/date/format.js +3 -1
- package/date/index.d.ts +11 -0
- package/date/index.js +24 -0
- package/date/is.d.ts +2 -1
- package/date/is.js +2 -0
- package/date/nowUnix.d.ts +2 -1
- package/date/nowUnix.js +2 -0
- package/date/nowUnixMs.d.ts +2 -1
- package/date/nowUnixMs.js +2 -0
- package/date/startOfUTC.d.ts +2 -1
- package/date/startOfUTC.js +3 -3
- package/date/toUTC.d.ts +2 -1
- package/date/toUTC.js +3 -1
- package/date/toUnix.d.ts +2 -1
- package/date/toUnix.js +3 -1
- package/deep/freeze.d.ts +2 -2
- package/deep/freeze.js +2 -0
- package/deep/get.d.ts +2 -1
- package/deep/get.js +2 -0
- package/deep/index.d.ts +5 -0
- package/deep/index.js +15 -0
- package/deep/seal.d.ts +2 -2
- package/deep/seal.js +2 -0
- package/deep/set.d.ts +2 -1
- package/deep/set.js +2 -0
- package/equal.d.ts +1 -1
- package/equal.js +4 -2
- package/formdata/index.d.ts +2 -0
- package/formdata/index.js +6 -0
- package/formdata/is.d.ts +9 -0
- package/formdata/is.js +8 -0
- package/function/index.d.ts +7 -0
- package/function/index.js +19 -0
- package/function/is.d.ts +2 -1
- package/function/is.js +2 -0
- package/function/isAsync.d.ts +2 -1
- package/function/isAsync.js +2 -0
- package/function/noop.d.ts +2 -1
- package/function/noop.js +2 -0
- package/function/noopresolve.d.ts +2 -1
- package/function/noopresolve.js +2 -0
- package/function/noopreturn.d.ts +2 -1
- package/function/noopreturn.js +2 -0
- package/function/sleep.d.ts +2 -1
- package/function/sleep.js +2 -0
- package/hash/fnv1A.d.ts +2 -1
- package/hash/fnv1A.js +2 -0
- package/hash/guid.d.ts +2 -1
- package/hash/guid.js +2 -0
- package/hash/index.d.ts +3 -0
- package/hash/index.js +7 -0
- package/index.d.ts +386 -238
- package/is.d.ts +52 -66
- package/is.js +61 -73
- package/number/index.d.ts +18 -0
- package/number/index.js +57 -0
- package/number/is.d.ts +2 -1
- package/number/is.js +2 -0
- package/number/isAbove.d.ts +2 -1
- package/number/isAbove.js +2 -0
- package/number/isAboveOrEqual.d.ts +2 -1
- package/number/isAboveOrEqual.js +2 -0
- package/number/isBelow.d.ts +2 -1
- package/number/isBelow.js +2 -0
- package/number/isBelowOrEqual.d.ts +2 -1
- package/number/isBelowOrEqual.js +2 -0
- package/number/isBetween.d.ts +2 -1
- package/number/isBetween.js +2 -0
- package/number/isInteger.d.ts +2 -1
- package/number/isInteger.js +2 -0
- package/number/isIntegerAbove.d.ts +2 -1
- package/number/isIntegerAbove.js +2 -0
- package/number/isIntegerAboveOrEqual.d.ts +2 -1
- package/number/isIntegerAboveOrEqual.js +2 -0
- package/number/isIntegerBelow.d.ts +2 -1
- package/number/isIntegerBelow.js +2 -0
- package/number/isIntegerBelowOrEqual.d.ts +2 -1
- package/number/isIntegerBelowOrEqual.js +2 -0
- package/number/isIntegerBetween.d.ts +2 -1
- package/number/isIntegerBetween.js +2 -0
- package/number/isNumericalNaN.d.ts +2 -1
- package/number/isNumericalNaN.js +2 -0
- package/number/randomBetween.d.ts +2 -1
- package/number/randomBetween.js +2 -0
- package/number/randomIntBetween.d.ts +2 -1
- package/number/randomIntBetween.js +2 -0
- package/number/round.d.ts +2 -1
- package/number/round.js +2 -0
- package/number/toPercentage.d.ts +2 -1
- package/number/toPercentage.js +3 -1
- package/object/define.d.ts +2 -1
- package/object/define.js +2 -0
- package/object/index.d.ts +6 -0
- package/object/index.js +17 -0
- package/object/is.d.ts +2 -1
- package/object/is.js +2 -0
- package/object/isNotEmpty.d.ts +2 -1
- package/object/isNotEmpty.js +2 -0
- package/object/merge.d.ts +1 -1
- package/object/merge.js +2 -0
- package/object/pick.d.ts +2 -1
- package/object/pick.js +4 -2
- package/package.json +1 -1
- package/regexp/index.d.ts +3 -0
- package/regexp/index.js +9 -0
- package/regexp/is.d.ts +2 -1
- package/regexp/is.js +2 -0
- package/regexp/sanitize.d.ts +2 -1
- package/regexp/sanitize.js +2 -0
- package/string/humanizeBytes.d.ts +2 -2
- package/string/humanizeBytes.js +4 -3
- package/string/humanizeNumber.d.ts +2 -2
- package/string/humanizeNumber.js +3 -1
- package/string/index.d.ts +7 -0
- package/string/index.js +20 -0
- package/string/is.d.ts +2 -1
- package/string/is.js +2 -0
- package/string/isBetween.d.ts +2 -1
- package/string/isBetween.js +2 -0
- package/string/isNotEmpty.d.ts +2 -1
- package/string/isNotEmpty.js +2 -0
- package/string/shorten.d.ts +2 -1
- package/string/shorten.js +2 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.randomIntBetween = void 0;
|
|
3
4
|
function randomIntBetween(min = 0, max = 10) {
|
|
4
5
|
if (!Number.isFinite(min) ||
|
|
5
6
|
!Number.isFinite(max))
|
|
6
7
|
throw new TypeError('Min/Max should be numeric');
|
|
7
8
|
return Math.floor((Math.random() * (max - min)) + min);
|
|
8
9
|
}
|
|
10
|
+
exports.randomIntBetween = randomIntBetween;
|
|
9
11
|
exports.default = randomIntBetween;
|
package/number/round.d.ts
CHANGED
package/number/round.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.round = void 0;
|
|
3
4
|
function round(val, precision = 0) {
|
|
4
5
|
if (!Number.isFinite(val))
|
|
5
6
|
throw new TypeError('Value should be numeric');
|
|
@@ -7,4 +8,5 @@ function round(val, precision = 0) {
|
|
|
7
8
|
const num = (val * exp) * (1 + Number.EPSILON);
|
|
8
9
|
return Math.round(num) / exp;
|
|
9
10
|
}
|
|
11
|
+
exports.round = round;
|
|
10
12
|
exports.default = round;
|
package/number/toPercentage.d.ts
CHANGED
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @returns Percentage value respective to the provided range
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
declare function toPercentage(val: number, precision?: number, min?: number, max?: number): number;
|
|
12
|
+
export { toPercentage, toPercentage as default };
|
package/number/toPercentage.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.toPercentage = void 0;
|
|
3
4
|
const round_1 = require("./round");
|
|
4
5
|
function toPercentage(val, precision = 0, min = 0, max = 1) {
|
|
5
6
|
if (!Number.isFinite(val) ||
|
|
6
7
|
!Number.isFinite(min) ||
|
|
7
8
|
!Number.isFinite(max))
|
|
8
9
|
throw new TypeError('value/min/max should be numeric');
|
|
9
|
-
return (0, round_1.
|
|
10
|
+
return (0, round_1.round)(((val - min) / (max - min)) * 100, precision);
|
|
10
11
|
}
|
|
12
|
+
exports.toPercentage = toPercentage;
|
|
11
13
|
exports.default = toPercentage;
|
package/object/define.d.ts
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @returns Object with the defined properties
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
declare function define(props: {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}, obj?: {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
}): {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
};
|
|
16
|
+
export { define, define as default };
|
package/object/define.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.define = void 0;
|
|
3
4
|
function define(props, obj = {}) {
|
|
4
5
|
if (Object.prototype.toString.call(props) !== '[object Object]' ||
|
|
5
6
|
Object.prototype.toString.call(obj) !== '[object Object]')
|
|
6
7
|
throw new TypeError('Please pass an object as the value for props and obj');
|
|
7
8
|
return Object.defineProperties(obj, props);
|
|
8
9
|
}
|
|
10
|
+
exports.define = define;
|
|
9
11
|
exports.default = define;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { define } from './define';
|
|
2
|
+
import { isObject } from './is';
|
|
3
|
+
import { isNotEmptyObject } from './isNotEmpty';
|
|
4
|
+
import { merge } from './merge';
|
|
5
|
+
import { pick } from './pick';
|
|
6
|
+
export { define, isObject, isObject as is, isNotEmptyObject, isNotEmptyObject as isNotEmpty, isNotEmptyObject as isNeObject, isNotEmptyObject as isNe, merge, pick };
|
package/object/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pick = exports.merge = exports.isNe = exports.isNeObject = exports.isNotEmpty = exports.isNotEmptyObject = exports.is = exports.isObject = exports.define = void 0;
|
|
4
|
+
const define_1 = require("./define");
|
|
5
|
+
Object.defineProperty(exports, "define", { enumerable: true, get: function () { return define_1.define; } });
|
|
6
|
+
const is_1 = require("./is");
|
|
7
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return is_1.isObject; } });
|
|
8
|
+
Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isObject; } });
|
|
9
|
+
const isNotEmpty_1 = require("./isNotEmpty");
|
|
10
|
+
Object.defineProperty(exports, "isNotEmptyObject", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyObject; } });
|
|
11
|
+
Object.defineProperty(exports, "isNotEmpty", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyObject; } });
|
|
12
|
+
Object.defineProperty(exports, "isNeObject", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyObject; } });
|
|
13
|
+
Object.defineProperty(exports, "isNe", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyObject; } });
|
|
14
|
+
const merge_1 = require("./merge");
|
|
15
|
+
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_1.merge; } });
|
|
16
|
+
const pick_1 = require("./pick");
|
|
17
|
+
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return pick_1.pick; } });
|
package/object/is.d.ts
CHANGED
package/object/is.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.isObject = void 0;
|
|
3
4
|
const PROTO_OBJ = '[object Object]';
|
|
4
5
|
function isObject(val) {
|
|
5
6
|
return Object.prototype.toString.call(val) === PROTO_OBJ;
|
|
6
7
|
}
|
|
8
|
+
exports.isObject = isObject;
|
|
7
9
|
exports.default = isObject;
|
package/object/isNotEmpty.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @returns Whether or not the value is an object with content
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare function isNotEmptyObject(val: unknown): val is {
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
|
+
export { isNotEmptyObject, isNotEmptyObject as default };
|
package/object/isNotEmpty.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.isNotEmptyObject = void 0;
|
|
3
4
|
function isNotEmptyObject(val) {
|
|
4
5
|
return Object.prototype.toString.call(val) === '[object Object]' && Object.keys(val).length > 0;
|
|
5
6
|
}
|
|
7
|
+
exports.isNotEmptyObject = isNotEmptyObject;
|
|
6
8
|
exports.default = isNotEmptyObject;
|
package/object/merge.d.ts
CHANGED
package/object/merge.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.merge = void 0;
|
|
3
4
|
const PROTO_OBJ = '[object Object]';
|
|
4
5
|
function merge(target, source = {}) {
|
|
5
6
|
if (Object.prototype.toString.call(target) !== PROTO_OBJ ||
|
|
@@ -19,4 +20,5 @@ function merge(target, source = {}) {
|
|
|
19
20
|
}
|
|
20
21
|
return acc;
|
|
21
22
|
}
|
|
23
|
+
exports.merge = merge;
|
|
22
24
|
exports.default = merge;
|
package/object/pick.d.ts
CHANGED
package/object/pick.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.pick = void 0;
|
|
3
4
|
const get_1 = require("../deep/get");
|
|
4
5
|
const set_1 = require("../deep/set");
|
|
5
6
|
const RGX_DEEP = /(\.|\[)/;
|
|
@@ -18,10 +19,10 @@ function pick(obj, keys) {
|
|
|
18
19
|
if (!sanitized.length)
|
|
19
20
|
continue;
|
|
20
21
|
if (RGX_DEEP.test(sanitized)) {
|
|
21
|
-
val = (0, get_1.
|
|
22
|
+
val = (0, get_1.deepGet)(obj, sanitized);
|
|
22
23
|
if (val === undefined)
|
|
23
24
|
continue;
|
|
24
|
-
(0, set_1.
|
|
25
|
+
(0, set_1.deepSet)(map, sanitized, val);
|
|
25
26
|
}
|
|
26
27
|
else if (obj[sanitized] !== undefined) {
|
|
27
28
|
map[sanitized] = obj[sanitized];
|
|
@@ -29,4 +30,5 @@ function pick(obj, keys) {
|
|
|
29
30
|
}
|
|
30
31
|
return map;
|
|
31
32
|
}
|
|
33
|
+
exports.pick = pick;
|
|
32
34
|
exports.default = pick;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "@valkyriestudios/utils", "version": "12.
|
|
1
|
+
{ "name": "@valkyriestudios/utils", "version": "12.5.0", "description": "A collection of single-function utilities for common tasks", "author": { "name": "Peter Vermeulen", "url": "https://www.linkedin.com/in/petervermeulen1/" }, "keywords": [ "utility", "library", "javascript", "js", "node", "bun" ], "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/ValkyrieStudios/utils.git" }, "bugs": { "url": "https://github.com/ValkyrieStudios/utils/issues" }, "homepage": "https://github.com/ValkyrieStudios/utils#readme", "types": "index.d.ts" }
|
package/regexp/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitize = exports.sanitizeRegExp = exports.is = exports.isRegExp = void 0;
|
|
4
|
+
const is_1 = require("./is");
|
|
5
|
+
Object.defineProperty(exports, "isRegExp", { enumerable: true, get: function () { return is_1.isRegExp; } });
|
|
6
|
+
Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isRegExp; } });
|
|
7
|
+
const sanitize_1 = require("./sanitize");
|
|
8
|
+
Object.defineProperty(exports, "sanitizeRegExp", { enumerable: true, get: function () { return sanitize_1.sanitizeRegExp; } });
|
|
9
|
+
Object.defineProperty(exports, "sanitize", { enumerable: true, get: function () { return sanitize_1.sanitizeRegExp; } });
|
package/regexp/is.d.ts
CHANGED
package/regexp/is.js
CHANGED
package/regexp/sanitize.d.ts
CHANGED
package/regexp/sanitize.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.sanitizeRegExp = void 0;
|
|
3
4
|
function sanitizeRegExp(val) {
|
|
4
5
|
if (typeof val !== 'string')
|
|
5
6
|
return false;
|
|
6
7
|
return val.trim().replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
|
|
7
8
|
}
|
|
9
|
+
exports.sanitizeRegExp = sanitizeRegExp;
|
|
8
10
|
exports.default = sanitizeRegExp;
|
|
@@ -36,5 +36,5 @@ interface humanizeBytesOptions {
|
|
|
36
36
|
*
|
|
37
37
|
* @returns Humanized byte value as string
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
export {};
|
|
39
|
+
declare function humanizeBytes(val: number | string, options?: humanizeBytesOptions): string;
|
|
40
|
+
export { humanizeBytes, humanizeBytes as default };
|
package/string/humanizeBytes.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.humanizeBytes = void 0;
|
|
3
4
|
const humanizeNumber_1 = require("./humanizeNumber");
|
|
4
|
-
const isNotEmpty_1 = require("../string/isNotEmpty");
|
|
5
5
|
function humanizeBytes(val, options = {}) {
|
|
6
6
|
const has_opts = Object.prototype.toString.call(options) === '[object Object]';
|
|
7
|
-
return (0, humanizeNumber_1.
|
|
7
|
+
return (0, humanizeNumber_1.humanizeNumber)(val, {
|
|
8
8
|
delim: has_opts && typeof options.delim === 'string'
|
|
9
9
|
? options.delim
|
|
10
10
|
: ',',
|
|
@@ -15,10 +15,11 @@ function humanizeBytes(val, options = {}) {
|
|
|
15
15
|
? options.precision
|
|
16
16
|
: 2,
|
|
17
17
|
units: has_opts && Array.isArray(options.units) && options.units.length
|
|
18
|
-
? options.units
|
|
18
|
+
? options.units
|
|
19
19
|
: [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'],
|
|
20
20
|
divider: 1024,
|
|
21
21
|
real: true,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
exports.humanizeBytes = humanizeBytes;
|
|
24
25
|
exports.default = humanizeBytes;
|
|
@@ -48,5 +48,5 @@ interface humanizeNumberOptions {
|
|
|
48
48
|
*
|
|
49
49
|
* @returns Humanized number as string
|
|
50
50
|
*/
|
|
51
|
-
|
|
52
|
-
export {};
|
|
51
|
+
declare function humanizeNumber(val: number | string, options?: humanizeNumberOptions | false): string;
|
|
52
|
+
export { humanizeNumber, humanizeNumber as default };
|
package/string/humanizeNumber.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.humanizeNumber = void 0;
|
|
3
4
|
const round_1 = require("../number/round");
|
|
4
5
|
const DEFAULT_UNITS = ['', 'k', 'm', 'b', 't', 'q'];
|
|
5
6
|
function humanizeNumber(val, options = false) {
|
|
@@ -45,7 +46,7 @@ function humanizeNumber(val, options = false) {
|
|
|
45
46
|
normalized /= DIVIDER;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
const humanized = `${(0, round_1.
|
|
49
|
+
const humanized = `${(0, round_1.round)(normalized, PRECISION)}`.split('.', 2);
|
|
49
50
|
humanized[0] = humanized[0].split('').reverse().map((char, ix, original) => {
|
|
50
51
|
if (ix > 0 && ix < original.length && ix % 3 === 0)
|
|
51
52
|
return char + DELIM;
|
|
@@ -53,4 +54,5 @@ function humanizeNumber(val, options = false) {
|
|
|
53
54
|
}).reverse().join('');
|
|
54
55
|
return `${sign}${humanized.join(SEPARATOR)}${UNITS ? UNITS[unit_ix] : ''}`;
|
|
55
56
|
}
|
|
57
|
+
exports.humanizeNumber = humanizeNumber;
|
|
56
58
|
exports.default = humanizeNumber;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { humanizeBytes } from './humanizeBytes';
|
|
2
|
+
import { humanizeNumber } from './humanizeNumber';
|
|
3
|
+
import { isString } from './is';
|
|
4
|
+
import { isNotEmptyString } from './isNotEmpty';
|
|
5
|
+
import { isStringBetween } from './isBetween';
|
|
6
|
+
import { shorten } from './shorten';
|
|
7
|
+
export { humanizeBytes, humanizeNumber, isString, isString as is, isNotEmptyString, isNotEmptyString as isNotEmpty, isNotEmptyString as isNeString, isNotEmptyString as isNe, isStringBetween, isStringBetween as isBetween, shorten };
|
package/string/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shorten = exports.isBetween = exports.isStringBetween = exports.isNe = exports.isNeString = exports.isNotEmpty = exports.isNotEmptyString = exports.is = exports.isString = exports.humanizeNumber = exports.humanizeBytes = void 0;
|
|
4
|
+
const humanizeBytes_1 = require("./humanizeBytes");
|
|
5
|
+
Object.defineProperty(exports, "humanizeBytes", { enumerable: true, get: function () { return humanizeBytes_1.humanizeBytes; } });
|
|
6
|
+
const humanizeNumber_1 = require("./humanizeNumber");
|
|
7
|
+
Object.defineProperty(exports, "humanizeNumber", { enumerable: true, get: function () { return humanizeNumber_1.humanizeNumber; } });
|
|
8
|
+
const is_1 = require("./is");
|
|
9
|
+
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return is_1.isString; } });
|
|
10
|
+
Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isString; } });
|
|
11
|
+
const isNotEmpty_1 = require("./isNotEmpty");
|
|
12
|
+
Object.defineProperty(exports, "isNotEmptyString", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyString; } });
|
|
13
|
+
Object.defineProperty(exports, "isNotEmpty", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyString; } });
|
|
14
|
+
Object.defineProperty(exports, "isNeString", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyString; } });
|
|
15
|
+
Object.defineProperty(exports, "isNe", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyString; } });
|
|
16
|
+
const isBetween_1 = require("./isBetween");
|
|
17
|
+
Object.defineProperty(exports, "isStringBetween", { enumerable: true, get: function () { return isBetween_1.isStringBetween; } });
|
|
18
|
+
Object.defineProperty(exports, "isBetween", { enumerable: true, get: function () { return isBetween_1.isStringBetween; } });
|
|
19
|
+
const shorten_1 = require("./shorten");
|
|
20
|
+
Object.defineProperty(exports, "shorten", { enumerable: true, get: function () { return shorten_1.shorten; } });
|
package/string/is.d.ts
CHANGED
package/string/is.js
CHANGED
package/string/isBetween.d.ts
CHANGED
|
@@ -10,4 +10,5 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @returns Whether or not the value is a string of length between min and max inclusive
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
declare function isStringBetween(val: unknown, min: number, max: number, trimmed?: boolean): val is string;
|
|
14
|
+
export { isStringBetween, isStringBetween as default };
|
package/string/isBetween.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.isStringBetween = void 0;
|
|
3
4
|
function isStringBetween(val, min, max, trimmed = true) {
|
|
4
5
|
if (typeof val !== 'string' ||
|
|
5
6
|
!Number.isFinite(min) ||
|
|
@@ -11,4 +12,5 @@ function isStringBetween(val, min, max, trimmed = true) {
|
|
|
11
12
|
const length = (trimmed === true ? val.trim() : val).length;
|
|
12
13
|
return length >= min && length <= max;
|
|
13
14
|
}
|
|
15
|
+
exports.isStringBetween = isStringBetween;
|
|
14
16
|
exports.default = isStringBetween;
|
package/string/isNotEmpty.d.ts
CHANGED
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @returns Whether or not the value is a string with content
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
declare function isNotEmptyString(val: unknown, trimmed?: boolean): val is string;
|
|
10
|
+
export { isNotEmptyString, isNotEmptyString as default };
|
package/string/isNotEmpty.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.isNotEmptyString = void 0;
|
|
3
4
|
function isNotEmptyString(val, trimmed = true) {
|
|
4
5
|
if (typeof val !== 'string')
|
|
5
6
|
return false;
|
|
6
7
|
return (trimmed === true ? val.trim() : val).length > 0;
|
|
7
8
|
}
|
|
9
|
+
exports.isNotEmptyString = isNotEmptyString;
|
|
8
10
|
exports.default = isNotEmptyString;
|
package/string/shorten.d.ts
CHANGED
package/string/shorten.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.shorten = void 0;
|
|
3
4
|
function shorten(val, length, postfix = '...') {
|
|
4
5
|
if (typeof val !== 'string')
|
|
5
6
|
return '';
|
|
@@ -8,4 +9,5 @@ function shorten(val, length, postfix = '...') {
|
|
|
8
9
|
const sanitized = val.trim();
|
|
9
10
|
return sanitized.length <= length ? sanitized : `${sanitized.substring(0, length)}${postfix}`;
|
|
10
11
|
}
|
|
12
|
+
exports.shorten = shorten;
|
|
11
13
|
exports.default = shorten;
|