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.1.0 to 1.1.1

24

dist/index.d.ts
// Generated by dts-bundle-generator v6.4.0
export declare type FullReadOnly<T> = T extends Array<infer U> ? ReadonlyArray<FullReadOnly<U>> : T extends object ? {
readonly [P in keyof T]: FullReadOnly<T[P]>;
} : T;
export declare type GlobalStateSetter<T> = (fn: (oldvalue: FullReadOnly<T>) => T) => void;
export interface GlobalState<T extends {}> {
$: {
get(): T;
set(fn: (oldvalue: T) => T): void;
subscribe(subscription: (value: T) => void): () => void;
get(): FullReadOnly<T>;
set: GlobalStateSetter<T>;
subscribe(subscription: (value: FullReadOnly<T>) => void): () => void;
destroy(): void;
};
}
export interface GlobalStateReducers {
[key: string]: (...value: any[]) => any;
}
export declare type DependencyCompute<T extends {}> = (setter: GlobalStateSetter<T>) => void;
export interface GlobalStateDef<T extends {}, REDUCERS extends GlobalStateReducers> {
initial: T;
reducers: (setter: (fn: (value: T) => T) => void) => REDUCERS;
reducers: (setter: GlobalStateSetter<T>) => REDUCERS;
dependencies?: [

@@ -18,12 +26,8 @@ ...Array<GlobalState<any>>,

];
compare?: (a: T, b: T) => boolean;
compare?: (a: FullReadOnly<T>, b: T) => boolean;
}
export declare type DependencyCompute<T extends {}> = (setter: (fn: (oldvalue: T) => T) => void) => void;
export interface GlobalStateReducers {
[key: string]: (...value: any[]) => any;
}
export declare function createGlobalState<T extends {}, REDUCERS extends GlobalStateReducers>(def: GlobalStateDef<T, REDUCERS>): GlobalState<T> & REDUCERS;
export declare function useGlobalState<T>(state: GlobalState<T>): T;
export declare function useGlobalState<T>(state: GlobalState<T>): FullReadOnly<T>;
export declare function isGlobalState(state: any): state is GlobalState<any>;
export {};

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

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

@@ -26,2 +26,3 @@ "main": "dist/index.js",

"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.28.0",
"jest": "^27.4.5",

@@ -43,3 +44,4 @@ "pjobs": "^1.1.3",

"test-coverage": "jest --coverage",
"lint": "eslint --fix --config .eslintrc.js"
"lint": "eslint --config .eslintrc.js src/**/*.ts",
"lint-fix": "eslint --fix --config .eslintrc.js src/**/*.ts"
},

@@ -46,0 +48,0 @@ "dependencies": {

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