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.8.0 to 0.9.0

19

lib/__tests__/createAction-test.js

@@ -70,3 +70,22 @@ 'use strict';

});
it('sets error to true if payload is an Error object', function () {
var actionCreator = _.createAction(type);
var errObj = new TypeError('this is an error');
var errAction = actionCreator(errObj);
expect(errAction).to.deep.equal({
type: type,
payload: errObj,
error: true
});
var foobar = { foo: 'bar', cid: 5 };
var noErrAction = actionCreator(foobar);
expect(noErrAction).to.deep.equal({
type: type,
payload: foobar
});
});
});
});

15

lib/createAction.js

@@ -13,9 +13,20 @@ 'use strict';

return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var action = {
type: type,
payload: finalActionCreator.apply(undefined, arguments)
payload: finalActionCreator.apply(undefined, args)
};
if (typeof metaCreator === 'function') action.meta = metaCreator.apply(undefined, arguments);
if (args.length === 1 && args[0] instanceof Error) {
// Handle FSA errors where the payload is an Error object. Set error.
action.error = true;
}
if (typeof metaCreator === 'function') {
action.meta = metaCreator.apply(undefined, args);
}
return action;

@@ -22,0 +33,0 @@ };

2

lib/handleAction.js

@@ -21,3 +21,3 @@ 'use strict';

if (isFunction(reducers)) {
reducers.next = reducers;
reducers.next = reducers['throw'] = reducers;
}

@@ -24,0 +24,0 @@

@@ -7,3 +7,3 @@ 'use strict';

function ownKeys(object) {
if (typeof Reflect !== 'undefined') {
if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
return Reflect.ownKeys(object);

@@ -10,0 +10,0 @@ }

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

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

@@ -12,2 +12,5 @@ redux-actions

```
```js
import { createAction, handleAction, handleActions } from 'redux-actions';
```

@@ -31,2 +34,19 @@ ### `createAction(type, payloadCreator = Identity, ?metaCreator)`

If the payload is an instance of an [Error
object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error),
redux-actions will automatically set ```action.error``` to true.
Example:
```js
const increment = createAction('INCREMENT');
const error = new TypeError('not a number');
expect(increment(error)).to.deep.equal({
type: 'INCREMENT',
payload: error,
error: true
});
```
**NOTE:** The more correct name for this function is probably `createActionCreator()`, but that seems a bit redundant.

@@ -81,3 +101,3 @@

redux-actions is handy all by itself, however, it's real power comes when you combine it with middleware.
redux-actions is handy all by itself, however, its real power comes when you combine it with middleware.

@@ -87,3 +107,3 @@ The identity form of `createAction` is a great way to create a single action creator that handles multiple payload types. For example, using [redux-promise](https://github.com/acdlite/redux-promise) and [redux-rx](https://github.com/acdlite/redux-rx):

```js
let addTodo = createAction('ADD_TODO');
const addTodo = createAction('ADD_TODO');

@@ -90,0 +110,0 @@ // A single reducer...

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