_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q7500 | cautiouslyApplyEach | train | function cautiouslyApplyEach(
array,
fns,
log = true,
keepOldValueOnFalseyReturn = false)
{
let items = Array.from(array);
if (items && Array.isArray(items) && fns && Array.isArray(fns)) {
items.forEach((item, itemIndex, itemArray) => {
let newItem = item;
fns.forEach(fn => {
try {
... | javascript | {
"resource": ""
} |
q7501 | cautiouslyApply | train | function cautiouslyApply(
item,
fns,
log = true,
keepOldValueOnFalseyReturn = false)
{
if (fns && Array.isArray(fns)) {
fns.forEach(fn => {
try {
let bindFunctor = Array.isArray(fn) && fn[1];
let functor = bindFunctor ?
fn[0].bind(item) :
Array.isArray(fn) ? fn[0] : fn;
... | javascript | {
"resource": ""
} |
q7502 | measureIndents | train | function measureIndents(
string,
config = {
preWork: [],
perLine: [],
postWork: [] },
whitespace = /[ \t]/)
{
let regexp = new RegExp(`(^${whitespace.source}*)`);
let strings;
let indents;
if (Array.isArray(string)) {
string = string.join('\n');
}
string = cautiouslyApply(string, config.preWork... | javascript | {
"resource": ""
} |
q7503 | stripEmptyFirstAndLast | train | function stripEmptyFirstAndLast(string) {
let strings = string.split(/\r?\n/);
// construct a small resuable function for trimming all initial whitespace
let trimL = s => s.replace(/^([ \t]*)/, '');
let trimR = s => s.replace(/([ \t]*)($)/, '$1');
// the first line is usually a misnomer, discount it if it is... | javascript | {
"resource": ""
} |
q7504 | dropLowestIndents | train | function dropLowestIndents(
values)
{
let [strings, indents] = values;
let set = new Set(indents);
let lowest = Math.min(...indents);
set.delete(lowest);
return [strings, Array.from(set)];
} | javascript | {
"resource": ""
} |
q7505 | GregorianCalendar | train | function GregorianCalendar(timezoneOffset, locale) {
var args = util.makeArray(arguments);
if (typeof timezoneOffset === 'object') {
locale = timezoneOffset;
timezoneOffset = locale.timezoneOffset;
} else if (args.length >= 3) {
timezoneOffset = locale = null;... | javascript | {
"resource": ""
} |
q7506 | train | function (field) {
if (MIN_VALUES[field] !== undefined) {
return MIN_VALUES[field];
}
var fields = this.fields;
if (field === WEEK_OF_MONTH) {
var cal = new GregorianCalendar(fields[YEAR], fields[MONTH], 1);
return cal.get(W... | javascript | {
"resource": ""
} | |
q7507 | train | function (field) {
if (MAX_VALUES[field] !== undefined) {
return MAX_VALUES[field];
}
var value, fields = this.fields;
switch (field) {
case DAY_OF_MONTH:
value = getMonthLength(fields[YEAR], fields[MONTH]);
brea... | javascript | {
"resource": ""
} | |
q7508 | train | function (field, v) {
var len = arguments.length;
if (len === 2) {
this.fields[field] = v;
} else if (len < MILLISECONDS + 1) {
for (var i = 0; i < len; i++) {
this.fields[YEAR + i] = arguments[i];
}
} el... | javascript | {
"resource": ""
} | |
q7509 | train | function (value, amount, min, max) {
var diff = value - min;
var range = max - min + 1;
amount %= range;
return min + (diff + amount + range) % range;
} | javascript | {
"resource": ""
} | |
q7510 | train | function (field, amount) {
if (!amount) {
return;
}
var self = this; // computer and retrieve original value
// computer and retrieve original value
var value = self.get(field);
var min = self.getActualMinimum(field);
... | javascript | {
"resource": ""
} | |
q7511 | train | function (field) {
var fields = this.fields;
switch (field) {
case WEEK_OF_MONTH:
fields[DAY_OF_MONTH] = undefined;
break;
case DAY_OF_YEAR:
fields[MONTH] = undefined;
break;
case DAY_OF_WEEK:
... | javascript | {
"resource": ""
} | |
q7512 | train | function () {
var weekYear = this.getWeekYear();
if (weekYear === this.get(YEAR)) {
return this.getActualMaximum(WEEK_OF_YEAR);
} // Use the 2nd week for calculating the max of WEEK_OF_YEAR
// Use the 2nd week for calculating the max of WEEK_OF_YEAR
... | javascript | {
"resource": ""
} | |
q7513 | train | function () {
var year = this.get(YEAR); // implicitly complete
// implicitly complete
var weekOfYear = this.get(WEEK_OF_YEAR);
var month = this.get(MONTH);
if (month === GregorianCalendar.JANUARY) {
if (weekOfYear >= 52) {
... | javascript | {
"resource": ""
} | |
q7514 | train | function () {
if (this.time === undefined) {
this.computeTime();
}
var cal = new GregorianCalendar(this.timezoneOffset, this.locale);
cal.setTime(this.time);
return cal;
} | javascript | {
"resource": ""
} | |
q7515 | Pass | train | function Pass(style, fields, opts, cb) {
Stream.call(this)
// Get our own shallow copy of the fields
this.fields = _.extend({}, fields)
this.style = style
this.opts = opts
if (!this.fields[style]) {
this.fields[style] = {}
}
// Copy structure fields to style
if (this.fields.structure) {
... | javascript | {
"resource": ""
} |
q7516 | sync | train | function sync() {
// retrieve latency, then wait 1 sec
function getLatencyAndWait() {
var result = null;
if (isDestroyed) {
return Promise.resolve(result);
}
return getLatency(slave)
.then(function (latency) { result = latency }) // store the retrieved latency
... | javascript | {
"resource": ""
} |
q7517 | getLatencyAndWait | train | function getLatencyAndWait() {
var result = null;
if (isDestroyed) {
return Promise.resolve(result);
}
return getLatency(slave)
.then(function (latency) { result = latency }) // store the retrieved latency
.catch(function (err) { console.log(err) }) // just log... | javascript | {
"resource": ""
} |
q7518 | getLatency | train | function getLatency(emitter) {
var start = Date.now();
return emitter.request('time')
.then(function (timestamp) {
var end = Date.now();
var latency = (end - start) / 2;
var time = timestamp + latency;
// apply the first ever retrieved offset immediately.
... | javascript | {
"resource": ""
} |
q7519 | build | train | function build(data) {
const resources = resources_1.ResourcesStructure.create();
const annotations = annotations_1.AnnotationsStructure.create();
data.content[0].content.forEach((content) => {
if (content.element === 'annotation') {
annotations.add(content.content);
return;
... | javascript | {
"resource": ""
} |
q7520 | Logger | train | function Logger (level, name) {
if (name) {
debug = require('debug')(typeof name === 'string' ? name : 'vxx');
}
this.level = level;
this.debug('Logger started');
} | javascript | {
"resource": ""
} |
q7521 | error | train | function error(status, req, res, msg) {
debug('%s %s', status, req.originalUrl);
msg = msg || '';
var page = generator.page$['/' + status];
// 404 with no matching status page => redirect to home
if (!page && status === 404) {
if (generator.home) return res.redirect(302, '/');
if (serv... | javascript | {
"resource": ""
} |
q7522 | train | function(frame) {
if (script2) {
script2.parentNode.removeChild(script2);
script2 = null;
}
if (script) {
clearTimeout(tref);
script.parentNode.removeChild(script);
script.onreadystatechange = script.onerror =
script.onl... | javascript | {
"resource": ""
} | |
q7523 | train | function(url, constructReceiver, user_callback) {
var id = 'a' + utils.random_string(6);
var url_id = url + '?c=' + escape(WPrefix + '.' + id);
// Callback will be called exactly once.
var callback = function(frame) {
delete _window[WPrefix][id];
user_callback(frame);
};
var clo... | javascript | {
"resource": ""
} | |
q7524 | wrapWorkAndCallback | train | function wrapWorkAndCallback(work, callback) {
return function(err) {
work.stop(err);
callback.apply(this, arguments);
};
} | javascript | {
"resource": ""
} |
q7525 | train | function(reaped) {
childCount += 1;
if (reaped) {
self.options.log.trace1('Incrementing reapCount', {current: reapCount});
reapCount += 1;
}
if (childCount >= children.length) {
cbWrapper(function() {
... | javascript | {
"resource": ""
} | |
q7526 | throttleMiddleware | train | function throttleMiddleware (request, response, next) {
var ip = null
if (config.useCustomHeader && request.headers[config.useCustomHeader]) {
ip = request.headers[config.useCustomHeader]
} else {
ip = request.headers['x-forwarded-for'] ||
request.connection.remoteAddress ||
req... | javascript | {
"resource": ""
} |
q7527 | send | train | function send (event, data) {
var envelope = {
event: event,
data: data
};
debug('send', envelope);
socket.send(JSON.stringify(envelope));
} | javascript | {
"resource": ""
} |
q7528 | request | train | function request (event, data) {
return new Promise(function (resolve, reject) {
// put the data in an envelope with id
var id = getId();
var envelope = {
event: event,
id: id,
data: data
};
// add the request to the list with requests in progress
queue[i... | javascript | {
"resource": ""
} |
q7529 | dummyMarkdown | train | function dummyMarkdown() {
var codeBlock = /^```/;
var quoteBlock = /^>/;
var listBlock = /^\* /;
var commentInline = '<!--.*-->';
var codeInline = '`.+`';
function split(content) {
var pattern = new RegExp([commentInline, codeInline].join('|'), 'g');
var result = null;
... | javascript | {
"resource": ""
} |
q7530 | parser | train | function parser(file, callback) {
// file exit conditions
if(file.isNull()) {
return callback(null, file); // pass along
}
if(file.isStream()) {
return callback(new Error('Streaming not supported'));
}
try {
var
/** @type {string} */
text = String(file.contents.toString('utf8'... | javascript | {
"resource": ""
} |
q7531 | train | function (element, deep) {
var
childNodes = element.childNodes || [],
index = -1,
key, value, childNode;
if (element.nodeType === 1 && element.constructor !== Element) {
element.constructor = Element;
for (key in cache) {
value = cache[key];
element[key] = value;
}
}
while (childNode =... | javascript | {
"resource": ""
} | |
q7532 | bodyCheck | train | function bodyCheck() {
if (!(loopLimit--)) clearTimeout(interval);
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
shiv(document, true);
if (interval && document.body.prototype) clearTimeout(interval);
return (!!document.body.prototype);
}
return f... | javascript | {
"resource": ""
} |
q7533 | _getConfig | train | function _getConfig () {
return {
paced: paced,
rate: rate,
deterministic: deterministic,
time: configuredTime,
master: master,
port: port
}
} | javascript | {
"resource": ""
} |
q7534 | _rescheduleIntervals | train | function _rescheduleIntervals(now) {
for (var i = 0; i < timeouts.length; i++) {
var timeout = timeouts[i];
if (timeout.type === TYPE.INTERVAL) {
_rescheduleInterval(timeout, now);
}
}
} | javascript | {
"resource": ""
} |
q7535 | _rescheduleInterval | train | function _rescheduleInterval(timeout, now) {
timeout.occurrence = Math.round((now - timeout.firstTime) / timeout.interval);
timeout.time = timeout.firstTime + timeout.occurrence * timeout.interval;
} | javascript | {
"resource": ""
} |
q7536 | _execTimeout | train | function _execTimeout(timeout, callback) {
// store the timeout in the queue with timeouts in progress
// it can be cleared when a clearTimeout is executed inside the callback
current[timeout.id] = timeout;
function finish() {
// in case of an interval we have to reschedule on next cycle
//... | javascript | {
"resource": ""
} |
q7537 | _getExpiredTimeouts | train | function _getExpiredTimeouts(time) {
var i = 0;
while (i < timeouts.length && ((timeouts[i].time <= time) || !isFinite(timeouts[i].time))) {
i++;
}
var expired = timeouts.splice(0, i);
if (deterministic == false) {
// the array with expired timeouts is in deterministic order
// sh... | javascript | {
"resource": ""
} |
q7538 | _schedule | train | function _schedule() {
// do not _schedule when there are timeouts in progress
// this can be the case with async timeouts in non-paced mode.
// _schedule will be executed again when all async timeouts are finished.
if (!paced && Object.keys(current).length > 0) {
return;
}
var next = tim... | javascript | {
"resource": ""
} |
q7539 | toTimestamp | train | function toTimestamp(date) {
var value =
(typeof date === 'number') ? date : // number
(date instanceof Date) ? date.valueOf() : // Date
new Date(date).valueOf(); // ISOString, momentjs, ...
if (isNaN(value)) {
throw new TypeError('Invalid date ' ... | javascript | {
"resource": ""
} |
q7540 | pick | train | function pick(obj, keys) {
var result = {};
for (var i = 0, length = keys.length; i < length; i++) {
var key = keys[i];
if (key in obj) result[key] = obj[key];
}
return result;
} | javascript | {
"resource": ""
} |
q7541 | copyAndPush | train | function copyAndPush(arr, obj) {
var result = arr.slice();
result.push(obj);
return result;
} | javascript | {
"resource": ""
} |
q7542 | Walker | train | function Walker(traversalStrategy) {
if (!(this instanceof Walker))
return new Walker(traversalStrategy);
// There are two different strategy shorthands: if a single string is
// specified, treat the value of that property as the traversal target.
// If an array is specified, the traversal target is the no... | javascript | {
"resource": ""
} |
q7543 | createMiddleware | train | function createMiddleware(router, validator) {
/**
* Checks request and response against a swagger spec
* Uses the usual koa context attributes
* Uses the koa-bodyparser context attribute
* Sets a new context attribute: {object} parameter
*/
return function* middleware(next) {
// Routing matches
... | javascript | {
"resource": ""
} |
q7544 | start | train | function start(projectConfig) {
var config = initConfig(projectConfig);
if (traceApi.isActive() && !config.forceNewAgent_) { // already started.
throw new Error('Cannot call start on an already started agent.');
}
if (!config.enabled) {
return traceApi;
}
if (config.logLevel < 0) {
config.log... | javascript | {
"resource": ""
} |
q7545 | train | function (signed, bytes, size) {
if (signed) {
switch(bytes) {
case 1:
return new Int8Array(size);
case 2:
return new Int16Array(size);
case 4:
return new Int32Array(size);
default:
... | javascript | {
"resource": ""
} | |
q7546 | scan | train | function scan(sp, cb) {
cb = u.onceMaybe(cb);
var timer = u.timer();
sp.route = sp.route || '/';
var src = sp.src;
// only construct src, defaults, sendOpts etc. once
if (!src) {
sp.name = sp.name || 'staticPath:' + sp.path;
sp.depth = sp.depth || opts.staticDepth || 5;
sp.ma... | javascript | {
"resource": ""
} |
q7547 | train | function () {
var gamepadSupportAvailable = navigator.getGamepads ||
!!navigator.webkitGetGamepads ||
!!navigator.webkitGamepads;
if (!gamepadSupportAvailable) {
// It doesn't seem Gamepad API is available, show a message telling
// the visitor about it.
window.tester.showNotS... | javascript | {
"resource": ""
} | |
q7548 | train | function (event) {
// Add the new gamepad on the list of gamepads to look after.
gamepadSupport.gamepads.push(event.gamepad);
// Ask the tester to update the screen to show more gamepads.
window.tester.updateGamepads(gamepadSupport.gamepads);
// Start the polling loop to monitor button changes.
... | javascript | {
"resource": ""
} | |
q7549 | train | function (event) {
// Remove the gamepad from the list of gamepads to monitor.
for (var i in gamepadSupport.gamepads) {
if (gamepadSupport.gamepads[i].index === event.gamepad.index) {
gamepadSupport.gamepads.splice(i, 1);
break;
}
}
// If no gamepads are left, stop the polli... | javascript | {
"resource": ""
} | |
q7550 | train | function (gamepadId) {
var gamepad = gamepadSupport.gamepads[gamepadId];
// Update all the buttons (and their corresponding labels) on screen.
window.tester.updateButton(gamepad.buttons[0], gamepadId, 'button-1');
window.tester.updateButton(gamepad.buttons[1], gamepadId, 'button-2');
window.tester.... | javascript | {
"resource": ""
} | |
q7551 | pushFiles | train | function pushFiles() {
console.info('Pushing files for ' + component);
git.push('origin', 'master', { args: '', cwd: outputDirectory }, function(error) {
console.info('Push completed successfully');
getSHA();
});
} | javascript | {
"resource": ""
} |
q7552 | getSHA | train | function getSHA() {
git.exec(versionOptions, function(error, version) {
version = version.trim();
createRelease(version);
});
} | javascript | {
"resource": ""
} |
q7553 | nextRepo | train | function nextRepo() {
console.log('Sleeping for 1 second...');
// avoid rate throttling
global.clearTimeout(timer);
timer = global.setTimeout(stepRepo, 100);
} | javascript | {
"resource": ""
} |
q7554 | Template | train | function Template(style, fields, opts) {
// throw early if style is incorrect
if (passFields.STYLES.indexOf(style) === -1) {
throw new Error('Incorrect passbook style ' + style)
}
this.style = style
this.opts = opts || {}
this.fields = fields || {}
// Set formatVersion by default
this.fields.... | javascript | {
"resource": ""
} |
q7555 | headingRange | train | function headingRange(node, options, callback) {
var test = options
var ignoreFinalDefinitions = false
// Object, not regex.
if (test && typeof test === 'object' && !('exec' in test)) {
ignoreFinalDefinitions = test.ignoreFinalDefinitions === true
test = test.test
}
if (typeof test === 'string') {... | javascript | {
"resource": ""
} |
q7556 | search | train | function search(root, test, skip, callback) {
var index = -1
var children = root.children
var length = children.length
var depth = null
var start = null
var end = null
var nodes
var clean
var child
while (++index < length) {
child = children[index]
if (closing(child, depth)) {
end = ... | javascript | {
"resource": ""
} |
q7557 | init | train | function init (prefs, callback) {
options = _.extend(defaults, prefs);
app = options.app || express();
app.use(cors());
ramlMocker.generate(options, process(function(requestsToMock){
requestsToMock.forEach(function(reqToMock){
addRoute(reqToMock);
});
log(new Array(30).join('='));
log('%s[%s]%s API rout... | javascript | {
"resource": ""
} |
q7558 | logout | train | function logout(_ref3) {
var state = _ref3.state,
commit = _ref3.commit;
commit('c3s/user/SET_CURRENT_USER', null, {
root: true
});
commit('SET_ANON', false);
} | javascript | {
"resource": ""
} |
q7559 | getActivities | train | function getActivities(_ref, _ref2) {
var state = _ref.state,
commit = _ref.commit,
dispatch = _ref.dispatch,
rootState = _ref.rootState;
var _ref3 = _slicedToArray(_ref2, 2),
search = _ref3[0],
limit = _ref3[1];
search = rison.encode(search);
return makeRequest... | javascript | {
"resource": ""
} |
q7560 | createActivity | train | function createActivity(_ref9, activity) {
var state = _ref9.state,
commit = _ref9.commit,
rootState = _ref9.rootState;
return makeRequest(commit, rootState.c3s.client.apis.Activities.create_activity, {
activity: activity
}, 'c3s/activity/SET_ACTIVITY');
} | javascript | {
"resource": ""
} |
q7561 | deleteActivity | train | function deleteActivity(_ref10, _ref11) {
var state = _ref10.state,
commit = _ref10.commit,
rootState = _ref10.rootState;
var _ref12 = _slicedToArray(_ref11, 2),
pid = _ref12[0],
localRemove = _ref12[1];
if (localRemove) commit('c3s/activity/SET_ACTIVITY', null);
return... | javascript | {
"resource": ""
} |
q7562 | deleteTasks | train | function deleteTasks(_ref12, tasks) {
var state = _ref12.state,
commit = _ref12.commit,
dispatch = _ref12.dispatch,
rootState = _ref12.rootState;
dispatch('SET_TASKS', null);
return makeRequest(commit, rootState.c3s.client.apis.Tasks.delete_tasks, {
tasks: tasks
}, 'c3s/tas... | javascript | {
"resource": ""
} |
q7563 | getProjects | train | function getProjects(_ref, _ref2) {
var state = _ref.state,
commit = _ref.commit,
dispatch = _ref.dispatch,
rootState = _ref.rootState;
var _ref3 = _slicedToArray(_ref2, 2),
search = _ref3[0],
limit = _ref3[1];
search = rison.encode(search);
return makeRequest(c... | javascript | {
"resource": ""
} |
q7564 | createProject | train | function createProject(_ref8, project) {
var state = _ref8.state,
commit = _ref8.commit,
rootState = _ref8.rootState;
return makeRequest(commit, rootState.c3s.client.apis.Projects.create_project, {
project: project
}, 'c3s/project/SET_PROJECT');
} | javascript | {
"resource": ""
} |
q7565 | deleteProject | train | function deleteProject(_ref9, _ref10) {
var state = _ref9.state,
commit = _ref9.commit,
rootState = _ref9.rootState;
var _ref11 = _slicedToArray(_ref10, 2),
pid = _ref11[0],
localRemove = _ref11[1];
if (localRemove) commit('c3s/project/SET_PROJECT', null);
return makeRe... | javascript | {
"resource": ""
} |
q7566 | install | train | function install(Vue) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
Swagger({
url: options.swaggerURL,
requestInterceptor: function requestInterceptor(req) {
// req.headers['content-type'] = 'application/json'
if (options.store.state.c3s && o... | javascript | {
"resource": ""
} |
q7567 | TraceWriter | train | function TraceWriter(logger, options) {
options = options || {};
EventEmitter.call(this);
/** @private */
this.logger_ = logger;
/** @private */
this.config_ = options;
/** @private {Array<string>} stringified traces to be published */
this.buffer_ = [];
/** @private {Object} default labels to be... | javascript | {
"resource": ""
} |
q7568 | arraySpliceOut | train | function arraySpliceOut(mutate, at, arr) {
var newLen = arr.length - 1;
var i = 0;
var g = 0;
var out = arr;
if (mutate) {
i = g = at;
} else {
out = new Array(newLen);
while (i < at) {
out[g++] = arr[i++];
}
}
++i;
while (i <= newLen) {
... | javascript | {
"resource": ""
} |
q7569 | arraySpliceIn | train | function arraySpliceIn(mutate, at, v, arr) {
var len = arr.length;
if (mutate) {
var _i = len;
while (_i >= at) {
arr[_i--] = arr[_i];
}arr[at] = v;
return arr;
}
var i = 0,
g = 0;
var out = new Array(len + 1);
while (i < at) {
out[g++]... | javascript | {
"resource": ""
} |
q7570 | Leaf | train | function Leaf(edit, hash, key, value) {
return {
type: LEAF,
edit: edit,
hash: hash,
key: key,
value: value,
_modify: Leaf__modify
};
} | javascript | {
"resource": ""
} |
q7571 | Collision | train | function Collision(edit, hash, children) {
return {
type: COLLISION,
edit: edit,
hash: hash,
children: children,
_modify: Collision__modify
};
} | javascript | {
"resource": ""
} |
q7572 | IndexedNode | train | function IndexedNode(edit, mask, children) {
return {
type: INDEX,
edit: edit,
mask: mask,
children: children,
_modify: IndexedNode__modify
};
} | javascript | {
"resource": ""
} |
q7573 | ArrayNode | train | function ArrayNode(edit, size, children) {
return {
type: ARRAY,
edit: edit,
size: size,
children: children,
_modify: ArrayNode__modify
};
} | javascript | {
"resource": ""
} |
q7574 | isLeaf | train | function isLeaf(node) {
return node === empty || node.type === LEAF || node.type === COLLISION;
} | javascript | {
"resource": ""
} |
q7575 | pack | train | function pack(edit, count, removed, elements) {
var children = new Array(count - 1);
var g = 0;
var bitmap = 0;
for (var i = 0, len = elements.length; i < len; ++i) {
if (i !== removed) {
var elem = elements[i];
if (elem && !isEmptyNode(elem)) {
children[g... | javascript | {
"resource": ""
} |
q7576 | mergeLeaves | train | function mergeLeaves(edit, shift, h1, n1, h2, n2) {
if (h1 === h2) return Collision(edit, h1, [n2, n1]);
var subH1 = hashFragment(shift, h1);
var subH2 = hashFragment(shift, h2);
return IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), subH1 === subH2 ? [mergeLeaves(edit, shift + SIZE, h1, n1, h2, n... | javascript | {
"resource": ""
} |
q7577 | updateCollisionList | train | function updateCollisionList(mutate, edit, keyEq, h, list, f, k, size) {
var len = list.length;
for (var i = 0; i < len; ++i) {
var child = list[i];
if (keyEq(k, child.key)) {
var value = child.value;
var _newValue = f(value);
if (_newValue === value) return l... | javascript | {
"resource": ""
} |
q7578 | lazyVisitChildren | train | function lazyVisitChildren(len, children, i, f, k) {
while (i < len) {
var child = children[i++];
if (child && !isEmptyNode(child)) return lazyVisit(child, f, [len, children, i, f, k]);
}
return appk(k);
} | javascript | {
"resource": ""
} |
q7579 | lazyVisit | train | function lazyVisit(node, f, k) {
switch (node.type) {
case LEAF:
return {
value: f(node),
rest: k
};
case COLLISION:
case ARRAY:
case INDEX:
var children = node.children;
return lazyVisitChildren(childre... | javascript | {
"resource": ""
} |
q7580 | truncate | train | function truncate(string, length) {
if (Buffer.byteLength(string, 'utf8') <= length) {
return string;
}
string = string.substr(0, length - 3);
while (Buffer.byteLength(string, 'utf8') > length - 3) {
string = string.substr(0, string.length - 1);
}
return string + '...';
} | javascript | {
"resource": ""
} |
q7581 | findModulePath | train | function findModulePath(request, parent) {
var mainScriptDir = path.dirname(Module._resolveFilename(request, parent));
var resolvedModule = Module._resolveLookupPaths(request, parent);
var paths = resolvedModule[1];
for (var i = 0, PL = paths.length; i < PL; i++) {
if (mainScriptDir.indexOf(paths[i]) === 0)... | javascript | {
"resource": ""
} |
q7582 | findModuleVersion | train | function findModuleVersion(modulePath, load) {
if (modulePath) {
var pjson = path.join(modulePath, 'package.json');
if (fs.existsSync(pjson)) {
return load(pjson).version;
}
}
return process.version;
} | javascript | {
"resource": ""
} |
q7583 | train | function( queryOptions, callback ) {
var _this = this;
if ( typeof queryOptions === 'function' ) {
callback = queryOptions;
this.capabilities( function( err, capabilities ) {
if ( err ) {
debug( "Error getting layers for server '%s': %j", _this.baseUrl,
err.stack );
return callback( err );... | javascript | {
"resource": ""
} | |
q7584 | train | function( queryOptions, callback ) {
var _this = this;
if ( typeof queryOptions === 'function' ) {
callback = queryOptions;
this.capabilities( function( err, capabilities ) {
if ( err ) {
debug( 'Error getting layers: %j', err );
return callback( err );
}
if ( _this.version === '1.3.0' )... | javascript | {
"resource": ""
} | |
q7585 | train | function( queryOptions, callback ) {
if ( typeof queryOptions === 'function' ) {
callback = queryOptions;
queryOptions = {};
}
this.capabilities( queryOptions, function( err, capabilities ) {
if ( err ) {
debug( 'Error getting service metadata: %j', err );
return callback( err );
}
callback... | javascript | {
"resource": ""
} | |
q7586 | train | function( wmsBaseUrl, queryOptions ) {
queryOptions = extend( {
request: 'GetCapabilities',
version: this.version,
service: 'WMS'
}, queryOptions );
// Append user provided GET parameters in the URL to required queryOptions
var urlQueryParams = new urijs( wmsBaseUrl ).search( true );
queryOptions = e... | javascript | {
"resource": ""
} | |
q7587 | train | function( minx, miny, maxx, maxy ) {
var bbox = '';
if ( this.version === '1.3.0' ) {
bbox = [minx, miny, maxx, maxy].join( ',' );
} else {
bbox = [miny, minx, maxy, maxx].join( ',' );
}
return bbox;
} | javascript | {
"resource": ""
} | |
q7588 | checkParameter | train | function checkParameter(validator, def, context) {
var value = match.fromContext(def.name, def.in, context);
// Check requirement
if(def.required && !value) {
throw new ValidationError(def.name + " is required");
} else if(!value) {
return def.default;
}
// Select the right schema according to the... | javascript | {
"resource": ""
} |
q7589 | createError | train | function createError(code, type, desc) {
errors[code] = function (msg, meta) {
const err = new type(msg);
if (desc) {
if (!meta) {
meta = {};
}
meta.desc = desc;
}
return Object.defineProperties(err, {
code: {
configurable: true,
enumerable: true,
writable: true,
value: `ERR_$... | javascript | {
"resource": ""
} |
q7590 | train | function(config) {
config = config || extend(false, {}, defaults);
/*--------------
File Paths
---------------*/
var
configPath = this.getPath(),
sourcePaths = {},
outputPaths = {},
folder
;
// resolve paths (config location + base + path)
for(folder in con... | javascript | {
"resource": ""
} | |
q7591 | train | function(exists, cb) {
if(!exists) {
fs.mkdir(rootDir + '/node_modules', function(error) {
cb(error);
});
} else {
cb(null);
}
} | javascript | {
"resource": ""
} | |
q7592 | SpanData | train | function SpanData(agent, trace, name, parentSpanId, isRoot, skipFrames) {
var spanId = uid++;
this.agent = agent;
var spanName = traceUtil.truncate(name, constants.TRACE_SERVICE_SPAN_NAME_LIMIT);
this.span = new TraceSpan(spanName, spanId, parentSpanId);
this.trace = trace;
this.isRoot = isRoot;
trace.spa... | javascript | {
"resource": ""
} |
q7593 | wrapCallback | train | function wrapCallback(api, span, done) {
var fn = function(err, res) {
if (api.enhancedDatabaseReportingEnabled()) {
if (err) {
// Errors may contain sensitive query parameters.
span.addLabel('mongoError', err);
}
if (res) {
var result = res.result ? res.result : res;
... | javascript | {
"resource": ""
} |
q7594 | TraceSpan | train | function TraceSpan(name, spanId, parentSpanId) {
this.name = name;
this.parentSpanId = parentSpanId;
this.spanId = spanId;
this.kind = 'RPC_CLIENT';
this.labels = {};
this.startTime = (new Date()).toISOString();
this.endTime = '';
} | javascript | {
"resource": ""
} |
q7595 | printHeadingCB | train | function printHeadingCB(err, heading) {
if (err) {
console.log(err);
return;
}
console.log(heading * 180 / Math.PI);
} | javascript | {
"resource": ""
} |
q7596 | ChildSpan | train | function ChildSpan(agent, span) {
this.agent_ = agent;
this.span_ = span;
this.serializedTraceContext_ = agent.generateTraceContext(span, true);
} | javascript | {
"resource": ""
} |
q7597 | RootSpan | train | function RootSpan(agent, span) {
this.agent_ = agent;
this.span_ = span;
this.serializedTraceContext_ = agent.generateTraceContext(span, true);
} | javascript | {
"resource": ""
} |
q7598 | TraceApiImplementation | train | function TraceApiImplementation(agent, pluginName) {
this.agent_ = agent;
this.logger_ = agent.logger;
this.pluginName_ = pluginName;
} | javascript | {
"resource": ""
} |
q7599 | createRootSpan_ | train | function createRootSpan_(api, options, skipFrames) {
options = options || {};
// If the options object passed in has the getTraceContext field set,
// try to retrieve the header field containing incoming trace metadata.
var incomingTraceContext;
if (is.string(options.traceContext)) {
incomingTraceContext ... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.