Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save babakness/ba3c2ac03b030cecceca8a64877a79f4 to your computer and use it in GitHub Desktop.
Save babakness/ba3c2ac03b030cecceca8a64877a79f4 to your computer and use it in GitHub Desktop.
Simple partial application with placeholders, example for discussion
export class Placeholder {}
export const _ = new Placeholder()
export const isPlaceholder = placeholder => placeholder instanceof Placeholder
export function bind( ...placeholders ) {
return ( ...fillers ) => this.call( this, ...placeholders.map(
item => isPlaceholder( item ) ? fillers.shift() : item
) )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment