@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: useEvent.useEvent(function () {
18
- return _debouncer.callback.apply(_debouncer, arguments);
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: useEvent(function () {
16
- return _debouncer.callback.apply(_debouncer, arguments);
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 _useMemo = react.useMemo(function () {
11
- return isFunction.isFunction(throttler) ? {
12
- callback: throttler,
13
- pipe: null
14
- } : throttler;
15
- }, [throttler]),
16
- callback = _useMemo.callback,
17
- pipe = _useMemo.pipe;
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: useEvent.useEvent(function () {
20
- return callback.apply(void 0, arguments);
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 _useMemo = useMemo(function () {
9
- return isFunction(throttler) ? {
10
- callback: throttler,
11
- pipe: null
12
- } : throttler;
13
- }, [throttler]),
14
- callback = _useMemo.callback,
15
- pipe = _useMemo.pipe;
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: useEvent(function () {
18
- return callback.apply(void 0, arguments);
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "react utils collection",
5
5
  "exports": {
6
6
  ".": {