_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39500 | cc | train | function cc(line, params) {
var event = params[0];
var what = params[1];
try {
++event[line[what]].counter;
} catch (TypeError) {
event[line[what]] = {
counter: 1
};
}
return event;
} | javascript | {
"resource": ""
} |
q39501 | avg | train | function avg(line, params) {
var event = params[0];
var what = params[1];
var r = Number(line[what]);
event.what += r;
++event.total;
if (r > event.max) {
event.max = r;
}
if (r < event.min) {
event.min = r;
}
return event;
} | javascript | {
"resource": ""
} |
q39502 | train | function(a,b,beStrict){
if(this.isArray(a) && this.isArray(b)){
var alen = a.length, i = 0;
if(beStrict){
if(alen !== (b).length){ return false; }
}
for(; i < alen; i++){
if(a[i] === undefined || b[i] === undefined) break;
... | javascript | {
"resource": ""
} | |
q39503 | train | function(a,b,beStrict){
if(this.isObject(a) && this.isObject(b)){
var alen = this.keys(a).length, i;
for(i in a){
if(beStrict){
if(!(i in b)){
return false;
break;
}
}
if((i in b)){
... | javascript | {
"resource": ""
} | |
q39504 | train | function(args){
if(this.isObject(args)){
return [this.keys(args),this.values(args)];
}
if(this.isArgument(args)){
return [].splice.call(args,0);
}
if(!this.isArray(args) && !this.isObject(args)){
return [args];
}
} | javascript | {
"resource": ""
} | |
q39505 | train | function () {
var val = (1 + (Math.random() * (30000)) | 3);
if(!(val >= 10000)){
val += (10000 * Math.floor(Math.random * 9));
}
return val;
} | javascript | {
"resource": ""
} | |
q39506 | train | function(i,value){
if(!value) return;
var i = i || 1,message = "";
while(true){
message += value;
if((--i) <= 0) break;
}
return message;
} | javascript | {
"resource": ""
} | |
q39507 | train | function(o,value,fn){
if(this.isArray(o)){
return this._anyArray(o,value,fn);
}
if(this.isObject(o)){
return this._anyObject(o,value,fn);
}
} | javascript | {
"resource": ""
} | |
q39508 | train | function(arrays,result){
var self = this,flat = result || [];
this.forEach(arrays,function(a){
if(self.isArray(a)){
self.flatten(a,flat);
}else{
flat.push(a);
}
},self);
return flat;
} | javascript | {
"resource": ""
} | |
q39509 | train | function(o,value){
var occurence = [];
this.forEach(o,function occurmover(e,i,b){
if(e === value){ occurence.push(i); }
},this);
return occurence;
} | javascript | {
"resource": ""
} | |
q39510 | train | function(o,value,fn){
this.forEach(o,function everymover(e,i,b){
if(e === value){
if(fn) fn.call(this,e,i,b);
}
},this);
return;
} | javascript | {
"resource": ""
} | |
q39511 | train | function(o,start,end){
var i = 0,len = o.length;
if(!len || len <= 0) return false;
start = Math.abs(start); end = Math.abs(end);
if(end > (len - start)){
end = (len - start);
}
for(; i < len; i++){
o[i] = o[start];
start +=1;
if(i >= end) break;
... | javascript | {
"resource": ""
} | |
q39512 | train | function(a){
if(!a || !this.isArray(a)) return;
var i = 0,start = 0,len = a.length;
for(;i < len; i++){
if(!this.isUndefined(a[i]) && !this.isNull(a[i]) && !(this.isEmpty(a[i]))){
a[start]=a[i];
start += 1;
}
}
... | javascript | {
"resource": ""
} | |
q39513 | Random | train | function Random(opts) {
Readable.apply(this, arguments);
if (opts && opts.objectMode) {
this.objectMode = true;
}
this.dictionary = ['1', '0'];
} | javascript | {
"resource": ""
} |
q39514 | createLocalCache | train | function createLocalCache() {
var localCache = lruCache({ max: 100, maxAge: 60000 });
return {
get: function (key) {
return new Q(localCache.get(key));
},
set: function (key, value) {
localCache.set(key, value);
},
del: function (key) {
... | javascript | {
"resource": ""
} |
q39515 | connectToRedis | train | function connectToRedis(db, opts) {
// get the redis client
var client = redis.createClient(opts.port, opts.host);
// log any errors
client.on('error', function (err) {
redisOffline = true;
console.log('connectToRedis error: ' + err);
});
client.on('ready', function () {
... | javascript | {
"resource": ""
} |
q39516 | init | train | function init(config) {
var promises = [];
if (config.redis) {
_.each(config.redis.dbs, function (idx, name) {
promises.push(
connectToRedis(idx, config.redis)
.then(function (remoteCache) {
caches[name] = wrapRemoteCache(remoteCac... | javascript | {
"resource": ""
} |
q39517 | get | train | function get(req) {
var cache = caches[this.name];
var returnVal = null;
if (cache && !redisOffline) {
try {
returnVal = cache.get(req.key);
}
catch (err) {
console.log('redis get err: ' + err);
}
}
... | javascript | {
"resource": ""
} |
q39518 | set | train | function set(req) {
var cache = caches[this.name];
if (!cache) {
cache = caches[this.name] = createLocalCache();
}
if (!redisOffline) {
try {
(req.value || !cache.del) ?
cache.set(req.key, req.value) :
cache... | javascript | {
"resource": ""
} |
q39519 | clear | train | function clear() {
var cache = caches[this.name];
if (cache && cache.flush && !redisOffline) {
cache.flush();
}
} | javascript | {
"resource": ""
} |
q39520 | addCounts | train | function addCounts(o1, o2) {
var result;
if (o1 && o2) {
result = _.merge(o1, o2, function (a, b) {
return a + b;
});
}
else if (o1) {
result = o1;
}
else {
result = o2;
}
return result;
} | javascript | {
"resource": ""
} |
q39521 | getThingUserRights | train | function getThingUserRights(userId, username, thing) {
if (!userId && !username)
throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "userId or usernane must be not empty", 28);
if (!thing)
throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Thing can't be null", 27);
let thingUs... | javascript | {
"resource": ""
} |
q39522 | getThingUserClaims | train | function getThingUserClaims(user, thing, isSuperAdministrator) {
if (!thing)
throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Thing can't be null", 26);
let thingUserClaimsAndRights = {
read : thing.publicReadClaims,
change : thing.publicChangeClaims
};
if (user) {
thingUserClaimsA... | javascript | {
"resource": ""
} |
q39523 | getThing | train | async function getThing(user, thingId, deletedStatus, userRole, userStatus, userVisibility) {
if (!thingId)
throw new utils.ErrorCustom(httpStatusCodes.BAD_REQUEST, "Thing's Id not valid", 37);
let thing = await findThingById(thingId);
if (!thing)
{
// Returns httpStatusCodes.UNAUTHORIZED to Reset Some Malici... | javascript | {
"resource": ""
} |
q39524 | getThingPosition | train | function getThingPosition(user, parentThing, childThing) {
if (!childThing)
throw new utils.ErrorCustom(httpStatusCodes.INTERNAL_SERVER_ERROR, "Child Thing can't be null", 29);
// If User is equal to null as it may be anonymous or is a SuperAdministrator who has no relationship with Thing
if (!user)
return nul... | javascript | {
"resource": ""
} |
q39525 | train | function(signal, arg, emitter) {
var widget = this,
slot;
if (typeof emitter === 'undefined') emitter = this;
console.log("fire(" + signal + ")", arg);
if (signal.charAt(0) == '@') {
// This is a global signal.
slot = $$.statics... | javascript | {
"resource": ""
} | |
q39526 | train | function(signal, arg) {
var slot = this._slots[signal];
if (slot) {
slot.call(this, arg, signal);
return true;
}
return false;
} | javascript | {
"resource": ""
} | |
q39527 | train | function() {
var element = this._element;
while (element.parentNode) {
element = element.parentNode;
if (element.$widget) {
return element.$widget;
}
}
return null;
} | javascript | {
"resource": ""
} | |
q39528 | train | function(id) {
if (!$$.App) $$.App = this;
if (!$$.App._languages) {
// Initialise localization.
var languages = [],
langStyle = document.createElement("style"),
children = document.querySelectorAll("[lang]");
docume... | javascript | {
"resource": ""
} | |
q39529 | train | function(name) {
if (typeof name === 'undefined') return this._element;
var e = this._element.querySelector("[name='" + name + "']");
if (!e) {
throw new Error(
"[WTag.get] Can't find child [name=\""
+ name + "\"] in element... | javascript | {
"resource": ""
} | |
q39530 | train | function(vars, slot, getter) {
if (!Array.isArray(vars)) {
vars = [vars];
}
if (vars.length == 0) return null;
if (typeof slot === 'string') {
slot = this[slot];
}
if (typeof getter === 'undefined') {
... | javascript | {
"resource": ""
} | |
q39531 | train | function(vars, listener) {
if (!Array.isArray(vars)) {
vars = [vars];
}
if (vars.length == 0) return null;
var found = false;
vars.forEach(
function(name) {
var data = this.findDataBinding(name);
... | javascript | {
"resource": ""
} | |
q39532 | QueryWhere | train | function QueryWhere(data)
{
//Initialize the string
var sql = '';
//Check the type
if(typeof data === 'string')
{
//Return the where
return data;
}
//Get all data
for(var key in data)
{
//Save data value
var value = data[key];
//Check the data type
if(typeof value === 'string'... | javascript | {
"resource": ""
} |
q39533 | RGBSplitFilter | train | function RGBSplitFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/rgbSplit.frag', 'utf8'),
// custom uniforms
{
red: { type: 'v2', value: { x: 20, y: 20 } },
green: { ... | javascript | {
"resource": ""
} |
q39534 | NoSuchPlugin | train | function NoSuchPlugin (message, name, paths) {
UnmetDependency.call(this, message);
this.name = name;
this.paths = paths;
} | javascript | {
"resource": ""
} |
q39535 | PluginInitializationError | train | function PluginInitializationError (message, module) {
this.message = message;
this.stack = new Error().stack;
this.module = module;
} | javascript | {
"resource": ""
} |
q39536 | instantiateDrivers | train | function instantiateDrivers(config, defaultDriverInstance) {
config.actionConfigs.forEach(action => {
action.driverInstance=action.driver?action.driver():defaultDriverInstance;
});
return config;
} | javascript | {
"resource": ""
} |
q39537 | initEnhancers | train | function initEnhancers(routes) {
invariant(routes.filter(actionConfig => !actionConfig.driverInstance).length===0, 'Routes must have instantiated drivers');
return routes
.filter(actionConfig => actionConfig.driverInstance.middleware)
.map(actionConfig => actionConfig.driverInstance.middleware(... | javascript | {
"resource": ""
} |
q39538 | findCTagsFile | train | function findCTagsFile(searchPath, tagFilePattern = '{.,}tags') {
const ctagsFinder = function ctagsFinder(tagPath) {
console.error(`ctagz: Searching ${tagPath}`)
return fs.readdirAsync(tagPath).then(files => {
const matched = files.filter(minimatch.filter(tagFilePattern)).sort()
... | javascript | {
"resource": ""
} |
q39539 | findCTagsBSearch | train | function findCTagsBSearch(searchPath, tag, ignoreCase = false, tagFilePattern = '{.,}tags') {
const ctags = findCTagsFile(searchPath, tagFilePattern)
.disposer(tags => {
if (tags) {
tags.destroy()
}
})
return Promise.using(ctags, tags => {
if (tag... | javascript | {
"resource": ""
} |
q39540 | injector | train | function injector(css, module, makeModule, options) {
output_css = join(options.output, options.css_folder || 'css');
location_css = options.client + '/' + (options.css_folder || 'css');
output_links = join(options.output, options.links_folder || 'links');
location_links = options.client + '/' + ... | javascript | {
"resource": ""
} |
q39541 | train | function () {
if (!enumer.moveNext()) {
cb(groups);
return;
}
var li = enumer.get_current();
var name = li.get_item("Name");
if (name.search(" ") > 0) {
doNext();
}
else {
var id = li.get_item("ID");
var user = web.ensureUser(name... | javascript | {
"resource": ""
} | |
q39542 | parseMatchplan | train | function parseMatchplan(team, callback) {
/** @type {String[]} */
var matchPlanArr = [],
/** @type {Matchplan} */
matchPlan,
/** @type {String[]} */
matchDetails = [],
/** @type {Encounter[]} */
encounters = [];
jsdom.env({
url: team,
scripts: ["http://code.jquery.com/jque... | javascript | {
"resource": ""
} |
q39543 | parseMatchTime | train | function parseMatchTime(matchTime) {
/** @type String[] */
var matchTimeArr = matchTime.split(' ');
matchTimeArr = [matchTimeArr[1], matchTimeArr[3]];
var dayMonthYear = matchTimeArr[0].split('.');
var hourMinutes = matchTimeArr[1].split(':');
var date = new Date(dayMonthYear[2], parseInt(dayMo... | javascript | {
"resource": ""
} |
q39544 | createMatchplan | train | function createMatchplan(matchPlanArr, encounters, matchDetails) {
var matchPlan = new Matchplan();
matchPlanArr.forEach(function(currentValue, index, array) {
matchplanEntry = new MatchplanEntry(currentValue, null, encounters[index], null, matchDetails[index]);
matchPlan.addEntry(matchplanEntry... | javascript | {
"resource": ""
} |
q39545 | refresh | train | function refresh(file, event, full) {
views.forEach(function loopViews(path) {
if (path !== full) return;
tempers.forEach(function eachTemper(temper) {
delete temper.file[path];
delete temper.compiled[path];
temper.prefetch(path);
});
});
assets... | javascript | {
"resource": ""
} |
q39546 | dyadic_pref_op | train | function dyadic_pref_op(pref, input1, input2, input_width) {
if (pref < -13 || pref > 13) throw new Error('dyadic_pref_op('+pref+'): out of range iii-111');
var bt_pref = pad(3, n2bts(pref), '0');
if (bt_pref.indexOf('i') === -1 || bt_pref.indexOf('0') === -1 || bt_pref.indexOf('1') === -1)
throw new Error('d... | javascript | {
"resource": ""
} |
q39547 | ejectionHandler | train | function ejectionHandler() {
process.stdin.resume();
log(chalk.yellow('Ejection, swooooooooo-oooopphhhf!'));
_this.fileSynceInstantly(function ejectionComplete() {
log(chalk.green('Everything saved, for god sake'));
log('shittung down, see you next life');
process.exit();
});
} | javascript | {
"resource": ""
} |
q39548 | execute | train | function execute(req, res) {
var save = undefined;
if(req.args[0] !== undefined) {
save = req.args[0] === true;
}
this.shutdown({save: save, code: 0}, process.exit);
} | javascript | {
"resource": ""
} |
q39549 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(args[0]) {
var arg = ('' + args[0]).toLowerCase();
if(arg !== Constants.SHUTDOWN.SAVE && arg !== Constants.SHUTDOWN.NOSAVE) {
throw CommandSyntax;
}
// rewrite with boolean
args[0] = (arg ==... | javascript | {
"resource": ""
} |
q39550 | train | function() {
var me = this;
var barCount = 0;
helpers.each(me.chart.data.datasets, function(dataset, datasetIndex) {
var meta = me.chart.getDatasetMeta(datasetIndex);
if (meta.bar && me.chart.isDatasetVisible(datasetIndex)) {
++barCount;
}
}, me);
return barCount;
} | javascript | {
"resource": ""
} | |
q39551 | train | function(datasetIndex) {
var barIndex = 0;
var meta, j;
for (j = 0; j < datasetIndex; ++j) {
meta = this.chart.getDatasetMeta(j);
if (meta.bar && this.chart.isDatasetVisible(j)) {
++barIndex;
}
}
return barIndex;
} | javascript | {
"resource": ""
} | |
q39552 | train | function() {
var me = this;
var options = me.options;
var scales = me.scales = {};
var items = [];
if (options.scales) {
items = items.concat(
(options.scales.xAxes || []).map(function(xAxisOptions) {
return {options: xAxisOptions, dtype: 'category'};
}),
(options.scales.yAxes |... | javascript | {
"resource": ""
} | |
q39553 | train | function() {
if (!stub.ticking) {
stub.ticking = true;
helpers.requestAnimFrame.call(window, function() {
if (stub.resizer) {
stub.ticking = false;
return callback();
}
});
}
} | javascript | {
"resource": ""
} | |
q39554 | train | function(chart, e) {
var position = helpers.getRelativePosition(e, chart.chart);
return getIntersectItems(chart, position);
} | javascript | {
"resource": ""
} | |
q39555 | train | function(chartInstance, box) {
if (!chartInstance.boxes) {
chartInstance.boxes = [];
}
chartInstance.boxes.push(box);
} | javascript | {
"resource": ""
} | |
q39556 | train | function(extension, args) {
var plugins = this._plugins;
var ilen = plugins.length;
var i, plugin;
for (i=0; i<ilen; ++i) {
plugin = plugins[i];
if (typeof plugin[extension] === 'function') {
if (plugin[extension].apply(plugin, args || []) === false) {
return false;
}
}
}
... | javascript | {
"resource": ""
} | |
q39557 | train | function(rawValue) {
// Null and undefined values first
if (rawValue === null || typeof(rawValue) === 'undefined') {
return NaN;
}
// isNaN(object) returns true, so make sure NaN is checking for a number; Discard Infinite values
if (typeof(rawValue) === 'number' && !isFinite(rawValue)) {
return N... | javascript | {
"resource": ""
} | |
q39558 | train | function(index, includeOffset) {
var me = this;
if (me.isHorizontal()) {
var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
var tickWidth = innerWidth / Math.max((me.ticks.length - ((me.options.gridLines.offsetGridLines) ? 0 : 1)), 1);
var pixel = (tickWidth * index) + me.paddingLeft;
... | javascript | {
"resource": ""
} | |
q39559 | train | function(decimal /* , includeOffset*/) {
var me = this;
if (me.isHorizontal()) {
var innerWidth = me.width - (me.paddingLeft + me.paddingRight);
var valueOffset = (innerWidth * decimal) + me.paddingLeft;
var finalVal = me.left + Math.round(valueOffset);
finalVal += me.isFullWidth() ? me.margins.l... | javascript | {
"resource": ""
} | |
q39560 | train | function(generationOptions, dataRange) {
var ticks = [];
// To get a "nice" value for the tick spacing, we will use the appropriately named
// "nice number" algorithm. See http://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
// for details.
var spacing;
... | javascript | {
"resource": ""
} | |
q39561 | train | function() {
var chartOpts = this.chart.options;
if (chartOpts && chartOpts.title) {
this.options = helpers.configMerge(Chart.defaults.global.title, chartOpts.title);
}
} | javascript | {
"resource": ""
} | |
q39562 | getBaseModel | train | function getBaseModel(tooltipOpts) {
var globalDefaults = Chart.defaults.global;
var getValueOrDefault = helpers.getValueOrDefault;
return {
// Positioning
xPadding: tooltipOpts.xPadding,
yPadding: tooltipOpts.yPadding,
xAlign: tooltipOpts.xAlign,
yAlign: tooltipOpts.yAlign,
// Body
bodyFon... | javascript | {
"resource": ""
} |
q39563 | train | function(elements) {
if (!elements.length) {
return false;
}
var i, len;
var x = 0;
var y = 0;
var count = 0;
for (i = 0, len = elements.length; i < len; ++i) {
var el = elements[i];
if (el && el.hasValue()) {
var pos = el.tooltipPosition();
x += pos.x;
y += pos.y;
... | javascript | {
"resource": ""
} | |
q39564 | lineToPoint | train | function lineToPoint(previousPoint, point) {
var pointVM = point._view;
if (point._view.steppedLine === true) {
ctx.lineTo(pointVM.x, previousPoint._view.y);
ctx.lineTo(pointVM.x, pointVM.y);
} else if (point._view.tension === 0) {
ctx.lineTo(pointVM.x, pointVM.y);
} else {
ctx.bezie... | javascript | {
"resource": ""
} |
q39565 | train | function() {
var me = this;
var labels = me.getLabels();
me.minIndex = 0;
me.maxIndex = labels.length - 1;
var findIndex;
if (me.options.ticks.min !== undefined) {
// user specified min value
findIndex = helpers.indexOf(labels, me.options.ticks.min);
me.minIndex = findIndex !== -1 ? findI... | javascript | {
"resource": ""
} | |
q39566 | train | function(value, index, datasetIndex, includeOffset) {
var me = this;
// 1 is added because we need the length but we have the indexes
var offsetAmt = Math.max((me.maxIndex + 1 - me.minIndex - ((me.options.gridLines.offsetGridLines) ? 0 : 1)), 1);
if (value !== undefined && isNaN(index)) {
var labels = ... | javascript | {
"resource": ""
} | |
q39567 | train | function(err, files, results) {
if(err) {
cb(err);
} else {
for(var i = 0; i < results.length; i++) {
if(results[i] !== undefined && results[i].error === undefined && results[i].id !== undefined) {
fixtures[results[i].id] = results[i];
}
}
cb(undefined, fixtures... | javascript | {
"resource": ""
} | |
q39568 | train | function (listTitle) {
return $.Deferred(function (dfd) {
trace.debug(`loading list ${listTitle}`);
spdal.getList(listTitle).done(function (list) {
onListChange(list);
listCtrl.data("xSPTreeLight").value(list);
}).always(function () {
dfd.resolve();
});
}).promise();
} | javascript | {
"resource": ""
} | |
q39569 | checkGitRepoExistence | train | function checkGitRepoExistence() {
return new Promise(function(resolve, reject) {
var checkRepoCommand = childProcess.exec('git branch');
checkRepoCommand.stderr.on('data', function(err) {
reject(err);
});
checkRepoCommand.on('close', function(co... | javascript | {
"resource": ""
} |
q39570 | create | train | function create (client) {
return function create (options) {
options = options || {};
const type = getType(options);
const req = {
url: `${client.baseUrl}/rest/applications/${options.pushAppId}/${type}`,
method: 'POST'
};
const data = {
name: options.name,
description: ... | javascript | {
"resource": ""
} |
q39571 | train | function(variables) {
var animation = false,
animationstring = 'animation',
keyframeprefix = '',
domPrefixes = ["Webkit", "Moz", "O", "ms", "Khtml"],
pfx = '',
elm = document.querySelector("body");
if( elm.style.animationName !== undefined ) { animation = true; }... | javascript | {
"resource": ""
} | |
q39572 | cli | train | function cli(program) {
var source = program.args[0] ? path.resolve(program.args[0]) : null,
destinations = program.args[1] ? Array.prototype.slice.call(program.args, 1) : [],
options = {},
camelton;
if (!source) {
console.error('Source file not defined.');
program.help();
}
if (!des... | javascript | {
"resource": ""
} |
q39573 | serializeToXRD | train | function serializeToXRD(descriptor) {
var xml = '<?xml version="1.0" encoding="UTF-8"?>';
xml += '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
if (descriptor.expires) {
xml += '<Expires>' + xsdDateTimeString(descriptor.expires) + '</Expires>'... | javascript | {
"resource": ""
} |
q39574 | serializeToJRD | train | function serializeToJRD(descriptor) {
var obj = {};
if (descriptor.expires) { obj.expires = xsdDateTimeString(descriptor.expires); }
if (descriptor.subject) { obj.subject = descriptor.subject; }
if (descriptor.aliases.length > 0) {
obj.aliases = [];
descriptor.aliases.forEach(function(alias) {
obj... | javascript | {
"resource": ""
} |
q39575 | textXml | train | function textXml(data) {
var xml = undefined,
tmp = undefined;
if (!data || typeof data !== "string") {
return null;
}
// Support: IE9
try {
tmp = new DOMParser();
... | javascript | {
"resource": ""
} |
q39576 | ajaxSetup | train | function ajaxSetup(target, settings) {
return settings ?
// Building a settings object
ajaxExtend(ajaxExtend(target, this.ajaxSettings), settings) :
// Extending ajaxSettings
ajaxExtend(this.ajaxSettings, target);
} | javascript | {
"resource": ""
} |
q39577 | abort | train | function abort(statusText) {
var finalText = statusText || strAbort;
if (transport) {
transport.abort(finalText);
}
done(0, finalText);
return this;
} | javascript | {
"resource": ""
} |
q39578 | train | function (endpoint, anchorPos) {
continuousAnchorLocations[endpoint.id] = [ anchorPos[0], anchorPos[1], anchorPos[2], anchorPos[3] ];
continuousAnchorOrientations[endpoint.id] = orientation;
} | javascript | {
"resource": ""
} | |
q39579 | sendSocketMessage | train | function sendSocketMessage(message) {
clients.forEach(function (client) {
if (client.readyState === WebSocket.OPEN) {
client.send(message || 'refresh', function (err) {
if (err) {
npmlog.error(err);
}
});
}
});
} | javascript | {
"resource": ""
} |
q39580 | getProperties | train | function getProperties( property ) {
var properties = property[ PROPERTY_SYMBOL ];
if ( !Array.isArray( properties ) ) return null;
return properties;
} | javascript | {
"resource": ""
} |
q39581 | applyAttributesToTarget | train | function applyAttributesToTarget( source, target ) {
var attName, attValue;
for ( attName in source ) {
if ( module.exports.isLinkable( target, attName ) ) {
attValue = source[ attName ];
target[ attName ] = attValue;
}
}
} | javascript | {
"resource": ""
} |
q39582 | addPropToValue | train | function addPropToValue( prop, value ) {
if ( value === undefined || value === null ) return;
if ( value.isContentChangeAware !== true ) return;
var properties = value[ PROPERTY_SYMBOL ];
if ( !Array.isArray( properties ) ) {
properties = [ prop ];
} else if ( properties.indexOf( prop ) === ... | javascript | {
"resource": ""
} |
q39583 | readonly | train | function readonly( target, attribs ) {
const attribNames = Object.keys( attribs );
attribNames.forEach( function ( attName ) {
const attValue = attribs[ attName ];
if ( typeof attValue === 'function' ) {
Object.defineProperty(
target,
attName, {
... | javascript | {
"resource": ""
} |
q39584 | updatePathInternal | train | function updatePathInternal(sourcePath, targetPath, options, log) {
var rootDir = (options && options.rootDir) || "";
var targetFullPath = path.join(rootDir, targetPath);
var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
var sourceStats = null;
if (sourcePath) {
... | javascript | {
"resource": ""
} |
q39585 | updatePaths | train | function updatePaths(pathMap, options, log) {
if (!pathMap || typeof pathMap !== "object" || Array.isArray(pathMap)) {
throw new Error("An object mapping from target paths to source paths is required.");
}
log = log || function(message) { };
var updated = false;
// Iterate in sorted order... | javascript | {
"resource": ""
} |
q39586 | mergeAndUpdateDir | train | function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
if (sourceDirs && typeof sourceDirs === "string") {
sourceDirs = [ sourceDirs ];
} else if (!Array.isArray(sourceDirs)) {
throw new Error("A source directory path or array of paths is required.");
}
if (!targetDir || type... | javascript | {
"resource": ""
} |
q39587 | mapDirectory | train | function mapDirectory(rootDir, subDir, include, exclude) {
var dirMap = { "": { subDir: subDir, stats: fs.statSync(path.join(rootDir, subDir)) } };
mapSubdirectory(rootDir, subDir, "", include, exclude, dirMap);
return dirMap;
function mapSubdirectory(rootDir, subDir, relativeDir, include, exclude, dir... | javascript | {
"resource": ""
} |
q39588 | mergePathMaps | train | function mergePathMaps(sourceMaps, targetMap, targetDir) {
// Merge multiple source maps together, along with target path info.
// Entries in later source maps override those in earlier source maps.
// Target stats will be filled in below for targets that exist.
var pathMap = {};
sourceMaps.forEach(... | javascript | {
"resource": ""
} |
q39589 | readFromEnvFile | train | function readFromEnvFile() {
try {
// .env file should be in root directory
const data = require('fs').readFileSync(require('path').join(__dirname, '../../.env'), 'utf8')
const env = {}
data.split('\n').filter((v) => {
return v !== ''
}).filter((v) => {
return v.indexOf('#') === -1
... | javascript | {
"resource": ""
} |
q39590 | splitMultipleValues | train | function splitMultipleValues(envObject) {
try {
const data = Object.keys(envObject)
return data.reduce((p, v) => {
p[v] = envObject[v]
if (envObject[v].indexOf(',') !== -1) {
p[v] = envObject[v].split(',')
}
return p
}, {})
} catch (err) {
throw err
}
} | javascript | {
"resource": ""
} |
q39591 | promiseReadFile | train | function promiseReadFile(path, encoding = 'utf-8') {
return new Promise((resolve, reject) => {
fs.readFile(path, encoding, (err, content) => {
if (err) reject(err);
resolve({
path,
fileName: path.split('/').pop(),
content
});
});
});
} | javascript | {
"resource": ""
} |
q39592 | Connection | train | function Connection(uri) {
this.channels = {};
let version = require('../package.json').version;
let opts = {
query: 'instanceId=' + 'js_cli_' + version,
'sync disconnect on unload': true,
path: '/syncsocket'
};
this.socket = io.connect(uri, opts);
this.bindEvents();
} | javascript | {
"resource": ""
} |
q39593 | getFoldersAndFiles | train | function getFoldersAndFiles(fpath, folders, files){
fs.readdirSync(fpath).forEach(function(name){
var stat = fs.statSync(fpath + name);
if(stat.isDirectory()){
folders.push({
path : fpath,
name : name
});
getFoldersAndFiles(fpath + name + '/', folders, files);
}else{
files.push... | javascript | {
"resource": ""
} |
q39594 | Decoder | train | function Decoder(options) {
options = options || {};
Transform.call(this, {});
this._reset();
// maximum length for bulk strings (512MB)
this.maxlen = options.maxlen || 536870912;
// create String instances for simple string replies
this.simple = options.simple !== undefined ? options.simple : false;
... | javascript | {
"resource": ""
} |
q39595 | _type | train | function _type(chunk, test) {
var b = chunk[0];
if(b === ERR || b === BST || b === STR || b === INT || b === ARR) {
if(!test) this._offset++;
return b;
}
} | javascript | {
"resource": ""
} |
q39596 | _arr | train | function _arr(chunk, type) {
var len = this._int(chunk, type);
// allow zero length for the empty array
if(typeof len === 'number' && !isNaN(len)) {
var arr = new Array(len);
this._elements += len;
Object.defineProperty(arr, '_index',
{
enumerable: false,
configurable: true,
... | javascript | {
"resource": ""
} |
q39597 | _int | train | function _int(chunk, type) {
var b, s = '', i;
while(this._offset < chunk.length) {
b = chunk[this._offset];
if(b === CR && chunk[this._offset + 1] === LF) {
this._offset += 2;
i = parseInt(s);
if(type === BST) {
if(isNaN(i)) {
return this._abort(new Error('bad string len... | javascript | {
"resource": ""
} |
q39598 | _bst | train | function _bst(chunk, type) {
// we should have already read the chunk
var len = this._int(chunk, type), buf;
if(!isNaN(len)) {
// read an integer less than zero, treat as null
if(len < 0) return null;
// read in the entire bulk string and swallow the crlf
if((chunk.length - this._offset) >= len + ... | javascript | {
"resource": ""
} |
q39599 | noNew | train | function noNew() {
return finish(function(err) {
if (err) return next(err);
// If there was a body initially, respond that there's been no change
if (ourEtag) return res.send(304);
// Otherwise, respond that there's no content (yet)
else return res.send(204);
});
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.