_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | 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 if (children instanceof Node) {
ele.appendChild(children);
} else if (children) {
ele.appendChild(document.create... | 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);
if (self.options.scanInterval) self.scanTimer = setTimeout(updateDrives, self.options.scanI... | javascript | {
"resource": ""
} |
q43404 | getDrivesNow | train | function getDrivesNow() {
reading = true;
newEvents = false;
return fs.readdirAsync(drivesPath)
.then(function(files) {
var drives = files.filter(function(name) {
return name != '.DS_Store';
});
return drives;
});
} | 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' + cpu.memdump(0, 65535).join('\n'))
process.exit() // workaround for stdin event listener hanging
} | 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 );
} else {
done( error );
return;
}
} else ... | 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 ( !quiet ) {
console.error( `installing missing dependencies:\n${collected.map( d =>... | 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;
else check();
};
// initialize alertify if it hasn't already been done
if (typeof this.init === "fun... | 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);
} else if (el.detachEvent) {
el.detachEvent("on" + event, fn);
}
} | 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);
throw ioErr;
}
fs.writeFile(filePath, sourceCode, function (writeErr) {
... | javascript | {
"resource": ""
} |
q43420 | ValueTemplate | train | function ValueTemplate(type, defaultValue, validator){
this.type = type;
this.defaultValue = defaultValue;
this.validator = validator;
} | javascript | {
"resource": ""
} |
q43421 | PropertyTemplate | train | function PropertyTemplate(name, required, nullable, template){
this.name = name;
this.required = required;
this.nullable = nullable;
this.template = template;
} | 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) {
obj[attribute] = img.attr(attribute);
});
return obj;
} else {
return undefined;
}
} | 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');
return delete pool[name];
}
// failure
log('ws', 'del', name, 'fail to remove (invalid connection)');
return false;
} | javascript | {
"resource": ""
} | |
q43425 | train | function ( name ) {
// valid connection
if ( name in pool ) {
return {
active: pool[name].active,
count: pool[name].count
};
}
// failure
return {active: false};
} | javascript | {
"resource": ""
} | |
q43426 | train | function ( name, data, response ) {
log('ws', 'send', name, data);
// store link to talk back when ready
pool[name].response = response;
// actual post
pool[name].socket.send(data);
pool[name].count++;
} | javascript | {
"resource": ""
} | |
q43427 | train | function(req, res) {
if (res.locals.success) {
options.success(model, response);
} else {
options.error(model, response);
}
} | javascript | {
"resource": ""
} | |
q43428 | train | function(s){
var currentState = history[historyIndex];
if(typeof s === 'function'){
s = s( history[historyIndex].toJS() );
}
var newState = currentState.merge(s);
history = history.slice(0,historyIndex + 1);
history.push(newState);
historyIndex++;
return new Immu... | javascript | {
"resource": ""
} | |
q43429 | train | function( name ) {
var type = _.reduce( name.split('.'), function( memo, val ) {
return memo[ val ];
}, exports);
return type !== exports ? type: null;
} | javascript | {
"resource": ""
} | |
q43430 | train | function( model ) {
var coll = this.getCollection( model );
coll._onModelEvent( 'change:' + model.idAttribute, model, coll );
} | javascript | {
"resource": ""
} | |
q43431 | train | function() {
Backbone.Relational.store.getCollection( this.instance )
.unbind( 'relational:remove', this._modelRemovedFromCollection );
Backbone.Relational.store.getCollection( this.relatedModel )
.unbind( 'relational:add', this._relatedModelAdded )
.unbind( 'relational:remove', this._relatedModel... | javascript | {
"resource": ""
} | |
q43432 | proxyVerifyCallback | train | function proxyVerifyCallback (fn, args, done) {
const {callback, index} = findCallback(args);
args[index] = function (err, user) {
done(err, user, callback);
};
fn.apply(null, args);
} | javascript | {
"resource": ""
} |
q43433 | SetOrGet | train | function SetOrGet(input, field, def) {
return input[field] = Deffy(input[field], def);
} | javascript | {
"resource": ""
} |
q43434 | proxyEvent | train | function proxyEvent (emitter, event, optionalCallback) {
emitter.on(event, function () {
if (optionalCallback) {
optionalCallback.apply(client, arguments)
}
client.emit(event)
})
} | javascript | {
"resource": ""
} |
q43435 | train | function(parent, app) {
this.use(middleware.sanitizeHost(app));
this.use(middleware.bodyParser());
this.use(middleware.cookieParser());
this.use(middleware.fragmentRedirect());
} | 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
// Set default headers.
this.header("Content-Type", "text/html; charset=utf-8")
this.header("Connection", "close")
this.header("Server", "S... | 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)
stream = stream.pipe(transform.pipe ? t... | 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) {
const glob = tasks[name... | javascript | {
"resource": ""
} |
q43443 | expand | train | function expand(to, from) {
const keys = Object.keys(from)
for (const key of keys) {
if (!to.hasOwnProperty(key))
to[key] = from[key]
}
} | javascript | {
"resource": ""
} |
q43444 | HostMapping | train | function HostMapping(settings) {
settings.init("hostConfig", {});
settings.init("hostMapping", {});
settings.init("xdmConfig", {});
this.settings = settings;
} | 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
return function() {
var func = self[newName]... | javascript | {
"resource": ""
} | |
q43447 | train | function (decorator, txt) {
var decostr = "@" + decorator;
var r = txt
.replace(decostr, "")
.trim()
;
if (debug) console.log(`Cleaning deco: ${decorator} in ${txt}
Result: ${r}
`);
return r;
} | 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) {
return "";
}
// return text.match(/([a-zA-Z0-9._-]+@... | 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));
}
return proxies.get(obj);
} | javascript | {
"resource": ""
} |
q43452 | ask | train | function ask(question, validValues, message) {
readline.setDefaultOptions({
limit: validValues,
limitMessage: message
});
return readline.question(question);
} | javascript | {
"resource": ""
} |
q43453 | color | train | function color(c, bold, msg) {
return bold ? clic.xterm(c).bold(msg) : clic.xterm(c)(msg);
} | 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,
config: config,
tokens: getTokens(),
});
... | 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 );
if ( negated !== matches ) {
return matches;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q43457 | find | train | function find(param) {
var fn, asInt = parseInt(param, 10);
fn = isNaN(asInt) ? findByUsername : findById;
fn.apply(null, arguments);
} | 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], function(err, r) {
var result = r && r.rows[0];
if(!err && !... | javascript | {
"resource": ""
} |
q43459 | findByUsername | train | function findByUsername(username, cb) {
db.getClient(function(err, client, done) {
client.query(SELECT_USERNAME, [username], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) { err = new exceptions.NotFound(); }
if(err) {
cb(err);
done(err);
} else {
... | 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); }
body.password = encoded;
_update(id, body, cb);
});
} else {
_update(id, body, cb);
}
} | 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;
}
if (!obj[currentContexName]) {
obj[currentContexName] = {... | javascript | {
"resource": ""
} |
q43463 | propertyToString | train | function propertyToString(property) {
return property.comment +
utils.addQuotes(property.name.split('.').pop()) +
': ' +
(
typeof options.sourceProcessor === 'function' ?
options.sourceProcessor(property.source, property) :
... | javascript | {
"resource": ""
} |
q43464 | stringifyJSONProperties | train | function stringifyJSONProperties(obj) {
var i,
properties = [];
for (i in obj) {
properties.push(
typeof obj[i] === 'string' ?
obj[i] :
utils.addQuotes(i) + ': ' + stringifyJSONProperties(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])) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q43467 | deepDiff | train | function deepDiff(obj1, obj2, path) {
return merge_1(_deepDiff(obj1, obj2, path), _deepDiff(obj2, obj1, path));
} | 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]);
builder.push(cond[2]+' [shape=Mdia... | 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);
var first = node1;
var node2;
for ... | 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 = {};
this.op_num = 1;
this.drain_for_writes = params.write_priority ? true : false;
} | javascript | {
"resource": ""
} |
q43477 | train | function (editor, message, callback) {
var rng = editor.selection.getRng();
Delay.setEditorTimeout(editor, function () {
editor.windowManager.confirm(message, function (state) {
editor.selection.setRng(rng);
callback(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;
temp = f.split(separator);
}
});
return separator;
} | javascript | {
"resource": ""
} | |
q43482 | train | function(username, password) {
var restler_defaults = { baseURL: config.baseUrl };
var RestlerService = restler.service(default_init, restler_defaults, api);
return new RestlerService(username, password);
} | javascript | {
"resource": ""
} | |
q43483 | get_id | train | function get_id(val) {
if ( typeof val === 'string' || typeof val === 'number' )
return val;
if ( typeof val === 'object' && val.id )
return val.id;
return false;
} | javascript | {
"resource": ""
} |
q43484 | default_init | train | function default_init(user, password) {
this.defaults.username = user;
this.defaults.password = password;
this.defaults.headers = {
Accept: 'application/json'
};
this.defaults.headers['Content-Type'] = 'application/json';
} | javascript | {
"resource": ""
} |
q43485 | LocalEnvironment | train | function LocalEnvironment(env, id) {
Environment.call(this, {}, env._fm.$log);
this._env = env;
this._thread_id = id;
} | 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 && options.state) {
this.transition(options.state, options.value, options.context);
}
} | 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], prop.unit... | 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) {
if (err) callback(err);
callback(null, has... | 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'),
pull.reduce(function (obj, val) {
if(!obj[val... | 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)) {
found = true... | 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": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.