_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q37600 | unwrap | train | function unwrap() {
var nodes = Array.prototype.slice.call(el.childNodes),
wrapper = void 0;
nodes.forEach(function (node) {
wrapper = node.parentNode;
dom(node).insertBefore(node.parentNode);
dom(wrapper).r... | javascript | {
"resource": ""
} |
q37601 | parents | train | function parents() {
var parent = void 0,
path = [];
while (!!(parent = el.parentNode)) {
path.push(parent);
el = parent;
}
return path;
} | javascript | {
"resource": ""
} |
q37602 | fromHTML | train | function fromHTML(html) {
var div = document.createElement('div');
div.innerHTML = html;
return div.childNodes;
} | javascript | {
"resource": ""
} |
q37603 | processCommandLine | train | function processCommandLine() {
if (commander.list) {
listApps();
process.exit(0);
}
if (!commander.app) {
commander.help();
}
commander.endDate = commander.runDate ? moment(commander.runDate, 'MM/DD/YYYY').toDate() : new Date();
comm... | javascript | {
"resource": ""
} |
q37604 | run | train | function run() {
var startTime = (new Date()).getTime();
// parse the command line using the commander object
processCommandLine();
// leverage the middleware to initialize all our services, adapters, etc. (i.e. connect to mongo, etc.)
mwServiceInit.init({ container: 'batch' })... | javascript | {
"resource": ""
} |
q37605 | supersede | train | function supersede(target, source, force, deepStringMixin) {
if (source) {
eachProp(source, function (value, prop) {
if (hasProp(target, prop)) {
if (deepStringMixin && typeof value === 'object' && value && !isArray(value) && !isFunction(value) && !(value instanceof RegExp)) {
... | javascript | {
"resource": ""
} |
q37606 | create | train | function create(type, def, base) {
// empty constructor
type.prototype = base ? typeof base === 'function' ? new base() : base : new Class(); // set base object as prototype
return apply(new type(), def); // return empty object with right [[Prototype]]
} | javascript | {
"resource": ""
} |
q37607 | define | train | function define(type, baseClass, members, statics) {
// empty constructor
type.prototype = baseClass ? typeof baseClass === "function" ? new baseClass() : baseClass : new Class(); // set base object as prototype
type.prototype.constructor = type;
type.prototype = apply(type.prototype, members || {});
... | javascript | {
"resource": ""
} |
q37608 | inherits | train | function inherits(constructor, superConstructor) {
constructor.prototype = Object.create(superConstructor.prototype, {
constructor: {
value: constructor
}
});
return constructor;
} | javascript | {
"resource": ""
} |
q37609 | typeOf | train | function typeOf(value) {
var returned = Object.prototype.toString.call(value);
return returned.substring(1, returned.length - 1).split(' ')[1].toLowerCase();
} | javascript | {
"resource": ""
} |
q37610 | add | train | function add(err, req, res) {
if(err) {
// TODO: send args length errors
// transaction errors are not queued
// but the transaction is left open for more
// command to be queued
if(err instanceof TransactionError) {
return res.send(err);
}
// last error
this.error = err;
}
... | javascript | {
"resource": ""
} |
q37611 | exec | train | function exec(scope, req, res) {
var replies = [], item;
// NOTE: incrby invalid amount will trigger EXECABORT
// NOTE: wrong number of args are returned to the client
// NOTE: but other types of validation errors (argument type coercion)
// NOTE: trigger EXECABORT
if(this.error) return this.destroy(req, ... | javascript | {
"resource": ""
} |
q37612 | destroy | train | function destroy(req, res, err, reply) {
req.conn.transaction = null;
req.conn.unwatch(req.db);
this.queue = null;
this.error = null;
res.send(err, reply);
} | javascript | {
"resource": ""
} |
q37613 | format | train | function format(fn) {
return function(chunk) {
if (arguments.length > 1) {
chunk = util.format.apply(null, arguments);
}
if (chunk === undefined) {
chunk = '';
}
fn.call(this, chunk);
};
} | javascript | {
"resource": ""
} |
q37614 | getDistanceInKilometers | train | function getDistanceInKilometers(p1, p2) {
// Credit: adapts code for Haversine formula and degrees-to-radian conversion found at:
// http://www.movable-type.co.uk/scripts/latlong.html
var R = 6371; // earth's radius in kilometers
var dLat = degreesToRadians(p2.lat - p1.lat);
var dLon = degreesToRadians(p2.l... | javascript | {
"resource": ""
} |
q37615 | parseGoogleGeocodes | train | function parseGoogleGeocodes(response) {
// the result has a results property that is an array
// there may be more than one result when the address is ambiguous
// for pragmatic reasons, only use the first result
// if the result does not have a zip code, then assume the user
// did not provide a valid addre... | javascript | {
"resource": ""
} |
q37616 | findAddressComponent | train | function findAddressComponent(components, type) {
for (var i = 0; i < components.length; i++) {
if (components[i].types.indexOf(type) > -1) {
return components[i];
}
}
return null;
} | javascript | {
"resource": ""
} |
q37617 | ToDate | train | function ToDate(amount, unit, method) {
this.amount = amount;
this.method = method;
this.unit = unit;
} | javascript | {
"resource": ""
} |
q37618 | train | function() {
var time = null;
if (this.method === 'from now') {
time = ago.fromNow(this.amount, this.unit);
} else if (this.method === 'ago') {
time = ago(this.amount, this.unit);
} else {
throw new Error('Invalid method: ' + this.method);
}
return new Date(time);
} | javascript | {
"resource": ""
} | |
q37619 | encode | train | function encode(number) {
if (number === 0) {
return '';
}
var quotient = Math.floor(number / 64);
var remainder = number % 64;
var digit;
if (remainder < 10) {
digit = '' + remainder;
}
else if (remainder < 36) {
digi... | javascript | {
"resource": ""
} |
q37620 | decode | train | function decode(base64string) {
var number = 0;
var chars = base64string.split('');
var len = chars.length;
var val10;
var val64;
var asciiVal;
for (var i = 0; i < len; i++) {
val64 = chars[len - 1 - i];
asciiVal = val64.charCodeAt(0);
... | javascript | {
"resource": ""
} |
q37621 | httpNotFound | train | function httpNotFound(req, res) {
console.log(`No request handler found for ${req.url}`);
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.write('404 Not found');
res.end();
} | javascript | {
"resource": ""
} |
q37622 | httpInternalError | train | function httpInternalError(req, res, err) {
console.error(err);
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.write(`Error 500 Internal server error: ${err}`);
res.end();
} | javascript | {
"resource": ""
} |
q37623 | httpOk | train | function httpOk(req, res, content, fileExt) {
res.writeHead(200, {
'Content-Type': Mine.getType(fileExt),
});
res.write(content, 'binary');
res.end();
} | javascript | {
"resource": ""
} |
q37624 | routine | train | function routine (fn, sets, context) {
const master = []
if (typeof context === 'undefined') {
context = fn
}
for (const args of sets) {
master.push(fn.apply(context, Array.isArray(args) ? args : [args]))
}
return Promise.all(master)
} | javascript | {
"resource": ""
} |
q37625 | run | train | async function run(command) {
if (!Array.isArray(command) && typeof command === "string") command = command.split(' ');
else throw new Error("command is either a string or a string array");
let c = command.shift();
let v = command;
let env = process.env;
env.BROWSERSLIST_CONFIG= "./config/.brow... | javascript | {
"resource": ""
} |
q37626 | _extractRealFiles | train | function _extractRealFiles (dir, givenFiles, realFiles, callback) {
if (0 >= givenFiles.length) {
return callback(null, realFiles);
}
else {
const file = join(dir, givenFiles.shift()).trim();
return isFileProm(file).then((exists) => {
if (exists) {
realFiles.push(file);
}
... | javascript | {
"resource": ""
} |
q37627 | respondText | train | function respondText(res, code, text) {
res.statusCode = code;
res.setHeader('Content-Type', 'text/plain');
return res.end(text.toString());
} | javascript | {
"resource": ""
} |
q37628 | train | function(){
var string = '\t\t\t',
path = info.path.replace(baseDir, '').split('/');
if(path.length > 1){
for(var i=0;i<path.length;i++){
string = string + '\t';
}
}
... | javascript | {
"resource": ""
} | |
q37629 | splice | train | function splice(array, criteria, tieBreakers) {
if (!criteria) { criteria = returnFalse; }
var matcher = anymatch(criteria);
var matched = array.filter(matcher);
var unmatched = array.filter(function(s) {
return matched.indexOf(s) === -1;
}).sort();
if (!Array.isArray(criteria)) { criteria = [criteria];... | javascript | {
"resource": ""
} |
q37630 | grouped | train | function grouped(array, groups, order) {
if (!groups) { groups = [returnFalse]; }
var sorted = [];
var ordered = [];
var remaining = array.slice();
var unmatchedPosition = groups.indexOf('unmatched');
groups.forEach(function(criteria, index) {
if (index === unmatchedPosition) { return; }
var tieBrea... | javascript | {
"resource": ""
} |
q37631 | Tab | train | function Tab (options) {
this.options = options || {}
this.master = null
this.header = document.createElement('li')
this.header.onclick = function () {
this.toggle()
}.bind(this)
this.content = document.createElement('div')
this.content.className = 'tabs-section'
} | javascript | {
"resource": ""
} |
q37632 | quadratic2cubicBezier | train | function quadratic2cubicBezier (a, b) {
return [
[
(a / 3 + (a + b) / 3 - a) / (b - a),
(a * a / 3 + a * b * 2 / 3 - a * a) / (b * b - a * a)
], [
(b / 3 + (a + b) / 3 - a) / (b - a),
(b * b / 3 + a * b * 2 / 3 - a * a) / (b * b - a * a)
]
]
} | javascript | {
"resource": ""
} |
q37633 | distAddon | train | function distAddon(opts, cb) {
// sign our add-on
const generatedXpi = 'addon.xpi';
signAddon(generatedXpi, opts.apiKey, opts.apiSecret, function(err, signedXpiPath) {
if (err) return cb(err);
// remove our generated xpi since we now have a signed version
removeGeneratedXpi();
// move our signed x... | javascript | {
"resource": ""
} |
q37634 | train | function(coll, callback){
// Switch databases
var collection = self.db.collection(coll.name);
// Get the stats. null if empty.
collection.stats(function(err, stats){
// Add the stats to the corresponding database.
coll.stats = stats;
callback(err, coll);
});
} | javascript | {
"resource": ""
} | |
q37635 | train | function(data, params, callback) {
if (!data.name) {
return callback({error:'name is required'});
}
this.db.createCollection(data.name, {}, function(err, collection){
var response = {
name:collection.collectionName,
_id:collection.collectionName
};
return callback(null, response)... | javascript | {
"resource": ""
} | |
q37636 | GameObject | train | function GameObject(useRectTransform) {
if (useRectTransform === void 0) { useRectTransform = false; }
_super.call(this);
this._UID = WOZLLA.utils.IdentifyUtils.genUID();
this._active = true;
this._visible = true;
this._initialized = false;
... | javascript | {
"resource": ""
} |
q37637 | Sprite | train | function Sprite(spriteAtlas, frame, name) {
this._spriteAtlas = spriteAtlas;
this._frame = frame;
this._name = name;
} | javascript | {
"resource": ""
} |
q37638 | containsAny | train | function containsAny(arr, compare, transform) {
if (is_1.isString(arr))
arr = arr.split('');
if (is_1.isString(compare))
compare = compare.split('');
if (!is_1.isArray(arr) || !is_1.isArray(compare))
return false;
return compare.filter(function (c) {
return contains(arr, ... | javascript | {
"resource": ""
} |
q37639 | duplicates | train | function duplicates(arr, value, breakable) {
var i = arr.length;
var dupes = 0;
while (i--) {
if (breakable && dupes > 0)
break;
if (is_1.isEqual(arr[i], value))
dupes += 1;
}
return dupes;
} | javascript | {
"resource": ""
} |
q37640 | push | train | function push(arr) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
arr = arr.concat(flatten.apply(void 0, args));
return {
array: arr,
val: arr.length
};
} | javascript | {
"resource": ""
} |
q37641 | splice | train | function splice(arr, start, remove) {
var items = [];
for (var _i = 3; _i < arguments.length; _i++) {
items[_i - 3] = arguments[_i];
}
start = start || 0;
var head = arr.slice(0, start);
var tail = arr.slice(start);
var removed = [];
if (remove) {
removed = tail.slice(0, ... | javascript | {
"resource": ""
} |
q37642 | unshift | train | function unshift(arr) {
var items = [];
for (var _i = 1; _i < arguments.length; _i++) {
items[_i - 1] = arguments[_i];
}
arr = arr.concat(flatten(items));
return {
array: arr,
val: arr.length
};
} | javascript | {
"resource": ""
} |
q37643 | init | train | function init(config) {
var hydroConfig = config.hydro || {};
var hydroJs = hydroConfig.path || dirname(dirname(require.resolve('hydro'))) + '/dist/hydro.js';
var before = hydroConfig.before || [];
config.files.unshift(createPattern(__dirname + '/adapter.js'));
config.files.unshift(createPattern(hydroJs));
... | javascript | {
"resource": ""
} |
q37644 | train | function(element) {
// return value of html.getBoundingClientRect().top ... IE : 0, other browsers : -pageYOffset
if(element.nodeName === 'HTML') return -window.pageYOffset
return element.getBoundingClientRect().top + window.pageYOffset;
} | javascript | {
"resource": ""
} | |
q37645 | train | function(el, duration, callback){
duration = duration || 500;
var start = window.pageYOffset;
if (typeof el === 'number') {
var end = parseInt(el);
} else {
var end = getTop(el);
}
var clock = Date.now();
var requestAnimationFrame = window.requestAnimationFrame ||
windo... | javascript | {
"resource": ""
} | |
q37646 | preload | train | function preload() {
var path = config.gulpFiles;
if (/^[^\/]/.test(path)) {
path = config.basePath + '/' + path;
}
glob.sync(path + '/*/*.js').map(function(file) {
return file.replace(path, '').split('/').filter(function(split) {
return !!split;
});
}).forEach(function(file) {
register(
... | javascript | {
"resource": ""
} |
q37647 | register | train | function register(type, name, create) {
if (!(type in definitions)) {
definitions[type] = {};
}
if (type === 'pipe') {
create = chain(create, devour);
}
definitions[type][name] = create;
} | javascript | {
"resource": ""
} |
q37648 | plug | train | function plug(name) {
var part, scope;
if (!('buffer' in plug.prototype)) {
plug.prototype.buffer = {};
}
part = name.split('.');
scope = part.shift();
if (!(scope in plug.prototype.buffer)) {
plug.prototype.buffer[scope] = wanted.require('gulp-' + scope);
}
scope = plug.prototype.buffer[scop... | javascript | {
"resource": ""
} |
q37649 | startRequested | train | function startRequested() {
var start = [];
if (run.length) {
run.forEach(function(task) {
var exists = task.replace(/:.*$/, '') in definitions.task;
console.log(
'Task %s %s',
exists ? chalk.green(task) : chalk.red(task),
exists ? 'running' : 'not found!'
);
if (exists) {
... | javascript | {
"resource": ""
} |
q37650 | readData | train | function readData(raw){
var dataObj = micro.toJSON(new Buffer(raw));
var type = dataObj._type;
delete dataObj._type;
switch (type){
case "Ping":
//Grab latency (if exists) and bounce back the exact same data packet
... | javascript | {
"resource": ""
} |
q37651 | onUserPlayerChange | train | function onUserPlayerChange(data){
var player = gameData.player;
//Check if data contains different values
if (player.get("angle") !== data.angle.toPrecision(1) || player.get("isAccelerating") !== data.isAccelerating){
var buffer = micro.toBinary(data, "PlayerUpdate... | javascript | {
"resource": ""
} |
q37652 | Task | train | function Task(options) {
if (!(this instanceof Task)) {
return new Task(options);
}
utils.is(this, 'task');
use(this);
this.options = options || {};
if (utils.isTask(options)) {
this.options = {};
this.addTargets(options);
return this;
}
} | javascript | {
"resource": ""
} |
q37653 | train | function (info, cb) {
// Default to a binary request
var options = info.src;
var dest = info.dest;
// Request the url
var req = request(options);
// On error, callback
req.on('error', cb);
// On response, callback for wri... | javascript | {
"resource": ""
} | |
q37654 | train | function (url, content) {
var dirName = path.dirname(url);
if (!fs.existsSync(dirName)) {
fs.mkdirSync(dirName);
}
fs.writeFileSync(url, content, {
mode: 0777
});
} | javascript | {
"resource": ""
} | |
q37655 | train | function (onComplete) {
grunt.file.delete(options.tempDir, { force: true });
fs.exists(options.downloadDestination, function (exists) {
if (exists) {
fs.unlinkSync(options.downloadDestination);
}
if (onComplete) {
... | javascript | {
"resource": ""
} | |
q37656 | train | function (orchardDownload) {
grunt.log.writeln('downloading Orchard ' + options.version + ', this may take a while...');
helpers.curl({
src: orchardDownload.url,
dest: options.downloadDestination
}, function handleCurlComplete (err) {
... | javascript | {
"resource": ""
} | |
q37657 | train | function (orchardDownload) {
var content, dest, zip;
grunt.log.writeln('extracting downloaded zip...');
fs.mkdirSync(options.tempDir);
fs.readFile(options.downloadDestination, function (err, data) {
if (err) {
throw err;
... | javascript | {
"resource": ""
} | |
q37658 | train | function () {
// ensures the uncompressed Orchard code is inside the version directory
// inside directory that contains local Orchard install. This is to
// ensure a directory structure like `/local/1.8.1/Orchard-1.8.1`
// doesn't occur becuase the download zip contents ... | javascript | {
"resource": ""
} | |
q37659 | _directoryToString | train | function _directoryToString (directory, encoding, separator, callback) {
if ("undefined" === typeof directory) {
throw new ReferenceError("missing \"directory\" argument");
}
else if ("string" !== typeof directory) {
throw new TypeError("\"directory\" argument is not a string");
}
else if ("... | javascript | {
"resource": ""
} |
q37660 | train | function (porcelainStatus) {
var PORCELAIN_PROPERTY_REGEXES = {
// Leading non-whitespace that is not a question mark
staged: /^[^\?\s]/,
// Trailing non-whitespace
unstaged: /\S$/,
// Any "A" or "??"
added: /A|\?\?/,
// Any "M"
modified: /M/,
// Any "D"
deleted: /D/,
// An... | javascript | {
"resource": ""
} | |
q37661 | f_tahta_kalem_takip_ekle | train | function f_tahta_kalem_takip_ekle(_tahta_id, _kalem_id) {
//kalem takip edilecek olarak belirlendiğinde ihalesi de takip edilecek olarak ayarlamalıyız
return result.dbQ.sadd(result.kp.tahta.ssetTakiptekiKalemleri(_tahta_id), _kalem_id)
.then(function () {
return result.db... | javascript | {
"resource": ""
} |
q37662 | f_kalem_ekle_tahta | train | function f_kalem_ekle_tahta(_tahta_id, _ihale_id, _es_kalem, _db_kalem, _kul_id) {
var onay_durumu = _es_kalem.OnayDurumu;
//genel ihaleye tahtada yeni kalem ekleniyor
//bu durumda sadece tahtanın (tahta:401:ihale:101:kalem) kalemlerine eklemeliyiz
//ihalenin genel kalemlerine de... | javascript | {
"resource": ""
} |
q37663 | _setIgnoreCase | train | function _setIgnoreCase(obj, key, val) {
var key_lower = key.toLowerCase();
for (var p in obj) {
if (obj.hasOwnProperty(p) && key_lower == p.toLowerCase()) {
obj[p] = val;
return;
}
}
obj[key] = val;
} | javascript | {
"resource": ""
} |
q37664 | SQLiteStorage | train | function SQLiteStorage(config) {
/*jshint bitwise: false */
var self = this;
this.events = new EventEmitter();
app.debug(util.format('Initializing SQLite Storage on %s', config.filename));
config = config || {};
config.table = config.table || "storage";
config.mode = config.mode || (sqlite3... | javascript | {
"resource": ""
} |
q37665 | ErrorConflict | train | function ErrorConflict (message) {
Error.call(this);
// Add Information
this.name = 'ErrorConflict';
this.type = 'client';
this.status = 409;
if (message) {
this.message = message;
}
} | javascript | {
"resource": ""
} |
q37666 | train | function (f, fieldsIndex, ignoreEmptyFields) {
if (!f)
return function () {};
return function (/*args*/) {
var context = this;
var args = arguments;
if (self.collection.paused)
return;
if (fieldsIndex !== undefined && self.projectionFn) {
args[fi... | javascript | {
"resource": ""
} | |
q37667 | Worker | train | function Worker() {
this.config = JSON.parse(process.env.WORKER_CONFIG);
if (typeof this.config !== 'object') {
throw new Error('WORKER_CONFIG is missing');
}
process.title = process.variousCluster = this.config.title;
} | javascript | {
"resource": ""
} |
q37668 | couchdbAuth | train | function couchdbAuth ({uri, key, secret} = {}) {
return {
/**
* Check whether we've already ran authentication.
* @returns {boolean} `true` if already authenticated, otherwise `false`
*/
isAuthenticated () {
return !!this._cookie
},
/**
* Authenticate and return true if auth... | javascript | {
"resource": ""
} |
q37669 | getDeviceId | train | function getDeviceId(req) {
// NOTE: client_id and client_secret are deprecated so eventually remove
var deviceId = req.headers['x-device-id'];
var deviceSecret = req.headers['x-device-secret'];
// if client ID and secret don't exist, then no device
if (!deviceId || !deviceSecr... | javascript | {
"resource": ""
} |
q37670 | getCaller | train | function getCaller(req) {
var ipAddress = req.headers['x-forwarded-for'] || req.info.remoteAddress || '';
var user = req.user;
if (user) {
// if user admin and there is an onBehalfOf value then use onBehalfOf
if (user.role === 'admin' && req.query.onBehalfOfId) {
... | javascript | {
"resource": ""
} |
q37671 | visitImportDeclaration | train | function visitImportDeclaration(traverse, node, path, state) {
var specifier, name;
utils.catchup(node.range[0], state);
switch (node.kind) {
// import "module"
case undefined:
utils.append('require(' + node.source.raw + ');', state);
break;
// import name from "module"
case "defaul... | javascript | {
"resource": ""
} |
q37672 | visitModuleDeclaration | train | function visitModuleDeclaration(traverse, node, path, state) {
utils.catchup(node.range[0], state);
utils.append('var ' + node.id.name + ' = require(' + node.source.raw + ');', state);
utils.move(node.range[1], state);
return false;
} | javascript | {
"resource": ""
} |
q37673 | commonStartupOperations | train | function commonStartupOperations() {
if (options.stayUp) {
process.on('uncaughtException', app.log); // prints stack trace
}
startupMessage.call(this, options);
} | javascript | {
"resource": ""
} |
q37674 | ip2long | train | function ip2long( a, b, c, d ) {
for (
c = b = 0;
d = a.split('.')[b++];
c +=
d >> 8
|
b > 4 ?
NaN
:
d * (1 << -8 * b)
)
d = parseInt(
+d
&&
d
);
return c
} | javascript | {
"resource": ""
} |
q37675 | cidr_match | train | function cidr_match( ip, range ) {
//
// If the range doesn't have a slash it will only match if identical to the IP.
//
if ( range.indexOf( "/" ) < 0 )
{
return ( ip == range );
}
//
// Split the range by the slash
//
var parsed = range.split( "/" );
if... | javascript | {
"resource": ""
} |
q37676 | selectWithValidation | train | function selectWithValidation(choices) {
// Validate argument is an array
if(!choices || !choices.length) {
throw new Error("Randomly Select: invalid argument, please provide a non-empty array");
}
// Validate that:
// - each array entry has a 'chance' and 'result' property
// - each 'chance' field is a number... | javascript | {
"resource": ""
} |
q37677 | selectWithoutValidation | train | function selectWithoutValidation(choices) {
// Generate a list of options with positive non-zero chances
let choicesWithNonZeroChances = [];
let totalWeight = 0.0;
for(let i = 0; i < choices.length; i++) {
if(choices[i].chance > 0.0) {
choicesWithNonZeroChances.push(choices[i]);
totalWeight += choices[i].ch... | javascript | {
"resource": ""
} |
q37678 | addClass | train | function addClass(element, className) {
if (!hasClassNameProperty(element) || hasClass(element, className)) {
return;
}
element.className = (element.className + ' ' + className).replace(/^\s+|\s+$/g, '');
} | javascript | {
"resource": ""
} |
q37679 | bind | train | function bind(element, eventName, callback) {
element.addEventListener(eventName, callback);
return function unbind() {
element.removeEventListener(eventName, callback);
};
} | javascript | {
"resource": ""
} |
q37680 | train | function (doc, ruleTree) {
// Special case for "sets"
if (_.isArray(doc))
return _.map(doc, function (subdoc) { return transform(subdoc, ruleTree); });
var res = details.including ? {} : EJSON.clone(doc);
_.each(ruleTree, function (rule, key) {
if (!_.has(doc, key))
return;
if... | javascript | {
"resource": ""
} | |
q37681 | AmqpQueue | train | function AmqpQueue(source) {
assert.ok(source);
TasksSource.Queue.apply(this, []);
this.source = source;
this._amqpProcessing = false;
} | javascript | {
"resource": ""
} |
q37682 | resolve | train | function resolve(promiseLike) {
// Return if already promised
if (promiseLike instanceof Promise) {
return promiseLike;
}
var promises = [];
if (promiseLike instanceof Array) {
promiseLike.forEach((promiseLikeEntry) => {
promises.push(promisify(promiseLikeEntry));
... | javascript | {
"resource": ""
} |
q37683 | GraphBuilder | train | function GraphBuilder(options){
options = options || {};
// Precedence for resolvers.
this.resolvers = options.resolvers || [
require('./resolvers/absolute'),
require('./resolvers/relative'),
require('./resolvers/environment')
];
this.handlers = options.directives || [];
} | javascript | {
"resource": ""
} |
q37684 | handleGlobalError | train | function handleGlobalError() {
// make sure Q provides long stack traces (disabled in prod for performance)
Q.longStackSupport = config.longStackSupport;
// hopefully we handle errors before this point, but this will log anything not caught
process.on('uncaughtException', function (err... | javascript | {
"resource": ""
} |
q37685 | handlePreResponseError | train | function handlePreResponseError(server) {
server.ext('onPreResponse', function (request, reply) {
var response = request.response;
var originalResponse = response;
var msg;
// No error, keep going with the reply as normal
if (!response.isBoom) { reply... | javascript | {
"resource": ""
} |
q37686 | leftAlign | train | function leftAlign(lines) {
if (lines.length == 0) return lines;
var distance = lines[0].match(/^\s*/)[0].length;
var result = [];
lines.forEach(function(line){
result.push(line.slice(Math.min(distance, line.match(/^\s*/)[0].length)));
});
return result;
} | javascript | {
"resource": ""
} |
q37687 | inject | train | function inject() {
var args = normalize(arguments);
/* Sanity check, need a callback */
if (!args.function) {
throw new EsquireError("Callback for injection unspecified");
}
/* Create a fake "null" module and return its value */
var module = new Module(null, args.arguments... | javascript | {
"resource": ""
} |
q37688 | tryExtensions | train | function tryExtensions(p, exts, isMain) {
for (var i = 0; i < exts.length; i++) {
const filename = tryFile(p + exts[i], isMain);
if (filename) {
return filename;
}
}
return false;
} | javascript | {
"resource": ""
} |
q37689 | generate | train | function generate (orgID, loanNumber) {
//strip non-numeric or letters
loanNumber = loanNumber.replace(/\D/g,"");
orgID = orgID.replace(/\D/g,"");
//string letters
var loanNum = loanNumber.replace(/[a-z]/gi,"");
orgID = orgID.replace(/[a-z]/gi,"");
if (orgID.toString().length != 7 ){
throw new Error... | javascript | {
"resource": ""
} |
q37690 | bbTeamToBotkitTeam | train | function bbTeamToBotkitTeam (team) {
return {
id: team.slack_team_id,
createdBy: team.slack_user_id,
url: `https://${team.slack_team_domain}.slack.com/`,
name: team.slack_team_name,
bot: {
name: team.slack_bot_user_name,
token: team.slack_bot_access_token,
user_id: team.slack_bot... | javascript | {
"resource": ""
} |
q37691 | genPasta | train | function genPasta (opts) {
// GENERAL Functions
//
function slice (ar, start, end) {
return Array.prototype.slice.call(ar, start, end)
}
function log () {
if (console && console.log) console.log(slice(arguments))
}
function combine (returned, added) {
Object.keys(added).forEach(function (key... | javascript | {
"resource": ""
} |
q37692 | train | function (url, hash, uuid) {
this.lastCalledUrl = url;
this.actionQueue.push(this.webdriverClient.url.bind(this.webdriverClient, url));
this.actionQueue.push(this._openCb.bind(this, url, hash, uuid));
return this;
} | javascript | {
"resource": ""
} | |
q37693 | train | function (expected, hash) {
this.actionQueue.push(this.webdriverClient.getUrl.bind(this.webdriverClient));
this.actionQueue.push(this._urlCb.bind(this, expected, hash));
return this;
} | javascript | {
"resource": ""
} | |
q37694 | train | function(mods) {
for (var i = 0, len = mods.length; i < len; i++) {
if (!internal.is_module_ready(mods[i])) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} | |
q37695 | train | function(mods) {
for (var i = 0, len = mods.length; i < len; i++) {
if (self.get_module_status(mods[i]) !== internal.states.initialized) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} | |
q37696 | train | function()
{
if (typeof console !== 'undefined' && ((pwf.has('module', 'config') && pwf.config.get('debug.frontend')) || !pwf.has('module', 'config'))) {
var args = pwf.clone_array(arguments);
if (args.length > 1) {
console.log(args);
} else {
console.log(args[0]);
}
}
} | javascript | {
"resource": ""
} | |
q37697 | train | function(items)
{
var register = [];
/// Export as module if running under nodejs
if (typeof global === 'object') {
register.push(global);
}
if (typeof window === 'object') {
register.push(window);
}
// Browse all resolved global objects and bind pwf items
for (var i = 0; i < register.length; ... | javascript | {
"resource": ""
} | |
q37698 | luckio | train | function luckio(chance) {
var min = 1;
var max = math.maxRange(chance);
var luckyNumber = math.randomNumber(min, max);
return function() {
if (math.randomNumber(min, max) === luckyNumber) return true;
return false;
}
} | javascript | {
"resource": ""
} |
q37699 | getScopeValue | train | function getScopeValue(scope, field) {
if (!scope || !field) { return null; }
var fieldParts = field.split('.');
var pntr = scope;
_.each(fieldParts, function (fieldPart) {
if (pntr) {
pntr = pntr[fieldPart];
}
});
return pntr;
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.