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

apothecary

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apothecary - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

53

dist/store.js

@@ -11,32 +11,29 @@ "use strict";

var store = null;
function initialize(initialState) {
if (!store) {
var state = computeState(initialState);
var listeners = [];
var dispatch = function dispatch(action) {
if (action.jam) {
return action(dispatch);
}
var state = computeState(initialState);
var listeners = [];
var dispatch = function dispatch(action) {
if (action.jam) {
return action(dispatch);
}
state = computeState(state, action);
listeners.forEach(function (l) {
return l(state);
});
state = computeState(state, action);
listeners.forEach(function (l) {
return l(state);
});
return state;
};
return {
subscribe: function subscribe(listener) {
return listeners.push(listener);
},
unsubscribe: function unsubscribe(listener) {
return listeners.splice(listeners.indexOf(listener), 1);
},
getState: function getState() {
return state;
};
store = {
subscribe: function subscribe(listener) {
return listeners.push(listener);
},
getState: function getState() {
return state;
},
dispatch: dispatch
};
}
return store;
}
},
dispatch: dispatch
};
}
{
"name": "apothecary",
"version": "0.3.0",
"version": "0.4.0",
"description": "Your local friendly storekeeper",

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

@@ -13,1 +13,15 @@ import initialize from '../src/store';

});
test('ability to unsubscribe', () => {
const store = initialize({ n: 1 });
const inc = state => ({ ...state, n: state.n + 1 });
const callback = jest.fn();
store.subscribe(callback);
store.dispatch(inc);
store.unsubscribe(callback);
store.dispatch(inc);
expect(callback.mock.calls.length).toBe(1);
});
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