Skip to content

Commit

Permalink
Require Node.js 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 31, 2019
1 parent 1568b19 commit 783ca58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_js:
- '12'
- '10'
- '8'
- '6'
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const isObject = value =>
!(value instanceof Date);

const mapObject = (object, fn, options, isSeen = new WeakMap()) => {
options = Object.assign({
options = {
deep: false,
target: {}
}, options);
target: {},
...options
};

if (isSeen.has(object)) {
return isSeen.get(object);
Expand All @@ -23,14 +24,12 @@ const mapObject = (object, fn, options, isSeen = new WeakMap()) => {
const {target} = options;
delete options.target;

const mapArray = array => array.map(x => isObject(x) ? mapObject(x, fn, options, isSeen) : x);
const mapArray = array => array.map(element => isObject(element) ? mapObject(element, fn, options, isSeen) : element);
if (Array.isArray(object)) {
return mapArray(object);
}

/// TODO: Use `Object.entries()` when targeting Node.js 8
for (const key of Object.keys(object)) {
const value = object[key];
for (const [key, value] of Object.entries(object)) {
let [newKey, newValue] = fn(key, value, object);

if (options.deep && isObject(newValue)) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -36,7 +36,7 @@
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}

0 comments on commit 783ca58

Please sign in to comment.