@aiszlab/relax 2.0.4 → 2.0.6-beta.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.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -4
  3. package/dist/class-name/normalize.cjs +2 -4
  4. package/dist/class-name/normalize.d.ts +2 -1
  5. package/dist/class-name/normalize.mjs +2 -4
  6. package/dist/hooks/use-lazy-ref.cjs +18 -0
  7. package/dist/hooks/use-lazy-ref.d.ts +7 -0
  8. package/dist/hooks/use-lazy-ref.mjs +16 -0
  9. package/dist/hooks/use-scroll.cjs +26 -0
  10. package/dist/hooks/use-scroll.d.ts +6 -0
  11. package/dist/hooks/use-scroll.mjs +24 -0
  12. package/dist/index.cjs +10 -0
  13. package/dist/index.d.ts +5 -0
  14. package/dist/index.mjs +5 -0
  15. package/dist/is/is-deep-key.cjs +46 -0
  16. package/dist/is/is-deep-key.mjs +44 -0
  17. package/dist/is/is-iterable.cjs +12 -0
  18. package/dist/is/is-iterable.d.ts +5 -0
  19. package/dist/is/is-iterable.mjs +10 -0
  20. package/dist/is/is-key.cjs +38 -0
  21. package/dist/is/is-key.mjs +36 -0
  22. package/dist/is/is-symbol.cjs +23 -0
  23. package/dist/is/is-symbol.mjs +21 -0
  24. package/dist/utils/get.cjs +81 -0
  25. package/dist/utils/get.mjs +79 -0
  26. package/dist/utils/is-index.cjs +28 -0
  27. package/dist/utils/is-index.mjs +26 -0
  28. package/dist/utils/pick.cjs +16 -0
  29. package/dist/utils/pick.d.ts +5 -0
  30. package/dist/utils/pick.mjs +14 -0
  31. package/dist/utils/set.cjs +38 -0
  32. package/dist/utils/set.mjs +36 -0
  33. package/dist/utils/to-array.cjs +7 -0
  34. package/dist/utils/to-array.d.ts +1 -1
  35. package/dist/utils/to-array.mjs +7 -0
  36. package/dist/utils/to-key.cjs +23 -0
  37. package/dist/utils/to-key.mjs +21 -0
  38. package/dist/utils/to-paths.cjs +85 -0
  39. package/dist/utils/to-paths.mjs +83 -0
  40. package/dist/utils/update.cjs +46 -0
  41. package/dist/utils/update.mjs +44 -0
  42. package/package.json +19 -19
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 aiszlab
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 aiszlab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # relax
2
- favorite and easy hooks for react
3
-
4
- ## i alaways like writting many hooks for mine project
1
+ # relax
2
+ favorite and easy hooks for react
3
+
4
+ ## i alaways like writting many hooks for mine project
5
5
  ## so i need a hooks project to support me
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
3
  var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
5
4
  var isString = require('../is/is-string.cjs');
6
5
 
@@ -11,13 +10,12 @@ function normalize() {
11
10
  }
12
11
  for (var _i = 0, _classNames2 = classNames; _i < _classNames2.length; _i++) {
13
12
  var _classNames = _classNames2[_i];
14
- if (!isString.isString(_classNames)) return;
13
+ if (!isString.isString(_classNames)) continue;
15
14
  var _iterator = _createForOfIteratorHelper(_classNames.matchAll(/\S+/g)),
16
15
  _step;
17
16
  try {
18
17
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
- var _step$value = _slicedToArray(_step.value, 1),
20
- className = _step$value[0];
18
+ var className = _step.value[0];
21
19
  values.add(className);
22
20
  }
23
21
  } catch (err) {
@@ -1,2 +1,3 @@
1
- declare function normalize(...classNames: string[]): string[] | undefined;
1
+ import type { Partialable } from "../types";
2
+ declare function normalize(...classNames: Partialable<string>[]): string[];
2
3
  export { normalize };
@@ -1,4 +1,3 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
1
  import _createForOfIteratorHelper from '@babel/runtime/helpers/createForOfIteratorHelper';
3
2
  import { isString } from '../is/is-string.mjs';
4
3
 
@@ -9,13 +8,12 @@ function normalize() {
9
8
  }
10
9
  for (var _i = 0, _classNames2 = classNames; _i < _classNames2.length; _i++) {
11
10
  var _classNames = _classNames2[_i];
12
- if (!isString(_classNames)) return;
11
+ if (!isString(_classNames)) continue;
13
12
  var _iterator = _createForOfIteratorHelper(_classNames.matchAll(/\S+/g)),
14
13
  _step;
15
14
  try {
16
15
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
17
- var _step$value = _slicedToArray(_step.value, 1),
18
- className = _step$value[0];
16
+ var className = _step.value[0];
19
17
  values.add(className);
20
18
  }
21
19
  } catch (err) {
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+
5
+ /**
6
+ * in react, ref always need a initial value
7
+ * but can not be a function
8
+ * so we create a lazy ref to get a value getter
9
+ */
10
+ function useLazyRef(getter) {
11
+ var ref = react.useRef(null);
12
+ return function () {
13
+ var _ref$current;
14
+ return (_ref$current = ref.current) !== null && _ref$current !== void 0 ? _ref$current : ref.current = getter();
15
+ };
16
+ }
17
+
18
+ exports.useLazyRef = useLazyRef;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * in react, ref always need a initial value
3
+ * but can not be a function
4
+ * so we create a lazy ref to get a value getter
5
+ */
6
+ declare function useLazyRef<T>(getter: () => T): () => T;
7
+ export { useLazyRef };
@@ -0,0 +1,16 @@
1
+ import { useRef } from 'react';
2
+
3
+ /**
4
+ * in react, ref always need a initial value
5
+ * but can not be a function
6
+ * so we create a lazy ref to get a value getter
7
+ */
8
+ function useLazyRef(getter) {
9
+ var ref = useRef(null);
10
+ return function () {
11
+ var _ref$current;
12
+ return (_ref$current = ref.current) !== null && _ref$current !== void 0 ? _ref$current : ref.current = getter();
13
+ };
14
+ }
15
+
16
+ export { useLazyRef };
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var isDomUsable = require('../is/is-dom-usable.cjs');
5
+ var useEvent = require('./use-event.cjs');
6
+ var useMounted = require('./use-mounted.cjs');
7
+
8
+ /**
9
+ * `window` `scroll` event
10
+ */
11
+ function useScroll(callback) {
12
+ var _callback = useEvent.useEvent(function (event) {
13
+ callback(event);
14
+ });
15
+ var clean = react.useCallback(function () {
16
+ window.removeEventListener("scroll", _callback);
17
+ }, [_callback]);
18
+ useMounted.useMounted(function () {
19
+ if (!isDomUsable.isDomUsable()) return;
20
+ window.addEventListener("scroll", _callback);
21
+ return clean;
22
+ });
23
+ return clean;
24
+ }
25
+
26
+ exports.useScroll = useScroll;
@@ -0,0 +1,6 @@
1
+ import type { AnyFunction } from "../types";
2
+ /**
3
+ * `window` `scroll` event
4
+ */
5
+ declare function useScroll(callback: AnyFunction<[Event]>): () => void;
6
+ export { useScroll };
@@ -0,0 +1,24 @@
1
+ import { useCallback } from 'react';
2
+ import { isDomUsable } from '../is/is-dom-usable.mjs';
3
+ import { useEvent } from './use-event.mjs';
4
+ import { useMounted } from './use-mounted.mjs';
5
+
6
+ /**
7
+ * `window` `scroll` event
8
+ */
9
+ function useScroll(callback) {
10
+ var _callback = useEvent(function (event) {
11
+ callback(event);
12
+ });
13
+ var clean = useCallback(function () {
14
+ window.removeEventListener("scroll", _callback);
15
+ }, [_callback]);
16
+ useMounted(function () {
17
+ if (!isDomUsable()) return;
18
+ window.addEventListener("scroll", _callback);
19
+ return clean;
20
+ });
21
+ return clean;
22
+ }
23
+
24
+ export { useScroll };
package/dist/index.cjs CHANGED
@@ -40,6 +40,8 @@ var useEventSource = require('./hooks/use-event-source.cjs');
40
40
  var useResize = require('./hooks/use-resize.cjs');
41
41
  var useDraggable = require('./hooks/use-draggable.cjs');
42
42
  var useAsyncEffect = require('./hooks/use-async-effect.cjs');
43
+ var useLazyRef = require('./hooks/use-lazy-ref.cjs');
44
+ var useScroll = require('./hooks/use-scroll.cjs');
43
45
  var isRefable = require('./is/is-refable.cjs');
44
46
  var isUndefined = require('./is/is-undefined.cjs');
45
47
  var isNull = require('./is/is-null.cjs');
@@ -78,6 +80,9 @@ var max = require('./utils/max.cjs');
78
80
  var min = require('./utils/min.cjs');
79
81
  var load = require('./utils/load.cjs');
80
82
  var at = require('./utils/at.cjs');
83
+ var pick = require('./utils/pick.cjs');
84
+ var get = require('./utils/get.cjs');
85
+ var set = require('./utils/set.cjs');
81
86
  var replace = require('./utils/replace/replace.cjs');
82
87
  var replaceAt = require('./utils/replace/replace-at.cjs');
83
88
 
@@ -123,6 +128,8 @@ exports.useEventSource = useEventSource.useEventSource;
123
128
  exports.useResize = useResize.useResize;
124
129
  exports.useDraggable = useDraggable.useDraggable;
125
130
  exports.useAsyncEffect = useAsyncEffect.useAsyncEffect;
131
+ exports.useLazyRef = useLazyRef.useLazyRef;
132
+ exports.useScroll = useScroll.useScroll;
126
133
  exports.isRefable = isRefable.isRefable;
127
134
  exports.isUndefined = isUndefined.isUndefined;
128
135
  exports.isNull = isNull.isNull;
@@ -161,5 +168,8 @@ exports.max = max.max;
161
168
  exports.min = min.min;
162
169
  exports.load = load.load;
163
170
  exports.at = at.at;
171
+ exports.pick = pick.pick;
172
+ exports.get = get.get;
173
+ exports.set = set.set;
164
174
  exports.replace = replace.replace;
165
175
  exports.replaceAt = replaceAt.replaceAt;
package/dist/index.d.ts CHANGED
@@ -42,6 +42,8 @@ export { useEventSource } from "./hooks/use-event-source";
42
42
  export { useResize } from "./hooks/use-resize";
43
43
  export { useDraggable } from "./hooks/use-draggable";
44
44
  export { useAsyncEffect } from "./hooks/use-async-effect";
45
+ export { useLazyRef } from "./hooks/use-lazy-ref";
46
+ export { useScroll } from "./hooks/use-scroll";
45
47
  /**
46
48
  * @description
47
49
  * is
@@ -89,3 +91,6 @@ export { max } from "./utils/max";
89
91
  export { min } from "./utils/min";
90
92
  export { load } from "./utils/load";
91
93
  export { at } from "./utils/at";
94
+ export { pick } from "./utils/pick";
95
+ export { get } from "./utils/get";
96
+ export { set } from "./utils/set";
package/dist/index.mjs CHANGED
@@ -38,6 +38,8 @@ export { useEventSource } from './hooks/use-event-source.mjs';
38
38
  export { useResize } from './hooks/use-resize.mjs';
39
39
  export { useDraggable } from './hooks/use-draggable.mjs';
40
40
  export { useAsyncEffect } from './hooks/use-async-effect.mjs';
41
+ export { useLazyRef } from './hooks/use-lazy-ref.mjs';
42
+ export { useScroll } from './hooks/use-scroll.mjs';
41
43
  export { isRefable } from './is/is-refable.mjs';
42
44
  export { isUndefined } from './is/is-undefined.mjs';
43
45
  export { isNull } from './is/is-null.mjs';
@@ -76,5 +78,8 @@ export { max } from './utils/max.mjs';
76
78
  export { min } from './utils/min.mjs';
77
79
  export { load } from './utils/load.mjs';
78
80
  export { at } from './utils/at.mjs';
81
+ export { pick } from './utils/pick.mjs';
82
+ export { get } from './utils/get.mjs';
83
+ export { set } from './utils/set.mjs';
79
84
  export { replace } from './utils/replace/replace.mjs';
80
85
  export { replaceAt } from './utils/replace/replace-at.mjs';
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var _typeof = require('@babel/runtime/helpers/typeof');
4
+
5
+ /**
6
+ * Checks if a given key is a deep key.
7
+ *
8
+ * A deep key is a string that contains a dot (.) or square brackets with a property accessor.
9
+ *
10
+ * @param {PropertyKey} key - The key to check.
11
+ * @returns {boolean} - Returns true if the key is a deep key, otherwise false.
12
+ *
13
+ * Examples:
14
+ *
15
+ * isDeepKey('a.b') // true
16
+ * isDeepKey('a[b]') // true
17
+ * isDeepKey('a') // false
18
+ * isDeepKey(123) // false
19
+ * isDeepKey('a.b.c') // true
20
+ * isDeepKey('a[b][c]') // true
21
+ */
22
+ function isDeepKey(key) {
23
+ switch (_typeof(key)) {
24
+ case "number":
25
+ case "symbol":
26
+ {
27
+ return false;
28
+ }
29
+ case "string":
30
+ {
31
+ var _deepKeys = new Set([".", "[", "]"]);
32
+ for (var index = 0; index < key.length; index++) {
33
+ if (_deepKeys.has(key[index])) {
34
+ return true;
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+ default:
40
+ {
41
+ return false;
42
+ }
43
+ }
44
+ }
45
+
46
+ exports.isDeepKey = isDeepKey;
@@ -0,0 +1,44 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+
3
+ /**
4
+ * Checks if a given key is a deep key.
5
+ *
6
+ * A deep key is a string that contains a dot (.) or square brackets with a property accessor.
7
+ *
8
+ * @param {PropertyKey} key - The key to check.
9
+ * @returns {boolean} - Returns true if the key is a deep key, otherwise false.
10
+ *
11
+ * Examples:
12
+ *
13
+ * isDeepKey('a.b') // true
14
+ * isDeepKey('a[b]') // true
15
+ * isDeepKey('a') // false
16
+ * isDeepKey(123) // false
17
+ * isDeepKey('a.b.c') // true
18
+ * isDeepKey('a[b][c]') // true
19
+ */
20
+ function isDeepKey(key) {
21
+ switch (_typeof(key)) {
22
+ case "number":
23
+ case "symbol":
24
+ {
25
+ return false;
26
+ }
27
+ case "string":
28
+ {
29
+ var _deepKeys = new Set([".", "[", "]"]);
30
+ for (var index = 0; index < key.length; index++) {
31
+ if (_deepKeys.has(key[index])) {
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }
37
+ default:
38
+ {
39
+ return false;
40
+ }
41
+ }
42
+ }
43
+
44
+ export { isDeepKey };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var isFunction = require('./is-function.cjs');
4
+
5
+ /**
6
+ * is iterable
7
+ */
8
+ function isIterable(value) {
9
+ return isFunction.isFunction(value === null || value === void 0 ? void 0 : value[Symbol.iterator]);
10
+ }
11
+
12
+ exports.isIterable = isIterable;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * is iterable
3
+ */
4
+ declare function isIterable(value: unknown): value is Iterable<unknown>;
5
+ export { isIterable };
@@ -0,0 +1,10 @@
1
+ import { isFunction } from './is-function.mjs';
2
+
3
+ /**
4
+ * is iterable
5
+ */
6
+ function isIterable(value) {
7
+ return isFunction(value === null || value === void 0 ? void 0 : value[Symbol.iterator]);
8
+ }
9
+
10
+ export { isIterable };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var isArray = require('./is-array.cjs');
4
+ var isBoolean = require('./is-boolean.cjs');
5
+ var isNull = require('./is-null.cjs');
6
+ var isNumber = require('./is-number.cjs');
7
+ var isObject = require('./is-object.cjs');
8
+ var isString = require('./is-string.cjs');
9
+ var isSymbol = require('./is-symbol.cjs');
10
+
11
+ /** Matches any deep property path. (e.g. `a.b[0].c`)*/
12
+ var _IS_DEEP_KEY = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
13
+ /** Matches any word character (alphanumeric & underscore).*/
14
+ var _IS_PLAIN_KEY = /^\w*$/;
15
+ /**
16
+ * Checks if `value` is a property name and not a property path. (It's ok that the `value` is not in the keys of the `object`)
17
+ * @param {unknown} value The value to check.
18
+ * @param {unknown} object The object to query.
19
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
20
+ *
21
+ * @example
22
+ * isKey('a', { a: 1 });
23
+ * // => true
24
+ *
25
+ * isKey('a.b', { a: { b: 2 } });
26
+ * // => false
27
+ */
28
+ function isKey(value, object) {
29
+ if (isArray.isArray(value) || isObject.isObject(value)) {
30
+ return false;
31
+ }
32
+ if (isNumber.isNumber(value) || isBoolean.isBoolean(value) || isNull.isNull(value) || isSymbol.isSymbol(value)) {
33
+ return true;
34
+ }
35
+ return isString.isString(value) && (_IS_PLAIN_KEY.test(value) || !_IS_DEEP_KEY.test(value)) || object != null && Object.hasOwn(object, value);
36
+ }
37
+
38
+ exports.isKey = isKey;
@@ -0,0 +1,36 @@
1
+ import { isArray } from './is-array.mjs';
2
+ import { isBoolean } from './is-boolean.mjs';
3
+ import { isNull } from './is-null.mjs';
4
+ import { isNumber } from './is-number.mjs';
5
+ import { isObject } from './is-object.mjs';
6
+ import { isString } from './is-string.mjs';
7
+ import { isSymbol } from './is-symbol.mjs';
8
+
9
+ /** Matches any deep property path. (e.g. `a.b[0].c`)*/
10
+ var _IS_DEEP_KEY = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
11
+ /** Matches any word character (alphanumeric & underscore).*/
12
+ var _IS_PLAIN_KEY = /^\w*$/;
13
+ /**
14
+ * Checks if `value` is a property name and not a property path. (It's ok that the `value` is not in the keys of the `object`)
15
+ * @param {unknown} value The value to check.
16
+ * @param {unknown} object The object to query.
17
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
18
+ *
19
+ * @example
20
+ * isKey('a', { a: 1 });
21
+ * // => true
22
+ *
23
+ * isKey('a.b', { a: { b: 2 } });
24
+ * // => false
25
+ */
26
+ function isKey(value, object) {
27
+ if (isArray(value) || isObject(value)) {
28
+ return false;
29
+ }
30
+ if (isNumber(value) || isBoolean(value) || isNull(value) || isSymbol(value)) {
31
+ return true;
32
+ }
33
+ return isString(value) && (_IS_PLAIN_KEY.test(value) || !_IS_DEEP_KEY.test(value)) || object != null && Object.hasOwn(object, value);
34
+ }
35
+
36
+ export { isKey };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var _typeof = require('@babel/runtime/helpers/typeof');
4
+
5
+ /**
6
+ * Check whether a value is a symbol.
7
+ *
8
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`.
9
+ *
10
+ * @param {unknown} value The value to check.
11
+ * @returns {value is symbol} Returns `true` if `value` is a symbol, else `false`.
12
+ * @example
13
+ * isSymbol(Symbol.iterator);
14
+ * // => true
15
+ *
16
+ * isSymbol('abc');
17
+ * // => false
18
+ */
19
+ function isSymbol(value) {
20
+ return _typeof(value) === "symbol" || value instanceof Symbol;
21
+ }
22
+
23
+ exports.isSymbol = isSymbol;
@@ -0,0 +1,21 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+
3
+ /**
4
+ * Check whether a value is a symbol.
5
+ *
6
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`.
7
+ *
8
+ * @param {unknown} value The value to check.
9
+ * @returns {value is symbol} Returns `true` if `value` is a symbol, else `false`.
10
+ * @example
11
+ * isSymbol(Symbol.iterator);
12
+ * // => true
13
+ *
14
+ * isSymbol('abc');
15
+ * // => false
16
+ */
17
+ function isSymbol(value) {
18
+ return _typeof(value) === "symbol" || value instanceof Symbol;
19
+ }
20
+
21
+ export { isSymbol };
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ var _typeof = require('@babel/runtime/helpers/typeof');
4
+ var isDeepKey = require('../is/is-deep-key.cjs');
5
+ var toKey = require('./to-key.cjs');
6
+ var toPaths = require('./to-paths.cjs');
7
+
8
+ /**
9
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
10
+ *
11
+ * @param {unknown} object - The object to query.
12
+ * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
13
+ * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
14
+ * @returns {any} - Returns the resolved value.
15
+ */
16
+ function get(object, path, defaultValue) {
17
+ if (object == null) {
18
+ return defaultValue;
19
+ }
20
+ switch (_typeof(path)) {
21
+ case "string":
22
+ {
23
+ var result = object[path];
24
+ if (result === undefined) {
25
+ if (isDeepKey.isDeepKey(path)) {
26
+ return get(object, toPaths.toPaths(path), defaultValue);
27
+ } else {
28
+ return defaultValue;
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+ case "number":
34
+ case "symbol":
35
+ {
36
+ if (typeof path === "number") {
37
+ path = toKey.toKey(path);
38
+ }
39
+ var _result = object[path];
40
+ if (_result === undefined) {
41
+ return defaultValue;
42
+ }
43
+ return _result;
44
+ }
45
+ default:
46
+ {
47
+ var _path;
48
+ if (Array.isArray(path)) {
49
+ return getWithPath(object, path, defaultValue);
50
+ }
51
+ if (Object.is((_path = path) === null || _path === void 0 ? void 0 : _path.valueOf(), -0)) {
52
+ path = "-0";
53
+ } else {
54
+ path = String(path);
55
+ }
56
+ var _result2 = object[path];
57
+ if (_result2 === undefined) {
58
+ return defaultValue;
59
+ }
60
+ return _result2;
61
+ }
62
+ }
63
+ }
64
+ function getWithPath(object, path, defaultValue) {
65
+ if (path.length === 0) {
66
+ return defaultValue;
67
+ }
68
+ var current = object;
69
+ for (var index = 0; index < path.length; index++) {
70
+ if (current == null) {
71
+ return defaultValue;
72
+ }
73
+ current = current[path[index]];
74
+ }
75
+ if (current === undefined) {
76
+ return defaultValue;
77
+ }
78
+ return current;
79
+ }
80
+
81
+ exports.get = get;
@@ -0,0 +1,79 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+ import { isDeepKey } from '../is/is-deep-key.mjs';
3
+ import { toKey } from './to-key.mjs';
4
+ import { toPaths } from './to-paths.mjs';
5
+
6
+ /**
7
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
8
+ *
9
+ * @param {unknown} object - The object to query.
10
+ * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
11
+ * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
12
+ * @returns {any} - Returns the resolved value.
13
+ */
14
+ function get(object, path, defaultValue) {
15
+ if (object == null) {
16
+ return defaultValue;
17
+ }
18
+ switch (_typeof(path)) {
19
+ case "string":
20
+ {
21
+ var result = object[path];
22
+ if (result === undefined) {
23
+ if (isDeepKey(path)) {
24
+ return get(object, toPaths(path), defaultValue);
25
+ } else {
26
+ return defaultValue;
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ case "number":
32
+ case "symbol":
33
+ {
34
+ if (typeof path === "number") {
35
+ path = toKey(path);
36
+ }
37
+ var _result = object[path];
38
+ if (_result === undefined) {
39
+ return defaultValue;
40
+ }
41
+ return _result;
42
+ }
43
+ default:
44
+ {
45
+ var _path;
46
+ if (Array.isArray(path)) {
47
+ return getWithPath(object, path, defaultValue);
48
+ }
49
+ if (Object.is((_path = path) === null || _path === void 0 ? void 0 : _path.valueOf(), -0)) {
50
+ path = "-0";
51
+ } else {
52
+ path = String(path);
53
+ }
54
+ var _result2 = object[path];
55
+ if (_result2 === undefined) {
56
+ return defaultValue;
57
+ }
58
+ return _result2;
59
+ }
60
+ }
61
+ }
62
+ function getWithPath(object, path, defaultValue) {
63
+ if (path.length === 0) {
64
+ return defaultValue;
65
+ }
66
+ var current = object;
67
+ for (var index = 0; index < path.length; index++) {
68
+ if (current == null) {
69
+ return defaultValue;
70
+ }
71
+ current = current[path[index]];
72
+ }
73
+ if (current === undefined) {
74
+ return defaultValue;
75
+ }
76
+ return current;
77
+ }
78
+
79
+ export { get };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var _typeof = require('@babel/runtime/helpers/typeof');
4
+
5
+ var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
6
+ function isIndex(value) {
7
+ var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_SAFE_INTEGER;
8
+ switch (_typeof(value)) {
9
+ case "number":
10
+ {
11
+ return Number.isInteger(value) && value >= 0 && value < length;
12
+ }
13
+ case "symbol":
14
+ {
15
+ return false;
16
+ }
17
+ case "string":
18
+ {
19
+ return IS_UNSIGNED_INTEGER.test(value);
20
+ }
21
+ default:
22
+ {
23
+ return false;
24
+ }
25
+ }
26
+ }
27
+
28
+ exports.isIndex = isIndex;
@@ -0,0 +1,26 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+
3
+ var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
4
+ function isIndex(value) {
5
+ var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_SAFE_INTEGER;
6
+ switch (_typeof(value)) {
7
+ case "number":
8
+ {
9
+ return Number.isInteger(value) && value >= 0 && value < length;
10
+ }
11
+ case "symbol":
12
+ {
13
+ return false;
14
+ }
15
+ case "string":
16
+ {
17
+ return IS_UNSIGNED_INTEGER.test(value);
18
+ }
19
+ default:
20
+ {
21
+ return false;
22
+ }
23
+ }
24
+ }
25
+
26
+ export { isIndex };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var get = require('./get.cjs');
4
+ var set = require('./set.cjs');
5
+
6
+ /**
7
+ * pick value
8
+ */
9
+ function pick(value, keys) {
10
+ return keys.reduce(function (picked, key) {
11
+ set.set(picked, key, get.get(value, key));
12
+ return picked;
13
+ }, {});
14
+ }
15
+
16
+ exports.pick = pick;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * pick value
3
+ */
4
+ declare function pick<T extends object>(value: T, keys: PropertyKey[]): Partial<T>;
5
+ export { pick };
@@ -0,0 +1,14 @@
1
+ import { get } from './get.mjs';
2
+ import { set } from './set.mjs';
3
+
4
+ /**
5
+ * pick value
6
+ */
7
+ function pick(value, keys) {
8
+ return keys.reduce(function (picked, key) {
9
+ set(picked, key, get(value, key));
10
+ return picked;
11
+ }, {});
12
+ }
13
+
14
+ export { pick };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var update = require('./update.cjs');
4
+
5
+ /**
6
+ * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
7
+ *
8
+ * @template T - The type of the object.
9
+ * @param {T} obj - The object to modify.
10
+ * @param {PropertyKey | PropertyKey[]} path - The path of the property to set.
11
+ * @param {unknown} value - The value to set.
12
+ * @returns {T} - The modified object.
13
+ *
14
+ * @example
15
+ * // Set a value in a nested object
16
+ * const obj = { a: { b: { c: 3 } } };
17
+ * set(obj, 'a.b.c', 4);
18
+ * console.log(obj.a.b.c); // 4
19
+ *
20
+ * @example
21
+ * // Set a value in an array
22
+ * const arr = [1, 2, 3];
23
+ * set(arr, 1, 4);
24
+ * console.log(arr[1]); // 4
25
+ *
26
+ * @example
27
+ * // Create non-existent path and set value
28
+ * const obj = {};
29
+ * set(obj, 'a.b.c', 4);
30
+ * console.log(obj); // { a: { b: { c: 4 } } }
31
+ */
32
+ function set(obj, path, value) {
33
+ return update.update(obj, path, function () {
34
+ return value;
35
+ });
36
+ }
37
+
38
+ exports.set = set;
@@ -0,0 +1,36 @@
1
+ import { update } from './update.mjs';
2
+
3
+ /**
4
+ * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
5
+ *
6
+ * @template T - The type of the object.
7
+ * @param {T} obj - The object to modify.
8
+ * @param {PropertyKey | PropertyKey[]} path - The path of the property to set.
9
+ * @param {unknown} value - The value to set.
10
+ * @returns {T} - The modified object.
11
+ *
12
+ * @example
13
+ * // Set a value in a nested object
14
+ * const obj = { a: { b: { c: 3 } } };
15
+ * set(obj, 'a.b.c', 4);
16
+ * console.log(obj.a.b.c); // 4
17
+ *
18
+ * @example
19
+ * // Set a value in an array
20
+ * const arr = [1, 2, 3];
21
+ * set(arr, 1, 4);
22
+ * console.log(arr[1]); // 4
23
+ *
24
+ * @example
25
+ * // Create non-existent path and set value
26
+ * const obj = {};
27
+ * set(obj, 'a.b.c', 4);
28
+ * console.log(obj); // { a: { b: { c: 4 } } }
29
+ */
30
+ function set(obj, path, value) {
31
+ return update(obj, path, function () {
32
+ return value;
33
+ });
34
+ }
35
+
36
+ export { set };
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var isArray = require('../is/is-array.cjs');
4
+ var isIterable = require('../is/is-iterable.cjs');
5
+ var isString = require('../is/is-string.cjs');
4
6
  var isVoid = require('../is/is-void.cjs');
5
7
 
6
8
  /**
@@ -16,6 +18,11 @@ function toArray(value) {
16
18
  if (isArray.isArray(value)) {
17
19
  return value;
18
20
  }
21
+ // has iterator
22
+ // `string` to `[string]`
23
+ if (isIterable.isIterable(value) && !isString.isString(value)) {
24
+ return Array.from(value);
25
+ }
19
26
  return [value];
20
27
  }
21
28
 
@@ -1,4 +1,4 @@
1
- type ToArrayReturn<T> = T extends null ? unknown[] : T extends undefined ? unknown : T extends Array<infer E> ? E[] : T[];
1
+ type ToArrayReturn<T> = T extends null ? never[] : T extends undefined ? never[] : T extends string ? T[] : T extends Array<infer R> ? R[] : T extends Iterable<infer I> ? I[] : T[];
2
2
  /**
3
3
  * @description
4
4
  * convert any type data to a array
@@ -1,4 +1,6 @@
1
1
  import { isArray } from '../is/is-array.mjs';
2
+ import { isIterable } from '../is/is-iterable.mjs';
3
+ import { isString } from '../is/is-string.mjs';
2
4
  import { isVoid } from '../is/is-void.mjs';
3
5
 
4
6
  /**
@@ -14,6 +16,11 @@ function toArray(value) {
14
16
  if (isArray(value)) {
15
17
  return value;
16
18
  }
19
+ // has iterator
20
+ // `string` to `[string]`
21
+ if (isIterable(value) && !isString(value)) {
22
+ return Array.from(value);
23
+ }
17
24
  return [value];
18
25
  }
19
26
 
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var _typeof = require('@babel/runtime/helpers/typeof');
4
+
5
+ /**
6
+ * Converts `value` to a string key if it's not a string or symbol.
7
+ *
8
+ * @private
9
+ * @param {unknown} value The value to inspect.
10
+ * @returns {string|symbol} Returns the key.
11
+ */
12
+ function toKey(value) {
13
+ var _value$valueOf;
14
+ if (typeof value === "string" || _typeof(value) === "symbol") {
15
+ return value;
16
+ }
17
+ if (Object.is(value === null || value === void 0 || (_value$valueOf = value.valueOf) === null || _value$valueOf === void 0 ? void 0 : _value$valueOf.call(value), -0)) {
18
+ return "-0";
19
+ }
20
+ return String(value);
21
+ }
22
+
23
+ exports.toKey = toKey;
@@ -0,0 +1,21 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+
3
+ /**
4
+ * Converts `value` to a string key if it's not a string or symbol.
5
+ *
6
+ * @private
7
+ * @param {unknown} value The value to inspect.
8
+ * @returns {string|symbol} Returns the key.
9
+ */
10
+ function toKey(value) {
11
+ var _value$valueOf;
12
+ if (typeof value === "string" || _typeof(value) === "symbol") {
13
+ return value;
14
+ }
15
+ if (Object.is(value === null || value === void 0 || (_value$valueOf = value.valueOf) === null || _value$valueOf === void 0 ? void 0 : _value$valueOf.call(value), -0)) {
16
+ return "-0";
17
+ }
18
+ return String(value);
19
+ }
20
+
21
+ export { toKey };
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Converts a deep key string into an array of path segments.
5
+ *
6
+ * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.
7
+ *
8
+ * @param {string} deepKey - The deep key string to convert.
9
+ * @returns {string[]} An array of strings, each representing a segment of the path.
10
+ *
11
+ * Examples:
12
+ *
13
+ * toPath('a.b.c') // Returns ['a', 'b', 'c']
14
+ * toPath('a[b][c]') // Returns ['a', 'b', 'c']
15
+ * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']
16
+ * toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd']
17
+ * toPath('') // Returns []
18
+ * toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']
19
+ */
20
+ function toPaths(deepKey) {
21
+ var result = [];
22
+ var length = deepKey.length;
23
+ if (length === 0) {
24
+ return result;
25
+ }
26
+ var index = 0;
27
+ var key = "";
28
+ var quoteChar = "";
29
+ var bracket = false;
30
+ // Leading dot
31
+ if (deepKey.charCodeAt(0) === 46) {
32
+ result.push("");
33
+ index++;
34
+ }
35
+ while (index < length) {
36
+ var _char = deepKey[index];
37
+ if (quoteChar) {
38
+ if (_char === "\\" && index + 1 < length) {
39
+ // Escape character
40
+ index++;
41
+ key += deepKey[index];
42
+ } else if (_char === quoteChar) {
43
+ // End of quote
44
+ quoteChar = "";
45
+ } else {
46
+ key += _char;
47
+ }
48
+ } else if (bracket) {
49
+ if (_char === '"' || _char === "'") {
50
+ // Start of quoted string inside brackets
51
+ quoteChar = _char;
52
+ } else if (_char === "]") {
53
+ // End of bracketed segment
54
+ bracket = false;
55
+ result.push(key);
56
+ key = "";
57
+ } else {
58
+ key += _char;
59
+ }
60
+ } else {
61
+ if (_char === "[") {
62
+ // Start of bracketed segment
63
+ bracket = true;
64
+ if (key) {
65
+ result.push(key);
66
+ key = "";
67
+ }
68
+ } else if (_char === ".") {
69
+ if (key) {
70
+ result.push(key);
71
+ key = "";
72
+ }
73
+ } else {
74
+ key += _char;
75
+ }
76
+ }
77
+ index++;
78
+ }
79
+ if (key) {
80
+ result.push(key);
81
+ }
82
+ return result;
83
+ }
84
+
85
+ exports.toPaths = toPaths;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Converts a deep key string into an array of path segments.
3
+ *
4
+ * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.
5
+ *
6
+ * @param {string} deepKey - The deep key string to convert.
7
+ * @returns {string[]} An array of strings, each representing a segment of the path.
8
+ *
9
+ * Examples:
10
+ *
11
+ * toPath('a.b.c') // Returns ['a', 'b', 'c']
12
+ * toPath('a[b][c]') // Returns ['a', 'b', 'c']
13
+ * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']
14
+ * toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd']
15
+ * toPath('') // Returns []
16
+ * toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']
17
+ */
18
+ function toPaths(deepKey) {
19
+ var result = [];
20
+ var length = deepKey.length;
21
+ if (length === 0) {
22
+ return result;
23
+ }
24
+ var index = 0;
25
+ var key = "";
26
+ var quoteChar = "";
27
+ var bracket = false;
28
+ // Leading dot
29
+ if (deepKey.charCodeAt(0) === 46) {
30
+ result.push("");
31
+ index++;
32
+ }
33
+ while (index < length) {
34
+ var _char = deepKey[index];
35
+ if (quoteChar) {
36
+ if (_char === "\\" && index + 1 < length) {
37
+ // Escape character
38
+ index++;
39
+ key += deepKey[index];
40
+ } else if (_char === quoteChar) {
41
+ // End of quote
42
+ quoteChar = "";
43
+ } else {
44
+ key += _char;
45
+ }
46
+ } else if (bracket) {
47
+ if (_char === '"' || _char === "'") {
48
+ // Start of quoted string inside brackets
49
+ quoteChar = _char;
50
+ } else if (_char === "]") {
51
+ // End of bracketed segment
52
+ bracket = false;
53
+ result.push(key);
54
+ key = "";
55
+ } else {
56
+ key += _char;
57
+ }
58
+ } else {
59
+ if (_char === "[") {
60
+ // Start of bracketed segment
61
+ bracket = true;
62
+ if (key) {
63
+ result.push(key);
64
+ key = "";
65
+ }
66
+ } else if (_char === ".") {
67
+ if (key) {
68
+ result.push(key);
69
+ key = "";
70
+ }
71
+ } else {
72
+ key += _char;
73
+ }
74
+ }
75
+ index++;
76
+ }
77
+ if (key) {
78
+ result.push(key);
79
+ }
80
+ return result;
81
+ }
82
+
83
+ export { toPaths };
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
+ var isKey = require('../is/is-key.cjs');
5
+ var isObject = require('../is/is-object.cjs');
6
+ var isUndefined = require('../is/is-undefined.cjs');
7
+ var isVoid = require('../is/is-void.cjs');
8
+ var isIndex = require('./is-index.cjs');
9
+ var toKey = require('./to-key.cjs');
10
+ var toPaths = require('./to-paths.cjs');
11
+
12
+ /**
13
+ * Updates the value at the specified path of the given object using an updater function.
14
+ * If any part of the path does not exist, it will be created.
15
+ *
16
+ * @template T - The type of the object.
17
+ * @param {T} target - The object to modify.
18
+ * @param {PropertyKey | PropertyKey[]} path - The path of the property to update.
19
+ * @param {(value: unknown) => unknown} updater - The function to produce the updated value.
20
+ * @returns {T} - The modified object.
21
+ */
22
+ function update(target, path, updater) {
23
+ if (isVoid.isVoid(target)) {
24
+ return target;
25
+ }
26
+ var _paths = isKey.isKey(path, target) ? [path] : Array.isArray(path) ? path : typeof path === "string" ? toPaths.toPaths(path) : [path];
27
+ var current = target;
28
+ for (var i = 0; i < _paths.length && current != null; i++) {
29
+ var key = toKey.toKey(_paths[i]);
30
+ var _newValue = void 0;
31
+ if (i === _paths.length - 1) {
32
+ // @ts-expect-error get value of key
33
+ _newValue = updater(current[key]);
34
+ } else {
35
+ // @ts-expect-error get value of key
36
+ var _value = current[key];
37
+ _newValue = !isUndefined.isUndefined(_value) ? _value : isObject.isObject(_value) ? _value : isIndex.isIndex(_paths[i + 1]) ? [] : {};
38
+ }
39
+ Object.assign(current, _defineProperty({}, key, _newValue));
40
+ // @ts-expect-error get value of key
41
+ current = current[key];
42
+ }
43
+ return target;
44
+ }
45
+
46
+ exports.update = update;
@@ -0,0 +1,44 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import { isKey } from '../is/is-key.mjs';
3
+ import { isObject } from '../is/is-object.mjs';
4
+ import { isUndefined } from '../is/is-undefined.mjs';
5
+ import { isVoid } from '../is/is-void.mjs';
6
+ import { isIndex } from './is-index.mjs';
7
+ import { toKey } from './to-key.mjs';
8
+ import { toPaths } from './to-paths.mjs';
9
+
10
+ /**
11
+ * Updates the value at the specified path of the given object using an updater function.
12
+ * If any part of the path does not exist, it will be created.
13
+ *
14
+ * @template T - The type of the object.
15
+ * @param {T} target - The object to modify.
16
+ * @param {PropertyKey | PropertyKey[]} path - The path of the property to update.
17
+ * @param {(value: unknown) => unknown} updater - The function to produce the updated value.
18
+ * @returns {T} - The modified object.
19
+ */
20
+ function update(target, path, updater) {
21
+ if (isVoid(target)) {
22
+ return target;
23
+ }
24
+ var _paths = isKey(path, target) ? [path] : Array.isArray(path) ? path : typeof path === "string" ? toPaths(path) : [path];
25
+ var current = target;
26
+ for (var i = 0; i < _paths.length && current != null; i++) {
27
+ var key = toKey(_paths[i]);
28
+ var _newValue = void 0;
29
+ if (i === _paths.length - 1) {
30
+ // @ts-expect-error get value of key
31
+ _newValue = updater(current[key]);
32
+ } else {
33
+ // @ts-expect-error get value of key
34
+ var _value = current[key];
35
+ _newValue = !isUndefined(_value) ? _value : isObject(_value) ? _value : isIndex(_paths[i + 1]) ? [] : {};
36
+ }
37
+ Object.assign(current, _defineProperty({}, key, _newValue));
38
+ // @ts-expect-error get value of key
39
+ current = current[key];
40
+ }
41
+ return target;
42
+ }
43
+
44
+ export { update };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "2.0.4",
3
+ "version": "2.0.6-beta.0",
4
4
  "description": "react utils collection",
5
5
  "exports": {
6
6
  ".": {
@@ -19,31 +19,38 @@
19
19
  },
20
20
  "./types": "./dist/types/index.d.ts"
21
21
  },
22
+ "scripts": {
23
+ "dev": "rollup -c -w",
24
+ "build": "rollup -c",
25
+ "clean:build": "rm -rf dist",
26
+ "test": "jest",
27
+ "test:coverage": "jest --coverage"
28
+ },
22
29
  "dependencies": {
23
- "@babel/runtime": "^7.27.0",
30
+ "@babel/runtime": "^7.27.1",
24
31
  "react-is": "^19.1.0",
25
32
  "rxjs": "^7.8.2"
26
33
  },
27
34
  "devDependencies": {
28
- "@babel/core": "^7.26.10",
29
- "@babel/plugin-transform-runtime": "^7.26.10",
30
- "@babel/preset-env": "^7.26.9",
31
- "@babel/preset-react": "^7.26.3",
32
- "@babel/preset-typescript": "^7.27.0",
35
+ "@babel/core": "^7.27.1",
36
+ "@babel/plugin-transform-runtime": "^7.27.1",
37
+ "@babel/preset-env": "^7.27.2",
38
+ "@babel/preset-react": "^7.27.1",
39
+ "@babel/preset-typescript": "^7.27.1",
33
40
  "@jest/globals": "^29.7.0",
34
41
  "@rollup/plugin-babel": "^6.0.4",
35
42
  "@rollup/plugin-node-resolve": "^16.0.1",
36
43
  "@rollup/plugin-typescript": "^12.1.2",
37
44
  "@testing-library/react": "^16.3.0",
38
45
  "@types/babel__core": "^7.20.5",
39
- "@types/react": "^19.1.2",
40
- "@types/react-dom": "^19.1.2",
46
+ "@types/react": "^19.1.3",
47
+ "@types/react-dom": "^19.1.3",
41
48
  "@types/react-is": "^19.0.0",
42
49
  "jest": "^29.7.0",
43
50
  "jest-environment-jsdom": "^29.7.0",
44
51
  "react": "^19.1.0",
45
52
  "react-dom": "^19.1.0",
46
- "rollup": "^4.40.0",
53
+ "rollup": "^4.40.2",
47
54
  "typescript": "5.8.3"
48
55
  },
49
56
  "peerDependencies": {
@@ -63,12 +70,5 @@
63
70
  "access": "public",
64
71
  "registry": "https://registry.npmjs.org/"
65
72
  },
66
- "homepage": "https://aisz.dev/hooks",
67
- "scripts": {
68
- "dev": "rollup -c -w",
69
- "build": "rollup -c",
70
- "clean:build": "rm -rf dist",
71
- "test": "jest",
72
- "test:coverage": "jest --coverage"
73
- }
74
- }
73
+ "homepage": "https://aisz.dev/hooks"
74
+ }