How to use tree-kit - 10 common examples

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 / terminal-kit / lib / termconfig / linux.js View on Github external
this.root.gpmHandler.on( 'mouse' , ( name , data ) => {
		self.root.emit( 'mouse' , name , data ) ;
	} ) ;
	this.root.gpmHandler.on( 'error' , ( /* error */ ) => {
		//console.log( 'mouseDrag error:' , error ) ;
	} ) ;
}




/* Key Mapping */



var keymap = tree.extend( null , Object.create( xterm.keymap ) , {

	F1: '\x1b[[A' ,
	F2: '\x1b[[B' ,
	F3: '\x1b[[C' ,
	F4: '\x1b[[D' ,
	F5: '\x1b[[E' ,

	SHIFT_F1: '\x1b[25~' ,
	SHIFT_F2: '\x1b[26~' ,
	SHIFT_F3: '\x1b[28~' ,
	SHIFT_F4: '\x1b[29~' ,
	SHIFT_F5: '\x1b[31~' ,
	SHIFT_F6: '\x1b[32~' ,
	SHIFT_F7: '\x1b[33~' ,
	SHIFT_F8: '\x1b[34~' ,
	// SHIFT F9-F12 is not supported by the Linux console
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 / kung-fig / lib / kungFigAsync.js View on Github external
configPath = paths.configDir + paths.configFile ;

		if ( options.baseDir && ! options.baseDir.some( e => configPath.startsWith( e ) ) ) {
			throw new Error( 'Cannot load config file, path denied by baseDir option: ' + configPath_ ) ;
		}
	}

	//console.log( '\n### Trying:' , configPath , "\n" ) ;

	// Search the cache
	if ( options.fileObjectMap.has( configPath ) ) {
		// Found in the cache, exit now!
		required = options.fileObjectMap.get( configPath ) ;
		config = required instanceof kungFig.kfgCommon.KFG ? required.data : required ;

		if ( innerPath ) { config = tree.path.get( config , innerPath ) ; }
		return config ;
	}

	try {
		config = required = await this.requireAsync( configPath , paths.configExt , options ) ;
	}
	catch ( error_ ) {
		if ( error_.metaTagsOnly ) { throw error_ ; }

		error = new Error( 'Cannot load config file: ' + configPath + ' (' + error_ + ')' ) ;
		error.from = error_ ;
		error.badContent = error_.code !== 'MODULE_NOT_FOUND' ;
		error.code = error_.code ;
		throw error ;
	}
github cronvel / http-requester / lib / HttpRequester.js View on Github external
if ( ! streams.output ) {
		this.displayBody( body , incomingMessage ) ;
		this.displayTrailer( incomingMessage ) ;
	}

	term.dim.magenta( '[Received ' + ( body ? utils.byteString( body.length ) + ' ' : '' ) + 'in ' + this.lastResponse.time + 'ms]\n' ) ;

	// Various stuff
	switch ( incomingMessage.status ) {
		case 200 :
		case 201 :
			// Add a new entry to pathCompletion
			pathArray = ( query.hostname + ':' + query.port + query.pathname ).split( '/' ) ;
			if ( pathArray[ pathArray.length - 1 ] === '' ) { pathArray.pop() ; }
			tree.path.define( this.pathCompletion , pathArray , true ) ;
			break ;
		case 404 :
			// Remove the entry from pathCompletion
			pathArray = ( query.hostname + ':' + query.port + query.pathname ).split( '/' ) ;
			if ( pathArray[ pathArray.length - 1 ] === '' ) { pathArray.pop() ; }
			tree.path.delete( this.pathCompletion , pathArray ) ;
			break ;
	}

	// Handle redirections
	if ( incomingMessage.headers && incomingMessage.headers.location ) {
		switch ( incomingMessage.status ) {
			case 301 :
			case 307 :
			case 308 :
				command = { outputFile: command.outputFile , inputFile: command.inputFile } ;
github cronvel / http-requester / lib / shell.js View on Github external
if ( ! streams.output ) {
		this.displayBody( query , body , incomingMessage ) ;
		this.displayTrailer( query , incomingMessage ) ;
	}

	term.dim.magenta( '[Received ' + ( body ? this.byteString( body.length ) + ' ' : '' ) + 'in ' + this.lastResponse.time + 'ms]\n' ) ;

	// Various stuff
	switch ( incomingMessage.status ) {
		case 200 :
		case 201 :
			// Add a new entry to pathCompletion
			pathArray = ( query.hostname + ':' + query.port + query.pathname ).split( '/' ) ;
			if ( pathArray[ pathArray.length - 1 ] === '' ) { pathArray.pop() ; }
			tree.path.define( pathCompletion , pathArray , true ) ;
			break ;
		case 404 :
			// Remove the entry from pathCompletion
			pathArray = ( query.hostname + ':' + query.port + query.pathname ).split( '/' ) ;
			if ( pathArray[ pathArray.length - 1 ] === '' ) { pathArray.pop() ; }
			tree.path.delete( pathCompletion , pathArray ) ;
			break ;
	}

	// Handle redirections
	if ( incomingMessage.headers && incomingMessage.headers.location ) {
		switch ( incomingMessage.status ) {
			case 301 :
			case 307 :
			case 308 :
				command = { shellConfig: query.shellConfig } ;
github cronvel / terminal-kit / lib / termconfig / eterm-256color.js View on Github external
var eterm = require( './eterm.js' ) ;

var	esc = tree.extend( { own: true } , Object.create( xterm256.esc ) , eterm.esc , {

	color24bits: { on: '%D%D%D' , na: true } ,	// not capable
	bgColor24bits: { on: '%D%D%D' , na: true }	// not capable
} ) ;


// So far, we derivate from xterm-256color and then just add specific things (owned properties)
// of Eterm, thus we achieve a clean inheritance model without duplicated code.

module.exports = {
	esc: esc ,
	keymap: tree.extend( { own: true } , Object.create( xterm256.keymap ) , eterm.keymap ) ,
	handler: tree.extend( { own: true } , Object.create( xterm256.handler ) , eterm.handler ) ,
	support: {
		deltaEscapeSequence: true ,
		"256colors": true ,
		"24bitsColors": false ,  // DEPRECATED
		"trueColor": false
	} ,
	colorRegister: eterm.colorRegister
} ;
github cronvel / terminal-kit / lib / termconfig / gnome-256color.js View on Github external
"use strict" ;



var tree = require( 'tree-kit' ) ;
var xterm256 = require( './xterm-256color.js' ) ;
var gnome = require( './gnome.js' ) ;



// Remove colors
var defaultColor = '\x1b[39m' ; // back to the default color, most of time it is the same than .white
var bgDefaultColor = '\x1b[49m' ;   // back to the default color, most of time it is the same than .bgBlack


var	esc = tree.extend( { own: true } , Object.create( xterm256.esc ) , gnome.esc , {

	color24bits: { on: '\x1b[38;2;%u;%u;%um' , off: defaultColor , optimized: ( r , g , b ) => '\x1b[38;2;' + r + ';' + g + ';' + b + 'm' } ,
	bgColor24bits: { on: '\x1b[48;2;%u;%u;%um' , off: bgDefaultColor , optimized: ( r , g , b ) => '\x1b[48;2;' + r + ';' + g + ';' + b + 'm' }
} ) ;


// So far, we derivate from xterm-256color and then just add specific things (owned properties)
// of gnome, thus we achieve a clean inheritance model without duplicated code.

module.exports = {
	esc: esc ,
	keymap: tree.extend( { own: true } , Object.create( xterm256.keymap ) , gnome.keymap ) ,
	handler: tree.extend( { own: true } , Object.create( xterm256.handler ) , gnome.handler ) ,
	support: {
		deltaEscapeSequence: true ,
		"256colors": true ,

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 2 months ago

Package Health Score

67 / 100
Full package analysis