lazylet
lazylet is a lazy-evaluation system for use in your specs.
Variables are defined within an environment object and are lazily computed on demand. A variable can hold either a value, function or object. If the variable is a function it used for computing the value of the variable when it is accessed from the environment.
Variables are accessed from the environment as if they are plain JS properties. Under the hood, the properties are defined using Object.defineProperty with a 'get' accessor in order that their value can be computed on demand.
WARNING: LazyLet is not yet stable. The API may change significantly before 1.0.0 and there may be show-stopping bugs.
Installation
Add it to your package.json or npm install lazylet
.
Usage
var LazyLet = env = LazyLet Let = envLet; ;
Caveats
To set a variable with a value that is a function, nest it within another function (to avoid ambiguity with dynamically computing a value), like so:
env;
Running the specs
Run make spec
.
Install the wach
node module if you would like to have the specs run
automatically when the source or specs are modified.
npm install -g wach
make watch
Contributing
- Fork it ( https://github.com/freshtonic/lazylet/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Licence
Copyright (c) 2014, lazylet is developed and maintained by James Sadler, and is released under the open MIT Licence.