Operators
:: operator
This provides a shortcut to the prototype operator. Without a preceed class, it will assume to be the last reference class or function defintion
Animal = {} ::fast = function() { return this.speed > 100 } ::alive = true
Mammal = {} ::legs = function() { return 4 } Mammal::lungs = true
.= and ||= and <–
2 extra assignment operators, ||=
and .=
. They work in a similar method as +=
etc.
location.href .= replace "?old", "?new" name .= toUpperCase() opts ||= {}
Also an extend operator ><–
This creates a new object as opposed to overwriting, so you will need to assign it
a <- b options = options <- { size: "small", num: 10}
pipe
This is probably one of the most unusual features of Kaffeine. It provides an alternative calling method than can be used for chaining (UNIX style passing)
Exmamples
result = input | fn args
Chaining input to output
result = input | fn a, b | fn2 c | fn3 d
For example, it is very useful for ruby style enumeration chaining without using prototypes, and other utilities
| = require "pipe_utils" People | map { #.name } | detect { #.length > 3 } opts = opts | extend default 5 | times { if(!send()) return false } names | asyncMap (name, fn) { user = User.find! {name: name} fn(user) }, complete
pipe_utils
is a v useful utility belt full of functions, available on npm and github