@creejs/commons-lang 2.1.28 → 2.1.30

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.
@@ -36,6 +36,32 @@ class _Error extends Error {
36
36
  return err._type === '_' && typeof err.code === 'number'
37
37
  }
38
38
 
39
+ /**
40
+ *
41
+ * @param {string} message
42
+ * @param {number} time ms
43
+ * @returns {_Error}
44
+ */
45
+ static timeout (message, time) {
46
+ return new _Error(`Timeout ${time}ms: ${message}`, 504)
47
+ }
48
+
49
+ /**
50
+ * "412 Precondition Failed" indicates that one or more conditions
51
+ * given in the request header fields evaluated to false when tested on the server.
52
+ * * Header Purpose
53
+ * * If-Match Only proceed if the resource's ETag matches the given value
54
+ * * If-None-Match Only proceed if the resource's ETag doesn't match the given value
55
+ * * If-Modified-Since Only proceed if the resource was modified after the given date
56
+ * * If-Unmodified-Since Only proceed if the resource wasn't modified after the given date
57
+
58
+ * @param {string} message
59
+ * @returns {_Error}
60
+ */
61
+ static preconditionFailed (message) {
62
+ return new _Error(`Not Matched: ${message}`, 412)
63
+ }
64
+
39
65
  /**
40
66
  * Creates and returns a 404 Not Found error instance with the given message.
41
67
  * @param {string} message - The error message to include.
@@ -2087,6 +2113,9 @@ async function parallelAllSettled (tasks, maxParallel = 5) {
2087
2113
  * 3. Notice:
2088
2114
  * * In Beginning, we start bulk(maxParallel) of tasks
2089
2115
  * * One task failed, it will start next task immediately, Not Wait for the bulk(maxParallel) to complete
2116
+ * * DO NOT ensure all tasks are executed.
2117
+ * * Tasks are NOT stoped immediately when a Task succeeds
2118
+ * * will be stopped when A bulk(maxParallel) is executed.
2090
2119
  * @param {Array<Function|Promise<any>>} tasks - Array of async functions to execute
2091
2120
  * @param {number} [maxParallel=5] - Maximum number of tasks to run in parallel
2092
2121
  * @param {string} [failureMessage] - Error message when all tasks failed
@@ -2523,8 +2552,8 @@ function writeString (buffer, str, offset = 0) {
2523
2552
  * * if dataLength <= 0, throw "Not Positive" Error
2524
2553
  * * if dataLength is omitted, read all bytes from dataOffset to the end of dataArrayBuffer
2525
2554
  * * if dataLength + dataOffset > dataArrayBuffer.length, read all bytes from dataOffset to the end of dataArrayBuffer
2526
- * @param {ArrayBuffer} target - The target buffer to write into.
2527
- * @param {ArrayBuffer} dataArrayBuffer - The data ArrayBuffer to write.
2555
+ * @param {ArrayBuffer|SharedArrayBuffer} target - The target buffer to write into.
2556
+ * @param {ArrayBuffer|SharedArrayBuffer} dataArrayBuffer - The data ArrayBuffer to write.
2528
2557
  * @param {number} [targetOffset=0] - Zero-based index at which to start write.
2529
2558
  * @param {number} [dataOffset=0] - The offset in the dataArrayBuffer
2530
2559
  * @param {number} [dataLength] - how many bytes extract from dataArrayBuffer