_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q36300
recurseSrcDirectories
train
function recurseSrcDirectories (grunt, fileData, options) { let promises = []; // Ignore everything except directories and Javascript files. // Store function in array for recursive-readdir module. let ignoreCallback = [(file, stats) => !(stats.isDirectory() || path.extname(file) === '.js')]; for ...
javascript
{ "resource": "" }
q36301
streamMatches
train
function streamMatches (grunt, fileData, options, matches, flattenedMatches) { // Run optional tasks after we stream matches to dest. stream.createWriteStream(fileData.dest, () => { require('./dev/test')(grunt, fileData, options, throwAsyncError).performTests(); if (options.deploy) { ...
javascript
{ "resource": "" }
q36302
train
function (buildConfig) { var configFile; var suffix = 'karma'; if (buildConfig.nodeProject) { suffix = 'mocha'; } configFile = path.join(currentDirectory, '../lint/eslint/eslintrc-' + suffix + '.js'); return configFile; }
javascript
{ "resource": "" }
q36303
train
function (buildConfig, config) { var testConfig = extend(true, {}, config || {}, { nomen: true, unparam: true, predef: [ 'it', 'describe' ] }); if (!buildConfig.nodeProject) { testConfig.predef.push('ang...
javascript
{ "resource": "" }
q36304
train
function (buildConfig, options) { options = options || {}; var includeLib = options.includeLib; if (includeLib === undefined) { includeLib = true; } var src = []; if (includeLib) { if (buildConfig.nodeProject) { src = src.concat([...
javascript
{ "resource": "" }
q36305
xml2json
train
function xml2json(method, body){ body = util.xml2json(body); if(body.return_code!=='SUCCESS'){ throw new Error(util.format('api error to call %s: %s', method, body.return_msg)); } if(body.result_code!=='SUCCESS'){ throw new Error(util.format('business error to call %s: %s %s', method, body.err_c...
javascript
{ "resource": "" }
q36306
referenceParentNode
train
function referenceParentNode () { // If nodeName is an empty string, then reference the parent of the root child. if (isEmptyString(nodeName)) { nodeName = this.$parentName; // Even though super might be invoked in different constructors, // the s...
javascript
{ "resource": "" }
q36307
applyParentNode
train
function applyParentNode (args) { if (isEmptyString(nodeName)) { return undefined; } let nextParentName = CLASS[nodeName].prototype.$parentName; // Keep reference of the node's name just in case the chain gets reset. let tmpName = nodeName; // If there are ...
javascript
{ "resource": "" }
q36308
get
train
function get(resource, path) { const [head, ...tail] = path.split('.'); return resource && head ? get(resource[head], tail.join('.')) : resource; }
javascript
{ "resource": "" }
q36309
createIdentifierNode
train
function createIdentifierNode(name) { return (scope, opts) => { const property = get(opts.properties, name); return property ? property(scope) : get(scope, name); }; }
javascript
{ "resource": "" }
q36310
createOperatorNode
train
function createOperatorNode(operand, nodes = []) { return (scope, opts) => { const args = nodes.map(node => node(scope, opts)); if (typeof operand === 'function') { return operand(...args); } const operator = get(opts.functions, operand); if (!operator) { throw new ReferenceError(`F...
javascript
{ "resource": "" }
q36311
processLogicalOr
train
function processLogicalOr(tokenizer, scope) { let node = processLogicalAnd(tokenizer, scope); while (tokenizer.token.match(types.LOGICAL_OR)) { node = createOperatorNode(tokenizer.token.value, [node, processLogicalAnd(tokenizer.skipToken(), scope)]); } return node; }
javascript
{ "resource": "" }
q36312
processLogicalAnd
train
function processLogicalAnd(tokenizer, scope) { let node = processLogicalEquality(tokenizer, scope); while (tokenizer.token.match(types.LOGICAL_AND)) { node = createOperatorNode(tokenizer.token.value, [node, processLogicalEquality(tokenizer.skipToken(), scope)]); } return node; }
javascript
{ "resource": "" }
q36313
processAddSubtract
train
function processAddSubtract(tokenizer, scope) { let node = processMultiplyDivide(tokenizer, scope); while (tokenizer.token.match(types.ADD_SUBTRACT)) { node = createOperatorNode(tokenizer.token.value, [node, processMultiplyDivide(tokenizer.skipToken(), scope)]); } return node; }
javascript
{ "resource": "" }
q36314
processMultiplyDivide
train
function processMultiplyDivide(tokenizer, scope) { let node = processUnary(tokenizer, scope); while (tokenizer.token.match(types.MULTIPLY_DIVIDE)) { node = createOperatorNode(tokenizer.token.value, [node, processUnary(tokenizer.skipToken(), scope)]); } return node; }
javascript
{ "resource": "" }
q36315
processUnary
train
function processUnary(tokenizer, scope) { const unaryAddSubtract = { '-': value => -value, '+': value => value }; if (tokenizer.token.match(types.ADD_SUBTRACT)) { return createOperatorNode(unaryAddSubtract[tokenizer.token.lexeme], [processUnary(tokenizer.skipToken(), scope)]); } if (tokenizer.to...
javascript
{ "resource": "" }
q36316
processIdentifiers
train
function processIdentifiers(tokenizer, scope) { let params = []; if (tokenizer.token.match(types.IDENTIFIER)) { const keys = [tokenizer.token.value]; tokenizer.skipToken(); while (tokenizer.token.match(types.DOT, types.OPEN_SQUARE_BRACKET)) { const token = tokenizer.token; tokenizer.skip...
javascript
{ "resource": "" }
q36317
processConstants
train
function processConstants(tokenizer, scope) { if (tokenizer.token.match(types.CONSTANT)) { const node = createConstantNode(tokenizer.token.value); tokenizer.skipToken(); return node; } return processParentheses(tokenizer, scope); }
javascript
{ "resource": "" }
q36318
processParentheses
train
function processParentheses(tokenizer, scope) { if (tokenizer.token.match(types.CLOSE_PARENTHESES)) { throw new SyntaxError('Unexpected end of expression'); } if (tokenizer.token.match(types.OPEN_PARENTHESES)) { const node = processLogicalOr(tokenizer.skipToken(), scope); if (!tokenizer.token.match(...
javascript
{ "resource": "" }
q36319
makeMBTAPI
train
function makeMBTAPI( config ) { if ( ! config.apiKey || typeof config.apiKey !== 'string' ) { throw new Error( 'An MBTA API key must be provided' ); } config.apiRoot = config.apiRoot || 'http://realtime.mbta.com/developer/api/v2/'; return _.mapValues( methods, function( args, key ) { // makeQueryHandle...
javascript
{ "resource": "" }
q36320
serialize
train
function serialize(path){ return path.reduce(function(str, seg){ return str + seg[0] + seg.slice(1).join(',') }, '') }
javascript
{ "resource": "" }
q36321
slice
train
function slice(str, beginSlice, endSlice) { return GraphemeBreaker.break(str) .slice(beginSlice, endSlice) .join(''); }
javascript
{ "resource": "" }
q36322
zipFolder
train
function zipFolder(zip, ffs, root, dir) { dir = dir || ''; let files = ffs.readdirSync(root + (dir ? '/' + dir : '')); files.forEach(file => { if (['.ts', '.js.map'].some(e => file.endsWith(e))) { return; } let stat = ffs.statSync(root + (dir ? '/' + dir : '') + '/' + fil...
javascript
{ "resource": "" }
q36323
zipFile
train
function zipFile(zip, ffs, root, dir, file) { dir = dir || ''; let zipfolder = dir ? zip.folder(dir) : zip; const data = ffs.readFileSync(root + (dir ? '/' + dir : '') + '/' + file); zipfolder.file(file, data); }
javascript
{ "resource": "" }
q36324
checkFolder
train
function checkFolder(ffs, fld) { let fldBits = fld.split('/'), mkfld = ''; fldBits.forEach(toBit => { mkfld = mkfld ? mkfld + '/' + toBit : toBit; if (mkfld && !ffs.existsSync(mkfld)) { ffs.mkdirSync(mkfld); } }); }
javascript
{ "resource": "" }
q36325
copyFolder
train
function copyFolder(ffs, from, to) { checkFolder(ffs, to); let tasks = []; ffs.readdirSync(from).forEach(child => { if (ffs.statSync(from + '/' + child).isDirectory()) { copyFolder(ffs, from + '/' + child, to + '/' + child); } else { copyFile(ffs, from + '/' +...
javascript
{ "resource": "" }
q36326
_process
train
function _process(templates, params, cb) { var _templates = _.extend(templates, {}), // process template copies, not the originals tasks = {}; _.keys(_templates).forEach(function (key) { tasks[key] = function (cb) { _templates[key].process(params, function (data) { cb(null, data);...
javascript
{ "resource": "" }
q36327
train
function(node) { if (node.type !== 'AssignmentExpression') return false; return node.left.type === 'MemberExpression' && node.left.object.type === 'Identifier' && node.left.object.name === 'module' && node.left.property.type === 'Identifier' && node.left.property.name === 'exports'; // TODO: de...
javascript
{ "resource": "" }
q36328
train
function(rootNode) { // queue to compute de breadth first search var queue = [rootNode]; var nodes = [rootNode]; while (queue.length !== 0) { // fetch child nodes of the first node of the queue var currentNode = queue.shift(); for (var property in cu...
javascript
{ "resource": "" }
q36329
train
function(nodes, methods) { var segmentsToBlank = []; for (var i = 0, ii = nodes.length; i < ii; ++i) { // checks if the statement is a CallExpression if (nodes[i].type === 'CallExpression' && nodes[i].callee.type === 'MemberExpression') { var ...
javascript
{ "resource": "" }
q36330
train
function(segments) { var previousSegment = [-1, -1]; var segmentIndicesToRemove = []; var cleanedSegmentArray = []; var i, ii; for (i = 0, ii = segments.length; i < ii; ++i) { if (!(previousSegment[0] <= segments[i][0] && previousSegment[1] >= segm...
javascript
{ "resource": "" }
q36331
importModule
train
function importModule(module, scope, fn) { debug("Importing module: " + module); var imports = require(module), name = path.basename(module, path.extname(module)); if (isPlainObject(imports)) { var keys = Object.keys(imports), key, len = keys.length; for (var i = 0; i < len; i++) {...
javascript
{ "resource": "" }
q36332
load
train
function load(target, opts) { target = path.resolve(target); debug("Load enter: " + target); if (fs.statSync(target).isDirectory()) { var files = fs.readdirSync(target), len = files.length, file; for (var i = 0; i < len; i++) { file = files[i]; var fullPath = target...
javascript
{ "resource": "" }
q36333
asRegExps
train
function asRegExps(array) { var array = asArray(array), len = array.length; for (var i = 0; i < len; i++) { if (!(array[i] instanceof RegExp)) { array[i] = new RegExp(array[i]); } } return array; }
javascript
{ "resource": "" }
q36334
defaultOpts
train
function defaultOpts(opts, parentId) { var targets = opts.targets && opts.targets.length ? asArray(opts.targets) : [defaultTarget(parentId)]; return mixin({targets: targets, grep: [/\.js$/], ungrep: opts.ungrep && opts.ungrep.length ? asArray(...
javascript
{ "resource": "" }
q36335
defaultUngrep
train
function defaultUngrep(targets) { if (targets && targets.length) { var ungreps = [], target, len = targets.length; for (var i = 0; i < len; i++) { target = targets[i]; target = '(?:^' + path.dirname(target) + sep + '){1}'; target += '(?:/?.*/?)*' + NM_SEG; ...
javascript
{ "resource": "" }
q36336
compare
train
function compare(data, candidates, shim, at, mt) { var results = []; var i; for (i = 0; i < candidates.length; i++) { var candidate = candidates[i]; if (shim) { candidate = shim(candidate); } //compare candidate with patient var s = score(data, candidat...
javascript
{ "resource": "" }
q36337
newLineAfterCompositeExpressions
train
function newLineAfterCompositeExpressions(previous) { if (previous.type === 'ExpressionStatement') { var expression = previous.expression; switch (expression.type) { case 'AssignmentExpression': case 'BinaryExpression': return NEED_EXTRA_NEWLINE_AFTER[express...
javascript
{ "resource": "" }
q36338
getPrototype
train
function getPrototype(model) { if (model.__recordPrototype) return model.__recordPrototype; const mrProto = Object.assign({}, proto);// eslint-disable-line no-use-before-define const extraProperties = {}; Object.keys(model.def.fields).forEach((fieldName) => { extraProperties[fieldName] = { enumerable...
javascript
{ "resource": "" }
q36339
normalizeUserData
train
function normalizeUserData() { function handler(req, res, next) { if (req.session && !req.session.user && req.session.auth && req.session.auth.loggedIn) { var user = {}; if (req.session.auth.github) { user.image = 'http://1.gravatar.com/avatar/'+req.session.auth.github.user.gravatar_id+'?s=48'; u...
javascript
{ "resource": "" }
q36340
IntN
train
function IntN(bytes, unsigned) { /** * Represented byte values, least significant first. * @type {!Array.<number>} * @expose */ this.bytes = new Array(nBytes); for (var i=0, k=Math.min(nBytes, bytes.len...
javascript
{ "resource": "" }
q36341
createBuildConfig
train
function createBuildConfig(grunt, options, projectConfig) { var configType = 'grunt-web'; if (options.buildConfig.dualProject) { configType = 'grunt-dual'; } else if (options.buildConfig.nodeProject) { configType = 'grunt-node'; } var loader = require('./' + configType); return...
javascript
{ "resource": "" }
q36342
echo
train
function echo(message) { return __awaiter(this, void 0, void 0, function* () { console.log('----------------'); console.log(message); console.log('----------------'); return Promise.resolve(); }); }
javascript
{ "resource": "" }
q36343
generateListItem
train
function generateListItem(result, hasBlankLine) { const content = [result[3]]; if (hasBlankLine) { content.unshift('\n'); } return { type: 'ListItem', checked: result[2] === '[x]' ? true : (result[2] === '[ ]' ? false : undefined), // true / false / undefined content, ...
javascript
{ "resource": "" }
q36344
getHistory
train
function getHistory(context) { if (!historyMap.has(context)) { clear(context); } return historyMap.get(context); }
javascript
{ "resource": "" }
q36345
constructor
train
function constructor(models, options) { if (!Array.isArray(models)) { options = models; models = []; } options = options || {}; // // Set the database name if it was provided in the options. // if (options.url) this.url = options.url; if (options.databas...
javascript
{ "resource": "" }
q36346
clone
train
function clone() { return new this.constructor(this.models, { url: 'function' === typeof this.url ? this.url() : this.url, model: this.model, database: this.database, comparator: this.comparator }); }
javascript
{ "resource": "" }
q36347
ShutdownManager
train
function ShutdownManager (params) { // Set State var that = this; this.isShuttingDown = false; this.actionChain = []; this.finalActionChain = []; // Set Parameters this.logger = (params && params.hasOwnProperty("logger")) ? params.logger : null; this.loggingPrefix = (params && params.hasOwnProperty("log...
javascript
{ "resource": "" }
q36348
readAuth
train
function readAuth (path) { var auth; if (grunt.file.exists(path)) { auth = grunt.file.read(path).trim().split(/\s/); if (auth.length === 2 && auth[0].indexOf('@') !== -1) { return {email: auth[0], password: auth[1]}; } } return null; ...
javascript
{ "resource": "" }
q36349
run
train
function run(command, auth, options, async, done, msgSuccess, msgSuccessAsync, msgFailure) { var args, flags, field, i, childProcess; // Pass auth. command = command.replace('{auth}', auth ? format('--email=%s --passin ', auth.email) : ''); ...
javascript
{ "resource": "" }
q36350
depends
train
function depends (targets) { debug('Depends: start parse dependencies'); targets = prepare.targets(targets).filter(directories); debug('Depends: target : ' + targets); targets.forEach(parse_node_module); }
javascript
{ "resource": "" }
q36351
terminate
train
function terminate(control) { if (control && control._process && typeof control._process.kill == 'function') { control._process._executioner_killRequested = true; control._process.kill(); return true; } return false; }
javascript
{ "resource": "" }
q36352
getMtgJson
train
function getMtgJson(type, directory, opts) { //Setup input and output URIs const outFileName = getJsonFilename(type, opts); const url = `${BASE_URL}/${outFileName}`; const output = path.resolve(`${directory}/${outFileName}`); const outputStream = fs.createWriteStream(output); //Return a file pa...
javascript
{ "resource": "" }
q36353
Data
train
function Data(properties) { this.custom = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36354
Custom
train
function Custom(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36355
Gateway
train
function Gateway(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36356
Attitude
train
function Attitude(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36357
Battery
train
function Battery(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36358
Dronestatus
train
function Dronestatus(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36359
GNSS
train
function GNSS(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36360
Signal
train
function Signal(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36361
Velocity
train
function Velocity(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36362
Atmosphere
train
function Atmosphere(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
{ "resource": "" }
q36363
relativize
train
function relativize (dest, src) { // both of these are absolute paths. // find the shortest relative distance. src = src.split("/") var abs = dest dest = dest.split("/") var i = 0 while (src[i] === dest[i]) i++ if (i === 1) return abs // nothing in common, leave absolute src.splice(0, i + 1) var dot...
javascript
{ "resource": "" }
q36364
configure
train
function configure(obj, fossa) { function get(key, backup) { return key in obj ? obj[key] : backup; } // // Allow new options to be be merged in against the original object. // get.merge = function merge(properties) { return fossa.merge(obj, properties); }; return get; }
javascript
{ "resource": "" }
q36365
Fossa
train
function Fossa(options) { this.fuse(); // // Store the options. // this.writable('queue', []); this.writable('plugins', {}); this.writable('connecting', false); this.readable('options', configure(options || {}, this)); // // Prepare a default model and collection sprinkled with MongoDB proxy metho...
javascript
{ "resource": "" }
q36366
expandKey
train
function expandKey(key) { let tempWord = new Array(WORD_LENGTH); let rounds = getRoundsCount(key); let wordsCount = key.length / WORD_LENGTH; let keySchedule = new Array(COLUMNS * (rounds + 1)); for (let i = 0; i < wordsCount; i++) { keySchedule[i] = key.slice(WORD_LENGTH * i, WORD_LENGTH * i + WORD_LENGTH); ...
javascript
{ "resource": "" }
q36367
encryptBlock
train
function encryptBlock(block, keySchedule) { let state = splitToMatrix(block); state = a_u.addRoundKey(state, keySchedule.slice(0, 4)); let rounds = keySchedule.length / COLUMNS; for (let round = 1; round < rounds; round++){ state = a_u.subBytes(state); state = a_u.shiftRows(state); state = a_u.mixColumns(sta...
javascript
{ "resource": "" }
q36368
train
function ( taskName ) { var task = grunt.config.get( "bundles" )[taskName]; var retVal = []; if ( task ) { var sources = task.modules; if ( !sys.isEmpty( sources ) && !sys.isEmpty( sources.src ) ) { grunt.log.writeln( "Adding sources for " + taskName ); retVal = sys.map( grunt.file.expand( so...
javascript
{ "resource": "" }
q36369
train
function ( file ) { var resolved; var expanded = grunt.file.expand( file )[0]; if ( !expanded ) { resolved = require.resolve( file ); } else { resolved = "./" + expanded; } return resolved; }
javascript
{ "resource": "" }
q36370
train
function ( pkg ) { grunt.verbose.writeln( "Populating compiler" ); var copts = { noParse : pkg.noParse, entries : pkg.modules, externalRequireName : options.externalRequireName, pack : options.pack, bundleExternal : options.bundleExternal, // buil...
javascript
{ "resource": "" }
q36371
train
function ( pkg, compiler ) { if ( !sys.isEmpty( task.data.depends ) && options.resolveAliases && !sys.isEmpty( pkg.dependAliases ) ) { compiler.transform( function ( file ) { grunt.verbose.writeln( "Transforming " + file ); function write( buf ) { data += buf; } var data = ''; r...
javascript
{ "resource": "" }
q36372
dumpToFile
train
function dumpToFile(extension, regex) { return inspect(onComplete); function onComplete(filename, contents, done) { if (!regex || regex.test(filename)) { var newName = [filename, extension || 'gen'].join('.'); fs.writeFile(newName, contents, done); } else { done(); } } }
javascript
{ "resource": "" }
q36373
dbName
train
function dbName(str) { if (!str) return str; str = str.replace(/[A-Z]/g, $0 => `_${$0.toLowerCase()}`); if (str[0] === '_') return str.slice(1); return str; }
javascript
{ "resource": "" }
q36374
train
function () { bytes = str.substr(u, 45).split('') for (i in bytes) { bytes[i] = bytes[i].charCodeAt(0) } return bytes.length || 0 }
javascript
{ "resource": "" }
q36375
train
function(result, callback) { self.cache.put(result, function(err, doc) { if (err) return callback(err); callback(null, result, doc._id); }); }
javascript
{ "resource": "" }
q36376
train
function(result, cached, callback) { self.metacache.store(id, processor, cached, function(err) { if (err) return callback(err); callback(null, result); }); }
javascript
{ "resource": "" }
q36377
train
function(metacache, callback) { var funcs = []; for (var processor in metacache) { if (processor !== '_id') { var cached = metacache[processor]; funcs.push(function(callback) { self.cache.del...
javascript
{ "resource": "" }
q36378
load
train
function load(file, options) { if (options.cache && rr.cache['rvc!' + file]) { return Promise.resolve(rr.cache['rvc!' + file]); } return requireJSAsync(file).then(function (Component) { // flush requireJS's cache _.forEach(requireJS.s.contexts._.defined, function (value, key, array) { if (key.substr(0, 4) ...
javascript
{ "resource": "" }
q36379
requireJSAsync
train
function requireJSAsync (file) { return new Promise(function (resolve, reject) { requireJS([ 'rvc!' + requireJSPath(file, '.html') ], resolve, reject); }); }
javascript
{ "resource": "" }
q36380
requireJSPath
train
function requireJSPath(file, extension) { return path.join(path.dirname(file), path.basename(file, extension)).replace(/\\/g, '/'); }
javascript
{ "resource": "" }
q36381
DetectMouseUser
train
function DetectMouseUser(event) { if(isMouseUser) { // collection throttle interval. setInterval(function() { trackData = true; }, 50); return true; } let current = movement; if(x && y){ movement = movement + Mat...
javascript
{ "resource": "" }
q36382
startIdle
train
function startIdle() { var idleCount = 0; function idle() { coordinates.push({ t: 1, x: lastX, y: lastY }); idleCount++; if (idleCount > 10) { clearInterval(idleInterval); } ...
javascript
{ "resource": "" }
q36383
emitHeatmapCoordinates
train
function emitHeatmapCoordinates() { if(coordinates.length > 0) { ceddl.emitEvent('heatmap:update', { width: windowWidth, coordinates: coordinates.splice(0, coordinates.length) }); } windowWidth = Math.round(parseInt(window.innerWidth, 10));...
javascript
{ "resource": "" }
q36384
isClickTarget
train
function isClickTarget(element) { return element.hasAttribute('ceddl-click') || (element.nodeType === 1 && element.tagName.toUpperCase() === 'BUTTON') || (element.nodeType === 1 && element.tagName.toUpperCase() === 'A'); }
javascript
{ "resource": "" }
q36385
delegate
train
function delegate(callback, el) { var currentElement = el; do { if (!isClickTarget(currentElement)) continue; callback(currentElement); return; } while(currentElement.nodeName.toUpperCase() !== 'BODY' && (currentElement = currentElement.parentNode)); }
javascript
{ "resource": "" }
q36386
ButtonGroup
train
function ButtonGroup({ children, className, ...rest }) { const classes = cx(buttonGroupClassName, className) return ( <div className={classes} {...rest}> {children} </div> ) }
javascript
{ "resource": "" }
q36387
hashDocument
train
function hashDocument(document) { var words; if (Buffer.isBuffer(document)) { words = Base64.parse(document.toString('base64')); } else if (typeof document === 'string') { words = Base64.parse(document); } else { throw new TypeError('Expected document to be Buffer or String'); } var hash = sha...
javascript
{ "resource": "" }
q36388
publishProof
train
function publishProof(privateKeyHex, toAddress, hash, rpcUri) { if (!EthereumUtil.isValidAddress(EthereumUtil.addHexPrefix(toAddress))) { throw new Error('Invalid destination address.'); } if (!rpcUri) { rpcUri = localDefault; } var web3 = new Web3( new Web3.providers.HttpProvider(rpcUri) ); ...
javascript
{ "resource": "" }
q36389
buildTransaction
train
function buildTransaction(privateKeyHex, toAddress, hash, web3) { var privateKeyBuffer = Buffer.from(privateKeyHex, 'hex'); if (!EthereumUtil.isValidPrivate(privateKeyBuffer)) { throw new Error('Invalid private key.'); } var txParams = { nonce: '0x00', gasPrice: '0x09184e72a000', // How should we ...
javascript
{ "resource": "" }
q36390
toCsvValue
train
function toCsvValue(theValue, sDelimiter) { const t = typeof (theValue); let output, stringDelimiter ; if (typeof (sDelimiter) === "undefined" || sDelimiter === null) stringDelimiter = '"'; else stringDelimiter = sDelimiter; if (t === "undefined" || t === null) ...
javascript
{ "resource": "" }
q36391
taskMinus
train
function taskMinus() { taskCounter-- if (taskCounter === 0) { // Time to respond if (files.length === 0) { res.send(200, { result: 'no files to upload', files }) } else { res.send(201, { result: 'upload OK', ...
javascript
{ "resource": "" }
q36392
train
function (tmr, timeout) { return new Promise((resolve, reject) => { /*eslint-disable no-return-assign */ return tmr = setTimeout(reject, timeout, httpError(408)); }); }
javascript
{ "resource": "" }
q36393
defineImmutable
train
function defineImmutable(target, values) { Object.keys(values).forEach(function(key){ Object.defineProperty(target, key, { configurable: false, enumerable: true, value: values[key] }); }); return target; }
javascript
{ "resource": "" }
q36394
train
function ( data ) { if ( !data ) return data; if ( typeof data !== 'object' ) return data; if ( 'entrySet' in data && typeof data.entrySet === 'function' ) { //var allowed_long_keys = ['utc_timestamp', 'duration', 'type', 'token']; var set = data.entrySet(); if ( !set ) return dat...
javascript
{ "resource": "" }
q36395
evaluate
train
function evaluate(score, at, mt) { var automaticThreshold = at || 17.73; var manualThreshold = mt || 15.957; var result = "no match"; if (score >= automaticThreshold) { result = "automatic"; } else if (score >= manualThreshold) { result = "manual"; } return result; }
javascript
{ "resource": "" }
q36396
train
function(seneca, options, bases, next) { var add = []; var host = options.host; if (0 === bases.length) { if (null != host && host !== DEFAULT_HOST) { add.push(host + ":" + DEFAULT_PORT); } add.push(DEFAULT_HOST + ":" + DEFAULT_PORT); } ...
javascript
{ "resource": "" }
q36397
maxSatisfying
train
function maxSatisfying (versions, range) { return versions .filter(function (v) { return satisfies(v, range) }) .sort(compare) .pop() }
javascript
{ "resource": "" }
q36398
train
function(item) { // Drop newline symbol in error string item.msg = (Array.isArray(item.msg) ? item.msg.join(' ') : item.msg).replace('\n', ''); // Using zero instead of undefined item.column = (item.column === undefined) ? 0 : item.column; // Drop `PUG:LINT_` prefix in error code item.code = chalk.grey(item...
javascript
{ "resource": "" }
q36399
readFile
train
function readFile (file) { if (!isFileRegistered(file)) { return undefined; } fileRegistry[file].content = gruntIsFile(file) ? gruntRead(file) + '\x0A' : ''; }
javascript
{ "resource": "" }