_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23600 | isAncestorContainer | train | function isAncestorContainer(ancestor, descendant) {
return (ancestor || descendant)
&& (ancestor == descendant || isAncestor(ancestor, descendant));
} | javascript | {
"resource": ""
} |
q23601 | isDescendant | train | function isDescendant(descendant, ancestor) {
return ancestor
&& descendant
&& Boolean(ancestor.compareDocumentPosition(descendant) & Node.DOCUMENT_POSITION_CONTAINED_BY);
} | javascript | {
"resource": ""
} |
q23602 | getPosition | train | function getPosition(nodeA, offsetA, nodeB, offsetB) {
// "If node A is the same as node B, return equal if offset A equals offset
// B, before if offset A is less than offset B, and after if offset A is
// greater than offset B."
if (nodeA == nodeB) {
if (offsetA == offsetB) {
return "equal";
}
if (offset... | javascript | {
"resource": ""
} |
q23603 | getContainedNodes | train | function getContainedNodes(range, condition) {
if (typeof condition == "undefined") {
condition = function() { return true };
}
var node = range.startContainer;
if (node.hasChildNodes()
&& range.startOffset < node.childNodes.length) {
// A child is contained
node = node.childNodes[range.startOffset];
} else... | javascript | {
"resource": ""
} |
q23604 | editCommandMethod | train | function editCommandMethod(command, range, callback) {
// Set up our global range magic, but only if we're the outermost function
if (executionStackDepth == 0 && typeof range != "undefined") {
globalRange = range;
} else if (executionStackDepth == 0) {
globalRange = null;
globalRange = getActiveRange();
}
/... | javascript | {
"resource": ""
} |
q23605 | isEditingHost | train | function isEditingHost(node) {
return node
&& isHtmlElement(node)
&& (node.contentEditable == "true"
|| (node.parentNode
&& node.parentNode.nodeType == Node.DOCUMENT_NODE
&& node.parentNode.designMode == "on"));
} | javascript | {
"resource": ""
} |
q23606 | isEditable | train | function isEditable(node) {
return node
&& !isEditingHost(node)
&& (node.nodeType != Node.ELEMENT_NODE || node.contentEditable != "false")
&& (isEditingHost(node.parentNode) || isEditable(node.parentNode))
&& (isHtmlElement(node)
|| (node.nodeType == Node.ELEMENT_NODE && node.namespaceURI == "http://www.w3.o... | javascript | {
"resource": ""
} |
q23607 | hasEditableDescendants | train | function hasEditableDescendants(node) {
for (var i = 0; i < node.childNodes.length; i++) {
if (isEditable(node.childNodes[i])
|| hasEditableDescendants(node.childNodes[i])) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q23608 | getEditingHostOf | train | function getEditingHostOf(node) {
if (isEditingHost(node)) {
return node;
} else if (isEditable(node)) {
var ancestor = node.parentNode;
while (!isEditingHost(ancestor)) {
ancestor = ancestor.parentNode;
}
return ancestor;
} else {
return null;
}
} | javascript | {
"resource": ""
} |
q23609 | isCollapsedBlockProp | train | function isCollapsedBlockProp(node) {
if (isCollapsedLineBreak(node)
&& !isExtraneousLineBreak(node)) {
return true;
}
if (!isInlineNode(node)
|| node.nodeType != Node.ELEMENT_NODE) {
return false;
}
var hasCollapsedBlockPropChild = false;
for (var i = 0; i < node.childNodes.length; i++) {
if (!isInvisi... | javascript | {
"resource": ""
} |
q23610 | isFormattableNode | train | function isFormattableNode(node) {
return isEditable(node)
&& isVisible(node)
&& (node.nodeType == Node.TEXT_NODE
|| isHtmlElement(node, ["img", "br"]));
} | javascript | {
"resource": ""
} |
q23611 | areEquivalentValues | train | function areEquivalentValues(command, val1, val2) {
if (val1 === null && val2 === null) {
return true;
}
if (typeof val1 == "string"
&& typeof val2 == "string"
&& val1 == val2
&& !("equivalentValues" in commands[command])) {
return true;
}
if (typeof val1 == "string"
&& typeof val2 == "string"
&& "equiv... | javascript | {
"resource": ""
} |
q23612 | normalizeFontSize | train | function normalizeFontSize(value) {
// "Strip leading and trailing whitespace from value."
//
// Cheap hack, not following the actual algorithm.
value = value.trim();
// "If value is not a valid floating point number, and would not be a valid
// floating point number if a single leading "+" character were stripp... | javascript | {
"resource": ""
} |
q23613 | train | function(value) {
// Action is further copy-pasted, same as foreColor
// "If value is not a valid CSS color, prepend "#" to it."
//
// "If value is still not a valid CSS color, or if it is currentColor,
// abort these steps and do nothing."
//
// Cheap hack for testing, no attempt to be comprehensive.
... | javascript | {
"resource": ""
} | |
q23614 | isIndentationElement | train | function isIndentationElement(node) {
if (!isHtmlElement(node)) {
return false;
}
if (node.tagName == "BLOCKQUOTE") {
return true;
}
if (node.tagName != "DIV") {
return false;
}
for (var i = 0; i < node.style.length; i++) {
// Approximate check
if (/^(-[a-z]+-)?margin/.test(node.style[i])) {
retu... | javascript | {
"resource": ""
} |
q23615 | removePreservingDescendants | train | function removePreservingDescendants(node) {
if (node.hasChildNodes()) {
splitParent([].slice.call(node.childNodes));
} else {
node.parentNode.removeChild(node);
}
} | javascript | {
"resource": ""
} |
q23616 | hasClass | train | function hasClass(el, className) {
if (typeof el.classList == "object") {
return el.classList.contains(className);
} else {
var classNameSupported = (typeof el.className == "string");
var elClass = classNameSupported ? el.className : el.getAttribute("class");
... | javascript | {
"resource": ""
} |
q23617 | train | function(textNodes, range, positionsToPreserve, isUndo) {
log.group("postApply " + range.toHtml());
var firstNode = textNodes[0], lastNode = textNodes[textNodes.length - 1];
var merges = [], currentMerge;
var rangeStartNode = firstNode, rangeEndNode = lastNode;
... | javascript | {
"resource": ""
} | |
q23618 | getComputedDisplay | train | function getComputedDisplay(el, win) {
var display = getComputedStyleProperty(el, "display", win);
var tagName = el.tagName.toLowerCase();
return (display == "block" &&
tableCssDisplayBlock &&
defaultDisplayValueForTag.hasOwnProperty(tagName)) ?
defaul... | javascript | {
"resource": ""
} |
q23619 | train | function() {
if (!this.prepopulatedChar) {
this.prepopulateChar();
}
if (this.checkForTrailingSpace) {
var trailingSpace = this.session.getNodeWrapper(this.node.childNodes[this.offset - 1]).getTrailingSpace();
log.debug("resolveLeadingA... | javascript | {
"resource": ""
} | |
q23620 | consumeWord | train | function consumeWord(forward) {
log.debug("consumeWord called, forward is " + forward);
var pos, textChar;
var newChars = [], it = forward ? forwardIterator : backwardIterator;
var passedWordBoundary = false, insideWord = false;
while ( (pos = it.next()) ) {... | javascript | {
"resource": ""
} |
q23621 | isEditingHost | train | function isEditingHost(node) {
return node &&
((node.nodeType == 9 && node.designMode == "on") ||
(isEditableElement(node) && !isEditableElement(node.parentNode)));
} | javascript | {
"resource": ""
} |
q23622 | isEditable | train | function isEditable(node, options) {
// This is slightly a lie, because we're excluding non-HTML elements with
// contentEditable attributes.
return !options || !options.applyToEditableOnly
|| ( (isEditableElement(node) || isEditableElement(node.parentNode)) && !isEditingHost(node) )... | javascript | {
"resource": ""
} |
q23623 | isEffectivelyContained | train | function isEffectivelyContained(node, range) {
if (isContained(node, range)) {
return true;
}
var isCharData = dom.isCharacterDataNode(node);
if (node == range.startContainer && isCharData && dom.getNodeLength(node) != range.startOffset) {
return true;
}
... | javascript | {
"resource": ""
} |
q23624 | isInlineNode | train | function isInlineNode(node) {
return dom.isCharacterDataNode(node) ||
(node.nodeType == 1 && inlineDisplayRegex.test(getComputedStyleProperty(node, "display")));
} | javascript | {
"resource": ""
} |
q23625 | valuesEqual | train | function valuesEqual(command, val1, val2) {
if (val1 === null || val2 === null) {
return val1 === val2;
}
return command.valuesEqual(val1, val2);
} | javascript | {
"resource": ""
} |
q23626 | train | function(textNodes, range) {
log.group("postApply");
var firstNode = textNodes[0], lastNode = textNodes[textNodes.length - 1];
var merges = [], currentMerge;
var rangeStartNode = firstNode, rangeEndNode = lastNode;
var rangeStartOffset = 0, rangeEndOffset = ... | javascript | {
"resource": ""
} | |
q23627 | getScrollPosition | train | function getScrollPosition(win) {
var x = 0, y = 0;
if (typeof win.pageXOffset == NUMBER && typeof win.pageYOffset == NUMBER) {
x = win.pageXOffset;
y = win.pageYOffset;
} else {
var doc = win.document;
var docEl = doc.documentElement;
... | javascript | {
"resource": ""
} |
q23628 | train | function(el) {
var x = 0, y = 0, offsetEl = el, width = el.offsetWidth, height = el.offsetHeight;
while (offsetEl) {
x += offsetEl.offsetLeft;
y += offsetEl.offsetTop;
offsetEl = offsetEl.offsetParent;
... | javascript | {
"resource": ""
} | |
q23629 | templateObjectOrArray | train | function templateObjectOrArray(o, context) {
deepForEach(o, (value, key, subj, path) => {
const newPath = template(path, context, true);
let newValue;
if (value && (value.constructor !== Object && value.constructor !== Array)) {
newValue = template(value, context, true);
} else {
newValue... | javascript | {
"resource": ""
} |
q23630 | extractJSONPath | train | function extractJSONPath(doc, expr) {
// typeof null is 'object' hence the explicit check here
if (typeof doc !== 'object' || doc === null) {
return '';
}
let results;
try {
results = jsonpath.query(doc, expr);
} catch (queryErr) {
debug(queryErr);
}
if (!results) {
return '';
}
... | javascript | {
"resource": ""
} |
q23631 | divideWork | train | function divideWork(script, numWorkers) {
let newPhases = [];
for (let i = 0; i < numWorkers; i++) {
newPhases.push(L.cloneDeep(script.config.phases));
}
//
// Adjust phase definitions:
//
L.each(script.config.phases, function(phase, phaseSpecIndex) {
if (phase.arrivalRate && phase.rampTo) {
... | javascript | {
"resource": ""
} |
q23632 | distribute | train | function distribute(m, n) {
m = Number(m);
n = Number(n);
let result = [];
if (m < n) {
for (let i = 0; i < n; i++) {
result.push(i < m ? 1 : 0);
}
} else {
let baseCount = Math.floor(m / n);
let extraItems = m % n;
for(let i = 0; i < n; i++) {
result.push(baseCount);
i... | javascript | {
"resource": ""
} |
q23633 | create | train | function create(list) {
let dist = l.reduce(list, function(acc, el, i) {
for(let j = 0; j < el.weight * 100; j++) {
acc.push(i);
}
return acc;
}, []);
return function() {
let i = dist[l.random(0, dist.length - 1)];
return [i, list[i]];
};
} | javascript | {
"resource": ""
} |
q23634 | createContext | train | function createContext(script) {
const INITIAL_CONTEXT = {
vars: {
target: script.config.target,
$environment: script._environment,
$processEnvironment: process.env
},
funcs: {
$randomNumber: $randomNumber,
$randomString: $randomString,
$template: input => engineUtil.te... | javascript | {
"resource": ""
} |
q23635 | combine | train | function combine(statsObjects) {
let result = create();
L.each(statsObjects, function(stats) {
L.each(stats._latencies, function(latency) {
result._latencies.push(latency);
});
result._generatedScenarios += stats._generatedScenarios;
L.each(stats._scenarioCounter, function(count, name) {
... | javascript | {
"resource": ""
} |
q23636 | ensurePropertyIsAList | train | function ensurePropertyIsAList(obj, prop) {
obj[prop] = [].concat(
typeof obj[prop] === 'undefined' ?
[] : obj[prop]);
return obj;
} | javascript | {
"resource": ""
} |
q23637 | propReplace | train | function propReplace(obj, prop, value) {
var o = {};
for (var p in obj) {
if (o.hasOwnProperty.call(obj, p)) {
if (typeof obj[p] == 'object' && !Array.isArray(obj[p])) {
propReplace(obj[p], prop, value);
} else if (p == prop) {
obj[p] = value;
... | javascript | {
"resource": ""
} |
q23638 | pbxBuildFileObj | train | function pbxBuildFileObj(file) {
var obj = Object.create(null);
obj.isa = 'PBXBuildFile';
obj.fileRef = file.fileRef;
obj.fileRef_comment = file.basename;
if (file.settings) obj.settings = file.settings;
return obj;
} | javascript | {
"resource": ""
} |
q23639 | getiframeDocument | train | function getiframeDocument($iframe) {
var iframeDoc = $iframe[0].contentWindow || $iframe[0].contentDocument;
if (iframeDoc.document) {
iframeDoc = iframeDoc.document;
}
return iframeDoc;
} | javascript | {
"resource": ""
} |
q23640 | quadrant | train | function quadrant(point, node, fallback) {
if (point.x < node.x && point.y < node.y) return 1;
if (point.x > node.x && point.y < node.y) return 2;
if (point.x > node.x && point.y > node.y) return 3;
if (point.x < node.x && point.y > node.y) return 4;
return fallback;
} | javascript | {
"resource": ""
} |
q23641 | adjustQuadrant | train | function adjustQuadrant(quadrant, point, opposite) {
if ((opposite.x == point.x) || (opposite.y == point.y)) return quadrant;
var flipHorizontally = [4, 3, 2, 1]
var flipVertically = [2, 1, 4, 3]
var oppositeQuadrant = (opposite.y < point.y) ?
((opposite.x < point.x) ? 2 : 1) :
((opposite.x < poin... | javascript | {
"resource": ""
} |
q23642 | _updateAllElements | train | function _updateAllElements({ updateCache } = {}) {
elements.forEach(element => {
_updateElementPosition(element);
if (updateCache) {
element.setCachedAttributes(view, scroll);
}
});
// reset ticking so more animations can be called
tic... | javascript | {
"resource": ""
} |
q23643 | _setViewSize | train | function _setViewSize() {
if (hasScrollContainer) {
const width = viewEl.offsetWidth;
const height = viewEl.offsetHeight;
return view.setSize(width, height);
}
const html = document.documentElement;
const width = window.innerWidth || html.clientWidth;... | javascript | {
"resource": ""
} |
q23644 | get | train | function get (target, key, receiver) {
const result = Reflect.get(target, key, receiver)
// do not register (observable.prop -> reaction) pairs for well known symbols
// these symbols are frequently retrieved in low level JavaScript under the hood
if (typeof key === 'symbol' && wellKnownSymbols.has(key)) {
... | javascript | {
"resource": ""
} |
q23645 | set | train | function set (target, key, value, receiver) {
// make sure to do not pollute the raw object with observables
if (typeof value === 'object' && value !== null) {
value = proxyToRaw.get(value) || value
}
// save if the object had a descriptor for this key
const hadKey = hasOwnProperty.call(target, key)
// ... | javascript | {
"resource": ""
} |
q23646 | splitDecimal | train | function splitDecimal(numStr) {
var allowNegative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var hasNagation = numStr[0] === '-';
var addNegation = hasNagation && allowNegative;
numStr = numStr.replace('-', '');
var parts = numStr.split('.');
var beforeDecimal = parts[0];
... | javascript | {
"resource": ""
} |
q23647 | limitToScale | train | function limitToScale(numStr, scale, fixedDecimalScale) {
var str = '';
var filler = fixedDecimalScale ? '0' : '';
for (var i = 0; i <= scale - 1; i++) {
str += numStr[i] || filler;
}
return str;
} | javascript | {
"resource": ""
} |
q23648 | roundToPrecision | train | function roundToPrecision(numStr, scale, fixedDecimalScale) {
//if number is empty don't do anything return empty string
if (['', '-'].indexOf(numStr) !== -1) return numStr;
var shoudHaveDecimalSeparator = numStr.indexOf('.') !== -1 && scale;
var _splitDecimal = splitDecimal(numStr),
beforeDecimal = _spl... | javascript | {
"resource": ""
} |
q23649 | findChangedIndex | train | function findChangedIndex(prevValue, newValue) {
var i = 0,
j = 0;
var prevLength = prevValue.length;
var newLength = newValue.length;
while (prevValue[i] === newValue[i] && i < prevLength) {
i++;
} //check what has been changed from last
while (prevValue[prevLength - 1 - j] === newValue[newLen... | javascript | {
"resource": ""
} |
q23650 | limit | train | function limit(val, max) {
if (val.length === 1 && val[0] > max[0]) {
val = '0' + val;
}
if (val.length === 2) {
if (Number(val) === 0) {
val = '01';
//this can happen when user paste number
} else if (val > max) {
val = max;
}
}
return val;
} | javascript | {
"resource": ""
} |
q23651 | readSpecFile | train | function readSpecFile(file, options) {
if (options.verbose > 1) {
file ? console.error('GET ' + file) : console.error('GET <stdin>');
}
if (!file) {
// standard input
return readFileStdinAsync();
} else if (file && file.startsWith('http')) {
// remote file
return ... | javascript | {
"resource": ""
} |
q23652 | cleanPath | train | function cleanPath( txt ) {
var ch;
var j;
if ( txt.charCodeAt( 0 ) === 34 ) {
j = 1;
for ( j = 1; j < txt.length; j++ ) {
ch = txt.charCodeAt( j );
if ( ch === 34 ) {
txt = txt.slice( 1, j );
break;
}
}
}
j = txt.indexOf( '/docs/types/' );
if ( j >= 0 ) {
txt = txt.slice( ... | javascript | {
"resource": ""
} |
q23653 | cleanTitle | train | function cleanTitle( el ) {
var txt = cleanPath( el.innerHTML );
var idx = txt.indexOf( 'stdlib' );
if ( idx === -1 || idx === 1 ) { // e.g., '@stdlib/types/iter'
txt = 'stdlib | ' + txt;
} else if ( txt.indexOf( ' | stdlib' ) === txt.length-9 ) { // e.g., 'foo/bar | stdlib'
txt = 'stdlib | ' + txt.slice(... | javascript | {
"resource": ""
} |
q23654 | cleanLinks | train | function cleanLinks( el ) {
var i;
for ( i = 0; i < el.length; i++ ) {
el[ i ].innerHTML = cleanPath( el[ i ].innerHTML );
}
} | javascript | {
"resource": ""
} |
q23655 | cleanHeadings | train | function cleanHeadings( el ) {
var i;
for ( i = 0; i < el.length; i++ ) {
el[ i ].innerHTML = cleanHeading( el[ i ].innerHTML );
}
} | javascript | {
"resource": ""
} |
q23656 | updateDescription | train | function updateDescription( txt ) {
var ch;
if ( txt.length === 0 ) {
return txt;
}
ch = txt[ 0 ].toUpperCase();
if ( ch !== txt[ 0 ] ) {
txt = ch + txt.slice( 1 );
}
if ( txt.charCodeAt( txt.length-1 ) !== 46 ) { // .
txt += '.';
}
return txt;
} | javascript | {
"resource": ""
} |
q23657 | main | train | function main() {
var el;
el = document.querySelector( 'title' );
cleanTitle( el );
el = document.querySelectorAll( '.tsd-kind-external-module a' );
cleanLinks( el );
el = document.querySelectorAll( '.tsd-is-not-exported a' );
cleanLinks( el );
el = document.querySelectorAll( '.tsd-breadcrumb a' );
... | javascript | {
"resource": ""
} |
q23658 | transform | train | function transform( node ) {
return {
'name': node.name,
'description': node.description || '',
'access': node.access || '',
'virtual': !!node.virtual
};
} | javascript | {
"resource": ""
} |
q23659 | transform | train | function transform( node ) {
var type;
if ( node.type ) {
if ( node.type.length === 1 ) {
type = node.type[ 0 ];
} else {
type = node.type;
}
} else {
type = '';
}
return {
'name': node.name,
'description': node.description || '',
'type': type,
'access': node.access || '',
'virtual': !!node... | javascript | {
"resource": ""
} |
q23660 | benchmark | train | function benchmark( b ) {
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
// TODO: synchronous task
if ( TODO/* TODO: condition */ ) {
b.fail( 'something went wrong' );
}
}
b.toc();
if ( TODO/* TODO: condition */ ) {
b.fail( 'something went wrong' );
}
b.pass( 'benchmark finished... | javascript | {
"resource": ""
} |
q23661 | transform | train | function transform( nodes ) {
var type;
var desc;
if ( nodes[ 0 ].type ) {
if ( nodes[ 0 ].type.names.length === 1 ) {
type = nodes[ 0 ].type.names[ 0 ];
} else {
type = nodes[ 0 ].type.names;
}
} else {
type = '';
}
desc = nodes[ 0 ].description || '';
return {
'type': type,
'description': des... | javascript | {
"resource": ""
} |
q23662 | getMethodReturnDoc | train | function getMethodReturnDoc(methodPath) {
const functionExpression = methodPath.get('value');
if (functionExpression.node.returnType) {
const returnType = getTypeAnnotation(functionExpression.get('returnType'));
if (returnType && t.Flow.check(returnType.node)) {
return { type: getFlowType(returnType)... | javascript | {
"resource": ""
} |
q23663 | amendComposes | train | function amendComposes(documentation, path) {
const moduleName = resolveToModule(path);
if (moduleName) {
documentation.addComposes(moduleName);
}
} | javascript | {
"resource": ""
} |
q23664 | buildBuilder | train | function buildBuilder(mqttClient, opts) {
var connection;
connection = tls.connect(opts);
function handleTLSerrors(err) {
mqttClient.emit('error', err);
connection.end();
}
connection.on('secureConnect', function() {
if (!connection.authorized) {
connection.emit('error', new... | javascript | {
"resource": ""
} |
q23665 | errorToString | train | function errorToString(err) {
if (isUndefined(err)) {
return undefined;
} else if (err.toString().length > maxStatusDetailLength) {
return err.toString().substring(0, maxStatusDetailLength - 3) + '...';
} else {
return err.toString();
}
} | javascript | {
"resource": ""
} |
q23666 | validateChecksum | train | function validateChecksum(fileName, checksum, cb) {
if (isUndefined(checksum) || isUndefined(checksum.hashAlgorithm)) {
cb();
return;
}
if (isUndefined(checksum.inline) || isUndefined(checksum.inline.value)) {
cb(new Error('Installed jobs agent only supports inline checksum value provided in... | javascript | {
"resource": ""
} |
q23667 | validateSignature | train | function validateSignature(fileName, signature, cb) {
if (isUndefined(signature) || isUndefined(signature.codesign)) {
cb();
return;
}
if (isUndefined(codeSignCertFileName)) {
cb(new Error('No code sign certificate file specified'));
return;
}
var codeSignCert;
try {
c... | javascript | {
"resource": ""
} |
q23668 | backupFiles | train | function backupFiles(job, iFile, cb) {
if (isUndefined(cb)) {
cb = iFile;
iFile = 0;
}
if (iFile === job.document.files.length) {
cb();
return;
}
var file = job.document.files[iFile];
if (isUndefined(file)) {
cb(new Error('empty file specification'));
return;
... | javascript | {
"resource": ""
} |
q23669 | rollbackFiles | train | function rollbackFiles(job, iFile, cb) {
if (isUndefined(cb)) {
cb = iFile;
iFile = 0;
}
if (iFile === job.document.files.length) {
cb();
return;
}
var file = job.document.files[iFile];
var filePath = path.resolve(job.document.workingDirectory || '', file.fileName);
if (!... | javascript | {
"resource": ""
} |
q23670 | downloadFiles | train | function downloadFiles(job, iFile, cb) {
if (isUndefined(cb)) {
cb = iFile;
iFile = 0;
}
if (iFile === job.document.files.length) {
cb();
return;
}
var file = job.document.files[iFile];
var filePath = path.resolve(job.document.workingDirectory || '', file.fileName);
if (... | javascript | {
"resource": ""
} |
q23671 | updateInstalledPackage | train | function updateInstalledPackage(updatedPackage) {
var packageIndex = installedPackages.findIndex(function(element) {
return (element.packageName === updatedPackage.packageName);
});
if (packageIndex < 0) {
packageIndex = installedPackages.length;
installedPackages.push(updatedPackage);
... | javascript | {
"resource": ""
} |
q23672 | startPackage | train | function startPackage(package, cb) {
if (isUndefined(packageRuntimes[package.packageName])) {
packageRuntimes[package.packageName] = {};
}
var packageRuntime = packageRuntimes[package.packageName];
if (!isUndefined(packageRuntime.process)) {
cb(new Error('package already running'));
retu... | javascript | {
"resource": ""
} |
q23673 | shutdownHandler | train | function shutdownHandler(job) {
// Change status to IN_PROGRESS
job.inProgress({ operation: job.operation, step: 'attempting' }, function(err) {
showJobsError(err);
var delay = (isUndefined(job.document.delay) ? '0' : job.document.delay.toString());
// Check for adequate permissions to perfor... | javascript | {
"resource": ""
} |
q23674 | rebootHandler | train | function rebootHandler(job) {
// Check if the reboot job has not yet been initiated
if (job.status.status === 'QUEUED' ||
isUndefined(job.status.statusDetails) ||
isUndefined(job.status.statusDetails.step)) {
// Change status to IN_PROGRESS
job.inProgress({ operation: job.operation, s... | javascript | {
"resource": ""
} |
q23675 | systemStatusHandler | train | function systemStatusHandler(job) {
var packageNames = '[';
for (var i = 0; i < installedPackages.length; i++) {
packageNames += installedPackages[i].packageName + ((i !== installedPackages.length - 1) ? ', ' : '');
}
packageNames += ']';
job.succeeded({
operation: job.operation,
inst... | javascript | {
"resource": ""
} |
q23676 | _markConnectionStable | train | function _markConnectionStable() {
currentReconnectTimeMs = baseReconnectTimeMs;
device.options.reconnectPeriod = currentReconnectTimeMs;
//
// Mark this timeout as expired
//
connectionTimer = null;
connectionState = 'stable';
} | javascript | {
"resource": ""
} |
q23677 | _trimOfflinePublishQueueIfNecessary | train | function _trimOfflinePublishQueueIfNecessary() {
var rc = true;
if ((offlineQueueMaxSize > 0) &&
(offlinePublishQueue.length >= offlineQueueMaxSize)) {
//
// The queue has reached its maximum size, trim it
// according to the defined drop behavior.
//
i... | javascript | {
"resource": ""
} |
q23678 | _drainOperationQueue | train | function _drainOperationQueue() {
//
// Handle our active subscriptions first, using a cloned
// copy of the array. We shift them out one-by-one until
// all have been processed, leaving the official record
// of active subscriptions untouched.
//
var subscription = clonedSu... | javascript | {
"resource": ""
} |
q23679 | AggregatorFactory | train | function AggregatorFactory(aggregatorFn) {
return metrics => {
if (metrics.length === 0) return;
const result = {
help: metrics[0].help,
name: metrics[0].name,
type: metrics[0].type,
values: [],
aggregator: metrics[0].aggregator
};
// Gather metrics by metricName and labels.
const byLabels = n... | javascript | {
"resource": ""
} |
q23680 | HappyForegroundThreadPool | train | function HappyForegroundThreadPool(config) {
var rpcHandler, worker;
return {
size: config.size,
start: function(compilerId, compiler, compilerOptions, done) {
var fakeCompiler = new HappyFakeCompiler({
id: 'foreground',
compilerId: compilerId,
send: function executeCompilerR... | javascript | {
"resource": ""
} |
q23681 | enableRerouting | train | function enableRerouting() {
if (enabled)
return;
enabled = true;
const connect = Net.Socket.prototype.connect;
Net.Socket.prototype.connect = function(options, callback) {
const hasNormalizedArgs = Object.getOwnPropertySymbols && Object.getOwnPropertySymbols(options).length > 0;
const isNode8 ... | javascript | {
"resource": ""
} |
q23682 | assertMatch | train | function assertMatch(actual, expected, message) {
if (isRegExp(expected))
assert(expected.test(actual), message || `Expected "${actual}" to match "${expected}"`);
else if (typeof expected === 'function')
assert(expected(actual), message);
else
assert.deepEqual(actual, expected, message);
} | javascript | {
"resource": ""
} |
q23683 | ontick | train | function ontick(next) {
// No point in waiting that long
if (next >= timeoutOn) {
timeout();
return;
}
const activeWindow = eventLoop.active;
if (completionFunction && activeWindow.document.documentElement)
try {
const waitFor = Math.max(next - Date.now... | javascript | {
"resource": ""
} |
q23684 | done | train | function done(error) {
global.clearTimeout(timer);
eventLoop.removeListener('tick', ontick);
eventLoop.removeListener('idle', done);
eventLoop.browser.removeListener('error', done);
--eventLoop.waiting;
try {
callback(error);
} catch (error) {
// If callback ma... | javascript | {
"resource": ""
} |
q23685 | changes | train | function changes() {
const version = require('./package.json').version;
const changelog = File.readFileSync('CHANGELOG.md', 'utf-8');
const match = changelog.match(/^## Version (.*) .*\n([\S\s]+?)\n##/m);
assert(match, 'CHANGELOG.md missing entry: ## Version ' + version);
assert.equal(match[1], version... | javascript | {
"resource": ""
} |
q23686 | decompressStream | train | function decompressStream(stream, headers) {
const transferEncoding = headers.get('Transfer-Encoding');
const contentEncoding = headers.get('Content-Encoding');
if (contentEncoding === 'deflate' || transferEncoding === 'deflate')
return stream.pipe( Zlib.createInflate() );
if (contentEncoding === 'gzip' ... | javascript | {
"resource": ""
} |
q23687 | click | train | function click() {
const clickEvent = input.ownerDocument.createEvent('HTMLEvents');
clickEvent.initEvent('click', true, true);
const labelElementImpl = domSymbolTree.parent(idlUtils.implForWrapper(input));
const dispatchResult = input.dispatchEvent(clickEvent);
input._click && input._click(clickEve... | javascript | {
"resource": ""
} |
q23688 | windowLoaded | train | function windowLoaded(event) {
document.removeEventListener('DOMContentLoaded', windowLoaded);
// JSDom > 7.1 does not allow re-dispatching the same event, so
// a copy of the event needs to be created for the new dispatch
const windowContentLoaded = document.createEvent('HTMLEvents');
windowConten... | javascript | {
"resource": ""
} |
q23689 | createDocument | train | function createDocument(args) {
const { browser } = args;
const features = {
FetchExternalResources: [],
ProcessExternalResources: [],
MutationEvents: '2.0'
};
const window = new Window({
parsingMode: 'html',
contentType: 'text/html',
url: args.url,
referrer... | javascript | {
"resource": ""
} |
q23690 | parseResponse | train | function parseResponse({ browser, history, document, response }) {
const window = document.defaultView;
window._request = response.request;
window._response = response;
history.updateLocation(window, response._url);
const done = window._eventQueue.waitForCompletion();
response
._consume()
.... | javascript | {
"resource": ""
} |
q23691 | expandQNames | train | function expandQNames(xpath) {
var namespaces = constants.XmlNamespaces;
var pathParts = xpath.split('/');
for (var i=0; i < pathParts.length; i++) {
if (pathParts[i].indexOf(':') !== -1) {
var QNameParts = pathParts[i].split(':');
if (QNameParts.length !== 2) {
throw new Error('Unable to ... | javascript | {
"resource": ""
} |
q23692 | train | function(node) {
var doc = '';
var sibling = node.firstChild;
var serializer = new XMLSerializer();
while (sibling) {
if (this.isElementNode(sibling)) {
doc += serializer.serializeToString(sibling);
}
sibling = sibling.nextSibling;
}
return doc !== '' ? doc : null;
... | javascript | {
"resource": ""
} | |
q23693 | train | function(node) {
var sibling = node.firstChild;
while (sibling && !sibling.data) {
sibling = sibling.nextSibling;
}
return sibling.data ? sibling.data : null;
} | javascript | {
"resource": ""
} | |
q23694 | Authority | train | function Authority(authorityUrl, validateAuthority) {
this._log = null;
this._url = url.parse(authorityUrl);
this._validateAuthorityUrl();
this._validated = !validateAuthority;
this._host = null;
this._tenant = null;
this._parseAuthority();
this._authorizationEndpoint = null;
this._tokenEndpoint = n... | javascript | {
"resource": ""
} |
q23695 | train | function(options) {
if (!options) {
options = {};
}
if (options.log) {
if (!_.isFunction(options.log)) {
throw new Error('setLogOptions expects the log key in the options parameter to be a function');
}
} else {
// if no log function was passed set it to a default no op ... | javascript | {
"resource": ""
} | |
q23696 | SelfSignedJwt | train | function SelfSignedJwt(callContext, authority, clientId) {
this._log = new Logger('SelfSignedJwt', callContext._logContext);
this._callContext = callContext;
this._authority = authority;
this._tokenEndpoint = authority.tokenEndpoint;
this._clientId = clientId;
} | javascript | {
"resource": ""
} |
q23697 | CacheDriver | train | function CacheDriver(callContext, authority, resource, clientId, cache, refreshFunction) {
this._callContext = callContext;
this._log = new Logger('CacheDriver', callContext._logContext);
this._authority = authority;
this._resource = resource;
this._clientId = clientId;
this._cache = cache || nopCache;
th... | javascript | {
"resource": ""
} |
q23698 | OAuth2Client | train | function OAuth2Client(callContext, authority) {
this._tokenEndpoint = authority.tokenEndpoint;
this._deviceCodeEndpoint = authority.deviceCodeEndpoint;
this._log = new Logger('OAuth2Client', callContext._logContext);
this._callContext = callContext;
this._cancelPollingRequest = false;
} | javascript | {
"resource": ""
} |
q23699 | train | function (response, body) {
var tokenResponse;
try {
tokenResponse = self._handlePollingResponse(body);
} catch (e) {
self._log.error('Error validating get token response', e, true);
callback(null, e);
return;
}
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.