@wener/utils 1.1.54 → 1.1.58
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/getFileFromDataTransfer.js +2 -2
- 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/crypto/randomUUIDv7.js +63 -0
- package/lib/crypto/randomUUIDv7.test.js +79 -0
- package/lib/fetch/createFetchWith.js +12 -4
- 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/index.js +2 -1
- package/lib/io/ArrayBuffers.js +2 -2
- package/lib/io/ByteBuffer.test.js +11 -3
- package/lib/io/dump.js +1 -1
- 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 +50 -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/clamp.js +5 -84
- package/lib/maths/clamp.test.js +33 -35
- package/lib/maths/createRandom.test.js +271 -29
- package/lib/maths/random.js +176 -154
- 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/getGlobalThis.js +0 -2
- package/lib/web/getRandomValues.js +5 -11
- package/lib/web/structuredClone.js +2 -2
- package/package.json +10 -6
- 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/crypto/randomUUIDv7.test.ts +82 -0
- package/src/crypto/randomUUIDv7.ts +79 -0
- package/src/fetch/dumpRequest.ts +1 -1
- package/src/index.ts +9 -2
- package/src/langs/mixin.test.ts +32 -5
- package/src/langs/mixin.ts +46 -65
- package/src/langs/mixin2.ts +80 -0
- package/src/langs/parseBoolean.ts +18 -1
- package/src/maths/clamp.test.ts +12 -9
- package/src/maths/clamp.ts +10 -16
- package/src/maths/createRandom.test.ts +199 -11
- package/src/maths/random.ts +190 -33
- package/src/objects/set.ts +10 -1
- package/src/types.d.ts +1 -1
- package/src/web/getGlobalThis.ts +1 -2
- package/src/web/getRandomValues.ts +14 -15
- package/tsconfig.json +6 -12
- package/src/schema/README.md +0 -2
|
@@ -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
|
@@ -76,6 +76,56 @@ function _is_native_reflect_construct() {
|
|
|
76
76
|
import { expect, test } from "vitest";
|
|
77
77
|
import { mixin } from "./mixin.js";
|
|
78
78
|
test("mixin", function () {
|
|
79
|
+
// @Ent()
|
|
80
|
+
var User = /*#__PURE__*/ function (_mixin) {
|
|
81
|
+
"use strict";
|
|
82
|
+
_inherits(User, _mixin);
|
|
83
|
+
function User() {
|
|
84
|
+
_class_call_check(this, User);
|
|
85
|
+
var _this;
|
|
86
|
+
_this = _call_super(this, User, arguments), _define_property(_this, "a", void 0);
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
return User;
|
|
90
|
+
}(mixin(BaseResource, withFooFields));
|
|
91
|
+
// @Ent()
|
|
92
|
+
var User2 = /*#__PURE__*/ function (_mixin) {
|
|
93
|
+
"use strict";
|
|
94
|
+
_inherits(User2, _mixin);
|
|
95
|
+
function User2() {
|
|
96
|
+
_class_call_check(this, User2);
|
|
97
|
+
var _this;
|
|
98
|
+
_this = _call_super(this, User2, arguments), _define_property(_this, "x", "x");
|
|
99
|
+
return _this;
|
|
100
|
+
}
|
|
101
|
+
return User2;
|
|
102
|
+
}(mixin(BaseEnt, withFooFields));
|
|
103
|
+
// type works
|
|
104
|
+
var usr = new User();
|
|
105
|
+
expect(usr.foo, "foo");
|
|
106
|
+
var u2 = new User2();
|
|
107
|
+
console.log(u2);
|
|
108
|
+
});
|
|
109
|
+
// <T extends EntityClass<unknown>>(options?: EntityOptions<T>): (target: T) => void;
|
|
110
|
+
// @Ent()
|
|
111
|
+
var BaseResource = function BaseResource() {
|
|
112
|
+
"use strict";
|
|
113
|
+
_class_call_check(this, BaseResource);
|
|
114
|
+
_define_property(this, "id", "");
|
|
115
|
+
};
|
|
116
|
+
// @Ent()
|
|
117
|
+
var BaseEnt = /*#__PURE__*/ function (BaseResource) {
|
|
118
|
+
"use strict";
|
|
119
|
+
_inherits(BaseEnt, BaseResource);
|
|
120
|
+
function BaseEnt() {
|
|
121
|
+
_class_call_check(this, BaseEnt);
|
|
122
|
+
var _this;
|
|
123
|
+
_this = _call_super(this, BaseEnt, arguments), _define_property(_this, "base", "base");
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
return BaseEnt;
|
|
127
|
+
}(BaseResource);
|
|
128
|
+
test("mixin deep not working", function () {
|
|
79
129
|
// @ts-ignore
|
|
80
130
|
var User = /*#__PURE__*/ function (_mixin) {
|
|
81
131
|
"use strict";
|
|
@@ -96,11 +146,6 @@ test("mixin", function () {
|
|
|
96
146
|
id: ""
|
|
97
147
|
});
|
|
98
148
|
});
|
|
99
|
-
var BaseResource = function BaseResource() {
|
|
100
|
-
"use strict";
|
|
101
|
-
_class_call_check(this, BaseResource);
|
|
102
|
-
_define_property(this, "id", "");
|
|
103
|
-
};
|
|
104
149
|
function createBarFields() {
|
|
105
150
|
return function (Base) {
|
|
106
151
|
// 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
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function parseBoolean(s) {
|
|
2
|
-
var
|
|
1
|
+
export function parseBoolean(s, options) {
|
|
2
|
+
var _ref;
|
|
3
|
+
var strict = typeof options === 'boolean' ? options : (_ref = options === null || options === void 0 ? void 0 : options.strict) !== null && _ref !== void 0 ? _ref : false;
|
|
3
4
|
if (typeof s === 'boolean') {
|
|
4
5
|
return s;
|
|
5
6
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
* shallow compare - support object, array
|
|
3
7
|
*
|
|
4
8
|
* @see {@link https://github.com/pmndrs/zustand/blob/main/src/shallow.ts zustand/src/shallow.ts}
|
|
5
|
-
*/ function
|
|
6
|
-
"@swc/helpers - typeof";
|
|
7
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
8
|
-
}
|
|
9
|
-
export function shallowEqual(objA, objB) {
|
|
9
|
+
*/ export function shallowEqual(objA, objB) {
|
|
10
10
|
if (Object.is(objA, objB)) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
package/lib/libs/ms.js
CHANGED
package/lib/maths/clamp.js
CHANGED
|
@@ -1,90 +1,11 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (
|
|
3
|
-
|
|
4
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
-
arr2[i] = arr[i];
|
|
6
|
-
return arr2;
|
|
7
|
-
}
|
|
8
|
-
function _array_with_holes(arr) {
|
|
9
|
-
if (Array.isArray(arr))
|
|
10
|
-
return arr;
|
|
11
|
-
}
|
|
12
|
-
function _iterable_to_array_limit(arr, i) {
|
|
13
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
14
|
-
if (_i == null)
|
|
15
|
-
return;
|
|
16
|
-
var _arr = [];
|
|
17
|
-
var _n = true;
|
|
18
|
-
var _d = false;
|
|
19
|
-
var _s, _e;
|
|
20
|
-
try {
|
|
21
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
22
|
-
_arr.push(_s.value);
|
|
23
|
-
if (i && _arr.length === i)
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
_d = true;
|
|
29
|
-
_e = err;
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
try {
|
|
33
|
-
if (!_n && _i["return"] != null)
|
|
34
|
-
_i["return"]();
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
if (_d)
|
|
38
|
-
throw _e;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return _arr;
|
|
42
|
-
}
|
|
43
|
-
function _non_iterable_rest() {
|
|
44
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
-
}
|
|
46
|
-
function _sliced_to_array(arr, i) {
|
|
47
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
48
|
-
}
|
|
49
|
-
function _type_of(obj) {
|
|
50
|
-
"@swc/helpers - typeof";
|
|
51
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
52
|
-
}
|
|
53
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
54
|
-
if (!o)
|
|
55
|
-
return;
|
|
56
|
-
if (typeof o === "string")
|
|
57
|
-
return _array_like_to_array(o, minLen);
|
|
58
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
59
|
-
if (n === "Object" && o.constructor)
|
|
60
|
-
n = o.constructor.name;
|
|
61
|
-
if (n === "Map" || n === "Set")
|
|
62
|
-
return Array.from(n);
|
|
63
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
64
|
-
return _array_like_to_array(o, minLen);
|
|
65
|
-
}
|
|
66
|
-
import { isDefined } from "../langs/isDefined.js";
|
|
67
|
-
import { isNil } from "../langs/isNil.js";
|
|
68
|
-
export function clamp(value) {
|
|
69
|
-
for (var _len = arguments.length, o = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
70
|
-
o[_key - 1] = arguments[_key];
|
|
71
|
-
}
|
|
72
|
-
var min, max, def;
|
|
73
|
-
if (o.length === 1 && o[0] && _type_of(o[0]) === "object") {
|
|
74
|
-
var ref, ref1;
|
|
75
|
-
ref = o[0], min = ref.min, max = ref.max, ref1 = ref.default, def = ref1 === void 0 ? min : ref1, ref;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
var ref2, ref3;
|
|
79
|
-
ref2 = _sliced_to_array(o, 3), min = ref2[0], max = ref2[1], ref3 = ref2[2], def = ref3 === void 0 ? min : ref3, ref2;
|
|
80
|
-
}
|
|
81
|
-
if (isNil(value)) {
|
|
82
|
-
return def;
|
|
1
|
+
export function clamp(value, min, max, def) {
|
|
2
|
+
if (value == null) {
|
|
3
|
+
return def !== null && def !== void 0 ? def : min;
|
|
83
4
|
}
|
|
84
|
-
if (
|
|
5
|
+
if (min != null && value < min) {
|
|
85
6
|
return min;
|
|
86
7
|
}
|
|
87
|
-
if (
|
|
8
|
+
if (max != null && value > max) {
|
|
88
9
|
return max;
|
|
89
10
|
}
|
|
90
11
|
return value;
|
package/lib/maths/clamp.test.js
CHANGED
|
@@ -63,6 +63,7 @@ import { expect, test } from "vitest";
|
|
|
63
63
|
import { clamp } from "./clamp.js";
|
|
64
64
|
test("clamp", function () {
|
|
65
65
|
for (var _i = 0, _iter = [
|
|
66
|
+
// 基本用法
|
|
66
67
|
[
|
|
67
68
|
[
|
|
68
69
|
null,
|
|
@@ -116,68 +117,65 @@ test("clamp", function () {
|
|
|
116
117
|
],
|
|
117
118
|
[
|
|
118
119
|
[
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
120
|
+
0,
|
|
121
|
+
1,
|
|
122
|
+
10,
|
|
123
|
+
5
|
|
124
124
|
],
|
|
125
|
-
|
|
125
|
+
1
|
|
126
126
|
],
|
|
127
|
+
// 只限制 min
|
|
127
128
|
[
|
|
128
129
|
[
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
max: 10
|
|
133
|
-
}
|
|
130
|
+
1,
|
|
131
|
+
2,
|
|
132
|
+
undefined
|
|
134
133
|
],
|
|
135
|
-
|
|
134
|
+
2
|
|
136
135
|
],
|
|
137
136
|
[
|
|
138
137
|
[
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
max: 10,
|
|
143
|
-
default: 5
|
|
144
|
-
}
|
|
138
|
+
5,
|
|
139
|
+
2,
|
|
140
|
+
undefined
|
|
145
141
|
],
|
|
146
142
|
5
|
|
147
143
|
],
|
|
144
|
+
// 只限制 max
|
|
148
145
|
[
|
|
149
146
|
[
|
|
150
|
-
2n,
|
|
151
147
|
1,
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
undefined,
|
|
149
|
+
0
|
|
154
150
|
],
|
|
155
|
-
|
|
151
|
+
0
|
|
156
152
|
],
|
|
157
153
|
[
|
|
158
154
|
[
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
5,
|
|
156
|
+
undefined,
|
|
157
|
+
10
|
|
161
158
|
],
|
|
162
|
-
|
|
159
|
+
5
|
|
163
160
|
],
|
|
161
|
+
// BigInt
|
|
164
162
|
[
|
|
165
163
|
[
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
2n,
|
|
165
|
+
1n,
|
|
166
|
+
10n,
|
|
167
|
+
5n
|
|
169
168
|
],
|
|
170
|
-
|
|
171
|
-
],
|
|
172
|
-
[
|
|
173
|
-
[],
|
|
174
|
-
undefined
|
|
169
|
+
2n
|
|
175
170
|
],
|
|
176
171
|
[
|
|
177
172
|
[
|
|
178
|
-
|
|
173
|
+
11n,
|
|
174
|
+
1n,
|
|
175
|
+
10n,
|
|
176
|
+
5n
|
|
179
177
|
],
|
|
180
|
-
|
|
178
|
+
10n
|
|
181
179
|
]
|
|
182
180
|
]; _i < _iter.length; _i++) {
|
|
183
181
|
var _iter__i = _sliced_to_array(_iter[_i], 2), a = _iter__i[0], b = _iter__i[1];
|