Comparing version 3.7.10 to 3.7.11
@@ -23,2 +23,3 @@ import { __assign, __read, __rest, __spreadArray } from "tslib"; | ||
var result = usePagination(service, __assign(__assign({ | ||
ready: ready, | ||
manual: true | ||
@@ -25,0 +26,0 @@ }, rest), { |
@@ -33,9 +33,6 @@ import { __read } from "tslib"; | ||
onEnd = _a.onEnd; | ||
var target = useMemo(function () { | ||
if ('leftTime' in options) { | ||
return isNumber(leftTime) && leftTime > 0 ? Date.now() + leftTime : undefined; | ||
} else { | ||
return targetDate; | ||
} | ||
}, [leftTime, targetDate]); | ||
var memoLeftTime = useMemo(function () { | ||
return isNumber(leftTime) && leftTime > 0 ? Date.now() + leftTime : undefined; | ||
}, [leftTime]); | ||
var target = 'leftTime' in options ? memoLeftTime : targetDate; | ||
var _c = __read(useState(function () { | ||
@@ -42,0 +39,0 @@ return calcLeft(target); |
import { __read } from "tslib"; | ||
import { useState, useRef, useCallback } from 'react'; | ||
import { useState, useCallback } from 'react'; | ||
import useLatest from '../useLatest'; | ||
function useGetState(initialState) { | ||
@@ -7,4 +8,3 @@ var _a = __read(useState(initialState), 2), | ||
setState = _a[1]; | ||
var stateRef = useRef(state); | ||
stateRef.current = state; | ||
var stateRef = useLatest(state); | ||
var getState = useCallback(function () { | ||
@@ -11,0 +11,0 @@ return stateRef.current; |
@@ -48,5 +48,3 @@ import { __assign, __read, __rest, __values } from "tslib"; | ||
els.forEach(function (el) { | ||
if (el) { | ||
observer.observe(el); | ||
} | ||
return observer.observe(el); | ||
}); | ||
@@ -53,0 +51,0 @@ return function () { |
@@ -20,13 +20,14 @@ import { __awaiter, __generator, __read, __spreadArray } from "tslib"; | ||
case 1: | ||
_a.trys.push([1, 3,, 4]); | ||
_a.trys.push([1, 3, 4, 5]); | ||
return [4 /*yield*/, fn.apply(void 0, __spreadArray([], __read(args), false))]; | ||
case 2: | ||
ret = _a.sent(); | ||
lockRef.current = false; | ||
return [2 /*return*/, ret]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
lockRef.current = false; | ||
throw e_1; | ||
case 4: | ||
lockRef.current = false; | ||
return [7 /*endfinally*/]; | ||
case 5: | ||
return [2 /*return*/]; | ||
@@ -33,0 +34,0 @@ } |
@@ -13,3 +13,3 @@ import { useCallback, useEffect, useRef } from 'react'; | ||
} | ||
var start = new Date().getTime(); | ||
var start = Date.now(); | ||
var handle = { | ||
@@ -19,6 +19,6 @@ id: 0 | ||
var loop = function () { | ||
var current = new Date().getTime(); | ||
var current = Date.now(); | ||
if (current - start >= delay) { | ||
callback(); | ||
start = new Date().getTime(); | ||
start = Date.now(); | ||
} | ||
@@ -43,4 +43,11 @@ handle.id = requestAnimationFrame(loop); | ||
var timerRef = useRef(); | ||
var clear = useCallback(function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}, []); | ||
useEffect(function () { | ||
if (!isNumber(delay) || delay < 0) return; | ||
if (!isNumber(delay) || delay < 0) { | ||
return; | ||
} | ||
if (immediate) { | ||
@@ -52,15 +59,6 @@ fnRef.current(); | ||
}, delay); | ||
return function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}; | ||
return clear; | ||
}, [delay]); | ||
var clear = useCallback(function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}, []); | ||
return clear; | ||
} | ||
export default useRafInterval; |
@@ -40,2 +40,7 @@ import { useCallback, useEffect, useRef } from 'react'; | ||
var timerRef = useRef(); | ||
var clear = useCallback(function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}, []); | ||
useEffect(function () { | ||
@@ -46,15 +51,6 @@ if (!isNumber(delay) || delay < 0) return; | ||
}, delay); | ||
return function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}; | ||
return clear; | ||
}, [delay]); | ||
var clear = useCallback(function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}, []); | ||
return clear; | ||
} | ||
export default useRafTimeout; |
@@ -31,3 +31,3 @@ import { useRef } from 'react'; | ||
} | ||
if (els.length !== lastElementRef.current.length || !depsAreSame(els, lastElementRef.current) || !depsAreSame(deps, lastDepsRef.current)) { | ||
if (els.length !== lastElementRef.current.length || !depsAreSame(lastElementRef.current, els) || !depsAreSame(lastDepsRef.current, deps)) { | ||
(_a = unLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(unLoadRef); | ||
@@ -34,0 +34,0 @@ lastElementRef.current = els; |
@@ -1,2 +0,2 @@ | ||
import isEqual from 'lodash/isEqual'; | ||
import isEqual from 'react-fast-compare'; | ||
export var depsEqual = function (aDeps, bDeps) { | ||
@@ -3,0 +3,0 @@ if (aDeps === void 0) { |
@@ -30,2 +30,3 @@ "use strict"; | ||
var result = (0, _usePagination["default"])(service, (0, _tslib.__assign)((0, _tslib.__assign)({ | ||
ready: ready, | ||
manual: true | ||
@@ -32,0 +33,0 @@ }, rest), { |
@@ -40,9 +40,6 @@ "use strict"; | ||
onEnd = _a.onEnd; | ||
var target = (0, _react.useMemo)(function () { | ||
if ('leftTime' in options) { | ||
return (0, _index.isNumber)(leftTime) && leftTime > 0 ? Date.now() + leftTime : undefined; | ||
} else { | ||
return targetDate; | ||
} | ||
}, [leftTime, targetDate]); | ||
var memoLeftTime = (0, _react.useMemo)(function () { | ||
return (0, _index.isNumber)(leftTime) && leftTime > 0 ? Date.now() + leftTime : undefined; | ||
}, [leftTime]); | ||
var target = 'leftTime' in options ? memoLeftTime : targetDate; | ||
var _c = (0, _tslib.__read)((0, _react.useState)(function () { | ||
@@ -49,0 +46,0 @@ return calcLeft(target); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +10,3 @@ value: true | ||
var _react = require("react"); | ||
var _useLatest = _interopRequireDefault(require("../useLatest")); | ||
function useGetState(initialState) { | ||
@@ -14,4 +16,3 @@ var _a = (0, _tslib.__read)((0, _react.useState)(initialState), 2), | ||
setState = _a[1]; | ||
var stateRef = (0, _react.useRef)(state); | ||
stateRef.current = state; | ||
var stateRef = (0, _useLatest["default"])(state); | ||
var getState = (0, _react.useCallback)(function () { | ||
@@ -18,0 +19,0 @@ return stateRef.current; |
@@ -55,5 +55,3 @@ "use strict"; | ||
els.forEach(function (el) { | ||
if (el) { | ||
observer.observe(el); | ||
} | ||
return observer.observe(el); | ||
}); | ||
@@ -60,0 +58,0 @@ return function () { |
@@ -26,13 +26,14 @@ "use strict"; | ||
case 1: | ||
_a.trys.push([1, 3,, 4]); | ||
_a.trys.push([1, 3, 4, 5]); | ||
return [4 /*yield*/, fn.apply(void 0, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(args), false))]; | ||
case 2: | ||
ret = _a.sent(); | ||
lockRef.current = false; | ||
return [2 /*return*/, ret]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
lockRef.current = false; | ||
throw e_1; | ||
case 4: | ||
lockRef.current = false; | ||
return [7 /*endfinally*/]; | ||
case 5: | ||
return [2 /*return*/]; | ||
@@ -39,0 +40,0 @@ } |
@@ -21,3 +21,3 @@ "use strict"; | ||
} | ||
var start = new Date().getTime(); | ||
var start = Date.now(); | ||
var handle = { | ||
@@ -27,6 +27,6 @@ id: 0 | ||
var loop = function loop() { | ||
var current = new Date().getTime(); | ||
var current = Date.now(); | ||
if (current - start >= delay) { | ||
callback(); | ||
start = new Date().getTime(); | ||
start = Date.now(); | ||
} | ||
@@ -51,4 +51,11 @@ handle.id = requestAnimationFrame(loop); | ||
var timerRef = (0, _react.useRef)(); | ||
var clear = (0, _react.useCallback)(function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}, []); | ||
(0, _react.useEffect)(function () { | ||
if (!(0, _utils.isNumber)(delay) || delay < 0) return; | ||
if (!(0, _utils.isNumber)(delay) || delay < 0) { | ||
return; | ||
} | ||
if (immediate) { | ||
@@ -60,13 +67,4 @@ fnRef.current(); | ||
}, delay); | ||
return function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}; | ||
return clear; | ||
}, [delay]); | ||
var clear = (0, _react.useCallback)(function () { | ||
if (timerRef.current) { | ||
clearRafInterval(timerRef.current); | ||
} | ||
}, []); | ||
return clear; | ||
@@ -73,0 +71,0 @@ } |
@@ -48,2 +48,7 @@ "use strict"; | ||
var timerRef = (0, _react.useRef)(); | ||
var clear = (0, _react.useCallback)(function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}, []); | ||
(0, _react.useEffect)(function () { | ||
@@ -54,13 +59,4 @@ if (!(0, _utils.isNumber)(delay) || delay < 0) return; | ||
}, delay); | ||
return function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}; | ||
return clear; | ||
}, [delay]); | ||
var clear = (0, _react.useCallback)(function () { | ||
if (timerRef.current) { | ||
clearRafTimeout(timerRef.current); | ||
} | ||
}, []); | ||
return clear; | ||
@@ -67,0 +63,0 @@ } |
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
if (els.length !== lastElementRef.current.length || !(0, _depsAreSame["default"])(els, lastElementRef.current) || !(0, _depsAreSame["default"])(deps, lastDepsRef.current)) { | ||
if (els.length !== lastElementRef.current.length || !(0, _depsAreSame["default"])(lastElementRef.current, els) || !(0, _depsAreSame["default"])(lastDepsRef.current, deps)) { | ||
(_a = unLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(unLoadRef); | ||
@@ -41,0 +41,0 @@ lastElementRef.current = els; |
@@ -8,3 +8,3 @@ "use strict"; | ||
exports.depsEqual = void 0; | ||
var _isEqual = _interopRequireDefault(require("lodash/isEqual")); | ||
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare")); | ||
var depsEqual = function depsEqual(aDeps, bDeps) { | ||
@@ -17,4 +17,4 @@ if (aDeps === void 0) { | ||
} | ||
return (0, _isEqual["default"])(aDeps, bDeps); | ||
return (0, _reactFastCompare["default"])(aDeps, bDeps); | ||
}; | ||
exports.depsEqual = depsEqual; |
{ | ||
"name": "ahooks", | ||
"version": "3.7.10", | ||
"version": "3.7.11", | ||
"description": "react hooks library", | ||
@@ -41,2 +41,3 @@ "keywords": [ | ||
"lodash": "^4.17.21", | ||
"react-fast-compare": "^3.2.2", | ||
"resize-observer-polyfill": "^1.5.1", | ||
@@ -43,0 +44,0 @@ "screenfull": "^5.0.0", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3
577650
10
13614
+ Addedreact-fast-compare@^3.2.2
+ Addedreact-fast-compare@3.2.2(transitive)