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

statecore

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statecore - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

2

package.json
{
"name": "statecore",
"version": "1.0.4",
"version": "1.1.0",
"description": "A state-observable library.",

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

@@ -17,6 +17,5 @@ (function moduleify(moduleFactory) {

return { createStatecore: function createStatecore(state) {
var undefined = (function _undefined() {})();
var allObservers = [];
function statecoreDiscard() { state = undefined; allObservers = undefined; }
function statecoreIsDiscarded() { return allObservers === undefined; }
function statecoreDiscard() { state = null; allObservers.splice(0); allObservers = null; }
function statecoreIsDiscarded() { return allObservers === null; }
function statecoreGetState() { return state; }

@@ -28,14 +27,19 @@ function statecoreSetState(newState) {

}
function statecoreRemoveObserver(observer) {
if (statecoreIsDiscarded()) return;
var copyObservers = allObservers;
allObservers = [];
for (var idx = 0; idx < copyObservers.length; idx += 1) {
if (observer !== copyObservers[idx]) allObservers.push(copyObservers[idx]);
}
}
function statecoreAddObserver(observer) {
if (statecoreIsDiscarded()) throw new Error('This Statecore has been discarded!');
if (typeof observer !== 'function') throw new Error('The observer must be a function!');
allObservers.push(observer);
return function removeObserver() {
if (observer && allObservers) {
var copyObservers = allObservers;
allObservers = [];
for (var idx = 0; idx < copyObservers.length; idx += 1) {
if (observer !== copyObservers[idx]) allObservers.push(copyObservers[idx]);
}
if (observer) {
statecoreRemoveObserver(observer);
observer = null;
}
observer = undefined;
};

@@ -48,4 +52,4 @@ }

}
return { statecoreGetState: statecoreGetState, statecoreSetState: statecoreSetState, statecoreAddObserver: statecoreAddObserver, statecoreNotifyAllObservers: statecoreNotifyAllObservers, statecoreDiscard: statecoreDiscard, statecoreIsDiscarded: statecoreIsDiscarded };
return { statecoreGetState: statecoreGetState, statecoreSetState: statecoreSetState, statecoreAddObserver: statecoreAddObserver, statecoreRemoveObserver: statecoreRemoveObserver, statecoreNotifyAllObservers: statecoreNotifyAllObservers, statecoreDiscard: statecoreDiscard, statecoreIsDiscarded: statecoreIsDiscarded };
}};
});
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