mrules-engine
Advanced tools
Comparing version 1.0.8 to 1.1.0
@@ -1,9 +0,13 @@ | ||
const { pathOr } = require('ramda'); | ||
function _pathOr(defaultValue, obj, ...keys) { | ||
return keys.reduce((acc, key) => (acc || {})[key], obj) || defaultValue; | ||
} | ||
; | ||
module.exports = (defaultValue, paths, body) => _pathOr(defaultValue, body, ...paths); | ||
const { unflatten } = require('flat'); | ||
const pathOr = require('./path-or'); | ||
; | ||
; | ||
const extract = (_path, body) => pathOr(null, _path.split('.'), body); | ||
const defaultSelector = (selected) => selected; | ||
const execute = (body, acc, item) => { | ||
const { pathTo, pathFor, fallback = null, selectorFn = defaultSelector, } = item; | ||
const { pathTo, pathFor, fallback = null, selectorFn = (s) => s, } = item; | ||
acc[pathFor] = selectorFn(extract(pathTo, body) || fallback); | ||
@@ -10,0 +14,0 @@ return acc; |
{ | ||
"name": "mrules-engine", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"dependencies": { | ||
"flat": "^4.0.0", | ||
"ramda": "^0.25.0" | ||
"flat": "^4.0.0" | ||
}, | ||
@@ -8,0 +7,0 @@ "main": "dist/rules-engine.js", |
Sorry, the diff of this file is not supported yet
40741
1
7
32
- Removedramda@^0.25.0
- Removedramda@0.25.0(transitive)