@valkyriestudios/utils 12.36.0 → 12.38.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/array/groupBy.d.ts +3 -3
- package/array/join.d.ts +2 -2
- package/array/split.d.ts +3 -3
- package/caching/LRU.d.ts +16 -10
- package/{array → cjs/array}/groupBy.js +16 -4
- package/{array → cjs/array}/join.js +15 -3
- package/{array → cjs/array}/mapFnAsMap.js +1 -1
- package/{array → cjs/array}/split.js +16 -7
- package/cjs/caching/LRU.js +123 -0
- package/{caching → cjs/caching}/memoize.js +11 -5
- package/{date → cjs/date}/format.js +7 -7
- package/{date → cjs/date}/isFormat.js +5 -2
- package/cjs/formdata/toObject.js +92 -0
- package/{object → cjs/object}/pick.js +2 -2
- package/{string → cjs/string}/humanizeNumber.js +2 -2
- package/cjs/string/isNotEmpty.js +23 -0
- package/{string → cjs/string}/shorten.js +1 -1
- package/esm/array/dedupe.js +52 -0
- package/esm/array/groupBy.js +43 -0
- package/esm/array/index.js +14 -0
- package/esm/array/is.js +4 -0
- package/esm/array/isNotEmpty.js +4 -0
- package/esm/array/join.js +58 -0
- package/esm/array/mapFn.js +22 -0
- package/esm/array/mapFnAsMap.js +21 -0
- package/esm/array/mapKey.js +22 -0
- package/esm/array/mapKeyAsMap.js +22 -0
- package/esm/array/mapPrimitive.js +33 -0
- package/esm/array/shuffle.js +10 -0
- package/esm/array/sort.js +137 -0
- package/esm/array/split.js +43 -0
- package/esm/boolean/index.js +1 -0
- package/esm/boolean/is.js +4 -0
- package/esm/caching/LRU.js +116 -0
- package/esm/caching/index.js +3 -0
- package/esm/caching/memoize.js +37 -0
- package/esm/date/addUTC.js +41 -0
- package/esm/date/convertToDate.js +12 -0
- package/esm/date/diff.js +34 -0
- package/esm/date/endOfUTC.js +50 -0
- package/esm/date/format.js +241 -0
- package/esm/date/index.js +15 -0
- package/esm/date/is.js +4 -0
- package/esm/date/isFormat.js +118 -0
- package/esm/date/isLeap.js +9 -0
- package/esm/date/nowUnix.js +4 -0
- package/esm/date/nowUnixMs.js +4 -0
- package/esm/date/setTimeUTC.js +10 -0
- package/esm/date/startOfUTC.js +50 -0
- package/esm/date/toUTC.js +7 -0
- package/esm/date/toUnix.js +7 -0
- package/esm/deep/freeze.js +21 -0
- package/esm/deep/get.js +84 -0
- package/esm/deep/index.js +8 -0
- package/esm/deep/seal.js +21 -0
- package/esm/deep/set.js +50 -0
- package/esm/equal.js +67 -0
- package/esm/formdata/index.js +2 -0
- package/esm/formdata/is.js +4 -0
- package/esm/formdata/toObject.js +89 -0
- package/esm/function/debounce.js +39 -0
- package/esm/function/index.js +9 -0
- package/esm/function/is.js +4 -0
- package/esm/function/isAsync.js +4 -0
- package/esm/function/noop.js +2 -0
- package/esm/function/noopresolve.js +4 -0
- package/esm/function/noopreturn.js +4 -0
- package/esm/function/sleep.js +6 -0
- package/esm/hash/fnv1A.js +51 -0
- package/esm/hash/guid.js +31 -0
- package/esm/hash/index.js +2 -0
- package/esm/is.js +63 -0
- package/esm/modules/PubSub.js +187 -0
- package/esm/modules/Scheduler.js +343 -0
- package/esm/modules/index.js +2 -0
- package/esm/number/index.js +37 -0
- package/esm/number/is.js +4 -0
- package/esm/number/isAbove.js +4 -0
- package/esm/number/isAboveOrEqual.js +4 -0
- package/esm/number/isBelow.js +4 -0
- package/esm/number/isBelowOrEqual.js +4 -0
- package/esm/number/isBetween.js +7 -0
- package/esm/number/isInteger.js +4 -0
- package/esm/number/isIntegerAbove.js +4 -0
- package/esm/number/isIntegerAboveOrEqual.js +4 -0
- package/esm/number/isIntegerBelow.js +4 -0
- package/esm/number/isIntegerBelowOrEqual.js +4 -0
- package/esm/number/isIntegerBetween.js +7 -0
- package/esm/number/isNumericalNaN.js +4 -0
- package/esm/number/randomBetween.js +7 -0
- package/esm/number/randomIntBetween.js +7 -0
- package/esm/number/round.js +10 -0
- package/esm/number/toPercentage.js +9 -0
- package/esm/object/define.js +7 -0
- package/esm/object/index.js +7 -0
- package/esm/object/is.js +4 -0
- package/esm/object/isNotEmpty.js +9 -0
- package/esm/object/merge.js +31 -0
- package/esm/object/omit.js +30 -0
- package/esm/object/pick.js +33 -0
- package/esm/regexp/index.js +3 -0
- package/esm/regexp/is.js +4 -0
- package/esm/regexp/sanitize.js +7 -0
- package/esm/string/humanizeBytes.js +15 -0
- package/esm/string/humanizeNumber.js +40 -0
- package/esm/string/index.js +7 -0
- package/esm/string/is.js +4 -0
- package/esm/string/isBetween.js +12 -0
- package/esm/string/isNotEmpty.js +20 -0
- package/esm/string/shorten.js +18 -0
- package/formdata/toObject.d.ts +4 -0
- package/index.d.ts +20 -15
- package/package.json +193 -851
- package/caching/LRU.js +0 -72
- package/formdata/toObject.js +0 -70
- package/string/isNotEmpty.js +0 -9
- /package/{array → cjs/array}/dedupe.js +0 -0
- /package/{array → cjs/array}/index.js +0 -0
- /package/{array → cjs/array}/is.js +0 -0
- /package/{array → cjs/array}/isNotEmpty.js +0 -0
- /package/{array → cjs/array}/mapFn.js +0 -0
- /package/{array → cjs/array}/mapKey.js +0 -0
- /package/{array → cjs/array}/mapKeyAsMap.js +0 -0
- /package/{array → cjs/array}/mapPrimitive.js +0 -0
- /package/{array → cjs/array}/shuffle.js +0 -0
- /package/{array → cjs/array}/sort.js +0 -0
- /package/{boolean → cjs/boolean}/index.js +0 -0
- /package/{boolean → cjs/boolean}/is.js +0 -0
- /package/{caching → cjs/caching}/index.js +0 -0
- /package/{date → cjs/date}/addUTC.js +0 -0
- /package/{date → cjs/date}/convertToDate.js +0 -0
- /package/{date → cjs/date}/diff.js +0 -0
- /package/{date → cjs/date}/endOfUTC.js +0 -0
- /package/{date → cjs/date}/index.js +0 -0
- /package/{date → cjs/date}/is.js +0 -0
- /package/{date → cjs/date}/isLeap.js +0 -0
- /package/{date → cjs/date}/nowUnix.js +0 -0
- /package/{date → cjs/date}/nowUnixMs.js +0 -0
- /package/{date → cjs/date}/setTimeUTC.js +0 -0
- /package/{date → cjs/date}/startOfUTC.js +0 -0
- /package/{date → cjs/date}/toUTC.js +0 -0
- /package/{date → cjs/date}/toUnix.js +0 -0
- /package/{deep → cjs/deep}/freeze.js +0 -0
- /package/{deep → cjs/deep}/get.js +0 -0
- /package/{deep → cjs/deep}/index.js +0 -0
- /package/{deep → cjs/deep}/seal.js +0 -0
- /package/{deep → cjs/deep}/set.js +0 -0
- /package/{equal.js → cjs/equal.js} +0 -0
- /package/{formdata → cjs/formdata}/index.js +0 -0
- /package/{formdata → cjs/formdata}/is.js +0 -0
- /package/{function → cjs/function}/debounce.js +0 -0
- /package/{function → cjs/function}/index.js +0 -0
- /package/{function → cjs/function}/is.js +0 -0
- /package/{function → cjs/function}/isAsync.js +0 -0
- /package/{function → cjs/function}/noop.js +0 -0
- /package/{function → cjs/function}/noopresolve.js +0 -0
- /package/{function → cjs/function}/noopreturn.js +0 -0
- /package/{function → cjs/function}/sleep.js +0 -0
- /package/{hash → cjs/hash}/fnv1A.js +0 -0
- /package/{hash → cjs/hash}/guid.js +0 -0
- /package/{hash → cjs/hash}/index.js +0 -0
- /package/{is.js → cjs/is.js} +0 -0
- /package/{modules → cjs/modules}/PubSub.js +0 -0
- /package/{modules → cjs/modules}/Scheduler.js +0 -0
- /package/{modules → cjs/modules}/index.js +0 -0
- /package/{number → cjs/number}/index.js +0 -0
- /package/{number → cjs/number}/is.js +0 -0
- /package/{number → cjs/number}/isAbove.js +0 -0
- /package/{number → cjs/number}/isAboveOrEqual.js +0 -0
- /package/{number → cjs/number}/isBelow.js +0 -0
- /package/{number → cjs/number}/isBelowOrEqual.js +0 -0
- /package/{number → cjs/number}/isBetween.js +0 -0
- /package/{number → cjs/number}/isInteger.js +0 -0
- /package/{number → cjs/number}/isIntegerAbove.js +0 -0
- /package/{number → cjs/number}/isIntegerAboveOrEqual.js +0 -0
- /package/{number → cjs/number}/isIntegerBelow.js +0 -0
- /package/{number → cjs/number}/isIntegerBelowOrEqual.js +0 -0
- /package/{number → cjs/number}/isIntegerBetween.js +0 -0
- /package/{number → cjs/number}/isNumericalNaN.js +0 -0
- /package/{number → cjs/number}/randomBetween.js +0 -0
- /package/{number → cjs/number}/randomIntBetween.js +0 -0
- /package/{number → cjs/number}/round.js +0 -0
- /package/{number → cjs/number}/toPercentage.js +0 -0
- /package/{object → cjs/object}/define.js +0 -0
- /package/{object → cjs/object}/index.js +0 -0
- /package/{object → cjs/object}/is.js +0 -0
- /package/{object → cjs/object}/isNotEmpty.js +0 -0
- /package/{object → cjs/object}/merge.js +0 -0
- /package/{object → cjs/object}/omit.js +0 -0
- /package/{regexp → cjs/regexp}/index.js +0 -0
- /package/{regexp → cjs/regexp}/is.js +0 -0
- /package/{regexp → cjs/regexp}/sanitize.js +0 -0
- /package/{string → cjs/string}/humanizeBytes.js +0 -0
- /package/{string → cjs/string}/index.js +0 -0
- /package/{string → cjs/string}/is.js +0 -0
- /package/{string → cjs/string}/isBetween.js +0 -0
package/caching/LRU.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _LRUCache_cache, _LRUCache_max_size;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.default = exports.LRUCache = void 0;
|
|
16
|
-
const is_1 = require("../object/is");
|
|
17
|
-
const isIntegerAbove_1 = require("../number/isIntegerAbove");
|
|
18
|
-
class LRUCache {
|
|
19
|
-
constructor(opts = {}) {
|
|
20
|
-
_LRUCache_cache.set(this, void 0);
|
|
21
|
-
_LRUCache_max_size.set(this, void 0);
|
|
22
|
-
const { max_size = 100 } = (0, is_1.default)(opts) ? opts : {};
|
|
23
|
-
__classPrivateFieldSet(this, _LRUCache_cache, new Map(), "f");
|
|
24
|
-
__classPrivateFieldSet(this, _LRUCache_max_size, (0, isIntegerAbove_1.default)(max_size, 0) ? max_size : 100, "f");
|
|
25
|
-
}
|
|
26
|
-
get max_size() {
|
|
27
|
-
return __classPrivateFieldGet(this, _LRUCache_max_size, "f");
|
|
28
|
-
}
|
|
29
|
-
set max_size(max_size) {
|
|
30
|
-
if (!(0, isIntegerAbove_1.default)(max_size, 0))
|
|
31
|
-
throw new Error('max_size must be a positive integer');
|
|
32
|
-
__classPrivateFieldSet(this, _LRUCache_max_size, max_size, "f");
|
|
33
|
-
if (__classPrivateFieldGet(this, _LRUCache_cache, "f").size > max_size) {
|
|
34
|
-
const excess = __classPrivateFieldGet(this, _LRUCache_cache, "f").size - max_size;
|
|
35
|
-
const keys = [...__classPrivateFieldGet(this, _LRUCache_cache, "f").keys()];
|
|
36
|
-
for (let i = 0; i < excess; i++) {
|
|
37
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(keys[i]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
has(key) {
|
|
42
|
-
return __classPrivateFieldGet(this, _LRUCache_cache, "f").has(key);
|
|
43
|
-
}
|
|
44
|
-
get(key) {
|
|
45
|
-
const value = __classPrivateFieldGet(this, _LRUCache_cache, "f").get(key);
|
|
46
|
-
if (value === undefined)
|
|
47
|
-
return undefined;
|
|
48
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
49
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").set(key, value);
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
set(key, value) {
|
|
53
|
-
if (__classPrivateFieldGet(this, _LRUCache_cache, "f").has(key)) {
|
|
54
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
55
|
-
}
|
|
56
|
-
else if (__classPrivateFieldGet(this, _LRUCache_cache, "f").size >= this.max_size) {
|
|
57
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(__classPrivateFieldGet(this, _LRUCache_cache, "f").keys().next().value);
|
|
58
|
-
}
|
|
59
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").set(key, value);
|
|
60
|
-
}
|
|
61
|
-
del(key) {
|
|
62
|
-
if (key === undefined || !__classPrivateFieldGet(this, _LRUCache_cache, "f").has(key))
|
|
63
|
-
return;
|
|
64
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
65
|
-
}
|
|
66
|
-
clear() {
|
|
67
|
-
__classPrivateFieldGet(this, _LRUCache_cache, "f").clear();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.LRUCache = LRUCache;
|
|
71
|
-
exports.default = LRUCache;
|
|
72
|
-
_LRUCache_cache = new WeakMap(), _LRUCache_max_size = new WeakMap();
|
package/formdata/toObject.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toObject = toObject;
|
|
4
|
-
exports.default = toObject;
|
|
5
|
-
const isFormat_1 = require("../date/isFormat");
|
|
6
|
-
const RGX_TOKENS = /[^.[\]]+/g;
|
|
7
|
-
function assign(acc, rawkey, value, single) {
|
|
8
|
-
let cursor = acc;
|
|
9
|
-
const keys = rawkey.match(RGX_TOKENS);
|
|
10
|
-
const keys_len = keys.length;
|
|
11
|
-
for (let i = 0; i < keys_len; i++) {
|
|
12
|
-
const key = keys[i];
|
|
13
|
-
if (i < (keys_len - 1)) {
|
|
14
|
-
const n_key = Array.isArray(cursor) ? Number(key) : key;
|
|
15
|
-
if (!cursor[n_key])
|
|
16
|
-
cursor[n_key] = Number.isInteger(+keys[i + 1]) ? [] : {};
|
|
17
|
-
cursor = cursor[n_key];
|
|
18
|
-
}
|
|
19
|
-
else if (!(key in cursor) || single.has(key)) {
|
|
20
|
-
cursor[key] = value;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const cursor_val = cursor[key];
|
|
24
|
-
if (Array.isArray(cursor_val)) {
|
|
25
|
-
cursor_val.push(value);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
cursor[key] = [cursor_val, value];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function toObject(form, config) {
|
|
34
|
-
if (!(form instanceof FormData))
|
|
35
|
-
throw new Error('formdata/toObject: Value is not an instance of FormData');
|
|
36
|
-
const set = config?.raw === true ? true : new Set(Array.isArray(config?.raw) ? config?.raw : []);
|
|
37
|
-
const single = new Set(Array.isArray(config?.single) ? config.single : []);
|
|
38
|
-
const nBool = config?.normalize_bool !== false;
|
|
39
|
-
const nDate = config?.normalize_date !== false;
|
|
40
|
-
const nNumber = config?.normalize_number !== false;
|
|
41
|
-
const acc = {};
|
|
42
|
-
form.forEach((value, key) => {
|
|
43
|
-
if (set !== true && value !== '' && typeof value === 'string' && !set.has(key)) {
|
|
44
|
-
if (nBool) {
|
|
45
|
-
switch (value) {
|
|
46
|
-
case 'true':
|
|
47
|
-
case 'TRUE':
|
|
48
|
-
case 'True':
|
|
49
|
-
return assign(acc, key, true, single);
|
|
50
|
-
case 'false':
|
|
51
|
-
case 'FALSE':
|
|
52
|
-
case 'False':
|
|
53
|
-
return assign(acc, key, false, single);
|
|
54
|
-
default:
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (nNumber) {
|
|
59
|
-
const nVal = Number(value);
|
|
60
|
-
if (!isNaN(nVal))
|
|
61
|
-
return assign(acc, key, nVal, single);
|
|
62
|
-
}
|
|
63
|
-
if (nDate &&
|
|
64
|
-
(0, isFormat_1.isDateFormat)(value, 'ISO'))
|
|
65
|
-
return assign(acc, key, new Date(value), single);
|
|
66
|
-
}
|
|
67
|
-
assign(acc, key, value, single);
|
|
68
|
-
});
|
|
69
|
-
return acc;
|
|
70
|
-
}
|
package/string/isNotEmpty.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNotEmptyString = isNotEmptyString;
|
|
4
|
-
exports.default = isNotEmptyString;
|
|
5
|
-
function isNotEmptyString(val, trimmed = true) {
|
|
6
|
-
if (typeof val !== 'string')
|
|
7
|
-
return false;
|
|
8
|
-
return (trimmed === true ? val.trim() : val).length > 0;
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{date → cjs/date}/is.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{is.js → cjs/is.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|