Skip to content

Instantly share code, notes, and snippets.

@airton
Created June 5, 2018 19:08
Show Gist options
  • Save airton/9e7ae695885a6591328894ca528eebb0 to your computer and use it in GitHub Desktop.
Save airton/9e7ae695885a6591328894ca528eebb0 to your computer and use it in GitHub Desktop.
console.log('arrayHashs',arrayHashs)
const array = arrayHashs.reduce((prev, curr) => {
let newJson = [],
json
const hasPercent = curr.Hash.indexOf('%') > -1
console.log(curr.Hash.indexOf('%') > -1)
if( hasPercent ) {
json = decrypt(curr.Hash.split('%')[0])
} else {
json = decrypt(curr.Hash)
}
if(json) {
newJson = Object.keys(json).reduce((pr,cur) => {
return pr.concat({ 'name': json[cur]['name'], 'email': json[cur]['email']})
}, []);
console.log('newJson',newJson)
}
const newArray = {
...newJson[0],
'hash': curr.Hash
};
return prev.concat(newArray)
}, [])
console.log('array',array)
console.log('array',JSON.stringify(array))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment