prelude-ls
prelude-ls copied to clipboard
Nice to have functions
# checking for null and undefined
const item =
test |> maybe (.maybe-not-exists-prop) |> maybe (.deeply-prop)
# return new object with additional properties
const item =
test |> extend (new-prop: 1, new-prop2: 2)
LiveScript already has operators for those.
The first is covered by ?.
, or just ?
for short.
item = test?maybe-not-exists-prop?deeply-prop
If you really want it as a function, use the bracketed operator-call shorthand:
item = test |> (?maybe-not-exists-prop) |> (?deeply-prop)
or even just
item = test |> (?maybe-not-exists-prop?deeply-prop)
The second is covered by combining ^^
cloneport and import
(<<<
):
item = ^^test <<< { new-prop1: 1, new-prop2 : 2 }
There's even the infix with
operator as an alias for that combination, since
it's so common:
item = test with new-prop1 : 1, new-prop2 : 2
As usual, you can make it a function if you want:
item = test |> (with new-prop1 : 1, new-prop2 : 2)
Damn, This is beautiful. You are best language designers. guys!!!
There are a lot of developers around me use coffeescript because it is popular. When I try to convince people that livescript is much much better I meet their mind barrier but be patient guys your star time come soon. I cannot use other languages. Livescript the best
because it is popular
So true. Unfortunately.
^^ cloneport
cloneport is actually "with":
$ lsc -le "a with b"
NEWLINE:\n ID:a CLONEPORT:with ID:b NEWLINE:\n