@webdeveric/utils 0.9.0 → 0.12.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/dist/cjs/clamp.js +10 -0
- package/dist/cjs/clamp.js.map +1 -0
- package/dist/cjs/convert.js +19 -0
- package/dist/cjs/convert.js.map +1 -0
- package/dist/cjs/getMaxValue.js +14 -0
- package/dist/cjs/getMaxValue.js.map +1 -0
- package/dist/cjs/getMinValue.js +14 -0
- package/dist/cjs/getMinValue.js.map +1 -0
- package/dist/cjs/getOwnKeys.js +1 -4
- package/dist/cjs/getOwnKeys.js.map +1 -1
- package/dist/cjs/getOwnProperties.js +11 -0
- package/dist/cjs/getOwnProperties.js.map +1 -0
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/isEmpty.js +17 -0
- package/dist/cjs/isEmpty.js.map +1 -0
- package/dist/cjs/isObject.js +8 -0
- package/dist/cjs/isObject.js.map +1 -0
- package/dist/cjs/node/index.js +5 -1
- package/dist/cjs/node/index.js.map +1 -1
- package/dist/cjs/normalize.js +14 -15
- package/dist/cjs/normalize.js.map +1 -1
- package/dist/cjs/type-assertion.js +16 -0
- package/dist/cjs/type-assertion.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/until.js +10 -13
- package/dist/cjs/until.js.map +1 -1
- package/dist/mjs/clamp.js +6 -0
- package/dist/mjs/clamp.js.map +1 -0
- package/dist/mjs/compose.js +1 -2
- package/dist/mjs/compose.js.map +1 -1
- package/dist/mjs/convert.js +15 -0
- package/dist/mjs/convert.js.map +1 -0
- package/dist/mjs/getMaxValue.js +10 -0
- package/dist/mjs/getMaxValue.js.map +1 -0
- package/dist/mjs/getMinValue.js +10 -0
- package/dist/mjs/getMinValue.js.map +1 -0
- package/dist/mjs/getOwnKeys.js +1 -4
- package/dist/mjs/getOwnKeys.js.map +1 -1
- package/dist/mjs/getOwnProperties.js +7 -0
- package/dist/mjs/getOwnProperties.js.map +1 -0
- package/dist/mjs/index.js +9 -0
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/isEmpty.js +13 -0
- package/dist/mjs/isEmpty.js.map +1 -0
- package/dist/mjs/isObject.js +4 -0
- package/dist/mjs/isObject.js.map +1 -0
- package/dist/mjs/normalize.js +14 -15
- package/dist/mjs/normalize.js.map +1 -1
- package/dist/mjs/type-assertion.js +11 -0
- package/dist/mjs/type-assertion.js.map +1 -0
- package/dist/mjs/types.js +2 -0
- package/dist/mjs/types.js.map +1 -0
- package/dist/mjs/until.js +10 -13
- package/dist/mjs/until.js.map +1 -1
- package/dist/types/clamp.d.ts +3 -0
- package/dist/types/clamp.d.ts.map +1 -0
- package/dist/types/convert.d.ts +8 -0
- package/dist/types/convert.d.ts.map +1 -0
- package/dist/types/getMaxValue.d.ts +3 -0
- package/dist/types/getMaxValue.d.ts.map +1 -0
- package/dist/types/getMinValue.d.ts +3 -0
- package/dist/types/getMinValue.d.ts.map +1 -0
- package/dist/types/getOwnKeys.d.ts +1 -1
- package/dist/types/getOwnKeys.d.ts.map +1 -1
- package/dist/types/getOwnProperties.d.ts +2 -0
- package/dist/types/getOwnProperties.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/isEmpty.d.ts +2 -0
- package/dist/types/isEmpty.d.ts.map +1 -0
- package/dist/types/isObject.d.ts +2 -0
- package/dist/types/isObject.d.ts.map +1 -0
- package/dist/types/normalize.d.ts +8 -6
- package/dist/types/normalize.d.ts.map +1 -1
- package/dist/types/type-assertion.d.ts +3 -0
- package/dist/types/type-assertion.d.ts.map +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/until.d.ts +8 -10
- package/dist/types/until.d.ts.map +1 -1
- package/package.json +27 -12
- package/src/clamp.ts +7 -0
- package/src/convert.ts +30 -0
- package/src/getMaxValue.ts +16 -0
- package/src/getMinValue.ts +16 -0
- package/src/getOwnKeys.ts +2 -5
- package/src/getOwnProperties.ts +6 -0
- package/src/index.ts +9 -0
- package/src/isEmpty.ts +15 -0
- package/src/isObject.ts +3 -0
- package/src/normalize.ts +36 -29
- package/src/type-assertion.ts +11 -0
- package/src/types.ts +12 -0
- package/src/until.ts +22 -29
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clamp = void 0;
|
|
4
|
+
const getMaxValue_js_1 = require("./getMaxValue.js");
|
|
5
|
+
const getMinValue_js_1 = require("./getMinValue.js");
|
|
6
|
+
function clamp(min, value, max) {
|
|
7
|
+
return (0, getMaxValue_js_1.getMaxValue)(min, (0, getMinValue_js_1.getMinValue)(value, max));
|
|
8
|
+
}
|
|
9
|
+
exports.clamp = clamp;
|
|
10
|
+
//# sourceMappingURL=clamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/clamp.ts"],"names":[],"mappings":";;;AAAA,qDAA+C;AAC/C,qDAA+C;AAG/C,SAAgB,KAAK,CAAC,GAAiB,EAAE,KAAmB,EAAE,GAAiB;IAC7E,OAAO,IAAA,4BAAW,EAAC,GAAG,EAAE,IAAA,4BAAW,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC;AAFD,sBAEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convert = void 0;
|
|
4
|
+
const getOwnProperties_js_1 = require("./getOwnProperties.js");
|
|
5
|
+
const getType_js_1 = require("./getType.js");
|
|
6
|
+
const convert = (input, converter) => {
|
|
7
|
+
if (typeof converter === 'function') {
|
|
8
|
+
return converter(input);
|
|
9
|
+
}
|
|
10
|
+
if (typeof converter === 'object' && converter !== null) {
|
|
11
|
+
return (0, getOwnProperties_js_1.getOwnProperties)(converter).reduce((data, key) => {
|
|
12
|
+
data[key] = (0, exports.convert)(input, converter[key]);
|
|
13
|
+
return data;
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
throw new TypeError(`${(0, getType_js_1.getType)(converter)} is not a valid converter`);
|
|
17
|
+
};
|
|
18
|
+
exports.convert = convert;
|
|
19
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/convert.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AACzD,6CAAuC;AAchC,MAAM,OAAO,GAAG,CAAgB,KAAsB,EAAE,SAAsC,EAAU,EAAE;IAC/G,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACnC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;KACzB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE;QACvD,OAAO,IAAA,sCAAgB,EAAC,SAAS,CAAC,CAAC,MAAM,CAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACvE,IAAI,CAAE,GAAG,CAAE,GAAG,IAAA,eAAO,EAAC,KAAK,EAAE,SAAS,CAAE,GAAG,CAAE,CAAC,CAAC;YAE/C,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAE,CAAW,CAAC;KAClB;IAED,MAAM,IAAI,SAAS,CAAC,GAAG,IAAA,oBAAO,EAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;AACxE,CAAC,CAAC;AAdW,QAAA,OAAO,WAclB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMaxValue = void 0;
|
|
4
|
+
function getMaxValue(...values) {
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
throw new Error('Expected at least one numeric value');
|
|
7
|
+
}
|
|
8
|
+
return values.reduce((high, current) => {
|
|
9
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
10
|
+
return value > high ? current : high;
|
|
11
|
+
}, values[0]);
|
|
12
|
+
}
|
|
13
|
+
exports.getMaxValue = getMaxValue;
|
|
14
|
+
//# sourceMappingURL=getMaxValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMaxValue.js","sourceRoot":"","sources":["../../src/getMaxValue.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,GAAG,MAAsB;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,IAAkB,EAAE,OAAqB,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEtE,OAAO,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC,EACD,MAAM,CAAE,CAAC,CAAE,CACZ,CAAC;AACJ,CAAC;AAbD,kCAaC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMinValue = void 0;
|
|
4
|
+
function getMinValue(...values) {
|
|
5
|
+
if (values.length === 0) {
|
|
6
|
+
throw new Error('Expected at least one numeric value');
|
|
7
|
+
}
|
|
8
|
+
return values.reduce((low, current) => {
|
|
9
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
10
|
+
return value < low ? current : low;
|
|
11
|
+
}, values[0]);
|
|
12
|
+
}
|
|
13
|
+
exports.getMinValue = getMinValue;
|
|
14
|
+
//# sourceMappingURL=getMinValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMinValue.js","sourceRoot":"","sources":["../../src/getMinValue.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,GAAG,MAAsB;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAiB,EAAE,OAAqB,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEtE,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACrC,CAAC,EACD,MAAM,CAAE,CAAC,CAAE,CACZ,CAAC;AACJ,CAAC;AAbD,kCAaC"}
|
package/dist/cjs/getOwnKeys.js
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOwnKeys = void 0;
|
|
4
4
|
function getOwnKeys(data) {
|
|
5
|
-
return
|
|
6
|
-
...Object.getOwnPropertyNames(data),
|
|
7
|
-
...Object.getOwnPropertySymbols(data),
|
|
8
|
-
];
|
|
5
|
+
return Object.keys(data);
|
|
9
6
|
}
|
|
10
7
|
exports.getOwnKeys = getOwnKeys;
|
|
11
8
|
//# sourceMappingURL=getOwnKeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnKeys.js","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"getOwnKeys.js","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAiE,IAAO;IAChG,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAC;AAClC,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOwnProperties = void 0;
|
|
4
|
+
function getOwnProperties(data) {
|
|
5
|
+
return [
|
|
6
|
+
...Object.getOwnPropertyNames(data),
|
|
7
|
+
...Object.getOwnPropertySymbols(data),
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
exports.getOwnProperties = getOwnProperties;
|
|
11
|
+
//# sourceMappingURL=getOwnProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOwnProperties.js","sourceRoot":"","sources":["../../src/getOwnProperties.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gBAAgB,CAAuB,IAAO;IAC5D,OAAO;QACL,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;QACnC,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC;KAC/B,CAAC;AACX,CAAC;AALD,4CAKC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,17 +15,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./asArray.js"), exports);
|
|
18
|
+
__exportStar(require("./clamp.js"), exports);
|
|
14
19
|
__exportStar(require("./compose.js"), exports);
|
|
20
|
+
__exportStar(require("./convert.js"), exports);
|
|
15
21
|
__exportStar(require("./delay.js"), exports);
|
|
16
22
|
__exportStar(require("./delayAnimationFrame.js"), exports);
|
|
23
|
+
__exportStar(require("./getMaxValue.js"), exports);
|
|
24
|
+
__exportStar(require("./getMinValue.js"), exports);
|
|
17
25
|
__exportStar(require("./getOwnKeys.js"), exports);
|
|
26
|
+
__exportStar(require("./getOwnProperties.js"), exports);
|
|
18
27
|
__exportStar(require("./getType.js"), exports);
|
|
28
|
+
__exportStar(require("./isEmpty.js"), exports);
|
|
29
|
+
__exportStar(require("./isObject.js"), exports);
|
|
19
30
|
__exportStar(require("./joinStrings.js"), exports);
|
|
20
31
|
__exportStar(require("./normalize.js"), exports);
|
|
21
32
|
__exportStar(require("./secToString.js"), exports);
|
|
22
33
|
__exportStar(require("./toPascalCase.js"), exports);
|
|
23
34
|
__exportStar(require("./trimEnd.js"), exports);
|
|
24
35
|
__exportStar(require("./trimStart.js"), exports);
|
|
36
|
+
__exportStar(require("./type-assertion.js"), exports);
|
|
37
|
+
__exportStar(require("./types.js"), exports);
|
|
25
38
|
__exportStar(require("./uniqueItems.js"), exports);
|
|
26
39
|
__exportStar(require("./until.js"), exports);
|
|
27
40
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,2DAAyC;AACzC,mDAAiC;AACjC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,+CAA6B;AAC7B,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,mDAAiC;AACjC,oDAAkC;AAClC,+CAA6B;AAC7B,iDAA+B;AAC/B,sDAAoC;AACpC,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmpty = void 0;
|
|
4
|
+
function isEmpty(input) {
|
|
5
|
+
if (typeof input === 'undefined' || input === null || (typeof input === 'string' && !input.length)) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(input)) {
|
|
9
|
+
return input.length === 0;
|
|
10
|
+
}
|
|
11
|
+
if (typeof input === 'object') {
|
|
12
|
+
return Object.keys(input).length === 0;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
exports.isEmpty = isEmpty;
|
|
17
|
+
//# sourceMappingURL=isEmpty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmpty.js","sourceRoot":"","sources":["../../src/isEmpty.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAE,KAAK,CAAC,MAAM,CAAC,EAAE;QACnG,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;KACxC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAdD,0BAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isObject.js","sourceRoot":"","sources":["../../src/isObject.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAFD,4BAEC"}
|
package/dist/cjs/node/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
|
package/dist/cjs/normalize.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.normalize = void 0;
|
|
7
7
|
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const getOwnProperties_js_1 = require("./getOwnProperties.js");
|
|
9
|
+
const isObject_js_1 = require("./isObject.js");
|
|
10
10
|
/**
|
|
11
11
|
* @example
|
|
12
12
|
*
|
|
@@ -22,34 +22,33 @@ const getType_1 = require("./getType");
|
|
|
22
22
|
* normalize(true, () => false );
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
function normalize(input, normalizers) {
|
|
26
|
-
const
|
|
25
|
+
function normalize(input, normalizers, initContextData = () => ({})) {
|
|
26
|
+
const current = (0, lodash_clonedeep_1.default)(input);
|
|
27
27
|
const context = Object.seal({
|
|
28
28
|
original: input,
|
|
29
|
-
current
|
|
30
|
-
data:
|
|
29
|
+
current,
|
|
30
|
+
data: initContextData(input, normalizers),
|
|
31
31
|
});
|
|
32
32
|
const walk = (currentRecord, currentNormalizers) => {
|
|
33
|
-
if (typeof currentNormalizers === 'undefined') {
|
|
34
|
-
return currentRecord;
|
|
35
|
-
}
|
|
36
33
|
if (typeof currentNormalizers === 'function') {
|
|
37
34
|
return currentNormalizers(currentRecord, context);
|
|
38
35
|
}
|
|
39
36
|
if (typeof currentNormalizers === 'object' && currentNormalizers !== null) {
|
|
40
37
|
if (typeof currentRecord === 'object' && currentRecord !== null) {
|
|
41
|
-
return (0,
|
|
42
|
-
|
|
38
|
+
return (0, getOwnProperties_js_1.getOwnProperties)(currentNormalizers).reduce((data, key) => {
|
|
39
|
+
const normalizers = currentNormalizers[key];
|
|
40
|
+
// If the value is undefined but there is a normalizer record, set value to empty object.
|
|
41
|
+
const value = typeof data[key] === 'undefined' && (0, isObject_js_1.isObject)(normalizers)
|
|
42
|
+
? {}
|
|
43
|
+
: data[key];
|
|
44
|
+
data[key] = walk(value, normalizers);
|
|
43
45
|
return data;
|
|
44
46
|
}, currentRecord);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
|
-
else {
|
|
48
|
-
throw new TypeError(`normalizers must be function or object. ${(0, getType_1.getType)(currentNormalizers)} was received.`);
|
|
49
|
-
}
|
|
50
49
|
return currentRecord;
|
|
51
50
|
};
|
|
52
|
-
return walk(
|
|
51
|
+
return walk(current, normalizers);
|
|
53
52
|
}
|
|
54
53
|
exports.normalize = normalize;
|
|
55
54
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAyC;AAIzC
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAyC;AAIzC,+DAAyD;AACzD,+CAAyC;AAyBzC;;;;;;;;;;;;;;GAcG;AACH,SAAgB,SAAS,CACvB,KAAqB,EACrB,WAAoD,EACpD,kBAA4F,GAAc,EAAE,CAAC,CAAC,EAAE,CAAC;IAEjH,MAAM,OAAO,GAAG,IAAA,0BAAS,EAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAwC,MAAM,CAAC,IAAI,CAAC;QAC/D,QAAQ,EAAE,KAAK;QACf,OAAO;QACP,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC;KAC1C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CACX,aAA4B,EAC5B,kBAAyH,EAC1G,EAAE;QACjB,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE;YAC5C,OAAO,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SACnD;QAED,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,IAAI,EAAE;YACzE,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE;gBAC/D,OAAO,IAAA,sCAAgB,EAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBAC/D,MAAM,WAAW,GAAG,kBAAkB,CAAE,GAAG,CAAE,CAAC;oBAC9C,yFAAyF;oBACzF,MAAM,KAAK,GAAG,OAAO,IAAI,CAAE,GAAG,CAAE,KAAK,WAAW,IAAI,IAAA,sBAAQ,EAAC,WAAW,CAAC;wBACvE,CAAC,CAAC,EAAwC;wBAC1C,CAAC,CAAC,IAAI,CAAE,GAAG,CAAE,CAAC;oBAEhB,IAAI,CAAE,GAAG,CAAE,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;oBAEvC,OAAO,IAAI,CAAC;gBACd,CAAC,EAAE,aAAa,CAAC,CAAC;aACnB;SACF;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC;AAzCD,8BAyCC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertsIsFiniteNumber = exports.assertsIsInteger = void 0;
|
|
4
|
+
function assertsIsInteger(input) {
|
|
5
|
+
if (!Number.isInteger(input)) {
|
|
6
|
+
throw new TypeError('input is not an integer');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.assertsIsInteger = assertsIsInteger;
|
|
10
|
+
function assertsIsFiniteNumber(input) {
|
|
11
|
+
if (!Number.isFinite(input)) {
|
|
12
|
+
throw new TypeError('input is not a finite number');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.assertsIsFiniteNumber = assertsIsFiniteNumber;
|
|
16
|
+
//# sourceMappingURL=type-assertion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-assertion.js","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,IAAI,CAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QAC7B,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAChD;AACH,CAAC;AAJD,4CAIC;AAED,SAAgB,qBAAqB,CAAC,KAAc;IAClD,IAAI,CAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;KACrD;AACH,CAAC;AAJD,sDAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/cjs/until.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.until = void 0;
|
|
4
|
-
|
|
5
|
-
return Number.isInteger(delay) || typeof delay === 'function';
|
|
6
|
-
}
|
|
7
|
-
function getDelay(delay, context) {
|
|
8
|
-
return typeof delay === 'function' ? delay(context) : delay;
|
|
9
|
-
}
|
|
4
|
+
const getType_js_1 = require("./getType.js");
|
|
10
5
|
const defaultOptions = {
|
|
11
6
|
delay: 10,
|
|
12
7
|
};
|
|
@@ -15,20 +10,22 @@ const defaultOptions = {
|
|
|
15
10
|
*/
|
|
16
11
|
function until(fn, options = defaultOptions) {
|
|
17
12
|
if (typeof fn !== 'function') {
|
|
18
|
-
|
|
13
|
+
return Promise.reject(new Error('fn must be a function'));
|
|
19
14
|
}
|
|
20
15
|
if (!options || typeof options !== 'object') {
|
|
21
|
-
|
|
16
|
+
return Promise.reject(new Error(`options must be an object. ${(0, getType_js_1.getType)(options)} provided.`));
|
|
22
17
|
}
|
|
23
18
|
const { delay, timeout, callLimit } = Object.assign({}, defaultOptions, options);
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const isDelay = (input) => Number.isInteger(input) || typeof input === 'function';
|
|
20
|
+
const getDelay = (delay, context) => typeof delay === 'function' ? delay(context) : delay;
|
|
21
|
+
if (!isDelay(delay)) {
|
|
22
|
+
return Promise.reject(new Error('invalid delay value'));
|
|
26
23
|
}
|
|
27
|
-
if (timeout !== undefined && !
|
|
28
|
-
|
|
24
|
+
if (timeout !== undefined && !isDelay(timeout)) {
|
|
25
|
+
return Promise.reject(new Error('invalid timeout value'));
|
|
29
26
|
}
|
|
30
27
|
if (callLimit !== undefined && !Number.isInteger(callLimit)) {
|
|
31
|
-
|
|
28
|
+
return Promise.reject(new Error('invalid callLimit value'));
|
|
32
29
|
}
|
|
33
30
|
return new Promise((resolutionFn, rejectionFn) => {
|
|
34
31
|
let callCount = 0;
|
package/dist/cjs/until.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/until.ts"],"names":[],"mappings":";;;AACA,6CAAuC;AA2BvC,MAAM,cAAc,GAA2B;IAC7C,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;GAEG;AACH,SAAgB,KAAK,CAAK,EAAoB,EAAE,UAAwB,cAAc;IAEpF,IAAK,OAAO,EAAE,KAAK,UAAU,EAAG;QAC9B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;KAC3D;IAED,IAAK,CAAE,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAG;QAC9C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,IAAA,oBAAO,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;KAC9F;IAED,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAEjF,MAAM,OAAO,GAAG,CAAE,KAAc,EAAoB,EAAE,CAAC,MAAM,CAAC,SAAS,CAAE,KAAK,CAAE,IAAI,OAAO,KAAK,KAAK,UAAU,C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AI,KAAK,CAAC,kBAAkB,CAAC,CAAE,CAAC;YAC1C,CAAC,EACD,QAAQ,CAAE,OAAO,EAAE,OAAO,CAAE,CAC7B,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAjGD,sBAiGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/clamp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,UAAU,KAAK,CAAC,GAAiB,EAAE,KAAmB,EAAE,GAAiB;IAC7E,OAAO,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
package/dist/mjs/compose.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export function compose(...functions) {
|
|
2
2
|
return functions.reduce((prev, next) => (data, ...args) => {
|
|
3
|
-
var _a;
|
|
4
3
|
const updatedData = prev(data, ...args);
|
|
5
|
-
return (
|
|
4
|
+
return (next(updatedData, ...args) ?? updatedData);
|
|
6
5
|
}, (data) => data);
|
|
7
6
|
}
|
|
8
7
|
//# sourceMappingURL=compose.js.map
|
package/dist/mjs/compose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/compose.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAyB,GAAG,SAAsC;IACvF,OAAO,SAAS,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACb,CAAC,IAAO,EAAE,GAAG,IAAO,EAAK,EAAE
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/compose.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAyB,GAAG,SAAsC;IACvF,OAAO,SAAS,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACb,CAAC,IAAO,EAAE,GAAG,IAAO,EAAK,EAAE;QACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAExC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,WAAW,CAAM,CAAC;IAC1D,CAAC,EACH,CAAC,IAAO,EAAE,EAAE,CAAC,IAAI,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getOwnProperties } from './getOwnProperties.js';
|
|
2
|
+
import { getType } from './getType.js';
|
|
3
|
+
export const convert = (input, converter) => {
|
|
4
|
+
if (typeof converter === 'function') {
|
|
5
|
+
return converter(input);
|
|
6
|
+
}
|
|
7
|
+
if (typeof converter === 'object' && converter !== null) {
|
|
8
|
+
return getOwnProperties(converter).reduce((data, key) => {
|
|
9
|
+
data[key] = convert(input, converter[key]);
|
|
10
|
+
return data;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
throw new TypeError(`${getType(converter)} is not a valid converter`);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAcvC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAgB,KAAsB,EAAE,SAAsC,EAAU,EAAE;IAC/G,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACnC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;KACzB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE;QACvD,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACvE,IAAI,CAAE,GAAG,CAAE,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAE,GAAG,CAAE,CAAC,CAAC;YAE/C,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAE,CAAW,CAAC;KAClB;IAED,MAAM,IAAI,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;AACxE,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function getMaxValue(...values) {
|
|
2
|
+
if (values.length === 0) {
|
|
3
|
+
throw new Error('Expected at least one numeric value');
|
|
4
|
+
}
|
|
5
|
+
return values.reduce((high, current) => {
|
|
6
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
7
|
+
return value > high ? current : high;
|
|
8
|
+
}, values[0]);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=getMaxValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMaxValue.js","sourceRoot":"","sources":["../../src/getMaxValue.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,GAAG,MAAsB;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,IAAkB,EAAE,OAAqB,EAAE,EAAE;QAC5C,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEtE,OAAO,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC,EACD,MAAM,CAAE,CAAC,CAAE,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function getMinValue(...values) {
|
|
2
|
+
if (values.length === 0) {
|
|
3
|
+
throw new Error('Expected at least one numeric value');
|
|
4
|
+
}
|
|
5
|
+
return values.reduce((low, current) => {
|
|
6
|
+
const value = typeof current === 'string' ? Number(current) : current;
|
|
7
|
+
return value < low ? current : low;
|
|
8
|
+
}, values[0]);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=getMinValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMinValue.js","sourceRoot":"","sources":["../../src/getMinValue.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,GAAG,MAAsB;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAiB,EAAE,OAAqB,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEtE,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACrC,CAAC,EACD,MAAM,CAAE,CAAC,CAAE,CACZ,CAAC;AACJ,CAAC"}
|
package/dist/mjs/getOwnKeys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnKeys.js","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"getOwnKeys.js","sourceRoot":"","sources":["../../src/getOwnKeys.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAiE,IAAO;IAChG,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAQ,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOwnProperties.js","sourceRoot":"","sources":["../../src/getOwnProperties.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAuB,IAAO;IAC5D,OAAO;QACL,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;QACnC,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC;KAC/B,CAAC;AACX,CAAC"}
|
package/dist/mjs/index.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
export * from './asArray.js';
|
|
2
|
+
export * from './clamp.js';
|
|
2
3
|
export * from './compose.js';
|
|
4
|
+
export * from './convert.js';
|
|
3
5
|
export * from './delay.js';
|
|
4
6
|
export * from './delayAnimationFrame.js';
|
|
7
|
+
export * from './getMaxValue.js';
|
|
8
|
+
export * from './getMinValue.js';
|
|
5
9
|
export * from './getOwnKeys.js';
|
|
10
|
+
export * from './getOwnProperties.js';
|
|
6
11
|
export * from './getType.js';
|
|
12
|
+
export * from './isEmpty.js';
|
|
13
|
+
export * from './isObject.js';
|
|
7
14
|
export * from './joinStrings.js';
|
|
8
15
|
export * from './normalize.js';
|
|
9
16
|
export * from './secToString.js';
|
|
10
17
|
export * from './toPascalCase.js';
|
|
11
18
|
export * from './trimEnd.js';
|
|
12
19
|
export * from './trimStart.js';
|
|
20
|
+
export * from './type-assertion.js';
|
|
21
|
+
export * from './types.js';
|
|
13
22
|
export * from './uniqueItems.js';
|
|
14
23
|
export * from './until.js';
|
|
15
24
|
//# sourceMappingURL=index.js.map
|
package/dist/mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isEmpty(input) {
|
|
2
|
+
if (typeof input === 'undefined' || input === null || (typeof input === 'string' && !input.length)) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
if (Array.isArray(input)) {
|
|
6
|
+
return input.length === 0;
|
|
7
|
+
}
|
|
8
|
+
if (typeof input === 'object') {
|
|
9
|
+
return Object.keys(input).length === 0;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=isEmpty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmpty.js","sourceRoot":"","sources":["../../src/isEmpty.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAE,KAAK,CAAC,MAAM,CAAC,EAAE;QACnG,OAAO,IAAI,CAAC;KACb;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;KAC3B;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;KACxC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isObject.js","sourceRoot":"","sources":["../../src/isObject.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
package/dist/mjs/normalize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cloneDeep from 'lodash.clonedeep';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { getOwnProperties } from './getOwnProperties.js';
|
|
3
|
+
import { isObject } from './isObject.js';
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
*
|
|
@@ -16,33 +16,32 @@ import { getType } from './getType';
|
|
|
16
16
|
* normalize(true, () => false );
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export function normalize(input, normalizers) {
|
|
20
|
-
const
|
|
19
|
+
export function normalize(input, normalizers, initContextData = () => ({})) {
|
|
20
|
+
const current = cloneDeep(input);
|
|
21
21
|
const context = Object.seal({
|
|
22
22
|
original: input,
|
|
23
|
-
current
|
|
24
|
-
data:
|
|
23
|
+
current,
|
|
24
|
+
data: initContextData(input, normalizers),
|
|
25
25
|
});
|
|
26
26
|
const walk = (currentRecord, currentNormalizers) => {
|
|
27
|
-
if (typeof currentNormalizers === 'undefined') {
|
|
28
|
-
return currentRecord;
|
|
29
|
-
}
|
|
30
27
|
if (typeof currentNormalizers === 'function') {
|
|
31
28
|
return currentNormalizers(currentRecord, context);
|
|
32
29
|
}
|
|
33
30
|
if (typeof currentNormalizers === 'object' && currentNormalizers !== null) {
|
|
34
31
|
if (typeof currentRecord === 'object' && currentRecord !== null) {
|
|
35
|
-
return
|
|
36
|
-
|
|
32
|
+
return getOwnProperties(currentNormalizers).reduce((data, key) => {
|
|
33
|
+
const normalizers = currentNormalizers[key];
|
|
34
|
+
// If the value is undefined but there is a normalizer record, set value to empty object.
|
|
35
|
+
const value = typeof data[key] === 'undefined' && isObject(normalizers)
|
|
36
|
+
? {}
|
|
37
|
+
: data[key];
|
|
38
|
+
data[key] = walk(value, normalizers);
|
|
37
39
|
return data;
|
|
38
40
|
}, currentRecord);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
else {
|
|
42
|
-
throw new TypeError(`normalizers must be function or object. ${getType(currentNormalizers)} was received.`);
|
|
43
|
-
}
|
|
44
43
|
return currentRecord;
|
|
45
44
|
};
|
|
46
|
-
return walk(
|
|
45
|
+
return walk(current, normalizers);
|
|
47
46
|
}
|
|
48
47
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAIzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":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