0.0.4 • Published 8 years ago

unto v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

unto

This library extends Object.prototype with a single function, unto. unto accepts a callback, and calls it with the object it was called on.

All objects can method chain with anonymous callbacks.

Installation

npm install unto

Example

require('unto').englobal()
// this defines a getter on Object.prototype which binds context

[ 'all things whatsoever ye desire'
, 'that men should do'
].unto((you) =>
  you.concat('so shall ye do')
).unto((them) =>
  them.concat('for this is the law and the prophets')
)
/* -->
[ 'all things whatsoever ye desire',
  'that men should do',
  'so shall ye do',
  'for this is the law and the prophets' ]
*/

Call unto on any object. It takes a callback and aditional parameters. The calling context becomes the first argument

'foo'.unto((a,b,c) => [a,b,c], 'bar', 'baz')
// -> [ 'foo', 'bar', 'baz' ]

When .unto is called, the object is bound, so binding any other context will not override it.

Note:

To use unto in the repl, you need the option useGlobal: true.

An example repl with unto exposed is provided in this repository. You can run it from the shel with $ ./repl.

License

MIT

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago