0.13.3 • Published 9 years ago

try v0.13.3

Weekly downloads
17
License
MIT
Repository
github
Last release
9 years ago

Try.js

Examples are the best source of documentation - read spec/ directory content to find some of those.

install

npm install try

async usage (read directory content)

var Try = require('try'),
    fs = require('fs');

new Try
    (function () {
        //this.pause() method returns a "resume" callback and pauses current execution.
        fs.readdir('./spec', this.pause());
    })
    (function (err, files) {
        if (err) { throw err; }
        var next = this.pause(files.length);

        files.forEach(function (file) {
            console.log('file', file);
            fs.readFile('./spec/' + file, next);
        });
    })
    (function () {
        return Array.prototype.map.call(arguments, function (args) {
            return args[1].toString();
        }).join('');
    })
    (function (result) {
        dirContent = result;
    })
    .catch(function (err) {
        console.log('catch', err.stack);
    })
    .run();

sync usage

var Try = require('try'),
    result = 0;

new Try
    (function () {
        return 1;
    })
    (function (n) {
        return n + 1;
    })
    (function (n) {
        return n * 2;
    })
    (function (n) {
        result = n;
    })();

expect(result).toBe(4);

more examples

For more examples check out the spec/ directory

0.13.3

9 years ago

0.13.2

10 years ago

0.13.1

10 years ago

0.13.0

10 years ago

0.12.0

10 years ago

0.11.1

10 years ago

0.11.0

10 years ago

0.10.3

10 years ago

0.10.2

10 years ago

0.10.1

10 years ago

0.10.0

10 years ago

0.9.1

10 years ago

0.9.0

10 years ago

0.8.1

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.0

11 years ago

0.3.6

11 years ago

0.3.5

11 years ago

0.3.4

11 years ago

0.3.3

11 years ago

0.3.2

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago