@aiszlab/relax 1.2.57 → 1.2.59
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/_virtual/_rollupPluginBabelHelpers.js +138 -0
- package/dist/dom/contains.d.ts +1 -0
- package/dist/dom/contains.js +20 -0
- package/dist/dom/index.d.ts +3 -0
- package/dist/dom/index.js +2 -0
- package/dist/dom/scroll-to.d.ts +19 -0
- package/dist/dom/scroll-to.js +69 -0
- package/dist/hooks/use-boolean.d.ts +19 -0
- package/dist/hooks/use-boolean.js +34 -0
- package/dist/hooks/use-controlled-state.d.ts +17 -0
- package/dist/hooks/use-controlled-state.js +40 -0
- package/dist/hooks/use-counter.d.ts +33 -0
- package/dist/hooks/use-counter.js +59 -0
- package/dist/hooks/use-debounce-callback.d.ts +18 -0
- package/dist/hooks/use-debounce-callback.js +81 -0
- package/dist/hooks/use-default.d.ts +8 -0
- package/dist/hooks/use-default.js +14 -0
- package/dist/hooks/use-device-pixel-ratio.d.ts +6 -0
- package/dist/hooks/use-device-pixel-ratio.js +20 -0
- package/dist/hooks/use-event.d.ts +2 -0
- package/dist/hooks/use-event.js +12 -0
- package/dist/hooks/use-focus.d.ts +15 -0
- package/dist/hooks/use-focus.js +31 -0
- package/dist/hooks/use-force-update.d.ts +7 -0
- package/dist/hooks/use-force-update.js +21 -0
- package/dist/hooks/use-hover.d.ts +8 -0
- package/dist/hooks/use-hover.js +25 -0
- package/dist/hooks/use-identity.d.ts +5 -0
- package/dist/hooks/use-identity.js +20 -0
- package/dist/hooks/use-image-loader.d.ts +12 -0
- package/dist/hooks/use-image-loader.js +54 -0
- package/dist/hooks/use-media-query.d.ts +7 -0
- package/dist/hooks/use-memorable.d.ts +1 -0
- package/dist/hooks/use-memorable.js +14 -0
- package/dist/hooks/use-mount.d.ts +8 -0
- package/dist/hooks/use-mount.js +16 -0
- package/dist/hooks/use-mounted.d.ts +8 -0
- package/dist/hooks/use-mounted.js +16 -0
- package/dist/hooks/use-mutate-observer.d.ts +1 -0
- package/dist/hooks/use-mutate-observer.js +28 -0
- package/dist/hooks/use-raf.d.ts +7 -0
- package/dist/hooks/use-raf.js +26 -0
- package/dist/hooks/use-reactive.d.ts +6 -0
- package/dist/hooks/use-refs.d.ts +5 -0
- package/dist/hooks/use-refs.js +31 -0
- package/dist/hooks/use-scroll-locker.d.ts +5 -0
- package/dist/hooks/use-scroll-locker.js +92 -0
- package/dist/hooks/use-scrollable.d.ts +17 -0
- package/dist/hooks/use-scrollable.js +43 -0
- package/dist/hooks/use-throttle-callback.d.ts +18 -0
- package/dist/hooks/use-throttle-callback.js +83 -0
- package/dist/hooks/use-timeout.d.ts +10 -0
- package/dist/hooks/use-timeout.js +68 -0
- package/dist/hooks/use-togglable.d.ts +48 -0
- package/dist/hooks/use-togglable.js +177 -0
- package/dist/hooks/use-update-effect.d.ts +3 -0
- package/dist/hooks/use-update-effect.js +19 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +52 -0
- package/dist/is/is-array.d.ts +5 -0
- package/dist/is/is-array.js +9 -0
- package/dist/is/is-complex.d.ts +5 -0
- package/dist/is/is-complex.js +11 -0
- package/dist/is/is-dom-usable.d.ts +5 -0
- package/dist/is/is-dom-usable.js +9 -0
- package/dist/is/is-empty.d.ts +7 -0
- package/dist/is/is-empty.js +25 -0
- package/dist/is/is-function.d.ts +5 -0
- package/dist/is/is-function.js +9 -0
- package/dist/is/is-map.d.ts +5 -0
- package/dist/is/is-mobile.d.ts +5 -0
- package/dist/is/is-mobile.js +13 -0
- package/dist/is/is-null.d.ts +5 -0
- package/dist/is/is-null.js +9 -0
- package/dist/is/is-overflow.d.ts +5 -0
- package/dist/is/is-overflow.js +14 -0
- package/dist/is/is-pointer-usable.d.ts +5 -0
- package/dist/is/is-primitive.d.ts +5 -0
- package/dist/is/is-primitive.js +9 -0
- package/dist/is/is-refable.d.ts +5 -0
- package/dist/is/is-refable.js +34 -0
- package/dist/is/is-set.d.ts +5 -0
- package/dist/is/is-set.js +9 -0
- package/dist/is/is-state-getter.d.ts +6 -0
- package/dist/is/is-state-getter.js +9 -0
- package/dist/is/is-style-element.d.ts +5 -0
- package/dist/is/is-style-element.js +9 -0
- package/dist/is/is-thenable.d.ts +5 -0
- package/dist/is/is-thenable.js +9 -0
- package/dist/is/is-undefined.d.ts +5 -0
- package/dist/is/is-undefined.js +9 -0
- package/dist/is/is-void.d.ts +5 -0
- package/dist/is/is-void.js +12 -0
- package/dist/types/first.d.ts +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/last.d.ts +1 -0
- package/dist/types/nullable.d.ts +5 -0
- package/dist/types/partialable.d.ts +5 -0
- package/dist/types/required-in.d.ts +5 -0
- package/dist/types/state.d.ts +10 -0
- package/dist/types/thenable-effect-callback.d.ts +6 -0
- package/dist/types/voidable.d.ts +7 -0
- package/dist/utils/chain.d.ts +2 -0
- package/dist/utils/chain.js +15 -0
- package/dist/utils/clamp.d.ts +9 -0
- package/dist/utils/clamp.js +13 -0
- package/dist/utils/clone.d.ts +6 -0
- package/dist/utils/clone.js +17 -0
- package/dist/utils/debounce.d.ts +23 -0
- package/dist/utils/debounce.js +32 -0
- package/dist/utils/effect.d.ts +7 -0
- package/dist/utils/effect.js +16 -0
- package/dist/utils/exclude.d.ts +10 -0
- package/dist/utils/exclude.js +18 -0
- package/dist/utils/range.d.ts +7 -0
- package/dist/utils/range.js +16 -0
- package/dist/utils/set-style.d.ts +6 -0
- package/dist/utils/set-style.js +21 -0
- package/dist/utils/throttle.d.ts +5 -0
- package/dist/utils/throttle.js +32 -0
- package/dist/utils/to-array.d.ts +18 -0
- package/dist/utils/to-array.js +25 -0
- package/dist/utils/to-form-data.d.ts +5 -0
- package/dist/utils/to-form-data.js +27 -0
- package/dist/utils/to-function.d.ts +1 -0
- package/dist/utils/to-function.js +13 -0
- package/dist/utils/toggle.d.ts +8 -0
- package/dist/utils/toggle.js +30 -0
- package/dist/utils/unique.d.ts +10 -0
- package/dist/utils/unique.js +16 -0
- package/dist/utils/waitable.d.ts +36 -0
- package/dist/utils/waitable.js +90 -0
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* unique
|
|
4
|
+
*/
|
|
5
|
+
var unique = function unique(value) {
|
|
6
|
+
return Array.from(new Set(value));
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* unique by
|
|
11
|
+
*/
|
|
12
|
+
var uniqueBy = function uniqueBy(value, callback) {
|
|
13
|
+
return Array.from(new Set(Array.from(value).map(callback)));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { unique, uniqueBy };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type MonoTypeOperatorFunction } from "rxjs";
|
|
2
|
+
interface Props<T extends Array<unknown> = Array<unknown>, R extends Array<unknown> = T> {
|
|
3
|
+
callback: (...args: T) => unknown;
|
|
4
|
+
pipe: (...args: R) => T | Promise<T>;
|
|
5
|
+
timer: MonoTypeOperatorFunction<R>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* waitable instance
|
|
10
|
+
* for debounce...
|
|
11
|
+
*/
|
|
12
|
+
export declare class Waitable<T extends Array<unknown>, R extends Array<unknown> = T> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(props: Props<T, R>);
|
|
15
|
+
/**
|
|
16
|
+
* @description
|
|
17
|
+
* flush
|
|
18
|
+
* complete all handlers
|
|
19
|
+
* in relax, we will create a new observable for next debounce/throttle handler
|
|
20
|
+
* so it will make some async problems, pls attention
|
|
21
|
+
*/
|
|
22
|
+
flush(): void;
|
|
23
|
+
/**
|
|
24
|
+
* @description
|
|
25
|
+
* abort
|
|
26
|
+
* cancel all handlers
|
|
27
|
+
* in relax, we will create a new observable for next debounce/throttle handler
|
|
28
|
+
*/
|
|
29
|
+
abort(): void;
|
|
30
|
+
/**
|
|
31
|
+
* @description
|
|
32
|
+
* trigger value
|
|
33
|
+
*/
|
|
34
|
+
next(...args: R): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createClass as _createClass, classPrivateFieldGet2 as _classPrivateFieldGet2, assertClassBrand as _assertClassBrand, classCallCheck as _classCallCheck, classPrivateMethodInitSpec as _classPrivateMethodInitSpec, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldSet2 as _classPrivateFieldSet2, toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { Observable, switchMap, from, of } from 'rxjs';
|
|
3
|
+
import { isThenable } from '../is/is-thenable.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* waitable instance
|
|
8
|
+
* for debounce...
|
|
9
|
+
*/
|
|
10
|
+
var _cook$ = /*#__PURE__*/new WeakMap();
|
|
11
|
+
var _waiter$ = /*#__PURE__*/new WeakMap();
|
|
12
|
+
var _timer = /*#__PURE__*/new WeakMap();
|
|
13
|
+
var _pipe = /*#__PURE__*/new WeakMap();
|
|
14
|
+
var _callback = /*#__PURE__*/new WeakMap();
|
|
15
|
+
var _Waitable_brand = /*#__PURE__*/new WeakSet();
|
|
16
|
+
var Waitable = /*#__PURE__*/function () {
|
|
17
|
+
function Waitable(props) {
|
|
18
|
+
_classCallCheck(this, Waitable);
|
|
19
|
+
_classPrivateMethodInitSpec(this, _Waitable_brand);
|
|
20
|
+
_classPrivateFieldInitSpec(this, _cook$, void 0);
|
|
21
|
+
_classPrivateFieldInitSpec(this, _waiter$, void 0);
|
|
22
|
+
_classPrivateFieldInitSpec(this, _timer, void 0);
|
|
23
|
+
_classPrivateFieldInitSpec(this, _pipe, void 0);
|
|
24
|
+
_classPrivateFieldInitSpec(this, _callback, void 0);
|
|
25
|
+
_classPrivateFieldSet2(_cook$, this, null);
|
|
26
|
+
_classPrivateFieldSet2(_waiter$, this, null);
|
|
27
|
+
_classPrivateFieldSet2(_pipe, this, props.pipe);
|
|
28
|
+
_classPrivateFieldSet2(_timer, this, props.timer);
|
|
29
|
+
_classPrivateFieldSet2(_callback, this, props.callback);
|
|
30
|
+
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
31
|
+
}
|
|
32
|
+
return _createClass(Waitable, [{
|
|
33
|
+
key: "flush",
|
|
34
|
+
value:
|
|
35
|
+
/**
|
|
36
|
+
* @description
|
|
37
|
+
* flush
|
|
38
|
+
* complete all handlers
|
|
39
|
+
* in relax, we will create a new observable for next debounce/throttle handler
|
|
40
|
+
* so it will make some async problems, pls attention
|
|
41
|
+
*/
|
|
42
|
+
function flush() {
|
|
43
|
+
var _classPrivateFieldGet2$1;
|
|
44
|
+
(_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_waiter$, this)) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1.complete();
|
|
45
|
+
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @description
|
|
49
|
+
* abort
|
|
50
|
+
* cancel all handlers
|
|
51
|
+
* in relax, we will create a new observable for next debounce/throttle handler
|
|
52
|
+
*/
|
|
53
|
+
}, {
|
|
54
|
+
key: "abort",
|
|
55
|
+
value: function abort() {
|
|
56
|
+
var _classPrivateFieldGet3, _classPrivateFieldGet4;
|
|
57
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet2(_cook$, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.unsubscribe();
|
|
58
|
+
(_classPrivateFieldGet4 = _classPrivateFieldGet2(_waiter$, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.error();
|
|
59
|
+
_assertClassBrand(_Waitable_brand, this, _use).call(this);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @description
|
|
63
|
+
* trigger value
|
|
64
|
+
*/
|
|
65
|
+
}, {
|
|
66
|
+
key: "next",
|
|
67
|
+
value: function next() {
|
|
68
|
+
var _classPrivateFieldGet5;
|
|
69
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
70
|
+
args[_key] = arguments[_key];
|
|
71
|
+
}
|
|
72
|
+
(_classPrivateFieldGet5 = _classPrivateFieldGet2(_waiter$, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.next(args);
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
}();
|
|
76
|
+
function _use() {
|
|
77
|
+
var _this = this;
|
|
78
|
+
_classPrivateFieldSet2(_cook$, this, new Observable(function (subscriber) {
|
|
79
|
+
_classPrivateFieldSet2(_waiter$, _this, subscriber);
|
|
80
|
+
}).pipe(_classPrivateFieldGet2(_timer, this), switchMap(function (args) {
|
|
81
|
+
var _classPrivateFieldGet6;
|
|
82
|
+
var piped = (_classPrivateFieldGet6 = _classPrivateFieldGet2(_pipe, _this)).call.apply(_classPrivateFieldGet6, [_this].concat(_toConsumableArray(args)));
|
|
83
|
+
return isThenable(piped) ? from(piped) : of(piped);
|
|
84
|
+
})).subscribe(function (args) {
|
|
85
|
+
var _classPrivateFieldGet7;
|
|
86
|
+
(_classPrivateFieldGet7 = _classPrivateFieldGet2(_callback, _this)) === null || _classPrivateFieldGet7 === void 0 || _classPrivateFieldGet7.call.apply(_classPrivateFieldGet7, [_this].concat(_toConsumableArray(args)));
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { Waitable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiszlab/relax",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.59",
|
|
4
4
|
"description": "react utils collection",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dev": "rollup -c -w",
|
|
19
19
|
"build": "rollup -c",
|
|
20
20
|
"clean:build": "rm -rf dist",
|
|
21
|
-
"
|
|
21
|
+
"prepublishOnly": "npm run clean:build && npm run build",
|
|
22
22
|
"test": "jest"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|