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

delux

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delux - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

use.test.js

45

bin/index.js

@@ -186,2 +186,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -219,6 +221,31 @@

* Append middleware
* @param {function} middleware
* @param {function|string|object} middleware
*/
value: function use(middleware) {
this.middlewares.push(middleware);
var _this = this;
var _arguments = Array.prototype.slice.call(arguments);
var arg0 = _arguments[0];
var arg1 = _arguments[1];
({
function: function _function() {
return _this.middlewares.push(middleware);
},
string: function string() {
return _this.middlewares.push(function (action) {
if (action.type === arg0) {
arg1(action);
}
});
},
object: function object() {
return _this.middlewares.push(function (action) {
if (arg0[action.type]) {
arg1[action.type](action);
}
});
}
})[typeof arg0 === 'undefined' ? 'undefined' : _typeof(arg0)]();
}

@@ -234,3 +261,3 @@ /**

value: function dispatch(action) {
var _this = this;
var _this2 = this;

@@ -245,3 +272,3 @@ var _iteratorNormalCompletion = true;

_this.queue(function () {
_this2.queue(function () {
return Promise.resolve(middleware(action));

@@ -270,6 +297,6 @@ });

return this.queue(function () {
return Promise.all(Object.keys(_this).filter(function (name) {
return _this[name] instanceof Collection && _this[name].reducers[action.type];
return Promise.all(Object.keys(_this2).filter(function (name) {
return _this2[name] instanceof Collection && _this2[name].reducers[action.type];
}).map(function (name) {
var collection = _this[name];
var collection = _this2[name];
var state = collection.state;

@@ -291,3 +318,3 @@ var reducers = collection.reducers;

observer(Object.assign(_this.state, _defineProperty({}, name, newCollectionState)), action, name);
observer(Object.assign(_this2.state, _defineProperty({}, name, newCollectionState)), action, name);
}

@@ -312,3 +339,3 @@ } catch (err) {

})).then(function () {
return _this.state;
return _this2.state;
});

@@ -315,0 +342,0 @@ });

92

package.json
{
"name": "delux",
"version": "1.3.0",
"description": "Beautiful, light and simple state manager inspired by Redux",
"main": "bin/index.js",
"repository": {
"type": "git",
"url": "git@github.com:aniddan/delux.git"
},
"keywords": [
"state",
"manager",
"immutable",
"redux",
"flux"
],
"scripts": {
"start": "webpack --progress --watch",
"build": "webpack --progress",
"test": "jest"
},
"author": "Iddan Aharonson <mail@iddan.co> (http://iddan.co)",
"license": "MIT",
"bugs": {
"url": "https://github.com/aniddan/delux/issues"
},
"homepage": "https://github.com/aniddan/delux",
"dependencies": {
"es6-promise": "3.2.1"
},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-0": "^6.5.0",
"jest": "^16.0.0",
"webpack": "^2.1.0-beta.25"
},
"babel": {
"presets": [
"es2015",
"stage-0"
]
},
"jest": {
"testEnvironment": "node"
}
"name": "delux",
"version": "1.4.0",
"description": "Beautiful, light and simple state manager inspired by Redux",
"main": "bin/index.js",
"repository": {
"type": "git",
"url": "git@github.com:aniddan/delux.git"
},
"keywords": [
"state",
"manager",
"immutable",
"redux",
"flux"
],
"scripts": {
"start": "webpack --progress --watch",
"build": "webpack --progress",
"test": "jest"
},
"author": "Iddan Aharonson <mail@iddan.co> (http://iddan.co)",
"license": "MIT",
"bugs": {
"url": "https://github.com/aniddan/delux/issues"
},
"homepage": "https://github.com/aniddan/delux",
"dependencies": {
"es6-promise": "3.2.1"
},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-0": "^6.5.0",
"jest": "^16.0.0",
"webpack": "^2.1.0-beta.25"
},
"babel": {
"presets": [
"es2015",
"stage-0"
]
},
"jest": {
"testEnvironment": "node"
}
}

@@ -67,3 +67,3 @@ <h1>

Returns an object with mutations of the collections' states
Object with mutations of the collections' states.

@@ -74,3 +74,3 @@ ##### Methods

Dispatches a [Flux Standard Action][FSA] on the state
Dispatches a [Flux Standard Action][FSA] on the state.

@@ -88,3 +88,3 @@ ```JavaScript

The mutated store state
A promise which resolves to the the mutated store state.

@@ -115,5 +115,3 @@ ###### Store.prototype.observe()

```JavaScript
store.use((action) => {
});
store.use(middleware|type|{type: middleware});
```

@@ -125,2 +123,4 @@

- **type** - action type to apply middleware on.
##### Store.prototype.queue()

@@ -127,0 +127,0 @@

const Collection = require('./collection');
const {forceArray, getByKeys} = require('./utils');
/**
* The Store holds the whole application state and it's mutation logic.
*/
module.exports = class Store {
middlewares = [];
queued = Promise.resolve();
/**
* object with mutations of the collections' states
*/
state = {

@@ -13,12 +19,25 @@ get (collections) {

/**
* Append middleware
* @param {function} middleware
* Adds an observer for mutations in the store's collections
* @param {function|string|object} middleware|type|{type:middleware}
*/
use (middleware) {
this.middlewares.push(middleware);
const [arg0, arg1] = arguments;
({
function: () => this.middlewares.push(middleware),
string: () => this.middlewares.push((action) => {
if (action.type === arg0) {
arg1(action);
}
}),
object: () => this.middlewares.push((action) => {
if (arg0[action.type]) {
arg1[action.type](action);
}
})
})[typeof arg0]();
}
/**
* Dispatch an action
* Dispatches a Flux Standard Action on the state.
* @param {object} action
* @returns {Promise} - resolves after the store state mutate
* @returns {Promise} - resolves to the mutated store state.
*/

@@ -57,3 +76,3 @@ dispatch (action) {

/**
* Observe collections changes
* Adds an observer for mutations in the store's collections.
* @param {string | array} collectionNames - collections to observe

@@ -68,3 +87,3 @@ * @param {function} observer

/**
* Queue an action in the store's queue
* Adds a function to the store's execute queue
* @param {function} action

@@ -71,0 +90,0 @@ * @returns {Promise} - resolves after the action resolves.

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