Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

Commit

Permalink
refactor utils.map function
Browse files Browse the repository at this point in the history
  • Loading branch information
marklawlor committed Jan 31, 2019
1 parent 5fa0e4d commit 55ffc5e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/appsync-emulator-serverless/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,14 @@ const create = (errors = [], now = new Date()) => ({
},
map: {
copyAndRetainAllKeys(map, keys = []) {
return Object.entries(map).reduce((sum, [key, value]) => {
if (keys.indexOf(key) === -1) return sum;
return {
...sum,
[key]: value,
};
}, {});
const newMap = new Map();
keys.forEach(key => newMap.set(key, map.get(key)));
return newMap;
},
copyAndRemoveAllKeys(map, keys = []) {
const result = { ...map };
for (const key of keys) {
delete result[key];
}
return result;
const newMap = new Map(map);
keys.forEach(key => newMap.delete(key));
return newMap;
},
},
dynamodb: {
Expand Down

0 comments on commit 55ffc5e

Please sign in to comment.