New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

async-extend-defaults

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-extend-defaults

Async deep extend and defaults functions

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

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)

Keywords

async

FAQs

Package last updated on 20 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts