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

@superstate/core

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superstate/core - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

2

core.js

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

function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}var t=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,u,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(u=r;0!=u--;)if(!e(t[u],n[u]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(u=r;0!=u--;)if(!Object.prototype.hasOwnProperty.call(n,o[u]))return!1;for(u=r;0!=u--;){var i=o[u];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n};exports.superstate=function(n){var r=n,u=void 0,o=[],i=[],c=[],f={draft:function(){return u},sketch:function(e,n){var o,i=u,c=p(null!=(o=u)?o:r,e);return t(i,c)||(v({eventType:"before:sketch"}),u=c,v({eventType:"after:sketch"}),null!=n&&n.silent||h()),a},publish:function(e){if(void 0===u)return a;var n=u;return t(r,n)||(v({eventType:"before:publish"}),l(n),v({eventType:"after:publish"}),s(),null!=e&&e.silent||b()),a},discard:s},a=e({},f,{set:function(e,n){if(void 0===e&&void 0===u)return a;var o=r,i=p(r,e);return t(o,i)||(v({eventType:"before:set"}),l(i),v({eventType:"after:set"}),null!=n&&n.silent||b()),a},now:function(){return r},subscribe:function(e,t){if("draft"===t)return function(e){var t=i.length;return i.push(e),function(){return i=[].concat(i.slice(0,t),i.slice(t+1,i.length))}}(e);var n=o.length;return o.push(e),function(){return o=[].concat(o.slice(0,n),o.slice(n+1,o.length))}},extend:function(t){return e({},a,function(t){return Object.keys(t).reduce(function(n,r){var u;return e({},n,((u={})[r]=function(){if(void 0!==t[r].apply(t,[y()].concat([].slice.call(arguments))))return f},u))},{})}(t))},use:function(e){return v({eventType:"init"},e),c=[].concat(c,e),a},unsubscribeAll:function(){o=[],i=[]}});function s(e){return void 0===u||(v({eventType:"before:discard"}),u=void 0,v({eventType:"after:discard"}),null!=e&&e.silent||h()),a}function l(e){v({eventType:"before:change"}),r=e,v({eventType:"after:change"})}function p(e,t){var n=function(e){if(void 0!==e)return e instanceof Map?new Map(e):e instanceof Set?new Set(e):JSON.parse(JSON.stringify(e))}(e);return function(e){return"function"==typeof e}(t)?t(n):t}function v(t,n){var r=t.eventType,u=n||c;u.length&&u.forEach(function(t){t(e({eventType:r},a))})}function y(){return a}function b(){v({eventType:"before:broadcast:now"}),o.forEach(function(e){return e(r)}),v({eventType:"after:broadcast:now"})}function h(){v({eventType:"before:broadcast:draft"}),i.forEach(function(e){return e(u)}),v({eventType:"after:broadcast:draft"})}return a};
function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.apply(this,arguments)}var t=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,u,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(u=r;0!=u--;)if(!e(t[u],n[u]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(u=r;0!=u--;)if(!Object.prototype.hasOwnProperty.call(n,o[u]))return!1;for(u=r;0!=u--;){var i=o[u];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n};exports.superstate=function(n){var r=n,u=void 0,o=[],i=[],c=[],f=e({},{draft:function(){return u},sketch:function(e,n){var o,i=u,c=l(null!=(o=u)?o:r,e);return t(i,c)||(p({eventType:"before:sketch"}),u=c,p({eventType:"after:sketch"}),null!=n&&n.silent||b()),f},publish:function(e){if(void 0===u)return f;var n=u;return t(r,n)||(p({eventType:"before:publish"}),s(n),p({eventType:"after:publish"}),a(),null!=e&&e.silent||y()),f},discard:a},{set:function(e,n){if(void 0===e&&void 0===u)return f;var o=r,i=l(r,e);return t(o,i)||(p({eventType:"before:set"}),s(i),p({eventType:"after:set"}),null!=n&&n.silent||y()),f},now:function(){return r},subscribe:function(e,t){if("draft"===t)return function(e){var t=i.length;return i.push(e),function(){return i=[].concat(i.slice(0,t),i.slice(t+1,i.length))}}(e);var n=o.length;return o.push(e),function(){return o=[].concat(o.slice(0,n),o.slice(n+1,o.length))}},extend:function(t){return e({},f,function(t){return Object.keys(t).reduce(function(n,r){var u;return e({},n,((u={})[r]=function(){var e=t[r].apply(t,[v()].concat([].slice.call(arguments)));if(void 0!==e)return e},u))},{})}(t))},use:function(e){return p({eventType:"init"},e),c=[].concat(c,e),f},unsubscribeAll:function(){o=[],i=[]}});function a(e){return void 0===u||(p({eventType:"before:discard"}),u=void 0,p({eventType:"after:discard"}),null!=e&&e.silent||b()),f}function s(e){p({eventType:"before:change"}),r=e,p({eventType:"after:change"})}function l(e,t){var n=function(e){if(void 0!==e)return e instanceof Map?new Map(e):e instanceof Set?new Set(e):JSON.parse(JSON.stringify(e))}(e);return function(e){return"function"==typeof e}(t)?t(n):t}function p(t,n){var r=t.eventType,u=n||c;u.length&&u.forEach(function(t){t(e({eventType:r},f))})}function v(){return f}function y(){p({eventType:"before:broadcast:now"}),o.forEach(function(e){return e(r)}),p({eventType:"after:broadcast:now"})}function b(){p({eventType:"before:broadcast:draft"}),i.forEach(function(e){return e(u)}),p({eventType:"after:broadcast:draft"})}return f};

@@ -93,9 +93,8 @@ /**

declare type ISubscriber<S> = (newState: S) => void;
declare type IExtensionOutput<S> = S | void | undefined | ISuperStateDraftMethods<S>;
declare type IExtensionUserParams = any[];
declare type IExtensionAllParams<S> = [IExtensionPropsBag<S>, ...IExtensionUserParams];
declare type IExtension<S> = (...params: IExtensionAllParams<S>) => IExtensionOutput<S>;
declare type IExtension<S, O = void> = (...params: IExtensionAllParams<S>) => O;
declare type IExtensions<S> = Record<string, IExtension<S>>;
declare type IExtensionMethods<S, E extends IExtensions<S>> = {
[key in keyof E]: (...params: DropFirst<Parameters<E[key]>>) => ISuperStateDraftMethods<S>;
[key in keyof E]: (...params: DropFirst<Parameters<E[key]>>) => ReturnType<E[key]>;
};

@@ -102,0 +101,0 @@ declare type IUnsubscribe = () => void;

{
"name": "@superstate/core",
"version": "0.0.12",
"version": "0.0.13",
"description": "The essential package for superstate, the state management library.",

@@ -5,0 +5,0 @@ "main": "./core.js",

Sorry, the diff of this file is not supported yet

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