Last active
May 23, 2019 01:44
-
-
Save mokanfar/8c61b80dc4f5d15759489eea241a747f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//find sku in json object list return arg[1] of that object | |
const filterIt = (sku, attr) => { | |
let arr = list.filter(function(asdf) { | |
return asdf.SKU == sku; | |
}); | |
return arr[0][attr]; | |
}; | |
//ramda find without for each | |
R.find(R.propEq('a', 2))(xs) | |
//create your own array by picking stuff out from a master list | |
let temp = []; | |
const firstRound = () => { | |
for (item of list) { | |
temp.push({ | |
parent_sku: item.SKU, | |
wayfair_sku: item.wayfair_sku, | |
child_SKUs: R.split(";", item.shipping_skus) | |
}); | |
} | |
}; | |
//merge 2 json objects by common sku | |
const mergeById = (a1, a2) => | |
a1.map(itm => ({ | |
...itm, | |
...a2.find(item => item.sku === itm.SKU && item) | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment