redux-collector
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -125,6 +125,7 @@ 'use strict'; | ||
} | ||
if (indexes !== undefined && rest.query === undefined) { | ||
rest.query = function (item, index) { | ||
if (indexes !== undefined) { | ||
var query = rest.query === undefined ? [] : [rest.query]; | ||
rest.query = [].concat(query, [function (item, index) { | ||
return (0, _lib.contains)(indexes, index); | ||
}; | ||
}]); | ||
} | ||
@@ -148,2 +149,2 @@ return _extends({ skip: toSkip, indexes: indexes, limit: toLimit }, rest); | ||
exports.normalizeTo = normalizeTo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9ub3JtYWxpemVycy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBOzs7O0FBRUE7O0FBQ0E7Ozs7Ozs7O0FBRUEsU0FBUyxjQUFULENBQXdCLFFBQXhCLEVBQWtDO0FBQ2hDLE1BQU0sUUFBUSxpQkFBRSxRQUFGLENBQVcsUUFBWCxJQUNWLFNBQVMsV0FBVCxFQURVLEdBRVYsUUFGSjtBQUdBLE1BQUksbUJBQVMsb0JBQVksSUFBckIsRUFBMkIsUUFBM0IsQ0FBSixFQUEwQztBQUN4QyxXQUFPLE1BQVA7QUFDRDtBQUNELE1BQUksbUJBQVMsb0JBQVksR0FBckIsRUFBMEIsUUFBMUIsQ0FBSixFQUF5QztBQUN2QyxXQUFPLEtBQVA7QUFDRDtBQUNELFNBQU8sS0FBUDtBQUNEOztBQUVELFNBQVMsaUJBQVQsT0FBMkQ7QUFBQSxNQUEvQixJQUErQixRQUEvQixJQUErQjtBQUFBLE1BQXpCLE1BQXlCLFFBQXpCLE1BQXlCO0FBQUEsTUFBakIsS0FBaUIsUUFBakIsS0FBaUI7O0FBQUEsTUFBUCxJQUFPOztBQUV6RCxNQUFJLFNBQVMsU0FBVCxJQUFzQixXQUFXLFNBQWpDLElBQThDLFVBQVUsU0FBNUQ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J5ID0gcmVzdC5xdWVyeSA9PT0gdW5kZWZpbmVkID8gW10gOiBbcmVzdC5xdWVyeV07XG4gICAgcmVzdC5xdWVyeSA9IFsuLi5xdWVyeSwgKGl0ZW0sIGluZGV4KSA9PiBjb250YWlucyhpbmRleGVzLCBpbmRleCldO1xuICB9XG4gIHJldHVybiB7c2tpcDogdG9Ta2lwLCBpbmRleGVzLCBsaW1pdDogdG9MaW1pdCwgLi4ucmVzdH07XG59XG5cbmZ1bmN0aW9uIG5vcm1hbGl6ZUZyb20oZnJvbSkge1xuICByZXR1cm4gXy5pc051bWJlcihmcm9tKVxuICAgID8ge2luZGV4OiBmcm9tfVxuICAgIDogXy5pc0FycmF5KGZyb20pXG4gICAgPyBmcm9tLmxlbmd0aCA9PT0gMiA/IHtyYW5nZTogZnJvbX0gOiB7aW5kZXhlczogZnJvbX1cbiAgICA6IF8uaXNGdW5jdGlvbihmcm9tKSA/IHtxdWVyeTogZnJvbX0gOiBmcm9tO1xufVxuXG5mdW5jdGlvbiBub3JtYWxpemVUbyh0bykge1xuICByZXR1cm4gXy5pc051bWJlcih0bylcbiAgICA/IHtpbmRleDogdG99XG4gICAgOiBfLmlzQXJyYXkodG8pXG4gICAgPyB7cmFuZ2U6IHRvfVxuICAgIDogdG87XG59XG5cblxuZXhwb3J0IHtub3JtYWxpemVPcmRlciwgbm9ybWFsaXplU29ydEFyZ3MsIG5vcm1hbGl6ZUluZGV4QXJncywgbm9ybWFsaXplQWN0aW9uLCBub3JtYWxpemVGcm9tLCBub3JtYWxpemVUb307XG4iXX0= |
{ | ||
"name": "redux-collector", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Easy Collection Reducers for Redux", | ||
@@ -5,0 +5,0 @@ "main": "lib/redux-collector.js", |
127
README.md
@@ -469,6 +469,133 @@ # Redux Collector [![Build Status](https://travis-ci.org/gtg092x/redux-collector.svg?branch=master)](https://travis-ci.org/gtg092x/redux-collector) | ||
Sort will make an effort to use the lodash method `_.orderBy`. It will incorporate [order](#order) if it exists in your action. Otherwise, it will just do the sorting. | ||
```js | ||
function itemReducer(state, action) { | ||
// reducer stuff | ||
} | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
{ | ||
hydrate: 'HYDRATE_ITEMS', | ||
sort: 'SORT_ITEMS' | ||
} | ||
) | ||
); | ||
myStore.dispatch({ | ||
type: 'SORT_ITEMS' | ||
}); | ||
// state is [1, 2, 3, 4] | ||
myStore.dispatch({ | ||
type: 'HYDRATE_ITEMS', | ||
[{num: 2}, {num: 3}, {num: 1}] | ||
}); | ||
myStore.dispatch({ | ||
type: 'SORT_ITEMS', | ||
sort: 'num' | ||
}); | ||
// state is [{num: 1}, {num: 2}, {num: 3}] | ||
myStore.dispatch({ | ||
type: 'SORT_ITEMS', | ||
sort: item => item.num | ||
}); | ||
// Same as above | ||
myStore.dispatch({ | ||
type: 'SORT_ITEMS', | ||
sort: () => Math.random() | ||
}); | ||
// state is randomized | ||
// we'll also make an effort to infer order arguments | ||
myStore.dispatch({ | ||
type: 'SORT_ITEMS', | ||
sort: {num: -1} | ||
}); | ||
// state is [{num: 3}, {num: 2}, {num: 1}] | ||
``` | ||
#### Move | ||
Move uses a `from` and a `to` argument to take an item or set of items and move them to another location in your array. | ||
```js | ||
function itemReducer(state, action) { | ||
// reducer stuff | ||
} | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
{ | ||
move: 'MOVE_ITEMS' | ||
} | ||
) | ||
); | ||
myStore.dispatch({ | ||
type: 'MOVE_ITEMS', | ||
from: 0, | ||
to: -1 | ||
}); | ||
// state is [3, 2, 1, 4] | ||
myStore.dispatch({ | ||
type: 'MOVE_ITEMS', | ||
from: [0, 1], | ||
to: -2 | ||
}); | ||
// state is [2, 1, 4, 3] | ||
``` | ||
Your `to` argument should always be a single index. Full on movement mapping is a TODO. | ||
#### Swap | ||
Swap relies on an [index argument](#indexes) to get an array of indexes. The most common use case is two indexes, but sending more than one will result in values rotating like a carousel. | ||
```js | ||
function itemReducer(state, action) { | ||
// reducer stuff | ||
} | ||
const myStore = createStore( | ||
collectify( | ||
[4, 3, 2, 1], | ||
{ | ||
swap: 'SWAP_ITEMS' | ||
} | ||
) | ||
); | ||
myStore.dispatch({ | ||
type: 'SWAP_ITEMS', | ||
indexes: [0, -1] | ||
}); | ||
// state is [1, 3, 2, 4] | ||
myStore.dispatch({ | ||
type: 'SWAP_ITEMS', | ||
range: [0, 2] | ||
}); | ||
// state is [2, 1, 3, 4] | ||
### Queries | ||
@@ -475,0 +602,0 @@ |
@@ -256,2 +256,3 @@ import collectify from '../src/redux-collector'; | ||
assert.deepEqual(toSort.slice(0).reverse(), newArr); | ||
}); | ||
@@ -258,0 +259,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
229495
1906
636