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-beta.0 to 0.4.0-beta.1

polyfill.js

24

index.d.ts

@@ -8,3 +8,3 @@ declare global {

store: any;
process: PurpleTeaProcess;
process: ArkflowsProcess;
name: string;

@@ -15,10 +15,10 @@ }>;

}
interface PurpleTeaEvent extends Event {
interface ArkflowsEvent extends Event {
detail?: any;
}
declare type PurpleTeaProcess = "create" | "get" | "update" | "set" | "subscribe";
declare type ArkflowsProcess = "create" | "get" | "update" | "set" | "subscribe";
declare const _default: {
new (): {
event: {
[key: string]: PurpleTeaEvent;
[key: string]: ArkflowsEvent;
};

@@ -34,6 +34,6 @@ store: {

* @param {string} name - Store Name
* @param {object} initStore - Initial storage value
* @param initStore - Initial storage value
* @returns {object} Storage value
*/
create<T = Object>(name: string, initStore?: {} | T): any;
create<T = any>(name: string, initStore?: {} | T): any;
/**

@@ -57,6 +57,6 @@ * Get existing store value with given store name.

* @param {string} name - Store Name
* @param {object} value - Value to change or update
* @returns {object} Storage value
* @param value - Value to change or update
* @returns Storage value
*/
update<T_2 = Object>(name: string, value: T_2): any;
update<T_2 = any>(name: string, value: T_2): any;
/**

@@ -75,3 +75,3 @@ *

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

@@ -113,5 +113,3 @@ };

[key: string]: any;
}, process: PurpleTeaProcess, name: string) => {
[key: string]: any;
})[]): void;
}, process: ArkflowsProcess, name: string) => any)[]): void;
/**

@@ -118,0 +116,0 @@ * Enable Arkflows devtools in browser developer's tool.

@@ -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));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){}};
"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}")`},isObject=e=>"object"==typeof e,isServer="undefined"==typeof window;var EventTargetClass="undefined"!=typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?require("./polyfill"):isServer?null:class extends EventTarget{};exports.default=isServer?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){}}:class extends EventTargetClass{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(void 0!==t?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(isObject(t)?Object.assign(Object.assign({},this.store[e]),t):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,this.model());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)}};
{
"name": "arkflows",
"version": "0.4.0-beta.0",
"version": "0.4.0-beta.1",
"description": "Immutable state container comes in light-weight",

@@ -5,0 +5,0 @@ "main": "index.js",

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