rattail 0.0.1 → 0.0.3
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/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/lib/index.cjs +8 -16
- package/lib/index.d.cts +2 -3
- package/lib/index.d.ts +2 -3
- package/lib/index.js +8 -15
- package/package.json +1 -1
package/README.md
CHANGED
package/README.zh-CN.md
CHANGED
package/lib/index.cjs
CHANGED
|
@@ -82,7 +82,6 @@ __export(src_exports, {
|
|
|
82
82
|
isString: () => isString,
|
|
83
83
|
isSymbol: () => isSymbol,
|
|
84
84
|
isTruthy: () => isTruthy,
|
|
85
|
-
isURL: () => isURL,
|
|
86
85
|
isWindow: () => isWindow,
|
|
87
86
|
kebabCase: () => kebabCase,
|
|
88
87
|
localStorage: () => localStorage,
|
|
@@ -174,12 +173,6 @@ function isNullish(val) {
|
|
|
174
173
|
function isTruthy(v) {
|
|
175
174
|
return Boolean(v);
|
|
176
175
|
}
|
|
177
|
-
function isURL(val) {
|
|
178
|
-
if (!val) {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
return /^(http)|(\.*\/)/.test(val);
|
|
182
|
-
}
|
|
183
176
|
function isEmpty(val) {
|
|
184
177
|
return val === void 0 || val === null || val === "" || isArray(val) && !val.length;
|
|
185
178
|
}
|
|
@@ -283,7 +276,8 @@ function pascalCase(s) {
|
|
|
283
276
|
return camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
284
277
|
}
|
|
285
278
|
function camelize(s) {
|
|
286
|
-
|
|
279
|
+
s = s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
280
|
+
return s.replace(s.charAt(0), s.charAt(0).toLowerCase());
|
|
287
281
|
}
|
|
288
282
|
function kebabCase(s) {
|
|
289
283
|
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
@@ -298,7 +292,7 @@ function slash(path) {
|
|
|
298
292
|
}
|
|
299
293
|
var key = 0;
|
|
300
294
|
function genStringKey() {
|
|
301
|
-
return
|
|
295
|
+
return `generated-key-${key++}`;
|
|
302
296
|
}
|
|
303
297
|
function capitalizeFirstLetter(s) {
|
|
304
298
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -495,23 +489,22 @@ var key2 = 0;
|
|
|
495
489
|
function genNumberKey() {
|
|
496
490
|
return key2++;
|
|
497
491
|
}
|
|
498
|
-
function randomNumber(min = 0, max =
|
|
492
|
+
function randomNumber(min = 0, max = 100) {
|
|
499
493
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
500
494
|
}
|
|
501
495
|
|
|
502
496
|
// src/collection.ts
|
|
503
497
|
function mergeWith(object, source, callback) {
|
|
504
|
-
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
505
498
|
function baseMerge(target, src) {
|
|
506
499
|
for (const key3 in src) {
|
|
507
|
-
if (
|
|
500
|
+
if (hasOwn(src, key3)) {
|
|
508
501
|
const srcValue = src[key3];
|
|
509
502
|
const targetValue = target[key3];
|
|
510
|
-
const customResult = callback(targetValue, srcValue, key3, object, source);
|
|
503
|
+
const customResult = callback == null ? void 0 : callback(targetValue, srcValue, key3, object, source);
|
|
511
504
|
if (customResult !== void 0) {
|
|
512
505
|
target[key3] = customResult;
|
|
513
|
-
} else if (
|
|
514
|
-
if (
|
|
506
|
+
} else if (isObject(srcValue)) {
|
|
507
|
+
if (isObject(targetValue)) {
|
|
515
508
|
target[key3] = baseMerge(targetValue, srcValue);
|
|
516
509
|
} else {
|
|
517
510
|
target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
@@ -641,7 +634,6 @@ var localStorage = createStorage(globalThis.localStorage);
|
|
|
641
634
|
isString,
|
|
642
635
|
isSymbol,
|
|
643
636
|
isTruthy,
|
|
644
|
-
isURL,
|
|
645
637
|
isWindow,
|
|
646
638
|
kebabCase,
|
|
647
639
|
localStorage,
|
package/lib/index.d.cts
CHANGED
|
@@ -57,7 +57,6 @@ declare function isFunction(val: unknown): val is Function;
|
|
|
57
57
|
declare function isArray(val: unknown): val is Array<any>;
|
|
58
58
|
declare function isNullish<T>(val: T | null | undefined): val is NonNullable<T>;
|
|
59
59
|
declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
|
60
|
-
declare function isURL(val: string | undefined | null): boolean;
|
|
61
60
|
declare function isEmpty(val: unknown): boolean;
|
|
62
61
|
declare function isWindow(val: unknown): val is Window;
|
|
63
62
|
declare function supportTouch(): boolean;
|
|
@@ -80,7 +79,7 @@ declare function slash(path: string): string;
|
|
|
80
79
|
declare function genStringKey(): string;
|
|
81
80
|
declare function capitalizeFirstLetter(s: string): string;
|
|
82
81
|
|
|
83
|
-
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback
|
|
82
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback?: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
84
83
|
|
|
85
84
|
declare function tryParseJSON<T>(json: string): T | undefined;
|
|
86
85
|
declare function prettyJSONObject(jsonObject: Record<string, any>): string;
|
|
@@ -98,4 +97,4 @@ declare function createStorage(storage: globalThis.Storage): Storage;
|
|
|
98
97
|
declare const sessionStorage: Storage;
|
|
99
98
|
declare const localStorage: Storage;
|
|
100
99
|
|
|
101
|
-
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, capitalizeFirstLetter, clamp, clampArrayRange, classes, createNamespaceFn, createStorage, debounce, doubleRaf, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy,
|
|
100
|
+
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, capitalizeFirstLetter, clamp, clampArrayRange, classes, createNamespaceFn, createStorage, debounce, doubleRaf, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isWindow, kebabCase, localStorage, mergeWith, normalizeToArray, objectToString, pascalCase, prettyJSONObject, preventDefault, raf, randomNumber, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, sessionStorage, shuffle, slash, sum, sumBy, supportTouch, throttle, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy };
|
package/lib/index.d.ts
CHANGED
|
@@ -57,7 +57,6 @@ declare function isFunction(val: unknown): val is Function;
|
|
|
57
57
|
declare function isArray(val: unknown): val is Array<any>;
|
|
58
58
|
declare function isNullish<T>(val: T | null | undefined): val is NonNullable<T>;
|
|
59
59
|
declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
|
60
|
-
declare function isURL(val: string | undefined | null): boolean;
|
|
61
60
|
declare function isEmpty(val: unknown): boolean;
|
|
62
61
|
declare function isWindow(val: unknown): val is Window;
|
|
63
62
|
declare function supportTouch(): boolean;
|
|
@@ -80,7 +79,7 @@ declare function slash(path: string): string;
|
|
|
80
79
|
declare function genStringKey(): string;
|
|
81
80
|
declare function capitalizeFirstLetter(s: string): string;
|
|
82
81
|
|
|
83
|
-
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback
|
|
82
|
+
declare function mergeWith<TObject extends Record<string, any>, TSource extends Record<string, any>>(object: TObject, source: TSource, callback?: (objValue: any, srcValue: any, key: string | number | symbol, object?: TObject, source?: TSource) => any | void): TObject & TSource;
|
|
84
83
|
|
|
85
84
|
declare function tryParseJSON<T>(json: string): T | undefined;
|
|
86
85
|
declare function prettyJSONObject(jsonObject: Record<string, any>): string;
|
|
@@ -98,4 +97,4 @@ declare function createStorage(storage: globalThis.Storage): Storage;
|
|
|
98
97
|
declare const sessionStorage: Storage;
|
|
99
98
|
declare const localStorage: Storage;
|
|
100
99
|
|
|
101
|
-
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, capitalizeFirstLetter, clamp, clampArrayRange, classes, createNamespaceFn, createStorage, debounce, doubleRaf, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy,
|
|
100
|
+
export { type BEM, type ClassName, type Classes, NOOP, type Storage, at, call, camelize, cancelAnimationFrame, capitalizeFirstLetter, clamp, clampArrayRange, classes, createNamespaceFn, createStorage, debounce, doubleRaf, find, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, hasOwn, inBrowser, inMobile, inViewport, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isWindow, kebabCase, localStorage, mergeWith, normalizeToArray, objectToString, pascalCase, prettyJSONObject, preventDefault, raf, randomNumber, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, sessionStorage, shuffle, slash, sum, sumBy, supportTouch, throttle, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy };
|
package/lib/index.js
CHANGED
|
@@ -74,12 +74,6 @@ function isNullish(val) {
|
|
|
74
74
|
function isTruthy(v) {
|
|
75
75
|
return Boolean(v);
|
|
76
76
|
}
|
|
77
|
-
function isURL(val) {
|
|
78
|
-
if (!val) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
return /^(http)|(\.*\/)/.test(val);
|
|
82
|
-
}
|
|
83
77
|
function isEmpty(val) {
|
|
84
78
|
return val === void 0 || val === null || val === "" || isArray(val) && !val.length;
|
|
85
79
|
}
|
|
@@ -183,7 +177,8 @@ function pascalCase(s) {
|
|
|
183
177
|
return camelize(s).replace(s.charAt(0), s.charAt(0).toUpperCase());
|
|
184
178
|
}
|
|
185
179
|
function camelize(s) {
|
|
186
|
-
|
|
180
|
+
s = s.replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
|
181
|
+
return s.replace(s.charAt(0), s.charAt(0).toLowerCase());
|
|
187
182
|
}
|
|
188
183
|
function kebabCase(s) {
|
|
189
184
|
const ret = s.replace(/([A-Z])/g, " $1").trim();
|
|
@@ -198,7 +193,7 @@ function slash(path) {
|
|
|
198
193
|
}
|
|
199
194
|
var key = 0;
|
|
200
195
|
function genStringKey() {
|
|
201
|
-
return
|
|
196
|
+
return `generated-key-${key++}`;
|
|
202
197
|
}
|
|
203
198
|
function capitalizeFirstLetter(s) {
|
|
204
199
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -395,23 +390,22 @@ var key2 = 0;
|
|
|
395
390
|
function genNumberKey() {
|
|
396
391
|
return key2++;
|
|
397
392
|
}
|
|
398
|
-
function randomNumber(min = 0, max =
|
|
393
|
+
function randomNumber(min = 0, max = 100) {
|
|
399
394
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
400
395
|
}
|
|
401
396
|
|
|
402
397
|
// src/collection.ts
|
|
403
398
|
function mergeWith(object, source, callback) {
|
|
404
|
-
const isObject2 = (obj) => obj !== null && typeof obj === "object";
|
|
405
399
|
function baseMerge(target, src) {
|
|
406
400
|
for (const key3 in src) {
|
|
407
|
-
if (
|
|
401
|
+
if (hasOwn(src, key3)) {
|
|
408
402
|
const srcValue = src[key3];
|
|
409
403
|
const targetValue = target[key3];
|
|
410
|
-
const customResult = callback(targetValue, srcValue, key3, object, source);
|
|
404
|
+
const customResult = callback == null ? void 0 : callback(targetValue, srcValue, key3, object, source);
|
|
411
405
|
if (customResult !== void 0) {
|
|
412
406
|
target[key3] = customResult;
|
|
413
|
-
} else if (
|
|
414
|
-
if (
|
|
407
|
+
} else if (isObject(srcValue)) {
|
|
408
|
+
if (isObject(targetValue)) {
|
|
415
409
|
target[key3] = baseMerge(targetValue, srcValue);
|
|
416
410
|
} else {
|
|
417
411
|
target[key3] = baseMerge(isArray(srcValue) ? [] : {}, srcValue);
|
|
@@ -540,7 +534,6 @@ export {
|
|
|
540
534
|
isString,
|
|
541
535
|
isSymbol,
|
|
542
536
|
isTruthy,
|
|
543
|
-
isURL,
|
|
544
537
|
isWindow,
|
|
545
538
|
kebabCase,
|
|
546
539
|
localStorage,
|