@unicom-cloud/utils 0.1.4 → 0.1.5

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.
@@ -1,154 +1,136 @@
1
- var P = Object.defineProperty;
2
- var Y = (i) => {
3
- throw TypeError(i);
4
- };
5
- var O = (i, t, e) => t in i ? P(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var R = (i, t, e) => O(i, typeof t != "symbol" ? t + "" : t, e), N = (i, t, e) => t.has(i) || Y("Cannot " + e);
7
- var s = (i, t, e) => (N(i, t, "read from private field"), e ? e.call(i) : t.get(i)), r = (i, t, e) => t.has(i) ? Y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), o = (i, t, e, n) => (N(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), x = (i, t, e) => (N(i, t, "access private method"), e);
8
- const C = "A", g = "*", v = "J", j = "j", q = "b", V = "K", W = "V", k = "D", H = "E", J = "!", K = "false", Q = "k", X = "H", Z = "h", $ = "F", ee = "I", te = "L", se = "G", ie = "O", ne = "M", re = "NaN", oe = "i", ae = "z", ce = "null", he = "P", Re = "$", de = "R", _e = "<redacted>", Te = "@", ue = "r", Se = "S", fe = ":", ye = "s", Ae = "true", pe = "l", le = "g", Ee = "o", we = "C", Ie = "u", Ne = "U";
9
- let b = !0;
1
+ const T = "A", u = "*", S = "J", f = "j", l = "b", y = "K", A = "V", p = "D", E = "E", w = "!", I = "false", N = "k", b = "H", L = "h", m = "F", B = "I", F = "L", U = "G", Y = "O", x = "M", D = "NaN", M = "i", P = "z", O = "null", z = "P", G = "$", C = "R", g = "<redacted>", v = "@", j = "r", q = "S", V = ":", W = "s", k = "true", H = "l", J = "g", K = "o", Q = "C", X = "u", Z = "U";
2
+ let a = !0;
10
3
  try {
11
4
  new File([], "");
12
5
  } catch {
13
- b = !1;
6
+ a = !1;
14
7
  }
15
- var l, w, M;
16
- class be {
17
- constructor() {
18
- r(this, w);
19
- R(this, "p", 0);
20
- r(this, l, []);
8
+ class $ {
9
+ p = 0;
10
+ #t = [];
11
+ #e(e) {
12
+ this.p === 0 ? e() : this.#t.push(e);
21
13
  }
22
14
  add() {
23
15
  this.p++;
24
16
  }
25
17
  done() {
26
18
  if (--this.p === 0) {
27
- let t;
28
- for (; (t = s(this, l).shift()) !== void 0; )
29
- t();
19
+ let e;
20
+ for (; (e = this.#t.shift()) !== void 0; )
21
+ e();
30
22
  }
31
23
  }
32
24
  wait() {
33
- return new Promise(x(this, w, M).bind(this));
25
+ return new Promise(this.#e.bind(this));
34
26
  }
35
27
  }
36
- l = new WeakMap(), w = new WeakSet(), M = function(t) {
37
- this.p === 0 ? t() : s(this, l).push(t);
38
- };
39
- class B {
28
+ class c {
29
+ promise;
30
+ resolve;
31
+ reject;
40
32
  constructor() {
41
- R(this, "promise");
42
- R(this, "resolve");
43
- R(this, "reject");
44
- this.promise = new Promise((t, e) => {
45
- this.resolve = t, this.reject = e;
33
+ this.promise = new Promise((e, t) => {
34
+ this.resolve = e, this.reject = t;
46
35
  });
47
36
  }
48
37
  }
49
- var E, d;
50
- class z {
38
+ class d {
39
+ iterable;
40
+ #t = new c();
41
+ #e = this.#t;
51
42
  constructor() {
52
- R(this, "iterable");
53
- r(this, E, new B());
54
- r(this, d, s(this, E));
55
- this.iterable = (async function* () {
56
- let t = s(this, E);
43
+ this.iterable = async function* () {
44
+ let e = this.#t;
57
45
  for (; ; ) {
58
- const e = await t.promise;
59
- if (e.done)
46
+ const t = await e.promise;
47
+ if (t.done)
60
48
  return;
61
- yield e.value, t = e.next;
49
+ yield t.value, e = t.next;
62
50
  }
63
- }).bind(this)();
51
+ }.bind(this)();
64
52
  }
65
53
  resolve() {
66
- s(this, d).resolve({ done: !0 });
54
+ this.#e.resolve({ done: !0 });
67
55
  }
68
- reject(t) {
69
- s(this, d).promise.catch(() => {
70
- }), s(this, d).reject(t);
56
+ reject(e) {
57
+ this.#e.promise.catch(() => {
58
+ }), this.#e.reject(e);
71
59
  }
72
- yield(t) {
73
- const e = new B();
74
- s(this, d).resolve({
60
+ yield(e) {
61
+ const t = new c();
62
+ this.#e.resolve({
75
63
  done: !1,
76
- value: t,
77
- next: e
78
- }), o(this, d, e);
64
+ value: e,
65
+ next: t
66
+ }), this.#e = t;
79
67
  }
80
68
  }
81
- E = new WeakMap(), d = new WeakMap();
82
- class Le extends z {
83
- constructor() {
84
- super(...arguments);
85
- R(this, "readable", new ReadableStream({
86
- start: async (e) => {
87
- try {
88
- for await (const n of this.iterable)
89
- e.enqueue(n);
90
- e.close();
91
- } catch (n) {
92
- e.error(n);
93
- }
69
+ class ee extends d {
70
+ readable = new ReadableStream({
71
+ start: async (e) => {
72
+ try {
73
+ for await (const t of this.iterable)
74
+ e.enqueue(t);
75
+ e.close();
76
+ } catch (t) {
77
+ e.error(t);
94
78
  }
95
- }));
96
- }
79
+ }
80
+ });
97
81
  }
98
- var _, T, a;
99
- const L = class L extends Blob {
100
- constructor(e, n, h, I) {
101
- super();
102
- R(this, "promise");
103
- r(this, _);
104
- r(this, T);
105
- r(this, a, {});
106
- if (typeof e < "u") {
82
+ class h extends Blob {
83
+ promise;
84
+ #t;
85
+ #e;
86
+ #s = {};
87
+ constructor(e, t, s, o) {
88
+ if (super(), typeof e < "u") {
107
89
  this.promise = e.promise;
108
- let y = s(e, a).start ?? 0;
109
- typeof n < "u" && (y += n), s(this, a).start = y;
110
- let A = s(e, a).end;
111
- typeof h < "u" && (A = (s(e, a).start ?? 0) + h), s(this, a).end = A, o(this, T, I ?? (e == null ? void 0 : e.type)), o(this, _, (A ?? e.size) - y);
90
+ let i = e.#s.start ?? 0;
91
+ typeof t < "u" && (i += t), this.#s.start = i;
92
+ let r = e.#s.end;
93
+ typeof s < "u" && (r = (e.#s.start ?? 0) + s), this.#s.end = r, this.#e = o ?? e?.type, this.#t = (r ?? e.size) - i;
112
94
  }
113
95
  }
114
96
  get size() {
115
- if (typeof s(this, _) > "u")
97
+ if (typeof this.#t > "u")
116
98
  throw new Error("Size is not set");
117
- return s(this, _);
99
+ return this.#t;
118
100
  }
119
101
  set size(e) {
120
- o(this, _, e);
102
+ this.#t = e;
121
103
  }
122
104
  get type() {
123
- if (typeof s(this, T) > "u")
105
+ if (typeof this.#e > "u")
124
106
  throw new Error("Type is not set");
125
- return s(this, T);
107
+ return this.#e;
126
108
  }
127
109
  set type(e) {
128
- o(this, T, e);
110
+ this.#e = e;
129
111
  }
130
112
  async arrayBuffer() {
131
113
  if (!this.promise)
132
114
  throw new Error("Promise is not set");
133
115
  const e = await this.promise;
134
- return s(this, a) ? e.slice(
135
- s(this, a).start,
136
- s(this, a).end
116
+ return this.#s ? e.slice(
117
+ this.#s.start,
118
+ this.#s.end
137
119
  ) : e;
138
120
  }
139
121
  bytes() {
140
122
  return this.arrayBuffer().then((e) => new Uint8Array(e));
141
123
  }
142
- slice(e, n, h) {
143
- return new L(this, e, n, h);
124
+ slice(e, t, s) {
125
+ return new h(this, e, t, s);
144
126
  }
145
127
  stream() {
146
128
  return new ReadableStream({
147
129
  start: async (e) => {
148
130
  try {
149
131
  e.enqueue(await this.bytes()), e.close();
150
- } catch (n) {
151
- e.error(n);
132
+ } catch (t) {
133
+ e.error(t);
152
134
  }
153
135
  }
154
136
  });
@@ -156,76 +138,78 @@ const L = class L extends Blob {
156
138
  text() {
157
139
  return this.bytes().then((e) => new TextDecoder().decode(e));
158
140
  }
159
- };
160
- _ = new WeakMap(), T = new WeakMap(), a = new WeakMap();
161
- let F = L;
162
- const m = b ? File : Blob;
163
- var p, u, S, f, c;
164
- const U = class U extends m {
165
- constructor(e, n, h, I) {
166
- var t = (...Ye) => (super(...Ye), R(this, "promise"), r(this, p), r(this, u), r(this, S), r(this, f), r(this, c, {}), this);
167
- if (b ? t([], "") : t([]), typeof e < "u") {
141
+ }
142
+ const _ = a ? File : Blob;
143
+ class R extends _ {
144
+ promise;
145
+ #t;
146
+ #e;
147
+ #s;
148
+ #r;
149
+ #i = {};
150
+ constructor(e, t, s, o) {
151
+ if (a ? super([], "") : super([]), typeof e < "u") {
168
152
  this.promise = e.promise;
169
- let y = s(e, c).start ?? 0;
170
- typeof n < "u" && (y += n), s(this, c).start = y;
171
- let A = s(e, c).end;
172
- typeof h < "u" && (A = (s(e, c).start ?? 0) + h), s(this, c).end = A, o(this, u, I ?? (e == null ? void 0 : e.type)), o(this, S, e.name), o(this, f, e.lastModified);
153
+ let i = e.#i.start ?? 0;
154
+ typeof t < "u" && (i += t), this.#i.start = i;
155
+ let r = e.#i.end;
156
+ typeof s < "u" && (r = (e.#i.start ?? 0) + s), this.#i.end = r, this.#e = o ?? e?.type, this.#s = e.name, this.#r = e.lastModified;
173
157
  }
174
158
  }
175
159
  get name() {
176
- if (typeof s(this, S) > "u")
160
+ if (typeof this.#s > "u")
177
161
  throw new Error("Name is not set");
178
- return s(this, S);
162
+ return this.#s;
179
163
  }
180
164
  set name(e) {
181
- o(this, S, e);
165
+ this.#s = e;
182
166
  }
183
167
  get lastModified() {
184
- if (typeof s(this, f) > "u")
168
+ if (typeof this.#r > "u")
185
169
  throw new Error("Last modified is not set");
186
- return s(this, f);
170
+ return this.#r;
187
171
  }
188
172
  set lastModified(e) {
189
- o(this, f, e);
173
+ this.#r = e;
190
174
  }
191
175
  get size() {
192
- if (typeof s(this, p) > "u")
176
+ if (typeof this.#t > "u")
193
177
  throw new Error("Size is not set");
194
- return s(this, p);
178
+ return this.#t;
195
179
  }
196
180
  set size(e) {
197
- o(this, p, e);
181
+ this.#t = e;
198
182
  }
199
183
  get type() {
200
- if (typeof s(this, u) > "u")
184
+ if (typeof this.#e > "u")
201
185
  throw new Error("Type is not set");
202
- return s(this, u);
186
+ return this.#e;
203
187
  }
204
188
  set type(e) {
205
- o(this, u, e);
189
+ this.#e = e;
206
190
  }
207
191
  async arrayBuffer() {
208
192
  if (!this.promise)
209
193
  throw new Error("Promise is not set");
210
194
  const e = await this.promise;
211
- return s(this, c) ? e.slice(
212
- s(this, c).start,
213
- s(this, c).end
195
+ return this.#i ? e.slice(
196
+ this.#i.start,
197
+ this.#i.end
214
198
  ) : e;
215
199
  }
216
200
  bytes() {
217
201
  return this.arrayBuffer().then((e) => new Uint8Array(e));
218
202
  }
219
- slice(e, n, h) {
220
- return new U(this, e, n, h);
203
+ slice(e, t, s) {
204
+ return new R(this, e, t, s);
221
205
  }
222
206
  stream() {
223
207
  return new ReadableStream({
224
208
  start: async (e) => {
225
209
  try {
226
210
  e.enqueue(await this.bytes()), e.close();
227
- } catch (n) {
228
- e.error(n);
211
+ } catch (t) {
212
+ e.error(t);
229
213
  }
230
214
  }
231
215
  });
@@ -233,55 +217,53 @@ const U = class U extends m {
233
217
  text() {
234
218
  return this.bytes().then((e) => new TextDecoder().decode(e));
235
219
  }
236
- };
237
- p = new WeakMap(), u = new WeakMap(), S = new WeakMap(), f = new WeakMap(), c = new WeakMap();
238
- let D = U;
220
+ }
239
221
  export {
240
- B as Deferred,
241
- z as DeferredAsyncIterable,
242
- Le as DeferredReadableStream,
243
- C as STR_ARRAY_BUFFER,
244
- g as STR_ASYNC_ITERABLE,
245
- q as STR_BIGINT,
246
- v as STR_BIG_INT_64_ARRAY,
247
- j as STR_BIG_UINT_64_ARRAY,
248
- V as STR_BLOB,
249
- W as STR_DATA_VIEW,
250
- k as STR_DATE,
251
- H as STR_ERROR,
252
- J as STR_FAILURE,
253
- K as STR_FALSE,
254
- Q as STR_FILE,
255
- X as STR_FLOAT_32_ARRAY,
256
- Z as STR_FLOAT_64_ARRAY,
257
- $ as STR_FORM_DATA,
258
- ee as STR_INFINITY,
259
- te as STR_INT_16_ARRAY,
260
- se as STR_INT_32_ARRAY,
261
- ie as STR_INT_8_ARRAY,
262
- ne as STR_MAP,
263
- oe as STR_NEGATIVE_INFINITY,
264
- ae as STR_NEGATIVE_ZERO,
265
- ce as STR_NULL,
266
- re as STR_NaN,
267
- he as STR_PLUGIN,
268
- Re as STR_PROMISE,
269
- de as STR_READABLE_STREAM,
270
- _e as STR_REDACTED,
271
- Te as STR_REFERENCE_SYMBOL,
272
- ue as STR_REGEXP,
273
- Se as STR_SET,
274
- fe as STR_SUCCESS,
275
- ye as STR_SYMBOL,
276
- Ae as STR_TRUE,
277
- pe as STR_UINT_16_ARRAY,
278
- le as STR_UINT_32_ARRAY,
279
- Ee as STR_UINT_8_ARRAY,
280
- we as STR_UINT_8_ARRAY_CLAMPED,
281
- Ie as STR_UNDEFINED,
282
- Ne as STR_URL,
283
- b as SUPPORTS_FILE,
284
- F as TurboBlob,
285
- D as TurboFile,
286
- be as WaitGroup
222
+ c as Deferred,
223
+ d as DeferredAsyncIterable,
224
+ ee as DeferredReadableStream,
225
+ T as STR_ARRAY_BUFFER,
226
+ u as STR_ASYNC_ITERABLE,
227
+ l as STR_BIGINT,
228
+ S as STR_BIG_INT_64_ARRAY,
229
+ f as STR_BIG_UINT_64_ARRAY,
230
+ y as STR_BLOB,
231
+ A as STR_DATA_VIEW,
232
+ p as STR_DATE,
233
+ E as STR_ERROR,
234
+ w as STR_FAILURE,
235
+ I as STR_FALSE,
236
+ N as STR_FILE,
237
+ b as STR_FLOAT_32_ARRAY,
238
+ L as STR_FLOAT_64_ARRAY,
239
+ m as STR_FORM_DATA,
240
+ B as STR_INFINITY,
241
+ F as STR_INT_16_ARRAY,
242
+ U as STR_INT_32_ARRAY,
243
+ Y as STR_INT_8_ARRAY,
244
+ x as STR_MAP,
245
+ M as STR_NEGATIVE_INFINITY,
246
+ P as STR_NEGATIVE_ZERO,
247
+ O as STR_NULL,
248
+ D as STR_NaN,
249
+ z as STR_PLUGIN,
250
+ G as STR_PROMISE,
251
+ C as STR_READABLE_STREAM,
252
+ g as STR_REDACTED,
253
+ v as STR_REFERENCE_SYMBOL,
254
+ j as STR_REGEXP,
255
+ q as STR_SET,
256
+ V as STR_SUCCESS,
257
+ W as STR_SYMBOL,
258
+ k as STR_TRUE,
259
+ H as STR_UINT_16_ARRAY,
260
+ J as STR_UINT_32_ARRAY,
261
+ K as STR_UINT_8_ARRAY,
262
+ Q as STR_UINT_8_ARRAY_CLAMPED,
263
+ X as STR_UNDEFINED,
264
+ Z as STR_URL,
265
+ a as SUPPORTS_FILE,
266
+ h as TurboBlob,
267
+ R as TurboFile,
268
+ $ as WaitGroup
287
269
  };