Skip to content

Instantly share code, notes, and snippets.

@MikeyBurkman
Last active September 23, 2016 17:57
Show Gist options
  • Save MikeyBurkman/46f81047b753a22134a90a446d00e2c0 to your computer and use it in GitHub Desktop.
Save MikeyBurkman/46f81047b753a22134a90a446d00e2c0 to your computer and use it in GitHub Desktop.
TS Example
const foo = [{
id: 1,
name: 'Mike'
}, {
id: 2,
name: 'Tom'
}, {
id: 3,
name: 'Sally'
}];
function nameLengthGreaterThan(x: number) {
return (namedThing: {name: string}) => namedThing.name.length > x;
}
const longNames = foo
.filter(nameLengthGreaterThan(4))
.map(person => person.name)
console.log(longNames);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment