zeal-redux-utils
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -5,4 +5,22 @@ # Change Log | ||
## [Unreleased](https://github.com/CodingZeal/zeal-redux-utils/compare/v0.2.0...HEAD) | ||
## [Unreleased](https://github.com/CodingZeal/zeal-redux-utils/compare/v0.3.0...HEAD) | ||
## [0.3.0](https://github.com/CodingZeal/zeal-redux-utils/compare/v0.2.0...v0.3.0) - 2016-12-14 | ||
### Changed | ||
* Check for flux standard actions (FSAs) in reducers created by `createReducer`. The check is performed only in development mode. Non-FSA actions raise a `NonStandardAction` exception. See [flux-standard-action](https://github.com/acdlite/flux-standard-action) for a definition of what is an FSA. ([#6](https://github.com/CodingZeal/zeal-redux-utils/pull/6)) | ||
### Added | ||
* Add `nullAction` for use in reducer specs. A `nullAction` is a flux-standard-action-compliant action that shouldn't match any of your normal actions. It can be used to initialize the state in a reducer spec. e.g `const initialState = reducer(undefined, nullAction)` ([#7](https://github.com/CodingZeal/zeal-redux-utils/pull/7)) | ||
### Removed | ||
* Cleaned non-essential files out of the npm package to reduce package size. ([#8](https://github.com/CodingZeal/zeal-redux-utils/pull/8)) | ||
### Internal | ||
* Use [yarn](https://yarnpkg.com/) for all building and scripting tasks. ([#8](https://github.com/CodingZeal/zeal-redux-utils/pull/8)) | ||
## [0.2.0](https://github.com/CodingZeal/zeal-redux-utils/compare/v0.1.1...v0.2.0) - 2016-12-14 | ||
@@ -9,0 +27,0 @@ |
@@ -6,6 +6,34 @@ 'use strict'; | ||
}); | ||
exports.NonStandardAction = undefined; | ||
exports.default = createReducer; | ||
var _fluxStandardAction = require('flux-standard-action'); | ||
var _ramda = require('ramda'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var NonStandardAction = exports.NonStandardAction = function NonStandardAction(action) { | ||
var _this = this; | ||
_classCallCheck(this, NonStandardAction); | ||
this.action = action; | ||
this.message = 'attempting to handle an action that is not a flux-standard-action'; | ||
this.stack = new Error().stack; | ||
this.toString = function () { | ||
return _this.message + ': ' + JSON.stringify(_this.action); | ||
}; | ||
}; | ||
var throwIfNotFSA = function throwIfNotFSA(action) { | ||
if ((0, _fluxStandardAction.isFSA)(action)) return; | ||
throw new NonStandardAction(action); | ||
}; | ||
// eslint-disable-next-line no-process-env | ||
var isProduction = process.env.NODE_ENV === 'production'; | ||
var ensureIsFSA = isProduction ? _ramda.identity : throwIfNotFSA; | ||
function createReducer(initialState, handlers) { | ||
@@ -15,4 +43,7 @@ return function () { | ||
var action = arguments[1]; | ||
ensureIsFSA(action); | ||
return (0, _ramda.propOr)(_ramda.identity, action.type, handlers)(state, action); | ||
}; | ||
} |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.globalizeSelectors = exports.createReducer = exports.createActionTypes = undefined; | ||
exports.nullAction = exports.globalizeSelectors = exports.createReducer = exports.createActionTypes = undefined; | ||
@@ -21,2 +21,6 @@ var _createActionTypes2 = require('./createActionTypes'); | ||
var _nullAction2 = require('./nullAction'); | ||
var _nullAction3 = _interopRequireDefault(_nullAction2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,2 +30,3 @@ | ||
exports.createReducer = _createReducer3.default; | ||
exports.globalizeSelectors = _globalizeSelectors3.default; | ||
exports.globalizeSelectors = _globalizeSelectors3.default; | ||
exports.nullAction = _nullAction3.default; |
{ | ||
"name": "zeal-redux-utils", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Utility functions for working with Redux", | ||
@@ -9,5 +9,5 @@ "main": "lib/index.js", | ||
"clean": "rimraf lib", | ||
"prepublish": "npm test && npm run clean && npm run build", | ||
"prepublish": "yarn test && yarn run clean && yarn build", | ||
"test": "jest", | ||
"test:watch": "npm run test -- --watch" | ||
"test:watch": "yarn test -- --watch" | ||
}, | ||
@@ -29,2 +29,3 @@ "repository": { | ||
"dependencies": { | ||
"flux-standard-action": "^1.0.0", | ||
"ramda": "^0.22.1" | ||
@@ -31,0 +32,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9624
2
9
103
1
+ Addedflux-standard-action@^1.0.0
+ Addedflux-standard-action@1.2.0(transitive)
+ Addedlodash@4.17.21(transitive)