New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hookstore

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hookstore - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

LICENSE

7

es/provider.js
import React, { createElement, memo, useContext, useEffect, useMemo, useRef, useDebugValue } from 'react';
import invariant from 'invariant';
import isEqual from 'lodash.isequal'; // import clonedeep from 'lodash.clonedeep';
import invariant from 'invariant'; // import isEqual from 'lodash.isequal';
import { isFunction, isString, checkModels, useForceRender, useIsomorphicLayoutEffect, tryClone } from './utils';
import { isFunction, isString, checkModels, useForceRender, useIsomorphicLayoutEffect, tryClone, shallowEqual } from './utils';
import { actionStatusModel } from './statusModel';

@@ -95,3 +94,3 @@ import { getContext, createContext, deleteContext } from './context';

if (isEqual(newValue, prev.value)) return;
if (shallowEqual(newValue, prev.value)) return;
prev.value = newValue;

@@ -98,0 +97,0 @@ forceRender({});

@@ -0,1 +1,2 @@

import _typeof from "@babel/runtime/helpers/esm/typeof";
import { useReducer, useEffect, useLayoutEffect } from 'react';

@@ -82,4 +83,35 @@ import invariant from 'invariant';

export function tryClone(value) {
if (isPlainObject(value) || Array.isArray(value)) return JSON.parse(JSON.stringify(value));
if (isPlainObject(value)) return JSON.parse(JSON.stringify(value));
if (Array.isArray(value)) return value.slice();
return value;
}
var hasOwn = Object.prototype.hasOwnProperty;
function is(x, y) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y;
} else {
return x !== x && y !== y;
}
} // copy from react-redux
export function shallowEqual(objA, objB) {
if (is(objA, objB)) return true;
if (_typeof(objA) !== 'object' || objA === null || _typeof(objB) !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}

@@ -17,4 +17,2 @@ "use strict";

var _lodash = _interopRequireDefault(require("lodash.isequal"));
var _utils = require("./utils");

@@ -30,3 +28,3 @@

// import clonedeep from 'lodash.clonedeep';
// import isEqual from 'lodash.isequal';
var StoreProvider = (0, _react.memo)(function (_ref) {

@@ -119,3 +117,3 @@ var model = _ref.model,

if ((0, _lodash.default)(newValue, prev.value)) return;
if ((0, _utils.shallowEqual)(newValue, prev.value)) return;
prev.value = newValue;

@@ -122,0 +120,0 @@ forceRender({});

@@ -13,2 +13,3 @@ "use strict";

exports.tryClone = tryClone;
exports.shallowEqual = shallowEqual;
Object.defineProperty(exports, "isPlainObject", {

@@ -22,2 +23,4 @@ enumerable: true,

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _react = require("react");

@@ -120,4 +123,36 @@

function tryClone(value) {
if ((0, _isPlainObject.default)(value) || Array.isArray(value)) return JSON.parse(JSON.stringify(value));
if ((0, _isPlainObject.default)(value)) return JSON.parse(JSON.stringify(value));
if (Array.isArray(value)) return value.slice();
return value;
}
var hasOwn = Object.prototype.hasOwnProperty;
function is(x, y) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y;
} else {
return x !== x && y !== y;
}
} // copy from react-redux
function shallowEqual(objA, objB) {
if (is(objA, objB)) return true;
if ((0, _typeof2.default)(objA) !== 'object' || objA === null || (0, _typeof2.default)(objB) !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
{
"name": "hookstore",
"version": "0.2.2",
"version": "0.2.3",
"description": "React Hook based and lightweight state manage library.",

@@ -28,6 +28,5 @@ "main": "lib/index.js",

"dependencies": {
"@babel/runtime": "^7.0.0",
"@babel/runtime": "^7.7.2",
"invariant": "^2.2.4",
"is-plain-object": "^3.0.0",
"lodash.isequal": "^4.5.0"
"is-plain-object": "^3.0.0"
},

@@ -43,3 +42,4 @@ "peerDependencies": {

"index.d.ts"
]
],
"gitHead": "c350ee11f4c8faf2dfdaa0212218b8fe286e405d"
}

@@ -11,3 +11,3 @@ English | [简体中文](./README.zh-CN.md)

React Hooks based and lightweight state manage library.
Hook based and lightweight centralized state management for React.

@@ -14,0 +14,0 @@ ## Try it on codesandbox

@@ -11,3 +11,3 @@ 简体中文 | [English](./README.md)

基于React Hooks的轻量级状态管理方案。
基于React Hooks的轻量级中心化数据管理方案。

@@ -14,0 +14,0 @@ ## 在线查看demo

@@ -11,3 +11,2 @@ import React, {

import invariant from 'invariant';
import isEqual from 'lodash.isequal';

@@ -21,2 +20,3 @@ import {

tryClone,
shallowEqual,
} from './utils';

@@ -114,3 +114,3 @@ import { actionStatusModel } from './statusModel';

// console.log('-->prev.value: %j, newValue: %j', prev.value, newValue);
if (isEqual(newValue, prev.value)) return;
if (shallowEqual(newValue, prev.value)) return;

@@ -117,0 +117,0 @@ prev.value = newValue;

@@ -92,5 +92,38 @@ import { useReducer, useEffect, useLayoutEffect } from 'react';

export function tryClone(value) {
if (isPlainObject(value) || Array.isArray(value)) return JSON.parse(JSON.stringify(value));
if (isPlainObject(value)) return JSON.parse(JSON.stringify(value));
if (Array.isArray(value)) return value.slice();
return value;
}
const hasOwn = Object.prototype.hasOwnProperty;
function is(x, y) {
if (x === y) {
return x !== 0 || y !== 0 || 1 / x === 1 / y;
}
return x !== x && y !== y;
}
// copy from react-redux
export function shallowEqual(objA, objB) {
if (is(objA, objB)) return true;
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) return false;
for (let i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
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