JavaScript Type Promotion.
Usage
// ES5var promote = ; // ES6;
promote(obj: object, promotype: callable, opts?: object): Promise
- obj: object
- An object, not
undefined
ornull
- promotype: callable
- The type to which the given object should be promoted to
- opts: object
- unsafe: boolean =
false
true
= Also allow promotion for incompatible types- strict: boolean =
false
true
= The object will be checked if it's already an instance of the given type
- unsafe: boolean =
promoteSync(obj: object, promotype: callable, opts?: object): boolean
- obj: object
- @see
promote()
- promotype: callable
- @see
promote()
- opts: object
- @see
promote()
- silent: boolean =
false
true
= No exceptions will be thrown
- silent: boolean =
Function bind (ES7)
let thing = ;thing; thing::; if thing:: thing;
Examples
One-Two
; : void { console; console;} name: string; { thisname = name; } { return thisname; } { return `²`; } let foo = name: "foo"; ; let bar = "bar";bar:: ;
> babel-node examples/one-twofoo name: foo²bar name: bar²
HTTP server with promoted response
;; { this; this; } { super { res::; }; if typeof requestListener === "function" this; } let server = { res;};server;
> babel-node examples/httpServer running at http://localhost:8080/