_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q44500
call
train
function call(method, key) { if (!exports.results.has(method)) create(method); // create as needed const methodCache = exports.results.get(method); let callResults; if (methodCache.has(key)) { log_1.logger.debug(`[${method}] Calling (cached): ${key}`); // return from cache if key...
javascript
{ "resource": "" }
q44501
get
train
function get(method, key) { if (exports.results.has(method)) return exports.results.get(method).get(key); }
javascript
{ "resource": "" }
q44502
getQueryString
train
function getQueryString(data) { if (!data || typeof data !== 'object' || !Object.keys(data).length) return ''; return '?' + Object.keys(data).map((k) => { const value = (typeof data[k] === 'object') ? JSON.stringify(data[k]) : encodeURIComponent(data[k]); return `...
javascript
{ "resource": "" }
q44503
getHeaders
train
function getHeaders(authRequired = false) { if (!authRequired) return exports.basicHeaders; if ((!('X-Auth-Token' in exports.authHeaders) || !('X-User-Id' in exports.authHeaders)) || exports.authHeaders['X-Auth-Token'] === '' || exports.authHeaders['X-User-Id'] === '') { throw ne...
javascript
{ "resource": "" }
q44504
success
train
function success(result, ignore) { return ((typeof result.error === 'undefined' && typeof result.status === 'undefined' && typeof result.success === 'undefined') || (result.status && result.status === 'success') || (result.success && result.success === true) || (ignore && res...
javascript
{ "resource": "" }
q44505
get
train
function get(endpoint, data, auth = true, ignore) { return __awaiter(this, void 0, void 0, function* () { try { log_1.logger.debug(`[API] GET: ${endpoint}`, data); if (auth && !loggedIn()) yield login(); let headers = getHeaders(auth); const qu...
javascript
{ "resource": "" }
q44506
login
train
function login(user = { username: settings.username, password: settings.password }) { return __awaiter(this, void 0, void 0, function* () { log_1.logger.info(`[API] Logging in ${user.username}`); if (exports.currentLogin !== null) { log_1.logger.debug(`[API] Already logged in`); ...
javascript
{ "resource": "" }
q44507
logout
train
function logout() { if (exports.currentLogin === null) { log_1.logger.debug(`[API] Already logged out`); return Promise.resolve(); } log_1.logger.info(`[API] Logging out ${exports.currentLogin.username}`); return get('logout', null, true).then(() => { clearHeaders(); expo...
javascript
{ "resource": "" }
q44508
asyncCall
train
function asyncCall(method, params) { if (!Array.isArray(params)) params = [params]; // cast to array for apply log_1.logger.info(`[${method}] Calling (async): ${JSON.stringify(params)}`); return Promise.resolve(exports.asteroid.apply(method, params).result) .catch((err) => { log_1.lo...
javascript
{ "resource": "" }
q44509
callMethod
train
function callMethod(name, params) { return (methodCache.has(name) || typeof params === 'undefined') ? asyncCall(name, params) : cacheCall(name, params); }
javascript
{ "resource": "" }
q44510
cacheCall
train
function cacheCall(method, key) { return methodCache.call(method, key) .catch((err) => { log_1.logger.error(`[${method}] Error:`, err); throw err; // throw after log to stop async chain }) .then((result) => { (result) ? log_1.logger.debug(`[${method}] Success:...
javascript
{ "resource": "" }
q44511
logout
train
function logout() { return exports.asteroid.logout() .catch((err) => { log_1.logger.error('[Logout] Error:', err); throw err; // throw after log to stop async chain }); }
javascript
{ "resource": "" }
q44512
unsubscribe
train
function unsubscribe(subscription) { const index = exports.subscriptions.indexOf(subscription); if (index === -1) return; subscription.stop(); // asteroid.unsubscribe(subscription.id) // v2 exports.subscriptions.splice(index, 1); // remove from collection log_1.logger.info(`[${subscripti...
javascript
{ "resource": "" }
q44513
subscribeToMessages
train
function subscribeToMessages() { return subscribe(_messageCollectionName, _messageStreamName) .then((subscription) => { exports.messages = exports.asteroid.getCollection(_messageCollectionName); return subscription; }); }
javascript
{ "resource": "" }
q44514
respondToMessages
train
function respondToMessages(callback, options = {}) { const config = Object.assign({}, settings, options); // return value, may be replaced by async ops let promise = Promise.resolve(); // Join configured rooms if they haven't been already, unless listening to all // public rooms, in which case it do...
javascript
{ "resource": "" }
q44515
leaveRoom
train
function leaveRoom(room) { return __awaiter(this, void 0, void 0, function* () { let roomId = yield getRoomId(room); let joinedIndex = exports.joinedIds.indexOf(room); if (joinedIndex === -1) { log_1.logger.error(`[leaveRoom] failed because bot has not joined ${room}`); }...
javascript
{ "resource": "" }
q44516
prepareMessage
train
function prepareMessage(content, roomId) { const message = new message_1.Message(content, exports.integrationId); if (roomId) message.setRoomId(roomId); return message; }
javascript
{ "resource": "" }
q44517
getControllerDir
train
function getControllerDir(isInstall) { var fs = require('fs'); // Find the js-controller location var controllerDir = __dirname.replace(/\\/g, '/'); controllerDir = controllerDir.split('/'); if (controllerDir[controllerDir.length - 3] === 'adapter') { controllerDir.splice(controllerDir...
javascript
{ "resource": "" }
q44518
getConfig
train
function getConfig() { var fs = require('fs'); if (fs.existsSync(controllerDir + '/conf/' + appName + '.json')) { return JSON.parse(fs.readFileSync(controllerDir + '/conf/' + appName + '.json')); } else if (fs.existsSync(controllerDir + '/conf/' + appName.toLowerCase() + '.json')) { ret...
javascript
{ "resource": "" }
q44519
train
function (remove) { if (!L.DomEvent) { return; } this._targets = {}; this._targets[L.stamp(this._container)] = this; var onOff = remove ? 'off' : 'on'; // @event click: MouseEvent // Fired when the user clicks (or taps) the map. // @event dblclick: MouseEvent // Fired when the user double-...
javascript
{ "resource": "" }
q44520
train
function (center, zoom, bounds) { if (!bounds) { return center; } var centerPoint = this.project(center, zoom), viewHalf = this.getSize().divideBy(2), viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)), offset = this._getBoundsOffset(viewBounds, bounds, z...
javascript
{ "resource": "" }
q44521
train
function (center) { var map = this._map; if (!map) { return; } var zoom = map.getZoom(); if (center === undefined) { center = map.getCenter(); } if (this._tileZoom === undefined) { return; } // if out of minzoom/maxzoom var pixelBounds = this._getTiledPixelBounds(center), tileRange = this._pxBoundsT...
javascript
{ "resource": "" }
q44522
train
function (coords) { var map = this._map, tileSize = this.getTileSize(), nwPoint = coords.scaleBy(tileSize), sePoint = nwPoint.add(tileSize), nw = map.wrapLatLng(map.unproject(nwPoint, coords.z)), se = map.wrapLatLng(map.unproject(sePoint, coords.z)); return new L.LatLngBounds(nw, s...
javascript
{ "resource": "" }
q44523
train
function (key) { var k = key.split(':'), coords = new L.Point(+k[0], +k[1]); coords.z = +k[2]; return coords; }
javascript
{ "resource": "" }
q44524
train
function (latlngs) { var result = [], flat = L.Polyline._flat(latlngs); for (var i = 0, len = latlngs.length; i < len; i++) { if (flat) { result[i] = L.latLng(latlngs[i]); this._bounds.extend(result[i]); } else { result[i] = this._convertLatLngs(latlngs[i]); } } return result; }
javascript
{ "resource": "" }
q44525
train
function (latlngs, result, projectedBounds) { var flat = latlngs[0] instanceof L.LatLng, len = latlngs.length, i, ring; if (flat) { ring = []; for (i = 0; i < len; i++) { ring[i] = this._map.latLngToLayerPoint(latlngs[i]); projectedBounds.extend(ring[i]); } result.push(ring); } el...
javascript
{ "resource": "" }
q44526
train
function () { var bounds = this._renderer._bounds; this._parts = []; if (!this._pxBounds || !this._pxBounds.intersects(bounds)) { return; } if (this.options.noClip) { this._parts = this._rings; return; } var parts = this._parts, i, j, k, len, len2, segment, points; for (i = 0, k = 0, ...
javascript
{ "resource": "" }
q44527
train
function () { var parts = this._parts, tolerance = this.options.smoothFactor; for (var i = 0, len = parts.length; i < len; i++) { parts[i] = L.LineUtil.simplify(parts[i], tolerance); } }
javascript
{ "resource": "" }
q44528
train
function (layer) { var path = layer._path = L.SVG.create('path'); // @namespace Path // @option className: String = null // Custom class name set on an element. Only for SVG renderer. if (layer.options.className) { L.DomUtil.addClass(path, layer.options.className); } if (layer.options.interactive) { ...
javascript
{ "resource": "" }
q44529
train
function (e, handler) { var timeStamp = (e.timeStamp || (e.originalEvent && e.originalEvent.timeStamp)), elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); // are they closer together than 500ms yet more than 100ms? // Android typically triggers them ~300ms apart while multiple li...
javascript
{ "resource": "" }
q44530
train
function(config) { config.client .query(config.query.analysis_type, _.omit(config.query, 'analysis_type')) .then(function(res, err){ if (err) { config.error(err); } else { config.success(res); } if (config.complete) config.complete(err, res); ...
javascript
{ "resource": "" }
q44531
_getDefaultFilterCoercionType
train
function _getDefaultFilterCoercionType(explorer, filter) { var propertyType = ProjectUtils.getPropertyType( ProjectStore.getProject(), explorer.query.event_collection, filter.property_name); var targetCoercionType = FormatUtils.coercionTypeForPropertyType(propertyType); return targetCoercionType; }
javascript
{ "resource": "" }
q44532
_prepareUpdates
train
function _prepareUpdates(explorer, updates) { // TODO: We're assigning the response object directly onto the model so we // don't have to loop through the (sometimes) massive response object. function customizer(objValue, srcValue, key) { if (_.isArray(objValue)) { return srcValue; } else if (key ==...
javascript
{ "resource": "" }
q44533
_migrateToFunnel
train
function _migrateToFunnel(explorer, newModel) { var firstStep = _defaultStep(); firstStep.active = true; _.each(SHARED_FUNNEL_STEP_PROPERTIES, function (key) { if(!_.isUndefined(explorer.query[key]) && !_.isNull(explorer.query[key])) { firstStep[key] = explorer.query[key] } newModel.query[key]...
javascript
{ "resource": "" }
q44534
_migrateFromFunnel
train
function _migrateFromFunnel(explorer, newModel) { if (explorer.query.steps.length < 1) return newModel; var activeStep = _.find(explorer.query.steps, { active: true }) || explorer.query.steps[0]; _.each(SHARED_FUNNEL_STEP_PROPERTIES, function (key) { if (!_.isUndefined(activeStep[key])) { newModel.quer...
javascript
{ "resource": "" }
q44535
_removeInvalidFields
train
function _removeInvalidFields(newModel) { if (!ExplorerUtils.isEmailExtraction(newModel)) { newModel.query.latest = null; newModel.query.email = null; } if (newModel.query.analysis_type === 'extraction') { newModel.query.group_by = null; newModel.query.order_by = null; newModel.query.limit = n...
javascript
{ "resource": "" }
q44536
_prepareFilterUpdates
train
function _prepareFilterUpdates(explorer, filter, updates) { if (updates.property_name && updates.property_name !== filter.property_name) { if (filter.operator === 'exists') { updates.coercion_type = 'Boolean'; } else { // No need to update the operator - we allow any operator for any property type...
javascript
{ "resource": "" }
q44537
_migrateAddonInitializers
train
function _migrateAddonInitializers(project) { project.addons.forEach(addon => { const currentAddonPath = addon.root; _checkBrowserInitializers(currentAddonPath); _moveFastBootInitializers(project, currentAddonPath); }); }
javascript
{ "resource": "" }
q44538
_migrateHostAppInitializers
train
function _migrateHostAppInitializers(project) { const hostAppPath = path.join(project.root); _checkBrowserInitializers(hostAppPath); _moveFastBootInitializers(project, hostAppPath); }
javascript
{ "resource": "" }
q44539
train
function() { var editMode = $scope.editMode; if (angular.isUndefined(editMode) || (editMode === null)) return; //Set completed for all steps to the value of editMode angular.forEach($scope.steps, function (step) { step.completed = edit...
javascript
{ "resource": "" }
q44540
unselectAll
train
function unselectAll() { //traverse steps array and set each "selected" property to false angular.forEach($scope.getEnabledSteps(), function (step) { step.selected = false; }); //set selectedStep variable to null $scope....
javascript
{ "resource": "" }
q44541
train
function() { const bounds = this._pixelBounds(); const pixelSize = (bounds.max.x - bounds.min.x) / this._field.nCols; var stride = Math.max( 1, Math.floor(1.2 * this.options.vectorSize / pixelSize) ); const ctx = this._getDrawingContext(); ctx.st...
javascript
{ "resource": "" }
q44542
_drawParticles
train
function _drawParticles() { // Previous paths... let prev = ctx.globalCompositeOperation; ctx.globalCompositeOperation = 'destination-in'; ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); //ctx.globalCompositeOperation = 'source-over'; ctx....
javascript
{ "resource": "" }
q44543
updateLines
train
function updateLines(from, to, newText, selFrom, selTo) { if (suppressEdits) return; var old = []; doc.iter(from.line, to.line + 1, function(line) { old.push(newHL(line.text, line.markedSpans)); }); if (history) { history.addChange(from.line, newText.length, old); w...
javascript
{ "resource": "" }
q44544
setSelection
train
function setSelection(from, to, oldFrom, oldTo) { goalColumn = null; if (oldFrom == null) {oldFrom = sel.from.line; oldTo = sel.to.line;} if (posEq(sel.from, from) && posEq(sel.to, to)) return; if (posLess(to, from)) {var tmp = to; to = from; from = tmp;} // Skip over hidden lines. ...
javascript
{ "resource": "" }
q44545
restartBlink
train
function restartBlink() { clearInterval(blinker); var on = true; cursor.style.visibility = ""; blinker = setInterval(function() { cursor.style.visibility = (on = !on) ? "" : "hidden"; }, options.cursorBlinkRate); }
javascript
{ "resource": "" }
q44546
connect
train
function connect(node, type, handler, disconnect) { if (typeof node.addEventListener == "function") { node.addEventListener(type, handler, false); if (disconnect) return function() {node.removeEventListener(type, handler, false);}; } else { var wrapHandler = function(event) {handler(event || w...
javascript
{ "resource": "" }
q44547
patchFetchForRelativeURLs
train
function patchFetchForRelativeURLs(instance) { const fastboot = instance.lookup('service:fastboot'); const request = fastboot.get('request'); // Prember is not sending protocol const protocol = request.protocol === 'undefined:' ? 'http:' : request.protocol; // host is cp setupFastboot(protocol, request.get(...
javascript
{ "resource": "" }
q44548
ondata
train
function ondata(chunk) { packet.push(chunk); if (packet.isReady()) { if (self._state.sessionId !== packet.header.sessionId) { self._state.sessionId = packet.header.sessionId; self._state.packetCount = -1; } var buffer = packet.getData(); packet.clear(); var cb = sel...
javascript
{ "resource": "" }
q44549
appendToHead
train
function appendToHead(document, tagName, attrs) { var elt = document.createElement(tagName); DOMDataUtils.addAttributes(elt, attrs || Object.create(null)); document.head.appendChild(elt); }
javascript
{ "resource": "" }
q44550
DOMPostOrder
train
function DOMPostOrder(root, visitFunc) { let node = root; while (true) { // Find leftmost (grand)child, and visit that first. while (node.firstChild) { node = node.firstChild; } visitFunc(node); while (true) { if (node === root) { return; // Visiting the root is the last thing we do. } /* Lo...
javascript
{ "resource": "" }
q44551
buildAsyncOutputBufferCB
train
function buildAsyncOutputBufferCB(cb) { function AsyncOutputBufferCB(cb2) { this.accum = []; this.targetCB = cb2; } AsyncOutputBufferCB.prototype.processAsyncOutput = function(res) { // * Ignore switch-to-async mode calls since // we are actually collapsing async calls. // * Accumulate async call result...
javascript
{ "resource": "" }
q44552
train
function(res, text, httpStatus) { processLogger.log('fatal/request', text); apiUtils.errorResponse(res, text, httpStatus || 404); }
javascript
{ "resource": "" }
q44553
train
function(doc, pb) { // Effectively, skip applying data-parsoid. Note that if we were to // support a pb2html downgrade, we'd need to apply the full thing, // but that would create complications where ids would be left behind. // See the comment in around `DOMDataUtils.applyPageBundle` DOMDataUtils.applyPageBundle...
javascript
{ "resource": "" }
q44554
train
function(codepoint) { // U+000C is valid in HTML5 but not allowed in XML. // U+000D is valid in XML but not allowed in HTML5. // U+007F - U+009F are disallowed in HTML5 (control characters). return codepoint === 0x09 || codepoint === 0x0a || (codepoint >= 0x20 && codepoint <= 0x7e) || (codepoint >= 0xa...
javascript
{ "resource": "" }
q44555
Batcher
train
function Batcher(env) { this.env = env; this.itemCallbacks = {}; this.currentBatch = []; this.pendingBatches = []; this.resultCache = {}; this.numOutstanding = 0; this.forwardProgressTimer = null; this.maxBatchSize = env.conf.parsoid.batchSize; this.targetConcurrency = env.conf.parsoid.batchConcurrency; // Ma...
javascript
{ "resource": "" }
q44556
train
function(node) { if (node.code) { // remove trailing whitespace for single-line predicates var code = node.code.replace(/[ \t]+$/, ''); // wrap with a function, to prevent spurious errors caused // by redeclarations or multiple returns in a block. rulesSource += tab + '(function() {\n' + code + '\n' + ...
javascript
{ "resource": "" }
q44557
train
function(options) { if (!options) { options = {}; } Object.keys(options).forEach(function(k) { console.assert(supportedOptions.has(k), 'Invalid cacheKey option: ' + k); }); // default: not an include context if (options.isInclude === undefined) { options.isInclude = false; } // default: wrap templates if...
javascript
{ "resource": "" }
q44558
startsOnANewLine
train
function startsOnANewLine(node) { var name = node.nodeName.toUpperCase(); return Consts.BlockScopeOpenTags.has(name) && !WTUtils.isLiteralHTMLNode(node) && name !== "BLOCKQUOTE"; }
javascript
{ "resource": "" }
q44559
hasBlocksOnLine
train
function hasBlocksOnLine(node, first) { // special case for firstNode: // we're at sol so ignore possible \n at first char if (first) { if (node.textContent.substring(1).match(/\n/)) { return false; } node = node.nextSibling; } while (node) { if (DOMUtils.isElt(node)) { if (DOMUtils.isBlockNode(nod...
javascript
{ "resource": "" }
q44560
logTypeToString
train
function logTypeToString(logType) { var logTypeString; if (logType instanceof RegExp) { logTypeString = logType.source; } else if (typeof (logType) === 'string') { logTypeString = '^' + JSUtils.escapeRegExp(logType) + '$'; } else { throw new Error('logType is neither a regular expression nor a string.'); } ...
javascript
{ "resource": "" }
q44561
train
function(parsoidConfig, options) { options = options || {}; // page information this.page = new Page(); Object.assign(this, options); // Record time spent in various passes this.timeProfile = {}; this.ioProfile = {}; this.mwProfile = {}; this.timeCategories = {}; this.counts = {}; // execution state thi...
javascript
{ "resource": "" }
q44562
TemplateRequest
train
function TemplateRequest(env, title, oldid, opts) { ApiRequest.call(this, env, title); // IMPORTANT: Set queueKey to the 'title' // since TemplateHandler uses it for recording listeners this.queueKey = title; this.reqType = "Template Fetch"; opts = opts || {}; // optional extra arguments var apiargs = { forma...
javascript
{ "resource": "" }
q44563
PreprocessorRequest
train
function PreprocessorRequest(env, title, text, queueKey) { ApiRequest.call(this, env, title); this.queueKey = queueKey; this.text = text; this.reqType = "Template Expansion"; var apiargs = { format: 'json', formatversion: 2, action: 'expandtemplates', prop: 'wikitext|categories|properties|modules|jsconfig...
javascript
{ "resource": "" }
q44564
PHPParseRequest
train
function PHPParseRequest(env, title, text, onlypst, queueKey) { ApiRequest.call(this, env, title); this.text = text; this.queueKey = queueKey || text; this.reqType = "Extension Parse"; var apiargs = { format: 'json', formatversion: 2, action: 'parse', text: text, disablelimitreport: 'true', contentmod...
javascript
{ "resource": "" }
q44565
BatchRequest
train
function BatchRequest(env, batchParams, key) { ApiRequest.call(this, env); this.queueKey = key; this.batchParams = batchParams; this.reqType = 'Batch request'; this.batchText = JSON.stringify(batchParams); var apiargs = { format: 'json', formatversion: 2, action: 'parsoid-batch', batch: this.batchText, ...
javascript
{ "resource": "" }
q44566
train
function(env) { ApiRequest.call(this, env, null); this.queueKey = env.conf.wiki.apiURI; this.reqType = "Config Request"; var metas = [ 'siteinfo' ]; var siprops = [ 'namespaces', 'namespacealiases', 'magicwords', 'functionhooks', 'extensiontags', 'general', 'interwikimap', 'languages', 'language...
javascript
{ "resource": "" }
q44567
ImageInfoRequest
train
function ImageInfoRequest(env, filename, dims, key) { ApiRequest.call(this, env, null); this.env = env; this.queueKey = key; this.reqType = "Image Info Request"; var conf = env.conf.wiki; var filenames = [ filename ]; var imgnsid = conf.canonicalNamespaces.image; var imgns = conf.namespaceNames[imgnsid]; var ...
javascript
{ "resource": "" }
q44568
TemplateDataRequest
train
function TemplateDataRequest(env, template, queueKey) { ApiRequest.call(this, env, null); this.env = env; this.text = template; this.queueKey = queueKey; this.reqType = "TemplateData Request"; var apiargs = { format: 'json', // XXX: should use formatversion=2 action: 'templatedata', includeMissingTitles:...
javascript
{ "resource": "" }
q44569
LintRequest
train
function LintRequest(env, data, queueKey) { ApiRequest.call(this, env, null); this.queueKey = queueKey || data; this.reqType = 'Lint Request'; var apiargs = { data: data, page: env.page.name, revision: env.page.meta.revision.revid, action: 'record-lint', format: 'json', formatversion: 2, }; this.req...
javascript
{ "resource": "" }
q44570
ParamInfoRequest
train
function ParamInfoRequest(env, queueKey) { ApiRequest.call(this, env, null); this.reqType = 'ParamInfo Request'; var apiargs = { format: 'json', // XXX: should use formatversion=2 action: 'paraminfo', modules: 'query', rawcontinue: 1, }; this.queueKey = queueKey || JSON.stringify(apiargs); this.reque...
javascript
{ "resource": "" }
q44571
getSepNlConstraints
train
function getSepNlConstraints(state, nodeA, aCons, nodeB, bCons) { const env = state.env; const nlConstraints = { min: aCons.min, max: aCons.max, force: aCons.force || bCons.force, }; // now figure out if this conflicts with the nlConstraints so far if (bCons.min !== undefined) { if (nlConstraints.max !==...
javascript
{ "resource": "" }
q44572
mergeConstraints
train
function mergeConstraints(env, oldConstraints, newConstraints) { const res = { min: Math.max(oldConstraints.min || 0, newConstraints.min || 0), max: Math.min( oldConstraints.max !== undefined ? oldConstraints.max : 2, newConstraints.max !== undefined ? newConstraints.max : 2 ), force: oldConstraints.forc...
javascript
{ "resource": "" }
q44573
train
function(state, nodeA, sepHandlerA, nodeB, sepHandlerB) { let sepType, nlConstraints, aCons, bCons; if (nodeA.nextSibling === nodeB) { // sibling separator sepType = "sibling"; aCons = sepHandlerA.after(nodeA, nodeB, state); bCons = sepHandlerB.before(nodeB, nodeA, state); nlConstraints = getSepNlConstrain...
javascript
{ "resource": "" }
q44574
train
function(node) { var dp = DOMDataUtils.getDataParsoid(node); var dsr = Util.clone(dp.dsr); if (dp.autoInsertedStart) { dsr[2] = null; } if (dp.autoInsertedEnd) { dsr[3] = null; } return dsr; }
javascript
{ "resource": "" }
q44575
train
function(diff) { var ret = []; diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier // Formats a given set of lines for printing as context lines in a patch function contextLines(lines) { return lines.map(function(entry) { return ' ' + entry; }); } var oldRangeStart = 0; var...
javascript
{ "resource": "" }
q44576
train
function(value) { var ret = []; var linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line if (!linesAndNewlines[linesAndNewlines.length - 1]) { linesAndNewlines.pop(); } // Merge the content and line separators into single tokens for...
javascript
{ "resource": "" }
q44577
mergable
train
function mergable(a, b) { return a.nodeName === b.nodeName && similar(a, b); }
javascript
{ "resource": "" }
q44578
swappable
train
function swappable(a, b) { return DOMUtils.numNonDeletedChildNodes(a) === 1 && similar(a, DOMUtils.firstNonDeletedChild(a)) && mergable(DOMUtils.firstNonDeletedChild(a), b); }
javascript
{ "resource": "" }
q44579
train
function(parsoidOptions, cliOpts) { [ 'fetchConfig', 'fetchTemplates', 'fetchImageInfo', 'expandExtensions', 'rtTestMode', 'addHTMLTemplateParameters', ].forEach(function(c) { if (cliOpts[c] !== undefined) { parsoidOptions[c] = ScriptUtils.booleanOption(cliOpts[c]); } }); if (cliOpts...
javascript
{ "resource": "" }
q44580
train
function(options) { var colors = require('colors'); if (options.color === 'auto') { if (!process.stdout.isTTY) { colors.mode = 'none'; } } else if (!ScriptUtils.booleanOption(options.color)) { colors.mode = 'none'; } }
javascript
{ "resource": "" }
q44581
merge
train
function merge (inputs) { var output = { type: 'FeatureCollection', features: [] }; for (var i = 0; i < inputs.length; i++) { var normalized = normalize(inputs[i]); for (var j = 0; j < normalized.features.length; j++) { output.features.push(normalized.features[j])...
javascript
{ "resource": "" }
q44582
mergeFeatureCollectionStream
train
function mergeFeatureCollectionStream (inputs) { var out = geojsonStream.stringify(); inputs.forEach(function(file) { fs.createReadStream(file) .pipe(geojsonStream.parse()) .pipe(out); }); return out; }
javascript
{ "resource": "" }
q44583
onerror
train
function onerror(err) { if (!err) { return; } debug('[%s] [cfork:master:%s] master uncaughtException: %s', Date(), process.pid, err.stack); debug(err); debug('(total %d disconnect, %d unexpected exit)', disconnectCount, unexpectedCount); }
javascript
{ "resource": "" }
q44584
onUnexpected
train
function onUnexpected(worker, code, signal) { var exitCode = worker.process.exitCode; var err = new Error(util.format('worker:%s died unexpected (code: %s, signal: %s, exitedAfterDisconnect: %s, state: %s)', worker.process.pid, exitCode, signal, worker.exitedAfterDisconnect, worker.state)); err.name =...
javascript
{ "resource": "" }
q44585
normalizeSlaveConfig
train
function normalizeSlaveConfig(opt) { // exec path if (typeof opt === 'string') { opt = { exec: opt }; } if (!opt.exec) { return null; } else { return opt; } }
javascript
{ "resource": "" }
q44586
forkWorker
train
function forkWorker(settings, env) { if (settings) { cluster.settings = settings; cluster.setupMaster(); } return cluster.fork(env); }
javascript
{ "resource": "" }
q44587
MouseEvent
train
function MouseEvent(eventType, params) { params = params || { bubbles: false, cancelable: false }; var mouseEvent = document.createEvent('MouseEvent'); mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); return mouseEvent;...
javascript
{ "resource": "" }
q44588
simulateMouseEvent
train
function simulateMouseEvent(e) { e.preventDefault(); const touch = e.changedTouches[0]; const eventMap = { 'touchstart': 'mousedown', 'touchmove': 'mousemove', 'touchend': 'mouseup' } touch.target.dispatchEvent(new MouseEvent(eventMap[e.type], { bubbles: true, cancelable: true, view: ...
javascript
{ "resource": "" }
q44589
onCardHeaderClick
train
function onCardHeaderClick(e) { if (/** @type {!Element} */(e.target).nodeName == 'A') { return; } /** @type {?Node} */ const node = /** @type {!Element} */(e.currentTarget).parentNode; if (node && node.nodeType === NodeType.ELEMENT) { const card = /** @type {!Element} */(node); if (card.classLis...
javascript
{ "resource": "" }
q44590
parseMessage
train
function parseMessage(message) { const parts = message.content.split(' '); const command = parts[1]; const args = parts.slice(2); if (typeof Commands[command] === 'function') { // @TODO We could check the command validity here return { command, args }; } else { return null; } }
javascript
{ "resource": "" }
q44591
train
function (next) { console.log(chalk.yellow.bold('Publishing wiki...')); // create a location to clone repository // @todo - maybe do this outside in an os-level temp folder to avoid recursive .git mkdir('-p', WIKI_GIT_PATH); rm('-rf', WIKI_GIT_PATH); ...
javascript
{ "resource": "" }
q44592
train
function (next) { var source = fs.readFileSync(path.join('out', 'wiki', 'REFERENCE.md')).toString(), home, sidebar; // extract sidebar from source sidebar = source.replace(/<a name="Collection"><\/a>[\s\S]+/g, ''); // remove sidebar data ...
javascript
{ "resource": "" }
q44593
train
function (next) { // silence terminal output to prevent leaking sensitive information config.silent = true; pushd(WIKI_GIT_PATH); exec('git add --all'); exec('git commit -m "[auto] ' + WIKI_VERSION + '"'); exec('git push origin master', function (...
javascript
{ "resource": "" }
q44594
train
function (obj, overrides, mutate) { var resolutionQueue = [], // we use this to store the queue of variable hierarchy // this is an intermediate object to stimulate a property (makes the do-while loop easier) variableSource = { variables: this, __parent: ...
javascript
{ "resource": "" }
q44595
train
function (obj, track, prune) { var list = this, ops = track && { created: [], updated: [], deleted: [] }, indexer = list._postman_listIndexKey, tmp; if (!_.isObject(obj)) { return ops; } // ensure t...
javascript
{ "resource": "" }
q44596
train
function (obj) { var list = this; // in case user did not provide an object to mutate, create a new one !_.isObject(obj) && (obj = {}); // delete extra variables from object that are not present in list _.forEach(obj, function (value, key) { !_.has(list.reference, k...
javascript
{ "resource": "" }
q44597
train
function (obj) { return Boolean(obj) && ((obj instanceof VariableList) || _.inSuperChain(obj.constructor, '_postman_propertyName', VariableList._postman_propertyName)); }
javascript
{ "resource": "" }
q44598
train
function (url) { // url must be either string or an instance of url. if (!_.isString(url) && !Url.isUrl(url)) { return; } // find a certificate that can be applied to the url return this.find(function (certificate) { return certificate.canApplyTo(url); ...
javascript
{ "resource": "" }
q44599
train
function (obj) { return Boolean(obj) && ((obj instanceof CertificateList) || _.inSuperChain(obj.constructor, '_postman_propertyName', CertificateList._postman_propertyName)); }
javascript
{ "resource": "" }