doc
Runtime documentation tool for REPL.
Usage
Have you ever wished you could see docs for the given function right out of
the REPL? If so, this tool is for you!
var doc = require('doc').doc
doc(doc)
function compose() {
doc: "Returns the composition of a list of functions, where each function"
| "consumes the return value of the function that follows. In math"
| "terms, composing the functions `f()`, `g()`, and `h()` produces"
| "`f(g(h()))`."
| "Usage:"
| "var greet = function(name) { return 'hi: ' + name }"
| "var exclaim = function(statement) { return statement + '!' }"
| "var welcome = compose(exclaim, greet)"
| "welcome('moe')"
| "//> 'hi: moe!'"
var funcs = Array.prototype.slice.call(arguments)
return function composed() {
var args = slice.call(arguments)
var i = funcs.length
while (0 <= --i) args = [ funcs[i].apply(this, args) ]
return args[0]
}
}
doc(compose)
function sum(a, b) {
var count = arguments.length, index = 0, value = 0
while (index < count) value += arguments[index++]
return value
}
doc(sum)
Install
npm install doc