JSPM

object-filler

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q26737F
  • License MIT

asynchronously resolve object properties

Package Exports

  • object-filler

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object-filler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

object-filler

populate the values of an object with asynchronous functions

e.g

var fill = require("object-filler");

var populateMe = {
    payments: function (cb) {
   
        // do something async
        setTimeout(function () {
       
            // err = undefined, data = [{...}]
            return cb(undefined, [{amount: 10, id: 19274}]); 
        }, 2000);
    },
    // properties can be nested as much as you like
    attributes: {
        members: function (cb) {
            
            // do something else async
            setTimeout(function () {
           
                // err = undefined, data = [{...}]
                return cb(undefined, [{name: "Cervantes", id: 88831}]); 
            }, 2000);
        }
    }
};

fill(populateMe, function (err, populatedObject) {

    /**
     *  populatedObject = {
     *    payments: [{amount: 10, id: 19274}],
     *    attributes: {
     *      members: [{name: "Cervantes", id: 88831}]
     *    }
     *  }
     */
    console.log(populatedObject);
});