Skip to content

seiyab/that

Repository files navigation

That

that is user-space implementation for call-this, inspired by Call-this operator for JavaScript proposal.

Examples

function increment(this: number): number {
    return this + 1;
}

function add(this: number, another: number): number {
    return this + another;
}

// call-this operator
that(8)
    ['~>'](increment)
    ['~>'](add, 5)
    ['~>'](add, 9)[';'];
// => 23

// Hack pipe
that('Hello, world!')
    ['|>'](($) => $.split(" "))
    ['|>'](($) => $.length)
    ['|>'](($) => Math.pow(3, $))[';'];
// => 9

// Optional chain
that([1, 2, 3, 4])
    ['|>'](($) => $.find((x) => x < 0))
    ['?|>'](($) => $ + 2)[';'];
// => undefined

Installation

npm install @seiyab/that

About

user-space call-this chain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published