_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q36500
flock
train
function flock(boids) { const averageVelocity = velocity.clone(); const averagePosition = Vec2.get(); let inSightCount = 0; for (let i = 0; i < boids.length; i++) { const b = boids[i]; if (b !== boid && inSight(b)) { averageVelocity.add(b.velocity)...
javascript
{ "resource": "" }
q36501
getEntityNameKeyMap
train
function getEntityNameKeyMap(structure) { const result = {}; for (const kk in structure) { const vv = structure[kk]; if (typeof vv === 'string') { if (types.isMap(vv)) { const info = types.getTypeInfo(vv); const entityName = info.entity; if (_entityNameType[ent...
javascript
{ "resource": "" }
q36502
wrapProcess
train
function wrapProcess (tmpIn, tmpOut, processProvider) { return createStream(tmpIn, tmpOut, function (input, output, callback) { var _this = this var process = processProvider.call(this, tmpIn, tmpOut) process.on('error', function (error) { callback(error) }) if (!tmpIn) { input.pipe(pr...
javascript
{ "resource": "" }
q36503
parseString
train
function parseString (string, tmpIn, tmpOut) { var resultIn = null var resultOut = null var resultString = string.replace(placeHolderRegex, function (match) { switch (match) { case IN: resultIn = resultIn || tmpIn return resultIn case OUT: resultOut = resu...
javascript
{ "resource": "" }
q36504
cleanJoin
train
function cleanJoin(req) { if(!isAbsoluteURL(req.url) && req.baseURL) { const parsedBase = url.parse(req.baseURL, true); const parsed = url.parse(req.url, true); return { protocol: parsedBase.protocol, host: parsedBase.hostname, port: parsedBase.port, path: URLJoin(parsedBase.pathna...
javascript
{ "resource": "" }
q36505
load
train
function load () { const str = fs.readFileSync(settingsFile, 'utf8') if (str) { const settings = JSON.parse(str) this.settings = settings.livereload this.paths = getPaths(settings) .map(p => path.normalize(this.root + '/' + p)) .map(p => makeGlob(p)) } }
javascript
{ "resource": "" }
q36506
init
train
function init (root, storage) { // calling path const calling = path.dirname(getCallingScript()) // root path root = !root || root === '.' || root === './' ? root = calling : path.isAbsolute(root) ? root : path.normalize(calling + root) sketchpad.root = root.replace(/\/*$/, '/') // set...
javascript
{ "resource": "" }
q36507
getOwnNameFallBack
train
function getOwnNameFallBack(names, dest) { if (!names[dest]) return dest else return names[dest][dest] || dest }
javascript
{ "resource": "" }
q36508
train
function (tag, text, index) { var re = wp.shortcode.regexp(tag) var match var result re.lastIndex = index || 0 match = re.exec(text) if (!match) { return } // If we matched an escaped shortcode, try again. if (match[1] === '[' && match[7] === ']') { return wp.shortcode...
javascript
{ "resource": "" }
q36509
train
function (match) { var type if (match[4]) { type = 'self-closing' } else if (match[6]) { type = 'closed' } else { type = 'single' } return new Shortcode({ tag: match[2], attrs: match[3], type: type, content: match[5] }) }
javascript
{ "resource": "" }
q36510
train
function () { var text = '[' + this.tag _.each(this.attrs.numeric, function (value) { if (/\s/.test(value)) { text += ' "' + value + '"' } else { text += ' ' + value } }) _.each(this.attrs.named, function (value, name) { text += ' ' + name + '="' + value + '"' ...
javascript
{ "resource": "" }
q36511
checkArguments
train
function checkArguments (argz) { if (!argz.args.length) { return error('first argument cant be function') } if (isEmptyFunction(argz.cb.toString())) { return error('should have `callback` (non empty callback)') } if (typeOf(argz.args[0]) !== 'string') { return type('expect `cmd` be string', argz...
javascript
{ "resource": "" }
q36512
buildSpawn
train
function buildSpawn (cmd, args, opts, callback) { var proc = spawn(cmd, args, opts) var buffer = new Buffer('') var cmdError = {} cmd = cmd + ' ' + args.join(' ') if (proc.stdout) { proc.stdout.on('data', function indexOnData (data) { buffer = Buffer.concat([buffer, data]) }) } proc ....
javascript
{ "resource": "" }
q36513
CommandError
train
function CommandError (err) { this.name = 'CommandError' this.command = err.command this.message = err.message this.stack = err.stack this.buffer = err.buffer this.status = err.status Error.captureStackTrace(this, CommandError) }
javascript
{ "resource": "" }
q36514
router
train
function router(req, resp, next) { const routerPath = req.routePath || ''; const beforeRunMiddleware = (route) => { const match = matchRoute(routerPath, req, route); if (!match) return false; const { params, path: matchPath } = match; if (options.params) req.params = { ...options.para...
javascript
{ "resource": "" }
q36515
eventPromise
train
function eventPromise (emitter, eventName) { return new Promise((resolve, reject) => { emitter.on(eventName, (...args) => { return resolve(args) }) }) }
javascript
{ "resource": "" }
q36516
status
train
function status() { var tasks = [], cwd = process.cwd(); findRepos(function(err, repos) { if (err) return console.log(err); repos.forEach(function(repo) { tasks.push(function(done) { repo.status(function(err, status) { if (err) return done(err); if (argv.b) { ...
javascript
{ "resource": "" }
q36517
pull
train
function pull() { var tasks = [], cwd = process.cwd(); findRepos(function(err, repos) { if (err) return console.log(err); repos.forEach(function(repo) { tasks.push(function(done) { repo.status(function(err, status) { var name = status.repo.path.replace(cwd + '/', ''); ...
javascript
{ "resource": "" }
q36518
indent
train
function indent(str, prefix) { prefix = prefix || ' '; var lines = str.split("\n"); lines.forEach(function(line, i) { lines[i] = prefix + line; }); return lines.join("\n"); }
javascript
{ "resource": "" }
q36519
findRepos
train
function findRepos(callback) { var cwd = process.cwd(), tasks = []; fs.readdir(cwd, function(err, files) { if (err) return callback(err); var repos = []; files.forEach(function(file) { if (fs.existsSync(path.join(cwd, file, '.git'))) { repos.push(path.join(cwd, file)); } ...
javascript
{ "resource": "" }
q36520
Iterator
train
function Iterator(iterator) { if (Array.isArray(iterator) || typeof iterator == "string") return Iterator.iterate(iterator); iterator = Object(iterator); if (!(this instanceof Iterator)) return new Iterator(iterator); this.next = this.send = iterator.send || iterator.next || ...
javascript
{ "resource": "" }
q36521
traverse
train
function traverse(_promise){ var c = _promise._chain, s = _promise._state, v = _promise._value, o = _promise._opaque, t, p, h, r; while((t = c.shift())){ p = t[0]; h = t[s]; if(typeof h === 'function') { try { r = h(v,o); ...
javascript
{ "resource": "" }
q36522
cart
train
function cart(xs, ys) { // nothing on the left if(!xs || xs.length === 0) return ys.map(function(y){ return [[],y] }); // nothing on the right if(!ys || ys.length === 0) return xs.map(function(x){ return [x,[]] }); return Combinatorics.cartesianProduct(x, y).toArray(); }
javascript
{ "resource": "" }
q36523
train
function(obj, iterator, context) { if (!obj) return else if (obj.forEach) obj.forEach(iterator) else if (obj.length == +obj.length) { for (var i = 0; i < obj.length; i++) iterator.call(context, obj[i], i) } else { for (var key in obj) iterator.call(context, obj[ke...
javascript
{ "resource": "" }
q36524
train
function(context, handlers/*, params*/ ) { var args = this.slice(arguments) args.shift() args.shift() this.each(handlers, function(handler) { if (handler) handler.apply(context, args) }) }
javascript
{ "resource": "" }
q36525
train
function(array) { // return Array.prototype.slice.call(array) var i = array.length var a = new Array(i) while(i) { i -- a[i] = array[i] } return a }
javascript
{ "resource": "" }
q36526
train
function(obj, extObj) { this.each(extObj, function(value, key) { if (extObj.hasOwnProperty(key)) obj[key] = value }) return obj }
javascript
{ "resource": "" }
q36527
train
function (f, proto) { function Ctor() {} Ctor.prototype = proto f.prototype = new Ctor() f.prototype.constructor = Ctor return f }
javascript
{ "resource": "" }
q36528
inspect
train
function inspect(callback) { return function (filename) { var chunks = []; function transform(chunk, encoding, done) { /* jshint validthis:true */ chunks.push(chunk); this.push(chunk); done(); } function flush(done) { callback(filename, chunks.join(''), done); if ...
javascript
{ "resource": "" }
q36529
getKeyColumn
train
function getKeyColumn(propDesc, keyPropContainer) { if (propDesc.keyColumn) return propDesc.keyColumn; const keyPropDesc = keyPropContainer.getPropertyDesc( propDesc.keyPropertyName); return keyPropDesc.column; }
javascript
{ "resource": "" }
q36530
makeSelector
train
function makeSelector(sql, markup) { return { sql: (sql instanceof Translatable ? sql.translate.bind(sql) : sql), markup: markup }; }
javascript
{ "resource": "" }
q36531
makeOrderElement
train
function makeOrderElement(sql) { return { sql: (sql instanceof Translatable ? sql.translate.bind(sql) : sql) }; }
javascript
{ "resource": "" }
q36532
buildQueryTree
train
function buildQueryTree( dbDriver, recordTypes, propsTree, anchorNode, clauses, singleAxis) { // get and validate top records specification data const recordTypeDesc = recordTypes.getRecordTypeDesc( propsTree.desc.refTarget); const topIdPropName = recordTypeDesc.idPropertyName; const topIdColumn = recordTypeDes...
javascript
{ "resource": "" }
q36533
long
train
function long(nodes, context, recur, wrap) { context.write(WRAPPERS[wrap].left); for (var i = 0; i < nodes.length; i++) { recur(nodes[i]); if (nodes[i + 1]) { context.write(', ');}} context.write(WRAPPERS[wrap].right);}
javascript
{ "resource": "" }
q36534
short
train
function short(nodes, context, recur, wrap) { context.write(WRAPPERS[wrap].left); context.indentIn(); context.write('\n'); for (var i = 0; i < nodes.length; i++) { context.write(context.getIndent()); recur(nodes[i]); if (nodes[i + 1]) { context.write(',\n');}} ...
javascript
{ "resource": "" }
q36535
MultiserverWorker
train
function MultiserverWorker(servers, func_name, callback, options) { var that = this; options = options || {}; Multiserver.call(this, servers, function(server, index) { return new gearman.Worker(func_name, function(payload, worker) { that._debug('received job from', that._serverString(index)); retu...
javascript
{ "resource": "" }
q36536
exec
train
function exec() { var actions = { commands: { init: { action: _init }, gen: { action: _gen }, watch: { action: _watch }, drift: { action: _watch }, clean: { action: _clean } } }; bag.command(__dirname, actions); }
javascript
{ "resource": "" }
q36537
pluck
train
function pluck(data) { // // Either map as array or return object through single map. // if (Array.isArray(data)) return data.map(map); return map(data); /** * Recursive mapping function. * * @param {Object} d Collection, Model or plain object. * @returns {Object} plucked ob...
javascript
{ "resource": "" }
q36538
map
train
function map(d) { if (isModel(d)) return pluck(d.attributes); for (var key in d) { if (isCollection(d[key])) { d[key] = pluck(d[key].models); } if (isModel(d[key])) { // // Delete MongoDB ObjectIDs. The stored state of the model is ambigious ...
javascript
{ "resource": "" }
q36539
persist
train
function persist(client, next) { var single = isModel(item) , data; switch (method) { case 'create': data = single ? [ item.clone() ] : item.clone().models; client.insert(pluck(data), config, function inserted(error, results) { if (error) return next(error); // ...
javascript
{ "resource": "" }
q36540
after
train
function after(results, next) { item.trigger('after:' + method, function done(error) { next(error, results); }); }
javascript
{ "resource": "" }
q36541
createRecord
train
function createRecord(fvs, options) { options || (options = {}); const model = this; const row = {}; if (fvs) { for (const kk in fvs) { row[kk] = fvs[kk]; } } const r = constructRecord(model, row, Object.keys(model.def.fields), true); getDefaultOnCreate(r, null, options.createdBy); return...
javascript
{ "resource": "" }
q36542
readDirSync
train
function readDirSync (dir, allFiles = []) { const files = fs.readdirSync(dir).map(f => join(dir, f)) allFiles.push(...files) files.forEach(f => { fs.statSync(f).isDirectory() && readDirSync(f, allFiles) }) return allFiles }
javascript
{ "resource": "" }
q36543
getData
train
function getData (allFiles = [], config) { const files = allFiles.reduce((memo, iteratee) => { const filePath = path.parse(iteratee) if (config.include.includes(filePath.ext) && !config.exclude.includes(filePath.base)) { const newFile = { file: iteratee.replace(config.content, ''), dir: ...
javascript
{ "resource": "" }
q36544
translate
train
function translate (content, contentTypes) { let output = {} content.forEach(each => { const base = path.parse(each.file).base if (base === 'index.md') { const type = each.dir.split('/').pop() const contentTypeTranslation = contentTypes.find(contentType => contentType[type]) if (contentTyp...
javascript
{ "resource": "" }
q36545
write
train
function write (filename, content) { const json = JSON.stringify(content, (key, value) => value === undefined ? null : value) fs.writeFileSync(filename, json) return json }
javascript
{ "resource": "" }
q36546
parse
train
function parse(html, script, filePath){ var m, index = 0;//the index in the html string while(m = reDelim.exec(html)) { addLiteral(script, html.slice(index, m.index));//string addCode(script, m, filePath); index = m.index + m[0].length; } addLiteral(script, html.slice(index)); script.push(...
javascript
{ "resource": "" }
q36547
addLiteral
train
function addLiteral(script, str){ if(!str) return; str = str.replace(/\\|'/g, '\\$&');// escape ' var m, index = 0; while(m = reNewline.exec(str)){ var nl = m[0]; var es = nl==='\r\n'? '\\r\\n':'\\n'; script.push("__p('" + str.slice(index, m.index) + es + "');\n"); index = m.index + nl...
javascript
{ "resource": "" }
q36548
addCode
train
function addCode(script, match, filePath) { var leftDeli = match[1], code = match[2]; if(leftDeli==='<@' || leftDeli==='<!--@='){ script.push('__p(escape(' + code + '));'); } else if(leftDeli==='<@|' || leftDeli==='<!--@|'){//no escape script.push('__p(' + code + ');'); } else{//<!--@ --> ...
javascript
{ "resource": "" }
q36549
defaultName
train
function defaultName (folder, data) { if (data.name) return data.name return path.basename(folder).replace(/^node[_-]?|[-\.]?js$/g, '') }
javascript
{ "resource": "" }
q36550
DriverOperationError
train
function DriverOperationError(code,description) { this.code = code; this.description = description; console.log('in DriverOperationError',code,description); }
javascript
{ "resource": "" }
q36551
train
function(me, deviceType, connectionType) { if (!self.hasOpenAll) { throw new DriverInterfaceError( 'openAll is not loaded. Use ListAll and Open functions instead.' ); } if (deviceType === undefined || connectionType === undefined) { throw 'Ins...
javascript
{ "resource": "" }
q36552
done
train
function done() { // get the next route from the stack route = stack.pop() var callback // if the stack is not empty yet, i.e., if this is not // the last route part, the callback standard callback is provided if (stack.length) { callback = done } // otherwise a slightly modified ...
javascript
{ "resource": "" }
q36553
Ejector
train
function Ejector(conf) { component.Component.call(this, 'ejector', conf); var that = this; this._dbconn = conf.dbconn; this.registerGearman(conf.servers, { worker: { func_name: 'delayedJobDone', func: function(payload, worker) { var task = JSON.parse(payload.toString()); that._in...
javascript
{ "resource": "" }
q36554
getRandomItem
train
function getRandomItem(list) { if (!list) return null; if (list.length === 0) return list[0]; const randomIndex = random(1, list.length) - 1; return list[randomIndex]; }
javascript
{ "resource": "" }
q36555
_loadRecursive
train
function _loadRecursive(container, map, accum = {}) { return Bluebird.reduce(Object.keys(map), (memo, key) => { const path = map[key]; if (typeof path === 'string') { return container._load(path) .then((mod) => { set(memo, key, mod); return memo; }); } return ...
javascript
{ "resource": "" }
q36556
_recursiveDeps
train
function _recursiveDeps(graph, name, deps) { return Object.keys(deps).forEach((key) => { const dep = deps[key]; if (PLUGIN.test(dep)) { return; } if (typeof dep === 'string') { if (!graph.hasNode(dep)) { graph.addNode(dep); } graph.addDependency(name, dep); } else i...
javascript
{ "resource": "" }
q36557
profile
train
function profile(excludeRegex) { var categories = []; return { forCategory: forCategory, toArray : toArray, toString : toString }; function toArray() { return categories; } function toString() { return categories .map(String) .filter(Boolean) .join('\n'); } ...
javascript
{ "resource": "" }
q36558
createEventTransform
train
function createEventTransform(data) { return inspect(onComplete); function onComplete(filename) { isUsed = true; var now = Date.now(); var events = eventsByFilename[filename] = eventsByFilename[filename] || []; events.push(now, data); } }
javascript
{ "resource": "" }
q36559
report
train
function report() { return Object.keys(eventsByFilename) .filter(testIncluded) .reduce(reduceFilenames, {}); function testIncluded(filename) { return !excludeRegex || !excludeRegex.test(filename); } function reduceFilenames(reduced, filename) { var totalsByKey =...
javascript
{ "resource": "" }
q36560
rows
train
function rows() { var fileTotals = filenames.reduce(reducePropToLength.bind(json), {}), fileOrder = sort(fileTotals); return fileOrder.map(rowForFile); function rowForFile(filename) { var data = json[filename]; // console.log(JSON.stringify(data, null, 2)); ...
javascript
{ "resource": "" }
q36561
train
function (data) { // Add property to hold internal values Object.defineProperty(this, '_', { enumerable: false, configurable: false, writable: false, value: { dt: this._clone(data), ev: {}, df: {}, sp: false, ct: 0 ...
javascript
{ "resource": "" }
q36562
Application
train
function Application (configDir, appConfigFileName) { /** * The DXL client to use for communication with the fabric. * @private * @type {external.DxlClient} * @name Application#_dxlClient */ this._dxlClient = null /** * The directory containing the application configuration files. * @private ...
javascript
{ "resource": "" }
q36563
transform
train
function transform(filepath, options) { // Normalize options options = extend({ match: /bower_components.*\.html$/ }, options || {}) if(!(options.match instanceof RegExp)) { options.match = RegExp.apply(null, Array.isArray(options.match) ? options.match : [options.match]) } // Shim polymer.js ...
javascript
{ "resource": "" }
q36564
include
train
function include(partial, cb) { cb((params.partials && params.partials[partial]) ? params.partials[partial] : '[error] partial ' + partial + ' does not exist'); }
javascript
{ "resource": "" }
q36565
title
train
function title(cb) { cb((params.sitemap && params.sitemap[page]) ? params.sitemap[page].title : '[error] page ' + page + ' does not have any sitemap title'); }
javascript
{ "resource": "" }
q36566
train
function (value, encoding) { encoding = (typeof encoding === 'undefined') ? 'utf8' : encoding if (Buffer.isBuffer(value)) { value = value.toString(encoding) } return value }
javascript
{ "resource": "" }
q36567
train
function (message, encoding) { return module.exports.jsonToObject( module.exports.decodePayload(message, encoding)) }
javascript
{ "resource": "" }
q36568
train
function (value, encoding) { encoding = (typeof encoding === 'undefined') ? 'utf8' : encoding var returnValue = value if (!Buffer.isBuffer(returnValue)) { if (value === null) { returnValue = '' } else if (typeof value === 'object') { returnValue = module.exports.objectToJson(valu...
javascript
{ "resource": "" }
q36569
train
function (message, value, encoding) { message.payload = module.exports.encode(value, encoding) }
javascript
{ "resource": "" }
q36570
train
function (obj, prettyPrint) { return prettyPrint ? JSON.stringify(obj, Object.keys(findUniqueKeys( obj, {}, [])).sort(), 4) : JSON.stringify(obj) }
javascript
{ "resource": "" }
q36571
plugin
train
function plugin(derby) { // Wrap createBackend in order to be able to listen to derby-ar RPC calls // But only do it once (e.g. if we have many apps, we need to ensure we only wrap it once since otherwise we'll destroy the wrapping) if(derby.__createBackend) return; derby.__createBackend = derby.createBackend;...
javascript
{ "resource": "" }
q36572
removeModuleAlias
train
function removeModuleAlias(moduleName, folder, replacement = './') { return __awaiter(this, void 0, void 0, function* () { fs.readdirSync(folder).forEach(child => { if (fs.statSync(folder + '/' + child).isDirectory()) { removeModuleAlias(moduleName, folder + '/' + child, './.' + ...
javascript
{ "resource": "" }
q36573
packageFilter
train
function packageFilter(pkg, root) { pkg.main = pkg.glslify || ( path.extname(pkg.main || '') !== '.js' && pkg.main ) || 'index.glsl' return pkg }
javascript
{ "resource": "" }
q36574
train
function (obj) { var fns = {}, i; for (i in obj) { fns[i] = hogan.compile( obj[i] ); } return fns; }
javascript
{ "resource": "" }
q36575
diffObjects
train
function diffObjects(container, pathPrefix, objOld, objNew, patchSpec) { // keep track of processed properties const unrecognizedPropNames = new Set(Object.keys(objNew)); // diff main properties diffObjectProps( container, pathPrefix, objOld, objNew, unrecognizedPropNames, patchSpec); // check if polymor...
javascript
{ "resource": "" }
q36576
diffMaps
train
function diffMaps(propDesc, propPath, mapOld, mapNew, patchSpec) { const objects = (propDesc.scalarValueType === 'object'); const keysToRemove = new Set(Object.keys(mapOld)); for (let key of Object.keys(mapNew)) { const valOld = mapOld[key]; const valNew = mapNew[key]; if ((valNew === undefined) || (valNew...
javascript
{ "resource": "" }
q36577
deserializeValue
train
function deserializeValue(value) { var num try { return value ? value == 'true' || value == true || (value == 'false' || value == false ? false : value == 'null' ? null : !/^0/.test(value) && !isNaN(num = Number(value)) ? num : /^[\[\{]/.test(value) ? JSON.parse(value) : ...
javascript
{ "resource": "" }
q36578
remove
train
function remove(item, list) { var i = list.indexOf(item); if (~i) list.splice(i, 1); }
javascript
{ "resource": "" }
q36579
train
function(element, options) { // Make sure the transform property is an object if(typeof element.transform != "object") { element.transform = {}; } // If we have an object of options if(typeof options[0] == "object") { // Loop through o...
javascript
{ "resource": "" }
q36580
train
function(element) { // Loop through all saved transform functions to generate the style text var funcs = Object.keys(element.transform); var style = []; funcs.forEach(function(func) { var args = element.transform[func]; // If we have an array of argu...
javascript
{ "resource": "" }
q36581
findModulePath
train
function findModulePath(filename_rootfile, filename, options = DEFAULT_OPTIONS) { /** * . 相对路径 * . 绝对路径 */ const ext = path.extname(filename); if (ext && exports.extensions.indexOf(ext) === -1) { return null; } if (path.dirname(filename_rootfile) !== filename_rootfile) { ...
javascript
{ "resource": "" }
q36582
MultiserverClient
train
function MultiserverClient(servers, options) { options = options || {}; Multiserver.call(this, servers, function(server) { return new gearman.Client({ host: server.host, port: server.port, debug: options.debug || false }); }, Multiserver.component_prefix(options.component_name) + 'client...
javascript
{ "resource": "" }
q36583
dump
train
function dump(gcore, coredump) { gcore = gcore || 'gcore'; coredump = coredump || `${process.cwd()}/core.${process.pid}`; return DumpProcess.dumpProcess(gcore, coredump); }
javascript
{ "resource": "" }
q36584
installMutations
train
function installMutations(modules, enclosingFolder) { makeFolderLibraryIfNotExist(enclosingFolder); if (modules.length === 0) { return new Promise(resolve => resolve({})); } return npm.install(modules, { cwd: pathToMutations(enclosingFolder), save: true }); }
javascript
{ "resource": "" }
q36585
loadMutations
train
function loadMutations(enclosingFolder) { const here = jetpack.cwd(pathToMutations(enclosingFolder)); const pkg = here.read(PACKAGE_JSON, "json"); errorIf( !pkg, `There doesn't seem to be a package.json file. Did you create one at the enclosing folder? FYI: installMutations creates one for you if you d...
javascript
{ "resource": "" }
q36586
next
train
function next() { var fns = activeQueue.shift(); if ( !fns ) { return; } ret = ret.then( typeof fns[0] === 'function' ? fns[0].bind(self) : fns[0], typeof fns[1] === 'function' ? fns[1].bind(self) : fns[1] ); next(); }
javascript
{ "resource": "" }
q36587
isInstalled
train
function isInstalled(dep) { if (_.has(exceptions, dep)) return exceptions[dep]; return installedDeps.has(dep); }
javascript
{ "resource": "" }
q36588
resolveDependencyPlugins
train
function resolveDependencyPlugins(deps) { return deps .filter(dep => isInstalled(dep) && isInstalled(`eslint-plugin-${dep}`)) .map(dep => `./lib/plugin-conf/${dep}.js`); }
javascript
{ "resource": "" }
q36589
mutate
train
function mutate(Component, title, api = {}) { class Mutated extends React.Component { constructor(props, context) { super(props); this.ToRender = Component; const mutations = context.mutations; if (!mutations || !mutations[title]) { return; } // Convert old style mut...
javascript
{ "resource": "" }
q36590
run
train
function run(collector, commands, keys, params, options, callback) { // either keys is array or commands var prefix, key, cmd = (keys || commands).shift(); // done here if (!cmd) { return callback(null, collector); } // transform object into a command if (keys) { key = cmd; cmd = command...
javascript
{ "resource": "" }
q36591
constructor
train
function constructor(attributes, options) { var hooks = [] , local = {}; options = options || {}; // // Set the database name and/or urlRoot if provided in the options. // if (options.database) this.database = options.database; if (options.urlRoot) this.urlRoot = opti...
javascript
{ "resource": "" }
q36592
save
train
function save() { var defer = new Defer , xhr = backbone.Model.prototype.save.apply(this, arguments); if (xhr) return xhr; defer.next(new Error('Could not validate model')); return defer; }
javascript
{ "resource": "" }
q36593
train
function(namespacedEvent, callback) { var event, namespace, _ref; _ref = namespacedEvent.split("."), event = _ref[0], namespace = _ref[1]; if (namespace) { callback.__PIXIE || (callback.__PIXIE = {}); callback.__PIXIE[namespace] = true; } eventCallbacks[event] || (eventCall...
javascript
{ "resource": "" }
q36594
train
function(namespacedEvent, callback) { var callbacks, event, key, namespace, _ref; _ref = namespacedEvent.split("."), event = _ref[0], namespace = _ref[1]; if (event) { eventCallbacks[event] || (eventCallbacks[event] = []); if (namespace) { eventCallbacks[event] = eventCallbac...
javascript
{ "resource": "" }
q36595
train
function() { var callbacks, event, parameters; event = arguments[0], parameters = 2 <= arguments.length ? __slice.call(arguments, 1) : []; callbacks = eventCallbacks[event]; if (callbacks && callbacks.length) { self = this; return callbacks.each(function(callback) { ret...
javascript
{ "resource": "" }
q36596
train
function() { var attrNames; attrNames = 1 <= arguments.length ? __slice.call(arguments, 0) : []; return attrNames.each(function(attrName) { return self[attrName] = function() { return I[attrName]; }; }); }
javascript
{ "resource": "" }
q36597
train
function() { var Module, key, moduleName, modules, value, _i, _len; modules = 1 <= arguments.length ? __slice.call(arguments, 0) : []; for (_i = 0, _len = modules.length; _i < _len; _i++) { Module = modules[_i]; if (typeof Module.isString === "function" ? Module.isString() : ...
javascript
{ "resource": "" }
q36598
train
function (route, options) { var opts = options || {}; opts.dest = opts.dest || './docs'; opts.destname = opts.destname || false; route = route || './*.js'; mkdirp( opts.dest, function (err) { if (err) { console.error(err); } else { // options is optional glob( route, function (err, files) { var f;...
javascript
{ "resource": "" }
q36599
hash
train
function hash(input, algo, type){ // string or buffer input ? => keep it if (typeof input !== 'string' && !(input instanceof Buffer)){ input = JSON.stringify(input); } // create hash algo var sum = _crypto.createHash(algo); // set content sum.update(input); // binary output ? ...
javascript
{ "resource": "" }