redux-collector
Advanced tools
Comparing version 0.1.2 to 1.0.0
@@ -10,4 +10,2 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _collectorReducers = require('./collector-reducers'); | ||
@@ -41,33 +39,23 @@ | ||
return function collectify() { | ||
for (var _len = arguments.length, config = Array(_len), _key = 0; _key < _len; _key++) { | ||
config[_key] = arguments[_key]; | ||
} | ||
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _config$reverse = config.reverse(); | ||
var itemDefaultArg = _ref.itemDefault; | ||
var _ref$add = _ref.add; | ||
var add = _ref$add === undefined ? '@@/COLLECTOR_ADD' : _ref$add; | ||
var _ref$move = _ref.move; | ||
var move = _ref$move === undefined ? '@@/COLLECTOR_MOVE' : _ref$move; | ||
var _ref$swap = _ref.swap; | ||
var swap = _ref$swap === undefined ? '@@/COLLECTOR_SWAP' : _ref$swap; | ||
var _ref$addRange = _ref.addRange; | ||
var addRange = _ref$addRange === undefined ? '@@/COLLECTOR_ADD_RANGE' : _ref$addRange; | ||
var _ref$remove = _ref.remove; | ||
var remove = _ref$remove === undefined ? '@@/COLLECTOR_REMOVE' : _ref$remove; | ||
var _ref$hydrate = _ref.hydrate; | ||
var hydrate = _ref$hydrate === undefined ? '@@/COLLECTOR_HYDRATE' : _ref$hydrate; | ||
var _ref$sort = _ref.sort; | ||
var sort = _ref$sort === undefined ? '@@/COLLECTOR_SORT' : _ref$sort; | ||
var reducerArg = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; | ||
var collectionDefault = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var _config$reverse2 = _slicedToArray(_config$reverse, 2); | ||
var _config$reverse2$ = _config$reverse2[0]; | ||
_config$reverse2$ = _config$reverse2$ === undefined ? {} : _config$reverse2$; | ||
var itemDefaultArg = _config$reverse2$.itemDefault; | ||
var _config$reverse2$$col = _config$reverse2$.collectionDefault; | ||
var collectionDefault = _config$reverse2$$col === undefined ? [] : _config$reverse2$$col; | ||
var _config$reverse2$$add = _config$reverse2$.add; | ||
var add = _config$reverse2$$add === undefined ? '@@/COLLECTOR_ADD' : _config$reverse2$$add; | ||
var _config$reverse2$$mov = _config$reverse2$.move; | ||
var move = _config$reverse2$$mov === undefined ? '@@/COLLECTOR_MOVE' : _config$reverse2$$mov; | ||
var _config$reverse2$$swa = _config$reverse2$.swap; | ||
var swap = _config$reverse2$$swa === undefined ? '@@/COLLECTOR_SWAP' : _config$reverse2$$swa; | ||
var _config$reverse2$$add2 = _config$reverse2$.addRange; | ||
var addRange = _config$reverse2$$add2 === undefined ? '@@/COLLECTOR_ADD_RANGE' : _config$reverse2$$add2; | ||
var _config$reverse2$$rem = _config$reverse2$.remove; | ||
var remove = _config$reverse2$$rem === undefined ? '@@/COLLECTOR_REMOVE' : _config$reverse2$$rem; | ||
var _config$reverse2$$hyd = _config$reverse2$.hydrate; | ||
var hydrate = _config$reverse2$$hyd === undefined ? '@@/COLLECTOR_HYDRATE' : _config$reverse2$$hyd; | ||
var _config$reverse2$$sor = _config$reverse2$.sort; | ||
var sort = _config$reverse2$$sor === undefined ? '@@/COLLECTOR_SORT' : _config$reverse2$$sor; | ||
var _config$reverse2$2 = _config$reverse2[1]; | ||
var reducerArg = _config$reverse2$2 === undefined ? [] : _config$reverse2$2; | ||
var itemDefault = itemDefaultArg === undefined ? reducerArg.defaultsTo : itemDefaultArg; | ||
@@ -83,4 +71,4 @@ | ||
for (var _len2 = arguments.length, rest = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
rest[_key2 - 2] = arguments[_key2]; | ||
for (var _len = arguments.length, rest = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
rest[_key - 2] = arguments[_key]; | ||
} | ||
@@ -113,2 +101,2 @@ | ||
exports.clamp = _lib.clamp; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb2xsZWN0aWZ5LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0FBQUE7Ozs7QUFDQTs7QUFDQTs7OztBQUNBOzs7Ozs7QUFFQSxTQUFTLGVBQVQsQ0FBeUIsR0FBekIsRUFBOEI7QUFDNUIsTUFBSSxJQUFJLENBQUosSUFBUyxJQUFJLE1BQWpCLEVBQXlCO0FBQ3ZCLFVBQU0scUxBQU47QUFDRDtBQUNELFNBQU8sSUFBUDtBQUNEOztBQUVELFNBQVMsbUJBQVQsR0FBMkM7QUFBQSxNQUFkLE9BQWMseURBQUosRUFBSTs7O0FBRXpDLFNBQU8sU0FBUyxVQUFULEdBQStCO0FBQUEsc0NBQVIsTUFBUTtBQUFSLFlBQVE7QUFBQTs7QUFBQSwwQkFZVCxPQUFPLE9BQVAsRUFaUzs7QUFBQTs7QUFBQTtBQUFBLDBEQVloQyxFQVpnQztBQUFBLFFBR3JCLGNBSHFCLHFCQUdsQyxXQUhrQztBQUFBLGtEQUlsQyxpQkFKa0M7QUFBQSxRQUlsQyxpQkFKa0MseUNBSWQsRUFKYztBQUFBLGtEQUtsQyxHQUxrQztBQUFBLFFBS2xDLEdBTGtDLHlDQUs1QixrQkFMNEI7QUFBQSxrREFNbEMsSUFOa0M7QUFBQSxRQU1sQyxJQU5rQyx5Q0FNM0IsbUJBTjJCO0FBQUEsa0RBT2xDLElBUGtDO0FBQUEsUUFPbEMsSUFQa0M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gICAgIHJldHVybiAkJGNvbGxlY3Rvci5zd2FwKHN0YXRlLCBhY3Rpb24sIC4uLnJlc3QpO1xuICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIHJldHVybiAkJGNvbGxlY3Rvci51cGRhdGUoc3RhdGUsIGFjdGlvbiwgLi4ucmVzdCk7XG4gICAgICB9XG4gICAgfVxuICB9XG59XG5cbmV4cG9ydCBkZWZhdWx0IGNvbmZpZ3VyZUNvbGxlY3RpZnkoKTtcbmV4cG9ydCB7Y29uZmlndXJlQ29sbGVjdGlmeSwgY2xhbXB9O1xuIl19 |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var _defaultResolver = require('./default-resolver'); | ||
var _defaultMatcher = require('./default-matcher'); | ||
@@ -55,3 +55,3 @@ var _methodGenerators = require('./method-generators'); | ||
var matcherConfig = matcherArg === undefined ? _defaultResolver.defaultMatcher : _lodash2.default.partialRight(matcherArg, _defaultResolver.defaultMatcher); | ||
var matcherConfig = matcherArg === undefined ? _defaultMatcher.defaultMatcher : _lodash2.default.partialRight(matcherArg, _defaultMatcher.defaultMatcher); | ||
@@ -147,2 +147,2 @@ // Matcher Methods | ||
exports.default = generateCollector; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb2xsZWN0b3ItcmVkdWNlcnMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7QUFBQTs7OztBQUNBOztBQUVBOztBQUNBOztBQUVBOztBQUNBOztBQUNBOzs7O0FBQ0E7Ozs7OztBQUVBLFNBQVMsVUFBVCxDQUFxQixLQUFyQixFQUE0QjtBQUMxQixNQUFJLENBQUMsaUJBQUUsT0FBRixDQUFVLEtBQVYsQ0FBTCxFQUF1QjtBQUNyQix5Q0FBbUMsS0FBSyxTQUFMLENBQWUsS0FBZixDQUFuQztBQUNEO0FBQ0Y7O0FBRUQsU0FBUyxpQkFBVCxHQUErSztBQUFBLG1F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ICAgIGlmIChjb250YWlucyhzb3J0UmVkdWNlcnMsIGtleSkpIHtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIC4uLnBvaW50ZXIsXG4gICAgICAgIFtrZXldOiBfLndyYXAoY29sbGVjdG9yT2JqZWN0W2tleV0sIHNvcnRSZWR1Y2VyV3JhcClcbiAgICAgIH07XG4gICAgfVxuXG4gICAgcmV0dXJuIHtcbiAgICAgIC4uLnBvaW50ZXIsXG4gICAgICBba2V5XTogXy53cmFwKGNvbGxlY3Rvck9iamVjdFtrZXldLCBjb2xsZWN0aW9uUmVkdWNlcldyYXApXG4gICAgfTtcbiAgfSwge30pO1xuXG59XG5cbmV4cG9ydCBkZWZhdWx0IGdlbmVyYXRlQ29sbGVjdG9yO1xuIl19 |
@@ -120,3 +120,3 @@ 'use strict'; | ||
toLimit = end - start; | ||
toLimit = end + 1 - start; | ||
toSkip = start; | ||
@@ -136,7 +136,12 @@ } else if (after !== undefined) { | ||
function normalizeFrom(from) { | ||
return _lodash2.default.isNumber(from) ? { index: from } : _lodash2.default.isArray(from) ? from.length === 2 ? { range: from } : { indexes: from } : _lodash2.default.isFunction(from) ? { query: from } : from; | ||
return _lodash2.default.isNumber(from) ? { index: from } : _lodash2.default.isArray(from) ? { indexes: from } : _lodash2.default.isFunction(from) ? { query: from } : from; | ||
} | ||
function normalizeTo(to) { | ||
return _lodash2.default.isNumber(to) ? { index: to } : _lodash2.default.isArray(to) ? { range: to } : to; | ||
if (_lodash2.default.isArray(to)) { | ||
throw '[Redux Collector] `to` must be a single index. You passed: ' + to; | ||
} | ||
return _lodash2.default.isNumber(to) ? { index: to } : _lodash2.default.isFunction(to) ? { query: to } : to; | ||
} | ||
@@ -150,2 +155,2 @@ | ||
exports.normalizeTo = normalizeTo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9ub3JtYWxpemVycy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjo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AuLi5yZXN0fTtcbn1cblxuZnVuY3Rpb24gbm9ybWFsaXplRnJvbShmcm9tKSB7XG4gIHJldHVybiBfLmlzTnVtYmVyKGZyb20pXG4gICAgPyB7aW5kZXg6IGZyb219XG4gICAgOiBfLmlzQXJyYXkoZnJvbSlcbiAgICAgID8ge2luZGV4ZXM6IGZyb219XG4gICAgICA6IF8uaXNGdW5jdGlvbihmcm9tKVxuICAgICAgICA/IHtxdWVyeTogZnJvbX1cbiAgICAgICAgOiBmcm9tO1xufVxuXG5mdW5jdGlvbiBub3JtYWxpemVUbyh0bykge1xuXG4gIGlmIChfLmlzQXJyYXkodG8pKSB7XG4gICAgdGhyb3cgJ1tSZWR1eCBDb2xsZWN0b3JdIGB0b2AgbXVzdCBiZSBhIHNpbmdsZSBpbmRleC4gWW91IHBhc3NlZDogJyArIHRvO1xuICB9XG5cbiAgcmV0dXJuIF8uaXNOdW1iZXIodG8pXG4gICAgPyB7aW5kZXg6IHRvfVxuICAgIDogXy5pc0Z1bmN0aW9uKHRvKVxuICAgICAgPyB7cXVlcnk6IHRvfVxuICAgICAgOiB0bztcbn1cblxuXG5leHBvcnQge25vcm1hbGl6ZU9yZGVyLCBub3JtYWxpemVTb3J0QXJncywgbm9ybWFsaXplSW5kZXhBcmdzLCBub3JtYWxpemVBY3Rpb24sIG5vcm1hbGl6ZUZyb20sIG5vcm1hbGl6ZVRvfTtcbiJdfQ== |
{ | ||
"name": "redux-collector", | ||
"version": "0.1.2", | ||
"version": "1.0.0", | ||
"description": "Easy Collection Reducers for Redux", | ||
@@ -5,0 +5,0 @@ "main": "lib/redux-collector.js", |
703
README.md
@@ -0,1 +1,6 @@ | ||
[Redux]: https://github.com/reactjs/redux | ||
[Matthew Drake]: http://www.mediadrake.com | ||
[Reducify]: http://reducify.mediadrake.com | ||
[Redux Pipeline]: http://redux-pipeline.mediadrake.com | ||
# Redux Collector [![Build Status](https://travis-ci.org/gtg092x/redux-collector.svg?branch=master)](https://travis-ci.org/gtg092x/redux-collector) | ||
@@ -35,4 +40,3 @@ | ||
export default createStore( | ||
collectify( | ||
counterReducer, | ||
collectify( | ||
{ | ||
@@ -42,3 +46,4 @@ add: 'ADD_ITEM', | ||
remove: 'REMOVE_ITEM' | ||
} | ||
}, | ||
counterReducer | ||
) | ||
@@ -109,10 +114,10 @@ ); | ||
{ | ||
add: 'ADD_ITEM', | ||
hydrate: 'HYDRATE_ITEMS', | ||
remove: 'REMOVE_ITEM' | ||
}, | ||
{ | ||
defaultsTo: 0, | ||
"INCREMENT": state => state + 1, | ||
"DECRAMENT": state => state - 1 | ||
}, | ||
{ | ||
add: 'ADD_ITEM', | ||
hydrate: 'HYDRATE_ITEMS', | ||
remove: 'REMOVE_ITEM' | ||
} | ||
@@ -132,3 +137,3 @@ ) | ||
```js | ||
collectify([[itemReducer<Object|Function>], actionTypes<Object>]); | ||
collectify([actionTypes<Object>, [itemReducer<Object|Function>, collectionDefault<Array>]]); | ||
``` | ||
@@ -161,3 +166,3 @@ | ||
const myReducer = collectify(itemReducer, actionTypes); | ||
const myReducer = collectify(actionTypes, itemReducer); | ||
``` | ||
@@ -185,3 +190,3 @@ | ||
const myStore = createStore(collectify(itemReducer, {hydrate: 'SET_ITEMS'})); | ||
const myStore = createStore(collectify({hydrate: 'SET_ITEMS'}, itemReducer)); | ||
@@ -208,3 +213,3 @@ myStore.dispatch({ | ||
#### collectionDefault | ||
#### Collection Default | ||
@@ -218,3 +223,3 @@ This is the default or initial value of the collection. | ||
const myStore = createStore(collectify(itemReducer, {collectionDefault: [1, 2]})); | ||
const myStore = createStore(collectify({}, itemReducer, [1, 2])); | ||
@@ -237,3 +242,3 @@ myStore.dispatch({ | ||
const myStore = createStore(collectify(itemReducer, {itemDefault: 10, add: 'ADD_ITEM'})); | ||
const myStore = createStore(collectify({itemDefault: 10, add: 'ADD_ITEM'}, itemReducer)); | ||
@@ -261,7 +266,7 @@ myStore.dispatch({ | ||
const myStore = createStore( | ||
collectify( | ||
itemReducer, | ||
collectify( | ||
{ | ||
hydrate: 'HYDRATE_ITEMS' | ||
} | ||
}, | ||
itemReducer | ||
) | ||
@@ -272,3 +277,3 @@ ); | ||
type: 'HYDRATE', | ||
data: [1, 2, 3, 4] // data is required | ||
data: [1, 2, 3, 4] // data is required for HYDRATE | ||
}); | ||
@@ -287,8 +292,8 @@ ``` | ||
const myStore = createStore( | ||
collectify( | ||
itemReducer, | ||
collectify( | ||
{ | ||
itemDefault: 10, | ||
add: 'ADD_ITEM' | ||
} | ||
}, | ||
itemReducer | ||
) | ||
@@ -319,5 +324,5 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
itemReducer, | ||
{ add: 'ADD_ITEM' } | ||
collectify( | ||
{ add: 'ADD_ITEM' }, | ||
itemReducer | ||
) | ||
@@ -353,8 +358,8 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
itemReducer, | ||
collectify( | ||
{ | ||
itemDefault: 10, | ||
addRange: 'ADD_MULTIPLE_ITEMS' | ||
} | ||
}, | ||
itemReducer | ||
) | ||
@@ -385,5 +390,5 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
itemReducer, | ||
{ addRange: 'ADD_MULTIPLE_ITEMS' } | ||
collectify( | ||
{ addRange: 'ADD_MULTIPLE_ITEMS' }, | ||
itemReducer | ||
) | ||
@@ -415,8 +420,8 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
[1, 2, 3, 4], // this is a static reducify reducer - defaulting to this array | ||
collectify( | ||
{ | ||
hydrate: 'HYDRATE_ITEMS', | ||
remove: 'REMOVE_ITEMS' | ||
} | ||
}, | ||
[1, 2, 3, 4] // passing in an object and not a function will make this the default value | ||
) | ||
@@ -493,8 +498,8 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
collectify( | ||
{ | ||
hydrate: 'HYDRATE_ITEMS', | ||
sort: 'SORT_ITEMS' | ||
} | ||
}, | ||
[4, 3, 2, 1] | ||
) | ||
@@ -556,7 +561,7 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
collectify( | ||
{ | ||
move: 'MOVE_ITEMS' | ||
} | ||
}, | ||
[4, 3, 2, 1] | ||
) | ||
@@ -595,7 +600,7 @@ ); | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
collectify( | ||
{ | ||
swap: 'SWAP_ITEMS' | ||
} | ||
}, | ||
[4, 3, 2, 1] | ||
) | ||
@@ -621,35 +626,627 @@ ); | ||
Because we may not always want to change the entire collection, Redux Collector looks for the keyword `query` in your action that you dispatch. This query is processed by the collector matching method. | ||
```js | ||
function increment(state = 0, action) { | ||
switch(action.type) { | ||
case 'INCREMENT': | ||
return state + 1; | ||
default: | ||
return state; | ||
} | ||
} | ||
const myStore = createStore( | ||
collectify( | ||
{ | ||
hydrate: 'HYDRATE_LIST' | ||
}, | ||
increment | ||
) | ||
); | ||
myStore.dispatch({ | ||
type: 'HYDRATE_LIST', | ||
data: [-1, 2, 4] | ||
}); | ||
// state is [-1, 2, 4] | ||
myStore.dispatch({ | ||
type: 'INCREMENT', | ||
query: function(item) { | ||
return item > 0; | ||
} | ||
}); | ||
// all items are incremented by 1 | ||
// state is [-1, 3, 5] | ||
``` | ||
#### Matcher | ||
By default, the matcher used by `query` and `after` inspects your query argument and compares it against every item in the collection. | ||
By default, your query is processed as follows: | ||
##### Undefined | ||
If undefined, we assume you want your operation applied to all items in the list. | ||
##### Function | ||
If a function, we evaluate this function passing in `[state, index]`. Returning `true` will say that query matches the item. Returning `false` will say it doesn't. | ||
##### Array | ||
If you pass an array, we will process every item in the query with against `every` (as an **and**, not **or**). For or, use [$or](#or). This is recursive. | ||
##### Or | ||
If you pass an object with the key `$or`, it must have a child that is an array and we will process this against `some`. This is recursive. | ||
```js | ||
myStore.dispatch({ | ||
type: 'INCREMENT', | ||
query: [ | ||
item => item > 0, | ||
item => item % 2 === 0 | ||
] // all items that are greater than 0 and are even | ||
}); | ||
myStore.dispatch({ | ||
type: 'INCREMENT', | ||
query: { | ||
$or: [ | ||
item => item > 0, | ||
item => item % 2 === 0 | ||
] | ||
} // all items that are greater than 0 or are even | ||
}); | ||
myStore.dispatch({ | ||
type: 'INCREMENT', | ||
query: [ | ||
item => item % 2 === 0 | ||
{ | ||
$or: [ | ||
item => item > 0, | ||
item => item === -2 | ||
] | ||
} | ||
] // all items that are even and are either greater than 0 or equal to -2 | ||
}); | ||
``` | ||
#### Boolean | ||
If `true`, we assume you want your operation applied to all truthy items in the list. | ||
If `false`, we assume you want your operation applied to all falsy items in the list. | ||
#### Object | ||
If you pass an object, we'll pass this to the [lodash function](https://lodash.com/docs#isMatch) `_.isMatch` with the item's state as the first argument. | ||
#### Primitive | ||
If you pass any number or string, we will do a strict equals comparison. | ||
#### Custom | ||
It's possible to customize your matcher function. Use the import `{configureCollectify}` and pass in a matcher argument. | ||
```js | ||
import {configureCollectify} | ||
// We pass you the default matcher so you can add functionality without losing default matching behavior | ||
function matcher(item, test, index, defaultMatcher) { | ||
if (test === 'isOdd') { | ||
return (item % 2) === 1; | ||
} | ||
return defaultMatcher(item, test, index); | ||
} | ||
const myCollectify = configureCollectify({matcher}); | ||
const myColReducer = myCollectify( | ||
{}, | ||
incrementReducer, | ||
[2, 3, 4] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
query: 'isOdd' | ||
}) | ||
// result is [2, 4, 4] | ||
``` | ||
### Operations | ||
#### Order | ||
Beyond queries, there are other ways to apply your partial changes to your collection. These should be familiar to anyone with experience in mongo or other collection libraries. | ||
#### Limit | ||
Limits the number of operations your query will execute. This applies to all reducer behavior and `remove`. | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
limit: 1 | ||
}) | ||
// result would be [2, 2, 3] | ||
``` | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
limit: 1 | ||
}) | ||
// result would be [2, 3] | ||
``` | ||
#### Skip | ||
Skips a number of items before executing your operation. This applies to all reducer behavior and `remove`. | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
skip: 1 | ||
}) | ||
// result would be [1, 3, 4] | ||
``` | ||
Skip and limit can be combined together. | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
skip: 1, | ||
limit: 1 | ||
}) | ||
// result would be [1, 3, 3] | ||
``` | ||
#### Index | ||
A shortcut for `skip = index` and `limit = 1`. Indexes are pythonic, meaning that -1 is equal to the last item in the array. | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
index: 1 | ||
}) | ||
// result would be [1, 3, 3] | ||
``` | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
index: -1 | ||
}) | ||
// result would be [1, 2, 4] | ||
``` | ||
#### Indexes | ||
The same as `index`, but should be an array of indexes. Like `index`, these values are pythonic. | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[1, 2, 3] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
indexes: [0, 2] | ||
}) | ||
// result would be [2] | ||
``` | ||
#### Range | ||
Should be a two dimensional array of pythonic indexes of the form `[start, end]`. | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[1, 2, 3, 4] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
range: [0, 2] | ||
}) | ||
// result would be [4] | ||
``` | ||
#### After | ||
Should be a `query` that, upon first match, will determine the `skip` and `limit`. | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[1, 2, 3, 4] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
after: (arg, index) => arg === 2 | ||
}) | ||
// result would be [1, 2] | ||
``` | ||
Keep in mind, this is only evaluated once. If the after function returns true, the rest of the collection will have operations applied to it. | ||
#### Sort | ||
#### Limit | ||
Sorts the collection before applying operations to it. This uses the same arguments available for `sort`, but does not actually sort your list. This is useful when used in conjunction with any index operators. | ||
```js | ||
function incrementReducer(state = {value: 0}, action) { | ||
switch(action.type) { | ||
case 'INCREMENT': | ||
return {...state, value: state.value + 1}; | ||
default: | ||
return state; | ||
} | ||
} | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
sort: 'ord', | ||
limit : 2 | ||
}) | ||
// result would be [{ord: 1, value: 4}, {ord: 3, value: 5}, {ord: 2, value: 11}] | ||
// notice the second element was not changed | ||
``` | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
sort: 'ord', | ||
limit : 1, | ||
skip: 1 | ||
}) | ||
// result would be [{ord: 1, value: 3}, {ord: 3, value: 5}] | ||
``` | ||
You can pass a function to `sort` if you need to do something more complicated than just checking against a single key. Keep in mind, that `order` can still flip your collection. If you sort by the negative result of a key, your `order` argument might undo that. | ||
```js | ||
// same as above | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
sort: item => item.ord, | ||
limit : 1, | ||
skip: 1 | ||
}) | ||
// result would be [{ord: 1, value: 3}, {ord: 3, value: 5}] | ||
``` | ||
#### Order | ||
This determines the direction your collections's sorting occurs in. If you do not sort your list, it can be used to just reverse the direction your operations are done in. | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[1, 5, 2] | ||
); | ||
// removes the last item in the list | ||
dispatch({ | ||
type: 'REMOVE', | ||
order: -1, | ||
limit : 1 | ||
}) | ||
// result would be [1, 5] | ||
``` | ||
```js | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
sort: 'ord', | ||
order : -1 | ||
}) | ||
// result would be [{ord: 1, value: 3}, {ord: 3, value: 5}] | ||
``` | ||
You can combine `order` and `sort` with a shortcut by passing an object to `sort`. | ||
```js | ||
// same as above | ||
const myColReducer = collectify( | ||
{remove: 'REMOVE'}, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
dispatch({ | ||
type: 'REMOVE', | ||
sort: {ord: -1} | ||
}) | ||
// result would be [{ord: 1, value: 3}, {ord: 3, value: 5}] | ||
``` | ||
### Moving and Sorting | ||
### Indexes | ||
#### Sort List | ||
## Customization | ||
Using the same arguments for [sort](#sort), you can modify the output of your list. | ||
### Matcher | ||
```js | ||
// same as above | ||
const myColReducer = collectify( | ||
{sort: 'SORT'}, | ||
[{ord: 1, value: 3}, {ord: 3, value: 5}, {ord: 2, value: 10}] | ||
); | ||
## Gotchas | ||
dispatch({ | ||
type: 'SORT', | ||
sort: 'ord' | ||
}) | ||
// result would be [{ord: 1, value: 3}, {ord: 2, value: 10}, {ord: 3, value: 5}] | ||
``` | ||
#### Move | ||
Move lets you take a set of `indexes` passed to a `from` argument and places them at a single indexes provided by a `to` argument. | ||
```js | ||
const myColReducer = collectify( | ||
{move: 'MOVE', hydrate: 'HYDRATE'}, | ||
[1, 2, 3, 4, 5] | ||
); | ||
dispatch({ | ||
type: 'MOVE', | ||
from: 1, | ||
to: 0 | ||
}) | ||
// result would be [2, 1, 3, 4, 5] | ||
dispatch({ | ||
type: 'HYDRATE', | ||
data: [1, 2, 3, 4, 5] | ||
}) | ||
dispatch({ | ||
type: 'MOVE', | ||
from: [1, 3], // treated as a list of indexes | ||
to: 0 | ||
}) | ||
// result would be [2, 4, 1, 3, 5] | ||
dispatch({ | ||
type: 'HYDRATE', | ||
data: [1, 2, 3, 4, 5] | ||
}) | ||
dispatch({ | ||
type: 'MOVE', | ||
from: item => item === 3, // treated as a query | ||
to: item => item === 2 // treated as a query, we will only use the first index returned | ||
}) | ||
// result would be [1, 3, 2, 4, 5] | ||
dispatch({ | ||
type: 'HYDRATE', | ||
data: [1, 2, 3, 4, 5] | ||
}) | ||
dispatch({ | ||
type: 'MOVE', | ||
from: {after: item => item > 1}, | ||
to: 0 | ||
}) | ||
// result would be [2, 3, 4, 5, 1] | ||
``` | ||
#### Swap | ||
Swap switches item by index. | ||
```js | ||
const myColReducer = collectify( | ||
{move: 'SWAP'}, | ||
[1, 2, 3, 4, 5] | ||
); | ||
dispatch({ | ||
type: 'SWAP', | ||
indexes: [1, 4] | ||
}) | ||
// result would be [1, 5, 3, 4, 2] | ||
``` | ||
While most `swap` use cases should just take advantage of `indexes`, you can swap more than one item and have everything move in a carousel. | ||
```js | ||
const myColReducer = collectify( | ||
{move: 'SWAP'}, | ||
[1, 2, 3, 4, 5] | ||
); | ||
dispatch({ | ||
type: 'SWAP', | ||
after: item => item === 3 | ||
}) | ||
// result would be [1, 2, 5, 3, 4] | ||
``` | ||
Check out [operations](#operations) for more details. | ||
## Integration | ||
Not every reducer is just a single array. Sometimes your array might be a property on the reducer itself. There's two ways to solve this. | ||
### With Pipeline | ||
The easy way. | ||
[Redux Pipeline]() can you let select object properties to apply certain reducers to. | ||
It would look something like this: | ||
```js | ||
const myState = {items: []}; | ||
function itemReducer(state = 0, action) { | ||
// reducer | ||
} | ||
const myReducer = pipeline( | ||
myState, | ||
{ | ||
$: 'items', | ||
reducer: collectify({ | ||
add: 'ADD', | ||
// etc. | ||
}, itemReducer) | ||
} | ||
); | ||
``` | ||
### Without Pipeline | ||
The slightly more difficult, but not impossible, way. | ||
Track all actions that would apply to your collection and run them through a collectified reducer for that item. It would look like this: | ||
```js | ||
const collectified = collectify({ | ||
add: "ADD" | ||
}, { | ||
"INCREMENT": state => state + 1 | ||
}); | ||
function reducer(state = {items: []}, action = {}) { | ||
switch(action.type) { | ||
case 'ADD': | ||
case 'INCREMENT': | ||
return {...state, items: collectified(state.items, action)}; | ||
default: | ||
return state; | ||
} | ||
} | ||
const store = createStore(reducer); | ||
const {dispatch, getState} = store; | ||
dispatch({type: 'ADD', data: 10}); | ||
// state is {items: [10]} | ||
dispatch({type: 'INCREMENT'}); | ||
// state is {items: [11]} | ||
``` | ||
## Gotchas | ||
### Multiple Aliases | ||
A lot of operations will override behavior of other operations. Mixing them together can lead to odd consequences. We try our best to merge them all, but, when in doubt, either use specific indexes or stick to `skip` and `limit`. | ||
```js | ||
const myColReducer = collectify( | ||
{}, | ||
incrementReducer, | ||
[1, 2, 3, 4] | ||
); | ||
dispatch({ | ||
type: 'INCREMENT', | ||
skip: 1, | ||
index: 0, | ||
limit 2 | ||
}) | ||
// result would be [1, 3, 4] | ||
// index just gets ignored | ||
``` | ||
### Selectors without pipeline | ||
Redux Collector uses [Reducify]() for your reducer config. This means you can pass any reducer function or a configuration. However, Redux Collector only works on collections, so trying to select something with your configuration will throw an error. | ||
```js | ||
const myState = {items: []}; | ||
const myReducer = collectify( | ||
{}, | ||
{ | ||
$: 'items', | ||
"INCREMENT": state => state + 1 | ||
}, | ||
myState | ||
); | ||
// throws an error, use pipeline instead | ||
``` | ||
If you find yourself selecting something within `collectify`, refer to the [With Pipeline](#with-pipeline) section of this readme. | ||
## Credits | ||
Redux Collector is free software under the MIT license. It was created in sunny Santa Monica by [Matthew Drake][]. | ||
[Redux]: https://github.com/reactjs/redux | ||
[Matthew Drake]: http://www.mediadrake.com | ||
[Reducify]: http://reducify.mediadrake.com | ||
[Redux Pipeline]: http://redux-pipeline.mediadrake.com |
@@ -34,3 +34,3 @@ import collectify from '../src/redux-collector'; | ||
const addAction = 'ADD_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
add: addAction | ||
@@ -75,3 +75,3 @@ }); | ||
const setAction = 'SET_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
hydrate: setAction | ||
@@ -91,3 +91,3 @@ }); | ||
const addAction = 'ADD_RANGE_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
addRange: addAction | ||
@@ -149,3 +149,3 @@ }); | ||
const removeAction = 'REMOVE_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
remove: removeAction | ||
@@ -165,2 +165,19 @@ }); | ||
it ("Should support range", function () { | ||
let newArr = myReducer([10, 11, 12, 13], {type: removeAction, range: [0, 2]}); | ||
assert.deepEqual([13], newArr); | ||
}); | ||
it ("Should support after", function () { | ||
let newArr = myReducer([10, 11, 12, 13], {type: removeAction, after: arg => arg === 11}); | ||
assert.deepEqual([10, 11], newArr); | ||
newArr = myReducer([10, 11, 12, 13], {type: removeAction, after: (arg, index) => index === 1}); | ||
assert.deepEqual([10, 11], newArr); | ||
}); | ||
it("Should support query", function() { | ||
@@ -222,3 +239,3 @@ | ||
const sortAction = 'SORT_TEST'; | ||
const myReducer = collectify([], {sort: sortAction}); | ||
const myReducer = collectify({sort: sortAction}); | ||
@@ -269,3 +286,3 @@ checkIntegrity(myReducer, {type: sortAction}); | ||
const moveAction = 'MOVE_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
move: moveAction | ||
@@ -283,3 +300,6 @@ }); | ||
newArr = myReducer([3, 4, 5, 6], {type: moveAction, from: [1, 3], to: 0}); | ||
newArr = myReducer([3, 4, 5, 6, 7], {type: moveAction, from: [2, 4], to: 0}); | ||
assert.deepEqual([5, 7, 3, 4, 6], newArr); | ||
newArr = myReducer([3, 4, 5, 6], {type: moveAction, from: {range: [1, 3]}, to: 0}); | ||
assert.deepEqual([4, 5, 6, 3], newArr); | ||
@@ -292,2 +312,5 @@ | ||
assert.deepEqual([5, 6, 3, 4], newArr); | ||
newArr = myReducer([3, 4, 5, 6], {type: moveAction, from: item => item > 5, to: item => item === 4}); | ||
assert.deepEqual([3, 6, 4, 5], newArr); | ||
}); | ||
@@ -298,3 +321,3 @@ }); | ||
const swapAction = 'SWAP_TEST'; | ||
const myReducer = collectify([], { | ||
const myReducer = collectify({ | ||
swap: swapAction | ||
@@ -315,6 +338,6 @@ }); | ||
describe('item reduce', function () { | ||
const myReducer = collectify({ | ||
const myReducer = collectify({}, { | ||
defaultsTo: [], | ||
"RANDOMIZE": () => randomInt() | ||
}, {}); | ||
}); | ||
@@ -391,3 +414,3 @@ const action = {type: 'RANDOMIZE'}; | ||
const myColReducer = collectify([], { | ||
const myColReducer = collectify({ | ||
add: "ADD_ITEM" | ||
@@ -420,8 +443,7 @@ }); | ||
const myColReducer = configureCollectify({matcher})({ | ||
add: "ADD_ITEM" | ||
}, { | ||
"INCREMENT": state => state + 1, | ||
defaultsTo: 0 | ||
}, { | ||
collectionDefault: [2], | ||
add: "ADD_ITEM" | ||
}); | ||
}, [2]); | ||
@@ -428,0 +450,0 @@ |
@@ -15,7 +15,7 @@ import { createStore, combineReducers } from 'redux'; | ||
const store = createStore(collectify({ | ||
add: "ADD", | ||
remove: "REMOVE" | ||
}, { | ||
defaultsTo: 0, | ||
"INCREMENT": state => state + 1 | ||
}, { | ||
add: "ADD", | ||
remove: "REMOVE" | ||
})); | ||
@@ -50,3 +50,54 @@ | ||
}); | ||
it('integrates into a parent reducer', function () { | ||
const collectified = collectify({ | ||
add: "ADD", | ||
remove: "REMOVE" | ||
}, { | ||
defaultsTo: 0, | ||
"INCREMENT": state => state + 1 | ||
}); | ||
function reducer(state = {items: []}, action = {}) { | ||
switch(action.type) { | ||
case 'ADD': | ||
case 'REMOVE': | ||
case 'INCREMENT': | ||
return {...state, items: collectified(state.items, action)}; | ||
default: | ||
return state; | ||
} | ||
} | ||
const store = createStore(reducer); | ||
const {dispatch, getState} = store; | ||
let toCompare = {items: []}; | ||
dispatch({type: 'ADD'}); | ||
toCompare.items.push(0); | ||
assert.deepEqual(toCompare, getState()); | ||
const toAdd = 10; | ||
dispatch({type: 'ADD', data: toAdd}); | ||
toCompare.items.push(toAdd); | ||
assert.deepEqual(toCompare, getState()); | ||
dispatch({type: 'ADD', data: toAdd}); | ||
toCompare.items.push(toAdd); | ||
dispatch({type: 'INCREMENT'}); | ||
toCompare.items = toCompare.items.map(item => item + 1); | ||
assert.deepEqual(toCompare, getState()); | ||
dispatch({type: 'REMOVE', limit: 1, index: -1}); | ||
toCompare.items.pop(); | ||
assert.deepEqual(toCompare, getState()); | ||
}); | ||
}); | ||
} |
@@ -20,4 +20,4 @@ import pipeline from 'redux-pipeline'; | ||
defaults, | ||
['breads', collectify({'SPOIL_BREAD': spoil}, {add: 'ADD_BREAD'})], | ||
['cheeses', collectify({'SPOIL_CHEESE': spoil}, {add: 'ADD_CHEESE'})], | ||
['breads', collectify({add: 'ADD_BREAD'}, {'SPOIL_BREAD': spoil})], | ||
['cheeses', collectify({add: 'ADD_CHEESE'}, {'SPOIL_CHEESE': spoil})], | ||
{ | ||
@@ -58,6 +58,7 @@ $: 'lunch', | ||
assert.throw(function() { | ||
const spoil = (state) => state + ' - gross'; | ||
pipeline( | ||
defaults, | ||
['breads', collectify({$: 'fail', 'SPOIL_BREAD': spoil}, {add: 'ADD_BREAD'})], | ||
['cheeses', collectify({$: 'fail', 'SPOIL_CHEESE': spoil}, {add: 'ADD_CHEESE'})], | ||
['breads', collectify({add: 'ADD_BREAD'}, {$: 'fail', 'SPOIL_BREAD': spoil})], | ||
['cheeses', collectify({add: 'ADD_CHEESE'}, {$: 'fail', 'SPOIL_CHEESE': spoil})], | ||
{ | ||
@@ -64,0 +65,0 @@ $: 'lunch', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
256873
38
1979
1
1233