0.0.2 • Published 8 years ago

new-thunk v0.0.2

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

new-thunk - npm

new-thunk is Thunk implementation. it supports browser Chrome, Firefox, ie11, ie9, ie8. (tested) also supports node.js.

INSTALL:

NPM NPM

for node.js

$ npm install new-thunk --save

or

for browsers

https://lightspeedworks.github.io/new-thunk/new-thunk.js

<script src="https://lightspeedworks.github.io/new-thunk/new-thunk.js"></script>

PREPARE:

you can use Thunk.

var Thunk = require('new-thunk');
// you can use Thunk

USAGE:

Thunk Specification

Thunk(setup)

how to make thunk.

thunk = Thunk(
  function setup(callback) {
    // async process -> callback(error, value)
    try { callback(null, 'value'); }
    catch (error) { callback(error); }
  }
);
// setup(
//  function callback(error, value) {},

example

var thunk = Thunk(
  function setup(callback) {
    setTimeout(function () {
      if (Math.random() < 0.5) callback(null, 'value');
      else callback(new Error('error'));
    }, 100);
  }
);

thunk(function callback(error, value) {
  if (error) console.error(error);
  else console.info(value);
});

thunk(callback)

how to use thunk.

thunk = thunk(
  function callback(error, value) {});

example

thunk = thunk(function callback(error, value) {
  if (error) console.error(error);
  else console.info(value);
});

TO DO LIST

To Do List

LICENSE:

MIT

0.0.2

8 years ago

0.0.1

8 years ago

0.0.0

9 years ago