there's no one style for expressing a node api, but here are some common patterns with explanations:
Produces a new REPO with name name
. Valid opts
keys include
db
(required) - uses the levelup instancedb
count
(optional) - does the thingcount
times
Shows how to create an instance of an object.
opts
is indicated to be the empty object by default, and its required and optional parameters are detailed.
Puts r
to work. If hard
is true
, it'll even work pretty hard at it. cb
will be called with the result of the work.
A method on the object. More importantly the indicator that it accepts a callback function (
cb
orcallback
are both popular names). The callback's parameters are named inwork
's signature.
r
implements a readable stream or writeable stream, respectively.
r
inheritsReadable
orWriteable
, or both.
r
can raise an event named 'foo'
with the argument bar
.
r
is an EventEmitter, and is known to emit an event with the given name. The callback that is ultimately called has the expected parameterbar
.