This package has been deprecated

Author message:

Obsolete

async-extend-defaults

0.0.1 • Public • Published

async.extend & async.defaults

Simple async function to extend or defaults object. Extends async module.

Install

If you use in your project any other async function from async module (of course you are :) ), please make sure that you install async module into your node_modules. It is desirable to use in your project one instance of async module. Read about Node.JS Folders and Modules dependencies.

npm install async

npm install async-extend-defaults

Usage

var asyncExtend = require('async-extend-defaults').extend
var asyncDefaults = require('async-extend-defaults').defaults
 
var extendableObject = {deep: {yes: true}, one: 1}
 
asyncExtend(
    extendableObject,
    {two: 2},
    {deep: {yes: 'it is'}},
    function (extended) {
        console.log(extended === extendableObject) // true
 
        console.log(extended) // {deep: {yes: 'it is'}, one: 1, two: 2}
    }
)
 
 
var defaultsObject = {deep: {yes: true}, one: 1}
 
asyncDefaults(
    defaultsObject,
    {one: 'no'},
    {two: 2},
    {deep: {yes: 'it is'}},
    function (options) {
        console.log(options === defaultsObject) // true
 
        console.log(options) // {deep: {yes: true}, one: 1, two: 2}
    }
)

If you want async clone object then you can do:

var asyncExtend = require('async-extend-defaults').extend
 
asyncExtend({}, sourceObject, function (clone) {})

If you have installed async module, and install async-extend-defaults after async, you can use module like this:

// Order is not important
var async = require('async')
 
// Require once in project
require('async-extend-defaults')
 
// extend and defaults function extends async
async.extend()
async.defaults()

License

(MIT License)

Package Sidebar

Install

npm i async-extend-defaults

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • radist2s