_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q48400
train
function() { this.appendDummyInput('TOPROW') .appendField('', 'NAME'); this.setOutput(true); this.setColour(Blockly.Blocks.procedures.HUE); // Tooltip is set in domToMutation. this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL); this.arguments_ = []; this.quarkConnections_ = {...
javascript
{ "resource": "" }
q48401
train
function() { this.appendValueInput('CONDITION') .setCheck('Boolean') .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); this.appendValueInput('VALUE') .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); this.setInputsInline(true); this.setPreviousStatement(true); this.setNextSt...
javascript
{ "resource": "" }
q48402
train
function(xmlElement) { var value = xmlElement.getAttribute('value'); this.hasReturnValue_ = (value == 1); if (!this.hasReturnValue_) { this.removeInput('VALUE'); this.appendDummyInput('VALUE') .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); } }
javascript
{ "resource": "" }
q48403
train
function() { this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL); this.setColour(Blockly.Blocks.texts.HUE); this.appendDummyInput() .appendField(this.newQuote_(true)) .appendField(new Blockly.FieldTextInput(''), 'TEXT') .appendField(this.newQuote_(false)); this.setOutput(true, 'String...
javascript
{ "resource": "" }
q48404
train
function() { this.setColour(Blockly.Blocks.texts.HUE); this.appendDummyInput() .appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN); this.appendStatementInput('STACK'); this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP); this.contextMenu = false; }
javascript
{ "resource": "" }
q48405
train
function() { this.jsonInit({ "message0": Blockly.Msg.TEXT_LENGTH_TITLE, "args0": [ { "type": "input_value", "name": "VALUE", "check": ['String', 'Array'] } ], "output": 'Number', "colour": Blockly.Blocks.texts.HUE, "tooltip": Blockly....
javascript
{ "resource": "" }
q48406
train
function() { this.jsonInit({ "message0": Blockly.Msg.TEXT_ISEMPTY_TITLE, "args0": [ { "type": "input_value", "name": "VALUE", "check": ['String', 'Array'] } ], "output": 'Boolean', "colour": Blockly.Blocks.texts.HUE, "tooltip": Blockl...
javascript
{ "resource": "" }
q48407
train
function() { this.WHERE_OPTIONS = [[Blockly.Msg.TEXT_CHARAT_FROM_START, 'FROM_START'], [Blockly.Msg.TEXT_CHARAT_FROM_END, 'FROM_END'], [Blockly.Msg.TEXT_CHARAT_FIRST, 'FIRST'], [Blockly.Msg.TEXT_CHARAT_LAST, 'LAST'], [Blockly.Msg.TEXT_CHARAT_RANDOM, 'RANDOM']]; this.s...
javascript
{ "resource": "" }
q48408
train
function(isAt) { // Destroy old 'AT' and 'ORDINAL' inputs. this.removeInput('AT'); this.removeInput('ORDINAL', true); // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT').setCheck('Number'); if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { this.ap...
javascript
{ "resource": "" }
q48409
train
function() { var container = document.createElement('mutation'); var isAt1 = this.getInput('AT1').type == Blockly.INPUT_VALUE; container.setAttribute('at1', isAt1); var isAt2 = this.getInput('AT2').type == Blockly.INPUT_VALUE; container.setAttribute('at2', isAt2); return container; }
javascript
{ "resource": "" }
q48410
train
function(xmlElement) { var isAt1 = (xmlElement.getAttribute('at1') == 'true'); var isAt2 = (xmlElement.getAttribute('at2') == 'true'); this.updateAt_(1, isAt1); this.updateAt_(2, isAt2); }
javascript
{ "resource": "" }
q48411
train
function() { var OPERATORS = [[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE, 'UPPERCASE'], [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE, 'LOWERCASE'], [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, 'TITLECASE']]; this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL); this.set...
javascript
{ "resource": "" }
q48412
train
function() { this.jsonInit({ "message0": Blockly.Msg.TEXT_PRINT_TITLE, "args0": [ { "type": "input_value", "name": "TEXT" } ], "previousStatement": null, "nextStatement": null, "colour": Blockly.Blocks.texts.HUE, "tooltip": Blockly.Msg.TE...
javascript
{ "resource": "" }
q48413
train
function(xmlElement) { this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0; this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0; this.updateShape_(); }
javascript
{ "resource": "" }
q48414
train
function(containerBlock) { var clauseBlock = containerBlock.nextConnection.targetBlock(); var i = 1; while (clauseBlock) { switch (clauseBlock.type) { case 'controls_if_elseif': var inputIf = this.getInput('IF' + i); var inputDo = this.getInput('DO' + i); clauseBl...
javascript
{ "resource": "" }
q48415
train
function() { this.setColour(Blockly.Blocks.logic.HUE); this.appendDummyInput() .appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF); this.setNextStatement(true); this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP); this.contextMenu = false; }
javascript
{ "resource": "" }
q48416
train
function() { this.setColour(Blockly.Blocks.logic.HUE); this.appendDummyInput() .appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF); this.setPreviousStatement(true); this.setNextStatement(true); this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP); this.contextMenu = false; }
javascript
{ "resource": "" }
q48417
train
function() { this.setColour(Blockly.Blocks.logic.HUE); this.appendDummyInput() .appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE); this.setPreviousStatement(true); this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP); this.contextMenu = false; }
javascript
{ "resource": "" }
q48418
train
function() { var OPERATORS = this.RTL ? [ ['=', 'EQ'], ['\u2260', 'NEQ'], ['>', 'LT'], ['\u2265', 'LTE'], ['<', 'GT'], ['\u2264', 'GTE'] ] : [ ['=', 'EQ'], ['\u2260', 'NEQ'], ['<', 'LT'], ['\u2264', 'LTE'], ...
javascript
{ "resource": "" }
q48419
train
function(e) { var blockA = this.getInputTargetBlock('A'); var blockB = this.getInputTargetBlock('B'); // Disconnect blocks that existed prior to this change if they don't match. if (blockA && blockB && !blockA.outputConnection.checkType_(blockB.outputConnection)) { // Mismatch between two ...
javascript
{ "resource": "" }
q48420
train
function() { this.jsonInit({ "message0": Blockly.Msg.LOGIC_NEGATE_TITLE, "args0": [ { "type": "input_value", "name": "BOOL", "check": "Boolean" } ], "output": "Boolean", "colour": Blockly.Blocks.logic.HUE, "tooltip": Blockly.Msg.LOGIC...
javascript
{ "resource": "" }
q48421
train
function() { this.jsonInit({ "message0": Blockly.Msg.LOGIC_NULL, "output": null, "colour": Blockly.Blocks.logic.HUE, "tooltip": Blockly.Msg.LOGIC_NULL_TOOLTIP, "helpUrl": Blockly.Msg.LOGIC_NULL_HELPURL }); }
javascript
{ "resource": "" }
q48422
train
function() { this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL); this.setColour(Blockly.Blocks.logic.HUE); this.appendValueInput('IF') .setCheck('Boolean') .appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION); this.appendValueInput('THEN') .appendField(Blockly.Msg.LOGIC_TERNARY_IF_T...
javascript
{ "resource": "" }
q48423
train
function(e) { var blockA = this.getInputTargetBlock('THEN'); var blockB = this.getInputTargetBlock('ELSE'); var parentConnection = this.outputConnection.targetConnection; // Disconnect blocks that existed prior to this change if they don't match. if ((blockA || blockB) && parentConnection) { f...
javascript
{ "resource": "" }
q48424
train
function(e) { var blocks = this.workspace_.getTopBlocks(false); for (var i = 0, block; block = blocks[i]; i++) { block.removeSelect(); } }
javascript
{ "resource": "" }
q48425
train
function() { this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL); this.setColour(330); this.appendValueInput('VALUE') .appendField(Plane.getMsg('Plane_setSeats')); this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP); this.setDeletable(false); }
javascript
{ "resource": "" }
q48426
train
function() { this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL); this.setColour(330); this.appendDummyInput() .appendField(Plane.getMsg('Plane_getRows2'), 'title'); this.setOutput(true, 'Number'); }
javascript
{ "resource": "" }
q48427
formatChange
train
function formatChange() { var mask = document.getElementById('blocklyMask'); var languagePre = document.getElementById('languagePre'); var languageTA = document.getElementById('languageTA'); if (document.getElementById('format').value == 'Manual') { Blockly.hideChaff(); mask.style.display = 'block'; ...
javascript
{ "resource": "" }
q48428
updateLanguage
train
function updateLanguage() { var rootBlock = getRootBlock(); if (!rootBlock) { return; } var blockType = rootBlock.getFieldValue('NAME').trim().toLowerCase(); if (!blockType) { blockType = UNNAMED; } blockType = blockType.replace(/\W/g, '_').replace(/^(\d)/, '_\\1'); switch (document.getElementBy...
javascript
{ "resource": "" }
q48429
formatJavaScript_
train
function formatJavaScript_(blockType, rootBlock) { var code = []; code.push("Blockly.Blocks['" + blockType + "'] = {"); code.push(" init: function() {"); // Generate inputs. var TYPES = {'input_value': 'appendValueInput', 'input_statement': 'appendStatementInput', 'input_dummy':...
javascript
{ "resource": "" }
q48430
connectionLineJs_
train
function connectionLineJs_(functionName, typeName) { var type = getOptTypesFrom(getRootBlock(), typeName); if (type) { type = ', ' + type; } else { type = ''; } return ' this.' + functionName + '(true' + type + ');'; }
javascript
{ "resource": "" }
q48431
updatePreview
train
function updatePreview() { // Toggle between LTR/RTL if needed (also used in first display). var newDir = document.getElementById('direction').value; if (oldDir != newDir) { if (previewWorkspace) { previewWorkspace.dispose(); } var rtl = newDir == 'rtl'; previewWorkspace = Blockly.inject('pr...
javascript
{ "resource": "" }
q48432
getRootBlock
train
function getRootBlock() { var blocks = mainWorkspace.getTopBlocks(false); for (var i = 0, block; block = blocks[i]; i++) { if (block.type == 'factory_base') { return block; } } return null; }
javascript
{ "resource": "" }
q48433
init
train
function init() { if ('BlocklyStorage' in window) { BlocklyStorage.HTTPREQUEST_ERROR = 'There was a problem with the request.\n'; BlocklyStorage.LINK_ALERT = 'Share your blocks with this link:\n\n%1'; BlocklyStorage.HASH_ERROR = 'Sorry, "%1" doesn\'t correspond with any saved Block...
javascript
{ "resource": "" }
q48434
train
function() { this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL); this.setColour(Blockly.Blocks.math.HUE); this.appendDummyInput() .appendField(new Blockly.FieldTextInput('0', Blockly.FieldTextInput.numberValidator), 'NUM'); this.setOutput(true, 'Number'); // Assign 'this' to a variable...
javascript
{ "resource": "" }
q48435
train
function() { this.jsonInit({ "message0": "%1 %2 %3", "args0": [ { "type": "input_value", "name": "A", "check": "Number" }, { "type": "field_dropdown", "name": "OP", "options": [[Blockly.Msg.MATH_ADDITION_SYMB...
javascript
{ "resource": "" }
q48436
train
function() { this.jsonInit({ "message0": "%1 %2", "args0": [ { "type": "field_dropdown", "name": "OP", "options": [ [Blockly.Msg.MATH_SINGLE_OP_ROOT, 'ROOT'], [Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE, 'ABS'], ['-', 'NEG'], ...
javascript
{ "resource": "" }
q48437
train
function() { this.jsonInit({ "message0": "%1 %2", "args0": [ { "type": "field_dropdown", "name": "OP", "options": [ [Blockly.Msg.MATH_TRIG_SIN, 'SIN'], [Blockly.Msg.MATH_TRIG_COS, 'COS'], [Blockly.Msg.MATH_TRIG_TAN, 'TAN'], ...
javascript
{ "resource": "" }
q48438
train
function() { var PROPERTIES = [[Blockly.Msg.MATH_IS_EVEN, 'EVEN'], [Blockly.Msg.MATH_IS_ODD, 'ODD'], [Blockly.Msg.MATH_IS_PRIME, 'PRIME'], [Blockly.Msg.MATH_IS_WHOLE, 'WHOLE'], [Blockly.Msg.MATH_IS_POSITIVE, 'POSITIVE'], [Blockly.Msg.MATH_IS_NEGATIVE, 'NEGATIVE']...
javascript
{ "resource": "" }
q48439
train
function() { this.jsonInit({ "message0": Blockly.Msg.MATH_CHANGE_TITLE, "args0": [ { "type": "field_variable", "name": "VAR", "variable": Blockly.Msg.MATH_CHANGE_TITLE_ITEM }, { "type": "input_value", "name": "DELTA", "c...
javascript
{ "resource": "" }
q48440
train
function() { this.jsonInit({ "message0": "%1 %2", "args0": [ { "type": "field_dropdown", "name": "OP", "options": [ [Blockly.Msg.MATH_ROUND_OPERATOR_ROUND, 'ROUND'], [Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP, 'ROUNDUP'], [Blockly.M...
javascript
{ "resource": "" }
q48441
train
function() { this.jsonInit({ "message0": Blockly.Msg.MATH_MODULO_TITLE, "args0": [ { "type": "input_value", "name": "DIVIDEND", "check": "Number" }, { "type": "input_value", "name": "DIVISOR", "check": "Number" }...
javascript
{ "resource": "" }
q48442
train
function() { this.jsonInit({ "message0": Blockly.Msg.MATH_CONSTRAIN_TITLE, "args0": [ { "type": "input_value", "name": "VALUE", "check": "Number" }, { "type": "input_value", "name": "LOW", "check": "Number" }, ...
javascript
{ "resource": "" }
q48443
train
function() { this.jsonInit({ "message0": Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM, "output": "Number", "colour": Blockly.Blocks.math.HUE, "tooltip": Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP, "helpUrl": Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL }); }
javascript
{ "resource": "" }
q48444
cacheList
train
function cacheList() { if (list.match(/^\w+$/)) { return ''; } var listVar = Blockly.PHP.variableDB_.getDistinctName( 'tmp_list', Blockly.Variables.NAME_TYPE); var code = listVar + ' = &' + list + ';\n'; list = listVar; return code; }
javascript
{ "resource": "" }
q48445
train
function() { this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL); this.setColour(Blockly.Blocks.lists.HUE); this.itemCount_ = 3; this.updateShape_(); this.setOutput(true, 'Array'); this.setMutator(new Blockly.Mutator(['lists_create_with_item'])); this.setTooltip(Blockly.Msg.LISTS_CREATE_W...
javascript
{ "resource": "" }
q48446
train
function() { this.setColour(Blockly.Blocks.lists.HUE); this.appendDummyInput() .appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE); this.setPreviousStatement(true); this.setNextStatement(true); this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP); this.contextMenu = false; }
javascript
{ "resource": "" }
q48447
train
function() { this.jsonInit({ "message0": Blockly.Msg.LISTS_REPEAT_TITLE, "args0": [ { "type": "input_value", "name": "ITEM" }, { "type": "input_value", "name": "NUM", "check": "Number" } ], "output": "Array", ...
javascript
{ "resource": "" }
q48448
train
function() { this.jsonInit({ "message0": Blockly.Msg.LISTS_LENGTH_TITLE, "args0": [ { "type": "input_value", "name": "VALUE", "check": ['String', 'Array'] } ], "output": 'Number', "colour": Blockly.Blocks.lists.HUE, "tooltip": Blockly...
javascript
{ "resource": "" }
q48449
train
function() { this.jsonInit({ "message0": Blockly.Msg.LISTS_ISEMPTY_TITLE, "args0": [ { "type": "input_value", "name": "VALUE", "check": ['String', 'Array'] } ], "output": 'Boolean', "colour": Blockly.Blocks.lists.HUE, "tooltip": Block...
javascript
{ "resource": "" }
q48450
train
function() { var MODE = [[Blockly.Msg.LISTS_GET_INDEX_GET, 'GET'], [Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE, 'GET_REMOVE'], [Blockly.Msg.LISTS_GET_INDEX_REMOVE, 'REMOVE']]; this.WHERE_OPTIONS = [[Blockly.Msg.LISTS_GET_INDEX_FROM_START, 'FROM_START'], [Blockly.Msg.LISTS_...
javascript
{ "resource": "" }
q48451
train
function() { var container = document.createElement('mutation'); var isStatement = !this.outputConnection; container.setAttribute('statement', isStatement); var isAt = this.getInput('AT').type == Blockly.INPUT_VALUE; container.setAttribute('at', isAt); return container; }
javascript
{ "resource": "" }
q48452
train
function(xmlElement) { // Note: Until January 2013 this block did not have mutations, // so 'statement' defaults to false and 'at' defaults to true. var isStatement = (xmlElement.getAttribute('statement') == 'true'); this.updateStatement_(isStatement); var isAt = (xmlElement.getAttribute('at') != 'f...
javascript
{ "resource": "" }
q48453
train
function(newStatement) { var oldStatement = !this.outputConnection; if (newStatement != oldStatement) { this.unplug(true, true); if (newStatement) { this.setOutput(false); this.setPreviousStatement(true); this.setNextStatement(true); } else { this.setPreviousSta...
javascript
{ "resource": "" }
q48454
train
function() { // Assign 'this' to a variable for use in the closures below. var thisBlock = this; var dropdown = new Blockly.FieldDropdown( [[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, 'SPLIT'], [Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, 'JOIN']], function(newMode) { thisBlock.u...
javascript
{ "resource": "" }
q48455
train
function(newMode) { if (newMode == 'SPLIT') { this.outputConnection.setCheck('Array'); this.getInput('INPUT').setCheck('String'); } else { this.outputConnection.setCheck('String'); this.getInput('INPUT').setCheck('Array'); } }
javascript
{ "resource": "" }
q48456
train
function(arg, suffix) { if (Blockly.isNumber(arg)) { // Simple number. arg = parseFloat(arg); } else if (arg.match(/^\w+$/)) { // Variable. arg = 'float(' + arg + ')'; } else { // It's complicated. var varName = Blockly.Python.variableDB_.getDistinctName...
javascript
{ "resource": "" }
q48457
Rocky
train
function Rocky (opts) { if (!(this instanceof Rocky)) return new Rocky(opts) opts = opts || {} Base.call(this, opts) this.server = null this.router = router(opts.router) this._setupMiddleware() }
javascript
{ "resource": "" }
q48458
setSingle
train
function setSingle(store, key, value, flag) { const { _store, _subscriptions } = store // Uncurry alfa action functions if (typeof value === 'function' && value.alfaAction) { value = value.alfaAction(store) } // Save the value to the store. _store[key] = value if (flag === 'merge') { return }...
javascript
{ "resource": "" }
q48459
getDynamicProps
train
function getDynamicProps({ keys, maps, inputs }, outputs, alfaStore) { const _props = getInjectedProps(inputs, outputs, alfaStore) if (maps) { keys.forEach(key => { _props[key] = _props[maps[key]] }) // Map outputs if (outputs && 'function' === typeof _props.set) { // The `set` of `prop...
javascript
{ "resource": "" }
q48460
setupBundler
train
function setupBundler(cwd, entryPoints, flags, noWatchify, ready) { noWatchify ? onlocalwatchify() : resolve('watchify', {basedir: cwd}, onlocalwatchify) function onlocalwatchify(err, localDir) { if(err || !localDir) { return resolve('browserify', {basedir: cwd}, onlocalbrowserify) } set...
javascript
{ "resource": "" }
q48461
TableFormatter
train
function TableFormatter(options) { const table = new Table(options); this.format = format; function format(result, formatOptions) { let data = []; _.each(result, function (item) { data.push(_.values(_.pick(item, options.values))); }); if (formatOptions.format === 'csv') { _.each(data, f...
javascript
{ "resource": "" }
q48462
MessageFormatter
train
function MessageFormatter() { this.format = format; function format(result) { _.each(result, function(message) { console.log(message); }); } }
javascript
{ "resource": "" }
q48463
init
train
function init(options) { self.email = options.email; self.key = options.token; self.cloudflareClient = new CloudFlareClient(options.email, options.token); }
javascript
{ "resource": "" }
q48464
runCommand
train
function runCommand(command, options) { let cmd = getCommand(command); if (!cmd || command === 'help') { cmd = getCommand('help'); } else { try { validateConfig(options); } catch (error) { console.log(error.message); process.exit(1); } } let fn = cmd.c...
javascript
{ "resource": "" }
q48465
addRecord
train
function addRecord(options) { options.type = options.type || 'CNAME'; return getZone(options.domain) .then(function (zone) { return self.cloudflareClient.addRecord( zone.id, _.extend({ttl: 1}, mapRecordOptions(options))); }) .then(function (response) { ret...
javascript
{ "resource": "" }
q48466
editRecord
train
function editRecord(options) { return find(options.domain, getQueryParams(options, ['name', 'type', 'query'])).then(function (response) { const records = response.data.result; //Properties that are editable options = mapRecordOptions(options); if (records.length === 0) { throw new Er...
javascript
{ "resource": "" }
q48467
find
train
function find(domain, query) { if (query.name && !query.name.includes(domain)) { query.name = query.name + '.' + domain; } if (query.query) { query = _.extend(query, query.query); delete query.query; } return getZone(domain).then(function (zone) { return self.cloudflareClient...
javascript
{ "resource": "" }
q48468
listRecords
train
function listRecords(options) { return getZone(options.domain).then(function (zone) { return self.cloudflareClient.findRecord(zone.id, {page: 1, per_page: self.perPage}) .then(function (response) { let promises = [Promise.resolve(response)]; for (let i = 2; i <= response.data['resu...
javascript
{ "resource": "" }
q48469
listZones
train
function listZones() { return self.cloudflareClient.findZones({page: 1, per_page: self.perPage}) .then(function (response) { let promises = [Promise.resolve(response)]; for (let i = 2; i <= response.data['result_info']['total_pages']; i++) { promises.push(self.cloudflareClient.findZo...
javascript
{ "resource": "" }
q48470
purgeCache
train
function purgeCache(options) { return getZone(options.domain).then(function (zone) { let query = (options._[1]) ? {files: options._.slice(1)} : {purge_everything: true}; return self.cloudflareClient.purgeCache(zone.id, query); }).then(function () { return new Result('Purged cache successfully'...
javascript
{ "resource": "" }
q48471
getCommand
train
function getCommand(commandName) { return _.find(commands, function (command) { return _.includes(command.aliases, commandName); }); }
javascript
{ "resource": "" }
q48472
mapRecordOptions
train
function mapRecordOptions(options) { if (options.type === 'SRV') { let contentParts = options.content.split(' '); let serverParts = options.name.split('.'); options.data = { service: serverParts[0], proto: serverParts[1], name: _.slice(serverParts, 2).join('.'), pri...
javascript
{ "resource": "" }
q48473
validateConfig
train
function validateConfig(config) { let missing = []; _.each(requiredOptions, function (option) { if (config[option] === undefined) { missing.push(option); } }); if (missing.length > 0) { throw new Error('The following required parameters were not provided: ' + missing.join(','))...
javascript
{ "resource": "" }
q48474
ConfigReader
train
function ConfigReader(path) { const self = this; const fs = require('fs'); const util = require('util'); const yaml = require('js-yaml'); const _ = require('lodash'); const allowedEnvironmentVars = { token: 'CF_API_KEY', email: 'CF_API_EMAIL', domain: 'CF_API_DOMAIN' }; const homePath = pro...
javascript
{ "resource": "" }
q48475
normalizeLimit
train
function normalizeLimit (options) { const limit = options.limit || options.resultRecordCount || options.count || options.maxFeatures // If there is a limit, add 1 to it so we can later calculate a limitExceeded. The result set will be resized accordingly, post SQL if (limit) return limit + 1 }
javascript
{ "resource": "" }
q48476
normalizeIdField
train
function normalizeIdField (options, features = []) { const collection = options.collection || {} const metadata = collection.metadata || {} const feature = features[0] || {} const featureProperties = feature.properties || feature.attributes || {} let idField = null // First, check metadata for idField if...
javascript
{ "resource": "" }
q48477
createClause
train
function createClause (options = {}, idField = null) { // Default clause let clause = `type, properties as properties` // Comma-delimited list of date-fields is needed for formatting ESRI specific output let dateFields = options.dateFields.join(',') let requiresObjectId = !!options.returnIdsOnly || !(options...
javascript
{ "resource": "" }
q48478
normalizeFields
train
function normalizeFields (options) { const fields = options.fields || options.outFields const idField = _.get(options, 'collection.metadata.idField') if (options.returnIdsOnly === true && idField) return [idField] else if (options.returnIdsOnly === true) return ['OBJECTID'] if (fields === '*') return undefine...
javascript
{ "resource": "" }
q48479
handleExpr
train
function handleExpr (node, options) { let expr if (node.type === 'unary_expr') { expr = `${node.operator} ${traverse(node.expr, options)}` } else if (node.operator === '=' && node.left.value === 1 && node.right.value === 1) { // a special case related to arcgis server return '1=1' } else if (node.o...
javascript
{ "resource": "" }
q48480
handleExprList
train
function handleExprList (node, options) { const values = node.value.map((valueNode) => traverse(valueNode, options)).join(',') return `(${values})` }
javascript
{ "resource": "" }
q48481
handleFunction
train
function handleFunction (node, options) { const args = handleExprList(node.args, options) return `${node.name}${args}` }
javascript
{ "resource": "" }
q48482
handleValue
train
function handleValue (node, options) { let value = node.value if (node.columnNode) { const field = _.find(options.esriFields, { name: node.columnNode.column }) if (_.has(field, 'domain.codedValues')) { const actual = _.find(field.domain.codedValues, { code: value }) if (actual) { valu...
javascript
{ "resource": "" }
q48483
traverse
train
function traverse (node, options) { if (!node) { return '' } switch (node.type) { case 'unary_expr': case 'binary_expr': return handleExpr(node, options) case 'function': return handleFunction(node, options) case 'expr_list': return handleExprList(node, options) case 'co...
javascript
{ "resource": "" }
q48484
esriFy
train
function esriFy (properties, geometry, dateFields, requiresObjectId, idField) { const parsedDateFields = (dateFields.length === 0) ? [] : dateFields.split(',') if (parsedDateFields.length) { parsedDateFields.forEach(field => { properties[field] = new Date(properties[field]).getTime() }) } // If t...
javascript
{ "resource": "" }
q48485
train
function(a, msg) { a = !!a; var details = { result: a, message: msg }; msg = escapeInnerText(msg); runLoggingCallbacks( 'log', QUnit, details ); config.current.assertions.push({ result: a, message: msg }); }
javascript
{ "resource": "" }
q48486
train
function(actual, expected, message) { QUnit.push(expected == actual, actual, expected, message); }
javascript
{ "resource": "" }
q48487
train
function() { extend(config, { stats: { all: 0, bad: 0 }, moduleStats: { all: 0, bad: 0 }, started: +new Date, updateRate: 1000, blocking: false, autostart: true, autorun: false, filter: "", queue: [], semaphore: 0 }); var tests = id( "qunit-tests" ), banner = id( "qunit-banner" )...
javascript
{ "resource": "" }
q48488
train
function() { if ( window.jQuery ) { jQuery( "#qunit-fixture" ).html( config.fixture ); } else { var main = id( 'qunit-fixture' ); if ( main ) { main.innerHTML = config.fixture; } } }
javascript
{ "resource": "" }
q48489
train
function( elem, type, event ) { if ( document.createEvent ) { event = document.createEvent("MouseEvents"); event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null); elem.dispatchEvent( event ); } else if ( elem.fireEvent ) { elem.fir...
javascript
{ "resource": "" }
q48490
diff
train
function diff( a, b ) { var result = a.slice(); for ( var i = 0; i < result.length; i++ ) { for ( var j = 0; j < b.length; j++ ) { if ( result[i] === b[j] ) { result.splice(i, 1); i--; break; } } } return result; }
javascript
{ "resource": "" }
q48491
runLoggingCallbacks
train
function runLoggingCallbacks(key, scope, args) { //debugger; var callbacks; if ( QUnit.hasOwnProperty(key) ) { QUnit[key].call(scope, args); } else { callbacks = config[key]; for( var i = 0; i < callbacks.length; i++ ) { callbacks[i].call( scope, args ); } } }
javascript
{ "resource": "" }
q48492
useStrictEquality
train
function useStrictEquality(b, a) { if (b instanceof a.constructor || a instanceof b.constructor) { // to catch short annotaion VS 'new' annotation of a // declaration // e.g. var i = 1; // var j = new Number(1); return a == b; } else { return a === b; } }
javascript
{ "resource": "" }
q48493
o
train
function o(name, value) { return { name: name, tokens: value || "", semantic: value || "", children: [] }; }
javascript
{ "resource": "" }
q48494
displayName
train
function displayName() { return wrap('display-name', function phraseFixedSemantic() { var result = phrase(); if (result !== null) { result.semantic = collapseWhitespace(result.semantic); } return result; }()); }
javascript
{ "resource": "" }
q48495
searchNodeInTree
train
function searchNodeInTree(treeRoot, nodeId){ if (treeRoot.childNodes){ for (var i = 0; i < treeRoot.childNodes.length; ++i){ var currentNode = treeRoot.childNodes[i]; if (currentNode._id == nodeId){ return currentNode; } else { var found = ...
javascript
{ "resource": "" }
q48496
createTree
train
function createTree(){ for (var i = 0; i < gRootNodes.length; ++i){ var node = { _id : gRootNodes[i]._id, //todo : id instead of name? node : gRootNodes[i], parent : "root", childNodes : loadChildNodes(gRootNodes[i]) }; gTree.childNodes.push(no...
javascript
{ "resource": "" }
q48497
loadChildNodes
train
function loadChildNodes(parentNode){ if (gNodesWithChildren[parentNode._id]){ var children = []; for (var i = 0; i < gNodesWithChildren[parentNode._id].length; ++i){ var currentNode = gNodesWithChildren[parentNode._id][i]; children.push({ _id : currentNode._id...
javascript
{ "resource": "" }
q48498
displayNameDOM
train
function displayNameDOM(node){ $('.nodeLabel').remove(); var nodePos = layout.getNodePosition(node._id); var domPos = { x: nodePos.x, y: nodePos.y }; graphics.transformGraphToClientCoordinates(domPos); var labelStyle = generateDOMLabel(node).style; labelStyle.left = domPos....
javascript
{ "resource": "" }
q48499
generateDOMLabel
train
function generateDOMLabel(node) { var label = document.createElement('span'); label.className = 'nodeLabel'; label.id = node._id; if (node.name){ label.innerText = node.name; } else { label.innerText = node._id; } divGraph.appendChild(label); return label; }
javascript
{ "resource": "" }