@creejs/commons-lang 2.1.29 → 2.1.31
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 +38 -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 +38 -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 +38 -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 +8 -1
- package/types/lang-utils.d.ts +11 -0
package/dist/esm/index-dev.js
CHANGED
|
@@ -32,6 +32,16 @@ class _Error extends Error {
|
|
|
32
32
|
return err._type === '_' && typeof err.code === 'number'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {string} message
|
|
38
|
+
* @param {number} time ms
|
|
39
|
+
* @returns {_Error}
|
|
40
|
+
*/
|
|
41
|
+
static timeout (message, time) {
|
|
42
|
+
return new _Error(`Timeout ${time}ms: ${message}`, 504)
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
/**
|
|
36
46
|
* "412 Precondition Failed" indicates that one or more conditions
|
|
37
47
|
* given in the request header fields evaluated to false when tested on the server.
|
|
@@ -44,8 +54,8 @@ class _Error extends Error {
|
|
|
44
54
|
* @param {string} message
|
|
45
55
|
* @returns {_Error}
|
|
46
56
|
*/
|
|
47
|
-
static
|
|
48
|
-
return new _Error(`Not
|
|
57
|
+
static preconditionFailed (message) {
|
|
58
|
+
return new _Error(`Not Matched: ${message}`, 412)
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
/**
|
|
@@ -152,6 +162,7 @@ class AggregatedError extends Error {
|
|
|
152
162
|
*/
|
|
153
163
|
|
|
154
164
|
var LangUtils = {
|
|
165
|
+
get,
|
|
155
166
|
constructorName,
|
|
156
167
|
defaults,
|
|
157
168
|
extend,
|
|
@@ -163,6 +174,31 @@ var LangUtils = {
|
|
|
163
174
|
deepCloneToPlainObject
|
|
164
175
|
};
|
|
165
176
|
|
|
177
|
+
/**
|
|
178
|
+
*
|
|
179
|
+
* @param {{[key:string]:any}} obj
|
|
180
|
+
* @param {string} path
|
|
181
|
+
* @param {any} [defaultValue]
|
|
182
|
+
* @returns
|
|
183
|
+
*/
|
|
184
|
+
function get (obj, path, defaultValue) {
|
|
185
|
+
if (obj == null) {
|
|
186
|
+
return defaultValue
|
|
187
|
+
}
|
|
188
|
+
if (typeof path !== 'string') {
|
|
189
|
+
throw new Error('"path" must be a string')
|
|
190
|
+
}
|
|
191
|
+
const pathArray = path.split('.');
|
|
192
|
+
let current = obj;
|
|
193
|
+
for (const key of pathArray) {
|
|
194
|
+
if (current[key] === undefined) {
|
|
195
|
+
return defaultValue
|
|
196
|
+
}
|
|
197
|
+
current = current[key];
|
|
198
|
+
}
|
|
199
|
+
return current
|
|
200
|
+
}
|
|
201
|
+
|
|
166
202
|
/**
|
|
167
203
|
* Gets the constructor name of a value.
|
|
168
204
|
* @param {*} value - The value to check.
|