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

arkflows

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arkflows - npm Package Compare versions

Comparing version 0.4.0-alpha.0 to 0.4.0-alpha.2

4

index.d.ts

@@ -71,3 +71,5 @@ declare global {

*/
subscribe<T_3 = Object>(name: string | string[], callback: (value: T_3) => void): void;
subscribe<T_3 = Object>(name: string | string[], callback: (value: T_3) => void): {
unsubscribe: () => void;
};
/**

@@ -74,0 +76,0 @@ * Get every store name.

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const validate=(e,t)=>{if(!e)throw"type is required.";if("string"!=typeof e)throw"type must be string.";if(void 0===t[e])throw`Store: ${e} isn't existed. Please create it with create("${e}")`};exports.default="undefined"!=typeof window?class extends EventTarget{constructor(){super(),this.event={},this.store={},this.middleware=[],this.withDevtools=void 0}create(e,t={}){if(void 0!==this.store[e])throw`${e} is already existed.`;return this.event[e]=new Event(e),this.store[e]=this.useMiddleware(t||{},"create",e),this.store[e]}get(e){return validate(e,this.event),Object.freeze(this.useMiddleware(this.store[e],"get",e))}set(e,t){validate(e,this.event);let s=this.event[e];return s.detail=t,this.store[e]=this.useMiddleware(t,"set",e),this.dispatchEvent(s),this.store[e]}update(e,t){validate(e,this.event);let s=this.event[e];return s.detail=t,this.store[e]=this.useMiddleware(Object.assign(Object.assign({},this.store[e]),t),"update",e),this.dispatchEvent(s),this.store[e]}subscribe(e,t){"*"===e&&(e=[...this.list()]||[]),"string"==typeof e&&(e=new Array(e)),e.forEach(e=>(validate(e,this.event),this.addEventListener(e,()=>t(this.useMiddleware(this.store[e],"subscribe",e)))))}list(){return Object.keys(this.store)}model(){let e=[];return Object.entries(this.store).map(([t,s])=>{e.push(JSON.parse(`{"name":"${t}","store":${JSON.stringify(this.useMiddleware(s,"get",t))}}`))}),e}applyMiddleware(...e){e.forEach(e=>this.middleware.push(e))}useMiddleware(e=this.store,t,s){let i=Object.freeze(e);return this.middleware.map(e=>i=e(i,t,s)),void 0===window.__arkflows__&&(window.__arkflows__={version:"0.4.0",listener:(e=(()=>null))=>this.subscribe("*",()=>e()),process:[]}),this.withDevtools&&"subscribe"!==t&&window.__arkflows__.process.push({name:s,process:t,store:e}),i}enableDevtools(e=!0){if(void 0!==this.withDevtools)throw"Devtools can only figure at once.";e&&(window.__arkflows__={version:"0.4.0",listener:(e=(()=>null))=>this.subscribe("*",()=>e()),process:[]},this.withDevtools=!0)}}:class{constructor(){this.event={},this.store={},this.middleware=[],this.withDevtools=void 0}create(e,t={}){return t}get(e){return{}}set(e,t){return{}}update(e,t){return{}}subscribe(e,t){}list(){return[]}model(){return[]}applyMiddleware(...e){}enableDevtools(e=!0){}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const validate=(e,t)=>{if(!e)throw"type is required.";if("string"!=typeof e)throw"type must be string.";if(void 0===t[e])throw`Store: ${e} isn't existed. Please create it with create("${e}")`};exports.default="undefined"!=typeof window?class extends EventTarget{constructor(){super(),this.event={},this.store={},this.middleware=[],this.withDevtools=void 0}create(e,t={}){if(void 0!==this.store[e])throw`${e} is already existed.`;return this.event[e]=new Event(e),this.store[e]=this.useMiddleware(t||{},"create",e),this.store[e]}get(e){return validate(e,this.event),Object.freeze(this.useMiddleware(this.store[e],"get",e))}set(e,t){validate(e,this.event);let s=this.event[e];return s.detail=t,this.store[e]=this.useMiddleware(t,"set",e),this.dispatchEvent(s),this.store[e]}update(e,t){validate(e,this.event);let s=this.event[e];return s.detail=t,this.store[e]=this.useMiddleware(Object.assign(Object.assign({},this.store[e]),t),"update",e),this.dispatchEvent(s),this.store[e]}subscribe(e,t){"*"===e&&(e=[...this.list()]||[]),"string"==typeof e&&(e=new Array(e));let s=[];return e.forEach(e=>{validate(e,this.event);let i=()=>t(this.useMiddleware(this.store[e],"subscribe",e),e);return s.push(i),this.addEventListener(e,()=>i())}),{unsubscribe:()=>Object.entries(this.event).forEach(([e,t],i)=>this.removeEventListener(e,s[i]))}}list(){return Object.keys(this.store)}model(){let e=[];return Object.entries(this.store).map(([t,s])=>{e.push(JSON.parse(`{"name":"${t}","store":${JSON.stringify(this.useMiddleware(s,"get",t))}}`))}),e}applyMiddleware(...e){e.forEach(e=>this.middleware.push(e))}useMiddleware(e=this.store,t,s){let i=Object.freeze(e);return this.middleware.map(e=>i=e(i,t,s)),this.withDevtools&&void 0===window.__arkflows__&&(window.__arkflows__={version:"0.4.0",listener:e=>this.subscribe("*",t=>e(t)),process:[]},"subscribe"!==t&&window.__arkflows__.process.push({name:s,process:t,store:e})),i}enableDevtools(e=!0){if(void 0!==this.withDevtools)throw"Devtools can only figure at once.";e&&(window.__arkflows__={version:"0.4.0",listener:(e=(()=>null))=>this.subscribe("*",(t,s)=>e(t,s,this.model())),process:[]},this.withDevtools=!0)}}:class{constructor(){this.event={},this.store={},this.middleware=[],this.withDevtools=void 0}create(e,t={}){return t}get(e){return{}}set(e,t){return{}}update(e,t){return{}}subscribe(e,t){return{unsubscribe:()=>null}}list(){return[]}model(){return[]}applyMiddleware(...e){}enableDevtools(e=!0){}};
{
"name": "arkflows",
"version": "0.4.0-alpha.0",
"description": "Immutatable state container comes in light-weight",
"version": "0.4.0-alpha.2",
"description": "Immutable state container comes in light-weight",
"main": "index.js",

@@ -6,0 +6,0 @@ "types": "index.d.ts",

Sorry, the diff of this file is not supported yet

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