@aiszlab/relax 1.4.3 → 1.4.4
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
3
4
|
var react = require('react');
|
|
4
5
|
var debounce = require('../utils/debounce.cjs');
|
|
5
6
|
var useEvent = require('./use-event.cjs');
|
|
@@ -13,17 +14,22 @@ var useDebouncer = function useDebouncer(debouncer) {
|
|
|
13
14
|
pipe: null
|
|
14
15
|
} : debouncer;
|
|
15
16
|
}, [debouncer]);
|
|
17
|
+
var callback = useEvent.useEvent(function (piped) {
|
|
18
|
+
if (_debouncer.pipe) {
|
|
19
|
+
return _debouncer.callback(piped);
|
|
20
|
+
}
|
|
21
|
+
return _debouncer.callback.apply(_debouncer, _toConsumableArray(piped));
|
|
22
|
+
});
|
|
23
|
+
var pipe = useEvent.useEvent(function () {
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
if (!_debouncer.pipe) return args;
|
|
28
|
+
return _debouncer.pipe.apply(_debouncer, args);
|
|
29
|
+
});
|
|
16
30
|
return {
|
|
17
|
-
callback:
|
|
18
|
-
|
|
19
|
-
}),
|
|
20
|
-
pipe: useEvent.useEvent(function () {
|
|
21
|
-
var _debouncer$pipe, _debouncer$pipe2;
|
|
22
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
-
args[_key] = arguments[_key];
|
|
24
|
-
}
|
|
25
|
-
return (_debouncer$pipe = (_debouncer$pipe2 = _debouncer.pipe) === null || _debouncer$pipe2 === void 0 ? void 0 : _debouncer$pipe2.call.apply(_debouncer$pipe2, [_debouncer].concat(args))) !== null && _debouncer$pipe !== void 0 ? _debouncer$pipe : args;
|
|
26
|
-
})
|
|
31
|
+
callback: callback,
|
|
32
|
+
pipe: pipe
|
|
27
33
|
};
|
|
28
34
|
};
|
|
29
35
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
1
2
|
import { useRef, useEffect, useMemo } from 'react';
|
|
2
3
|
import { debounce } from '../utils/debounce.mjs';
|
|
3
4
|
import { useEvent } from './use-event.mjs';
|
|
@@ -11,17 +12,22 @@ var useDebouncer = function useDebouncer(debouncer) {
|
|
|
11
12
|
pipe: null
|
|
12
13
|
} : debouncer;
|
|
13
14
|
}, [debouncer]);
|
|
15
|
+
var callback = useEvent(function (piped) {
|
|
16
|
+
if (_debouncer.pipe) {
|
|
17
|
+
return _debouncer.callback(piped);
|
|
18
|
+
}
|
|
19
|
+
return _debouncer.callback.apply(_debouncer, _toConsumableArray(piped));
|
|
20
|
+
});
|
|
21
|
+
var pipe = useEvent(function () {
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
if (!_debouncer.pipe) return args;
|
|
26
|
+
return _debouncer.pipe.apply(_debouncer, args);
|
|
27
|
+
});
|
|
14
28
|
return {
|
|
15
|
-
callback:
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
pipe: useEvent(function () {
|
|
19
|
-
var _debouncer$pipe, _debouncer$pipe2;
|
|
20
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
-
args[_key] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
return (_debouncer$pipe = (_debouncer$pipe2 = _debouncer.pipe) === null || _debouncer$pipe2 === void 0 ? void 0 : _debouncer$pipe2.call.apply(_debouncer$pipe2, [_debouncer].concat(args))) !== null && _debouncer$pipe !== void 0 ? _debouncer$pipe : args;
|
|
24
|
-
})
|
|
29
|
+
callback: callback,
|
|
30
|
+
pipe: pipe
|
|
25
31
|
};
|
|
26
32
|
};
|
|
27
33
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
3
4
|
var react = require('react');
|
|
4
5
|
var throttle = require('../utils/throttle.cjs');
|
|
5
6
|
var useEvent = require('./use-event.cjs');
|
|
@@ -7,25 +8,28 @@ var isFunction = require('../is/is-function.cjs');
|
|
|
7
8
|
var useDefault = require('./use-default.cjs');
|
|
8
9
|
|
|
9
10
|
var useThrottler = function useThrottler(throttler) {
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
var _throttler = react.useMemo(function () {
|
|
12
|
+
return isFunction.isFunction(throttler) ? {
|
|
13
|
+
callback: throttler,
|
|
14
|
+
pipe: null
|
|
15
|
+
} : throttler;
|
|
16
|
+
}, [throttler]);
|
|
17
|
+
var callback = useEvent.useEvent(function (piped) {
|
|
18
|
+
if (_throttler.pipe) {
|
|
19
|
+
return _throttler.callback(piped);
|
|
20
|
+
}
|
|
21
|
+
return _throttler.callback.apply(_throttler, _toConsumableArray(piped));
|
|
22
|
+
});
|
|
23
|
+
var pipe = useEvent.useEvent(function () {
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
if (!_throttler.pipe) return args;
|
|
28
|
+
return _throttler.pipe.apply(_throttler, args);
|
|
29
|
+
});
|
|
18
30
|
return {
|
|
19
|
-
callback:
|
|
20
|
-
|
|
21
|
-
}),
|
|
22
|
-
pipe: useEvent.useEvent(function () {
|
|
23
|
-
var _pipe;
|
|
24
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
-
args[_key] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
return (_pipe = pipe === null || pipe === void 0 ? void 0 : pipe.apply(void 0, args)) !== null && _pipe !== void 0 ? _pipe : args;
|
|
28
|
-
})
|
|
31
|
+
callback: callback,
|
|
32
|
+
pipe: pipe
|
|
29
33
|
};
|
|
30
34
|
};
|
|
31
35
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
1
2
|
import { useRef, useEffect, useMemo } from 'react';
|
|
2
3
|
import { throttle } from '../utils/throttle.mjs';
|
|
3
4
|
import { useEvent } from './use-event.mjs';
|
|
@@ -5,25 +6,28 @@ import { isFunction } from '../is/is-function.mjs';
|
|
|
5
6
|
import { useDefault } from './use-default.mjs';
|
|
6
7
|
|
|
7
8
|
var useThrottler = function useThrottler(throttler) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
var _throttler = useMemo(function () {
|
|
10
|
+
return isFunction(throttler) ? {
|
|
11
|
+
callback: throttler,
|
|
12
|
+
pipe: null
|
|
13
|
+
} : throttler;
|
|
14
|
+
}, [throttler]);
|
|
15
|
+
var callback = useEvent(function (piped) {
|
|
16
|
+
if (_throttler.pipe) {
|
|
17
|
+
return _throttler.callback(piped);
|
|
18
|
+
}
|
|
19
|
+
return _throttler.callback.apply(_throttler, _toConsumableArray(piped));
|
|
20
|
+
});
|
|
21
|
+
var pipe = useEvent(function () {
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
if (!_throttler.pipe) return args;
|
|
26
|
+
return _throttler.pipe.apply(_throttler, args);
|
|
27
|
+
});
|
|
16
28
|
return {
|
|
17
|
-
callback:
|
|
18
|
-
|
|
19
|
-
}),
|
|
20
|
-
pipe: useEvent(function () {
|
|
21
|
-
var _pipe;
|
|
22
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
-
args[_key] = arguments[_key];
|
|
24
|
-
}
|
|
25
|
-
return (_pipe = pipe === null || pipe === void 0 ? void 0 : pipe.apply(void 0, args)) !== null && _pipe !== void 0 ? _pipe : args;
|
|
26
|
-
})
|
|
29
|
+
callback: callback,
|
|
30
|
+
pipe: pipe
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
33
|
/**
|