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

lstate

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lstate - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

8

dist/index.d.ts

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

// Generated by dts-bundle-generator v6.4.0
// Generated by dts-bundle-generator v6.5.0

@@ -6,3 +6,3 @@ export declare type FullReadOnly<T> = T extends Array<infer U> ? ReadonlyArray<FullReadOnly<U>> : T extends object ? {

} : T;
export declare type LStateSetter<T> = (fn: (oldvalue: FullReadOnly<T>) => T) => void;
export declare type LStateSetter<T> = (fn: (oldvalue: FullReadOnly<T>) => undefined | T) => void;
export interface LState<T extends {}> {

@@ -42,3 +42,3 @@ $: {

subscribeItem(id: string, subscription: (item?: FullReadOnly<LCollectionOf<T>>) => void): () => void;
upsert(id: string, fn: (old?: Omit<T, "id">) => Omit<T, "id">): void;
upsert(id: string, fn: (old?: Omit<T, "id">) => undefined | Omit<T, "id">): void;
remove(id: string): void;

@@ -74,3 +74,3 @@ destroy(): void;

setter: LStateSetter<LCollectionOf<T>>;
upsert(id: string, fn: (old?: Omit<T, "id">) => Omit<T, "id">): void;
upsert(id: string, fn: (old?: Omit<T, "id">) => undefined | Omit<T, "id">): void;
remove(id: string): void;

@@ -77,0 +77,0 @@ }) => ACTIONS;

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

import{useEffect as C,useState as b}from"react";function f(e,n,d){if(e===n)return 0;let r=e===null?"null":typeof e,c=n===null?"null":typeof n,a;if(e instanceof Date)return n instanceof Date?e.getTime()-n.getTime():c==="string"?e.getTime()-new Date(n).getTime():-1;if(n instanceof Date)return r==="string"?new Date(e).getTime()-n.getTime():1;if(r!==c)return r==="undefined"?-1:c==="undefined"?1:r<c?-1:1;if(Array.isArray(e))return a=e.length-n.length,a||e.some((l,u)=>(a=f(l,n[u],d),!!a)),a;if(r==="object"){let l=Object.getOwnPropertyNames(e);return l.sort(),a=0,l.some(u=>(a=f(e[u],n[u],d),!!a)),a===0&&d&&(a=l.length-Object.getOwnPropertyNames(n).length),a}else return r==="function"?0:e<n?-1:1}function $(e){let n=e.compare||((t,o)=>t===o),d=e.items&&(Array.isArray(e.items)?g(e.items):e.items),r=e.initial||d||e.default,c=e.dependencies,a=e.compute,l=new Set,u;c&&v();let i={$:{get:x,subscribe(t){return l.add(t),()=>l&&l.delete(t)},destroy(){i&&(u&&(u.forEach(t=>setTimeout(t,1)),u=void 0),Object.keys(i.$).forEach(t=>{delete i.$[t]}),Object.keys(i).forEach(t=>{delete i[t]}),r=null,l.clear(),l=null,i=null,n=null)}}};return e.compute||(i.$.setter=y,e.actions&&(i={...i,...e.actions(d?{setter:y,upsert:p,remove:L}:y)})),d&&(i.$.load=t=>{y(()=>t)},i.$.subscribeList=t=>i.$.subscribe(o=>t(S(o))),i.$.subscribeQuery=(t,o,s)=>i.$.subscribe(T=>s(S(T).reduce(o,t))),i.$.subscribeItem=(t,o)=>i.$.subscribe(s=>o(s[t])),i.$.upsert=p,i.$.remove=L),i;function x(){return r}function y(t){let o=t(r);n(r,o)||(r=o,O())}function O(){l.forEach(t=>{setTimeout(()=>t(r),1)})}function v(){u=[];let t;u=c.map(s=>s.$.subscribe(o)),o();function o(){t&&clearTimeout(t),t=setTimeout(()=>{u&&a(y,...c.map(s=>s.$.get()))},100)}}function p(t,o){y(s=>{let T=s[t],m=o(T);return f(T,m,!0)===0?s:{...s,[t]:m}})}function L(t){y(o=>{let s={...o};return s[t]?(delete s[t],s):o})}}function F(e){let[n,d]=b(()=>e.$.get());return C(()=>e.$.subscribe(d),[]),n}function g(e){let n={};return e.forEach(d=>{let{id:r,...c}=d;n[r]=c}),n}function S(e){return Object.keys(e).map(n=>({id:n,...e[n]}))}export{g as collectionListToCollectionOf,S as collectionOfToCollectionList,$ as createLState,F as useLState};
import{useEffect as C,useState as b}from"react";function f(e,n,d){if(e===n)return 0;let r=e===null?"null":typeof e,c=n===null?"null":typeof n,a;if(e instanceof Date)return n instanceof Date?e.getTime()-n.getTime():c==="string"?e.getTime()-new Date(n).getTime():-1;if(n instanceof Date)return r==="string"?new Date(e).getTime()-n.getTime():1;if(r!==c)return r==="undefined"?-1:c==="undefined"?1:r<c?-1:1;if(Array.isArray(e))return a=e.length-n.length,a||e.some((l,u)=>(a=f(l,n[u],d),!!a)),a;if(r==="object"){let l=Object.getOwnPropertyNames(e);return l.sort(),a=0,l.some(u=>(a=f(e[u],n[u],d),!!a)),a===0&&d&&(a=l.length-Object.getOwnPropertyNames(n).length),a}else return r==="function"?0:e<n?-1:1}function $(e){let n=e.compare||((t,o)=>t===o),d=e.items&&g(e.items),r=e.initial||d||e.default,c=e.dependencies,a=e.compute,l=new Set,u;c&&v();let i={$:{get:x,subscribe(t){return l.add(t),()=>l&&l.delete(t)},destroy(){i&&(u&&(u.forEach(t=>setTimeout(t,1)),u=void 0),Object.keys(i.$).forEach(t=>{delete i.$[t]}),Object.keys(i).forEach(t=>{delete i[t]}),r=null,l.clear(),l=null,i=null,n=null)}}};return e.compute||(i.$.setter=y,e.actions&&(i={...i,...e.actions(d?{setter:y,upsert:L,remove:m}:y)})),d&&(i.$.load=t=>{y(()=>t)},i.$.subscribeList=t=>i.$.subscribe(o=>t(S(o))),i.$.subscribeQuery=(t,o,s)=>i.$.subscribe(T=>s(S(T).reduce(o,t))),i.$.subscribeItem=(t,o)=>i.$.subscribe(s=>o(s[t])),i.$.upsert=L,i.$.remove=m),i;function x(){return r}function y(t){let o=t(r);o&&!n(r,o)&&(r=o,O())}function O(){l.forEach(t=>{setTimeout(()=>t(r),1)})}function v(){u=[];let t;u=c.map(s=>s.$.subscribe(o)),o();function o(){t&&clearTimeout(t),t=setTimeout(()=>{u&&a(y,...c.map(s=>s.$.get()))},100)}}function L(t,o){y(s=>{let T=s[t],p=o(T);if(p)return f(T,p,!0)===0?s:{...s,[t]:p}})}function m(t){y(o=>{let s={...o};return s[t]?(delete s[t],s):o})}}function F(e){let[n,d]=b(()=>e.$.get());return C(()=>e.$.subscribe(d),[]),n}function g(e){let n={};return e.forEach(d=>{let{id:r,...c}=d;n[r]=c}),n}function S(e){return Object.keys(e).map(n=>({id:n,...e[n]}))}export{g as collectionListToCollectionOf,S as collectionOfToCollectionList,$ as createLState,F as useLState};
{
"name": "lstate",
"description": "A simple, super-efficient and small (just 2.1kb) global state for React/Typescript applications",
"version": "1.2.3",
"version": "1.2.4",
"private": false,

@@ -9,21 +9,21 @@ "main": "dist/index.js",

"devDependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@types/jest": "^27.0.3",
"@types/react": "^17.0.38",
"@types/jest": "^27.4.0",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/source-map-support": "^0.5.4",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"dts-bundle-generator": "^6.2.0",
"esbuild": "^0.14.5",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"dts-bundle-generator": "^6.5.0",
"esbuild": "^0.14.20",
"esbuild-jest": "^0.5.0",
"eslint": "^8.5.0",
"eslint": "^8.8.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.28.0",
"jest": "^27.4.5",
"jest": "^27.5.0",
"pjobs": "^1.1.3",

@@ -33,4 +33,4 @@ "react-dom": "^17.0.2",

"source-map-support": "^0.5.21",
"ts-jest": "^27.1.2",
"typescript": "^4.5.4"
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
},

@@ -37,0 +37,0 @@ "scripts": {

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