Add deferred properties to an object.

npm install deferred-object
36 downloads in the last month

Deferred Object

Add deferred properties to an object to allow lazy synchronous evaluation of asynchronous properties.

DeferredObject = require 'deferred-object'

obj = new DeferredObject {}
obj.defer 'person', (key, data, callback) ->
    process.nextTick () ->
        thing = new DeferredObject {}
        thing.defer 'name', (key, data, callback) ->
            process.nextTick () ->
                callback null, 'Richard'
        callback null, thing

obj.eval '', () ->
    console.log 'result', arguments
npm loves you