rattail 1.0.6 → 1.0.8
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/lib/index.cjs +23 -2
- package/lib/index.d.cts +12 -7
- package/lib/index.d.ts +12 -7
- package/lib/index.js +20 -1
- package/package.json +2 -3
package/lib/index.cjs
CHANGED
|
@@ -153,7 +153,9 @@ __export(src_exports, {
|
|
|
153
153
|
tryParseJSON: () => tryParseJSON,
|
|
154
154
|
uniq: () => uniq,
|
|
155
155
|
uniqBy: () => uniqBy,
|
|
156
|
-
upperFirst: () => upperFirst
|
|
156
|
+
upperFirst: () => upperFirst,
|
|
157
|
+
xor: () => xor,
|
|
158
|
+
xorWith: () => xorWith
|
|
157
159
|
});
|
|
158
160
|
module.exports = __toCommonJS(src_exports);
|
|
159
161
|
|
|
@@ -643,6 +645,23 @@ function groupBy(arr, fn) {
|
|
|
643
645
|
);
|
|
644
646
|
}
|
|
645
647
|
|
|
648
|
+
// src/array/xorWith.ts
|
|
649
|
+
function xorWith(...values) {
|
|
650
|
+
const fn = at(values, -1);
|
|
651
|
+
const targets = values.slice(0, -1);
|
|
652
|
+
return uniqBy(
|
|
653
|
+
targets.reduce((result, target) => {
|
|
654
|
+
return [...differenceWith(result, target, fn), ...differenceWith(target, result, fn)];
|
|
655
|
+
}),
|
|
656
|
+
fn
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// src/array/xor.ts
|
|
661
|
+
function xor(...values) {
|
|
662
|
+
return xorWith(...values, (a, b) => a === b);
|
|
663
|
+
}
|
|
664
|
+
|
|
646
665
|
// src/object/pick.ts
|
|
647
666
|
function pick(object, keys) {
|
|
648
667
|
return keys.reduce(
|
|
@@ -1403,5 +1422,7 @@ function round(val, precision = 0) {
|
|
|
1403
1422
|
tryParseJSON,
|
|
1404
1423
|
uniq,
|
|
1405
1424
|
uniqBy,
|
|
1406
|
-
upperFirst
|
|
1425
|
+
upperFirst,
|
|
1426
|
+
xor,
|
|
1427
|
+
xorWith
|
|
1407
1428
|
});
|
package/lib/index.d.cts
CHANGED
|
@@ -22,16 +22,21 @@ declare function normalizeToArray<T>(value: T | T[]): T[];
|
|
|
22
22
|
|
|
23
23
|
declare function difference<T>(arr: T[], ...values: T[][]): T[];
|
|
24
24
|
|
|
25
|
-
type Fn$
|
|
26
|
-
declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$
|
|
25
|
+
type Fn$4<T> = (a: T, b: T) => any;
|
|
26
|
+
declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$4<T>]): T[];
|
|
27
27
|
|
|
28
28
|
declare function intersection<T>(...values: T[][]): T[];
|
|
29
29
|
|
|
30
|
-
type Fn$
|
|
31
|
-
declare function intersectionWith<T>(...values: [...T[][], fn: Fn$
|
|
30
|
+
type Fn$3<T> = (a: T, b: T) => any;
|
|
31
|
+
declare function intersectionWith<T>(...values: [...T[][], fn: Fn$3<T>]): T[];
|
|
32
|
+
|
|
33
|
+
type Fn$2<T, K> = (val: T) => K;
|
|
34
|
+
declare function groupBy<T, K extends PropertyKey>(arr: T[], fn: Fn$2<T, K>): Record<K, T[]>;
|
|
35
|
+
|
|
36
|
+
declare function xor<T>(...values: T[][]): T[];
|
|
32
37
|
|
|
33
|
-
type Fn$1<T
|
|
34
|
-
declare function
|
|
38
|
+
type Fn$1<T> = (a: T, b: T) => any;
|
|
39
|
+
declare function xorWith<T>(...values: [...T[][], fn: Fn$1<T>]): T[];
|
|
35
40
|
|
|
36
41
|
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
37
42
|
|
|
@@ -245,4 +250,4 @@ declare function sample<T>(arr: T[]): T | undefined;
|
|
|
245
250
|
|
|
246
251
|
declare function round(val: number, precision?: number): number;
|
|
247
252
|
|
|
248
|
-
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
|
253
|
+
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
package/lib/index.d.ts
CHANGED
|
@@ -22,16 +22,21 @@ declare function normalizeToArray<T>(value: T | T[]): T[];
|
|
|
22
22
|
|
|
23
23
|
declare function difference<T>(arr: T[], ...values: T[][]): T[];
|
|
24
24
|
|
|
25
|
-
type Fn$
|
|
26
|
-
declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$
|
|
25
|
+
type Fn$4<T> = (a: T, b: T) => any;
|
|
26
|
+
declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$4<T>]): T[];
|
|
27
27
|
|
|
28
28
|
declare function intersection<T>(...values: T[][]): T[];
|
|
29
29
|
|
|
30
|
-
type Fn$
|
|
31
|
-
declare function intersectionWith<T>(...values: [...T[][], fn: Fn$
|
|
30
|
+
type Fn$3<T> = (a: T, b: T) => any;
|
|
31
|
+
declare function intersectionWith<T>(...values: [...T[][], fn: Fn$3<T>]): T[];
|
|
32
|
+
|
|
33
|
+
type Fn$2<T, K> = (val: T) => K;
|
|
34
|
+
declare function groupBy<T, K extends PropertyKey>(arr: T[], fn: Fn$2<T, K>): Record<K, T[]>;
|
|
35
|
+
|
|
36
|
+
declare function xor<T>(...values: T[][]): T[];
|
|
32
37
|
|
|
33
|
-
type Fn$1<T
|
|
34
|
-
declare function
|
|
38
|
+
type Fn$1<T> = (a: T, b: T) => any;
|
|
39
|
+
declare function xorWith<T>(...values: [...T[][], fn: Fn$1<T>]): T[];
|
|
35
40
|
|
|
36
41
|
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
37
42
|
|
|
@@ -245,4 +250,4 @@ declare function sample<T>(arr: T[]): T | undefined;
|
|
|
245
250
|
|
|
246
251
|
declare function round(val: number, precision?: number): number;
|
|
247
252
|
|
|
248
|
-
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
|
253
|
+
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
|
package/lib/index.js
CHANGED
|
@@ -504,6 +504,23 @@ function groupBy(arr, fn) {
|
|
|
504
504
|
);
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
+
// src/array/xorWith.ts
|
|
508
|
+
function xorWith(...values) {
|
|
509
|
+
const fn = at(values, -1);
|
|
510
|
+
const targets = values.slice(0, -1);
|
|
511
|
+
return uniqBy(
|
|
512
|
+
targets.reduce((result, target) => {
|
|
513
|
+
return [...differenceWith(result, target, fn), ...differenceWith(target, result, fn)];
|
|
514
|
+
}),
|
|
515
|
+
fn
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/array/xor.ts
|
|
520
|
+
function xor(...values) {
|
|
521
|
+
return xorWith(...values, (a, b) => a === b);
|
|
522
|
+
}
|
|
523
|
+
|
|
507
524
|
// src/object/pick.ts
|
|
508
525
|
function pick(object, keys) {
|
|
509
526
|
return keys.reduce(
|
|
@@ -1263,5 +1280,7 @@ export {
|
|
|
1263
1280
|
tryParseJSON,
|
|
1264
1281
|
uniq,
|
|
1265
1282
|
uniqBy,
|
|
1266
|
-
upperFirst
|
|
1283
|
+
upperFirst,
|
|
1284
|
+
xor,
|
|
1285
|
+
xorWith
|
|
1267
1286
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rattail",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -65,12 +65,11 @@
|
|
|
65
65
|
"mitt": "^3.0.1"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
|
-
"dev": "
|
|
68
|
+
"dev": "vitest --coverage",
|
|
69
69
|
"build": "tsup src/index.ts --format esm,cjs --out-dir=lib --dts --clean",
|
|
70
70
|
"lint": "eslint . --fix --ext .ts,.js",
|
|
71
71
|
"format": "prettier --write .",
|
|
72
72
|
"clean": "rimraf node_modules lib",
|
|
73
|
-
"test:watch": "vitest --coverage",
|
|
74
73
|
"test": "vitest run --coverage",
|
|
75
74
|
"release": "pnpm build && vr release",
|
|
76
75
|
"docs:dev": "vitepress dev docs",
|