Sha256: 0d02fe9bd33bcb4d60896f09a58fba09f09d1f999cd1980ded5868e664325f8d

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

function walk ( ast, ref) {
	var enter = ref.enter;
	var leave = ref.leave;

	visit( ast, null, enter, leave );
}

var context = {
	skip: function () { return context.shouldSkip = true; },
	shouldSkip: false
};

var childKeys = {};

var toString = Object.prototype.toString;

function isArray ( thing ) {
	return toString.call( thing ) === '[object Array]';
}

function visit ( node, parent, enter, leave, prop, index ) {
	if ( !node ) { return; }

	if ( enter ) {
		context.shouldSkip = false;
		enter.call( context, node, parent, prop, index );
		if ( context.shouldSkip ) { return; }
	}

	var keys = childKeys[ node.type ] || (
		childKeys[ node.type ] = Object.keys( node ).filter( function (key) { return typeof node[ key ] === 'object'; } )
	);

	for ( var i = 0; i < keys.length; i += 1 ) {
		var key = keys[i];
		var value = node[ key ];

		if ( isArray( value ) ) {
			for ( var j = 0; j < value.length; j += 1 ) {
				visit( value[j], node, enter, leave, key, j );
			}
		}

		else if ( value && value.type ) {
			visit( value, node, enter, leave, key, null );
		}
	}

	if ( leave ) {
		leave( node, parent, prop, index );
	}
}

export { walk };
//# sourceMappingURL=estree-walker.es.js.map

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
jass-vue-0.4.0 vendor/node_modules/estree-walker/dist/estree-walker.es.js
jass-vue-0.3.0 vendor/node_modules/estree-walker/dist/estree-walker.es.js
condenser-0.0.4 lib/condenser/processors/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es.js
jass-vue-0.2.1 vendor/node_modules/estree-walker/dist/estree-walker.es.js
jass-0.9.1 vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es.js