/* Expand node, return Deferred.promise.
174859
function(ctx, flag, opts) {
		var dfd = new $.Deferred(),
			subOpts = $.extend({}, opts, {noEvents: true, noAnimation: true});

		opts = opts || {};

		function _afterExpand(ok) {
			flag = (flag !== false);
			setChildRowVisibility(ctx.node, flag);
			if( ok ) {
				if( flag && ctx.options.autoScroll && !opts.noAnimation && ctx.node.hasChildren() ) {
					// Scroll down to last child, but keep current node visible
					ctx.node.getLastChild().scrollIntoView(true, {topNode: ctx.node}).always(function(){
						if( !opts.noEvents ) {
							ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
						}
						dfd.resolveWith(ctx.node);
					});
				} else {
					if( !opts.noEvents ) {
						ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
					}
					dfd.resolveWith(ctx.node);
				}
			} else {
				if( !opts.noEvents ) {
					ctx.tree._triggerNodeEvent(flag ? "expand" : "collapse", ctx);
				}
				dfd.rejectWith(ctx.node);
			}
		}
		// Call base-expand with disabled  events and animation
		this._super(ctx, flag, subOpts).done(function () {
			_afterExpand(true);
		}).fail(function () {
			_afterExpand(false);
		});
		return dfd.promise();
	}
1335646
function expandTreeToPipeline(pipelineId) {
  if (pipelineId == null) {
    return;
  }
  var elementId = getTreePipelineElementId(pipelineId);
  var parents = $(elementId).parents('.expandable');
  if (parents.size() > 0) {
    // The toggle function will scroll to highlight the pipeline.
    parents.children('.hitarea').click();
  } else {
    // No children, so just scroll.
    scrollTreeToPipeline(pipelineId);
  }
}
171244
function promisify(op) {
    var args = slice.call(arguments, 1);
    return new Promise(function(resolver) {
      op.apply(null, args.concat(function(err, value) {
        if(err) {
          resolver.reject(err);
        }
        else {
          resolver.resolve(value);
        }
      }));
    });
  }
1048095
function(prefPath) {
			var didRestoreSelections = false;
			var expanded = window.sessionStorage[prefPath+"expanded"]; //$NON-NLS-0$
			if (typeof expanded=== "string") { //$NON-NLS-0$
				if (expanded.length > 0) {
					expanded= JSON.parse(expanded);
				} else {
					expanded = null;
				}
			}
			var i;
			if (expanded) {
				for (i=0; i<expanded.length; i++) {
					var row= lib.node(expanded[i]);
					if (row) {
						this._expanded.push(expanded[i]);
						// restore selections after expansion in case an expanded item was selected.
						var self = this;
						this.tableTree.expand(expanded[i], function() {
							self._restoreSelections(prefPath);
						});
						didRestoreSelections = true;
					}
				}
			}
			return !didRestoreSelections;
		}
694794
protected final void expand (int needed)
    {
        int ocapacity = _buffer.capacity();
        int ncapacity = _buffer.position() + needed;
        if (ncapacity > ocapacity) {
            // increase the buffer size in large increments
            ncapacity = Math.max(ocapacity << 1, ncapacity);
            ByteBuffer newbuf = ByteBuffer.allocate(ncapacity);
            newbuf.put((ByteBuffer)_buffer.flip());
            _buffer = newbuf;
        }
    }
803380
function extend(source, target, deep) {
    if (deep) {
        return lodash.merge(lodash.cloneDeep(source), target);
    } else {
        return lodash.assignIn(source, target);
    }
}
1136054
function(url, method = 'get', body = undefined) {
		var deferred = Q.defer();

		this.extendedRequest(url, method, body)
			.then((res) => { deferred.resolve(res.body); })
			.catch((err) => { deferred.reject(err); });

		return deferred.promise;
	}
510203
function nodeGet(url) {
  // return new pending promise
  return new Promise(function (resolve, reject) {
    // select http or https module, depending on reqested url
    var lib = url.startsWith("https") ? require("https") : require("http");
    var request = lib.get(url, function (response) {
      // handle http errors
      if (response.statusCode < 200 || response.statusCode > 299) {
        reject(new Error("Failed to load page, status code: " + response.statusCode));
      }
      // temporary data holder
      var body = [];
      // on every content chunk, push it to the data array
      response.on("data", function (chunk) {
        return body.push(chunk);
      });
      // we are done, resolve promise with those joined chunks
      response.on("end", function () {
        return resolve(body.join(""));
      });
    });
    // handle connection errors of the request
    request.on("error", function (err) {
      return reject(err);
    });
  });
}
555381
function then(onFulfilled, onRejected) {
      var state = getInternalPromiseState(this);
      var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
      reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
      reaction.fail = typeof onRejected == 'function' && onRejected;
      reaction.domain = IS_NODE ? process.domain : undefined;
      state.parent = true;
      state.reactions.push(reaction);
      if (state.state != PENDING) notify(this, state, false);
      return reaction.promise;
    }
687064
def expand(self):
        
        return SLH(self.S.expand(), self.L.expand(), self.H.expand())
539027
function mix(self, ref, expanded) {
	switch (typeof(ref)) {
		case 'undefined': return self;
		case 'function': return expanded ? ref : undefined;
		case 'object':
			if (isValueObject(ref)) return (ref !== null) ? ref.valueOf() : null;
			if (expanded && ((ref instanceof Promise) || (self instanceof Promise))) return ref;
			if (typeof(self) != 'object' || isValueObject(self)) self = {};
			Object.keys(ref).forEach(function(key) {
				self[key] = mix(self[key], ref[key], expanded)
			})
			return self
	}
	return ref;
}
1128877
function promiseWrap(x) {
  if(x.then && typeof x.then === "function") {
    return x;    
  }
  var deferred = q.defer();
  deferred.resolve(x);
  return deferred.promise;
}
475005
function dummyP(n) {    
    return function lifted() {
        var deferred = Promise.pending();
        timers.setTimeout(nodeback, deferred, global.asyncTime || 100);
        return deferred.promise;
    }
}
830298
function(node) {
         var newNode = function(data, next) {
             var that = {};
             that.getData = function() {
                 return data;
             };
             that.getNext = function() {
                 return next;
             };
             return that;
         };
         var top = node || null;
         var that = {};

         that.__push_internal__ = function(data) {
             return newStack(newNode(data, top));
         };

         that.__peek__ = function() {
             return top && top.getData();
         };

         that.__pop_internal__ = function() {
             return top && newStack(top.getNext());
         };

         that.__forEach__ = function(f) {
             var i = top;
             var s = 0;
             while (i !== null) {
                 f(i.getData(), s);
                 s = s +1;
                 i = i.getNext();
             }
         };
         that.__map__ = function(f) {
             var i = top;
             var result = [];
             while (i !== null) {
                 result.push(f(i.getData()));
                 i = i.getNext();
             }
             return result;
         };

         that.__length__ = function() {
             var count = 0;
             that.__forEach__(function() { count = count + 1;});
             return count;
         };

         return that;
     }
1280453
private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<V> distFunction, SpatialObjectPair nodePair, DataStore<KNNList> knns) {
    DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID());
    DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID());

    if(node1.isLeaf()) {
      expandLeafNodes(distFunction, node1, node2, knns);
    }
    else {
      expandDirNodes(distFunction, node1, node2);
    }

    index.setExpanded(nodePair.entry2, nodePair.entry1);
  }
110940
function chain(promise,
               onResolve = idResolveHandler,
               onReject = idRejectHandler) {
  var deferred = getDeferred(promise.constructor);
  switch (promise.status_) {
    case undefined:
      throw TypeError;
    case 0:
      promise.onResolve_.push(onResolve, deferred);
      promise.onReject_.push(onReject, deferred);
      break;
    case +1:
      promiseEnqueue(promise.value_, [onResolve, deferred]);
      break;
    case -1:
      promiseEnqueue(promise.value_, [onReject, deferred]);
      break;
  }
  return deferred.promise;
}
841258
function() {
        return new Promise(function(resolve, reject) {
            exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", {
                timeout: 3000,
                cwd: process.cwd()
            }, function(err, stdout, stdin) {
                var results = stdout.trim().split('\n');
                var entities = {};

                // iterate all found js files and search for CRUD.define calls
                results.map(function(filename) {
                    if (filename.trim() == '') return;
                    var code = fs.readFileSync(filename) + '';
                    var ast = UglifyJS.parse(code);
                    ast.walk(new UglifyJS.TreeWalker(function(node) {
                        if (node instanceof UglifyJS.AST_Call && node.start.value == 'CRUD' && node.expression.property == 'define') {
                            entities[node.args[0].start.value] = filename;
                        }
                    }));
                });

                resolve(entities);
            });
        });
    }