Socket
Socket
Sign inDemoInstall

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.0.1 to 1.1.0

8

dist/index.d.ts

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

subscribe(subscription: (value: T) => void): () => void;
kill(): void;
destroy(): void;
};

@@ -15,4 +15,9 @@ }

reducers: (setter: (fn: (value: T) => T) => void) => REDUCERS;
dependencies?: [
...Array<GlobalState<any>>,
DependencyCompute<T>
];
compare?: (a: T, b: T) => boolean;
}
export declare type DependencyCompute<T extends {}> = (setter: (fn: (oldvalue: T) => T) => void) => void;
export interface GlobalStateReducers {

@@ -23,3 +28,4 @@ [key: string]: (...value: any[]) => any;

export declare function useGlobalState<T>(state: GlobalState<T>): T;
export declare function isGlobalState(state: any): state is GlobalState<any>;
export {};

2

dist/index.js

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

var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var S=e=>u(e,"__esModule",{value:!0});var v=(e,t)=>{for(var a in t)u(e,a,{get:t[a],enumerable:!0})},E=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of b(t))!f.call(e,l)&&(a||l!=="default")&&u(e,l,{get:()=>t[l],enumerable:!(n=T(t,l))||n.enumerable});return e};var R=(e=>(t,a)=>e&&e.get(t)||(a=E(S({}),t,1),e&&e.set(t,a),a))(typeof WeakMap!="undefined"?new WeakMap:0);var G={};v(G,{createGlobalState:()=>p,useGlobalState:()=>x});var s=require("react");function p(e){let t=e.compare||((o,r)=>o===r),a=e.initial,n=new Set,l={$:{get:c,set:i,subscribe(o){return n.add(o),()=>n.delete(o)},kill(){l&&(Object.keys(l.$).forEach(o=>{delete l.$[o]}),Object.keys(l).forEach(o=>{delete l[o]}),a=null,n.clear(),n=null,t=null)}},...e.reducers(i)};return l;function c(){return a}function i(o){let r=o(a);t(a,r)||(a=r,d())}function d(){n.forEach(o=>{setTimeout(()=>o(a),1)})}}function x(e){let[t,a]=(0,s.useState)(e.$.get());return(0,s.useEffect)(()=>e.$.subscribe(a),[]),t}module.exports=R(G);0&&(module.exports={createGlobalState,useGlobalState});
var d=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var E=e=>d(e,"__esModule",{value:!0});var R=(e,t)=>{for(var a in t)d(e,a,{get:t[a],enumerable:!0})},x=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of y(t))!m.call(e,l)&&(a||l!=="default")&&d(e,l,{get:()=>t[l],enumerable:!(o=v(t,l))||o.enumerable});return e};var G=(e=>(t,a)=>e&&e.get(t)||(a=x(E({}),t,1),e&&e.set(t,a),a))(typeof WeakMap!="undefined"?new WeakMap:0);var C={};R(C,{createGlobalState:()=>D,isGlobalState:()=>f,useGlobalState:()=>$});var s=require("react");function D(e){let t=e.compare||((n,r)=>n===r),a=e.initial,o;S();let l=new Set,i={$:{get:b,set:u,subscribe(n){return l.add(n),()=>l&&l.delete(n)},destroy(){i&&(o&&(o.forEach(n=>setTimeout(n,1)),o=void 0),Object.keys(i.$).forEach(n=>{delete i.$[n]}),Object.keys(i).forEach(n=>{delete i[n]}),a=null,l.clear(),l=null,t=null)}},...e.reducers(u)};return i;function b(){return a}function u(n){let r=n(a);t(a,r)||(a=r,p())}function p(){l.forEach(n=>{setTimeout(()=>n(a),1)})}function S(){if(!e.dependencies)return;o=[];let n,r;e.dependencies.map(c=>{f(c)?o.push(c.$.subscribe(T)):n=c}),T();function T(){r&&clearTimeout(r),r=setTimeout(()=>{o&&n(u)},100)}}}function $(e){let[t,a]=(0,s.useState)(e.$.get());return(0,s.useEffect)(()=>e.$.subscribe(a),[]),t}function f(e){return e&&e.$&&e.$.get&&e.$.set}module.exports=G(C);0&&(module.exports={createGlobalState,isGlobalState,useGlobalState});
{
"name": "lstate",
"description": "A simple, super-efficient and small (just 1.2kb) global state for React/Typescript applications",
"version": "1.0.1",
"description": "A simple, super-efficient and small (just 1.5kb) global state for React/Typescript applications",
"version": "1.1.0",
"private": false,

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

@@ -5,3 +5,3 @@ [![Node.js CI](https://github.com/teintinu/lstate/actions/workflows/test.yml/badge.svg)](https://github.com/teintinu/lstate/actions/workflows/test.yml)

# lstate
A simple, super-efficient and small (just 1.2kb) global state for React/Typescript applications
A simple, super-efficient and small (just 1.5kb) global state for React/Typescript applications

@@ -34,3 +34,3 @@ # install

<h1>Testing lstate</h1>
<h2>A simple, super-efficient and small (just 1.2kb) global state for React/Typescript applications</h2>
<h2>A simple, super-efficient and small (just 1.5kb) global state for React/Typescript applications</h2>
<p>count: {count}</p>

@@ -37,0 +37,0 @@ <button onClick={sample.inc}>+</button>

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