rattail 0.0.11 → 1.0.0
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 +58 -19
- package/lib/index.d.cts +10 -5
- package/lib/index.d.ts +10 -5
- package/lib/index.js +53 -5
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
9
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
10
|
var __defNormalProp = (obj, key3, value) => key3 in obj ? __defProp(obj, key3, { enumerable: true, configurable: true, writable: true, value }) : obj[key3] = value;
|
|
@@ -34,15 +32,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
32
|
}
|
|
35
33
|
return to;
|
|
36
34
|
};
|
|
37
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
38
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
39
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
40
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
41
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
42
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
43
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
44
|
-
mod
|
|
45
|
-
));
|
|
46
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
47
36
|
|
|
48
37
|
// src/index.ts
|
|
@@ -118,11 +107,14 @@ __export(src_exports, {
|
|
|
118
107
|
merge: () => merge,
|
|
119
108
|
mergeWith: () => mergeWith,
|
|
120
109
|
minBy: () => minBy,
|
|
121
|
-
mitt: () => import_mitt.default,
|
|
122
110
|
normalizeToArray: () => normalizeToArray,
|
|
123
111
|
objectToString: () => objectToString,
|
|
112
|
+
omit: () => omit,
|
|
113
|
+
omitBy: () => omitBy,
|
|
124
114
|
once: () => once,
|
|
125
115
|
pascalCase: () => pascalCase,
|
|
116
|
+
pick: () => pick,
|
|
117
|
+
pickBy: () => pickBy,
|
|
126
118
|
prettyJSONObject: () => prettyJSONObject,
|
|
127
119
|
preventDefault: () => preventDefault,
|
|
128
120
|
raf: () => raf,
|
|
@@ -583,6 +575,55 @@ function normalizeToArray(value) {
|
|
|
583
575
|
return isArray(value) ? value : [value];
|
|
584
576
|
}
|
|
585
577
|
|
|
578
|
+
// src/object/pick.ts
|
|
579
|
+
function pick(object, keys) {
|
|
580
|
+
return keys.reduce(
|
|
581
|
+
(result, key3) => {
|
|
582
|
+
result[key3] = object[key3];
|
|
583
|
+
return result;
|
|
584
|
+
},
|
|
585
|
+
{}
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// src/object/pickBy.ts
|
|
590
|
+
function pickBy(object, fn) {
|
|
591
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
592
|
+
return ownKeys.reduce((result, key3) => {
|
|
593
|
+
const value = object[key3];
|
|
594
|
+
if (fn(value, key3)) {
|
|
595
|
+
result[key3] = value;
|
|
596
|
+
}
|
|
597
|
+
return result;
|
|
598
|
+
}, {});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// src/object/omit.ts
|
|
602
|
+
function omit(object, keys) {
|
|
603
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
604
|
+
return ownKeys.reduce(
|
|
605
|
+
(result, key3) => {
|
|
606
|
+
if (!keys.includes(key3)) {
|
|
607
|
+
result[key3] = object[key3];
|
|
608
|
+
}
|
|
609
|
+
return result;
|
|
610
|
+
},
|
|
611
|
+
{}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/object/omitBy.ts
|
|
616
|
+
function omitBy(object, fn) {
|
|
617
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
618
|
+
return ownKeys.reduce((result, key3) => {
|
|
619
|
+
const value = object[key3];
|
|
620
|
+
if (!fn(value, key3)) {
|
|
621
|
+
result[key3] = value;
|
|
622
|
+
}
|
|
623
|
+
return result;
|
|
624
|
+
}, {});
|
|
625
|
+
}
|
|
626
|
+
|
|
586
627
|
// src/util/cancelAnimationFrame.ts
|
|
587
628
|
function cancelAnimationFrame(handle) {
|
|
588
629
|
const globalThis2 = getGlobalThis();
|
|
@@ -1155,10 +1196,6 @@ function sample(arr) {
|
|
|
1155
1196
|
}
|
|
1156
1197
|
return arr[randomNumber(0, arr.length - 1)];
|
|
1157
1198
|
}
|
|
1158
|
-
|
|
1159
|
-
// src/index.ts
|
|
1160
|
-
__reExport(src_exports, require("mitt"), module.exports);
|
|
1161
|
-
var import_mitt = __toESM(require("mitt"), 1);
|
|
1162
1199
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1163
1200
|
0 && (module.exports = {
|
|
1164
1201
|
NOOP,
|
|
@@ -1231,11 +1268,14 @@ var import_mitt = __toESM(require("mitt"), 1);
|
|
|
1231
1268
|
merge,
|
|
1232
1269
|
mergeWith,
|
|
1233
1270
|
minBy,
|
|
1234
|
-
mitt,
|
|
1235
1271
|
normalizeToArray,
|
|
1236
1272
|
objectToString,
|
|
1273
|
+
omit,
|
|
1274
|
+
omitBy,
|
|
1237
1275
|
once,
|
|
1238
1276
|
pascalCase,
|
|
1277
|
+
pick,
|
|
1278
|
+
pickBy,
|
|
1239
1279
|
prettyJSONObject,
|
|
1240
1280
|
preventDefault,
|
|
1241
1281
|
raf,
|
|
@@ -1266,6 +1306,5 @@ var import_mitt = __toESM(require("mitt"), 1);
|
|
|
1266
1306
|
tryParseJSON,
|
|
1267
1307
|
uniq,
|
|
1268
1308
|
uniqBy,
|
|
1269
|
-
upperFirst
|
|
1270
|
-
...require("mitt")
|
|
1309
|
+
upperFirst
|
|
1271
1310
|
});
|
package/lib/index.d.cts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export * from 'mitt';
|
|
2
|
-
export { default as mitt } from 'mitt';
|
|
3
|
-
|
|
4
1
|
declare function at<T>(arr: T[], index: number): T | undefined;
|
|
5
2
|
|
|
6
3
|
declare function chunk<T>(arr: T[], size?: number): T[][];
|
|
@@ -11,7 +8,7 @@ declare function toggleItem<T>(arr: Array<T>, item: T): T[];
|
|
|
11
8
|
|
|
12
9
|
declare function uniq<T>(arr: T[]): T[];
|
|
13
10
|
|
|
14
|
-
declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) =>
|
|
11
|
+
declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) => any): T[];
|
|
15
12
|
|
|
16
13
|
declare function find<T>(arr: Array<T>, fn: (item: T, index: number, array: Array<T>) => any, from?: 'start' | 'end'): [T, number] | [null, -1];
|
|
17
14
|
|
|
@@ -23,6 +20,14 @@ declare function removeArrayEmpty<T>(arr: Array<T | null | undefined | ''>): T[]
|
|
|
23
20
|
|
|
24
21
|
declare function normalizeToArray<T>(value: T | T[]): T[];
|
|
25
22
|
|
|
23
|
+
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
24
|
+
|
|
25
|
+
declare function pickBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
26
|
+
|
|
27
|
+
declare function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
|
|
28
|
+
|
|
29
|
+
declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
30
|
+
|
|
26
31
|
declare function cancelAnimationFrame(handle: number): void;
|
|
27
32
|
|
|
28
33
|
type ClassName = string | undefined | null;
|
|
@@ -220,4 +225,4 @@ declare function meanBy<T>(arr: T[], fn: (val: T) => number): number;
|
|
|
220
225
|
|
|
221
226
|
declare function sample<T>(arr: T[]): T | undefined;
|
|
222
227
|
|
|
223
|
-
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, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isArrayBuffer, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, 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, once, pascalCase, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
|
228
|
+
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, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isArrayBuffer, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, 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, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export * from 'mitt';
|
|
2
|
-
export { default as mitt } from 'mitt';
|
|
3
|
-
|
|
4
1
|
declare function at<T>(arr: T[], index: number): T | undefined;
|
|
5
2
|
|
|
6
3
|
declare function chunk<T>(arr: T[], size?: number): T[][];
|
|
@@ -11,7 +8,7 @@ declare function toggleItem<T>(arr: Array<T>, item: T): T[];
|
|
|
11
8
|
|
|
12
9
|
declare function uniq<T>(arr: T[]): T[];
|
|
13
10
|
|
|
14
|
-
declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) =>
|
|
11
|
+
declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) => any): T[];
|
|
15
12
|
|
|
16
13
|
declare function find<T>(arr: Array<T>, fn: (item: T, index: number, array: Array<T>) => any, from?: 'start' | 'end'): [T, number] | [null, -1];
|
|
17
14
|
|
|
@@ -23,6 +20,14 @@ declare function removeArrayEmpty<T>(arr: Array<T | null | undefined | ''>): T[]
|
|
|
23
20
|
|
|
24
21
|
declare function normalizeToArray<T>(value: T | T[]): T[];
|
|
25
22
|
|
|
23
|
+
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
24
|
+
|
|
25
|
+
declare function pickBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
26
|
+
|
|
27
|
+
declare function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
|
|
28
|
+
|
|
29
|
+
declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
30
|
+
|
|
26
31
|
declare function cancelAnimationFrame(handle: number): void;
|
|
27
32
|
|
|
28
33
|
type ClassName = string | undefined | null;
|
|
@@ -220,4 +225,4 @@ declare function meanBy<T>(arr: T[], fn: (val: T) => number): number;
|
|
|
220
225
|
|
|
221
226
|
declare function sample<T>(arr: T[]): T | undefined;
|
|
222
227
|
|
|
223
|
-
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, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isArrayBuffer, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, 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, once, pascalCase, prettyJSONObject, preventDefault, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
|
228
|
+
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, doubleRaf, ensurePrefix, ensureSuffix, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isArrayBuffer, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEqual, isEqualWith, isError, 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, sample, sessionStorage, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst };
|
package/lib/index.js
CHANGED
|
@@ -444,6 +444,55 @@ function normalizeToArray(value) {
|
|
|
444
444
|
return isArray(value) ? value : [value];
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
+
// src/object/pick.ts
|
|
448
|
+
function pick(object, keys) {
|
|
449
|
+
return keys.reduce(
|
|
450
|
+
(result, key3) => {
|
|
451
|
+
result[key3] = object[key3];
|
|
452
|
+
return result;
|
|
453
|
+
},
|
|
454
|
+
{}
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// src/object/pickBy.ts
|
|
459
|
+
function pickBy(object, fn) {
|
|
460
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
461
|
+
return ownKeys.reduce((result, key3) => {
|
|
462
|
+
const value = object[key3];
|
|
463
|
+
if (fn(value, key3)) {
|
|
464
|
+
result[key3] = value;
|
|
465
|
+
}
|
|
466
|
+
return result;
|
|
467
|
+
}, {});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// src/object/omit.ts
|
|
471
|
+
function omit(object, keys) {
|
|
472
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
473
|
+
return ownKeys.reduce(
|
|
474
|
+
(result, key3) => {
|
|
475
|
+
if (!keys.includes(key3)) {
|
|
476
|
+
result[key3] = object[key3];
|
|
477
|
+
}
|
|
478
|
+
return result;
|
|
479
|
+
},
|
|
480
|
+
{}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/object/omitBy.ts
|
|
485
|
+
function omitBy(object, fn) {
|
|
486
|
+
const ownKeys = [...Object.keys(object), ...Object.getOwnPropertySymbols(object)];
|
|
487
|
+
return ownKeys.reduce((result, key3) => {
|
|
488
|
+
const value = object[key3];
|
|
489
|
+
if (!fn(value, key3)) {
|
|
490
|
+
result[key3] = value;
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
}, {});
|
|
494
|
+
}
|
|
495
|
+
|
|
447
496
|
// src/util/cancelAnimationFrame.ts
|
|
448
497
|
function cancelAnimationFrame(handle) {
|
|
449
498
|
const globalThis2 = getGlobalThis();
|
|
@@ -1016,10 +1065,6 @@ function sample(arr) {
|
|
|
1016
1065
|
}
|
|
1017
1066
|
return arr[randomNumber(0, arr.length - 1)];
|
|
1018
1067
|
}
|
|
1019
|
-
|
|
1020
|
-
// src/index.ts
|
|
1021
|
-
export * from "mitt";
|
|
1022
|
-
import { default as default2 } from "mitt";
|
|
1023
1068
|
export {
|
|
1024
1069
|
NOOP,
|
|
1025
1070
|
at,
|
|
@@ -1091,11 +1136,14 @@ export {
|
|
|
1091
1136
|
merge,
|
|
1092
1137
|
mergeWith,
|
|
1093
1138
|
minBy,
|
|
1094
|
-
default2 as mitt,
|
|
1095
1139
|
normalizeToArray,
|
|
1096
1140
|
objectToString,
|
|
1141
|
+
omit,
|
|
1142
|
+
omitBy,
|
|
1097
1143
|
once,
|
|
1098
1144
|
pascalCase,
|
|
1145
|
+
pick,
|
|
1146
|
+
pickBy,
|
|
1099
1147
|
prettyJSONObject,
|
|
1100
1148
|
preventDefault,
|
|
1101
1149
|
raf,
|