How to use the tree-kit/lib/extend.js function in tree-kit

To help you get started, we’ve selected a few tree-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cronvel / async-kit / lib / core.js View on Github external
this.jobsUsing.call( jobContext , job , jobContext.callback ) ;
		}
	}
	else if ( typeof job === 'function' )
	{
		if ( this.waterfallMode && indexOfKey > 0 )
		{
			// remove the first, error arg if waterfallTransmitError is false
			//console.log( index , key , execContext.results ) ;
			args = execContext.results[ execContext.jobsKeys[ indexOfKey - 1 ] ].slice( this.waterfallTransmitError ? 0 : 1 ) ;
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else if ( Array.isArray( this.jobsUsing ) || this.execMappingMaxInputs )
		{
			if ( Array.isArray( this.jobsUsing ) ) { args = treeExtend( null , [] , this.jobsUsing , execContext.execInputs ) ; }
			else { args = treeExtend( null , [] , execContext.execInputs ) ; }
			
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else
		{
			job.call( jobContext , jobContext.callback ) ;
		}
	}
	else if ( Array.isArray( job ) && typeof job[ 0 ] === 'function' )
	{
		args = job.slice( 1 ) ;
		args.push( jobContext.callback ) ;
		job[ 0 ].apply( jobContext , args ) ;
	}
github cronvel / async-kit / browser / async.js View on Github external
this.jobsUsing.call( jobContext , job , jobContext.callback ) ;
		}
	}
	else if ( typeof job === 'function' )
	{
		if ( this.waterfallMode && indexOfKey > 0 )
		{
			// remove the first, error arg if waterfallTransmitError is false
			//console.log( index , key , execContext.results ) ;
			args = execContext.results[ execContext.jobsKeys[ indexOfKey - 1 ] ].slice( this.waterfallTransmitError ? 0 : 1 ) ;
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else if ( Array.isArray( this.jobsUsing ) || this.execMappingMaxInputs )
		{
			if ( Array.isArray( this.jobsUsing ) ) { args = treeExtend( null , [] , this.jobsUsing , execContext.execInputs ) ; }
			else { args = treeExtend( null , [] , execContext.execInputs ) ; }
			
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else
		{
			job.call( jobContext , jobContext.callback ) ;
		}
	}
	else if ( Array.isArray( job ) && typeof job[ 0 ] === 'function' )
	{
		args = job.slice( 1 ) ;
		args.push( jobContext.callback ) ;
		job[ 0 ].apply( jobContext , args ) ;
	}
github cronvel / async-kit / browser / async.js View on Github external
}
	}
	else if ( typeof job === 'function' )
	{
		if ( this.waterfallMode && indexOfKey > 0 )
		{
			// remove the first, error arg if waterfallTransmitError is false
			//console.log( index , key , execContext.results ) ;
			args = execContext.results[ execContext.jobsKeys[ indexOfKey - 1 ] ].slice( this.waterfallTransmitError ? 0 : 1 ) ;
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else if ( Array.isArray( this.jobsUsing ) || this.execMappingMaxInputs )
		{
			if ( Array.isArray( this.jobsUsing ) ) { args = treeExtend( null , [] , this.jobsUsing , execContext.execInputs ) ; }
			else { args = treeExtend( null , [] , execContext.execInputs ) ; }
			
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else
		{
			job.call( jobContext , jobContext.callback ) ;
		}
	}
	else if ( Array.isArray( job ) && typeof job[ 0 ] === 'function' )
	{
		args = job.slice( 1 ) ;
		args.push( jobContext.callback ) ;
		job[ 0 ].apply( jobContext , args ) ;
	}
	else if ( typeof job === 'object' && job instanceof async.Plan )
github cronvel / async-kit / lib / core.js View on Github external
}
	}
	else if ( typeof job === 'function' )
	{
		if ( this.waterfallMode && indexOfKey > 0 )
		{
			// remove the first, error arg if waterfallTransmitError is false
			//console.log( index , key , execContext.results ) ;
			args = execContext.results[ execContext.jobsKeys[ indexOfKey - 1 ] ].slice( this.waterfallTransmitError ? 0 : 1 ) ;
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else if ( Array.isArray( this.jobsUsing ) || this.execMappingMaxInputs )
		{
			if ( Array.isArray( this.jobsUsing ) ) { args = treeExtend( null , [] , this.jobsUsing , execContext.execInputs ) ; }
			else { args = treeExtend( null , [] , execContext.execInputs ) ; }
			
			args.push( jobContext.callback ) ;
			job.apply( jobContext , args ) ;
		}
		else
		{
			job.call( jobContext , jobContext.callback ) ;
		}
	}
	else if ( Array.isArray( job ) && typeof job[ 0 ] === 'function' )
	{
		args = job.slice( 1 ) ;
		args.push( jobContext.callback ) ;
		job[ 0 ].apply( jobContext , args ) ;
	}
	else if ( typeof job === 'object' && job instanceof async.Plan )
github cronvel / async-kit / lib / core.js View on Github external
async.Plan.prototype.execMapping = function execMapping( config )
{
	if ( this.locked )  { return this ; }
	
	config = treeExtend( null , { minInputs: 0 , maxInputs: 0 } , config ) ;
	
	var i , j , maxUnnamed = 5 ;
	
	config.minInputs = parseInt( config.minInputs ) ;
	config.maxInputs = parseInt( config.maxInputs ) ;
	
	if ( config.minInputs < config.maxInputs )
	{
		this.execMappingMinInputs = config.minInputs ;
		this.execMappingMaxInputs = config.maxInputs ;
	}
	else
	{
		// User is stOopid, swap...
		this.execMappingMinInputs = config.maxInputs ;
		this.execMappingMaxInputs = config.minInputs ;
github cronvel / async-kit / lib / core.js View on Github external
error: { value: undefined , writable: true , enumerable: true } ,
			statusTriggerJobsKey: { value: undefined , writable: true , enumerable: true } ,
			whileStatus: { value: undefined , writable: true } ,
				// true if current execContext has looped in another execContext (one loop per execContext possible)
				// false if this execContext will never loop, undefined if this isn't settled
			whileChecked: { value: false , writable: true }
		} ) ;
		
		// Add some properties depending on inherited ExecContext or not
		if ( ! fromExecContext )
		{
			// This is the top-level/first ExecContext
			Object.defineProperties( execContext , {
				root: { value: execContext , enumerable: true } ,
				jobsData: {
					value: ( isArray ? this.jobsData.slice(0) : treeExtend( null , {} , this.jobsData ) ) ,
					enumerable: true
				} ,
				jobsKeys: { value: this.jobsKeys.slice(0) , enumerable: true } ,
				execInputs: { value: config.inputs , enumerable: true } ,
				execCallbacks: { value: config.callbacks } ,
				whileIterator: { value: 0 , enumerable: true , writable: true }
			} ) ;
		}
		else
		{
			// This is a loop, and this ExecContext is derived from the first one
			Object.defineProperties( execContext , {
				root: { value: fromExecContext.root , enumerable: true } ,
				jobsData: { value: fromExecContext.jobsData , enumerable: true } ,
				jobsKeys: { value: fromExecContext.jobsKeys , enumerable: true } ,
				execInputs: { value: fromExecContext.execInputs , enumerable: true } ,
github cronvel / async-kit / browser / async.js View on Github external
error: { value: undefined , writable: true , enumerable: true } ,
			statusTriggerJobsKey: { value: undefined , writable: true , enumerable: true } ,
			whileStatus: { value: undefined , writable: true } ,
				// true if current execContext has looped in another execContext (one loop per execContext possible)
				// false if this execContext will never loop, undefined if this isn't settled
			whileChecked: { value: false , writable: true }
		} ) ;
		
		// Add some properties depending on inherited ExecContext or not
		if ( ! fromExecContext )
		{
			// This is the top-level/first ExecContext
			Object.defineProperties( execContext , {
				root: { value: execContext , enumerable: true } ,
				jobsData: {
					value: ( isArray ? this.jobsData.slice(0) : treeExtend( null , {} , this.jobsData ) ) ,
					enumerable: true
				} ,
				jobsKeys: { value: this.jobsKeys.slice(0) , enumerable: true } ,
				execInputs: { value: config.inputs , enumerable: true } ,
				execCallbacks: { value: config.callbacks } ,
				whileIterator: { value: 0 , enumerable: true , writable: true }
			} ) ;
		}
		else
		{
			// This is a loop, and this ExecContext is derived from the first one
			Object.defineProperties( execContext , {
				root: { value: fromExecContext.root , enumerable: true } ,
				jobsData: { value: fromExecContext.jobsData , enumerable: true } ,
				jobsKeys: { value: fromExecContext.jobsKeys , enumerable: true } ,
				execInputs: { value: fromExecContext.execInputs , enumerable: true } ,
github cronvel / async-kit / lib / core.js View on Github external
async.ExecContext.prototype.getJobsStatus = function getJobsStatus()
{
	var i , key , fullJobsStatus = Array.isArray( this.jobsData ) ? [] : {} ;
	
	for ( i = 0 ; i < this.jobsKeys.length ; i ++ )
	{
		key = this.jobsKeys[ i ] ;
		
		fullJobsStatus[ key ] = treeExtend( null , {
				job: this.jobsData[ key ] ,
				result: this.results[ key ]
			} ,
			this.jobsStatus[ key ]
		) ;
	}
	
	return fullJobsStatus ;
} ;
github cronvel / async-kit / browser / async.js View on Github external
async.ExecContext.prototype.getJobsStatus = function getJobsStatus()
{
	var i , key , fullJobsStatus = Array.isArray( this.jobsData ) ? [] : {} ;
	
	for ( i = 0 ; i < this.jobsKeys.length ; i ++ )
	{
		key = this.jobsKeys[ i ] ;
		
		fullJobsStatus[ key ] = treeExtend( null , {
				job: this.jobsData[ key ] ,
				result: this.results[ key ]
			} ,
			this.jobsStatus[ key ]
		) ;
	}
	
	return fullJobsStatus ;
} ;
github cronvel / async-kit / lib / core.js View on Github external
async.Plan.prototype.clone = function clone()
{
	var asyncPlan = Object.create( async.Plan.prototype , planCommonProperties ) ;
	treeExtend( null , asyncPlan , this ) ;
	asyncPlan.locked = false ;
	return asyncPlan ;
} ;

tree-kit

Tree utilities which provides a full-featured extend and object-cloning facility, and various tools to deal with nested object structures.

MIT
Latest version published 8 months ago

Package Health Score

60 / 100
Full package analysis