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

little-state-machine

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

little-state-machine - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3-beta.1

11

dist/little-state-machine.es.js

@@ -34,11 +34,2 @@ import { createContext, useState, useMemo, createElement, useContext, useCallback } from 'react';

var isSessionStorageAllowed = () => {
try {
return !!window.sessionStorage;
}
catch (e) {
return false;
}
};
function setUpDevTools(isDevMode, storageType, getName, getStore) {

@@ -114,3 +105,3 @@ if (typeof window === 'undefined' || !isDevMode)

const isDevMode = process.env.NODE_ENV !== 'production';
let storageType = isClient && isSessionStorageAllowed()
let storageType = isClient
? window.sessionStorage

@@ -117,0 +108,0 @@ : {

@@ -125,10 +125,2 @@ 'use strict';

var isSessionStorageAllowed = function () {
try {
return !!window.sessionStorage;
} catch (e) {
return false;
}
};
function setUpDevTools(isDevMode, storageType, getName, getStore) {

@@ -230,3 +222,3 @@ if (typeof window === 'undefined' || !isDevMode) return; // @ts-ignore

var isDevMode = process.env.NODE_ENV !== 'production';
var storageType = isClient && isSessionStorageAllowed() ? window.sessionStorage : {
var storageType = isClient ? window.sessionStorage : {
getItem: function (payload) {

@@ -233,0 +225,0 @@ return payload;

@@ -38,11 +38,2 @@ 'use strict';

var isSessionStorageAllowed = () => {
try {
return !!window.sessionStorage;
}
catch (e) {
return false;
}
};
function setUpDevTools(isDevMode, storageType, getName, getStore) {

@@ -118,3 +109,3 @@ if (typeof window === 'undefined' || !isDevMode)

const isDevMode = process.env.NODE_ENV !== 'production';
let storageType = isClient && isSessionStorageAllowed()
let storageType = isClient
? window.sessionStorage

@@ -121,0 +112,0 @@ : {

2

dist/little-state-machine.min.es.js

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

import{createContext as e,useState as t,useMemo as r,createElement as n,useContext as o,useCallback as a}from"react";var s=(e,t)=>{const r=e.getItem(t);try{return r?JSON.parse(r):void 0}catch(e){return}};var i=e=>void 0===e;var c=e({store:{},updateStore:e=>e}),_=({transform:e,externalStoreName:t,storageType:r,store:n})=>e({externalStoreData:s(r,t),currentStoreData:n});const S="undefined"!=typeof window,E="production"!==process.env.NODE_ENV;let d,m,A,l=S&&(()=>{try{return!!window.sessionStorage}catch(e){return!1}})()?window.sessionStorage:{getItem:e=>e,setItem:e=>e,clear:()=>{},length:0,key:e=>e.toString(),removeItem:()=>{}},u=[];function T(e){l=e}function f(e,t={name:"__STATE_MACHINE__",middleWares:[],syncStores:void 0}){const r=t?t.name:"__STATE_MACHINE__",n=function(e,t){const r=t||"__STATE_MACHINE__";let n=s(e,r);return{set:e=>{n=e},get:()=>n,getName:()=>r}}(l,r);E&&S&&(window.STATE_MACHINE_NAME=r),A=n.getName,d=n.get,m=n.set,u=t.middleWares,function(e,t,r,n){"undefined"!=typeof window&&e&&(window.STATE_MACHINE_DEBUG=e=>t.setItem("___STATE_MACHINE_DEBUG__",e),window.STATE_MACHINE_RESET=()=>t.clear(),window.STATE_MACHINE_GET_STORE=()=>t.getItem(r()),window.STATE_MACHINE_SAVE_TO=e=>window.localStorage.setItem(e,JSON.stringify(n())),window.STATE_MACHINE_LOAD=({storeName:e,data:n})=>t.setItem(r()||"___STATE_MACHINE_DEBUG__",n||window.localStorage.getItem(e)||""))}(E,l,A,d),m(function(e,t,r){let n=e;const o=t.syncStores;if(!o)return n;try{if(Array.isArray(o))o.forEach(e=>{n=_({transform:e.transform,externalStoreName:e.externalStoreName,storageType:r,store:n})});else{if(o.externalStoreName&&"function"==typeof o.transform&&"string"==typeof o.externalStoreName)return _({transform:o.transform,externalStoreName:o.externalStoreName,storageType:r,store:n});Object.entries(o).forEach(([e,t])=>{const o=s(r,e);t.forEach(e=>{n=Object.assign(Object.assign({},n),{[e]:Object.assign(Object.assign({},n[e]),o[e])})})})}}catch(e){return n}return n}(d()||e,t,l))}function N(e){const[o,a]=t(d()),s=r(()=>({store:o,updateStore:a}),[o]);return n(c.Provider,Object.assign({value:s},e))}const g=({options:e,callback:t,updateStore:r})=>n=>{let o;const a=t?t.name:"";if(E&&((e="")=>{e&&S&&(window.__STATE_MACHINE_ACTION_NAME__=e)})(a),t&&(o=t(d(),n)),m(i(o)?d():o),l.setItem(A(),JSON.stringify(d())),i(e)||e&&!1!==e.shouldReRenderApp){let e=d();Array.isArray(u)&&u.length&&(e=u.reduce((e,t)=>t(e)||e,e)),r(e)}};function w(e,t){const{store:r,updateStore:n}=o(c);return e&&Object.keys(e).length?{actions:Object.entries(e).reduce((e,[r,o])=>Object.assign(Object.assign({},e),{[r]:a(g({options:t,callback:o,updateStore:n}),[])}),{}),action:e=>e,state:r}:{actions:{},action:a(e?g({options:t,callback:e,updateStore:n}):()=>{},[]),state:r}}export{c as StateMachineContext,N as StateMachineProvider,f as createStore,T as setStorageType,w as useStateMachine};
import{createContext as e,useState as t,useMemo as r,createElement as o,useContext as n,useCallback as a}from"react";var s=(e,t)=>{const r=e.getItem(t);try{return r?JSON.parse(r):void 0}catch(e){return}};var i=e=>void 0===e;var c=e({store:{},updateStore:e=>e}),_=({transform:e,externalStoreName:t,storageType:r,store:o})=>e({externalStoreData:s(r,t),currentStoreData:o});const E="undefined"!=typeof window,S="production"!==process.env.NODE_ENV;let d,m,A,l=E?window.sessionStorage:{getItem:e=>e,setItem:e=>e,clear:()=>{},length:0,key:e=>e.toString(),removeItem:()=>{}},T=[];function u(e){l=e}function f(e,t={name:"__STATE_MACHINE__",middleWares:[],syncStores:void 0}){const r=t?t.name:"__STATE_MACHINE__",o=function(e,t){const r=t||"__STATE_MACHINE__";let o=s(e,r);return{set:e=>{o=e},get:()=>o,getName:()=>r}}(l,r);S&&E&&(window.STATE_MACHINE_NAME=r),A=o.getName,d=o.get,m=o.set,T=t.middleWares,function(e,t,r,o){"undefined"!=typeof window&&e&&(window.STATE_MACHINE_DEBUG=e=>t.setItem("___STATE_MACHINE_DEBUG__",e),window.STATE_MACHINE_RESET=()=>t.clear(),window.STATE_MACHINE_GET_STORE=()=>t.getItem(r()),window.STATE_MACHINE_SAVE_TO=e=>window.localStorage.setItem(e,JSON.stringify(o())),window.STATE_MACHINE_LOAD=({storeName:e,data:o})=>t.setItem(r()||"___STATE_MACHINE_DEBUG__",o||window.localStorage.getItem(e)||""))}(S,l,A,d),m(function(e,t,r){let o=e;const n=t.syncStores;if(!n)return o;try{if(Array.isArray(n))n.forEach(e=>{o=_({transform:e.transform,externalStoreName:e.externalStoreName,storageType:r,store:o})});else{if(n.externalStoreName&&"function"==typeof n.transform&&"string"==typeof n.externalStoreName)return _({transform:n.transform,externalStoreName:n.externalStoreName,storageType:r,store:o});Object.entries(n).forEach(([e,t])=>{const n=s(r,e);t.forEach(e=>{o=Object.assign(Object.assign({},o),{[e]:Object.assign(Object.assign({},o[e]),n[e])})})})}}catch(e){return o}return o}(d()||e,t,l))}function N(e){const[n,a]=t(d()),s=r(()=>({store:n,updateStore:a}),[n]);return o(c.Provider,Object.assign({value:s},e))}const g=({options:e,callback:t,updateStore:r})=>o=>{let n;const a=t?t.name:"";if(S&&((e="")=>{e&&E&&(window.__STATE_MACHINE_ACTION_NAME__=e)})(a),t&&(n=t(d(),o)),m(i(n)?d():n),l.setItem(A(),JSON.stringify(d())),i(e)||e&&!1!==e.shouldReRenderApp){let e=d();Array.isArray(T)&&T.length&&(e=T.reduce((e,t)=>t(e)||e,e)),r(e)}};function w(e,t){const{store:r,updateStore:o}=n(c);return e&&Object.keys(e).length?{actions:Object.entries(e).reduce((e,[r,n])=>Object.assign(Object.assign({},e),{[r]:a(g({options:t,callback:n,updateStore:o}),[])}),{}),action:e=>e,state:r}:{actions:{},action:a(e?g({options:t,callback:e,updateStore:o}):()=>{},[]),state:r}}export{c as StateMachineContext,N as StateMachineProvider,f as createStore,u as setStorageType,w as useStateMachine};

@@ -37,11 +37,2 @@ (function (global, factory) {

var isSessionStorageAllowed = () => {
try {
return !!window.sessionStorage;
}
catch (e) {
return false;
}
};
function setUpDevTools(isDevMode, storageType, getName, getStore) {

@@ -117,3 +108,3 @@ if (typeof window === 'undefined' || !isDevMode)

const isDevMode = "production" !== 'production';
let storageType = isClient && isSessionStorageAllowed()
let storageType = isClient
? window.sessionStorage

@@ -120,0 +111,0 @@ : {

{
"name": "little-state-machine",
"sideEffects": false,
"version": "3.1.2",
"version": "3.1.3-beta.1",
"main": "dist/little-state-machine.js",

@@ -6,0 +6,0 @@ "module": "dist/little-state-machine.es.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