UI for Zipcoin Blue

estree-walker.es.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function walk ( ast, ref) {
  2. var enter = ref.enter;
  3. var leave = ref.leave;
  4. visit( ast, null, enter, leave );
  5. }
  6. var shouldSkip = false;
  7. var context = { skip: function () { return shouldSkip = true; } };
  8. var childKeys = {};
  9. var toString = Object.prototype.toString;
  10. function isArray ( thing ) {
  11. return toString.call( thing ) === '[object Array]';
  12. }
  13. function visit ( node, parent, enter, leave, prop, index ) {
  14. if ( !node ) { return; }
  15. if ( enter ) {
  16. var _shouldSkip = shouldSkip;
  17. shouldSkip = false;
  18. enter.call( context, node, parent, prop, index );
  19. var skipped = shouldSkip;
  20. shouldSkip = _shouldSkip;
  21. if ( skipped ) { return; }
  22. }
  23. var keys = childKeys[ node.type ] || (
  24. childKeys[ node.type ] = Object.keys( node ).filter( function (key) { return typeof node[ key ] === 'object'; } )
  25. );
  26. for ( var i = 0; i < keys.length; i += 1 ) {
  27. var key = keys[i];
  28. var value = node[ key ];
  29. if ( isArray( value ) ) {
  30. for ( var j = 0; j < value.length; j += 1 ) {
  31. visit( value[j], node, enter, leave, key, j );
  32. }
  33. }
  34. else if ( value && value.type ) {
  35. visit( value, node, enter, leave, key, null );
  36. }
  37. }
  38. if ( leave ) {
  39. leave( node, parent, prop, index );
  40. }
  41. }
  42. export { walk, childKeys };
  43. //# sourceMappingURL=estree-walker.es.js.map