@wener/utils 1.1.53 → 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.
Files changed (68) hide show
  1. package/lib/arrays/arrayFromAsync.js +11 -3
  2. package/lib/asyncs/AsyncInterval.js +11 -3
  3. package/lib/asyncs/Promises.js +6 -5
  4. package/lib/asyncs/createAsyncIterator.js +11 -3
  5. package/lib/asyncs/createLazyPromise.test.js +11 -3
  6. package/lib/asyncs/generatorOfStream.js +11 -3
  7. package/lib/browsers/download.js +11 -3
  8. package/lib/browsers/loaders.js +11 -3
  9. package/lib/crypto/hashing.js +11 -3
  10. package/lib/crypto/hashing.test.js +11 -3
  11. package/lib/crypto/pem/pem.js +1 -1
  12. package/lib/errors/Errors.js +201 -2
  13. package/lib/fetch/createFetchWith.js +11 -3
  14. package/lib/fetch/dumpRequest.js +12 -4
  15. package/lib/fetch/dumpRequest.test.js +11 -3
  16. package/lib/fetch/dumpResponse.js +11 -3
  17. package/lib/fetch/dumpResponse.test.js +11 -3
  18. package/lib/index.js +9 -8
  19. package/lib/io/ArrayBuffers.js +559 -2
  20. package/lib/io/ByteBuffer.test.js +11 -3
  21. package/lib/io/parseDataUri.js +11 -3
  22. package/lib/io/parseDataUri.test.js +31 -11
  23. package/lib/langs/AsyncCloser.js +11 -3
  24. package/lib/langs/deepFreeze.js +5 -5
  25. package/lib/langs/mixin.js +6 -12
  26. package/lib/langs/mixin.test.js +53 -5
  27. package/lib/langs/mixin2.js +26 -0
  28. package/lib/langs/parseBoolean.js +3 -2
  29. package/lib/langs/parseDate.js +20 -0
  30. package/lib/langs/shallowEqual.js +5 -5
  31. package/lib/libs/ms.js +1 -1
  32. package/lib/maths/random.js +12 -4
  33. package/lib/objects/merge/isMergeableObject.js +1 -1
  34. package/lib/objects/merge/merge.js +1 -1
  35. package/lib/objects/merge/merge.test.js +11 -3
  36. package/lib/objects/set.js +10 -2
  37. package/lib/objects/set.test.js +2 -2
  38. package/lib/scripts/getGenerateContext.js +13 -5
  39. package/lib/server/fetch/createFetchWithProxyByNodeFetch.js +11 -3
  40. package/lib/server/fetch/createFetchWithProxyByUndici.js +11 -3
  41. package/lib/server/polyfill/polyfillBrowser.js +11 -3
  42. package/lib/server/polyfill/polyfillBrowser.test.js +11 -3
  43. package/lib/server/polyfill/polyfillCrypto.js +11 -3
  44. package/lib/server/polyfill/polyfillJsDom.js +31 -11
  45. package/lib/strings/renderTemplate.test.js +2 -2
  46. package/lib/web/getRandomValues.js +1 -1
  47. package/lib/web/structuredClone.js +2 -2
  48. package/package.json +8 -4
  49. package/src/asyncs/Promises.ts +2 -1
  50. package/src/asyncs/timeout.ts +1 -1
  51. package/src/crypto/hashing.ts +7 -6
  52. package/src/crypto/pem/pem.ts +3 -2
  53. package/src/errors/Errors.ts +106 -1
  54. package/src/fetch/dumpRequest.ts +1 -1
  55. package/src/index.ts +10 -8
  56. package/src/io/ArrayBuffers.ts +676 -1
  57. package/src/langs/mixin.test.ts +35 -5
  58. package/src/langs/mixin.ts +46 -65
  59. package/src/langs/mixin2.ts +80 -0
  60. package/src/langs/parseBoolean.ts +9 -1
  61. package/src/langs/parseDate.ts +13 -0
  62. package/src/objects/set.ts +10 -1
  63. package/src/types.d.ts +1 -1
  64. package/tsconfig.json +8 -14
  65. package/lib/errors/Errors.mod.js +0 -206
  66. package/lib/io/ArrayBuffers.mod.js +0 -531
  67. package/src/errors/Errors.mod.ts +0 -104
  68. package/src/io/ArrayBuffers.mod.ts +0 -670
@@ -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 _type_of(obj) {
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
  }
@@ -1,19 +1,13 @@
1
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.
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. All mixins must extend a common base class or an empty class.
5
+ * @param mixins The mixins to apply sequentially.
10
6
  * @returns A class constructor with all mixins applied.
11
7
  *
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) {}
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
- } // https://github.com/1nVitr0/lib-ts-mixin-extended
19
+ }
@@ -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
@@ -1,5 +1,6 @@
1
- export function parseBoolean(s) {
2
- var strict = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
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
  }
@@ -0,0 +1,20 @@
1
+ function _instanceof(left, right) {
2
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
3
+ return !!right[Symbol.hasInstance](left);
4
+ } else {
5
+ return left instanceof right;
6
+ }
7
+ }
8
+ export function parseDate(value) {
9
+ if (!value) {
10
+ return undefined;
11
+ }
12
+ if (_instanceof(value, Date)) {
13
+ return value;
14
+ }
15
+ var parsed = new Date(value);
16
+ if (isNaN(parsed.getTime())) {
17
+ return undefined;
18
+ }
19
+ return parsed;
20
+ }
@@ -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 _type_of(obj) {
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
@@ -1,8 +1,8 @@
1
- // Helpers.
2
1
  function _type_of(obj) {
3
2
  "@swc/helpers - typeof";
4
3
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
4
  }
5
+ // Helpers.
6
6
  var s = 1000;
7
7
  var m = s * 60;
8
8
  var h = m * 60;
@@ -1,4 +1,3 @@
1
- // LCG pseudo random
2
1
  function _define_property(obj, key, value) {
3
2
  if (key in obj) {
4
3
  Object.defineProperty(obj, key, {
@@ -21,9 +20,17 @@ function _ts_generator(thisArg, body) {
21
20
  },
22
21
  trys: [],
23
22
  ops: []
24
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
25
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
26
- return this;
23
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
24
+ return d(g, "next", {
25
+ value: verb(0)
26
+ }), d(g, "throw", {
27
+ value: verb(1)
28
+ }), d(g, "return", {
29
+ value: verb(2)
30
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
31
+ value: function() {
32
+ return this;
33
+ }
27
34
  }), g;
28
35
  function verb(n) {
29
36
  return function(v) {
@@ -103,6 +110,7 @@ function _ts_generator(thisArg, body) {
103
110
  };
104
111
  }
105
112
  }
113
+ // LCG pseudo random
106
114
  export function createRandom() {
107
115
  var _seed = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Date.now();
108
116
  var seed = 0;
@@ -1,8 +1,8 @@
1
- // https://github.com/TehShrike/is-mergeable-object/blob/master/index.js
2
1
  function _type_of(obj) {
3
2
  "@swc/helpers - typeof";
4
3
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5
4
  }
5
+ // https://github.com/TehShrike/is-mergeable-object/blob/master/index.js
6
6
  export function isMergeableObject(value) {
7
7
  return isNonNullObject(value) && !isSpecial(value);
8
8
  }
@@ -1,4 +1,3 @@
1
- // https://github.com/TehShrike/deepmerge/blob/master/index.js
2
1
  function _define_property(obj, key, value) {
3
2
  if (key in obj) {
4
3
  Object.defineProperty(obj, key, {
@@ -53,6 +52,7 @@ function _object_spread_props(target, source) {
53
52
  }
54
53
  return target;
55
54
  }
55
+ // https://github.com/TehShrike/deepmerge/blob/master/index.js
56
56
  import { isMergeableObject as defaultIsMergeableObject } from "./isMergeableObject.js";
57
57
  function emptyTarget(val) {
58
58
  return Array.isArray(val) ? [] : {};
@@ -70,9 +70,17 @@ function _ts_generator(thisArg, body) {
70
70
  },
71
71
  trys: [],
72
72
  ops: []
73
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
74
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
75
- return this;
73
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
74
+ return d(g, "next", {
75
+ value: verb(0)
76
+ }), d(g, "throw", {
77
+ value: verb(1)
78
+ }), d(g, "return", {
79
+ value: verb(2)
80
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
81
+ value: function () {
82
+ return this;
83
+ }
76
84
  }), g;
77
85
  function verb(n) {
78
86
  return function (v) {
@@ -16,11 +16,19 @@ import { parseObjectPath } from "./parseObjectPath.js";
16
16
  var x, k;
17
17
  while (i < len) {
18
18
  k = path[i++];
19
+ // Security: Prevent prototype pollution
19
20
  if (k === "__proto__" || k === "constructor" || k === "prototype")
20
21
  break;
21
22
  // noinspection PointlessArithmeticExpressionJS
22
- current = current[k] = i === len ? merging ? merge(current[k], val) : val : _type_of(x = current[k]) === (typeof path === "undefined" ? "undefined" : _type_of(path)) ? x : path[i] * 0 !== 0 || !!~("" + path[i]).indexOf(".") // eslint-disable-line
23
- ? {} : [];
23
+ current = current[k] = i === len ? merging ? merge(current[k], val) : val : _type_of(x = current[k]) === (typeof path === "undefined" ? "undefined" : _type_of(path)) ? x : // If the next key is NOT an integer-like index, or contains a dot, create an Object.
24
+ // Otherwise, create an Array.
25
+ //
26
+ // path[i] * 0 !== 0 checks if it is NOT a number (NaN * 0 is NaN).
27
+ // !!~('' + path[i]).indexOf('.') checks if it contains a dot.
28
+ //
29
+ // @ts-expect-error hacky type check from dset
30
+ path[i] * 0 !== 0 || !!~("" + path[i]).indexOf(".") // eslint-disable-line
31
+ ? {} : [];
24
32
  }
25
33
  }
26
34
  export function merge(a, b) {
@@ -1,4 +1,4 @@
1
- /* eslint no-proto:0 no-prototype-builtins:0 */ function _instanceof(left, right) {
1
+ function _instanceof(left, right) {
2
2
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
3
3
  return !!right[Symbol.hasInstance](left);
4
4
  }
@@ -6,7 +6,7 @@
6
6
  return left instanceof right;
7
7
  }
8
8
  }
9
- import { describe, expect, it, test } from "vitest";
9
+ /* eslint no-proto:0 no-prototype-builtins:0 */ import { describe, expect, it, test } from "vitest";
10
10
  import { set } from "./set.js";
11
11
  test("set basics", function () {
12
12
  expect(set({}, "c", 3), "should not give return value").toBe(undefined);
@@ -93,9 +93,17 @@ function _ts_generator(thisArg, body) {
93
93
  },
94
94
  trys: [],
95
95
  ops: []
96
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
97
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
98
- return this;
96
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
97
+ return d(g, "next", {
98
+ value: verb(0)
99
+ }), d(g, "throw", {
100
+ value: verb(1)
101
+ }), d(g, "return", {
102
+ value: verb(2)
103
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
104
+ value: function () {
105
+ return this;
106
+ }
99
107
  }), g;
100
108
  function verb(n) {
101
109
  return function (v) {
@@ -347,7 +355,7 @@ export function getGenerateContext(prefix) {
347
355
  }
348
356
  function write(dir, file, content) {
349
357
  return _async_to_generator(function () {
350
- var size, dst, last, e;
358
+ var size, dst, last, unused;
351
359
  return _ts_generator(this, function (_state) {
352
360
  switch (_state.label) {
353
361
  case 0:
@@ -374,7 +382,7 @@ function write(dir, file, content) {
374
382
  4
375
383
  ];
376
384
  case 3:
377
- e = _state.sent();
385
+ unused = _state.sent();
378
386
  return [
379
387
  3,
380
388
  4
@@ -101,9 +101,17 @@ function _ts_generator(thisArg, body) {
101
101
  },
102
102
  trys: [],
103
103
  ops: []
104
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
105
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
106
- return this;
104
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
105
+ return d(g, "next", {
106
+ value: verb(0)
107
+ }), d(g, "throw", {
108
+ value: verb(1)
109
+ }), d(g, "return", {
110
+ value: verb(2)
111
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
112
+ value: function () {
113
+ return this;
114
+ }
107
115
  }), g;
108
116
  function verb(n) {
109
117
  return function (v) {
@@ -139,9 +139,17 @@ function _ts_generator(thisArg, body) {
139
139
  },
140
140
  trys: [],
141
141
  ops: []
142
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
143
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
144
- return this;
142
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
143
+ return d(g, "next", {
144
+ value: verb(0)
145
+ }), d(g, "throw", {
146
+ value: verb(1)
147
+ }), d(g, "return", {
148
+ value: verb(2)
149
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
150
+ value: function () {
151
+ return this;
152
+ }
145
153
  }), g;
146
154
  function verb(n) {
147
155
  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 g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
44
- return this;
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) {
@@ -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 g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
44
- return this;
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) {
@@ -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 g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
44
- return this;
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) {
@@ -37,12 +37,24 @@ function _class_call_check(instance, Constructor) {
37
37
  function _object_without_properties(source, excluded) {
38
38
  if (source == null)
39
39
  return {};
40
- var target = _object_without_properties_loose(source, excluded);
41
- var key, i;
40
+ var target = {}, sourceKeys, key, i;
41
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
42
+ sourceKeys = Reflect.ownKeys(source);
43
+ for (i = 0; i < sourceKeys.length; i++) {
44
+ key = sourceKeys[i];
45
+ if (excluded.indexOf(key) >= 0)
46
+ continue;
47
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
48
+ continue;
49
+ target[key] = source[key];
50
+ }
51
+ return target;
52
+ }
53
+ target = _object_without_properties_loose(source, excluded);
42
54
  if (Object.getOwnPropertySymbols) {
43
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
44
- for (i = 0; i < sourceSymbolKeys.length; i++) {
45
- key = sourceSymbolKeys[i];
55
+ sourceKeys = Object.getOwnPropertySymbols(source);
56
+ for (i = 0; i < sourceKeys.length; i++) {
57
+ key = sourceKeys[i];
46
58
  if (excluded.indexOf(key) >= 0)
47
59
  continue;
48
60
  if (!Object.prototype.propertyIsEnumerable.call(source, key))
@@ -55,13 +67,13 @@ function _object_without_properties(source, excluded) {
55
67
  function _object_without_properties_loose(source, excluded) {
56
68
  if (source == null)
57
69
  return {};
58
- var target = {};
59
- var sourceKeys = Object.keys(source);
60
- var key, i;
70
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
61
71
  for (i = 0; i < sourceKeys.length; i++) {
62
72
  key = sourceKeys[i];
63
73
  if (excluded.indexOf(key) >= 0)
64
74
  continue;
75
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
76
+ continue;
65
77
  target[key] = source[key];
66
78
  }
67
79
  return target;
@@ -76,9 +88,17 @@ function _ts_generator(thisArg, body) {
76
88
  },
77
89
  trys: [],
78
90
  ops: []
79
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
80
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
81
- return this;
91
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
92
+ return d(g, "next", {
93
+ value: verb(0)
94
+ }), d(g, "throw", {
95
+ value: verb(1)
96
+ }), d(g, "return", {
97
+ value: verb(2)
98
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
99
+ value: function () {
100
+ return this;
101
+ }
82
102
  }), g;
83
103
  function verb(n) {
84
104
  return function (v) {
@@ -1,4 +1,4 @@
1
- /* eslint no-template-curly-in-string:0 */ function _array_like_to_array(arr, len) {
1
+ function _array_like_to_array(arr, len) {
2
2
  if (len == null || len > arr.length)
3
3
  len = arr.length;
4
4
  for (var i = 0, arr2 = new Array(len); i < len; i++)
@@ -59,7 +59,7 @@ function _unsupported_iterable_to_array(o, minLen) {
59
59
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
60
60
  return _array_like_to_array(o, minLen);
61
61
  }
62
- import { expect, test } from "vitest";
62
+ /* eslint no-template-curly-in-string:0 */ import { expect, test } from "vitest";
63
63
  import { renderTemplate } from "./renderTemplate.js";
64
64
  test("renderTemplate", function () {
65
65
  var obj = {
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/consistent-type-imports
2
1
  function _instanceof(left, right) {
3
2
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
4
3
  return !!right[Symbol.hasInstance](left);
@@ -8,6 +7,7 @@ function _instanceof(left, right) {
8
7
  }
9
8
  }
10
9
  var _globalThis_crypto_getRandomValues, _globalThis_crypto, _globalThis_msCrypto_getRandomValues, _globalThis_msCrypto;
10
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
11
11
  import { getNodeCrypto } from "../crypto/getNodeCrypto.js";
12
12
  import { getGlobalThis } from "./getGlobalThis.js";
13
13
  var globalThis = getGlobalThis();
@@ -1,8 +1,8 @@
1
- /* eslint no-proto:0 */ function _type_of(obj) {
1
+ function _type_of(obj) {
2
2
  "@swc/helpers - typeof";
3
3
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
4
  }
5
- import { classOf } from "../langs/classOf.js";
5
+ /* eslint no-proto:0 */ import { classOf } from "../langs/classOf.js";
6
6
  /**
7
7
  * Clone an object using structured cloning algorithm
8
8
  *
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@wener/utils",
3
- "version": "1.1.53",
3
+ "version": "1.1.56",
4
4
  "type": "module",
5
5
  "description": "Utils for daily use",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/wener/wode.git"
8
+ "url": "https://github.com/wenerme/wener.git",
9
+ "directory": "packages/wener-utils"
9
10
  },
10
- "homepage": "https://github.com/wenerme/wode#readme",
11
+ "homepage": "https://github.com/wenerme/wener/tree/main/packages/wener-utils",
11
12
  "author": "wener",
12
13
  "license": "MIT",
14
+ "imports": {
15
+ "#/*": "./src/*"
16
+ },
13
17
  "exports": {
14
18
  ".": {
15
19
  "types": "./src/index.ts",
@@ -70,7 +74,7 @@
70
74
  "https-proxy-agent": "^7.0.6",
71
75
  "node-fetch": "^3.3.2",
72
76
  "undici": "^7.16.0",
73
- "zod": "^4.1.9"
77
+ "zod": "^4.1.13"
74
78
  },
75
79
  "publishConfig": {
76
80
  "registry": "https://registry.npmjs.org",
@@ -20,7 +20,8 @@ export class Promises {
20
20
  }
21
21
  let resolve: (value: T | PromiseLike<T>) => void;
22
22
  let reject: (reason?: any) => void;
23
- // @ts-ignore
23
+ // @ts-ignore -- Polyfill/Fallback for environment without Promise.withResolvers
24
+ // eslint-disable-next-line
24
25
  const promise = new Promise<T>((res, rej) => {
25
26
  resolve = res;
26
27
  reject = rej;
@@ -3,7 +3,7 @@ export function timeout<T = any>(
3
3
  ms: number,
4
4
  ): Promise<T> {
5
5
  const error = new TimeoutError();
6
- let timeout: any;
6
+ let timeout: ReturnType<typeof setTimeout>;
7
7
  let ac: AbortController | undefined;
8
8
  if (typeof pending === 'function') {
9
9
  ac = new AbortController();