Simple partial application with placeholders, example for discussion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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