@creejs/commons-lang 2.1.27 → 2.1.29
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/cjs/index-dev.cjs +60 -2
- package/dist/cjs/index-dev.cjs.map +1 -1
- package/dist/cjs/index-min.cjs +1 -1
- package/dist/cjs/index-min.cjs.map +1 -1
- package/dist/esm/index-dev.js +60 -2
- package/dist/esm/index-dev.js.map +1 -1
- package/dist/esm/index-min.js +1 -1
- package/dist/esm/index-min.js.map +1 -1
- package/dist/umd/index.dev.js +60 -2
- package/dist/umd/index.dev.js.map +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +1 -1
- package/types/_error.d.ts +13 -0
- package/types/array-buffer-utils.d.ts +3 -3
- package/types/promise-utils.d.ts +3 -0
package/dist/esm/index-dev.js
CHANGED
|
@@ -32,6 +32,22 @@ class _Error extends Error {
|
|
|
32
32
|
return err._type === '_' && typeof err.code === 'number'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* "412 Precondition Failed" indicates that one or more conditions
|
|
37
|
+
* given in the request header fields evaluated to false when tested on the server.
|
|
38
|
+
* * Header Purpose
|
|
39
|
+
* * If-Match Only proceed if the resource's ETag matches the given value
|
|
40
|
+
* * If-None-Match Only proceed if the resource's ETag doesn't match the given value
|
|
41
|
+
* * If-Modified-Since Only proceed if the resource was modified after the given date
|
|
42
|
+
* * If-Unmodified-Since Only proceed if the resource wasn't modified after the given date
|
|
43
|
+
|
|
44
|
+
* @param {string} message
|
|
45
|
+
* @returns {_Error}
|
|
46
|
+
*/
|
|
47
|
+
static PreconditionFailed (message) {
|
|
48
|
+
return new _Error(`Not Found: ${message}`, 412)
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
/**
|
|
36
52
|
* Creates and returns a 404 Not Found error instance with the given message.
|
|
37
53
|
* @param {string} message - The error message to include.
|
|
@@ -1537,6 +1553,45 @@ function safeToString (value) {
|
|
|
1537
1553
|
} else if (value === undefined) {
|
|
1538
1554
|
return 'undefined'
|
|
1539
1555
|
}
|
|
1556
|
+
const type = typeof value;
|
|
1557
|
+
if (type === 'string') {
|
|
1558
|
+
return value
|
|
1559
|
+
} else if (type === 'symbol') {
|
|
1560
|
+
return `Symbol(${value.description})`
|
|
1561
|
+
} else if (type === 'function') {
|
|
1562
|
+
return `Function ${value.name}(){}`
|
|
1563
|
+
}
|
|
1564
|
+
if (value instanceof String) {
|
|
1565
|
+
return value.toString()
|
|
1566
|
+
}
|
|
1567
|
+
if (Number.isNaN(value)) {
|
|
1568
|
+
return 'NaN'
|
|
1569
|
+
}
|
|
1570
|
+
if (value === Infinity) {
|
|
1571
|
+
return 'Infinity'
|
|
1572
|
+
}
|
|
1573
|
+
if (value === -Infinity) {
|
|
1574
|
+
return '-Infinity'
|
|
1575
|
+
}
|
|
1576
|
+
if (value instanceof Error) {
|
|
1577
|
+
return `${value.constructor.name}: ${value.message}`
|
|
1578
|
+
}
|
|
1579
|
+
if (value instanceof Promise) {
|
|
1580
|
+
return 'Promise'
|
|
1581
|
+
}
|
|
1582
|
+
if (value instanceof Set) {
|
|
1583
|
+
return `Set: ${safeToString(Array.from(value))}`
|
|
1584
|
+
}
|
|
1585
|
+
if (value instanceof Map) {
|
|
1586
|
+
return `Map: ${safeToString(Array.from(value.entries()))}`
|
|
1587
|
+
}
|
|
1588
|
+
if (value instanceof RegExp) {
|
|
1589
|
+
return value.toString()
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
if (Array.isArray(value)) {
|
|
1593
|
+
return `[${value.map(safeToString).join(', ')}]`
|
|
1594
|
+
}
|
|
1540
1595
|
let valueStr;
|
|
1541
1596
|
try {
|
|
1542
1597
|
valueStr = JSON.stringify(value);
|
|
@@ -2044,6 +2099,9 @@ async function parallelAllSettled (tasks, maxParallel = 5) {
|
|
|
2044
2099
|
* 3. Notice:
|
|
2045
2100
|
* * In Beginning, we start bulk(maxParallel) of tasks
|
|
2046
2101
|
* * One task failed, it will start next task immediately, Not Wait for the bulk(maxParallel) to complete
|
|
2102
|
+
* * DO NOT ensure all tasks are executed.
|
|
2103
|
+
* * Tasks are NOT stoped immediately when a Task succeeds
|
|
2104
|
+
* * will be stopped when A bulk(maxParallel) is executed.
|
|
2047
2105
|
* @param {Array<Function|Promise<any>>} tasks - Array of async functions to execute
|
|
2048
2106
|
* @param {number} [maxParallel=5] - Maximum number of tasks to run in parallel
|
|
2049
2107
|
* @param {string} [failureMessage] - Error message when all tasks failed
|
|
@@ -2480,8 +2538,8 @@ function writeString (buffer, str, offset = 0) {
|
|
|
2480
2538
|
* * if dataLength <= 0, throw "Not Positive" Error
|
|
2481
2539
|
* * if dataLength is omitted, read all bytes from dataOffset to the end of dataArrayBuffer
|
|
2482
2540
|
* * if dataLength + dataOffset > dataArrayBuffer.length, read all bytes from dataOffset to the end of dataArrayBuffer
|
|
2483
|
-
* @param {ArrayBuffer} target - The target buffer to write into.
|
|
2484
|
-
* @param {ArrayBuffer} dataArrayBuffer - The data ArrayBuffer to write.
|
|
2541
|
+
* @param {ArrayBuffer|SharedArrayBuffer} target - The target buffer to write into.
|
|
2542
|
+
* @param {ArrayBuffer|SharedArrayBuffer} dataArrayBuffer - The data ArrayBuffer to write.
|
|
2485
2543
|
* @param {number} [targetOffset=0] - Zero-based index at which to start write.
|
|
2486
2544
|
* @param {number} [dataOffset=0] - The offset in the dataArrayBuffer
|
|
2487
2545
|
* @param {number} [dataLength] - how many bytes extract from dataArrayBuffer
|