foreslash 0.3.3 → 0.3.4
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/CHANGELOG.md +12 -0
- package/lib/index.cmn.cjs +49 -1
- package/lib/index.d.ts +53 -2
- package/lib/index.mjs +48 -2
- package/lib/index.umd.js +49 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## Version 0.3.4 - 2025-11-
|
|
4
|
+
|
|
5
|
+
Unstable version
|
|
6
|
+
|
|
7
|
+
- Feat 🥥 Functions added: `omit` `pick`
|
|
8
|
+
- Other fixes and improvements
|
|
9
|
+
|
|
10
|
+
不稳定版本
|
|
11
|
+
|
|
12
|
+
- 功能 🥥 添加函数: `omit` `pick`
|
|
13
|
+
- 其他修复与优化
|
|
14
|
+
|
|
3
15
|
## Version 0.3.3 - 2025-11-05
|
|
4
16
|
|
|
5
17
|
Unstable version
|
package/lib/index.cmn.cjs
CHANGED
|
@@ -749,7 +749,7 @@ function scientificNotation(num, options) {
|
|
|
749
749
|
return str;
|
|
750
750
|
const type = (options || {}).type || 'unicode';
|
|
751
751
|
const _precision = (options || {}).precision;
|
|
752
|
-
const precision = isNumber(_precision) ? clamp(_precision
|
|
752
|
+
const precision = isNumber(_precision) ? clamp(_precision, 0, Infinity) : null;
|
|
753
753
|
const round = (options || {}).round || 'round';
|
|
754
754
|
let [integer, fractional] = str.split('.');
|
|
755
755
|
let sign = '';
|
|
@@ -2489,6 +2489,27 @@ function not(value) {
|
|
|
2489
2489
|
return !Boolean(value);
|
|
2490
2490
|
}
|
|
2491
2491
|
|
|
2492
|
+
function omit(obj, keys) {
|
|
2493
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2494
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2495
|
+
if (isFunction(keys)) {
|
|
2496
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2497
|
+
const key = ownKeys[i];
|
|
2498
|
+
if (!keys(obj[key], key, obj))
|
|
2499
|
+
res[key] = obj[key];
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
else {
|
|
2503
|
+
const keysSet = new Set((isArray(keys) ? keys : [keys]).map((k) => (isNumber(k) ? String(k) : k)));
|
|
2504
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2505
|
+
const key = ownKeys[i];
|
|
2506
|
+
if (!keysSet.has(key))
|
|
2507
|
+
res[key] = obj[key];
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
return res;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2492
2513
|
function pass(value) {
|
|
2493
2514
|
return value;
|
|
2494
2515
|
}
|
|
@@ -2499,6 +2520,31 @@ function passWith(fn) {
|
|
|
2499
2520
|
});
|
|
2500
2521
|
}
|
|
2501
2522
|
|
|
2523
|
+
function pick(obj, keys) {
|
|
2524
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2525
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2526
|
+
if (isFunction(keys)) {
|
|
2527
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2528
|
+
const key = ownKeys[i];
|
|
2529
|
+
if (keys(obj[key], key, obj))
|
|
2530
|
+
res[key] = obj[key];
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
else if (isArray(keys)) {
|
|
2534
|
+
const keysSet = new Set(ownKeys);
|
|
2535
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2536
|
+
const key = keys[i];
|
|
2537
|
+
if (keysSet.has(isNumber(key) ? String(key) : key))
|
|
2538
|
+
res[key] = obj[key];
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
else if (isString(keys) || isNumber(keys) || isSymbol(keys)) {
|
|
2542
|
+
if (ownKeys.includes(isNumber(keys) ? String(keys) : keys))
|
|
2543
|
+
res[keys] = obj[keys];
|
|
2544
|
+
}
|
|
2545
|
+
return res;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2502
2548
|
function pipe(...pipeFunc) {
|
|
2503
2549
|
if (pipeFunc.length === 0) {
|
|
2504
2550
|
throw new Error('Invalid pipeFunc parameter: pipeFunc is empty');
|
|
@@ -2613,10 +2659,12 @@ exports.lerp = lerp;
|
|
|
2613
2659
|
exports.memo = memo;
|
|
2614
2660
|
exports.noop = noop;
|
|
2615
2661
|
exports.not = not;
|
|
2662
|
+
exports.omit = omit;
|
|
2616
2663
|
exports.parallel = parallel;
|
|
2617
2664
|
exports.pascalCase = pascalCase;
|
|
2618
2665
|
exports.pass = pass;
|
|
2619
2666
|
exports.passWith = passWith;
|
|
2667
|
+
exports.pick = pick;
|
|
2620
2668
|
exports.pipe = pipe;
|
|
2621
2669
|
exports.randomBase32String = randomBase32String;
|
|
2622
2670
|
exports.randomChoice = randomChoice;
|
package/lib/index.d.ts
CHANGED
|
@@ -1095,7 +1095,7 @@ declare function lerp(val1: number[][], val2: number[][], t: number): number[][]
|
|
|
1095
1095
|
* - `'unicode'` 使用 Unicode 表示 `'I̅V̅XC'`
|
|
1096
1096
|
* - `'js'` 适合用于 JavaScript 代码字符串 `'I\\u0305V\\u0305XC'`
|
|
1097
1097
|
* - `'html'` 适合用于 HTML 展示的字符串 `'I̅V̅XC'`
|
|
1098
|
-
* - `'json'` 一个 JSON 字符串, 具体数值是下标^1000 `["XC", "IV"]`
|
|
1098
|
+
* - `'json'` 一个 JSON 字符串, 具体数值是下标^1000 `'["XC", "IV"]'`
|
|
1099
1099
|
*
|
|
1100
1100
|
* `thousand` 千分位类型, 默认为 `normal`
|
|
1101
1101
|
* - `'normal'` 习惯用法, 超过 3999 的部分才使用上划线区分
|
|
@@ -2245,6 +2245,34 @@ declare const noop: (...args: any[]) => void;
|
|
|
2245
2245
|
*/
|
|
2246
2246
|
declare function not(value: unknown): boolean;
|
|
2247
2247
|
|
|
2248
|
+
type KeyOf<T extends object> = object extends T ? keyof any : keyof T;
|
|
2249
|
+
type ValueOf<T extends object> = object extends T ? unknown : T[keyof T];
|
|
2250
|
+
type PickPredicate<T extends object> = (value: ValueOf<T>, key: KeyOf<T>, obj: T) => any;
|
|
2251
|
+
type OmitPredicate<T extends object> = (value: ValueOf<T>, key: KeyOf<T>, obj: T) => any;
|
|
2252
|
+
|
|
2253
|
+
/**
|
|
2254
|
+
* 给定一个对象和对象中键的列表, 返回一个**排除**给定键的新对象(是传入对象的浅拷贝)\
|
|
2255
|
+
* 如果你希望深拷贝一个对象, 请使用 `deepClone` 或 `fastClone`
|
|
2256
|
+
* @param obj 需要处理的对象
|
|
2257
|
+
* @param keys 需要**排除**的键, 可以是一个数组、字符串或谓词函数
|
|
2258
|
+
* @returns 传入对象的浅拷贝, 与传入对象不同的是新对象**排除了**指定的键
|
|
2259
|
+
* @example
|
|
2260
|
+
* ```ts
|
|
2261
|
+
* omit({ a: 1, b: 2, c: '' }, ['a', 'c']) // { b: 2 }
|
|
2262
|
+
* omit({ a: 1, b: 2, c: '' }, 'b') // { a: 1, c: '' }
|
|
2263
|
+
* // 谓词函数
|
|
2264
|
+
* omit({ a: 1, b: 2, c: '' }, (value, key) => value === 2 || key === 'c') // { a: 1 }
|
|
2265
|
+
* // 需要注意的是传入谓词函数时可能会有类型不匹配的问题
|
|
2266
|
+
* // Typescript 无法得知最终过滤的结果, 而是认为过滤结果与原类型一致
|
|
2267
|
+
* const obj = omit({ a: 1, b: 2 }, (value, key) => value === 2) // { a: 1 }
|
|
2268
|
+
* type typeofObj = typeof obj // { a: number; b: number } <- Typescript 没有推导出正确结果
|
|
2269
|
+
* ```
|
|
2270
|
+
* @version 0.3.4
|
|
2271
|
+
*/
|
|
2272
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
2273
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, keys: OmitPredicate<T>): T;
|
|
2274
|
+
declare function omit<T extends object, K extends keyof T>(obj: T, key: K): Omit<T, K>;
|
|
2275
|
+
|
|
2248
2276
|
/**
|
|
2249
2277
|
* 不做任何操作,返回第一个参数,一般用于函数式编程
|
|
2250
2278
|
* @param value 任意值
|
|
@@ -2273,6 +2301,29 @@ declare function pass(): undefined;
|
|
|
2273
2301
|
*/
|
|
2274
2302
|
declare function passWith<T>(fn: (arg: T) => any): typeof pass;
|
|
2275
2303
|
|
|
2304
|
+
/**
|
|
2305
|
+
* 给定一个对象和对象中键的列表, 返回一个**只包含**给定键的新对象(是传入对象的浅拷贝)\
|
|
2306
|
+
* 如果你希望深拷贝一个对象, 请使用 `deepClone` 或 `fastClone`
|
|
2307
|
+
* @param obj 需要处理的对象
|
|
2308
|
+
* @param keys 需要**取出**的键, 可以是一个数组、字符串或谓词函数
|
|
2309
|
+
* @returns 传入对象的浅拷贝, 与传入对象不同的是新对象仅包含指定的键
|
|
2310
|
+
* @example
|
|
2311
|
+
* ```ts
|
|
2312
|
+
* pick({ a: 1, b: 2, c: '' }, ['a', 'c']) // { a: 1, c: '' }
|
|
2313
|
+
* pick({ a: 1, b: 2, c: '' }, 'b') // { b: 2 }
|
|
2314
|
+
* // 谓词函数
|
|
2315
|
+
* pick({ a: 1, b: 2, c: '' }, (value, key) => value === 2 || key === 'c') // { b: 2, c: '' }
|
|
2316
|
+
* // 需要注意的是传入谓词函数时可能会有类型不匹配的问题
|
|
2317
|
+
* // Typescript 无法得知最终过滤的结果, 而是认为过滤结果与原类型一致
|
|
2318
|
+
* const obj = pick({ a: 1, b: 2 }, (value, key) => value === 2) // { b: 2 }
|
|
2319
|
+
* type typeofObj = typeof obj // { a: number; b: number } <- Typescript 没有推导出正确结果
|
|
2320
|
+
* ```
|
|
2321
|
+
* @version 0.3.4
|
|
2322
|
+
*/
|
|
2323
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
2324
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: PickPredicate<T>): T;
|
|
2325
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, key: K): Pick<T, K>;
|
|
2326
|
+
|
|
2276
2327
|
// pipe
|
|
2277
2328
|
type PipeFuncList1<PipeArgs extends any[], PipeResult> = [(...args: PipeArgs) => PipeResult]
|
|
2278
2329
|
type PipeFuncList2<PipeArgs extends any[], PipeResult, Mid1 = any> = [
|
|
@@ -2408,5 +2459,5 @@ declare function throttle<T extends any[]>(fn: (...args: T) => any, delay: numbe
|
|
|
2408
2459
|
reset: () => void;
|
|
2409
2460
|
};
|
|
2410
2461
|
|
|
2411
|
-
export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, parallel, pascalCase, pass, passWith, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, withResolvers };
|
|
2462
|
+
export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, withResolvers };
|
|
2412
2463
|
export type { BaseMargeType, CastArray, Chunked, CloneOptions, CustomCloner, IsNegative, IsPositive, IsZero, MergeOption, MergeStrategy, MergeStrategyFunction, MergeType, MergeTypeStrategy, Not, RangeOptions, SourceMergeType, Stringify, TargetMergeType, TypedArray };
|
package/lib/index.mjs
CHANGED
|
@@ -747,7 +747,7 @@ function scientificNotation(num, options) {
|
|
|
747
747
|
return str;
|
|
748
748
|
const type = (options || {}).type || 'unicode';
|
|
749
749
|
const _precision = (options || {}).precision;
|
|
750
|
-
const precision = isNumber(_precision) ? clamp(_precision
|
|
750
|
+
const precision = isNumber(_precision) ? clamp(_precision, 0, Infinity) : null;
|
|
751
751
|
const round = (options || {}).round || 'round';
|
|
752
752
|
let [integer, fractional] = str.split('.');
|
|
753
753
|
let sign = '';
|
|
@@ -2487,6 +2487,27 @@ function not(value) {
|
|
|
2487
2487
|
return !Boolean(value);
|
|
2488
2488
|
}
|
|
2489
2489
|
|
|
2490
|
+
function omit(obj, keys) {
|
|
2491
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2492
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2493
|
+
if (isFunction(keys)) {
|
|
2494
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2495
|
+
const key = ownKeys[i];
|
|
2496
|
+
if (!keys(obj[key], key, obj))
|
|
2497
|
+
res[key] = obj[key];
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
else {
|
|
2501
|
+
const keysSet = new Set((isArray(keys) ? keys : [keys]).map((k) => (isNumber(k) ? String(k) : k)));
|
|
2502
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2503
|
+
const key = ownKeys[i];
|
|
2504
|
+
if (!keysSet.has(key))
|
|
2505
|
+
res[key] = obj[key];
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return res;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2490
2511
|
function pass(value) {
|
|
2491
2512
|
return value;
|
|
2492
2513
|
}
|
|
@@ -2497,6 +2518,31 @@ function passWith(fn) {
|
|
|
2497
2518
|
});
|
|
2498
2519
|
}
|
|
2499
2520
|
|
|
2521
|
+
function pick(obj, keys) {
|
|
2522
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2523
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2524
|
+
if (isFunction(keys)) {
|
|
2525
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2526
|
+
const key = ownKeys[i];
|
|
2527
|
+
if (keys(obj[key], key, obj))
|
|
2528
|
+
res[key] = obj[key];
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
else if (isArray(keys)) {
|
|
2532
|
+
const keysSet = new Set(ownKeys);
|
|
2533
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2534
|
+
const key = keys[i];
|
|
2535
|
+
if (keysSet.has(isNumber(key) ? String(key) : key))
|
|
2536
|
+
res[key] = obj[key];
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
else if (isString(keys) || isNumber(keys) || isSymbol(keys)) {
|
|
2540
|
+
if (ownKeys.includes(isNumber(keys) ? String(keys) : keys))
|
|
2541
|
+
res[keys] = obj[keys];
|
|
2542
|
+
}
|
|
2543
|
+
return res;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2500
2546
|
function pipe(...pipeFunc) {
|
|
2501
2547
|
if (pipeFunc.length === 0) {
|
|
2502
2548
|
throw new Error('Invalid pipeFunc parameter: pipeFunc is empty');
|
|
@@ -2522,4 +2568,4 @@ function throttle(fn, delay, options) {
|
|
|
2522
2568
|
return _throttle(fn, delay, Object.assign({ trailing: false, leading: true }, options));
|
|
2523
2569
|
}
|
|
2524
2570
|
|
|
2525
|
-
export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, parallel, pascalCase, pass, passWith, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, withResolvers };
|
|
2571
|
+
export { $$Empty, _, acceptableFileName, acceptableFileType, camelCase, capitalize, cartesianProduct, caseCamel, caseConvert, caseKebab, casePascal, caseSnake, castArray, chunk, clamp, compose, _curryMore as curry, debounce, decimalNotation, dedent, deepClone, deepMerge, defer, fastClone, format, getAcceptableExtByMIME, getAcceptableMIMEByExt, getGlobalThis, getInitP, getTag, indent, isArray, isArrayBuffer, isArrayLike, isBigInt, isBigInt64Array, isBigUint64Array, isBlob, isBoolean, isBuffer, isDataView, isDate, isEmpty, isEven, isFile, isFloat32Array, isFloat64Array, isFormData, isFunction, isInt16Array, isInt32Array, isInt8Array, isInteger, isIterable, isMap, isMergeEmptyPlaceholder, isNil, isNull, isNumber, isObject, isOdd, isPlaceholder, isPlainObject, isPrimitive, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isTypedArray, isUint16Array, isUint32Array, isUint8Array, isUint8ClampedArray, isUndefined, isWeakMap, isWeakSet, isWrapperBigInt, isWrapperBoolean, isWrapperNumber, isWrapperObject, isWrapperString, isWrapperSymbol, kebabCase, lerp, memo, noop, not, omit, parallel, pascalCase, pass, passWith, pick, pipe, randomBase32String, randomChoice, randomDistribution, randomHexString, randomInt, randomIntFloor, randomString, range, remove, retry, romanNumerals, round, roundBank, roundBase, roundCeil, roundFloor, scientificNotation, shuffle, sleep, snakeCase, splitWords, throttle, titleCase, tryit, ulid, uncapitalize, uuidNil, uuidV4, withResolvers };
|
package/lib/index.umd.js
CHANGED
|
@@ -753,7 +753,7 @@ See the Mulan PSL v2 for more details.
|
|
|
753
753
|
return str;
|
|
754
754
|
const type = (options || {}).type || 'unicode';
|
|
755
755
|
const _precision = (options || {}).precision;
|
|
756
|
-
const precision = isNumber(_precision) ? clamp(_precision
|
|
756
|
+
const precision = isNumber(_precision) ? clamp(_precision, 0, Infinity) : null;
|
|
757
757
|
const round = (options || {}).round || 'round';
|
|
758
758
|
let [integer, fractional] = str.split('.');
|
|
759
759
|
let sign = '';
|
|
@@ -2493,6 +2493,27 @@ See the Mulan PSL v2 for more details.
|
|
|
2493
2493
|
return !Boolean(value);
|
|
2494
2494
|
}
|
|
2495
2495
|
|
|
2496
|
+
function omit(obj, keys) {
|
|
2497
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2498
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2499
|
+
if (isFunction(keys)) {
|
|
2500
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2501
|
+
const key = ownKeys[i];
|
|
2502
|
+
if (!keys(obj[key], key, obj))
|
|
2503
|
+
res[key] = obj[key];
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
else {
|
|
2507
|
+
const keysSet = new Set((isArray(keys) ? keys : [keys]).map((k) => (isNumber(k) ? String(k) : k)));
|
|
2508
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2509
|
+
const key = ownKeys[i];
|
|
2510
|
+
if (!keysSet.has(key))
|
|
2511
|
+
res[key] = obj[key];
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
return res;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2496
2517
|
function pass(value) {
|
|
2497
2518
|
return value;
|
|
2498
2519
|
}
|
|
@@ -2503,6 +2524,31 @@ See the Mulan PSL v2 for more details.
|
|
|
2503
2524
|
});
|
|
2504
2525
|
}
|
|
2505
2526
|
|
|
2527
|
+
function pick(obj, keys) {
|
|
2528
|
+
const res = (Object.getPrototypeOf(obj) ? {} : Object.create(null));
|
|
2529
|
+
const ownKeys = Reflect.ownKeys(obj);
|
|
2530
|
+
if (isFunction(keys)) {
|
|
2531
|
+
for (let i = 0; i < ownKeys.length; i++) {
|
|
2532
|
+
const key = ownKeys[i];
|
|
2533
|
+
if (keys(obj[key], key, obj))
|
|
2534
|
+
res[key] = obj[key];
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
else if (isArray(keys)) {
|
|
2538
|
+
const keysSet = new Set(ownKeys);
|
|
2539
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2540
|
+
const key = keys[i];
|
|
2541
|
+
if (keysSet.has(isNumber(key) ? String(key) : key))
|
|
2542
|
+
res[key] = obj[key];
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
else if (isString(keys) || isNumber(keys) || isSymbol(keys)) {
|
|
2546
|
+
if (ownKeys.includes(isNumber(keys) ? String(keys) : keys))
|
|
2547
|
+
res[keys] = obj[keys];
|
|
2548
|
+
}
|
|
2549
|
+
return res;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2506
2552
|
function pipe(...pipeFunc) {
|
|
2507
2553
|
if (pipeFunc.length === 0) {
|
|
2508
2554
|
throw new Error('Invalid pipeFunc parameter: pipeFunc is empty');
|
|
@@ -2617,10 +2663,12 @@ See the Mulan PSL v2 for more details.
|
|
|
2617
2663
|
exports.memo = memo;
|
|
2618
2664
|
exports.noop = noop;
|
|
2619
2665
|
exports.not = not;
|
|
2666
|
+
exports.omit = omit;
|
|
2620
2667
|
exports.parallel = parallel;
|
|
2621
2668
|
exports.pascalCase = pascalCase;
|
|
2622
2669
|
exports.pass = pass;
|
|
2623
2670
|
exports.passWith = passWith;
|
|
2671
|
+
exports.pick = pick;
|
|
2624
2672
|
exports.pipe = pipe;
|
|
2625
2673
|
exports.randomBase32String = randomBase32String;
|
|
2626
2674
|
exports.randomChoice = randomChoice;
|