cerebral-module-fuse
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -7,6 +7,4 @@ Object.defineProperty(exports, "__esModule", { | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
exports.default = function (modulePath) { | ||
var queryPath = [].concat(_toConsumableArray(modulePath), ['query']); | ||
var queryPath = modulePath + ".query"; | ||
@@ -13,0 +11,0 @@ return function (_ref) { |
@@ -11,10 +11,8 @@ 'use strict'; | ||
var _compute = require('./compute'); | ||
var _computed = require('./computed'); | ||
var _compute2 = _interopRequireDefault(_compute); | ||
var _computed2 = _interopRequireDefault(_computed); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
exports.default = function (_ref) { | ||
@@ -25,6 +23,5 @@ var statePath = _ref.statePath; | ||
return function (module) { | ||
var modulePath = module.name.split('.'); | ||
var modulePath = module.name; | ||
module.addState({ | ||
statePath: statePath, | ||
options: options, | ||
@@ -39,6 +36,7 @@ query: null | ||
module.addServices({ | ||
fuse: (0, _compute2.default)(modulePath), | ||
queryPath: [].concat(_toConsumableArray(modulePath), ['query']) | ||
get: function get(state) { | ||
return state.computed((0, _computed2.default)({ modulePath: modulePath, statePath: statePath })); | ||
} | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "cerebral-module-fuse", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "A cerebral module that adds fuzzy search to data in store", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"lint": "standard src/**/*.js test/**/*.js --verbose | snazzy", | ||
"start": "parallelshell 'babel src --watch --out-dir lib' 'watch --wait=1 \"npm run lint && mocha --compilers js:babel-core/register --recursive --reporter dot\" src test'", | ||
"start": "parallelshell 'babel src --watch --out-dir lib' 'watch --wait=1 \"npm run lint && mocha --compilers js:babel-core/register --recursive\" src test'", | ||
"prebuild": "npm run lint", | ||
@@ -37,21 +37,23 @@ "build": "rimraf lib && babel src --out-dir lib", | ||
"devDependencies": { | ||
"babel": "^6.5.1", | ||
"babel-cli": "^6.5.1", | ||
"babel-core": "^6.5.1", | ||
"babel-preset-es2015": "^6.5.0", | ||
"baobab": "^2.3.3", | ||
"cerebral": "^0.33.24", | ||
"babel": "^6.5.2", | ||
"babel-cli": "^6.11.4", | ||
"babel-core": "^6.11.4", | ||
"babel-preset-es2015": "^6.9.0", | ||
"cerebral": "^0.35.7", | ||
"cerebral-model-baobab": "^0.4.7", | ||
"cerebral-testable": "^0.3.2", | ||
"chai": "^3.5.0", | ||
"eslint": "^2.0.0-rc.0", | ||
"mocha": "^2.4.5", | ||
"mocha": "^3.0.0", | ||
"parallelshell": "^2.0.0", | ||
"rimraf": "^2.5.1", | ||
"snazzy": "^2.0.1", | ||
"standard": "^6.0.4", | ||
"watch": "^0.17.1" | ||
"rimraf": "^2.5.4", | ||
"snazzy": "^4.0.0", | ||
"standard": "^7.1.2", | ||
"watch": "^0.19.1" | ||
}, | ||
"dependencies": { | ||
"fuse.js": "^1.3.1" | ||
"fuse.js": "^2.3.0" | ||
}, | ||
"peerDependencies": { | ||
"cerebral": "^0.35.0" | ||
} | ||
} |
@@ -17,7 +17,7 @@ # cerebral-module-fuse | ||
import controller from './controller' | ||
import fuse form 'cerebral-module-fuse' | ||
import fuse from 'cerebral-module-fuse' | ||
controller.modules({ | ||
findUsers: fuse({ | ||
statePath: ['users'], // statePath should point to either an object or array in the store | ||
statePath: 'users', // statePath should point to either an object or array in the store | ||
options: { keys: ['firstName', 'lastName'] } // options are passed on to fuse.js | ||
@@ -33,20 +33,15 @@ }) | ||
```js | ||
import React from 'react'; | ||
import { Decorator as Cerebral } from 'cerebral-view-react'; | ||
import fuse from 'cerebral-module-fuse/compute'; | ||
import React from 'react' | ||
import { connect } from 'cerebral-view-react' | ||
import fuse from 'cerebral-module-fuse/computed' | ||
@Cerebral({ | ||
users: fuse(['findUsers']) // where fuse is given the path to the module state | ||
}) | ||
class App extends React.Component { | ||
render() { | ||
return ( | ||
<ul> | ||
{this.props.users.map(user => ( | ||
<li>{`${user.firstName} ${user.lastName}`}</li> | ||
))} | ||
</ul> | ||
); | ||
} | ||
} | ||
export default connect({ | ||
users: fuse({ modulePath: 'findUsers', statePath: 'users' }) | ||
}, ({ users }) => ( | ||
<ul> | ||
{users.map(user => ( | ||
<li>{`${user.firstName} ${user.lastName}`}</li> | ||
))} | ||
</ul> | ||
)) | ||
``` | ||
@@ -60,7 +55,7 @@ | ||
you can also access the filtered data from an action via the provided services | ||
you can also access the filtered data from an action via the provided service | ||
```js | ||
export default myAction({ state, services: { findUsers } }) { | ||
const users = state.get(findUsers.fuse) | ||
const users = findUsers.get(state) | ||
} | ||
@@ -77,2 +72,2 @@ ``` | ||
* `npm run lint` lints the code | ||
* `npm run build` compiles es6 to es5 | ||
* `npm run build` compiles es2015 to es5 |
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
14
88
7262
2
70
+ Addedbaobab@2.6.1(transitive)
+ Addedcerebral@0.35.9(transitive)
+ Addedcerebral-model@0.1.1(transitive)
+ Addedcerebral-model-immutable@0.1.5(transitive)
+ Addedcerebral-operators@0.2.5(transitive)
+ Addedcerebral-url-scheme-compiler@0.5.3(transitive)
+ Addedd@1.0.2(transitive)
+ Addedemmett@3.2.0(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfuse.js@2.7.4(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedstate-tree@0.3.1(transitive)
+ Addedtype@2.7.3(transitive)
- Removedfuse.js@1.3.1(transitive)
Updatedfuse.js@^2.3.0