Skip to content

Commit

Permalink
fix(deps): Updated dependencies to allow greenkeper
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Sep 30, 2017
1 parent 2ec8623 commit d1342d0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -28,11 +28,11 @@
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"lint": "npm run lint:eslint",
"lint:eslint": "eslint src/*.js",
"test": "clear && jest",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "clear && jest --watch --coverage",
"lint:test": "npm run lint && npm run test:coverage",
"build": "clear && npm run lint:test && npm run build:cjs && npm run build:es && npm run build:umd",
"build": "npm run lint:test && npm run build:cjs && npm run build:es && npm run build:umd",
"build:watch": "clear && rimraf cjs && cross-env BABEL_ENV=cjs babel -w src --out-dir cjs",
"build:es": "rimraf es && cross-env BABEL_ENV=es babel src --out-dir es",
"build:cjs": "rimraf cjs && cross-env BABEL_ENV=cjs babel src --out-dir cjs",
Expand Down
70 changes: 35 additions & 35 deletions src/index.js
Expand Up @@ -7,45 +7,45 @@ module.exports = (mapDefinition, defaults) => {
defaults = defaults || {};

return originalObj => Traverse(mapDefinition).map(
/*eslint-disable prefer-arrow-callback */
function (item) {

let getMethod = `get`;
let path = item;
let process = x => x;

if (!this.isLeaf) {
const isObject = Object.prototype.toString.apply(item) === `[object Object]`;
const hasAlternatives = isObject && Array.isArray(item.alternatives);
const hasProcessor = isObject && typeof item.processor === `function`;
// not leaf, not alternatives, no processor, this means a regular object so skip
// it
if (!hasAlternatives && !hasProcessor) {
return;
}
if (hasAlternatives) {
path = item.alternatives;
getMethod = `coalesce`;
}
if (hasProcessor) {
if (!hasAlternatives && !item.path) {
console.warn(`You have provided a processor func. without path or alternatives. Null will be returned`);
return null;
/*eslint-disable prefer-arrow-callback */
function (item) {

let getMethod = `get`;
let path = item;
let process = x => x;

if (!this.isLeaf) {
const isObject = Object.prototype.toString.apply(item) === `[object Object]`;
const hasAlternatives = isObject && Array.isArray(item.alternatives);
const hasProcessor = isObject && typeof item.processor === `function`;
// not leaf, not alternatives, no processor, this means a regular object so skip
// it
if (!hasAlternatives && !hasProcessor) {
return;
}
if (hasAlternatives) {
path = item.alternatives;
getMethod = `coalesce`;
}
if (hasProcessor) {
if (!hasAlternatives && !item.path) {
console.warn(`You have provided a processor func. without path or alternatives. Null will be returned`);
return null;
}
path = hasAlternatives
? path
: item.path;
process = item.processor;
}
path = hasAlternatives
? path
: item.path;
process = item.processor;
}
}

let originalValue = Op[ getMethod ](originalObj, path);
// try to use a default value ONLY if the original value is undefined. Values like false, 0, '', null, will pass as they are
originalValue = originalValue === undefined ? Op[ getMethod ](defaults, path) : originalValue;
let originalValue = Op[getMethod](originalObj, path);
// try to use a default value ONLY if the original value is undefined. Values like false, 0, '', null, will pass as they are
originalValue = originalValue === undefined ? Op[getMethod](defaults, path) : originalValue;

const newValue = process(originalValue, originalObj);
const newValue = process(originalValue, originalObj);

this.update(newValue, true);
});
this.update(newValue, true);
});

};

0 comments on commit d1342d0

Please sign in to comment.