zeed 0.7.113 → 0.7.117
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/dist/{chunk-MN2DIK4K.js → chunk-AYKBI7RN.js} +178 -4
- package/dist/chunk-AYKBI7RN.js.map +1 -0
- package/dist/{chunk-RR25VKTJ.js → chunk-BGJHXJ4O.js} +4 -4
- package/dist/{chunk-RR25VKTJ.js.map → chunk-BGJHXJ4O.js.map} +0 -0
- package/dist/{chunk-HERPZYOG.js → chunk-C3WHNRRT.js} +17 -3
- package/dist/chunk-C3WHNRRT.js.map +1 -0
- package/dist/{chunk-DUGVRMRT.js → chunk-G3LBBVZT.js} +9 -1
- package/dist/{chunk-DUGVRMRT.js.map → chunk-G3LBBVZT.js.map} +1 -1
- package/dist/{chunk-MYUIYPZU.js → chunk-QCK7R55W.js} +2 -2
- package/dist/{chunk-MYUIYPZU.js.map → chunk-QCK7R55W.js.map} +0 -0
- package/dist/index.all.cjs +199 -2
- package/dist/index.all.cjs.map +1 -1
- package/dist/index.all.d.ts +3 -3
- package/dist/index.all.js +25 -5
- package/dist/index.browser.cjs +185 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +22 -4
- package/dist/index.log.js +2 -2
- package/dist/index.node.cjs +199 -2
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +23 -3
- package/dist/{log-colors-8f1ba30e.d.ts → log-colors-7ad2cdf2.d.ts} +1 -1
- package/dist/{log-util-baebadc8.d.ts → log-util-42a95b2b.d.ts} +5 -2
- package/dist/{uuid-7c205442.d.ts → uuid-c834ecf8.d.ts} +39 -2
- package/package.json +27 -17
- package/dist/chunk-HERPZYOG.js.map +0 -1
- package/dist/chunk-MN2DIK4K.js.map +0 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__spreadValues,
|
|
6
6
|
getGlobalContext,
|
|
7
7
|
getTimestamp
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-G3LBBVZT.js";
|
|
9
9
|
|
|
10
10
|
// src/common/data/bin.ts
|
|
11
11
|
var log = Logger("bin");
|
|
@@ -272,6 +272,14 @@ function between(min, value, max) {
|
|
|
272
272
|
return Math.max(min, Math.min(max, value));
|
|
273
273
|
}
|
|
274
274
|
__name(between, "between");
|
|
275
|
+
function sum(array) {
|
|
276
|
+
return array.reduce((acc, value) => acc + value, 0);
|
|
277
|
+
}
|
|
278
|
+
__name(sum, "sum");
|
|
279
|
+
function avg(array) {
|
|
280
|
+
return sum(array) / array.length;
|
|
281
|
+
}
|
|
282
|
+
__name(avg, "avg");
|
|
275
283
|
|
|
276
284
|
// src/common/data/orderby.ts
|
|
277
285
|
function parseOrderby(value = "") {
|
|
@@ -417,6 +425,25 @@ function arrayMin(...array) {
|
|
|
417
425
|
return arrayFlatten(array).reduce((acc, value) => acc != null ? value < acc ? value : acc : value, void 0);
|
|
418
426
|
}
|
|
419
427
|
__name(arrayMin, "arrayMin");
|
|
428
|
+
function arraySum(...array) {
|
|
429
|
+
return arrayFlatten(array).reduce((acc, value) => acc + value, 0);
|
|
430
|
+
}
|
|
431
|
+
__name(arraySum, "arraySum");
|
|
432
|
+
function arrayAvg(...array) {
|
|
433
|
+
let flatArray = arrayFlatten(array);
|
|
434
|
+
return flatArray.reduce((acc, value) => acc + value, 0) / flatArray.length;
|
|
435
|
+
}
|
|
436
|
+
__name(arrayAvg, "arrayAvg");
|
|
437
|
+
function arrayBatches(array, chunckLength) {
|
|
438
|
+
let chunks = [];
|
|
439
|
+
let i = 0;
|
|
440
|
+
const n = array.length;
|
|
441
|
+
while (i < n) {
|
|
442
|
+
chunks.push(array.slice(i, i += chunckLength));
|
|
443
|
+
}
|
|
444
|
+
return chunks;
|
|
445
|
+
}
|
|
446
|
+
__name(arrayBatches, "arrayBatches");
|
|
420
447
|
function createArray(size2 = 0, item) {
|
|
421
448
|
if (size2 <= 0)
|
|
422
449
|
return [];
|
|
@@ -808,6 +835,7 @@ var Currency = _Currency;
|
|
|
808
835
|
__name(Currency, "Currency");
|
|
809
836
|
Currency.zero = new _Currency(0);
|
|
810
837
|
Currency.one = new _Currency(1);
|
|
838
|
+
Currency.hundred = new _Currency(100);
|
|
811
839
|
function parse(value, opts, useRounding = true) {
|
|
812
840
|
let v = 0, { decimal, errorOnInvalid, precision: decimals, fromCents } = opts, precision = pow(decimals), isNumber = typeof value === "number";
|
|
813
841
|
if (value instanceof Currency && fromCents) {
|
|
@@ -1046,7 +1074,6 @@ var Day = class {
|
|
|
1046
1074
|
if (mm === 0)
|
|
1047
1075
|
mm = 12;
|
|
1048
1076
|
let yy = Math.floor((m - 1) / 12);
|
|
1049
|
-
console.log("calc", m, mm, yy, [this.year + yy, mm, this.day]);
|
|
1050
1077
|
return Day.from([this.year + yy, mm, this.day]);
|
|
1051
1078
|
}
|
|
1052
1079
|
daysUntil(otherDay) {
|
|
@@ -1282,6 +1309,128 @@ function cloneJsonObject(obj) {
|
|
|
1282
1309
|
return JSON.parse(JSON.stringify(obj));
|
|
1283
1310
|
}
|
|
1284
1311
|
__name(cloneJsonObject, "cloneJsonObject");
|
|
1312
|
+
function memoize(fn) {
|
|
1313
|
+
let cache = /* @__PURE__ */ new Map();
|
|
1314
|
+
return (n) => {
|
|
1315
|
+
if (cache.has(n)) {
|
|
1316
|
+
return cache.get(n);
|
|
1317
|
+
}
|
|
1318
|
+
let result = fn(n);
|
|
1319
|
+
cache.set(n, result);
|
|
1320
|
+
return result;
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
__name(memoize, "memoize");
|
|
1324
|
+
|
|
1325
|
+
// src/common/data/xrx.ts
|
|
1326
|
+
var RX_WHITESPACE = /\\\s|\s+|#[^\n]*\n?/gm;
|
|
1327
|
+
var RX_REAL_GROUPS = /\(\?P?<(\w[\w\d_]+)>|\((?!\?(:|\!|=|<=|<\!))/gm;
|
|
1328
|
+
var RX_LOOK_BEHIND = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*?)\)/gm;
|
|
1329
|
+
function regExpString(rx) {
|
|
1330
|
+
return typeof rx === "string" ? rx : rx.source || "";
|
|
1331
|
+
}
|
|
1332
|
+
__name(regExpString, "regExpString");
|
|
1333
|
+
function regExpEscape(str) {
|
|
1334
|
+
return str.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1335
|
+
}
|
|
1336
|
+
__name(regExpEscape, "regExpEscape");
|
|
1337
|
+
var XRX = class {
|
|
1338
|
+
constructor(pattern2, flags) {
|
|
1339
|
+
this.namedGroups = {};
|
|
1340
|
+
this.names = [];
|
|
1341
|
+
let _flags = flags != null ? flags : "";
|
|
1342
|
+
let _rx;
|
|
1343
|
+
if (pattern2 instanceof RegExp) {
|
|
1344
|
+
if (flags == null) {
|
|
1345
|
+
_flags = pattern2.flags;
|
|
1346
|
+
}
|
|
1347
|
+
_rx = pattern2.source;
|
|
1348
|
+
} else {
|
|
1349
|
+
_rx = pattern2;
|
|
1350
|
+
}
|
|
1351
|
+
const extended = _flags && _flags.indexOf("x") !== -1;
|
|
1352
|
+
if (extended) {
|
|
1353
|
+
_flags = _flags.replace("x", "");
|
|
1354
|
+
_rx = _rx.replace(RX_WHITESPACE, (r) => {
|
|
1355
|
+
return r[0] === "\\" ? r : "";
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
if (!(pattern2 instanceof RegExp)) {
|
|
1359
|
+
let index = 0;
|
|
1360
|
+
_rx = _rx.replace(RX_REAL_GROUPS, (str, name) => {
|
|
1361
|
+
index += 1;
|
|
1362
|
+
if (name) {
|
|
1363
|
+
if (name !== "index" && name !== "length" && !this.namedGroups[name]) {
|
|
1364
|
+
this.namedGroups[name] = index;
|
|
1365
|
+
} else {
|
|
1366
|
+
console.error(`Unallowed or duplicate group name: ${name}`);
|
|
1367
|
+
}
|
|
1368
|
+
return "(";
|
|
1369
|
+
}
|
|
1370
|
+
return str;
|
|
1371
|
+
});
|
|
1372
|
+
this.names = Object.keys(this.namedGroups);
|
|
1373
|
+
}
|
|
1374
|
+
_rx = regExpString(_rx);
|
|
1375
|
+
RX_LOOK_BEHIND.lastIndex = 0;
|
|
1376
|
+
let parts = RX_LOOK_BEHIND.exec(_rx);
|
|
1377
|
+
if (parts) {
|
|
1378
|
+
this.lookBehind = {
|
|
1379
|
+
rx: new RegExp(`${parts[3]}$(?!\\s)`),
|
|
1380
|
+
expect: parts ? parts[2] === "=" : !parts
|
|
1381
|
+
};
|
|
1382
|
+
_rx = _rx.substr(parts[0].length);
|
|
1383
|
+
}
|
|
1384
|
+
this.rx = new RegExp(_rx, _flags);
|
|
1385
|
+
}
|
|
1386
|
+
get lastIndex() {
|
|
1387
|
+
return this.rx.lastIndex;
|
|
1388
|
+
}
|
|
1389
|
+
set lastIndex(index) {
|
|
1390
|
+
this.rx.lastIndex = index;
|
|
1391
|
+
}
|
|
1392
|
+
_handleMatch(m) {
|
|
1393
|
+
if (this.lookBehind) {
|
|
1394
|
+
let leftContext = m.input.slice(0, m.index);
|
|
1395
|
+
if (this.lookBehind.expect !== this.lookBehind.rx.test(leftContext)) {
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
for (let name of this.names) {
|
|
1400
|
+
m[name] = m[this.namedGroups[name]];
|
|
1401
|
+
}
|
|
1402
|
+
return m;
|
|
1403
|
+
}
|
|
1404
|
+
exec(str) {
|
|
1405
|
+
let m;
|
|
1406
|
+
while (m = this.rx.exec(str)) {
|
|
1407
|
+
if (this.rx.lastIndex === m.index) {
|
|
1408
|
+
this.rx.lastIndex++;
|
|
1409
|
+
}
|
|
1410
|
+
m = this._handleMatch(m);
|
|
1411
|
+
if (m != null) {
|
|
1412
|
+
return m;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
execAll(str) {
|
|
1417
|
+
let matches = [];
|
|
1418
|
+
let m;
|
|
1419
|
+
this.rx.lastIndex = 0;
|
|
1420
|
+
while (m = this.exec(str)) {
|
|
1421
|
+
matches.push(m);
|
|
1422
|
+
}
|
|
1423
|
+
this.rx.lastIndex = 0;
|
|
1424
|
+
return matches;
|
|
1425
|
+
}
|
|
1426
|
+
replace(str, replacement) {
|
|
1427
|
+
let fn = typeof replacement === "function" ? replacement : () => replacement;
|
|
1428
|
+
return str.replace(this.rx, (m) => {
|
|
1429
|
+
return fn(m);
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
__name(XRX, "XRX");
|
|
1285
1434
|
|
|
1286
1435
|
// src/common/dispose-defer.ts
|
|
1287
1436
|
var log3 = Logger("dispose");
|
|
@@ -2216,11 +2365,14 @@ __name(usePool, "usePool");
|
|
|
2216
2365
|
|
|
2217
2366
|
// src/common/queue.ts
|
|
2218
2367
|
var log6 = Logger("zeed:queue");
|
|
2219
|
-
var SerialQueue = class {
|
|
2368
|
+
var SerialQueue = class extends Emitter {
|
|
2220
2369
|
constructor(opt = {}) {
|
|
2370
|
+
super();
|
|
2221
2371
|
this.queue = [];
|
|
2222
2372
|
this.isPaused = false;
|
|
2223
2373
|
this.waitToFinish = [];
|
|
2374
|
+
this.max = 0;
|
|
2375
|
+
this.resolved = 0;
|
|
2224
2376
|
const { name = uname("queue"), logLevel } = opt;
|
|
2225
2377
|
this.name = name;
|
|
2226
2378
|
this.log = Logger(`zeed:queue:${name}`);
|
|
@@ -2242,6 +2394,10 @@ var SerialQueue = class {
|
|
|
2242
2394
|
if (info == null) {
|
|
2243
2395
|
break;
|
|
2244
2396
|
}
|
|
2397
|
+
if (this.resolved === 0) {
|
|
2398
|
+
this.emit("didStart", this.max);
|
|
2399
|
+
this.emit("didUpdate", this.max, 0);
|
|
2400
|
+
}
|
|
2245
2401
|
const { name, task, resolve } = info;
|
|
2246
2402
|
this.currentTask = task();
|
|
2247
2403
|
let result = void 0;
|
|
@@ -2254,6 +2410,13 @@ var SerialQueue = class {
|
|
|
2254
2410
|
}
|
|
2255
2411
|
resolve(result);
|
|
2256
2412
|
this.currentTask = void 0;
|
|
2413
|
+
this.resolved += 1;
|
|
2414
|
+
this.emit("didUpdate", this.max, this.resolved);
|
|
2415
|
+
}
|
|
2416
|
+
if (this.queue.length === 0) {
|
|
2417
|
+
this.emit("didFinish", this.max);
|
|
2418
|
+
this.max = 0;
|
|
2419
|
+
this.resolved = 0;
|
|
2257
2420
|
}
|
|
2258
2421
|
while (this.waitToFinish.length > 0) {
|
|
2259
2422
|
this.waitToFinish.shift()();
|
|
@@ -2265,6 +2428,7 @@ var SerialQueue = class {
|
|
|
2265
2428
|
this.log.info(`immediate execution ${name}`);
|
|
2266
2429
|
return await task();
|
|
2267
2430
|
}
|
|
2431
|
+
this.max += 1;
|
|
2268
2432
|
this.log(`enqueue ${name}`);
|
|
2269
2433
|
return new Promise((resolve) => {
|
|
2270
2434
|
this.queue.push({
|
|
@@ -2283,6 +2447,7 @@ var SerialQueue = class {
|
|
|
2283
2447
|
}
|
|
2284
2448
|
async cancelAll(unblock = true) {
|
|
2285
2449
|
this.log(`cancelAll`);
|
|
2450
|
+
this.emit("didCancel", this.queue.length);
|
|
2286
2451
|
let resolver = this.queue.map((task) => task.resolve);
|
|
2287
2452
|
this.queue = [];
|
|
2288
2453
|
resolver.forEach((r) => r(void 0));
|
|
@@ -2451,6 +2616,8 @@ export {
|
|
|
2451
2616
|
randomInt,
|
|
2452
2617
|
randomFloat,
|
|
2453
2618
|
between,
|
|
2619
|
+
sum,
|
|
2620
|
+
avg,
|
|
2454
2621
|
parseOrderby,
|
|
2455
2622
|
composeOrderby,
|
|
2456
2623
|
cmp,
|
|
@@ -2475,6 +2642,9 @@ export {
|
|
|
2475
2642
|
arrayRandomElement,
|
|
2476
2643
|
arrayMax,
|
|
2477
2644
|
arrayMin,
|
|
2645
|
+
arraySum,
|
|
2646
|
+
arrayAvg,
|
|
2647
|
+
arrayBatches,
|
|
2478
2648
|
createArray,
|
|
2479
2649
|
useBase,
|
|
2480
2650
|
encodeBase16,
|
|
@@ -2552,6 +2722,10 @@ export {
|
|
|
2552
2722
|
empty,
|
|
2553
2723
|
cloneObject,
|
|
2554
2724
|
cloneJsonObject,
|
|
2725
|
+
memoize,
|
|
2726
|
+
regExpString,
|
|
2727
|
+
regExpEscape,
|
|
2728
|
+
XRX,
|
|
2555
2729
|
useDispose,
|
|
2556
2730
|
useDisposer,
|
|
2557
2731
|
useDefer,
|
|
@@ -2607,4 +2781,4 @@ export {
|
|
|
2607
2781
|
throttle,
|
|
2608
2782
|
debounce
|
|
2609
2783
|
};
|
|
2610
|
-
//# sourceMappingURL=chunk-
|
|
2784
|
+
//# sourceMappingURL=chunk-AYKBI7RN.js.map
|