Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derek-adair/7b0d0598faf5f5dba574d453fd8ead32 to your computer and use it in GitHub Desktop.
Save derek-adair/7b0d0598faf5f5dba574d453fd8ead32 to your computer and use it in GitHub Desktop.
//Object.keys returns an array like ['username/clipname': {name: clipname, mp3_file:<link_to_mp3>}]
userClips = Object.keys(clips)
// filter the array to only include those that start with the username
.filter(clip => !clip.indexOf(`${username}/`))
// reduces the original object key array using object explode syntax
.reduce((obj, key)=>{
return {
// obj is exploded, its the accumulation of the reduce
...obj,
// inserts the clip into the accumulator
[key]:clips[key]
}
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment