@creejs/commons-lang 2.1.30 → 2.1.32
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 +72 -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 +72 -3
- 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 +72 -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/index.d.ts +3 -1
- package/types/iterator-utils.d.ts +9 -0
- package/types/lang-utils.d.ts +11 -0
- package/types/type-assert.d.ts +8 -0
package/dist/esm/index-dev.js
CHANGED
|
@@ -162,6 +162,7 @@ class AggregatedError extends Error {
|
|
|
162
162
|
*/
|
|
163
163
|
|
|
164
164
|
var LangUtils = {
|
|
165
|
+
get,
|
|
165
166
|
constructorName,
|
|
166
167
|
defaults,
|
|
167
168
|
extend,
|
|
@@ -173,6 +174,31 @@ var LangUtils = {
|
|
|
173
174
|
deepCloneToPlainObject
|
|
174
175
|
};
|
|
175
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
|
+
|
|
176
202
|
/**
|
|
177
203
|
* Gets the constructor name of a value.
|
|
178
204
|
* @param {*} value - The value to check.
|
|
@@ -759,7 +785,8 @@ var TypeAssert = {
|
|
|
759
785
|
assertBigInt64Array,
|
|
760
786
|
assertBigUint64Array,
|
|
761
787
|
assertTypedArray,
|
|
762
|
-
assertArrayBuffer
|
|
788
|
+
assertArrayBuffer,
|
|
789
|
+
assertIterable
|
|
763
790
|
};
|
|
764
791
|
/**
|
|
765
792
|
* if value is not Array, throw error
|
|
@@ -1125,6 +1152,18 @@ function assertArrayBuffer (value, paramName) {
|
|
|
1125
1152
|
}
|
|
1126
1153
|
}
|
|
1127
1154
|
|
|
1155
|
+
/**
|
|
1156
|
+
* Asserts that the given value is Iterable
|
|
1157
|
+
* @param {*} value - The value to check.
|
|
1158
|
+
* @param {string} [paramName] - Optional parameter name for error message.
|
|
1159
|
+
* @throws {Error} Throws an error if the value is not Iterable
|
|
1160
|
+
*/
|
|
1161
|
+
function assertIterable (value, paramName) {
|
|
1162
|
+
if (!isIterable(value)) {
|
|
1163
|
+
throw new Error(`${paramName ? '"' + paramName + '" ' : ''}Not Iterable`)
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1128
1167
|
// 3rd
|
|
1129
1168
|
// internal
|
|
1130
1169
|
// owned
|
|
@@ -2795,6 +2834,35 @@ function chunk (array, size) {
|
|
|
2795
2834
|
return chunked
|
|
2796
2835
|
}
|
|
2797
2836
|
|
|
2837
|
+
// owned
|
|
2838
|
+
|
|
2839
|
+
/**
|
|
2840
|
+
* @template T
|
|
2841
|
+
* @param {Iterable<T>} iterable
|
|
2842
|
+
*/
|
|
2843
|
+
function length (iterable) {
|
|
2844
|
+
TypeAssert.assertIterable(iterable);
|
|
2845
|
+
// @ts-ignore
|
|
2846
|
+
if (typeof iterable.length !== 'undefined') {
|
|
2847
|
+
// @ts-ignore
|
|
2848
|
+
return iterable.length
|
|
2849
|
+
// @ts-ignore
|
|
2850
|
+
} else if (typeof iterable.size !== 'undefined') {
|
|
2851
|
+
// @ts-ignore
|
|
2852
|
+
return iterable.size
|
|
2853
|
+
}
|
|
2854
|
+
let counter = 0;
|
|
2855
|
+
// eslint-disable-next-line no-unused-vars
|
|
2856
|
+
for (const _item of iterable) {
|
|
2857
|
+
counter++;
|
|
2858
|
+
}
|
|
2859
|
+
return counter
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
var IteratorUtils = {
|
|
2863
|
+
length
|
|
2864
|
+
};
|
|
2865
|
+
|
|
2798
2866
|
/**
|
|
2799
2867
|
* @module Lang
|
|
2800
2868
|
* @description Core language utilities for type checking, string manipulation, and common operations.
|
|
@@ -2818,8 +2886,9 @@ var index = {
|
|
|
2818
2886
|
TypedArrayUtils,
|
|
2819
2887
|
ArrayBufferUtils,
|
|
2820
2888
|
TimeUtils,
|
|
2821
|
-
ArrayUtils
|
|
2889
|
+
ArrayUtils,
|
|
2890
|
+
IteratorUtils
|
|
2822
2891
|
};
|
|
2823
2892
|
|
|
2824
|
-
export { AggregatedError, ArrayBufferUtils, ArrayUtils, ClassProxyUtils, ExecUtils as Exec, ExecUtils, InstanceProxyUtils, LangUtils as Lang, LangUtils, PromiseUtils, ReflectUtils, StringUtils, TimeUtils, TypeUtils as Type, TypeAssert, TypeUtils, TypedArrayUtils, _Error, index as default };
|
|
2893
|
+
export { AggregatedError, ArrayBufferUtils, ArrayUtils, ClassProxyUtils, ExecUtils as Exec, ExecUtils, InstanceProxyUtils, IteratorUtils, LangUtils as Lang, LangUtils, PromiseUtils, ReflectUtils, StringUtils, TimeUtils, TypeUtils as Type, TypeAssert, TypeUtils, TypedArrayUtils, _Error, index as default };
|
|
2825
2894
|
//# sourceMappingURL=index-dev.js.map
|