vest-utils 0.0.1-rc → 0.0.4-dev-afe5de
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/dist/cjs/vest-utils.development.js +348 -0
- package/dist/cjs/vest-utils.production.js +1 -1
- package/dist/es/vest-utils.development.js +305 -0
- package/dist/es/vest-utils.production.js +1 -1
- package/dist/umd/vest-utils.development.js +352 -4
- package/dist/umd/vest-utils.production.js +1 -1
- package/package.json +4 -662
- package/src/{exports/__tests__ → __tests__}/bindNot.test.ts +1 -1
- package/src/{exports/__tests__ → __tests__}/bus.test.ts +0 -0
- package/src/{exports/__tests__ → __tests__}/cache.test.ts +1 -1
- package/src/{exports/__tests__ → __tests__}/defaultTo.test.ts +1 -1
- package/src/{exports/__tests__ → __tests__}/genId.test.ts +0 -0
- package/src/__tests__/greaterThan.test.ts +59 -0
- package/src/{exports/__tests__ → __tests__}/invariant.test.ts +1 -1
- package/src/__tests__/isArray.test.ts +15 -0
- package/src/__tests__/isNull.test.ts +25 -0
- package/src/__tests__/isNumeric.test.ts +26 -0
- package/src/__tests__/isUndefined.test.ts +26 -0
- package/src/__tests__/lengthEquals.test.ts +56 -0
- package/src/__tests__/longerThan.test.ts +56 -0
- package/src/{exports/__tests__ → __tests__}/mapFirst.test.ts +1 -1
- package/src/__tests__/numberEquals.test.ts +59 -0
- package/src/{exports/__tests__ → __tests__}/optionalFunctionValue.test.ts +1 -1
- package/src/{exports/__tests__ → __tests__}/partition.test.ts +1 -1
- package/src/{exports/__tests__ → __tests__}/throwError.test.ts +1 -1
- package/src/{exports/asArray.ts → asArray.ts} +0 -0
- package/src/{exports/assign.ts → assign.ts} +0 -0
- package/src/{exports/bindNot.ts → bindNot.ts} +0 -0
- package/src/{exports/bus.ts → bus.ts} +0 -0
- package/src/{exports/cache.ts → cache.ts} +0 -0
- package/src/{exports/callEach.ts → callEach.ts} +0 -0
- package/src/{exports/defaultTo.ts → defaultTo.ts} +0 -0
- package/src/{exports/throwError.ts → deferThrow.ts} +1 -1
- package/src/{exports/either.ts → either.ts} +0 -0
- package/src/{exports/genId.ts → genId.ts} +0 -0
- package/src/globals.d.ts +3 -3
- package/src/greaterThan.ts +8 -0
- package/src/{exports/hasOwnProperty.ts → hasOwnProperty.ts} +0 -0
- package/src/{exports/invariant.ts → invariant.ts} +0 -0
- package/src/isArrayValue.ts +11 -0
- package/src/isBooleanValue.ts +3 -0
- package/src/isEmpty.ts +17 -0
- package/src/{exports/isFunction.ts → isFunction.ts} +0 -0
- package/src/isNull.ts +7 -0
- package/src/{exports/isNullish.ts → isNullish.ts} +1 -2
- package/src/isNumeric.ts +11 -0
- package/src/isPositive.ts +5 -0
- package/src/{exports/isPromise.ts → isPromise.ts} +0 -0
- package/src/isStringValue.ts +3 -0
- package/src/isUndefined.ts +7 -0
- package/src/{exports/last.ts → last.ts} +0 -0
- package/src/lengthEquals.ts +11 -0
- package/src/longerThan.ts +8 -0
- package/src/{exports/mapFirst.ts → mapFirst.ts} +0 -0
- package/src/{exports/nestedArray.ts → nestedArray.ts} +2 -3
- package/src/numberEquals.ts +11 -0
- package/src/{exports/optionalFunctionValue.ts → optionalFunctionValue.ts} +1 -1
- package/src/{exports/partition.ts → partition.ts} +0 -0
- package/src/vest-utils.ts +32 -0
- package/types/vest-utils.d.ts +96 -1
- package/asArray/package.json +0 -9
- package/assign/package.json +0 -9
- package/bindNot/package.json +0 -9
- package/bus/package.json +0 -9
- package/cache/package.json +0 -9
- package/callEach/package.json +0 -9
- package/defaultTo/package.json +0 -9
- package/dist/cjs/asArray.development.js +0 -7
- package/dist/cjs/asArray.js +0 -7
- package/dist/cjs/asArray.production.js +0 -1
- package/dist/cjs/assign.development.js +0 -5
- package/dist/cjs/assign.js +0 -7
- package/dist/cjs/assign.production.js +0 -1
- package/dist/cjs/bindNot.development.js +0 -13
- package/dist/cjs/bindNot.js +0 -7
- package/dist/cjs/bindNot.production.js +0 -1
- package/dist/cjs/bus.development.js +0 -27
- package/dist/cjs/bus.js +0 -7
- package/dist/cjs/bus.production.js +0 -1
- package/dist/cjs/cache.development.js +0 -72
- package/dist/cjs/cache.js +0 -7
- package/dist/cjs/cache.production.js +0 -1
- package/dist/cjs/callEach.development.js +0 -7
- package/dist/cjs/callEach.js +0 -7
- package/dist/cjs/callEach.production.js +0 -1
- package/dist/cjs/defaultTo.development.js +0 -20
- package/dist/cjs/defaultTo.js +0 -7
- package/dist/cjs/defaultTo.production.js +0 -1
- package/dist/cjs/either.development.js +0 -7
- package/dist/cjs/either.js +0 -7
- package/dist/cjs/either.production.js +0 -1
- package/dist/cjs/genId.development.js +0 -10
- package/dist/cjs/genId.js +0 -7
- package/dist/cjs/genId.production.js +0 -1
- package/dist/cjs/hasOwnProperty.development.js +0 -10
- package/dist/cjs/hasOwnProperty.js +0 -7
- package/dist/cjs/hasOwnProperty.production.js +0 -1
- package/dist/cjs/invariant.development.js +0 -36
- package/dist/cjs/invariant.js +0 -7
- package/dist/cjs/invariant.production.js +0 -1
- package/dist/cjs/isBooleanValue.development.js +0 -9
- package/dist/cjs/isBooleanValue.js +0 -7
- package/dist/cjs/isBooleanValue.production.js +0 -1
- package/dist/cjs/isFunction.development.js +0 -7
- package/dist/cjs/isFunction.js +0 -7
- package/dist/cjs/isFunction.production.js +0 -1
- package/dist/cjs/isNullish.development.js +0 -37
- package/dist/cjs/isNullish.js +0 -7
- package/dist/cjs/isNullish.production.js +0 -1
- package/dist/cjs/isPromise.development.js +0 -11
- package/dist/cjs/isPromise.js +0 -7
- package/dist/cjs/isPromise.production.js +0 -1
- package/dist/cjs/isStringValue.development.js +0 -9
- package/dist/cjs/isStringValue.js +0 -7
- package/dist/cjs/isStringValue.production.js +0 -1
- package/dist/cjs/last.development.js +0 -12
- package/dist/cjs/last.js +0 -7
- package/dist/cjs/last.production.js +0 -1
- package/dist/cjs/mapFirst.development.js +0 -20
- package/dist/cjs/mapFirst.js +0 -7
- package/dist/cjs/mapFirst.production.js +0 -1
- package/dist/cjs/nestedArray.development.js +0 -99
- package/dist/cjs/nestedArray.js +0 -7
- package/dist/cjs/nestedArray.production.js +0 -1
- package/dist/cjs/optionalFunctionValue.development.js +0 -15
- package/dist/cjs/optionalFunctionValue.js +0 -7
- package/dist/cjs/optionalFunctionValue.production.js +0 -1
- package/dist/cjs/partition.development.js +0 -10
- package/dist/cjs/partition.js +0 -7
- package/dist/cjs/partition.production.js +0 -1
- package/dist/cjs/throwError.development.js +0 -11
- package/dist/cjs/throwError.js +0 -7
- package/dist/cjs/throwError.production.js +0 -1
- package/dist/es/asArray.development.js +0 -5
- package/dist/es/asArray.production.js +0 -1
- package/dist/es/assign.development.js +0 -3
- package/dist/es/assign.production.js +0 -1
- package/dist/es/bindNot.development.js +0 -11
- package/dist/es/bindNot.production.js +0 -1
- package/dist/es/bus.development.js +0 -23
- package/dist/es/bus.production.js +0 -1
- package/dist/es/cache.development.js +0 -66
- package/dist/es/cache.production.js +0 -1
- package/dist/es/callEach.development.js +0 -5
- package/dist/es/callEach.production.js +0 -1
- package/dist/es/defaultTo.development.js +0 -18
- package/dist/es/defaultTo.production.js +0 -1
- package/dist/es/either.development.js +0 -5
- package/dist/es/either.production.js +0 -1
- package/dist/es/genId.development.js +0 -8
- package/dist/es/genId.production.js +0 -1
- package/dist/es/hasOwnProperty.development.js +0 -8
- package/dist/es/hasOwnProperty.production.js +0 -1
- package/dist/es/invariant.development.js +0 -32
- package/dist/es/invariant.production.js +0 -1
- package/dist/es/isBooleanValue.development.js +0 -5
- package/dist/es/isBooleanValue.production.js +0 -1
- package/dist/es/isFunction.development.js +0 -5
- package/dist/es/isFunction.production.js +0 -1
- package/dist/es/isNullish.development.js +0 -28
- package/dist/es/isNullish.production.js +0 -1
- package/dist/es/isPromise.development.js +0 -9
- package/dist/es/isPromise.production.js +0 -1
- package/dist/es/isStringValue.development.js +0 -5
- package/dist/es/isStringValue.production.js +0 -1
- package/dist/es/last.development.js +0 -10
- package/dist/es/last.production.js +0 -1
- package/dist/es/mapFirst.development.js +0 -18
- package/dist/es/mapFirst.production.js +0 -1
- package/dist/es/nestedArray.development.js +0 -87
- package/dist/es/nestedArray.production.js +0 -1
- package/dist/es/optionalFunctionValue.development.js +0 -13
- package/dist/es/optionalFunctionValue.production.js +0 -1
- package/dist/es/partition.development.js +0 -8
- package/dist/es/partition.production.js +0 -1
- package/dist/es/throwError.development.js +0 -7
- package/dist/es/throwError.production.js +0 -1
- package/dist/umd/asArray.development.js +0 -13
- package/dist/umd/asArray.production.js +0 -1
- package/dist/umd/assign.development.js +0 -11
- package/dist/umd/assign.production.js +0 -1
- package/dist/umd/bindNot.development.js +0 -19
- package/dist/umd/bindNot.production.js +0 -1
- package/dist/umd/bus.development.js +0 -33
- package/dist/umd/bus.production.js +0 -1
- package/dist/umd/cache.development.js +0 -76
- package/dist/umd/cache.production.js +0 -1
- package/dist/umd/callEach.development.js +0 -13
- package/dist/umd/callEach.production.js +0 -1
- package/dist/umd/defaultTo.development.js +0 -26
- package/dist/umd/defaultTo.production.js +0 -1
- package/dist/umd/either.development.js +0 -13
- package/dist/umd/either.production.js +0 -1
- package/dist/umd/genId.development.js +0 -16
- package/dist/umd/genId.production.js +0 -1
- package/dist/umd/hasOwnProperty.development.js +0 -16
- package/dist/umd/hasOwnProperty.production.js +0 -1
- package/dist/umd/invariant.development.js +0 -42
- package/dist/umd/invariant.production.js +0 -1
- package/dist/umd/isBooleanValue.development.js +0 -15
- package/dist/umd/isBooleanValue.production.js +0 -1
- package/dist/umd/isFunction.development.js +0 -13
- package/dist/umd/isFunction.production.js +0 -1
- package/dist/umd/isNullish.development.js +0 -41
- package/dist/umd/isNullish.production.js +0 -1
- package/dist/umd/isPromise.development.js +0 -17
- package/dist/umd/isPromise.production.js +0 -1
- package/dist/umd/isStringValue.development.js +0 -15
- package/dist/umd/isStringValue.production.js +0 -1
- package/dist/umd/last.development.js +0 -18
- package/dist/umd/last.production.js +0 -1
- package/dist/umd/mapFirst.development.js +0 -26
- package/dist/umd/mapFirst.production.js +0 -1
- package/dist/umd/nestedArray.development.js +0 -103
- package/dist/umd/nestedArray.production.js +0 -1
- package/dist/umd/optionalFunctionValue.development.js +0 -21
- package/dist/umd/optionalFunctionValue.production.js +0 -1
- package/dist/umd/partition.development.js +0 -16
- package/dist/umd/partition.production.js +0 -1
- package/dist/umd/throwError.development.js +0 -17
- package/dist/umd/throwError.production.js +0 -1
- package/either/package.json +0 -9
- package/genId/package.json +0 -9
- package/hasOwnProperty/package.json +0 -9
- package/invariant/package.json +0 -9
- package/isBooleanValue/package.json +0 -9
- package/isFunction/package.json +0 -9
- package/isNullish/package.json +0 -9
- package/isPromise/package.json +0 -9
- package/isStringValue/package.json +0 -9
- package/last/package.json +0 -9
- package/mapFirst/package.json +0 -9
- package/nestedArray/package.json +0 -9
- package/optionalFunctionValue/package.json +0 -9
- package/partition/package.json +0 -9
- package/src/exports/isBooleanValue.ts +0 -3
- package/src/exports/isStringValue.ts +0 -3
- package/throwError/package.json +0 -9
- package/tsconfig.json +0 -6
- package/types/asArray.d.ts +0 -2
- package/types/assign.d.ts +0 -7
- package/types/bindNot.d.ts +0 -2
- package/types/bus.d.ts +0 -9
- package/types/cache.d.ts +0 -9
- package/types/callEach.d.ts +0 -2
- package/types/defaultTo.d.ts +0 -2
- package/types/either.d.ts +0 -2
- package/types/genId.d.ts +0 -5
- package/types/hasOwnProperty.d.ts +0 -5
- package/types/invariant.d.ts +0 -4
- package/types/isBooleanValue.d.ts +0 -2
- package/types/isFunction.d.ts +0 -2
- package/types/isNullish.d.ts +0 -3
- package/types/isPromise.d.ts +0 -2
- package/types/isStringValue.d.ts +0 -2
- package/types/last.d.ts +0 -2
- package/types/mapFirst.d.ts +0 -2
- package/types/nestedArray.d.ts +0 -7
- package/types/optionalFunctionValue.d.ts +0 -2
- package/types/partition.d.ts +0 -5
- package/types/throwError.d.ts +0 -2
- package/types/utilityTypes.d.ts +0 -8
- package/types/vest-utilities.d.ts +0 -1
- package/utilityTypes/package.json +0 -9
|
@@ -1,2 +1,350 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function bindNot(fn) {
|
|
6
|
+
return function () {
|
|
7
|
+
var args = [];
|
|
8
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9
|
+
args[_i] = arguments[_i];
|
|
10
|
+
}
|
|
11
|
+
return !fn.apply(void 0, args);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isNumeric(value) {
|
|
16
|
+
var str = String(value);
|
|
17
|
+
var num = Number(value);
|
|
18
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
19
|
+
return Boolean(result);
|
|
20
|
+
}
|
|
21
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
22
|
+
|
|
23
|
+
function numberEquals(value, eq) {
|
|
24
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
25
|
+
}
|
|
26
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
27
|
+
|
|
28
|
+
function lengthEquals(value, arg1) {
|
|
29
|
+
return numberEquals(value.length, arg1);
|
|
30
|
+
}
|
|
31
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
32
|
+
|
|
33
|
+
function greaterThan(value, gt) {
|
|
34
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function longerThan(value, arg1) {
|
|
38
|
+
return greaterThan(value.length, arg1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a cache function
|
|
43
|
+
*/
|
|
44
|
+
function createCache(maxSize) {
|
|
45
|
+
if (maxSize === void 0) { maxSize = 1; }
|
|
46
|
+
var cacheStorage = [];
|
|
47
|
+
var cache = function (deps, cacheAction) {
|
|
48
|
+
var cacheHit = cache.get(deps);
|
|
49
|
+
// cache hit is not null
|
|
50
|
+
if (cacheHit)
|
|
51
|
+
return cacheHit[1];
|
|
52
|
+
var result = cacheAction();
|
|
53
|
+
cacheStorage.unshift([deps.concat(), result]);
|
|
54
|
+
if (longerThan(cacheStorage, maxSize))
|
|
55
|
+
cacheStorage.length = maxSize;
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
// invalidate an item in the cache by its dependencies
|
|
59
|
+
cache.invalidate = function (deps) {
|
|
60
|
+
var index = findIndex(deps);
|
|
61
|
+
if (index > -1)
|
|
62
|
+
cacheStorage.splice(index, 1);
|
|
63
|
+
};
|
|
64
|
+
// Retrieves an item from the cache.
|
|
65
|
+
cache.get = function (deps) {
|
|
66
|
+
return cacheStorage[findIndex(deps)] || null;
|
|
67
|
+
};
|
|
68
|
+
return cache;
|
|
69
|
+
function findIndex(deps) {
|
|
70
|
+
return cacheStorage.findIndex(function (_a) {
|
|
71
|
+
var cachedDeps = _a[0];
|
|
72
|
+
return lengthEquals(deps, cachedDeps.length) &&
|
|
73
|
+
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isNull(value) {
|
|
79
|
+
return value === null;
|
|
80
|
+
}
|
|
81
|
+
var isNotNull = bindNot(isNull);
|
|
82
|
+
|
|
83
|
+
function isUndefined(value) {
|
|
84
|
+
return value === undefined;
|
|
85
|
+
}
|
|
86
|
+
var isNotUndefined = bindNot(isUndefined);
|
|
87
|
+
|
|
88
|
+
function isNullish(value) {
|
|
89
|
+
return isNull(value) || isUndefined(value);
|
|
90
|
+
}
|
|
91
|
+
var isNotNullish = bindNot(isNullish);
|
|
92
|
+
|
|
93
|
+
function asArray(possibleArg) {
|
|
94
|
+
return [].concat(possibleArg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isFunction(value) {
|
|
98
|
+
return typeof value === 'function';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function optionalFunctionValue(value) {
|
|
102
|
+
var args = [];
|
|
103
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
104
|
+
args[_i - 1] = arguments[_i];
|
|
105
|
+
}
|
|
106
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function defaultTo(value, defaultValue) {
|
|
110
|
+
var _a;
|
|
111
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// The module is named "isArrayValue" since it
|
|
115
|
+
// is conflicting with a nested npm dependency.
|
|
116
|
+
// We may need to revisit this in the future.
|
|
117
|
+
function isArray(value) {
|
|
118
|
+
return Boolean(Array.isArray(value));
|
|
119
|
+
}
|
|
120
|
+
var isNotArray = bindNot(isArray);
|
|
121
|
+
|
|
122
|
+
function last(values) {
|
|
123
|
+
var valuesArray = asArray(values);
|
|
124
|
+
return valuesArray[valuesArray.length - 1];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// This is kind of a map/filter in one function.
|
|
128
|
+
// Normally, behaves like a nested-array map,
|
|
129
|
+
// but returning `null` will drop the element from the array
|
|
130
|
+
function transform(array, cb) {
|
|
131
|
+
var res = [];
|
|
132
|
+
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
133
|
+
var v = array_1[_i];
|
|
134
|
+
if (isArray(v)) {
|
|
135
|
+
res.push(transform(v, cb));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
var output = cb(v);
|
|
139
|
+
if (isNotNull(output)) {
|
|
140
|
+
res.push(output);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return res;
|
|
145
|
+
}
|
|
146
|
+
function valueAtPath(array, path) {
|
|
147
|
+
return getCurrent(array, path)[last(path)];
|
|
148
|
+
}
|
|
149
|
+
function setValueAtPath(array, path, value) {
|
|
150
|
+
var current = getCurrent(array, path);
|
|
151
|
+
current[last(path)] = value;
|
|
152
|
+
return array;
|
|
153
|
+
}
|
|
154
|
+
function flatten(values) {
|
|
155
|
+
return asArray(values).reduce(function (acc, value) {
|
|
156
|
+
if (isArray(value)) {
|
|
157
|
+
return acc.concat(flatten(value));
|
|
158
|
+
}
|
|
159
|
+
return asArray(acc).concat(value);
|
|
160
|
+
}, []);
|
|
161
|
+
}
|
|
162
|
+
function getCurrent(array, path) {
|
|
163
|
+
var current = array;
|
|
164
|
+
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
165
|
+
var p = _a[_i];
|
|
166
|
+
current[p] = defaultTo(current[p], []);
|
|
167
|
+
current = current[p];
|
|
168
|
+
}
|
|
169
|
+
return current;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var nestedArray = /*#__PURE__*/Object.freeze({
|
|
173
|
+
__proto__: null,
|
|
174
|
+
transform: transform,
|
|
175
|
+
valueAtPath: valueAtPath,
|
|
176
|
+
setValueAtPath: setValueAtPath,
|
|
177
|
+
flatten: flatten,
|
|
178
|
+
getCurrent: getCurrent
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
function callEach(arr) {
|
|
182
|
+
return arr.forEach(function (fn) { return fn(); });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* A safe hasOwnProperty access
|
|
187
|
+
*/
|
|
188
|
+
function hasOwnProperty(obj, key) {
|
|
189
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function isPromise(value) {
|
|
193
|
+
return value && isFunction(value.then);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var assign = Object.assign;
|
|
197
|
+
|
|
198
|
+
function invariant(condition,
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
200
|
+
message) {
|
|
201
|
+
if (condition) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// If message is a string object (rather than string literal)
|
|
205
|
+
// Throw the value directly as a string
|
|
206
|
+
// Alternatively, throw an error with the message
|
|
207
|
+
throw message instanceof String
|
|
208
|
+
? message.valueOf()
|
|
209
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
210
|
+
}
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
212
|
+
function StringObject(value) {
|
|
213
|
+
return new String(optionalFunctionValue(value));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function isStringValue(v) {
|
|
217
|
+
return String(v) === v;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function partition(array, predicate) {
|
|
221
|
+
return array.reduce(function (partitions, value, number) {
|
|
222
|
+
partitions[predicate(value, number, array) ? 0 : 1].push(value);
|
|
223
|
+
return partitions;
|
|
224
|
+
}, [[], []]);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function either(a, b) {
|
|
228
|
+
return !!a !== !!b;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function isBoolean(value) {
|
|
232
|
+
return !!value === value;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function deferThrow(message) {
|
|
236
|
+
setTimeout(function () {
|
|
237
|
+
throw new Error(message);
|
|
238
|
+
}, 0);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function createBus() {
|
|
242
|
+
var listeners = {};
|
|
243
|
+
return {
|
|
244
|
+
emit: function (event, data) {
|
|
245
|
+
listener(event).forEach(function (handler) {
|
|
246
|
+
handler(data);
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
on: function (event, handler) {
|
|
250
|
+
listeners[event] = listener(event).concat(handler);
|
|
251
|
+
return {
|
|
252
|
+
off: function () {
|
|
253
|
+
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
function listener(event) {
|
|
259
|
+
return listeners[event] || [];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
var bus = /*#__PURE__*/Object.freeze({
|
|
264
|
+
__proto__: null,
|
|
265
|
+
createBus: createBus
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @returns a unique numeric id.
|
|
270
|
+
*/
|
|
271
|
+
var genId = (function (n) { return function () {
|
|
272
|
+
return "".concat(n++);
|
|
273
|
+
}; })(0);
|
|
274
|
+
|
|
275
|
+
function mapFirst(array, callback) {
|
|
276
|
+
var broke = false;
|
|
277
|
+
var breakoutValue = null;
|
|
278
|
+
for (var i = 0; i < array.length; i++) {
|
|
279
|
+
callback(array[i], breakout, i);
|
|
280
|
+
if (broke) {
|
|
281
|
+
return breakoutValue;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function breakout(conditional, value) {
|
|
285
|
+
if (conditional) {
|
|
286
|
+
broke = true;
|
|
287
|
+
breakoutValue = value;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function isEmpty(value) {
|
|
293
|
+
if (!value) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
297
|
+
return lengthEquals(value, 0);
|
|
298
|
+
}
|
|
299
|
+
else if (typeof value === 'object') {
|
|
300
|
+
return lengthEquals(Object.keys(value), 0);
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
305
|
+
|
|
306
|
+
function isPositive(value) {
|
|
307
|
+
return greaterThan(value, 0);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
exports.StringObject = StringObject;
|
|
311
|
+
exports.asArray = asArray;
|
|
312
|
+
exports.assign = assign;
|
|
313
|
+
exports.bindNot = bindNot;
|
|
314
|
+
exports.bus = bus;
|
|
315
|
+
exports.cache = createCache;
|
|
316
|
+
exports.callEach = callEach;
|
|
317
|
+
exports.defaultTo = defaultTo;
|
|
318
|
+
exports.deferThrow = deferThrow;
|
|
319
|
+
exports.either = either;
|
|
320
|
+
exports.genId = genId;
|
|
321
|
+
exports.greaterThan = greaterThan;
|
|
322
|
+
exports.hasOwnProperty = hasOwnProperty;
|
|
323
|
+
exports.invariant = invariant;
|
|
324
|
+
exports.isArray = isArray;
|
|
325
|
+
exports.isBoolean = isBoolean;
|
|
326
|
+
exports.isEmpty = isEmpty;
|
|
327
|
+
exports.isFunction = isFunction;
|
|
328
|
+
exports.isNotArray = isNotArray;
|
|
329
|
+
exports.isNotEmpty = isNotEmpty;
|
|
330
|
+
exports.isNotNull = isNotNull;
|
|
331
|
+
exports.isNotNullish = isNotNullish;
|
|
332
|
+
exports.isNotNumeric = isNotNumeric;
|
|
333
|
+
exports.isNotUndefined = isNotUndefined;
|
|
334
|
+
exports.isNull = isNull;
|
|
335
|
+
exports.isNullish = isNullish;
|
|
336
|
+
exports.isNumeric = isNumeric;
|
|
337
|
+
exports.isPositive = isPositive;
|
|
338
|
+
exports.isPromise = isPromise;
|
|
339
|
+
exports.isStringValue = isStringValue;
|
|
340
|
+
exports.isUndefined = isUndefined;
|
|
341
|
+
exports.last = last;
|
|
342
|
+
exports.lengthEquals = lengthEquals;
|
|
343
|
+
exports.lengthNotEquals = lengthNotEquals;
|
|
344
|
+
exports.longerThan = longerThan;
|
|
345
|
+
exports.mapFirst = mapFirst;
|
|
346
|
+
exports.nestedArray = nestedArray;
|
|
347
|
+
exports.numberEquals = numberEquals;
|
|
348
|
+
exports.numberNotEquals = numberNotEquals;
|
|
349
|
+
exports.optionalFunctionValue = optionalFunctionValue;
|
|
350
|
+
exports.partition = partition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";function t(t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return!t.apply(void 0,r)}}function r(t){var r=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(r))}Object.defineProperty(exports,"__esModule",{value:!0});var n=t(r);function e(t,n){return r(t)&&r(n)&&Number(t)===Number(n)}var o=t(e);function u(t,r){return e(t.length,r)}var i=t(u);function s(t,n){return r(t)&&r(n)&&Number(t)>Number(n)}function c(t,r){return s(t.length,r)}function a(t){return null===t}var f=t(a);function p(t){return void 0===t}var l=t(p);function x(t){return a(t)||p(t)}var v=t(x);function h(t){return[].concat(t)}function g(t){return"function"==typeof t}function N(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return g(t)?t.apply(void 0,r):t}function d(t,r){var n;return null!==(n=N(t))&&void 0!==n?n:N(r)}function b(t){return!!Array.isArray(t)}var y=t(b);function m(t){return(t=h(t))[t.length-1]}function E(t,r){var n=0;for(r=r.slice(0,-1);n<r.length;n++){var e=r[n];t[e]=d(t[e],[]),t=t[e]}return t}var O=Object.freeze({__proto__:null,transform:function t(r,n){for(var e=[],o=0;o<r.length;o++){var u=r[o];b(u)?e.push(t(u,n)):(u=n(u),f(u)&&e.push(u))}return e},valueAtPath:function(t,r){return E(t,r)[m(r)]},setValueAtPath:function(t,r,n){return E(t,r)[m(r)]=n,t},flatten:function t(r){return h(r).reduce((function(r,n){return b(n)?r.concat(t(n)):h(r).concat(n)}),[])},getCurrent:E});function _(t,r){return Object.prototype.hasOwnProperty.call(t,r)}var j=Object.assign;var A,P=Object.freeze({__proto__:null,createBus:function(){var t={};return{emit:function(r,n){(t[r]||[]).forEach((function(t){t(n)}))},on:function(r,n){return t[r]=(t[r]||[]).concat(n),{off:function(){t[r]=(t[r]||[]).filter((function(t){return t!==n}))}}}}}}),w=(A=0,function(){return"".concat(A++)});function S(t){return!t||(_(t,"length")?u(t,0):"object"==typeof t&&u(Object.keys(t),0))}var F=t(S);exports.StringObject=function(t){return new String(N(t))},exports.asArray=h,exports.assign=j,exports.bindNot=t,exports.bus=P,exports.cache=function(t){function r(t){return n.findIndex((function(r){var n=r[0];return u(t,n.length)&&t.every((function(t,r){return t===n[r]}))}))}void 0===t&&(t=1);var n=[],e=function(r,o){var u=e.get(r);return u?u[1]:(o=o(),n.unshift([r.concat(),o]),c(n,t)&&(n.length=t),o)};return e.invalidate=function(t){-1<(t=r(t))&&n.splice(t,1)},e.get=function(t){return n[r(t)]||null},e},exports.callEach=function(t){return t.forEach((function(t){return t()}))},exports.defaultTo=d,exports.deferThrow=function(t){setTimeout((function(){throw Error(t)}),0)},exports.either=function(t,r){return!!t!=!!r},exports.genId=w,exports.greaterThan=s,exports.hasOwnProperty=_,exports.invariant=function(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?N(r):r)},exports.isArray=b,exports.isBoolean=function(t){return!!t===t},exports.isEmpty=S,exports.isFunction=g,exports.isNotArray=y,exports.isNotEmpty=F,exports.isNotNull=f,exports.isNotNullish=v,exports.isNotNumeric=n,exports.isNotUndefined=l,exports.isNull=a,exports.isNullish=x,exports.isNumeric=r,exports.isPositive=function(t){return s(t,0)},exports.isPromise=function(t){return t&&g(t.then)},exports.isStringValue=function(t){return String(t)===t},exports.isUndefined=p,exports.last=m,exports.lengthEquals=u,exports.lengthNotEquals=i,exports.longerThan=c,exports.mapFirst=function(t,r){function n(t,r){t&&(e=!0,o=r)}for(var e=!1,o=null,u=0;u<t.length;u++)if(r(t[u],n,u),e)return o},exports.nestedArray=O,exports.numberEquals=e,exports.numberNotEquals=o,exports.optionalFunctionValue=N,exports.partition=function(t,r){return t.reduce((function(n,e,o){return n[r(e,o,t)?0:1].push(e),n}),[[],[]])};
|
|
@@ -1 +1,306 @@
|
|
|
1
|
+
function bindNot(fn) {
|
|
2
|
+
return function () {
|
|
3
|
+
var args = [];
|
|
4
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5
|
+
args[_i] = arguments[_i];
|
|
6
|
+
}
|
|
7
|
+
return !fn.apply(void 0, args);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
1
10
|
|
|
11
|
+
function isNumeric(value) {
|
|
12
|
+
var str = String(value);
|
|
13
|
+
var num = Number(value);
|
|
14
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
15
|
+
return Boolean(result);
|
|
16
|
+
}
|
|
17
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
18
|
+
|
|
19
|
+
function numberEquals(value, eq) {
|
|
20
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
21
|
+
}
|
|
22
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
23
|
+
|
|
24
|
+
function lengthEquals(value, arg1) {
|
|
25
|
+
return numberEquals(value.length, arg1);
|
|
26
|
+
}
|
|
27
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
28
|
+
|
|
29
|
+
function greaterThan(value, gt) {
|
|
30
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function longerThan(value, arg1) {
|
|
34
|
+
return greaterThan(value.length, arg1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a cache function
|
|
39
|
+
*/
|
|
40
|
+
function createCache(maxSize) {
|
|
41
|
+
if (maxSize === void 0) { maxSize = 1; }
|
|
42
|
+
var cacheStorage = [];
|
|
43
|
+
var cache = function (deps, cacheAction) {
|
|
44
|
+
var cacheHit = cache.get(deps);
|
|
45
|
+
// cache hit is not null
|
|
46
|
+
if (cacheHit)
|
|
47
|
+
return cacheHit[1];
|
|
48
|
+
var result = cacheAction();
|
|
49
|
+
cacheStorage.unshift([deps.concat(), result]);
|
|
50
|
+
if (longerThan(cacheStorage, maxSize))
|
|
51
|
+
cacheStorage.length = maxSize;
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
// invalidate an item in the cache by its dependencies
|
|
55
|
+
cache.invalidate = function (deps) {
|
|
56
|
+
var index = findIndex(deps);
|
|
57
|
+
if (index > -1)
|
|
58
|
+
cacheStorage.splice(index, 1);
|
|
59
|
+
};
|
|
60
|
+
// Retrieves an item from the cache.
|
|
61
|
+
cache.get = function (deps) {
|
|
62
|
+
return cacheStorage[findIndex(deps)] || null;
|
|
63
|
+
};
|
|
64
|
+
return cache;
|
|
65
|
+
function findIndex(deps) {
|
|
66
|
+
return cacheStorage.findIndex(function (_a) {
|
|
67
|
+
var cachedDeps = _a[0];
|
|
68
|
+
return lengthEquals(deps, cachedDeps.length) &&
|
|
69
|
+
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isNull(value) {
|
|
75
|
+
return value === null;
|
|
76
|
+
}
|
|
77
|
+
var isNotNull = bindNot(isNull);
|
|
78
|
+
|
|
79
|
+
function isUndefined(value) {
|
|
80
|
+
return value === undefined;
|
|
81
|
+
}
|
|
82
|
+
var isNotUndefined = bindNot(isUndefined);
|
|
83
|
+
|
|
84
|
+
function isNullish(value) {
|
|
85
|
+
return isNull(value) || isUndefined(value);
|
|
86
|
+
}
|
|
87
|
+
var isNotNullish = bindNot(isNullish);
|
|
88
|
+
|
|
89
|
+
function asArray(possibleArg) {
|
|
90
|
+
return [].concat(possibleArg);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function isFunction(value) {
|
|
94
|
+
return typeof value === 'function';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function optionalFunctionValue(value) {
|
|
98
|
+
var args = [];
|
|
99
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
100
|
+
args[_i - 1] = arguments[_i];
|
|
101
|
+
}
|
|
102
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function defaultTo(value, defaultValue) {
|
|
106
|
+
var _a;
|
|
107
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// The module is named "isArrayValue" since it
|
|
111
|
+
// is conflicting with a nested npm dependency.
|
|
112
|
+
// We may need to revisit this in the future.
|
|
113
|
+
function isArray(value) {
|
|
114
|
+
return Boolean(Array.isArray(value));
|
|
115
|
+
}
|
|
116
|
+
var isNotArray = bindNot(isArray);
|
|
117
|
+
|
|
118
|
+
function last(values) {
|
|
119
|
+
var valuesArray = asArray(values);
|
|
120
|
+
return valuesArray[valuesArray.length - 1];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// This is kind of a map/filter in one function.
|
|
124
|
+
// Normally, behaves like a nested-array map,
|
|
125
|
+
// but returning `null` will drop the element from the array
|
|
126
|
+
function transform(array, cb) {
|
|
127
|
+
var res = [];
|
|
128
|
+
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
129
|
+
var v = array_1[_i];
|
|
130
|
+
if (isArray(v)) {
|
|
131
|
+
res.push(transform(v, cb));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
var output = cb(v);
|
|
135
|
+
if (isNotNull(output)) {
|
|
136
|
+
res.push(output);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return res;
|
|
141
|
+
}
|
|
142
|
+
function valueAtPath(array, path) {
|
|
143
|
+
return getCurrent(array, path)[last(path)];
|
|
144
|
+
}
|
|
145
|
+
function setValueAtPath(array, path, value) {
|
|
146
|
+
var current = getCurrent(array, path);
|
|
147
|
+
current[last(path)] = value;
|
|
148
|
+
return array;
|
|
149
|
+
}
|
|
150
|
+
function flatten(values) {
|
|
151
|
+
return asArray(values).reduce(function (acc, value) {
|
|
152
|
+
if (isArray(value)) {
|
|
153
|
+
return acc.concat(flatten(value));
|
|
154
|
+
}
|
|
155
|
+
return asArray(acc).concat(value);
|
|
156
|
+
}, []);
|
|
157
|
+
}
|
|
158
|
+
function getCurrent(array, path) {
|
|
159
|
+
var current = array;
|
|
160
|
+
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
161
|
+
var p = _a[_i];
|
|
162
|
+
current[p] = defaultTo(current[p], []);
|
|
163
|
+
current = current[p];
|
|
164
|
+
}
|
|
165
|
+
return current;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var nestedArray = /*#__PURE__*/Object.freeze({
|
|
169
|
+
__proto__: null,
|
|
170
|
+
transform: transform,
|
|
171
|
+
valueAtPath: valueAtPath,
|
|
172
|
+
setValueAtPath: setValueAtPath,
|
|
173
|
+
flatten: flatten,
|
|
174
|
+
getCurrent: getCurrent
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
function callEach(arr) {
|
|
178
|
+
return arr.forEach(function (fn) { return fn(); });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A safe hasOwnProperty access
|
|
183
|
+
*/
|
|
184
|
+
function hasOwnProperty(obj, key) {
|
|
185
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function isPromise(value) {
|
|
189
|
+
return value && isFunction(value.then);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
var assign = Object.assign;
|
|
193
|
+
|
|
194
|
+
function invariant(condition,
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
196
|
+
message) {
|
|
197
|
+
if (condition) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// If message is a string object (rather than string literal)
|
|
201
|
+
// Throw the value directly as a string
|
|
202
|
+
// Alternatively, throw an error with the message
|
|
203
|
+
throw message instanceof String
|
|
204
|
+
? message.valueOf()
|
|
205
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
206
|
+
}
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
208
|
+
function StringObject(value) {
|
|
209
|
+
return new String(optionalFunctionValue(value));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function isStringValue(v) {
|
|
213
|
+
return String(v) === v;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function partition(array, predicate) {
|
|
217
|
+
return array.reduce(function (partitions, value, number) {
|
|
218
|
+
partitions[predicate(value, number, array) ? 0 : 1].push(value);
|
|
219
|
+
return partitions;
|
|
220
|
+
}, [[], []]);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function either(a, b) {
|
|
224
|
+
return !!a !== !!b;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function isBoolean(value) {
|
|
228
|
+
return !!value === value;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function deferThrow(message) {
|
|
232
|
+
setTimeout(function () {
|
|
233
|
+
throw new Error(message);
|
|
234
|
+
}, 0);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function createBus() {
|
|
238
|
+
var listeners = {};
|
|
239
|
+
return {
|
|
240
|
+
emit: function (event, data) {
|
|
241
|
+
listener(event).forEach(function (handler) {
|
|
242
|
+
handler(data);
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
on: function (event, handler) {
|
|
246
|
+
listeners[event] = listener(event).concat(handler);
|
|
247
|
+
return {
|
|
248
|
+
off: function () {
|
|
249
|
+
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function listener(event) {
|
|
255
|
+
return listeners[event] || [];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
var bus = /*#__PURE__*/Object.freeze({
|
|
260
|
+
__proto__: null,
|
|
261
|
+
createBus: createBus
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @returns a unique numeric id.
|
|
266
|
+
*/
|
|
267
|
+
var genId = (function (n) { return function () {
|
|
268
|
+
return "".concat(n++);
|
|
269
|
+
}; })(0);
|
|
270
|
+
|
|
271
|
+
function mapFirst(array, callback) {
|
|
272
|
+
var broke = false;
|
|
273
|
+
var breakoutValue = null;
|
|
274
|
+
for (var i = 0; i < array.length; i++) {
|
|
275
|
+
callback(array[i], breakout, i);
|
|
276
|
+
if (broke) {
|
|
277
|
+
return breakoutValue;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function breakout(conditional, value) {
|
|
281
|
+
if (conditional) {
|
|
282
|
+
broke = true;
|
|
283
|
+
breakoutValue = value;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function isEmpty(value) {
|
|
289
|
+
if (!value) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
293
|
+
return lengthEquals(value, 0);
|
|
294
|
+
}
|
|
295
|
+
else if (typeof value === 'object') {
|
|
296
|
+
return lengthEquals(Object.keys(value), 0);
|
|
297
|
+
}
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
301
|
+
|
|
302
|
+
function isPositive(value) {
|
|
303
|
+
return greaterThan(value, 0);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export { StringObject, asArray, assign, bindNot, bus, createCache as cache, callEach, defaultTo, deferThrow, either, genId, greaterThan, hasOwnProperty, invariant, isArray, isBoolean, isEmpty, isFunction, isNotArray, isNotEmpty, isNotNull, isNotNullish, isNotNumeric, isNotUndefined, isNull, isNullish, isNumeric, isPositive, isPromise, isStringValue, isUndefined, last, lengthEquals, lengthNotEquals, longerThan, mapFirst, nestedArray, numberEquals, numberNotEquals, optionalFunctionValue, partition };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function n(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function t(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}var r=n(t);function u(n,r){return t(n)&&t(r)&&Number(n)===Number(r)}var e=n(u);function o(n,t){return u(n.length,t)}var i=n(o);function a(n,r){return t(n)&&t(r)&&Number(n)>Number(r)}function c(n,t){return a(n.length,t)}function f(n){return null===n}var s=n(f);function l(n){return void 0===n}var v=n(l);function h(n){return null===n||l(n)}var g=n(h);function N(n){return[].concat(n)}function p(n){return"function"==typeof n}function d(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(n)?n.apply(void 0,t):n}function b(n,t){var r;return null!==(r=d(n))&&void 0!==r?r:d(t)}function y(n){return!!Array.isArray(n)}var m=n(y);function E(n){return(n=N(n))[n.length-1]}function A(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var u=t[r];n[u]=b(n[u],[]),n=n[u]}return n}var _=Object.freeze({__proto__:null,transform:function n(t,r){for(var u=[],e=0;e<t.length;e++){var o=t[e];y(o)?u.push(n(o,r)):(o=r(o),s(o)&&u.push(o))}return u},valueAtPath:function(n,t){return A(n,t)[E(t)]},setValueAtPath:function(n,t,r){return A(n,t)[E(t)]=r,n},flatten:function n(t){return N(t).reduce((function(t,r){return y(r)?t.concat(n(r)):N(t).concat(r)}),[])},getCurrent:A});function O(n,t){return Object.prototype.hasOwnProperty.call(n,t)}var j,q=Object.assign,w=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(t,r){(n[t]||[]).forEach((function(n){n(r)}))},on:function(t,r){return n[t]=(n[t]||[]).concat(r),{off:function(){n[t]=(n[t]||[]).filter((function(n){return n!==r}))}}}}}}),F=(j=0,function(){return"".concat(j++)});function S(n){return!n||(O(n,"length")?o(n,0):"object"==typeof n&&o(Object.keys(n),0))}var T=n(S);function P(n){return new String(d(n))}function x(n){function t(r,e){var o=t.get(r);return o?o[1]:(e=e(),u.unshift([r.concat(),e]),c(u,n)&&(u.length=n),e)}function r(n){return u.findIndex((function(t){var r=t[0];return o(n,r.length)&&n.every((function(n,t){return n===r[t]}))}))}void 0===n&&(n=1);var u=[];return t.invalidate=function(n){-1<(n=r(n))&&u.splice(n,1)},t.get=function(n){return u[r(n)]||null},t}function z(n){return n.forEach((function(n){return n()}))}function I(n){setTimeout((function(){throw Error(n)}),0)}function U(n,t){return!!n!=!!t}function V(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?d(t):t)}function k(n){return!!n===n}function B(n){return a(n,0)}function C(n){return n&&p(n.then)}function D(n){return String(n)===n}function G(n,t){function r(n,t){n&&(u=!0,e=t)}for(var u=!1,e=null,o=0;o<n.length;o++)if(t(n[o],r,o),u)return e}function H(n,t){return n.reduce((function(r,u,e){return r[t(u,e,n)?0:1].push(u),r}),[[],[]])}export{P as StringObject,N as asArray,q as assign,n as bindNot,w as bus,x as cache,z as callEach,b as defaultTo,I as deferThrow,U as either,F as genId,a as greaterThan,O as hasOwnProperty,V as invariant,y as isArray,k as isBoolean,S as isEmpty,p as isFunction,m as isNotArray,T as isNotEmpty,s as isNotNull,g as isNotNullish,r as isNotNumeric,v as isNotUndefined,f as isNull,h as isNullish,t as isNumeric,B as isPositive,C as isPromise,D as isStringValue,l as isUndefined,E as last,o as lengthEquals,i as lengthNotEquals,c as longerThan,G as mapFirst,_ as nestedArray,u as numberEquals,e as numberNotEquals,d as optionalFunctionValue,H as partition};
|