Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Super simple DI for JavaScript, targetted mainly at spec test setup
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
package.json
tel.js

README.md

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

Something went wrong with that request. Please try again.