fnstuff
Experimental function argument structure helper for Javascript/Coffeescript
Last updated 8 years ago by jaekwon .
Repository · Original npm · Tarball · package.json
$ cnpm install fnstuff 
SYNC missed versions from official npm registry.

Allows the declaration of argument structure.

-   X     : any type. X is a placeholder for the argument name (not used)
-  {X}    : object type
-  "X"    : string type
-  X->    : function type
-     ?   : arg can be 'undefined'
- [    ]  : arg is optional (can be left out)

e.g.:

 myfunc = Fn ' "name" [{options}?] callback-> ', (name, options, callback) ->

The name can be missing from the argument syntax, so the above is the same as...

 myfunc = Fn ' "" [{}?] -> ', (foo, options, cb) ->

Missing arguments are always passed in as 'undefined'.

 myfunc = Fn ' foo bar ', (foo, bar) -> console.log "#{foo} #{bar}"
 myfunc('hello')
 > 'hello undefined'

Extra arguments throw an error.

 myfunc = Fn ' foo bar ', (foo, bar) -> console.log "#{foo} #{bar}"
 myfunc('hello', 'coffee', 'donut') # throws error

Current Tags

  • 0.0.1-alpha                                ...           latest (8 years ago)

1 Versions

  • 0.0.1-alpha                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |