tel

0.1.0 • Public • Published

tel

tel is designed to provide a similar feature to RSpec's let function in mocha. For more information on why this is useful, see this stackoverflow question "When to use RSpec let"

build status

Install

tel can be used with Node.js and in modern browsers

Install via npm

npm install tel --save

Or simply copy tel.js into the desired location

Usage

var Tel = require('tel');
var tel = Tel();
 
// Set a value
tel('number', 5);
tel('url', 'http://google.com');
tel.also = 'as property';
 
// Set a lazy value
tel('later', function() {
    return [];
});
 
// Access values by property
5 === tel.number;
 
// Refer to other values
tel('added', function() {
    return tel.later.push(tel.number);
});
 
// Values can also be calculated asynchronously
tel('webpage', function(done) {
    request(tel.url, done);
});
 
// But make sure you access them asynchronously too
tel.webpage(function(err, response, body) {
    console.log(body);
});

Lazy and async values are only ever calculated once per tel() instance.

For more examples, see the unit tests

Readme

Keywords

none

Package Sidebar

Install

npm i tel

Weekly Downloads

203

Version

0.1.0

License

MIT

Last publish

Collaborators

  • glenjamin