New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alt

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alt - npm Package Compare versions

Comparing version 0.13.9 to 0.13.10

CHANGELOG.md

31

dist/alt-with-runtime.js

@@ -269,4 +269,10 @@ "use strict";

value: function createStore(StoreModel, iden) {
var _this6 = this;
var saveStore = arguments[2] === undefined ? true : arguments[2];
var storeInstance = undefined;
var key = iden || StoreModel.displayName || StoreModel.name;
if (saveStore && this.stores[key]) {
throw new ReferenceError("A store named " + key + " already exists, double check your store names or pass in\nyour own custom identifier for each store");
}
// Creating a class here so we don't overload the provided store's

@@ -294,3 +300,3 @@ // prototype with the mixin behaviour and I'm extending from StoreModel

getInstance: function () {
return _this6.stores[key];
return storeInstance;
}

@@ -301,11 +307,10 @@ });

if (this.stores[key]) {
throw new ReferenceError("A store named " + key + " already exists, double check your store names or pass in\nyour own custom identifier for each store");
storeInstance = assign(new AltStore(this.dispatcher, store), getInternalMethods(StoreModel, builtIns));
if (saveStore) {
this.stores[key] = storeInstance;
saveInitialSnapshot(this, key);
}
this.stores[key] = assign(new AltStore(this.dispatcher, store), getInternalMethods(StoreModel, builtIns));
saveInitialSnapshot(this, key);
return this.stores[key];
return storeInstance;
},

@@ -321,10 +326,6 @@ writable: true,

var ActionsClass = function ActionsClass() {
return this.createActions(function () {
var _ref;
babelHelpers.classCallCheck(this, ActionsClass);
(_ref = this).generateActions.apply(_ref, actionNames);
};
return this.createActions(ActionsClass);
});
},

@@ -331,0 +332,0 @@ writable: true,

@@ -279,4 +279,10 @@ "use strict";

value: function createStore(StoreModel, iden) {
var _this6 = this;
var saveStore = arguments[2] === undefined ? true : arguments[2];
var storeInstance = undefined;
var key = iden || StoreModel.displayName || StoreModel.name;
if (saveStore && this.stores[key]) {
throw new ReferenceError("A store named " + key + " already exists, double check your store names or pass in\nyour own custom identifier for each store");
}
// Creating a class here so we don't overload the provided store's

@@ -304,3 +310,3 @@ // prototype with the mixin behaviour and I'm extending from StoreModel

getInstance: function () {
return _this6.stores[key];
return storeInstance;
}

@@ -311,11 +317,10 @@ });

if (this.stores[key]) {
throw new ReferenceError("A store named " + key + " already exists, double check your store names or pass in\nyour own custom identifier for each store");
storeInstance = assign(new AltStore(this.dispatcher, store), getInternalMethods(StoreModel, builtIns));
if (saveStore) {
this.stores[key] = storeInstance;
saveInitialSnapshot(this, key);
}
this.stores[key] = assign(new AltStore(this.dispatcher, store), getInternalMethods(StoreModel, builtIns));
saveInitialSnapshot(this, key);
return this.stores[key];
return storeInstance;
},

@@ -331,10 +336,6 @@ writable: true,

var ActionsClass = function ActionsClass() {
return this.createActions(function () {
var _ref;
_classCallCheck(this, ActionsClass);
(_ref = this).generateActions.apply(_ref, actionNames);
};
return this.createActions(ActionsClass);
});
},

@@ -341,0 +342,0 @@ writable: true,

@@ -1,15 +0,14 @@

var MIXIN_REGISTRY = '_alt store listener registry_'
var Subscribe = require('./Subscribe')
var ListenerMixin = {
componentWillMount: function () {
Subscribe.create(this)
},
componentWillUnmount: function () {
this[MIXIN_REGISTRY] && this[MIXIN_REGISTRY].forEach(function (x) {
x.store.unlisten(x.handler)
})
this[MIXIN_REGISTRY] = []
Subscribe.destroy(this)
},
listenTo: function (store, handler) {
this[MIXIN_REGISTRY] = this[MIXIN_REGISTRY] || []
this[MIXIN_REGISTRY].push({ store: store, handler: handler })
store.listen(handler)
Subscribe.add(this, store, handler)
},

@@ -19,4 +18,8 @@

stores.forEach(function (store) {
this.listenTo(store, handler);
}, this);
this.listenTo(store, handler)
}, this)
},
getListeners: function () {
return Subscribe.listeners(this)
}

@@ -23,0 +26,0 @@ }

@@ -1,2 +0,3 @@

var MIXIN_REGISTRY = '_alt store listener registry_'
var Symbol = require('es-symbol')
var MIXIN_REGISTRY = Symbol('alt store listeners')

@@ -8,4 +9,3 @@ var Subscribe = {

add: function (context, store, fn) {
var handler = fn.bind(context)
add: function (context, store, handler) {
context[MIXIN_REGISTRY].push({ store: store, handler: handler })

@@ -20,2 +20,6 @@ store.listen(handler)

context[MIXIN_REGISTRY] = []
},
listeners: function (context) {
return context[MIXIN_REGISTRY]
}

@@ -22,0 +26,0 @@ }

{
"name": "alt",
"version": "0.13.9",
"version": "0.13.10",
"description": "A flux implementation",

@@ -26,6 +26,6 @@ "main": "dist/alt.js",

"build-alt-runtime": "babel --external-helpers src/alt.js > dist/alt-with-runtime.js",
"coverage": "istanbul cover _mocha -- -u exports -R list --compilers js:babel/register test/index.js",
"coverage": "istanbul cover _mocha -- -u exports -R list --compilers js:babel/register --require babel/external-helpers test",
"prepublish": "npm test",
"test": "npm run build; npm run tests-all",
"tests-all": "mocha -u exports -R list --compilers js:babel/register test/index.js"
"tests-all": "mocha -u exports -R list --compilers js:babel/register --require babel/external-helpers test"
},

@@ -32,0 +32,0 @@ "keywords": [

@@ -9,4 +9,19 @@ class ReactComponent {

static test(Component, testFn, props) {
let component = new Component()
let builtInProto = Object.getOwnPropertyNames(Component.prototype)
// A trolol way of doing the react <0.13 auto-binding.
function AutoBoundComponent() {
Component.call(this)
builtInProto.forEach((method) => {
if (method !== 'constructor') {
this[method] = this[method].bind(this)
}
})
}
AutoBoundComponent.prototype = Component.prototype
// initialize the component
let component = new AutoBoundComponent()
Component.mixins.forEach((mixin) => {

@@ -26,2 +41,3 @@ // transfer over the mixins.

// call the lifecycle methods and the test function
try {

@@ -43,2 +59,3 @@ component.props = component.getDefaultProps

} finally {
// end with last lifecycle method
component.componentWillUnmount && component.componentWillUnmount();

@@ -45,0 +62,0 @@ }

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

import 'babel/external-helpers'
import Alt from '../dist/alt-with-runtime'

@@ -13,2 +11,4 @@ import assert from 'assert'

import makeFinalStore from '../utils/makeFinalStore'
let alt = new Alt()

@@ -900,13 +900,16 @@

// set up
ListenerMixin.componentWillMount()
ListenerMixin.listenTo(myStore, handler)
assert.equal(ListenerMixin['_alt store listener registry_'].length, 1, 'mixin has one handler')
assert.equal(ListenerMixin.getListeners().length, 1, 'mixin has one handler')
ListenerMixin.componentWillUnmount()
assert.equal(ListenerMixin['_alt store listener registry_'].length, 0, 'mixin was unmounted')
assert.equal(ListenerMixin.getListeners().length, 0, 'mixin was unmounted')
ListenerMixin.listenToMany([myStore, secondStore], handler)
assert.equal(ListenerMixin['_alt store listener registry_'].length, 2, 'mixin has two handlers')
assert.equal(ListenerMixin.getListeners().length, 2, 'mixin has two handlers')

@@ -916,3 +919,3 @@ // tear it down

assert.equal(ListenerMixin['_alt store listener registry_'].length, 0, 'mixin was unmounted')
assert.equal(ListenerMixin.getListeners().length, 0, 'mixin was unmounted')
},

@@ -1145,4 +1148,73 @@

},
'do not include store in snapshots'() {
function NoBootstrap() { }
alt.createStore(NoBootstrap, 'NoBootstrap', false)
let snapshot = JSON.parse(alt.takeSnapshot())
assert.equal(typeof snapshot.NoBootstrap, 'undefined', 'Store does not exist in snapshots')
assert.equal(typeof snapshot.AltSecondStore, 'object', 'AltSecondStore exists')
},
'make final store'() {
function Action() { this.generateActions('set') }
let action = alt.createActions(Action)
function Store1() {
this.bindActions(action)
this.value = null
}
Store1.prototype.set = function () {
this.value = 1
}
function Store2() {
this.bindActions(action)
this.value = null
}
Store2.prototype.set = function () {
this.value = 2
}
function Store3() {
this.bindActions(action)
this.value = null
}
Store3.prototype.set = function () {
this.value = 3
}
// I put these out of order intentionally because order shouldn't
// determine when these get called, the finalstore should always be last.
let store1 = alt.createStore(Store1)
let FinalStore = makeFinalStore(alt)
let store2 = alt.createStore(Store2)
let store3 = alt.createStore(Store3)
let finalStoreCalls = 0
FinalStore.listen(() => {
assert.equal(++finalStoreCalls, 1, 'final store was called only once')
assert.equal(store1.getState().value, 1, 'store1 value correct')
assert.equal(store2.getState().value, 2, 'store2 value correct')
assert.equal(store3.getState().value, 3, 'store3 value correct')
})
let store2Calls = 0
store2.listen(() => {
assert.equal(++store2Calls, 1, 'store 2 listen was only called once')
assert.equal(store2.getState().value, 2, 'store2 state was updated successfully')
})
// Fire off the action
action.set()
},
}
export default tests
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