Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ahooks

Package Overview
Dependencies
Maintainers
0
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks - npm Package Compare versions

Comparing version 3.8.0 to 3.8.1

10

dist/ahooks.js.LICENSE.txt
/*!
* JavaScript Cookie v2.2.1
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
/*!
* screenfull

@@ -14,1 +6,3 @@ * v5.2.0 - 2021-11-03

*/
/*! js-cookie v3.0.5 | MIT */

2

es/createDeepCompareEffect/index.js

@@ -8,7 +8,7 @@ import { useRef } from 'react';

if (deps === undefined || !depsEqual(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;
hook(effect, [signalRef.current]);
};
};

@@ -53,3 +53,3 @@ import { createUpdateEffect } from './createUpdateEffect';

import useResetState from './useResetState';
import { configResponsive, useResponsive } from './useResponsive';
import useResponsive, { configResponsive } from './useResponsive';
import useSafeState from './useSafeState';

@@ -56,0 +56,0 @@ import useScroll from './useScroll';

@@ -53,3 +53,3 @@ import { createUpdateEffect } from './createUpdateEffect';

import useResetState from './useResetState';
import { configResponsive, useResponsive } from './useResponsive';
import useResponsive, { configResponsive } from './useResponsive';
import useSafeState from './useSafeState';

@@ -56,0 +56,0 @@ import useScroll from './useScroll';

@@ -21,3 +21,3 @@ import { __read, __spreadArray } from "tslib";

var value = props[valuePropName];
var isControlled = props.hasOwnProperty(valuePropName);
var isControlled = Object.prototype.hasOwnProperty.call(props, valuePropName);
var initialValue = useMemo(function () {

@@ -27,3 +27,3 @@ if (isControlled) {

}
if (props.hasOwnProperty(defaultValuePropName)) {
if (Object.prototype.hasOwnProperty.call(props, defaultValuePropName)) {
return props[defaultValuePropName];

@@ -30,0 +30,0 @@ }

@@ -40,3 +40,3 @@ import { useRef } from 'react';

function getClientPosition(event) {
if (event instanceof TouchEvent) {
if ('TouchEvent' in window && event instanceof TouchEvent) {
return {

@@ -43,0 +43,0 @@ clientX: event.touches[0].clientX,

@@ -19,3 +19,5 @@ import { __assign, __read, __rest, __spreadArray } from "tslib";

manual = _a === void 0 ? false : _a,
rest = __rest(options, ["manual"]);
_b = options.ready,
ready = _b === void 0 ? true : _b,
rest = __rest(options, ["manual", "ready"]);
if (isDev) {

@@ -27,3 +29,4 @@ if (options.defaultParams && !Array.isArray(options.defaultParams)) {

var fetchOptions = __assign({
manual: manual
manual: manual,
ready: ready
}, rest);

@@ -45,3 +48,3 @@ var serviceRef = useLatest(service);

useMount(function () {
if (!manual) {
if (!manual && ready) {
// useCachePlugin can set fetchInstance.state.params from cache when init

@@ -48,0 +51,0 @@ var params = fetchInstance.state.params || options.defaultParams || [];

import { __read } from "tslib";
import { useState } from 'react';
import { useRef, useState } from 'react';
import { isFunction } from '../utils';
import useMemoizedFn from '../useMemoizedFn';
import useCreation from '../useCreation';
var useResetState = function (initialState) {
var _a = __read(useState(initialState), 2),
var initialStateRef = useRef(initialState);
var initialStateMemo = useCreation(function () {
return isFunction(initialStateRef.current) ? initialStateRef.current() : initialStateRef.current;
}, []);
var _a = __read(useState(initialStateMemo), 2),
state = _a[0],
setState = _a[1];
var resetState = useMemoizedFn(function () {
setState(initialState);
setState(initialStateMemo);
});

@@ -11,0 +17,0 @@ return [state, setState, resetState];

type ResponsiveConfig = Record<string, number>;
type ResponsiveInfo = Record<string, boolean>;
export declare function configResponsive(config: ResponsiveConfig): void;
export declare function useResponsive(): ResponsiveInfo;
export {};
declare function useResponsive(): ResponsiveInfo;
export default useResponsive;

@@ -68,3 +68,3 @@ import { __read, __values } from "tslib";

}
export function useResponsive() {
function useResponsive() {
if (isBrowser && !listening) {

@@ -99,2 +99,3 @@ info = {};

return state;
}
}
export default useResponsive;

@@ -30,2 +30,5 @@ import { __read } from "tslib";

var keyToItemMap = new Map();
if (!Array.isArray(selected)) {
return keyToItemMap;
}
selected.forEach(function (item) {

@@ -32,0 +35,0 @@ keyToItemMap.set(getKey(item), item);

@@ -8,7 +8,7 @@ import { useRef } from 'react';

if (!depsEqual(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;
useEffectWithTarget(effect, [signalRef.current], target);
};
export default useDeepCompareEffectWithTarget;

@@ -14,5 +14,5 @@ "use strict";

if (deps === undefined || !(0, _depsEqual.depsEqual)(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;
hook(effect, [signalRef.current]);

@@ -19,0 +19,0 @@ };

@@ -53,3 +53,3 @@ import { createUpdateEffect } from './createUpdateEffect';

import useResetState from './useResetState';
import { configResponsive, useResponsive } from './useResponsive';
import useResponsive, { configResponsive } from './useResponsive';
import useSafeState from './useSafeState';

@@ -56,0 +56,0 @@ import useScroll from './useScroll';

@@ -341,3 +341,3 @@ "use strict";

get: function get() {
return _useResponsive.useResponsive;
return _useResponsive["default"];
}

@@ -535,3 +535,3 @@ });

var _useResetState = _interopRequireDefault(require("./useResetState"));
var _useResponsive = require("./useResponsive");
var _useResponsive = _interopRequireWildcard(require("./useResponsive"));
var _useSafeState = _interopRequireDefault(require("./useSafeState"));

@@ -538,0 +538,0 @@ var _useScroll = _interopRequireDefault(require("./useScroll"));

@@ -28,3 +28,3 @@ "use strict";

var value = props[valuePropName];
var isControlled = props.hasOwnProperty(valuePropName);
var isControlled = Object.prototype.hasOwnProperty.call(props, valuePropName);
var initialValue = (0, _react.useMemo)(function () {

@@ -34,3 +34,3 @@ if (isControlled) {

}
if (props.hasOwnProperty(defaultValuePropName)) {
if (Object.prototype.hasOwnProperty.call(props, defaultValuePropName)) {
return props[defaultValuePropName];

@@ -37,0 +37,0 @@ }

@@ -47,3 +47,3 @@ "use strict";

function getClientPosition(event) {
if (event instanceof TouchEvent) {
if ('TouchEvent' in window && event instanceof TouchEvent) {
return {

@@ -50,0 +50,0 @@ clientX: event.touches[0].clientX,

@@ -27,3 +27,5 @@ "use strict";

manual = _a === void 0 ? false : _a,
rest = (0, _tslib.__rest)(options, ["manual"]);
_b = options.ready,
ready = _b === void 0 ? true : _b,
rest = (0, _tslib.__rest)(options, ["manual", "ready"]);
if (_isDev["default"]) {

@@ -35,3 +37,4 @@ if (options.defaultParams && !Array.isArray(options.defaultParams)) {

var fetchOptions = (0, _tslib.__assign)({
manual: manual
manual: manual,
ready: ready
}, rest);

@@ -53,3 +56,3 @@ var serviceRef = (0, _useLatest["default"])(service);

(0, _useMount["default"])(function () {
if (!manual) {
if (!manual && ready) {
// useCachePlugin can set fetchInstance.state.params from cache when init

@@ -56,0 +59,0 @@ var params = fetchInstance.state.params || options.defaultParams || [];

@@ -10,9 +10,15 @@ "use strict";

var _react = require("react");
var _utils = require("../utils");
var _useMemoizedFn = _interopRequireDefault(require("../useMemoizedFn"));
var _useCreation = _interopRequireDefault(require("../useCreation"));
var useResetState = function useResetState(initialState) {
var _a = (0, _tslib.__read)((0, _react.useState)(initialState), 2),
var initialStateRef = (0, _react.useRef)(initialState);
var initialStateMemo = (0, _useCreation["default"])(function () {
return (0, _utils.isFunction)(initialStateRef.current) ? initialStateRef.current() : initialStateRef.current;
}, []);
var _a = (0, _tslib.__read)((0, _react.useState)(initialStateMemo), 2),
state = _a[0],
setState = _a[1];
var resetState = (0, _useMemoizedFn["default"])(function () {
setState(initialState);
setState(initialStateMemo);
});

@@ -19,0 +25,0 @@ return [state, setState, resetState];

type ResponsiveConfig = Record<string, number>;
type ResponsiveInfo = Record<string, boolean>;
export declare function configResponsive(config: ResponsiveConfig): void;
export declare function useResponsive(): ResponsiveInfo;
export {};
declare function useResponsive(): ResponsiveInfo;
export default useResponsive;

@@ -8,3 +8,3 @@ "use strict";

exports.configResponsive = configResponsive;
exports.useResponsive = useResponsive;
exports["default"] = void 0;
var _tslib = require("tslib");

@@ -107,2 +107,4 @@ var _react = require("react");

return state;
}
}
var _default = useResponsive;
exports["default"] = _default;

@@ -37,2 +37,5 @@ "use strict";

var keyToItemMap = new Map();
if (!Array.isArray(selected)) {
return keyToItemMap;
}
selected.forEach(function (item) {

@@ -39,0 +42,0 @@ keyToItemMap.set(getKey(item), item);

@@ -15,5 +15,5 @@ "use strict";

if (!(0, _depsEqual.depsEqual)(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;
(0, _useEffectWithTarget["default"])(effect, [signalRef.current], target);

@@ -20,0 +20,0 @@ };

{
"name": "ahooks",
"version": "3.8.0",
"version": "3.8.1",
"description": "react hooks library",

@@ -39,3 +39,3 @@ "keywords": [

"intersection-observer": "^0.12.0",
"js-cookie": "^2.x.x",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",

@@ -53,3 +53,3 @@ "react-fast-compare": "^3.2.2",

"@ant-design/icons": "^5.0.1",
"@types/js-cookie": "^2.x.x",
"@types/js-cookie": "^3.0.6",
"@types/lodash": "^4.14.202",

@@ -56,0 +56,0 @@ "antd": "^5.2.1",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc