tc39 / proposal-bind-operator

This-Binding Syntax for ECMAScript
1.74k stars 30 forks source link

a bit like Lua ! #40

Open weepy opened 7 years ago

weepy commented 7 years ago

Lua does something similar - from https://www.lua.org/pil/5.html

An expression like o:foo(x) is just another way to write o.foo(o, x), that is, to call o.foo adding o as a first extra argument. 

It wouldn't help with using const {map} = Array.prototype but it would allow functional thisless pure pipelines. E.g:

a::map( upperCase )::filter( s => s.length > 5 )  

would be compiled to

filter( map(a, upperCase), (s) => s.length > 5)

Allowing functions to be written like like :

function upperCase(name) {
    return name.toUpper()
}
calebmer commented 7 years ago

Also see https://github.com/mindeavor/es-pipeline-operator