rattail 1.0.7 → 1.0.9
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 +37 -0
- package/lib/index.d.cts +12 -1
- package/lib/index.d.ts +12 -1
- package/lib/index.js +34 -0
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -95,6 +95,7 @@ __export(src_exports, {
|
|
|
95
95
|
isNumeric: () => isNumeric,
|
|
96
96
|
isObject: () => isObject,
|
|
97
97
|
isPlainObject: () => isPlainObject,
|
|
98
|
+
isPrimitive: () => isPrimitive,
|
|
98
99
|
isPromise: () => isPromise,
|
|
99
100
|
isRegExp: () => isRegExp,
|
|
100
101
|
isSet: () => isSet,
|
|
@@ -108,6 +109,7 @@ __export(src_exports, {
|
|
|
108
109
|
kebabCase: () => kebabCase,
|
|
109
110
|
localStorage: () => localStorage,
|
|
110
111
|
lowerFirst: () => lowerFirst,
|
|
112
|
+
mapObject: () => mapObject,
|
|
111
113
|
maxBy: () => maxBy,
|
|
112
114
|
mean: () => mean,
|
|
113
115
|
meanBy: () => meanBy,
|
|
@@ -124,6 +126,7 @@ __export(src_exports, {
|
|
|
124
126
|
pickBy: () => pickBy,
|
|
125
127
|
prettyJSONObject: () => prettyJSONObject,
|
|
126
128
|
preventDefault: () => preventDefault,
|
|
129
|
+
promiseWithResolvers: () => promiseWithResolvers,
|
|
127
130
|
raf: () => raf,
|
|
128
131
|
randomColor: () => randomColor,
|
|
129
132
|
randomNumber: () => randomNumber,
|
|
@@ -492,6 +495,11 @@ function isBlob(val) {
|
|
|
492
495
|
return toRawType(val) === "Blob";
|
|
493
496
|
}
|
|
494
497
|
|
|
498
|
+
// src/general/isPrimitive.ts
|
|
499
|
+
function isPrimitive(val) {
|
|
500
|
+
return val == null || typeof val !== "object" && typeof val !== "function";
|
|
501
|
+
}
|
|
502
|
+
|
|
495
503
|
// src/number/toNumber.ts
|
|
496
504
|
function toNumber(val) {
|
|
497
505
|
if (val == null) {
|
|
@@ -711,6 +719,32 @@ function omitBy(object, fn) {
|
|
|
711
719
|
}, {});
|
|
712
720
|
}
|
|
713
721
|
|
|
722
|
+
// src/object/mapObject.ts
|
|
723
|
+
function mapObject(object, fn) {
|
|
724
|
+
return Object.entries(object).reduce(
|
|
725
|
+
(result, [key3, value]) => {
|
|
726
|
+
const entry = fn(key3, value);
|
|
727
|
+
if (isArray(entry)) {
|
|
728
|
+
const [newKey, newValue] = entry;
|
|
729
|
+
result[newKey] = newValue;
|
|
730
|
+
}
|
|
731
|
+
return result;
|
|
732
|
+
},
|
|
733
|
+
{}
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/object/promiseWithResolvers.ts
|
|
738
|
+
function promiseWithResolvers() {
|
|
739
|
+
let resolve;
|
|
740
|
+
let reject;
|
|
741
|
+
const promise = new Promise((_resolver, _reject) => {
|
|
742
|
+
resolve = _resolver;
|
|
743
|
+
reject = _reject;
|
|
744
|
+
});
|
|
745
|
+
return { promise, resolve, reject };
|
|
746
|
+
}
|
|
747
|
+
|
|
714
748
|
// src/util/cancelAnimationFrame.ts
|
|
715
749
|
function cancelAnimationFrame(handle) {
|
|
716
750
|
const globalThis2 = getGlobalThis();
|
|
@@ -1364,6 +1398,7 @@ function round(val, precision = 0) {
|
|
|
1364
1398
|
isNumeric,
|
|
1365
1399
|
isObject,
|
|
1366
1400
|
isPlainObject,
|
|
1401
|
+
isPrimitive,
|
|
1367
1402
|
isPromise,
|
|
1368
1403
|
isRegExp,
|
|
1369
1404
|
isSet,
|
|
@@ -1377,6 +1412,7 @@ function round(val, precision = 0) {
|
|
|
1377
1412
|
kebabCase,
|
|
1378
1413
|
localStorage,
|
|
1379
1414
|
lowerFirst,
|
|
1415
|
+
mapObject,
|
|
1380
1416
|
maxBy,
|
|
1381
1417
|
mean,
|
|
1382
1418
|
meanBy,
|
|
@@ -1393,6 +1429,7 @@ function round(val, precision = 0) {
|
|
|
1393
1429
|
pickBy,
|
|
1394
1430
|
prettyJSONObject,
|
|
1395
1431
|
preventDefault,
|
|
1432
|
+
promiseWithResolvers,
|
|
1396
1433
|
raf,
|
|
1397
1434
|
randomColor,
|
|
1398
1435
|
randomNumber,
|
package/lib/index.d.cts
CHANGED
|
@@ -46,6 +46,15 @@ declare function omit<T extends object, K extends keyof T>(object: T, keys: K[])
|
|
|
46
46
|
|
|
47
47
|
declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
48
48
|
|
|
49
|
+
declare function mapObject<K extends PropertyKey, V, NK extends PropertyKey = K, NV = V>(object: Record<K, V>, fn: (key: K, value: V) => [PropertyKey, NV] | undefined): Record<NK, NV>;
|
|
50
|
+
|
|
51
|
+
type PromiseWithResolvers<T> = {
|
|
52
|
+
promise: Promise<T>;
|
|
53
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
54
|
+
reject: (reason?: any) => void;
|
|
55
|
+
};
|
|
56
|
+
declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
|
|
57
|
+
|
|
49
58
|
declare function cancelAnimationFrame(handle: number): void;
|
|
50
59
|
|
|
51
60
|
type ClassName = string | undefined | null;
|
|
@@ -181,6 +190,8 @@ declare function isFile(val: unknown): val is File;
|
|
|
181
190
|
|
|
182
191
|
declare function isBlob(val: unknown): val is Blob;
|
|
183
192
|
|
|
193
|
+
declare function isPrimitive(val: unknown): boolean;
|
|
194
|
+
|
|
184
195
|
declare function clamp(num: number, min: number, max: number): number;
|
|
185
196
|
|
|
186
197
|
declare function clampArrayRange(index: number, arr: Array<unknown>): number;
|
|
@@ -250,4 +261,4 @@ declare function sample<T>(arr: T[]): T | undefined;
|
|
|
250
261
|
|
|
251
262
|
declare function round(val: number, precision?: number): number;
|
|
252
263
|
|
|
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 };
|
|
264
|
+
export { type BEM, type ClassName, type Classes, NOOP, type PromiseWithResolvers, 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, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, 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
|
@@ -46,6 +46,15 @@ declare function omit<T extends object, K extends keyof T>(object: T, keys: K[])
|
|
|
46
46
|
|
|
47
47
|
declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
|
|
48
48
|
|
|
49
|
+
declare function mapObject<K extends PropertyKey, V, NK extends PropertyKey = K, NV = V>(object: Record<K, V>, fn: (key: K, value: V) => [PropertyKey, NV] | undefined): Record<NK, NV>;
|
|
50
|
+
|
|
51
|
+
type PromiseWithResolvers<T> = {
|
|
52
|
+
promise: Promise<T>;
|
|
53
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
54
|
+
reject: (reason?: any) => void;
|
|
55
|
+
};
|
|
56
|
+
declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
|
|
57
|
+
|
|
49
58
|
declare function cancelAnimationFrame(handle: number): void;
|
|
50
59
|
|
|
51
60
|
type ClassName = string | undefined | null;
|
|
@@ -181,6 +190,8 @@ declare function isFile(val: unknown): val is File;
|
|
|
181
190
|
|
|
182
191
|
declare function isBlob(val: unknown): val is Blob;
|
|
183
192
|
|
|
193
|
+
declare function isPrimitive(val: unknown): boolean;
|
|
194
|
+
|
|
184
195
|
declare function clamp(num: number, min: number, max: number): number;
|
|
185
196
|
|
|
186
197
|
declare function clampArrayRange(index: number, arr: Array<unknown>): number;
|
|
@@ -250,4 +261,4 @@ declare function sample<T>(arr: T[]): T | undefined;
|
|
|
250
261
|
|
|
251
262
|
declare function round(val: number, precision?: number): number;
|
|
252
263
|
|
|
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 };
|
|
264
|
+
export { type BEM, type ClassName, type Classes, NOOP, type PromiseWithResolvers, 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, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maxBy, mean, meanBy, merge, mergeWith, minBy, normalizeToArray, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, 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
|
@@ -351,6 +351,11 @@ function isBlob(val) {
|
|
|
351
351
|
return toRawType(val) === "Blob";
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
// src/general/isPrimitive.ts
|
|
355
|
+
function isPrimitive(val) {
|
|
356
|
+
return val == null || typeof val !== "object" && typeof val !== "function";
|
|
357
|
+
}
|
|
358
|
+
|
|
354
359
|
// src/number/toNumber.ts
|
|
355
360
|
function toNumber(val) {
|
|
356
361
|
if (val == null) {
|
|
@@ -570,6 +575,32 @@ function omitBy(object, fn) {
|
|
|
570
575
|
}, {});
|
|
571
576
|
}
|
|
572
577
|
|
|
578
|
+
// src/object/mapObject.ts
|
|
579
|
+
function mapObject(object, fn) {
|
|
580
|
+
return Object.entries(object).reduce(
|
|
581
|
+
(result, [key3, value]) => {
|
|
582
|
+
const entry = fn(key3, value);
|
|
583
|
+
if (isArray(entry)) {
|
|
584
|
+
const [newKey, newValue] = entry;
|
|
585
|
+
result[newKey] = newValue;
|
|
586
|
+
}
|
|
587
|
+
return result;
|
|
588
|
+
},
|
|
589
|
+
{}
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// src/object/promiseWithResolvers.ts
|
|
594
|
+
function promiseWithResolvers() {
|
|
595
|
+
let resolve;
|
|
596
|
+
let reject;
|
|
597
|
+
const promise = new Promise((_resolver, _reject) => {
|
|
598
|
+
resolve = _resolver;
|
|
599
|
+
reject = _reject;
|
|
600
|
+
});
|
|
601
|
+
return { promise, resolve, reject };
|
|
602
|
+
}
|
|
603
|
+
|
|
573
604
|
// src/util/cancelAnimationFrame.ts
|
|
574
605
|
function cancelAnimationFrame(handle) {
|
|
575
606
|
const globalThis2 = getGlobalThis();
|
|
@@ -1222,6 +1253,7 @@ export {
|
|
|
1222
1253
|
isNumeric,
|
|
1223
1254
|
isObject,
|
|
1224
1255
|
isPlainObject,
|
|
1256
|
+
isPrimitive,
|
|
1225
1257
|
isPromise,
|
|
1226
1258
|
isRegExp,
|
|
1227
1259
|
isSet,
|
|
@@ -1235,6 +1267,7 @@ export {
|
|
|
1235
1267
|
kebabCase,
|
|
1236
1268
|
localStorage,
|
|
1237
1269
|
lowerFirst,
|
|
1270
|
+
mapObject,
|
|
1238
1271
|
maxBy,
|
|
1239
1272
|
mean,
|
|
1240
1273
|
meanBy,
|
|
@@ -1251,6 +1284,7 @@ export {
|
|
|
1251
1284
|
pickBy,
|
|
1252
1285
|
prettyJSONObject,
|
|
1253
1286
|
preventDefault,
|
|
1287
|
+
promiseWithResolvers,
|
|
1254
1288
|
raf,
|
|
1255
1289
|
randomColor,
|
|
1256
1290
|
randomNumber,
|