Skip to content

Instantly share code, notes, and snippets.

@TylerGarlick
Created August 4, 2022 01:13
Show Gist options
  • Save TylerGarlick/15c1964634c734a6fe2408313634f6c0 to your computer and use it in GitHub Desktop.
Save TylerGarlick/15c1964634c734a6fe2408313634f6c0 to your computer and use it in GitHub Desktop.
const perms = [{active: true, name: 'tyler'}, {active: false, name: 'Kyle'}]
const updatedPerms = [{active: false, name: 'tyler'}, {active: false, name: 'Kyle'}]
const someMethod = (original: unknown[], newValue: unknown[]) => original.filter(o => Boolean(o['active'] === !newValue.some(n => n['active'] && n['name'] === o['name'])))
console.log(someMethod(perms, updatedPerms))
// {
// op: replace
// path: "active"
// value: array['active']
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment