basic-fsa-factories
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -9,6 +9,3 @@ "use strict"; | ||
return keys.reduce(function (handlers, key) { | ||
const factory = factories[key]; | ||
handlers[key] = function (...args) { | ||
dispatch(factory(...args)); | ||
}; | ||
handlers[key] = createDispatcher(dispatch, factories[key]); | ||
return handlers; | ||
@@ -22,8 +19,13 @@ }, {}); | ||
return function (dispatch) { | ||
return function (...args) { | ||
dispatch(factory(...args)); | ||
}; | ||
return createDispatcher(dispatch, factory); | ||
}; | ||
} | ||
exports.createActionDispatcher = createActionDispatcher; | ||
function createDispatcher(dispatch, factory) { | ||
return function (...args) { | ||
const action = factory(...args); | ||
if (action) | ||
dispatch(action); | ||
}; | ||
} | ||
function createActionFactories(specs) { | ||
@@ -30,0 +32,0 @@ return Object.keys(specs).reduce(function (factories, key) { |
@@ -1,1 +0,1 @@ | ||
"use strict";function t(t){const n=e(t),r=Object.keys(n);return function(t){return r.reduce(function(e,r){const c=n[r];return e[r]=function(...n){t(c(...n))},e},{})}}function n(t,n=c){const e=r(t,n);return function(t){return function(...n){t(e(...n))}}}function e(t){return Object.keys(t).reduce(function(n,e){const c=t[e];return n[e]="function"==typeof c?c:Array.isArray(c)?r(c[0],c[1]):r(c),n},{})}function r(t,n=c){return function(...e){const r=n(...e);return{type:t,payload:r}}}function c(t){return t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createActionDispatchers=t,exports.createActionDispatcher=n,exports.createActionFactories=e,exports.createActionFactory=r; | ||
"use strict";function t(t){const n=r(t),c=Object.keys(n);return function(t){return c.reduce(function(r,c){return r[c]=e(t,n[c]),r},{})}}function n(t,n=o){const r=c(t,n);return function(t){return e(t,r)}}function e(t,n){return function(...e){const r=n(...e);r&&t(r)}}function r(t){return Object.keys(t).reduce(function(n,e){const r=t[e];return n[e]="function"==typeof r?r:Array.isArray(r)?c(r[0],r[1]):c(r),n},{})}function c(t,n=o){return function(...e){const r=n(...e);return{type:t,payload:r}}}function o(t){return t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createActionDispatchers=t,exports.createActionDispatcher=n,exports.createActionFactories=r,exports.createActionFactory=c; |
{ | ||
"name": "basic-fsa-factories", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "basic (0.3kB) partial implementation of some common flux standard action (FSA) factories to instantiate action factories and dispatchers", | ||
@@ -16,4 +16,4 @@ "main": "dist/index.min.js", | ||
"pretest:web": "rimraf spec/web/*.js && npm run pretest", | ||
"test:web": "browserify spec/*.spec.js -g uglifyify -p bundle-collapser/plugin -p [ common-shakeify -v ] | uglifyjs -c -m toplevel -o spec/web/index.spec.js && npm run test:web:serve", | ||
"uglify": "uglifyjs dist/index.js -c -m toplevel -o dist/index.min.js" | ||
"test:web": "browserify spec/*.spec.js -g uglifyify -p bundle-collapser/plugin -p [ common-shakeify -v ] | terser -c -m toplevel -o spec/web/index.spec.js && npm run test:web:serve", | ||
"uglify": "terser dist/index.js -c -m toplevel -o dist/index.min.js" | ||
}, | ||
@@ -44,14 +44,15 @@ "keywords": [ | ||
"@types/es6-promise": "^3.3.0", | ||
"browserify": "^16.2.2", | ||
"browserify": "^16.2.3", | ||
"bundle-collapser": "^1.3.0", | ||
"common-shakeify": "^0.4.6", | ||
"http-server": "^0.11.1", | ||
"jasmine": "^3.1.0", | ||
"jasmine": "^3.3.0", | ||
"rimraf": "^2.6.2", | ||
"tsify": "^4.0.0", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.9.1", | ||
"uglifyify": "^5.0.0" | ||
"terser": "^3.10.12", | ||
"tsify": "^4.0.1", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.6", | ||
"uglifyify": "^5.0.1" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -54,2 +54,5 @@ # basic Flux Standard Action factories | ||
note that when a factory function returns nothing or something falsy, | ||
the dispatcher is not called. | ||
# TypeScript | ||
@@ -56,0 +59,0 @@ although this library is written in [TypeScript](https://www.typescriptlang.org), |
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
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
19193
61
77
12