rattail 1.6.2 → 1.7.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/dist/index.d.mts CHANGED
@@ -101,20 +101,6 @@ declare namespace index_d_exports$1 {
101
101
  export { mitt, uuid, uuidV6 };
102
102
  }
103
103
  //#endregion
104
- //#region src/util/maskText.d.ts
105
- interface MaskTextOptions {
106
- prefix?: number;
107
- suffix?: number;
108
- mask?: string;
109
- maskLength?: number;
110
- }
111
- declare function maskText(text: string, {
112
- prefix,
113
- suffix,
114
- mask,
115
- maskLength
116
- }?: MaskTextOptions): string;
117
- //#endregion
118
104
  //#region src/util/cancelAnimationFrame.d.ts
119
105
  declare function cancelAnimationFrame(handle: number): void;
120
106
  //#endregion
@@ -312,6 +298,12 @@ declare const navigation: {
312
298
  //#region src/function/call.d.ts
313
299
  declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined;
314
300
  //#endregion
301
+ //#region src/function/tryCall.d.ts
302
+ declare function tryCall<Args extends any[], T>(fn: (...args: Args) => T, ...args: Args): [unknown, undefined] | [undefined, T];
303
+ //#endregion
304
+ //#region src/function/tryAsyncCall.d.ts
305
+ declare function tryAsyncCall<Args extends any[], T>(fn: (...args: Args) => Promise<T>, ...args: Args): Promise<[unknown, undefined] | [undefined, T]>;
306
+ //#endregion
315
307
  //#region src/function/once.d.ts
316
308
  declare function once<F extends (...args: any[]) => any>(fn: F): (this: unknown, ...args: Parameters<F>) => ReturnType<F>;
317
309
  //#endregion
@@ -475,6 +467,20 @@ declare function toNumber(val: number | string | boolean | undefined | null): nu
475
467
  //#region src/number/genNumberKey.d.ts
476
468
  declare function genNumberKey(): number;
477
469
  //#endregion
470
+ //#region src/string/maskString.d.ts
471
+ interface MaskStringOptions {
472
+ prefix?: number;
473
+ suffix?: number;
474
+ mask?: string;
475
+ maskLength?: number;
476
+ }
477
+ declare function maskString(text: string, {
478
+ prefix,
479
+ suffix,
480
+ mask,
481
+ maskLength
482
+ }?: MaskStringOptions): string;
483
+ //#endregion
478
484
  //#region src/string/camelize.d.ts
479
485
  declare function camelize(s: string): string;
480
486
  //#endregion
@@ -564,7 +570,7 @@ declare function floor(val: number, precision?: number): number;
564
570
  //#region src/math/ceil.d.ts
565
571
  declare function ceil(val: number, precision?: number): number;
566
572
  declare namespace index_d_exports {
567
- export { BEM, ClassName, Classes, CookieAttributes, CookieStorage, CreateCacheManagerOptions, DurationContext, EnumOf, EnumOfConfigValue, EnumOfExtractOptionShape, EnumOfExtractValues, EnumOfKeyForValue, EnumOfNormalizeToOption, EnumOfOptionForValue, EnumOfResolvedField, EnumOfResolvedOption, EnumOfResult, EnumOfResultMethods, EnumOfStringOrGetter, EnumOfValue, EnumOfValueObject, MaskTextOptions, Motion, MotionOptions, MotionState, NOOP, NavigationTarget, PromiseWithResolvers, Storage, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskText, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
573
+ export { BEM, ClassName, Classes, CookieAttributes, CookieStorage, CreateCacheManagerOptions, DurationContext, EnumOf, EnumOfConfigValue, EnumOfExtractOptionShape, EnumOfExtractValues, EnumOfKeyForValue, EnumOfNormalizeToOption, EnumOfOptionForValue, EnumOfResolvedField, EnumOfResolvedOption, EnumOfResult, EnumOfResultMethods, EnumOfStringOrGetter, EnumOfValue, EnumOfValueObject, MaskStringOptions, Motion, MotionOptions, MotionState, NOOP, NavigationTarget, PromiseWithResolvers, Storage, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskString, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryAsyncCall, tryCall, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
568
574
  }
569
575
  //#endregion
570
- export { BEM, ClassName, Classes, CookieAttributes, CookieStorage, CreateCacheManagerOptions, DurationContext, EnumOf, EnumOfConfigValue, EnumOfExtractOptionShape, EnumOfExtractValues, EnumOfKeyForValue, EnumOfNormalizeToOption, EnumOfOptionForValue, EnumOfResolvedField, EnumOfResolvedOption, EnumOfResult, EnumOfResultMethods, EnumOfStringOrGetter, EnumOfValue, EnumOfValueObject, MaskTextOptions, Motion, MotionOptions, MotionState, NOOP, NavigationTarget, PromiseWithResolvers, Storage, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskText, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
576
+ export { BEM, ClassName, Classes, CookieAttributes, CookieStorage, CreateCacheManagerOptions, DurationContext, EnumOf, EnumOfConfigValue, EnumOfExtractOptionShape, EnumOfExtractValues, EnumOfKeyForValue, EnumOfNormalizeToOption, EnumOfOptionForValue, EnumOfResolvedField, EnumOfResolvedOption, EnumOfResult, EnumOfResultMethods, EnumOfStringOrGetter, EnumOfValue, EnumOfValueObject, MaskStringOptions, Motion, MotionOptions, MotionState, NOOP, NavigationTarget, PromiseWithResolvers, Storage, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskString, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryAsyncCall, tryCall, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
package/dist/index.mjs CHANGED
@@ -569,16 +569,6 @@ var integrated_exports = /* @__PURE__ */ __exportAll({
569
569
  uuidV6: () => uuidV6
570
570
  });
571
571
  //#endregion
572
- //#region src/util/maskText.ts
573
- function maskText(text, { prefix = 2, suffix = 2, mask = "*", maskLength } = {}) {
574
- if (text.length <= 1) return text;
575
- const effectivePrefix = Math.min(prefix, text.length - 1);
576
- const effectiveSuffix = Math.min(suffix, Math.max(text.length - effectivePrefix - 1, 0));
577
- const count = maskLength ?? text.length - effectivePrefix - effectiveSuffix;
578
- const suffixPart = effectiveSuffix > 0 ? text.slice(-effectiveSuffix) : "";
579
- return text.slice(0, effectivePrefix) + mask.repeat(count) + suffixPart;
580
- }
581
- //#endregion
582
572
  //#region src/util/cancelAnimationFrame.ts
583
573
  function cancelAnimationFrame(handle) {
584
574
  const globalThis = getGlobalThis();
@@ -609,6 +599,16 @@ function copyText(value) {
609
599
  document.body.removeChild(textArea);
610
600
  }
611
601
  //#endregion
602
+ //#region src/string/maskString.ts
603
+ function maskString(text, { prefix = 2, suffix = 2, mask = "*", maskLength } = {}) {
604
+ if (text.length <= 1) return text;
605
+ const effectivePrefix = Math.min(prefix, text.length - 1);
606
+ const effectiveSuffix = Math.min(suffix, Math.max(text.length - effectivePrefix - 1, 0));
607
+ const count = maskLength ?? text.length - effectivePrefix - effectiveSuffix;
608
+ const suffixPart = effectiveSuffix > 0 ? text.slice(-effectiveSuffix) : "";
609
+ return text.slice(0, effectivePrefix) + mask.repeat(count) + suffixPart;
610
+ }
611
+ //#endregion
612
612
  //#region src/string/camelize.ts
613
613
  function camelize(s) {
614
614
  s = s.replace(/[-_](\w)/g, (_, p) => p.toUpperCase());
@@ -877,6 +877,24 @@ function call(fn, ...args) {
877
877
  if (fn) return fn(...args);
878
878
  }
879
879
  //#endregion
880
+ //#region src/function/tryCall.ts
881
+ function tryCall(fn, ...args) {
882
+ try {
883
+ return [void 0, fn(...args)];
884
+ } catch (e) {
885
+ return [e, void 0];
886
+ }
887
+ }
888
+ //#endregion
889
+ //#region src/function/tryAsyncCall.ts
890
+ async function tryAsyncCall(fn, ...args) {
891
+ try {
892
+ return [void 0, await fn(...args)];
893
+ } catch (e) {
894
+ return [e, void 0];
895
+ }
896
+ }
897
+ //#endregion
880
898
  //#region src/function/once.ts
881
899
  function once(fn) {
882
900
  let called = false;
@@ -1495,7 +1513,7 @@ __reExport(/* @__PURE__ */ __exportAll({
1495
1513
  localStorage: () => localStorage,
1496
1514
  lowerFirst: () => lowerFirst,
1497
1515
  mapObject: () => mapObject,
1498
- maskText: () => maskText,
1516
+ maskString: () => maskString,
1499
1517
  maxBy: () => maxBy,
1500
1518
  mean: () => mean,
1501
1519
  meanBy: () => meanBy,
@@ -1547,6 +1565,8 @@ __reExport(/* @__PURE__ */ __exportAll({
1547
1565
  toText: () => toText,
1548
1566
  toTypeString: () => toTypeString,
1549
1567
  toggleItem: () => toggleItem,
1568
+ tryAsyncCall: () => tryAsyncCall,
1569
+ tryCall: () => tryCall,
1550
1570
  tryParseJSON: () => tryParseJSON,
1551
1571
  uniq: () => uniq,
1552
1572
  uniqBy: () => uniqBy,
@@ -1557,4 +1577,4 @@ __reExport(/* @__PURE__ */ __exportAll({
1557
1577
  xorWith: () => xorWith
1558
1578
  }), integrated_exports);
1559
1579
  //#endregion
1560
- export { NOOP, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskText, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
1580
+ export { NOOP, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, 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, maskString, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryAsyncCall, tryCall, tryParseJSON, uniq, uniqBy, upperFirst, uuid, uuidV6, xor, xorWith };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rattail",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "A utilities library for front-end developers, lightweight and ts-friendly",
5
5
  "keywords": [
6
6
  "utilities library",