rattail 1.0.22 → 1.0.24

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 CHANGED
@@ -137,6 +137,8 @@ __export(src_exports, {
137
137
  mitt: () => import_mitt.default,
138
138
  motion: () => motion,
139
139
  normalizeToArray: () => normalizeToArray,
140
+ objectEntries: () => objectEntries,
141
+ objectKeys: () => objectKeys,
140
142
  objectToString: () => objectToString,
141
143
  omit: () => omit,
142
144
  omitBy: () => omitBy,
@@ -158,6 +160,7 @@ __export(src_exports, {
158
160
  round: () => round,
159
161
  sample: () => sample,
160
162
  sessionStorage: () => sessionStorage,
163
+ set: () => set,
161
164
  shuffle: () => shuffle,
162
165
  slash: () => slash,
163
166
  sum: () => sum,
@@ -776,6 +779,37 @@ function promiseWithResolvers() {
776
779
  return { promise, resolve, reject };
777
780
  }
778
781
 
782
+ // src/object/set.ts
783
+ function set(object, path, value) {
784
+ if (!isObject(object)) {
785
+ return;
786
+ }
787
+ const keys = [...path];
788
+ if (keys.length === 0) {
789
+ return;
790
+ }
791
+ let target = object;
792
+ while (keys.length > 1) {
793
+ const key3 = keys.shift();
794
+ const nextKey = keys[0];
795
+ if (!isObject(target[key3])) {
796
+ target[key3] = isNumber(nextKey) ? [] : {};
797
+ }
798
+ target = target[key3];
799
+ }
800
+ target[keys[0]] = value;
801
+ }
802
+
803
+ // src/object/objectKeys.ts
804
+ function objectKeys(object) {
805
+ return Object.keys(object);
806
+ }
807
+
808
+ // src/object/objectEntries.ts
809
+ function objectEntries(object) {
810
+ return Object.entries(object);
811
+ }
812
+
779
813
  // src/util/index.ts
780
814
  var util_exports = {};
781
815
  __export(util_exports, {
@@ -1645,6 +1679,8 @@ function ceil(val, precision = 0) {
1645
1679
  mitt,
1646
1680
  motion,
1647
1681
  normalizeToArray,
1682
+ objectEntries,
1683
+ objectKeys,
1648
1684
  objectToString,
1649
1685
  omit,
1650
1686
  omitBy,
@@ -1666,6 +1702,7 @@ function ceil(val, precision = 0) {
1666
1702
  round,
1667
1703
  sample,
1668
1704
  sessionStorage,
1705
+ set,
1669
1706
  shuffle,
1670
1707
  slash,
1671
1708
  sum,
package/lib/index.d.cts CHANGED
@@ -58,6 +58,12 @@ type PromiseWithResolvers<T> = {
58
58
  };
59
59
  declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
60
60
 
61
+ declare function set<T extends object | any[]>(object: T, path: (string | number)[], value: any): void;
62
+
63
+ declare function objectKeys<T extends object>(object: T): `${keyof T & string}`[];
64
+
65
+ declare function objectEntries<T extends object>(object: T): [keyof T & string, T[keyof T & string]][];
66
+
61
67
  declare function cancelAnimationFrame(handle: number): void;
62
68
 
63
69
  type ClassName = string | undefined | null;
@@ -310,4 +316,4 @@ declare function floor(val: number, precision?: number): number;
310
316
 
311
317
  declare function ceil(val: number, precision?: number): number;
312
318
 
313
- export { type BEM, type ClassName, type Classes, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, 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, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, 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 };
319
+ export { type BEM, type ClassName, type Classes, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, 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, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, set, 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
@@ -58,6 +58,12 @@ type PromiseWithResolvers<T> = {
58
58
  };
59
59
  declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
60
60
 
61
+ declare function set<T extends object | any[]>(object: T, path: (string | number)[], value: any): void;
62
+
63
+ declare function objectKeys<T extends object>(object: T): `${keyof T & string}`[];
64
+
65
+ declare function objectEntries<T extends object>(object: T): [keyof T & string, T[keyof T & string]][];
66
+
61
67
  declare function cancelAnimationFrame(handle: number): void;
62
68
 
63
69
  type ClassName = string | undefined | null;
@@ -310,4 +316,4 @@ declare function floor(val: number, precision?: number): number;
310
316
 
311
317
  declare function ceil(val: number, precision?: number): number;
312
318
 
313
- export { type BEM, type ClassName, type Classes, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, 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, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, 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 };
319
+ export { type BEM, type ClassName, type Classes, type DurationContext, type Motion, type MotionOptions, type MotionState, NOOP, type PromiseWithResolvers, type Storage, assert, at, baseRound, call, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, 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, maxBy, mean, meanBy, merge, mergeWith, minBy, motion, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryParseJSON, uniq, uniqBy, upperFirst, xor, xorWith };
@@ -127,6 +127,8 @@ var Rattail = (() => {
127
127
  mitt: () => mitt_default,
128
128
  motion: () => motion,
129
129
  normalizeToArray: () => normalizeToArray,
130
+ objectEntries: () => objectEntries,
131
+ objectKeys: () => objectKeys,
130
132
  objectToString: () => objectToString,
131
133
  omit: () => omit,
132
134
  omitBy: () => omitBy,
@@ -148,6 +150,7 @@ var Rattail = (() => {
148
150
  round: () => round,
149
151
  sample: () => sample,
150
152
  sessionStorage: () => sessionStorage,
153
+ set: () => set,
151
154
  shuffle: () => shuffle,
152
155
  slash: () => slash,
153
156
  sum: () => sum,
@@ -765,6 +768,37 @@ var Rattail = (() => {
765
768
  return { promise, resolve, reject };
766
769
  }
767
770
 
771
+ // src/object/set.ts
772
+ function set(object, path, value) {
773
+ if (!isObject(object)) {
774
+ return;
775
+ }
776
+ const keys = [...path];
777
+ if (keys.length === 0) {
778
+ return;
779
+ }
780
+ let target = object;
781
+ while (keys.length > 1) {
782
+ const key3 = keys.shift();
783
+ const nextKey = keys[0];
784
+ if (!isObject(target[key3])) {
785
+ target[key3] = isNumber(nextKey) ? [] : {};
786
+ }
787
+ target = target[key3];
788
+ }
789
+ target[keys[0]] = value;
790
+ }
791
+
792
+ // src/object/objectKeys.ts
793
+ function objectKeys(object) {
794
+ return Object.keys(object);
795
+ }
796
+
797
+ // src/object/objectEntries.ts
798
+ function objectEntries(object) {
799
+ return Object.entries(object);
800
+ }
801
+
768
802
  // src/util/cancelAnimationFrame.ts
769
803
  function cancelAnimationFrame(handle) {
770
804
  const globalThis2 = getGlobalThis();
package/lib/index.js CHANGED
@@ -125,6 +125,8 @@ __export(src_exports, {
125
125
  mitt: () => default2,
126
126
  motion: () => motion,
127
127
  normalizeToArray: () => normalizeToArray,
128
+ objectEntries: () => objectEntries,
129
+ objectKeys: () => objectKeys,
128
130
  objectToString: () => objectToString,
129
131
  omit: () => omit,
130
132
  omitBy: () => omitBy,
@@ -146,6 +148,7 @@ __export(src_exports, {
146
148
  round: () => round,
147
149
  sample: () => sample,
148
150
  sessionStorage: () => sessionStorage,
151
+ set: () => set,
149
152
  shuffle: () => shuffle,
150
153
  slash: () => slash,
151
154
  sum: () => sum,
@@ -763,6 +766,37 @@ function promiseWithResolvers() {
763
766
  return { promise, resolve, reject };
764
767
  }
765
768
 
769
+ // src/object/set.ts
770
+ function set(object, path, value) {
771
+ if (!isObject(object)) {
772
+ return;
773
+ }
774
+ const keys = [...path];
775
+ if (keys.length === 0) {
776
+ return;
777
+ }
778
+ let target = object;
779
+ while (keys.length > 1) {
780
+ const key3 = keys.shift();
781
+ const nextKey = keys[0];
782
+ if (!isObject(target[key3])) {
783
+ target[key3] = isNumber(nextKey) ? [] : {};
784
+ }
785
+ target = target[key3];
786
+ }
787
+ target[keys[0]] = value;
788
+ }
789
+
790
+ // src/object/objectKeys.ts
791
+ function objectKeys(object) {
792
+ return Object.keys(object);
793
+ }
794
+
795
+ // src/object/objectEntries.ts
796
+ function objectEntries(object) {
797
+ return Object.entries(object);
798
+ }
799
+
766
800
  // src/util/index.ts
767
801
  var util_exports = {};
768
802
  __export(util_exports, {
@@ -1632,6 +1666,8 @@ export {
1632
1666
  default2 as mitt,
1633
1667
  motion,
1634
1668
  normalizeToArray,
1669
+ objectEntries,
1670
+ objectKeys,
1635
1671
  objectToString,
1636
1672
  omit,
1637
1673
  omitBy,
@@ -1653,6 +1689,7 @@ export {
1653
1689
  round,
1654
1690
  sample,
1655
1691
  sessionStorage,
1692
+ set,
1656
1693
  shuffle,
1657
1694
  slash,
1658
1695
  sum,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rattail",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "A utilities library for front-end developers, lightweight and ts-friendly",
5
5
  "keywords": [
6
6
  "utilities library",