@tanstack/react-store
Advanced tools
Comparing version 0.0.1-beta.62 to 0.0.1-beta.81
@@ -15,51 +15,11 @@ /** | ||
var store = require('@tanstack/store'); | ||
var withSelector = require('use-sync-external-store/shim/with-selector'); | ||
function useStore(store, selector = d => d, compareShallow) { | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined); | ||
function useStore(store$1, selector = d => d, compareShallow) { | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store$1.subscribe, () => store$1.state, () => store$1.state, selector, compareShallow ? store.shallow : undefined); | ||
return slice; | ||
} | ||
function shallow(objA, objB) { | ||
if (Object.is(objA, objB)) { | ||
return true; | ||
} | ||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
return false; | ||
} | ||
// if (objA instanceof Map && objB instanceof Map) { | ||
// if (objA.size !== objB.size) return false | ||
// for (const [key, value] of objA) { | ||
// if (!Object.is(value, objB.get(key))) { | ||
// return false | ||
// } | ||
// } | ||
// return true | ||
// } | ||
// if (objA instanceof Set && objB instanceof Set) { | ||
// if (objA.size !== objB.size) return false | ||
// for (const value of objA) { | ||
// if (!objB.has(value)) { | ||
// return false | ||
// } | ||
// } | ||
// return true | ||
// } | ||
const keysA = Object.keys(objA); | ||
if (keysA.length !== Object.keys(objB).length) { | ||
return false; | ||
} | ||
for (let i = 0; i < keysA.length; i++) { | ||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
exports.useStore = useStore; | ||
//# sourceMappingURL=index.js.map |
@@ -11,2 +11,3 @@ /** | ||
*/ | ||
import { shallow } from '@tanstack/store'; | ||
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'; | ||
@@ -18,45 +19,4 @@ | ||
} | ||
function shallow(objA, objB) { | ||
if (Object.is(objA, objB)) { | ||
return true; | ||
} | ||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
return false; | ||
} | ||
// if (objA instanceof Map && objB instanceof Map) { | ||
// if (objA.size !== objB.size) return false | ||
// for (const [key, value] of objA) { | ||
// if (!Object.is(value, objB.get(key))) { | ||
// return false | ||
// } | ||
// } | ||
// return true | ||
// } | ||
// if (objA instanceof Set && objB instanceof Set) { | ||
// if (objA.size !== objB.size) return false | ||
// for (const value of objA) { | ||
// if (!objB.has(value)) { | ||
// return false | ||
// } | ||
// } | ||
// return true | ||
// } | ||
const keysA = Object.keys(objA); | ||
if (keysA.length !== Object.keys(objB).length) { | ||
return false; | ||
} | ||
for (let i = 0; i < keysA.length; i++) { | ||
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
export { useStore }; | ||
//# sourceMappingURL=index.js.map |
@@ -10,4 +10,13 @@ { | ||
{ | ||
"name": "packages/react-store/src/index.tsx", | ||
"uid": "dcf0-86" | ||
"name": "packages", | ||
"children": [ | ||
{ | ||
"name": "store/build/esm/index.js", | ||
"uid": "298b-92" | ||
}, | ||
{ | ||
"name": "react-store/src/index.tsx", | ||
"uid": "298b-94" | ||
} | ||
] | ||
} | ||
@@ -20,18 +29,39 @@ ] | ||
"nodeParts": { | ||
"dcf0-86": { | ||
"renderedLength": 1347, | ||
"gzipLength": 484, | ||
"298b-92": { | ||
"renderedLength": 1310, | ||
"gzipLength": 488, | ||
"brotliLength": 0, | ||
"mainUid": "dcf0-85" | ||
"mainUid": "298b-91" | ||
}, | ||
"298b-94": { | ||
"renderedLength": 253, | ||
"gzipLength": 171, | ||
"brotliLength": 0, | ||
"mainUid": "298b-93" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"dcf0-85": { | ||
"298b-91": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "298b-92" | ||
}, | ||
"imported": [], | ||
"importedBy": [ | ||
{ | ||
"uid": "298b-93" | ||
} | ||
] | ||
}, | ||
"298b-93": { | ||
"id": "/packages/react-store/src/index.tsx", | ||
"moduleParts": { | ||
"index.production.js": "dcf0-86" | ||
"index.production.js": "298b-94" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "dcf0-87" | ||
"uid": "298b-91" | ||
}, | ||
{ | ||
"uid": "298b-95" | ||
} | ||
@@ -42,3 +72,3 @@ ], | ||
}, | ||
"dcf0-87": { | ||
"298b-95": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -49,3 +79,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "dcf0-85" | ||
"uid": "298b-93" | ||
} | ||
@@ -52,0 +82,0 @@ ], |
@@ -17,6 +17,12 @@ /** | ||
function useStore(store, selector = d => d, compareShallow) { | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined); | ||
return slice; | ||
} | ||
/** | ||
* store | ||
* | ||
* Copyright (c) TanStack | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.md file in the root directory of this source tree. | ||
* | ||
* @license MIT | ||
*/ | ||
function shallow(objA, objB) { | ||
@@ -64,2 +70,7 @@ if (Object.is(objA, objB)) { | ||
function useStore(store, selector = d => d, compareShallow) { | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined); | ||
return slice; | ||
} | ||
exports.useStore = useStore; | ||
@@ -66,0 +77,0 @@ |
@@ -11,3 +11,13 @@ /** | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","use-sync-external-store/shim/with-selector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLoaders={},e.withSelector)}(this,(function(e,t){"use strict";function n(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}e.useStore=function(e,o=(e=>e),r){return t.useSyncExternalStoreWithSelector(e.subscribe,(()=>e.state),(()=>e.state),o,r?n:void 0)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","use-sync-external-store/shim/with-selector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactLoaders={},e.withSelector)}(this,(function(e,t){"use strict"; | ||
/** | ||
* store | ||
* | ||
* Copyright (c) TanStack | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.md file in the root directory of this source tree. | ||
* | ||
* @license MIT | ||
*/function n(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}e.useStore=function(e,o=(e=>e),r){return t.useSyncExternalStoreWithSelector(e.subscribe,(()=>e.state),(()=>e.state),o,r?n:void 0)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/react-store", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.62", | ||
"version": "0.0.1-beta.81", | ||
"license": "MIT", | ||
@@ -39,3 +39,3 @@ "repository": "tanstack/react-store", | ||
"use-sync-external-store": "^1.2.0", | ||
"@tanstack/store": "0.0.1-beta.62" | ||
"@tanstack/store": "0.0.1-beta.81" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
156764
255
+ Added@tanstack/store@0.0.1-beta.81(transitive)
- Removed@tanstack/store@0.0.1-beta.62(transitive)