@wener/utils 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/lib/cjs/arrays/MaybeArray.js +44 -27
- package/lib/cjs/arrays/index.js +17 -5
- package/lib/cjs/asyncs/AsyncInterval.js +31 -14
- package/lib/cjs/asyncs/LazyPromise.js +41 -24
- package/lib/cjs/asyncs/MaybePromise.js +15 -3
- package/lib/cjs/asyncs/generatorOfStream.js +32 -15
- package/lib/cjs/asyncs/index.js +23 -11
- package/lib/cjs/asyncs/isPromise.js +23 -6
- package/lib/cjs/asyncs/promiseOfCallback.js +34 -19
- package/lib/cjs/asyncs/sleep.js +22 -5
- package/lib/cjs/asyncs/timeout.js +40 -23
- package/lib/cjs/browsers/copy.js +65 -49
- package/lib/cjs/browsers/download.js +44 -32
- package/lib/cjs/browsers/getFileFromDataTransfer.js +44 -37
- package/lib/cjs/browsers/index.js +20 -8
- package/lib/cjs/browsers/loaders.js +48 -32
- package/lib/cjs/formats/formatBytes.js +34 -29
- package/lib/cjs/index.js +35 -15
- package/lib/cjs/io/index.js +17 -5
- package/lib/cjs/io/isBuffer.js +23 -10
- package/lib/cjs/isomorphics/getGlobalThis.js +31 -23
- package/lib/cjs/maths/index.js +17 -5
- package/lib/cjs/maths/random.js +33 -17
- package/lib/cjs/shim/urljoin.js +70 -0
- package/lib/cjs/shim/urljoin.test.js +4 -0
- package/lib/cjs/strings/camelCase.js +68 -65
- package/lib/cjs/strings/index.js +18 -7
- package/lib/cjs/strings/templates.js +25 -16
- package/lib/cjs/validations/asserts.js +25 -14
- package/lib/cjs/validations/index.js +20 -8
- package/lib/cjs/validations/isClass.js +23 -6
- package/lib/cjs/validations/isDefined.js +23 -6
- package/lib/cjs/validations/isEmptyObject.js +26 -9
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +5 -2
- package/lib/esm/shim/urljoin.d.ts +2 -0
- package/lib/esm/{strings → shim}/urljoin.js +3 -5
- package/lib/{cjs/strings → esm/shim}/urljoin.test.d.ts +0 -0
- package/lib/esm/{strings → shim}/urljoin.test.js +0 -0
- package/lib/esm/strings/index.d.ts +0 -1
- package/lib/esm/strings/index.js +0 -1
- package/package.json +3 -3
- package/src/index.ts +2 -1
- package/src/{strings → shim}/urljoin.test.ts +0 -0
- package/src/{strings → shim}/urljoin.ts +6 -10
- package/src/strings/index.ts +0 -1
- package/tsconfig.json +1 -1
- package/dist/utils.cjs +0 -497
- package/dist/utils.cjs.map +0 -7
- package/dist/utils.js +0 -445
- package/dist/utils.js.map +0 -7
- package/dist/utils.mjs +0 -475
- package/dist/utils.mjs.map +0 -7
- package/lib/cjs/arrays/MaybeArray.d.ts +0 -5
- package/lib/cjs/arrays/MaybeArray.js.map +0 -1
- package/lib/cjs/arrays/index.d.ts +0 -1
- package/lib/cjs/arrays/index.js.map +0 -1
- package/lib/cjs/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/cjs/asyncs/AsyncInterval.js.map +0 -1
- package/lib/cjs/asyncs/LazyPromise.d.ts +0 -5
- package/lib/cjs/asyncs/LazyPromise.js.map +0 -1
- package/lib/cjs/asyncs/MaybePromise.d.ts +0 -1
- package/lib/cjs/asyncs/MaybePromise.js.map +0 -1
- package/lib/cjs/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/cjs/asyncs/generatorOfStream.js.map +0 -1
- package/lib/cjs/asyncs/index.d.ts +0 -7
- package/lib/cjs/asyncs/index.js.map +0 -1
- package/lib/cjs/asyncs/isPromise.d.ts +0 -1
- package/lib/cjs/asyncs/isPromise.js.map +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/cjs/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/cjs/asyncs/sleep.d.ts +0 -1
- package/lib/cjs/asyncs/sleep.js.map +0 -1
- package/lib/cjs/asyncs/timeout.d.ts +0 -4
- package/lib/cjs/asyncs/timeout.js.map +0 -1
- package/lib/cjs/browsers/copy.d.ts +0 -1
- package/lib/cjs/browsers/copy.js.map +0 -1
- package/lib/cjs/browsers/download.d.ts +0 -4
- package/lib/cjs/browsers/download.js.map +0 -1
- package/lib/cjs/browsers/getFileFromDataTransfer.d.ts +0 -4
- package/lib/cjs/browsers/getFileFromDataTransfer.js.map +0 -1
- package/lib/cjs/browsers/index.d.ts +0 -4
- package/lib/cjs/browsers/index.js.map +0 -1
- package/lib/cjs/browsers/loaders.d.ts +0 -6
- package/lib/cjs/browsers/loaders.js.map +0 -1
- package/lib/cjs/formats/formatBytes.d.ts +0 -11
- package/lib/cjs/formats/formatBytes.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -9
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/io/index.d.ts +0 -1
- package/lib/cjs/io/index.js.map +0 -1
- package/lib/cjs/io/isBuffer.d.ts +0 -2
- package/lib/cjs/io/isBuffer.js.map +0 -1
- package/lib/cjs/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/cjs/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/cjs/isomorphics/index.d.ts +0 -1
- package/lib/cjs/isomorphics/index.js +0 -5
- package/lib/cjs/isomorphics/index.js.map +0 -1
- package/lib/cjs/maths/index.d.ts +0 -1
- package/lib/cjs/maths/index.js.map +0 -1
- package/lib/cjs/maths/random.d.ts +0 -3
- package/lib/cjs/maths/random.js.map +0 -1
- package/lib/cjs/strings/camelCase.d.ts +0 -4
- package/lib/cjs/strings/camelCase.js.map +0 -1
- package/lib/cjs/strings/index.d.ts +0 -3
- package/lib/cjs/strings/index.js.map +0 -1
- package/lib/cjs/strings/templates.d.ts +0 -7
- package/lib/cjs/strings/templates.js.map +0 -1
- package/lib/cjs/strings/urljoin.d.ts +0 -2
- package/lib/cjs/strings/urljoin.js +0 -69
- package/lib/cjs/strings/urljoin.js.map +0 -1
- package/lib/cjs/strings/urljoin.test.js +0 -7
- package/lib/cjs/strings/urljoin.test.js.map +0 -1
- package/lib/cjs/validations/asserts.d.ts +0 -2
- package/lib/cjs/validations/asserts.js.map +0 -1
- package/lib/cjs/validations/index.d.ts +0 -4
- package/lib/cjs/validations/index.js.map +0 -1
- package/lib/cjs/validations/isClass.d.ts +0 -1
- package/lib/cjs/validations/isClass.js.map +0 -1
- package/lib/cjs/validations/isDefined.d.ts +0 -1
- package/lib/cjs/validations/isDefined.js.map +0 -1
- package/lib/cjs/validations/isEmptyObject.d.ts +0 -1
- package/lib/cjs/validations/isEmptyObject.js.map +0 -1
- package/lib/esm/isomorphics/index.d.ts +0 -1
- package/lib/esm/isomorphics/index.js +0 -1
- package/lib/esm/strings/urljoin.d.ts +0 -2
- package/lib/esm/strings/urljoin.test.d.ts +0 -1
- package/lib/esnext/arrays/MaybeArray.d.ts +0 -5
- package/lib/esnext/arrays/MaybeArray.js +0 -28
- package/lib/esnext/arrays/MaybeArray.js.map +0 -1
- package/lib/esnext/arrays/index.d.ts +0 -1
- package/lib/esnext/arrays/index.js +0 -2
- package/lib/esnext/arrays/index.js.map +0 -1
- package/lib/esnext/asyncs/AsyncInterval.d.ts +0 -3
- package/lib/esnext/asyncs/AsyncInterval.js +0 -13
- package/lib/esnext/asyncs/AsyncInterval.js.map +0 -1
- package/lib/esnext/asyncs/LazyPromise.d.ts +0 -5
- package/lib/esnext/asyncs/LazyPromise.js +0 -22
- package/lib/esnext/asyncs/LazyPromise.js.map +0 -1
- package/lib/esnext/asyncs/MaybePromise.d.ts +0 -1
- package/lib/esnext/asyncs/MaybePromise.js +0 -2
- package/lib/esnext/asyncs/MaybePromise.js.map +0 -1
- package/lib/esnext/asyncs/generatorOfStream.d.ts +0 -1
- package/lib/esnext/asyncs/generatorOfStream.js +0 -14
- package/lib/esnext/asyncs/generatorOfStream.js.map +0 -1
- package/lib/esnext/asyncs/index.d.ts +0 -7
- package/lib/esnext/asyncs/index.js +0 -8
- package/lib/esnext/asyncs/index.js.map +0 -1
- package/lib/esnext/asyncs/isPromise.d.ts +0 -1
- package/lib/esnext/asyncs/isPromise.js +0 -4
- package/lib/esnext/asyncs/isPromise.js.map +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.d.ts +0 -1
- package/lib/esnext/asyncs/promiseOfCallback.js +0 -18
- package/lib/esnext/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/esnext/asyncs/sleep.d.ts +0 -1
- package/lib/esnext/asyncs/sleep.js +0 -2
- package/lib/esnext/asyncs/sleep.js.map +0 -1
- package/lib/esnext/asyncs/timeout.d.ts +0 -4
- package/lib/esnext/asyncs/timeout.js +0 -22
- package/lib/esnext/asyncs/timeout.js.map +0 -1
- package/lib/esnext/browsers/copy.d.ts +0 -1
- package/lib/esnext/browsers/copy.js +0 -51
- package/lib/esnext/browsers/copy.js.map +0 -1
- package/lib/esnext/browsers/download.d.ts +0 -4
- package/lib/esnext/browsers/download.js +0 -31
- package/lib/esnext/browsers/download.js.map +0 -1
- package/lib/esnext/browsers/getFileFromDataTransfer.d.ts +0 -4
- package/lib/esnext/browsers/getFileFromDataTransfer.js +0 -37
- package/lib/esnext/browsers/getFileFromDataTransfer.js.map +0 -1
- package/lib/esnext/browsers/index.d.ts +0 -4
- package/lib/esnext/browsers/index.js +0 -5
- package/lib/esnext/browsers/index.js.map +0 -1
- package/lib/esnext/browsers/loaders.d.ts +0 -6
- package/lib/esnext/browsers/loaders.js +0 -33
- package/lib/esnext/browsers/loaders.js.map +0 -1
- package/lib/esnext/formats/formatBytes.d.ts +0 -11
- package/lib/esnext/formats/formatBytes.js +0 -27
- package/lib/esnext/formats/formatBytes.js.map +0 -1
- package/lib/esnext/index.d.ts +0 -9
- package/lib/esnext/index.js +0 -10
- package/lib/esnext/index.js.map +0 -1
- package/lib/esnext/io/index.d.ts +0 -1
- package/lib/esnext/io/index.js +0 -2
- package/lib/esnext/io/index.js.map +0 -1
- package/lib/esnext/io/isBuffer.d.ts +0 -2
- package/lib/esnext/io/isBuffer.js +0 -8
- package/lib/esnext/io/isBuffer.js.map +0 -1
- package/lib/esnext/isomorphics/getGlobalThis.d.ts +0 -9
- package/lib/esnext/isomorphics/getGlobalThis.js +0 -21
- package/lib/esnext/isomorphics/getGlobalThis.js.map +0 -1
- package/lib/esnext/isomorphics/index.d.ts +0 -1
- package/lib/esnext/isomorphics/index.js +0 -2
- package/lib/esnext/isomorphics/index.js.map +0 -1
- package/lib/esnext/maths/index.d.ts +0 -1
- package/lib/esnext/maths/index.js +0 -2
- package/lib/esnext/maths/index.js.map +0 -1
- package/lib/esnext/maths/random.d.ts +0 -3
- package/lib/esnext/maths/random.js +0 -16
- package/lib/esnext/maths/random.js.map +0 -1
- package/lib/esnext/strings/camelCase.d.ts +0 -4
- package/lib/esnext/strings/camelCase.js +0 -68
- package/lib/esnext/strings/camelCase.js.map +0 -1
- package/lib/esnext/strings/index.d.ts +0 -3
- package/lib/esnext/strings/index.js +0 -4
- package/lib/esnext/strings/index.js.map +0 -1
- package/lib/esnext/strings/templates.d.ts +0 -7
- package/lib/esnext/strings/templates.js +0 -14
- package/lib/esnext/strings/templates.js.map +0 -1
- package/lib/esnext/strings/urljoin.d.ts +0 -2
- package/lib/esnext/strings/urljoin.js +0 -65
- package/lib/esnext/strings/urljoin.js.map +0 -1
- package/lib/esnext/strings/urljoin.test.d.ts +0 -1
- package/lib/esnext/strings/urljoin.test.js +0 -5
- package/lib/esnext/strings/urljoin.test.js.map +0 -1
- package/lib/esnext/validations/asserts.d.ts +0 -2
- package/lib/esnext/validations/asserts.js +0 -13
- package/lib/esnext/validations/asserts.js.map +0 -1
- package/lib/esnext/validations/index.d.ts +0 -4
- package/lib/esnext/validations/index.js +0 -5
- package/lib/esnext/validations/index.js.map +0 -1
- package/lib/esnext/validations/isClass.d.ts +0 -1
- package/lib/esnext/validations/isClass.js +0 -4
- package/lib/esnext/validations/isClass.js.map +0 -1
- package/lib/esnext/validations/isDefined.d.ts +0 -1
- package/lib/esnext/validations/isDefined.js +0 -4
- package/lib/esnext/validations/isDefined.js.map +0 -1
- package/lib/esnext/validations/isEmptyObject.d.ts +0 -1
- package/lib/esnext/validations/isEmptyObject.js +0 -7
- package/lib/esnext/validations/isEmptyObject.js.map +0 -1
- package/src/isomorphics/index.ts +0 -1
package/lib/cjs/maths/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var maths_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(maths_exports);
|
|
17
|
+
__reExport(maths_exports, require("./random"), module.exports);
|
package/lib/cjs/maths/random.js
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var random_exports = {};
|
|
19
|
+
__export(random_exports, {
|
|
20
|
+
createRandom: () => createRandom
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(random_exports);
|
|
5
23
|
function createRandom(o = {}) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
seed = sum;
|
|
24
|
+
let seed = typeof o.seed === "string" ? 0 : o.seed ?? 0;
|
|
25
|
+
if (typeof o.seed === "string") {
|
|
26
|
+
let sum = 0;
|
|
27
|
+
for (let i = 0; i < o.seed.length; i++) {
|
|
28
|
+
sum += o.seed.charCodeAt(i);
|
|
13
29
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
30
|
+
seed = sum;
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
const x = Math.sin(seed++) * 1e4;
|
|
34
|
+
return x - Math.floor(x);
|
|
35
|
+
};
|
|
18
36
|
}
|
|
19
|
-
exports.createRandom = createRandom;
|
|
20
|
-
//# sourceMappingURL=random.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var urljoin_exports = {};
|
|
19
|
+
__export(urljoin_exports, {
|
|
20
|
+
urljoin: () => urljoin
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(urljoin_exports);
|
|
23
|
+
function urljoin(...args) {
|
|
24
|
+
if (Array.isArray(args[0])) {
|
|
25
|
+
return normalize(args[0]);
|
|
26
|
+
} else {
|
|
27
|
+
return normalize(args);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function normalize(strArray) {
|
|
31
|
+
const resultArray = [];
|
|
32
|
+
if (strArray.length === 0) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
if (typeof strArray[0] !== "string") {
|
|
36
|
+
throw new TypeError("Url must be a string. Received " + strArray[0]);
|
|
37
|
+
}
|
|
38
|
+
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
39
|
+
const first = strArray.shift();
|
|
40
|
+
strArray[0] = first + strArray[0];
|
|
41
|
+
}
|
|
42
|
+
if (strArray[0].match(/^file:\/\/\//)) {
|
|
43
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1:///");
|
|
44
|
+
} else {
|
|
45
|
+
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1://");
|
|
46
|
+
}
|
|
47
|
+
for (let i = 0; i < strArray.length; i++) {
|
|
48
|
+
let component = strArray[i];
|
|
49
|
+
if (typeof component !== "string") {
|
|
50
|
+
throw new TypeError("Url must be a string. Received " + component);
|
|
51
|
+
}
|
|
52
|
+
if (component === "") {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (i > 0) {
|
|
56
|
+
component = component.replace(/^[\/]+/, "");
|
|
57
|
+
}
|
|
58
|
+
if (i < strArray.length - 1) {
|
|
59
|
+
component = component.replace(/[\/]+$/, "");
|
|
60
|
+
} else {
|
|
61
|
+
component = component.replace(/[\/]+$/, "/");
|
|
62
|
+
}
|
|
63
|
+
resultArray.push(component);
|
|
64
|
+
}
|
|
65
|
+
let str = resultArray.join("/");
|
|
66
|
+
str = str.replace(/\/(\?|&|#[^!])/g, "$1");
|
|
67
|
+
const parts = str.split("?");
|
|
68
|
+
str = parts.shift() + (parts.length > 0 ? "?" : "") + parts.join("&");
|
|
69
|
+
return str;
|
|
70
|
+
}
|
|
@@ -1,73 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var camelCase_exports = {};
|
|
19
|
+
__export(camelCase_exports, {
|
|
20
|
+
camelCase: () => camelCase,
|
|
21
|
+
pascalCase: () => pascalCase
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(camelCase_exports);
|
|
5
24
|
function preserveCamelCase(string) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
|
29
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
30
|
-
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
|
31
|
-
}
|
|
25
|
+
let isLastCharLower = false;
|
|
26
|
+
let isLastCharUpper = false;
|
|
27
|
+
let isLastLastCharUpper = false;
|
|
28
|
+
for (let i = 0; i < string.length; i++) {
|
|
29
|
+
const character = string[i];
|
|
30
|
+
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
|
|
31
|
+
string = string.slice(0, i) + "-" + string.slice(i);
|
|
32
|
+
isLastCharLower = false;
|
|
33
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
34
|
+
isLastCharUpper = true;
|
|
35
|
+
i++;
|
|
36
|
+
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
|
|
37
|
+
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
|
|
38
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
39
|
+
isLastCharUpper = false;
|
|
40
|
+
isLastCharLower = true;
|
|
41
|
+
} else {
|
|
42
|
+
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
|
43
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
44
|
+
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
|
32
45
|
}
|
|
33
|
-
|
|
46
|
+
}
|
|
47
|
+
return string;
|
|
34
48
|
}
|
|
35
49
|
function pascalCase(input) {
|
|
36
|
-
|
|
50
|
+
return camelCase(input, { pascalCase: true });
|
|
37
51
|
}
|
|
38
|
-
exports.pascalCase = pascalCase;
|
|
39
52
|
function camelCase(input, options = {
|
|
40
|
-
|
|
53
|
+
pascalCase: false
|
|
41
54
|
}) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
input = preserveCamelCase(input);
|
|
64
|
-
}
|
|
65
|
-
input = input
|
|
66
|
-
.replace(/^[_.\- ]+/, '')
|
|
67
|
-
.toLowerCase()
|
|
68
|
-
.replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase())
|
|
69
|
-
.replace(/\d+(\w|$)/g, (m) => m.toUpperCase());
|
|
70
|
-
return postProcess(input);
|
|
55
|
+
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
56
|
+
throw new TypeError("Expected the input to be `string | string[]`");
|
|
57
|
+
}
|
|
58
|
+
const postProcess = (x) => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
|
|
59
|
+
if (Array.isArray(input)) {
|
|
60
|
+
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
61
|
+
} else {
|
|
62
|
+
input = input.trim();
|
|
63
|
+
}
|
|
64
|
+
if (input.length === 0) {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
if (input.length === 1) {
|
|
68
|
+
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
|
|
69
|
+
}
|
|
70
|
+
const hasUpperCase = input !== input.toLowerCase();
|
|
71
|
+
if (hasUpperCase) {
|
|
72
|
+
input = preserveCamelCase(input);
|
|
73
|
+
}
|
|
74
|
+
input = input.replace(/^[_.\- ]+/, "").toLowerCase().replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()).replace(/\d+(\w|$)/g, (m) => m.toUpperCase());
|
|
75
|
+
return postProcess(input);
|
|
71
76
|
}
|
|
72
|
-
exports.camelCase = camelCase;
|
|
73
|
-
//# sourceMappingURL=camelCase.js.map
|
package/lib/cjs/strings/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var strings_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(strings_exports);
|
|
17
|
+
__reExport(strings_exports, require("./camelCase"), module.exports);
|
|
18
|
+
__reExport(strings_exports, require("./templates"), module.exports);
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var templates_exports = {};
|
|
19
|
+
__export(templates_exports, {
|
|
20
|
+
templateString: () => templateString
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(templates_exports);
|
|
10
23
|
function templateString(template, getter) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getter(g.trim());
|
|
15
|
-
});
|
|
24
|
+
return template.replace(/\${(.*?)}/g, (_, g) => {
|
|
25
|
+
return getter(g.trim());
|
|
26
|
+
});
|
|
16
27
|
}
|
|
17
|
-
exports.templateString = templateString;
|
|
18
|
-
//# sourceMappingURL=templates.js.map
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var asserts_exports = {};
|
|
19
|
+
__export(asserts_exports, {
|
|
20
|
+
assert: () => assert,
|
|
21
|
+
assertIsDefined: () => assertIsDefined
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(asserts_exports);
|
|
4
24
|
function assert(condition, msg) {
|
|
5
|
-
|
|
6
|
-
// throw new AssertionError(msg);
|
|
7
|
-
// }
|
|
8
|
-
console.assert(!condition, msg);
|
|
25
|
+
console.assert(!condition, msg);
|
|
9
26
|
}
|
|
10
|
-
exports.assert = assert;
|
|
11
27
|
function assertIsDefined(val) {
|
|
12
|
-
|
|
13
|
-
// throw new AssertionError(`Expected 'val' to be defined, but received ${val}`);
|
|
14
|
-
// }
|
|
15
|
-
console.assert(val === undefined || val === null, 'Expected defined');
|
|
28
|
+
console.assert(val === void 0 || val === null, "Expected defined");
|
|
16
29
|
}
|
|
17
|
-
exports.assertIsDefined = assertIsDefined;
|
|
18
|
-
//# sourceMappingURL=asserts.js.map
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var validations_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(validations_exports);
|
|
17
|
+
__reExport(validations_exports, require("./asserts"), module.exports);
|
|
18
|
+
__reExport(validations_exports, require("./isDefined"), module.exports);
|
|
19
|
+
__reExport(validations_exports, require("./isEmptyObject"), module.exports);
|
|
20
|
+
__reExport(validations_exports, require("./isClass"), module.exports);
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var isClass_exports = {};
|
|
19
|
+
__export(isClass_exports, {
|
|
20
|
+
isClass: () => isClass
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(isClass_exports);
|
|
4
23
|
function isClass(func) {
|
|
5
|
-
|
|
24
|
+
return typeof func === "function" && /^class\s/.test(Function.prototype.toString.call(func));
|
|
6
25
|
}
|
|
7
|
-
exports.isClass = isClass;
|
|
8
|
-
//# sourceMappingURL=isClass.js.map
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var isDefined_exports = {};
|
|
19
|
+
__export(isDefined_exports, {
|
|
20
|
+
isDefined: () => isDefined
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(isDefined_exports);
|
|
4
23
|
function isDefined(v) {
|
|
5
|
-
|
|
24
|
+
return v !== null && v !== void 0;
|
|
6
25
|
}
|
|
7
|
-
exports.isDefined = isDefined;
|
|
8
|
-
//# sourceMappingURL=isDefined.js.map
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var isEmptyObject_exports = {};
|
|
19
|
+
__export(isEmptyObject_exports, {
|
|
20
|
+
isEmptyObject: () => isEmptyObject
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(isEmptyObject_exports);
|
|
4
23
|
function isEmptyObject(o) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
if (o === null || o === void 0) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return o.constructor === Object && Object.keys(o).length === 0;
|
|
9
28
|
}
|
|
10
|
-
exports.isEmptyObject = isEmptyObject;
|
|
11
|
-
//# sourceMappingURL=isEmptyObject.js.map
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './strings';
|
|
|
5
5
|
export * from './maths';
|
|
6
6
|
export * from './io';
|
|
7
7
|
export * from './browsers';
|
|
8
|
-
export
|
|
8
|
+
export { getGlobalThis } from './isomorphics/getGlobalThis';
|
|
9
9
|
export { formatBytes } from './formats/formatBytes';
|
|
10
|
+
export { urljoin } from './shim/urljoin';
|
package/lib/esm/index.js
CHANGED
|
@@ -5,8 +5,11 @@ export * from "./strings";
|
|
|
5
5
|
export * from "./maths";
|
|
6
6
|
export * from "./io";
|
|
7
7
|
export * from "./browsers";
|
|
8
|
-
|
|
8
|
+
import { getGlobalThis } from "./isomorphics/getGlobalThis";
|
|
9
9
|
import { formatBytes } from "./formats/formatBytes";
|
|
10
|
+
import { urljoin } from "./shim/urljoin";
|
|
10
11
|
export {
|
|
11
|
-
formatBytes
|
|
12
|
+
formatBytes,
|
|
13
|
+
getGlobalThis,
|
|
14
|
+
urljoin
|
|
12
15
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
function urljoin(...args) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
input = args[0];
|
|
2
|
+
if (Array.isArray(args[0])) {
|
|
3
|
+
return normalize(args[0]);
|
|
5
4
|
} else {
|
|
6
|
-
|
|
5
|
+
return normalize(args);
|
|
7
6
|
}
|
|
8
|
-
return normalize(input);
|
|
9
7
|
}
|
|
10
8
|
function normalize(strArray) {
|
|
11
9
|
const resultArray = [];
|
|
File without changes
|
|
File without changes
|
package/lib/esm/strings/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wener/utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Utils for daily use",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utils",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"tsconfig.json"
|
|
44
44
|
],
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build": "make
|
|
46
|
+
"build": "make prepublish",
|
|
47
47
|
"clean": "make clean",
|
|
48
48
|
"dev": "make dev",
|
|
49
49
|
"test": "jest"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/jest": "^
|
|
52
|
+
"@types/jest": "^28",
|
|
53
53
|
"@types/lodash": "^4",
|
|
54
54
|
"@types/node": "^16",
|
|
55
55
|
"dotenv": "^16",
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './strings';
|
|
|
5
5
|
export * from './maths';
|
|
6
6
|
export * from './io';
|
|
7
7
|
export * from './browsers';
|
|
8
|
-
export * from './isomorphics';
|
|
9
8
|
|
|
9
|
+
export { getGlobalThis } from './isomorphics/getGlobalThis';
|
|
10
10
|
export { formatBytes } from './formats/formatBytes';
|
|
11
|
+
export { urljoin } from './shim/urljoin';
|
|
File without changes
|