_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q43400
use
train
function use(fullQualifiedClassName) { var container = use.getContainer(fullQualifiedClassName) ; if (container._loader === null) { use.loadCount++; container._loader = Ajax.factory( "get", container._path + use.fileExtension ); container._loader.addEventListener(Ajax.Event.LOAD, function(event...
javascript
{ "resource": "" }
q43401
Client
train
function Client(endpointUrl, sourceId) { this.restClient = new restClient.Client(); this.endpointUrl = endpointUrl; if (this.endpointUrl) { // Remove the trailing slash if necessary if (this.endpointUrl.indexOf('/', this.endpointUrl.length - 1) !== -1) { this.endpointUrl = this.endpointUrl.substr(0, t...
javascript
{ "resource": "" }
q43402
processChildren
train
function processChildren(ele, children) { if (children && children.constructor === Array) { for(var i = 0; i < children.length; i++) { processChildren(ele, children[i]); } } else
javascript
{ "resource": "" }
q43403
getDrives
train
function getDrives() { return getDrivesNow().then(function(drives) { // if new drive events during scan, redo scan if (newEvents) return getDrives(); recordDrives(drives);
javascript
{ "resource": "" }
q43404
getDrivesNow
train
function getDrivesNow() { reading = true; newEvents = false; return fs.readdirAsync(drivesPath)
javascript
{ "resource": "" }
q43405
onRead
train
function onRead (key) { if (key !== null) { if (cli.debug) console.log('Key:', key) // Exits on CTRL-C if (key === '\u0003') process.exit() // If enter is pressed and the program is waiting for the user to press enter // so that the emulator can step forward, then call the appropriate callback ...
javascript
{ "resource": "" }
q43406
end
train
function end () { console.log('\n=== REG DUMP ===\n' + cpu.regdump().join('\n')) if (options.memDump) console.log('\n\n=== MEM DUMP ===\n'
javascript
{ "resource": "" }
q43407
processSimple
train
function processSimple( names, current, stopAt, collector, done ) { const name = names[current]; File.stat( Path.join( "node_modules", name, "hitchy.json" ), ( error, stat ) => { if ( error ) { if ( error.code === "ENOENT" ) { collector.push( name );
javascript
{ "resource": "" }
q43408
installMissing
train
function installMissing( error, collected ) { if ( error ) { console.error( `checking dependencies failed: ${error.message}` ); process.exit( 1 ); return; } if ( collected.length < 1 ) { postProcess( 0 ); } else { if
javascript
{ "resource": "" }
q43409
postProcess
train
function postProcess( errorCode ) { if ( errorCode ) { console.error( `running npm for installing missing dependencies ${collected.join( ", " )} exited on error (${errorCode})` ); } else if ( exec ) { const cmd = exec.join( " " ); if ( !quiet ) { console.error( `invoking follow-up command: ${cmd}` ); } ...
javascript
{ "resource": "" }
q43410
train
function (fn) { var hasOK = (typeof btnOK !== "undefined"), hasCancel = (typeof btnCancel !== "undefined"), hasInput = (typeof input !== "undefined"), val = "", self = this, ok, cancel, common, key, reset; // ok event handler ok = function (event) { ...
javascript
{ "resource": "" }
q43411
train
function (item) { var html = "", type = item.type, message = item.message, css = item.cssClass || ""; html += "<div class=\"alertify-dialog\">"; if (_alertify.buttonFocus === "none") html += "<a href=\"#\" id=\"alertify-noneFocus\" class=\"alertify-hidden\"></a>"; if...
javascript
{ "resource": "" }
q43412
train
function (elem, wait) { // Unary Plus: +"2" === 2 var timer = (wait && !isNaN(wait)) ? +wait : this.delay, self = this, hideElement, transitionDone; // set click event on log messages this.bind(elem, "click", function () { hideElement(elem); }); // Hide the dialog box afte...
javascript
{ "resource": "" }
q43413
train
function (message, type, fn, placeholder, cssClass) { // set the current active element // this allows the keyboard focus to be resetted // after the dialog box is closed elCallee = document.activeElement; // check to ensure the alertify dialog element // has been successfully created var ch...
javascript
{ "resource": "" }
q43414
train
function () { var transitionDone, self = this; // remove reference from queue queue.splice(0,1); // if items remaining in the queue if (queue.length > 0) this.setup(true); else { isopen = false; // Hide the dialog box after transition // This ensure it doens't block any el...
javascript
{ "resource": "" }
q43415
train
function () { // ensure legacy browsers support html5 tags document.createElement("nav"); document.createElement("article"); document.createElement("section"); // cover elCover = document.createElement("div"); elCover.setAttribute("id", "alertify-cover"); elCover.className = "alertify-co...
javascript
{ "resource": "" }
q43416
train
function (message, type, wait) { // check to ensure the alertify dialog element // has been successfully created var check = function () { if (elLog && elLog.scrollTop !== null) return;
javascript
{ "resource": "" }
q43417
train
function (fromQueue) { var item = queue[0], self = this, transitionDone; // dialog is open isopen = true; // Set button focus after transition transitionDone = function (event) { event.stopPropagation(); self.setFocus(); // unbind event so function only gets called on...
javascript
{ "resource": "" }
q43418
train
function (el, event, fn) { if (typeof el.removeEventListener === "function") { el.removeEventListener(event, fn, false);
javascript
{ "resource": "" }
q43419
output
train
function output(sourceCode, filePath) { return new Promise(function (resolve, reject) { mkdirp(path.dirname(filePath), function (ioErr) { if (ioErr) { reject(ioErr);
javascript
{ "resource": "" }
q43420
ValueTemplate
train
function ValueTemplate(type, defaultValue, validator){
javascript
{ "resource": "" }
q43421
PropertyTemplate
train
function PropertyTemplate(name, required, nullable, template){ this.name = name; this.required = required;
javascript
{ "resource": "" }
q43422
getByFirstImage
train
function getByFirstImage(file, attributes) { var $ = cheerio.load(file.contents.toString()), img = $('img').first(), obj = {}; if (img.length) { _.forEach(attributes, function(attribute) {
javascript
{ "resource": "" }
q43423
train
function ( name, socket ) { var self = this; // check input if ( name && socket ) { log('ws', 'init', name, 'connection'); // main data structure pool[name] = { socket: socket, time: +new Date(), count: 0, active: true }; // disable link on close pool[name].socket.on('close', ...
javascript
{ "resource": "" }
q43424
train
function ( name ) { // valid connection if ( name in pool ) { log('ws', 'exit', name, 'close');
javascript
{ "resource": "" }
q43425
train
function ( name ) { // valid connection if ( name in pool ) { return { active: pool[name].active,
javascript
{ "resource": "" }
q43426
train
function ( name, data, response ) { log('ws', 'send', name, data); // store link to talk back when ready pool[name].response = response;
javascript
{ "resource": "" }
q43427
train
function(req, res) { if (res.locals.success) { options.success(model, response); } else {
javascript
{ "resource": "" }
q43428
train
function(s){ var currentState = history[historyIndex]; if(typeof s === 'function'){ s = s( history[historyIndex].toJS() );
javascript
{ "resource": "" }
q43429
train
function( name ) { var type = _.reduce( name.split('.'), function( memo,
javascript
{ "resource": "" }
q43430
train
function( model ) { var coll = this.getCollection( model );
javascript
{ "resource": "" }
q43431
train
function() { Backbone.Relational.store.getCollection( this.instance ) .unbind( 'relational:remove', this._modelRemovedFromCollection ); Backbone.Relational.store.getCollection( this.relatedModel
javascript
{ "resource": "" }
q43432
proxyVerifyCallback
train
function proxyVerifyCallback (fn, args, done) { const {callback, index} = findCallback(args); args[index] = function (err, user) {
javascript
{ "resource": "" }
q43433
SetOrGet
train
function SetOrGet(input, field, def)
javascript
{ "resource": "" }
q43434
proxyEvent
train
function proxyEvent (emitter, event, optionalCallback) { emitter.on(event, function () { if (optionalCallback) {
javascript
{ "resource": "" }
q43435
train
function(parent, app) { this.use(middleware.sanitizeHost(app)); this.use(middleware.bodyParser());
javascript
{ "resource": "" }
q43436
Scope
train
function Scope(site, page, params) { this.site = site this.page = page this.params = params || {} this.status = 200 this._headers = {} this.locale = site.locales.default //
javascript
{ "resource": "" }
q43437
train
function( option ) { if ( this._self === option.exporter ) { return; } if ( this._action && !this._action.test( option.action ) ) { return; } if ( this._path && !this._path.test( option.path ) ) { return; ...
javascript
{ "resource": "" }
q43438
glupost
train
function glupost(configuration) { const tasks = configuration.tasks || {} const template = configuration.template || {} // Expand template object with defaults. expand(template, { transforms: [], dest: "." }) // Create tasks. const names = Object.keys(tasks) for (const name of names) { co...
javascript
{ "resource": "" }
q43439
compose
train
function compose(task) { // Already composed action. if (task.action) return task.action // 1. named task. if (typeof task === "string") return task // 2. a function directly. if (typeof task === "function") return task.length ? task : () => Promise.resolve(task()) // 3. task ...
javascript
{ "resource": "" }
q43440
pipify
train
function pipify(task) { const options = task.base ? { base: task.base } : {} let stream = gulp.src(task.src, options) // This is used to abort any further transforms in case of error. const state = { error: false } for (const transform of task.transforms)
javascript
{ "resource": "" }
q43441
pluginate
train
function pluginate(transform, state) { return through.obj((file, encoding, done) => { // Nothing to transform. if (file.isNull() || state.error) { done(null, file) return } // Transform function returns a vinyl file or file contents (in form of a // stream, a buffer...
javascript
{ "resource": "" }
q43442
watch
train
function watch(tasks) { if (tasks["watch"]) { console.warn("`watch` task redefined.") return } const names = Object.keys(tasks).filter((name) => tasks[name].watch) if (!names.length) return gulp.task("watch", () => { for (const name of names) {
javascript
{ "resource": "" }
q43443
expand
train
function expand(to, from) { const keys = Object.keys(from) for (const key of keys) {
javascript
{ "resource": "" }
q43444
HostMapping
train
function HostMapping(settings) { settings.init("hostConfig", {}); settings.init("hostMapping", {});
javascript
{ "resource": "" }
q43445
decorateWithCollation
train
function decorateWithCollation(command, target, options) { const topology = target.s && target.s.topology; if (!topology) { throw new TypeError('parameter "target" is missing a topology'); } const capabilities = target.s.topology.capabilities(); if (options.collation && typeof options.collation === 'obj...
javascript
{ "resource": "" }
q43446
train
function(fn) { // Save off the existing spy method as __functionName var newName = '__' + fn; self[newName] = self[fn]; // This is the actual function that will be called when, // for example, calledWith() is invoked
javascript
{ "resource": "" }
q43447
train
function (decorator, txt) { var decostr = "@" + decorator; var r = txt .replace(decostr, "") .trim() ; if
javascript
{ "resource": "" }
q43448
extractDecorator2
train
function extractDecorator2(text) { try { var email = text.match(reSTCDeco); // console.log("DEBUG: reSTCDeco:" + email); var deco = email[0].split('@')[1]; return deco; } catch (error) {
javascript
{ "resource": "" }
q43449
train
function (err, req, res, next) { if (seminarjs.get('logger')) { if (err instanceof Error) { console.log((err.type ? err.type + ' ' : '') + 'Error thrown for request: ' + req.url); } else { console.log('Error thrown for request: ' + req.url); } console.log(err.stack || err); } var ms...
javascript
{ "resource": "" }
q43450
Mutant
train
function Mutant(obj) { var triggered, i = 0; mutations = {}; if (!obj.addEventListener) { obj = EventTarget(obj); } function trigger() { i++; if (triggered) return; triggered = setTimeout(function() { var evt = new Mutat...
javascript
{ "resource": "" }
q43451
mutant
train
function mutant(obj) { if (!proxies.has(obj)) { proxies.set(obj, Mutant(obj));
javascript
{ "resource": "" }
q43452
ask
train
function ask(question, validValues, message) { readline.setDefaultOptions({ limit: validValues,
javascript
{ "resource": "" }
q43453
color
train
function color(c, bold, msg) { return bold ?
javascript
{ "resource": "" }
q43454
renderState
train
function renderState(env, stateDir, nav, componentData, state) { const statePath = Path.join(stateDir, 'index.html'); const raw = env.render('component-raw.html', { navigation: nav, component: componentData, state: state,
javascript
{ "resource": "" }
q43455
renderDocs
train
function renderDocs(SITE_DIR, name) { const env = templates.configure(); const nav = navigation.getNavigation(); const components = _.find(nav.children, { id: name }); components.children.forEach(component => { const dirPath = Path.join(SITE_DIR, component.path); console.log(dirPath); ...
javascript
{ "resource": "" }
q43456
train
function( string ) { var negated, matches, patterns = this.patterns, i = patterns.length; while ( i-- ) { negated = patterns[ i ].negated; matches = patterns[ i ].matcher( string
javascript
{ "resource": "" }
q43457
find
train
function find(param) { var fn, asInt = parseInt(param,
javascript
{ "resource": "" }
q43458
findByCredentials
train
function findByCredentials(username, password, cb) { crypto.encode(password, function(err, encoded) { if(err) { return cb(err); } db.getClient(function(err, client, done) { client.query(SELECT_CREDENTIALS, [username, encoded],
javascript
{ "resource": "" }
q43459
findByUsername
train
function findByUsername(username, cb) { db.getClient(function(err, client, done) { client.query(SELECT_USERNAME, [username], function(err, r) {
javascript
{ "resource": "" }
q43460
update
train
function update(id, body, cb) { if(body.password) { crypto.encode(body.password, function(err, encoded) { if(err) { return cb(err); }
javascript
{ "resource": "" }
q43461
createPlaceHolder
train
function createPlaceHolder($page, type) { var placeHolders = { kittens : 'placekitten.com', bears: 'placebear.com', lorem: 'lorempixel.com', bacon: 'baconmockup.com', murray: 'www.fillmurray.com'}; var gallery = ''; for (var i = 0; i < getRandomInt(50,100); i++) { gallery...
javascript
{ "resource": "" }
q43462
addToJSONRecursively
train
function addToJSONRecursively(contextNames, data, obj) { var currentContexName = contextNames.shift(); // last name if (!contextNames.length) { obj[currentContexName] = data; return;
javascript
{ "resource": "" }
q43463
propertyToString
train
function propertyToString(property) { return property.comment + utils.addQuotes(property.name.split('.').pop()) + ': ' + ( typeof options.sourceProcessor === 'function' ?
javascript
{ "resource": "" }
q43464
stringifyJSONProperties
train
function stringifyJSONProperties(obj) { var i, properties = []; for (i in obj) { properties.push( typeof obj[i] === 'string' ? obj[i] :
javascript
{ "resource": "" }
q43465
addPropertiesToText
train
function addPropertiesToText(text, properties, filePath) { if (!properties.length) { return text; } var placeRegexp = patterns.getPlacePattern(properties[0].isFromPrototype), matchedData = placeRegexp.exec(text); // Can`t find properties place if (!matc...
javascript
{ "resource": "" }
q43466
areArrays
train
function areArrays () { for (let i = 0; i < arguments.length; i++) { if (!Array.isArray(arguments[i])) {
javascript
{ "resource": "" }
q43467
deepDiff
train
function deepDiff(obj1, obj2, path) { return merge_1(_deepDiff(obj1, obj2,
javascript
{ "resource": "" }
q43468
checkFunctions
train
function checkFunctions (impl, schema) { const children = schema.describe().children const ret = { ok: true } for (let i in children) { if (impl.hasOwnProperty(i) && children.hasOwnProperty(i)) { if (children[ i ].flags && children[ i ].flags.func === true) { const func = impl[ i ] const...
javascript
{ "resource": "" }
q43469
_dot_inner
train
function _dot_inner(elem, make_digraph, names) { var builder = []; var name = hash_name_get(elem, names); // Only push graphs/clusters for chains if (elem instanceof fl.ChainBase) { if (make_digraph) builder.push('digraph '+name+' {'); else builder.push('subgraph cluster_'+name+' {'); builder....
javascript
{ "resource": "" }
q43470
get_chain_content
train
function get_chain_content(elem, names) { if (elem instanceof fl.Branch) { return handle_branch(elem, names); } else if (elem instanceof fl.ParallelChain) { return handle_parallel(elem, names); } else if (elem instanceof fl.LoopChain) { return handle_loop(elem, names); } else if (elem instanceof ...
javascript
{ "resource": "" }
q43471
handle_branch
train
function handle_branch(elem, names) { var cond = _dot_inner(elem.cond.fn, false, names); var if_true = _dot_inner(elem.if_true.fn, false, names); var if_false = _dot_inner(elem.if_false.fn, false, names); var terminator = hash_name_get({name : 'branch_end'}, names); var builder = []; Array.prototype.push.a...
javascript
{ "resource": "" }
q43472
handle_parallel
train
function handle_parallel(elem, names) { var phead = hash_name_get({name : 'parallel_head'}, names); var ptail = hash_name_get({name : 'parallel_tail'}, names); var node; var builder = []; for (var i = 0; i < elem.fns.length; ++i) { node = _dot_inner(elem.fns[i].fn, false, names); Array.prototype.push.a...
javascript
{ "resource": "" }
q43473
handle_loop
train
function handle_loop(elem, names) { var cond = _dot_inner(elem.cond.fn, false, names); var node1 = _dot_inner(elem.fns[0].fn, false, names); var builder = []; var node2 = node1; Array.prototype.push.apply(builder, cond[0]); Array.prototype.push.apply(builder, node1[0]);
javascript
{ "resource": "" }
q43474
handle_chain
train
function handle_chain(elem, names) { // Make sure the chain does something if (elem.fns.length === 0) { return [[], hash_name_get({name : '__empty__'}), hash_name_get({name : '__empty__'})]; } var builder = []; var node1 = _dot_inner(elem.fns[0].fn, false, names);
javascript
{ "resource": "" }
q43475
hash_name_get
train
function hash_name_get(elem, names) { var fname; if (elem.fn !== undefined) fname = format_name(helpers.fname(elem, elem.fn.name)); else fname = format_name(elem.name); var list = names[fname]; // First unique instance of a function gets to use its proper name if (list === undefined) { names[fname...
javascript
{ "resource": "" }
q43476
polylock
train
function polylock (params) { if (params === undefined) params = {}; this.queue = new polylock_ll(); this.ex_locks = {}; this.ex_reserved = {}; this.sh_locks
javascript
{ "resource": "" }
q43477
train
function (editor, message, callback) { var rng = editor.selection.getRng(); Delay.setEditorTimeout(editor, function () { editor.windowManager.confirm(message, function (state) {
javascript
{ "resource": "" }
q43478
gruntYakTask
train
function gruntYakTask(grunt) { 'use strict'; /** * @type {!Array<string>} */ let filesToUpload = []; /** * @type {RequestSender} */ let requestSender; /** * Register task for grunt. */ grunt.registerMultiTask('yakjs', 'A grunt task to update the YAKjs via res...
javascript
{ "resource": "" }
q43479
request
train
function request (reqOptions, data) { const t = require('typical') if (!reqOptions) return Promise.reject(Error('need a URL or request options object')) if (t.isString(reqOptions)) { const urlUtils = require('url') reqOptions = urlUtils.parse(reqOptions) } else { reqOptions = Object.assign({ headers...
javascript
{ "resource": "" }
q43480
Loader
train
function Loader(loadItem) { this.AbstractLoader_constructor(loadItem, true, createjs.AbstractLoader.SOUND); /** * A Media object used to determine if src exists and to get duration * @property _media * @type {Media} * @protected */ this._media = null; /** * A time counter that triggers timeo...
javascript
{ "resource": "" }
q43481
train
function (f) { var separator , temp = []; [ '/', '-', ' '].forEach(function(sep) { if (temp.length < 2) { separator = sep;
javascript
{ "resource": "" }
q43482
train
function(username, password) { var restler_defaults = { baseURL: config.baseUrl };
javascript
{ "resource": "" }
q43483
get_id
train
function get_id(val) { if ( typeof val === 'string' || typeof val === 'number' )
javascript
{ "resource": "" }
q43484
default_init
train
function default_init(user, password) { this.defaults.username = user; this.defaults.password = password; this.defaults.headers = {
javascript
{ "resource": "" }
q43485
LocalEnvironment
train
function LocalEnvironment(env, id) { Environment.call(this,
javascript
{ "resource": "" }
q43486
StateManager
train
function StateManager(options) { // Initial state is pending this.state = states.pending; // If a state is passed in, then we go ahead and initialize the state manager with it if (options
javascript
{ "resource": "" }
q43487
startDomAnimate
train
function startDomAnimate(selector, animationProps, interval, onDone){ let numberIndex = 0 const numbersLength = animationProps[0].numbers.length this.isDomRunning = true const tick = setInterval(() => { animationProps.forEach(prop => { setStyle(selector, prop.attr, prop.numbers[numberIndex],
javascript
{ "resource": "" }
q43488
encryptPassword
train
function encryptPassword(password, callback) { bcrypt.gen_salt(workFactor, function(err, salt) { if (err) callback(err); bcrypt.encrypt(password, salt, function(err, hashedPassword) {
javascript
{ "resource": "" }
q43489
ls
train
function ls (dir, cb) { if(!cb) cb = dir, dir = null dir = dir || process.cwd() pull( pfs.ancestors(dir), pfs.resolve('node_modules'), pfs.star(), pull.filter(Boolean), paramap(maybe(readPackage)), filter(), pull.unique('name'),
javascript
{ "resource": "" }
q43490
tree
train
function tree (dir, opts, cb) { var i = 0 findPackage(dir, function (err, pkg) { pull( pull.depthFirst(pkg, function (pkg) { pkg.tree = {} return pull( pfs.readdir(path.resolve(pkg.path, 'node_modules')), paramap(maybe(readPackage)), pull.filter(function (_pkg...
javascript
{ "resource": "" }
q43491
train
function () { var args = arguments, argc = arguments.length; if (argc === 1) { if (args[0] === undefined || args[0] === null) { return undefined; } return args[0]; } else if (argc === 2) { ...
javascript
{ "resource": "" }
q43492
train
function (variable, isRecursive) { var property, result = 0; isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false; if (variable === false || variable === null || typeof variable === "undefined" ) { ...
javascript
{ "resource": "" }
q43493
train
function (needle, haystack, strict) { var found = false; strict = !!strict; $this.each(haystack, function (key) { /* jshint -W116 */ if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
javascript
{ "resource": "" }
q43494
train
function (value, precision, mode) { /* jshint -W016 */ /* jshint -W018 */ // Helper variables var base, floorNum, isHalf, sign; // Making sure precision is integer precision |= 0; base = Math.pow(10, precision); value *= b...
javascript
{ "resource": "" }
q43495
train
function (glue, pieces) { var retVal = "", tGlue = ""; if (arguments.length === 1) { pieces = glue; glue = ""; } if (typeof pieces === "object") { if ($this.type(pieces) === "array") { ...
javascript
{ "resource": "" }
q43496
train
function (delimiter, string, limit) { if (arguments.length < 2 || typeof delimiter === "undefined" || typeof string === "undefined" ) { return null; } if (delimiter === "" || delimiter === false || ...
javascript
{ "resource": "" }
q43497
authDetectionMiddleware
train
function authDetectionMiddleware(req, res, next) { logger.debug('Running Auth Detection Middleware...', req.body); if (req.headers['token']) { try { req.user = encryption.decode(req.headers['token'], config.secret); req.session = { user: req.user }; } catch (ex) { logger.log...
javascript
{ "resource": "" }
q43498
createStorage
train
function createStorage(defaults, queue, unqueue, log) { if (typeof defaults !== "object") { log = unqueue; unqueue = queue; queue = defaults; defaults = {}; } /** * @constructor * @param {object} [opts] */ function Storage(opts) { mixin(mixin(this,...
javascript
{ "resource": "" }
q43499
train
function(callback) { var self = this; this.beet.client.getAllProcessInfo(function(err, processes) { if(processes) for(var i = processes.length; i--;) { var proc = processes[i], nameParts = proc.name.split('_'); if(namePa...
javascript
{ "resource": "" }