@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/umd/index.dev.js
CHANGED
|
@@ -38,6 +38,16 @@
|
|
|
38
38
|
return err._type === '_' && typeof err.code === 'number'
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {string} message
|
|
44
|
+
* @param {number} time ms
|
|
45
|
+
* @returns {_Error}
|
|
46
|
+
*/
|
|
47
|
+
static timeout (message, time) {
|
|
48
|
+
return new _Error(`Timeout ${time}ms: ${message}`, 504)
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
/**
|
|
42
52
|
* "412 Precondition Failed" indicates that one or more conditions
|
|
43
53
|
* given in the request header fields evaluated to false when tested on the server.
|
|
@@ -50,8 +60,8 @@
|
|
|
50
60
|
* @param {string} message
|
|
51
61
|
* @returns {_Error}
|
|
52
62
|
*/
|
|
53
|
-
static
|
|
54
|
-
return new _Error(`Not
|
|
63
|
+
static preconditionFailed (message) {
|
|
64
|
+
return new _Error(`Not Matched: ${message}`, 412)
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
/**
|
|
@@ -158,6 +168,7 @@
|
|
|
158
168
|
*/
|
|
159
169
|
|
|
160
170
|
var LangUtils = {
|
|
171
|
+
get,
|
|
161
172
|
constructorName,
|
|
162
173
|
defaults,
|
|
163
174
|
extend,
|
|
@@ -169,6 +180,31 @@
|
|
|
169
180
|
deepCloneToPlainObject
|
|
170
181
|
};
|
|
171
182
|
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @param {{[key:string]:any}} obj
|
|
186
|
+
* @param {string} path
|
|
187
|
+
* @param {any} [defaultValue]
|
|
188
|
+
* @returns
|
|
189
|
+
*/
|
|
190
|
+
function get (obj, path, defaultValue) {
|
|
191
|
+
if (obj == null) {
|
|
192
|
+
return defaultValue
|
|
193
|
+
}
|
|
194
|
+
if (typeof path !== 'string') {
|
|
195
|
+
throw new Error('"path" must be a string')
|
|
196
|
+
}
|
|
197
|
+
const pathArray = path.split('.');
|
|
198
|
+
let current = obj;
|
|
199
|
+
for (const key of pathArray) {
|
|
200
|
+
if (current[key] === undefined) {
|
|
201
|
+
return defaultValue
|
|
202
|
+
}
|
|
203
|
+
current = current[key];
|
|
204
|
+
}
|
|
205
|
+
return current
|
|
206
|
+
}
|
|
207
|
+
|
|
172
208
|
/**
|
|
173
209
|
* Gets the constructor name of a value.
|
|
174
210
|
* @param {*} value - The value to check.
|