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.2 to 1.2.3

4

dist/index.d.ts

@@ -36,3 +36,3 @@ // Generated by dts-bundle-generator v6.4.0

set: LStateSetter<LCollectionOf<T>>;
load(data: FullReadOnly<LCollectionList<T>>): void;
load(data: FullReadOnly<LCollectionOf<T>>): void;
subscribe(subscription: (collectionOf: FullReadOnly<LCollectionOf<T>>) => void): () => void;

@@ -70,3 +70,3 @@ subscribeList(subscription: (items: FullReadOnly<LCollectionList<T>>) => void): () => void;

}, ACTIONS extends LStateActions> {
items: LCollectionOf<T>;
items: ArrayLike<T> | LCollectionOf<T>;
actions: (dml: {

@@ -73,0 +73,0 @@ setter: LStateSetter<LCollectionOf<T>>;

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

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

@@ -6,0 +6,0 @@ "main": "dist/index.js",

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