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

redux-actions

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-actions - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

43

lib/__tests__/createAction-test.js

@@ -14,9 +14,9 @@ 'use strict';

var type = 'TYPE';
var actionCreator = _.createAction(type, function (b) {
return b;
});
var foobar = { foo: 'bar' };
var action = actionCreator(foobar);
it('returns plain object', function () {
var actionCreator = _.createAction(type, function (b) {
return b;
});
var foobar = { foo: 'bar' };
var action = actionCreator(foobar);
expect(_lodashIsplainobject2['default'](action)).to.be['true'];

@@ -26,6 +26,16 @@ });

it('uses return value as payload', function () {
var actionCreator = _.createAction(type, function (b) {
return b;
});
var foobar = { foo: 'bar' };
var action = actionCreator(foobar);
expect(action.payload).to.equal(foobar);
});
it('has `status` nor any extraneous keys', function () {
it('has no extraneous keys', function () {
var actionCreator = _.createAction(type, function (b) {
return b;
});
var foobar = { foo: 'bar' };
var action = actionCreator(foobar);
expect(action).to.deep.equal({

@@ -38,3 +48,6 @@ type: type,

it('uses identity function if actionCreator is not a function', function () {
expect(_.createAction(type)(foobar)).to.deep.equal({
var actionCreator = _.createAction(type);
var foobar = { foo: 'bar' };
var action = actionCreator(foobar);
expect(action).to.deep.equal({
type: type,

@@ -44,3 +57,19 @@ payload: foobar

});
it('accepts a second parameter for adding meta to object', function () {
var actionCreator = _.createAction(type, null, function (_ref) {
var cid = _ref.cid;
return { cid: cid };
});
var foobar = { foo: 'bar', cid: 5 };
var action = actionCreator(foobar);
expect(action).to.deep.equal({
type: type,
payload: foobar,
meta: {
cid: 5
}
});
});
});
});

8

lib/createAction.js

@@ -9,10 +9,14 @@ 'use strict';

function createAction(type, actionCreator) {
function createAction(type, actionCreator, metaCreator) {
var finalActionCreator = typeof actionCreator === 'function' ? actionCreator : identity;
return function () {
return {
var action = {
type: type,
payload: finalActionCreator.apply(undefined, arguments)
};
if (typeof metaCreator === 'function') action.meta = metaCreator.apply(undefined, arguments);
return action;
};

@@ -19,0 +23,0 @@ }

@@ -20,3 +20,5 @@ 'use strict';

// If function is passed instead of map, use as reducer
if (isFunction(reducers)) return reducers(state, action);
if (isFunction(reducers)) {
reducers.next = reducers;
}

@@ -23,0 +25,0 @@ // Otherwise, assume an action map was passed

{
"name": "redux-actions",
"version": "0.6.0",
"version": "0.7.0",
"description": "Flux Standard Action utlities for Redux",

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

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