Typedef can be used on the server with NodeJS or on the client, built with Browserify, so install with npm:
npm install typedef
This is the
extends function that is used in Typescript, Coffeescript, ES6
compilers, etc. It uses prototypes to setup something similar to to classical
var extends_ = require'typedef'extends;console.log'base ctor';console.log'hello from base class';extends_Child Base;// Call base constructorChildSuperapplythis arguments;console.log'child ctor';console.log'hello from child class';var foo = ;// base ctor// child ctorfoomethod;// hello from base classfoomethod2;// hello from child classfoo instanceof Child;// truefoo instanceof Base;// true
Class composition method. Mixin methods into
Mixin is a constructor function (class), then mixin all static properties
Constructor, and everything on
Mixin is just a Plain Old Object, then simply add
the members of
Get the name of all the parameters or name for function
var getArguments = require'typedef'getArguments;var getName = require'typedef'getName;getArgumentsfoo;// ['a', 'b', 'c']getNamefoo;// 'foo'
The library files are all decorated with JSDoc3-style
annotations that work great with the Tern code inference
system. Combined with the Node plugin (see this project's
file), you can have intelligent autocomplete for methods in this library.
Testing is done with Tape and can be run
with the command
Automated CI cross-browser testing is provided by Testling.
Copyright 2014 Brandon Valosek
Typedef is released under the MIT license.