@wener/utils 1.1.54 → 1.1.56
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/lib/arrays/arrayFromAsync.js +11 -3
- package/lib/asyncs/AsyncInterval.js +11 -3
- package/lib/asyncs/Promises.js +6 -5
- package/lib/asyncs/createAsyncIterator.js +11 -3
- package/lib/asyncs/createLazyPromise.test.js +11 -3
- package/lib/asyncs/generatorOfStream.js +11 -3
- package/lib/browsers/download.js +11 -3
- package/lib/browsers/loaders.js +11 -3
- package/lib/crypto/hashing.js +11 -3
- package/lib/crypto/hashing.test.js +11 -3
- package/lib/crypto/pem/pem.js +1 -1
- package/lib/fetch/createFetchWith.js +11 -3
- package/lib/fetch/dumpRequest.js +12 -4
- package/lib/fetch/dumpRequest.test.js +11 -3
- package/lib/fetch/dumpResponse.js +11 -3
- package/lib/fetch/dumpResponse.test.js +11 -3
- package/lib/io/ArrayBuffers.js +2 -2
- package/lib/io/ByteBuffer.test.js +11 -3
- package/lib/io/parseDataUri.js +11 -3
- package/lib/io/parseDataUri.test.js +31 -11
- package/lib/langs/AsyncCloser.js +11 -3
- package/lib/langs/deepFreeze.js +5 -5
- package/lib/langs/mixin.js +6 -12
- package/lib/langs/mixin.test.js +53 -5
- package/lib/langs/mixin2.js +26 -0
- package/lib/langs/parseBoolean.js +3 -2
- package/lib/langs/shallowEqual.js +5 -5
- package/lib/libs/ms.js +1 -1
- package/lib/maths/random.js +12 -4
- package/lib/objects/merge/isMergeableObject.js +1 -1
- package/lib/objects/merge/merge.js +1 -1
- package/lib/objects/merge/merge.test.js +11 -3
- package/lib/objects/set.js +10 -2
- package/lib/objects/set.test.js +2 -2
- package/lib/scripts/getGenerateContext.js +13 -5
- package/lib/server/fetch/createFetchWithProxyByNodeFetch.js +11 -3
- package/lib/server/fetch/createFetchWithProxyByUndici.js +11 -3
- package/lib/server/polyfill/polyfillBrowser.js +11 -3
- package/lib/server/polyfill/polyfillBrowser.test.js +11 -3
- package/lib/server/polyfill/polyfillCrypto.js +11 -3
- package/lib/server/polyfill/polyfillJsDom.js +31 -11
- package/lib/strings/renderTemplate.test.js +2 -2
- package/lib/web/getRandomValues.js +1 -1
- package/lib/web/structuredClone.js +2 -2
- package/package.json +8 -4
- package/src/asyncs/Promises.ts +2 -1
- package/src/asyncs/timeout.ts +1 -1
- package/src/crypto/hashing.ts +7 -6
- package/src/crypto/pem/pem.ts +3 -2
- package/src/fetch/dumpRequest.ts +1 -1
- package/src/langs/mixin.test.ts +35 -5
- package/src/langs/mixin.ts +46 -65
- package/src/langs/mixin2.ts +80 -0
- package/src/langs/parseBoolean.ts +9 -1
- package/src/objects/set.ts +10 -1
- package/src/types.d.ts +1 -1
- package/tsconfig.json +5 -2
|
@@ -77,9 +77,17 @@ function _ts_generator(thisArg, body) {
|
|
|
77
77
|
},
|
|
78
78
|
trys: [],
|
|
79
79
|
ops: []
|
|
80
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
81
|
-
return
|
|
82
|
-
|
|
80
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
81
|
+
return d(g, "next", {
|
|
82
|
+
value: verb(0)
|
|
83
|
+
}), d(g, "throw", {
|
|
84
|
+
value: verb(1)
|
|
85
|
+
}), d(g, "return", {
|
|
86
|
+
value: verb(2)
|
|
87
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
88
|
+
value: function() {
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
83
91
|
}), g;
|
|
84
92
|
function verb(n) {
|
|
85
93
|
return function(v) {
|
|
@@ -36,9 +36,17 @@ function _ts_generator(thisArg, body) {
|
|
|
36
36
|
},
|
|
37
37
|
trys: [],
|
|
38
38
|
ops: []
|
|
39
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
-
return
|
|
41
|
-
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
40
|
+
return d(g, "next", {
|
|
41
|
+
value: verb(0)
|
|
42
|
+
}), d(g, "throw", {
|
|
43
|
+
value: verb(1)
|
|
44
|
+
}), d(g, "return", {
|
|
45
|
+
value: verb(2)
|
|
46
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
47
|
+
value: function() {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
42
50
|
}), g;
|
|
43
51
|
function verb(n) {
|
|
44
52
|
return function(v) {
|
package/lib/asyncs/Promises.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* A collection of utility functions for working with Promises.
|
|
3
|
-
*/ function _class_call_check(instance, Constructor) {
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
4
2
|
if (!(instance instanceof Constructor)) {
|
|
5
3
|
throw new TypeError("Cannot call a class as a function");
|
|
6
4
|
}
|
|
@@ -26,7 +24,9 @@ function _instanceof(left, right) {
|
|
|
26
24
|
return left instanceof right;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A collection of utility functions for working with Promises.
|
|
29
|
+
*/ export var Promises = /*#__PURE__*/ function() {
|
|
30
30
|
"use strict";
|
|
31
31
|
function Promises() {
|
|
32
32
|
_class_call_check(this, Promises);
|
|
@@ -51,7 +51,8 @@ export var Promises = /*#__PURE__*/ function() {
|
|
|
51
51
|
}
|
|
52
52
|
var resolve;
|
|
53
53
|
var reject;
|
|
54
|
-
// @ts-ignore
|
|
54
|
+
// @ts-ignore -- Polyfill/Fallback for environment without Promise.withResolvers
|
|
55
|
+
// eslint-disable-next-line
|
|
55
56
|
var promise = new Promise(function(res, rej) {
|
|
56
57
|
resolve = res;
|
|
57
58
|
reject = rej;
|
|
@@ -162,9 +162,17 @@ function _ts_generator(thisArg, body) {
|
|
|
162
162
|
},
|
|
163
163
|
trys: [],
|
|
164
164
|
ops: []
|
|
165
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
166
|
-
return
|
|
167
|
-
|
|
165
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
166
|
+
return d(g, "next", {
|
|
167
|
+
value: verb(0)
|
|
168
|
+
}), d(g, "throw", {
|
|
169
|
+
value: verb(1)
|
|
170
|
+
}), d(g, "return", {
|
|
171
|
+
value: verb(2)
|
|
172
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
173
|
+
value: function () {
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
168
176
|
}), g;
|
|
169
177
|
function verb(n) {
|
|
170
178
|
return function (v) {
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
|
@@ -7,9 +7,17 @@ function _ts_generator(thisArg, body) {
|
|
|
7
7
|
},
|
|
8
8
|
trys: [],
|
|
9
9
|
ops: []
|
|
10
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
11
|
-
return
|
|
12
|
-
|
|
10
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
11
|
+
return d(g, "next", {
|
|
12
|
+
value: verb(0)
|
|
13
|
+
}), d(g, "throw", {
|
|
14
|
+
value: verb(1)
|
|
15
|
+
}), d(g, "return", {
|
|
16
|
+
value: verb(2)
|
|
17
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
18
|
+
value: function() {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
13
21
|
}), g;
|
|
14
22
|
function verb(n) {
|
|
15
23
|
return function(v) {
|
package/lib/browsers/download.js
CHANGED
|
@@ -43,9 +43,17 @@ function _ts_generator(thisArg, body) {
|
|
|
43
43
|
},
|
|
44
44
|
trys: [],
|
|
45
45
|
ops: []
|
|
46
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
47
|
-
return
|
|
48
|
-
|
|
46
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
47
|
+
return d(g, "next", {
|
|
48
|
+
value: verb(0)
|
|
49
|
+
}), d(g, "throw", {
|
|
50
|
+
value: verb(1)
|
|
51
|
+
}), d(g, "return", {
|
|
52
|
+
value: verb(2)
|
|
53
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
54
|
+
value: function() {
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
49
57
|
}), g;
|
|
50
58
|
function verb(n) {
|
|
51
59
|
return function(v) {
|
package/lib/browsers/loaders.js
CHANGED
|
@@ -82,9 +82,17 @@ function _ts_generator(thisArg, body) {
|
|
|
82
82
|
},
|
|
83
83
|
trys: [],
|
|
84
84
|
ops: []
|
|
85
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
86
|
-
return
|
|
87
|
-
|
|
85
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
86
|
+
return d(g, "next", {
|
|
87
|
+
value: verb(0)
|
|
88
|
+
}), d(g, "throw", {
|
|
89
|
+
value: verb(1)
|
|
90
|
+
}), d(g, "return", {
|
|
91
|
+
value: verb(2)
|
|
92
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
93
|
+
value: function() {
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
88
96
|
}), g;
|
|
89
97
|
function verb(n) {
|
|
90
98
|
return function(v) {
|
package/lib/crypto/hashing.js
CHANGED
|
@@ -47,9 +47,17 @@ function _ts_generator(thisArg, body) {
|
|
|
47
47
|
},
|
|
48
48
|
trys: [],
|
|
49
49
|
ops: []
|
|
50
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
51
|
-
return
|
|
52
|
-
|
|
50
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
51
|
+
return d(g, "next", {
|
|
52
|
+
value: verb(0)
|
|
53
|
+
}), d(g, "throw", {
|
|
54
|
+
value: verb(1)
|
|
55
|
+
}), d(g, "return", {
|
|
56
|
+
value: verb(2)
|
|
57
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
58
|
+
value: function () {
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
53
61
|
}), g;
|
|
54
62
|
function verb(n) {
|
|
55
63
|
return function (v) {
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
package/lib/crypto/pem/pem.js
CHANGED
|
@@ -173,7 +173,7 @@ export var PEM = /*#__PURE__*/ function () {
|
|
|
173
173
|
type: type,
|
|
174
174
|
header: header,
|
|
175
175
|
// avoid replaceAll
|
|
176
|
-
bytes: ArrayBuffers.from(b64.replace(/[\r\n]/g, ""), "base64")
|
|
176
|
+
bytes: ArrayBuffers.from(b64.replace(/[\r\n]/g, ""), "base64", Uint8Array)
|
|
177
177
|
},
|
|
178
178
|
head: data.slice(0, match.index || 0),
|
|
179
179
|
tail: data.slice((match.index || 0) + match[0].length)
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
package/lib/fetch/dumpRequest.js
CHANGED
|
@@ -112,9 +112,17 @@ function _ts_generator(thisArg, body) {
|
|
|
112
112
|
},
|
|
113
113
|
trys: [],
|
|
114
114
|
ops: []
|
|
115
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
116
|
-
return
|
|
117
|
-
|
|
115
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
116
|
+
return d(g, "next", {
|
|
117
|
+
value: verb(0)
|
|
118
|
+
}), d(g, "throw", {
|
|
119
|
+
value: verb(1)
|
|
120
|
+
}), d(g, "return", {
|
|
121
|
+
value: verb(2)
|
|
122
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
123
|
+
value: function () {
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
118
126
|
}), g;
|
|
119
127
|
function verb(n) {
|
|
120
128
|
return function (v) {
|
|
@@ -246,7 +254,7 @@ export function dumpRequest(_0) {
|
|
|
246
254
|
})
|
|
247
255
|
];
|
|
248
256
|
case 1:
|
|
249
|
-
out
|
|
257
|
+
out = out + _state.sent();
|
|
250
258
|
_state.label = 2;
|
|
251
259
|
case 2:
|
|
252
260
|
log(out);
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
|
@@ -100,9 +100,17 @@ function _ts_generator(thisArg, body) {
|
|
|
100
100
|
},
|
|
101
101
|
trys: [],
|
|
102
102
|
ops: []
|
|
103
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
104
|
-
return
|
|
105
|
-
|
|
103
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
104
|
+
return d(g, "next", {
|
|
105
|
+
value: verb(0)
|
|
106
|
+
}), d(g, "throw", {
|
|
107
|
+
value: verb(1)
|
|
108
|
+
}), d(g, "return", {
|
|
109
|
+
value: verb(2)
|
|
110
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
111
|
+
value: function () {
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
106
114
|
}), g;
|
|
107
115
|
function verb(n) {
|
|
108
116
|
return function (v) {
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
package/lib/io/ArrayBuffers.js
CHANGED
|
@@ -206,8 +206,8 @@ import { isBuffer } from "./isBuffer.js";
|
|
|
206
206
|
return new ArrayBuffer(0);
|
|
207
207
|
}
|
|
208
208
|
var length = buffers.reduce(function (a, b) {
|
|
209
|
-
var
|
|
210
|
-
return a + ((
|
|
209
|
+
var _ref;
|
|
210
|
+
return a + ((_ref = b === null || b === void 0 ? void 0 : b.byteLength) !== null && _ref !== void 0 ? _ref : 0);
|
|
211
211
|
}, 0);
|
|
212
212
|
var r = result ? new Uint8Array(result) : new Uint8Array(length);
|
|
213
213
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -39,9 +39,17 @@ function _ts_generator(thisArg, body) {
|
|
|
39
39
|
},
|
|
40
40
|
trys: [],
|
|
41
41
|
ops: []
|
|
42
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
43
|
-
return
|
|
44
|
-
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
45
53
|
}), g;
|
|
46
54
|
function verb(n) {
|
|
47
55
|
return function (v) {
|
package/lib/io/parseDataUri.js
CHANGED
|
@@ -107,9 +107,17 @@ function _ts_generator(thisArg, body) {
|
|
|
107
107
|
},
|
|
108
108
|
trys: [],
|
|
109
109
|
ops: []
|
|
110
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
111
|
-
return
|
|
112
|
-
|
|
110
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
111
|
+
return d(g, "next", {
|
|
112
|
+
value: verb(0)
|
|
113
|
+
}), d(g, "throw", {
|
|
114
|
+
value: verb(1)
|
|
115
|
+
}), d(g, "return", {
|
|
116
|
+
value: verb(2)
|
|
117
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
118
|
+
value: function () {
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
113
121
|
}), g;
|
|
114
122
|
function verb(n) {
|
|
115
123
|
return function (v) {
|
|
@@ -32,12 +32,24 @@ function _async_to_generator(fn) {
|
|
|
32
32
|
function _object_without_properties(source, excluded) {
|
|
33
33
|
if (source == null)
|
|
34
34
|
return {};
|
|
35
|
-
var target =
|
|
36
|
-
|
|
35
|
+
var target = {}, sourceKeys, key, i;
|
|
36
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
37
|
+
sourceKeys = Reflect.ownKeys(source);
|
|
38
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
39
|
+
key = sourceKeys[i];
|
|
40
|
+
if (excluded.indexOf(key) >= 0)
|
|
41
|
+
continue;
|
|
42
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
|
43
|
+
continue;
|
|
44
|
+
target[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
return target;
|
|
47
|
+
}
|
|
48
|
+
target = _object_without_properties_loose(source, excluded);
|
|
37
49
|
if (Object.getOwnPropertySymbols) {
|
|
38
|
-
|
|
39
|
-
for (i = 0; i <
|
|
40
|
-
key =
|
|
50
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
51
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
52
|
+
key = sourceKeys[i];
|
|
41
53
|
if (excluded.indexOf(key) >= 0)
|
|
42
54
|
continue;
|
|
43
55
|
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
|
@@ -50,13 +62,13 @@ function _object_without_properties(source, excluded) {
|
|
|
50
62
|
function _object_without_properties_loose(source, excluded) {
|
|
51
63
|
if (source == null)
|
|
52
64
|
return {};
|
|
53
|
-
var target = {};
|
|
54
|
-
var sourceKeys = Object.keys(source);
|
|
55
|
-
var key, i;
|
|
65
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
56
66
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
57
67
|
key = sourceKeys[i];
|
|
58
68
|
if (excluded.indexOf(key) >= 0)
|
|
59
69
|
continue;
|
|
70
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
|
71
|
+
continue;
|
|
60
72
|
target[key] = source[key];
|
|
61
73
|
}
|
|
62
74
|
return target;
|
|
@@ -71,9 +83,17 @@ function _ts_generator(thisArg, body) {
|
|
|
71
83
|
},
|
|
72
84
|
trys: [],
|
|
73
85
|
ops: []
|
|
74
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
75
|
-
return
|
|
76
|
-
|
|
86
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
87
|
+
return d(g, "next", {
|
|
88
|
+
value: verb(0)
|
|
89
|
+
}), d(g, "throw", {
|
|
90
|
+
value: verb(1)
|
|
91
|
+
}), d(g, "return", {
|
|
92
|
+
value: verb(2)
|
|
93
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
94
|
+
value: function () {
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
77
97
|
}), g;
|
|
78
98
|
function verb(n) {
|
|
79
99
|
return function (v) {
|
package/lib/langs/AsyncCloser.js
CHANGED
|
@@ -68,9 +68,17 @@ function _ts_generator(thisArg, body) {
|
|
|
68
68
|
},
|
|
69
69
|
trys: [],
|
|
70
70
|
ops: []
|
|
71
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
-
return
|
|
73
|
-
|
|
71
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
72
|
+
return d(g, "next", {
|
|
73
|
+
value: verb(0)
|
|
74
|
+
}), d(g, "throw", {
|
|
75
|
+
value: verb(1)
|
|
76
|
+
}), d(g, "return", {
|
|
77
|
+
value: verb(2)
|
|
78
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
79
|
+
value: function() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
74
82
|
}), g;
|
|
75
83
|
function verb(n) {
|
|
76
84
|
return function(v) {
|
package/lib/langs/deepFreeze.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
function _type_of(obj) {
|
|
2
|
+
"@swc/helpers - typeof";
|
|
3
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* Freezes the given object and all its nested objects recursively.
|
|
3
7
|
*
|
|
4
8
|
* @param {T} obj - The object to freeze.
|
|
5
9
|
* @returns {T} - The frozen object.
|
|
6
|
-
*/ function
|
|
7
|
-
"@swc/helpers - typeof";
|
|
8
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
9
|
-
}
|
|
10
|
-
export function deepFreeze(obj) {
|
|
10
|
+
*/ export function deepFreeze(obj) {
|
|
11
11
|
if (obj === null || (typeof obj === "undefined" ? "undefined" : _type_of(obj)) !== 'object') {
|
|
12
12
|
return obj;
|
|
13
13
|
}
|
package/lib/langs/mixin.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/ /**
|
|
6
|
-
* Applies the given mixins to the a common base class.
|
|
2
|
+
* Applies the given mixins to a common base class.
|
|
7
3
|
*
|
|
8
4
|
* @param Base The base class to apply the mixins to.
|
|
9
|
-
* @param mixins The mixins to apply
|
|
5
|
+
* @param mixins The mixins to apply sequentially.
|
|
10
6
|
* @returns A class constructor with all mixins applied.
|
|
11
7
|
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @example ```ts
|
|
16
|
-
* class Dog extends mixin(Animal, FourLegged, Carnivore, PackHunting, Barking, Domesticated) {}
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* class Dog extends mixin(Animal, FourLegged, Carnivore) {}
|
|
17
11
|
* ```
|
|
18
12
|
*/ export function mixin(Base) {
|
|
19
13
|
for(var _len = arguments.length, mixins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
@@ -22,4 +16,4 @@
|
|
|
22
16
|
return mixins.reduce(function(mix, applyMixin) {
|
|
23
17
|
return applyMixin(mix);
|
|
24
18
|
}, Base);
|
|
25
|
-
}
|
|
19
|
+
}
|
package/lib/langs/mixin.test.js
CHANGED
|
@@ -75,7 +75,60 @@ function _is_native_reflect_construct() {
|
|
|
75
75
|
}
|
|
76
76
|
import { expect, test } from "vitest";
|
|
77
77
|
import { mixin } from "./mixin.js";
|
|
78
|
+
function Ent() {
|
|
79
|
+
return function () { };
|
|
80
|
+
}
|
|
78
81
|
test("mixin", function () {
|
|
82
|
+
// @Ent()
|
|
83
|
+
var User = /*#__PURE__*/ function (_mixin) {
|
|
84
|
+
"use strict";
|
|
85
|
+
_inherits(User, _mixin);
|
|
86
|
+
function User() {
|
|
87
|
+
_class_call_check(this, User);
|
|
88
|
+
var _this;
|
|
89
|
+
_this = _call_super(this, User, arguments), _define_property(_this, "a", void 0);
|
|
90
|
+
return _this;
|
|
91
|
+
}
|
|
92
|
+
return User;
|
|
93
|
+
}(mixin(BaseResource, withFooFields));
|
|
94
|
+
// @Ent()
|
|
95
|
+
var User2 = /*#__PURE__*/ function (_mixin) {
|
|
96
|
+
"use strict";
|
|
97
|
+
_inherits(User2, _mixin);
|
|
98
|
+
function User2() {
|
|
99
|
+
_class_call_check(this, User2);
|
|
100
|
+
var _this;
|
|
101
|
+
_this = _call_super(this, User2, arguments), _define_property(_this, "x", "x");
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
return User2;
|
|
105
|
+
}(mixin(BaseEnt, withFooFields));
|
|
106
|
+
// type works
|
|
107
|
+
var usr = new User();
|
|
108
|
+
expect(usr.foo, "foo");
|
|
109
|
+
var u2 = new User2();
|
|
110
|
+
console.log(u2);
|
|
111
|
+
});
|
|
112
|
+
// <T extends EntityClass<unknown>>(options?: EntityOptions<T>): (target: T) => void;
|
|
113
|
+
// @Ent()
|
|
114
|
+
var BaseResource = function BaseResource() {
|
|
115
|
+
"use strict";
|
|
116
|
+
_class_call_check(this, BaseResource);
|
|
117
|
+
_define_property(this, "id", "");
|
|
118
|
+
};
|
|
119
|
+
// @Ent()
|
|
120
|
+
var BaseEnt = /*#__PURE__*/ function (BaseResource) {
|
|
121
|
+
"use strict";
|
|
122
|
+
_inherits(BaseEnt, BaseResource);
|
|
123
|
+
function BaseEnt() {
|
|
124
|
+
_class_call_check(this, BaseEnt);
|
|
125
|
+
var _this;
|
|
126
|
+
_this = _call_super(this, BaseEnt, arguments), _define_property(_this, "base", "base");
|
|
127
|
+
return _this;
|
|
128
|
+
}
|
|
129
|
+
return BaseEnt;
|
|
130
|
+
}(BaseResource);
|
|
131
|
+
test("mixin deep not working", function () {
|
|
79
132
|
// @ts-ignore
|
|
80
133
|
var User = /*#__PURE__*/ function (_mixin) {
|
|
81
134
|
"use strict";
|
|
@@ -96,11 +149,6 @@ test("mixin", function () {
|
|
|
96
149
|
id: ""
|
|
97
150
|
});
|
|
98
151
|
});
|
|
99
|
-
var BaseResource = function BaseResource() {
|
|
100
|
-
"use strict";
|
|
101
|
-
_class_call_check(this, BaseResource);
|
|
102
|
-
_define_property(this, "id", "");
|
|
103
|
-
};
|
|
104
152
|
function createBarFields() {
|
|
105
153
|
return function (Base) {
|
|
106
154
|
// nested type not working
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper type to convert a union to an intersection.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/ /**
|
|
6
|
+
* Applies the given mixins to the a common base class.
|
|
7
|
+
*
|
|
8
|
+
* @param Base The base class to apply the mixins to.
|
|
9
|
+
* @param mixins The mixins to apply. All mixins must extend a common base class or an empty class.
|
|
10
|
+
* @returns A class constructor with all mixins applied.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam T The type of the base class.
|
|
13
|
+
* @typeParam M The type of the mixin functions.
|
|
14
|
+
*
|
|
15
|
+
* @example ```ts
|
|
16
|
+
* class Dog extends mixin(Animal, FourLegged, Carnivore, PackHunting, Barking, Domesticated) {}
|
|
17
|
+
* ```
|
|
18
|
+
*/ export function mixin(Base) {
|
|
19
|
+
for(var _len = arguments.length, mixins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
20
|
+
mixins[_key - 1] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
return mixins.reduce(function(mix, applyMixin) {
|
|
23
|
+
return applyMixin(mix);
|
|
24
|
+
}, Base);
|
|
25
|
+
} // this is complex, may cause ts unable to resolve prototype typing
|
|
26
|
+
// https://github.com/1nVitr0/lib-ts-mixin-extended
|