_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q32300 | train | function() {
const query = {clientId};
var body = sg.extend({partnerId, version, sessionId}, {rsvr});
self.POST('hq', '/clientStart', query, body, function(err, config) {
//console.log('clientStart-object', query, body, err, config);
if (sg.ok(err, config)) {
self.config = sg.deepCo... | javascript | {
"resource": ""
} | |
q32301 | flatten | train | function flatten(array) {
return array.reduce(function (a, b) {
return isArray(b) ? a.concat(flatten(b)) : a.concat(b);
}, []);
} | javascript | {
"resource": ""
} |
q32302 | handleConnection | train | function handleConnection(socket) { // server 'connect'
socket.setEncoding('utf-8')
socket.on('data', requestResponder)
function requestResponder(data) {
socket.end(String(process.pid))
self.emit('data', data)
}
} | javascript | {
"resource": ""
} |
q32303 | getVariable | train | function getVariable(variable) {
if ( cached.data == null ) {
getData();
}
if (variable.toUpperCase() in cached.data ) {
return cached.data[variable.toUpperCase()];
} else if (variable in cached.data) {
return cached.data[variable];
}
} | javascript | {
"resource": ""
} |
q32304 | resolve | train | function resolve(moduleMeta, options) {
function setPath(path) {
return {
path: path
};
}
return resolvePath(moduleMeta, options).then(setPath, log2console);
} | javascript | {
"resource": ""
} |
q32305 | resolvePath | train | function resolvePath(moduleMeta, options) {
var parentPath = getParentPath(moduleMeta, options);
var filePath = path.resolve(path.dirname(options.baseUrl), moduleMeta.name);
if (fs.existsSync(filePath)) {
return Promise.resolve(filePath);
}
return new Promise(function(resolve, reject) {
browserResol... | javascript | {
"resource": ""
} |
q32306 | getParentPath | train | function getParentPath(moduleMeta, options) {
var referrer = moduleMeta.referrer;
return (referrer && moduleMeta !== referrer) ? referrer.path : options.baseUrl;
} | javascript | {
"resource": ""
} |
q32307 | train | function(point) {
var latitude = point.hasOwnProperty('lat') ? 'lat' : 'latitude';
var longitude = (point.hasOwnProperty('lng') ? 'lng' : false) ||
(point.hasOwnProperty('long') ? 'long' : false) ||
'longitude';
var elevation = (point.hasOwnProperty('alt') ? 'alt' : false) ||
(... | javascript | {
"resource": ""
} | |
q32308 | train | function(start, end, accuracy) {
var keys = geolib.getKeys(start);
var latitude = keys.latitude;
var longitude = keys.longitude;
accuracy = Math.floor(accuracy) || 1;
var coord1 = {}, coord2 = {};
coord1[latitude] = parseFloat(geolib.useDecimal(start[latitude])).toRad();
coord1[longitude] = pars... | javascript | {
"resource": ""
} | |
q32309 | train | function(coords) {
if (!coords.length) {
return false;
}
var keys = geolib.getKeys(coords[0]);
var latitude = keys.latitude;
var longitude = keys.longitude;
var max = function( array ){
return Math.max.apply( Math, array );
};
var min = function( array ){
return Math.min.apply( M... | javascript | {
"resource": ""
} | |
q32310 | train | function(latlng, coords) {
var keys = geolib.getKeys(latlng);
var latitude = keys.latitude;
var longitude = keys.longitude;
for(var c = false, i = -1, l = coords.length, j = l - 1; ++i < l; j = i) {
(
(coords[i][longitude] <= latlng[longitude] && latlng[longitude] < coords[j][longitude]) ||
... | javascript | {
"resource": ""
} | |
q32311 | train | function(originLL, destLL) {
var keys = geolib.getKeys(originLL);
var latitude = keys.latitude;
var longitude = keys.longitude;
destLL[latitude] = geolib.useDecimal(destLL[latitude]);
destLL[longitude] = geolib.useDecimal(destLL[longitude]);
originLL[latitude] = geolib.useDecimal(originLL[latitude])... | javascript | {
"resource": ""
} | |
q32312 | train | function(originLL, destLL, bearingMode) {
var direction;
if(bearingMode == 'circle') { // use great circle bearing
var bearing = geolib.getBearing(originLL, destLL);
} else { // default is rhumb line bearing
var bearing = geolib.getRhumbLineBearing(originLL, destLL);
}
switch(Math.round(bearing... | javascript | {
"resource": ""
} | |
q32313 | train | function(latlng, coords) {
var keys = geolib.getKeys(latlng);
var latitude = keys.latitude;
var longitude = keys.longitude;
var coordsArray = [];
for(var coord in coords) {
var d = geolib.getDistance(latlng, coords[coord]);
coordsArray.push({key: coord, latitude: coords[coord][latitude], longit... | javascript | {
"resource": ""
} | |
q32314 | train | function(latlng, coords, offset) {
offset = offset || 0;
var ordered = geolib.orderByDistance(latlng, coords);
return ordered[offset];
} | javascript | {
"resource": ""
} | |
q32315 | train | function(coords) {
var dist = 0, last;
for (var i = 0, l = coords.length; i < l; ++i) {
if(last) {
dist += geolib.getDistance(coords[i], last);
}
last = coords[i];
}
return dist;
} | javascript | {
"resource": ""
} | |
q32316 | train | function(unit, distance, round) {
if(distance == 0 || typeof distance == 'undefined') {
if(geolib.distance == 0) {
// throw 'No distance given.';
return 0;
} else {
distance = geolib.distance;
}
}
unit = unit || 'm';
round = (null == round ? 4 : round);
switch(unit) {
... | javascript | {
"resource": ""
} | |
q32317 | train | function(value) {
value = value.toString().replace(/\s*/, '');
// looks silly but works as expected
// checks if value is in decimal format
if (!isNaN(parseFloat(value)) && parseFloat(value).toString() == value) {
return parseFloat(value);
// checks if it's sexagesimal format (HHH° MM' SS" (NES... | javascript | {
"resource": ""
} | |
q32318 | train | function(dec) {
if (dec in geolib.sexagesimal) {
return geolib.sexagesimal[dec];
}
var tmp = dec.toString().split('.');
var deg = Math.abs(tmp[0]);
var min = ('0.' + tmp[1])*60;
var sec = min.toString().split('.');
min = Math.floor(min);
sec = (('0.' + sec[1]) * 60).toFixed(2);
geoli... | javascript | {
"resource": ""
} | |
q32319 | train | function(sexagesimal) {
if (sexagesimal in geolib.decimal) {
return geolib.decimal[sexagesimal];
}
var regEx = new RegExp(sexagesimalPattern);
var data = regEx.exec(sexagesimal);
if(data) {
var min = parseFloat(data[2]/60);
var sec = parseFloat(data[4]/3600) || 0;
}
var dec = ((pars... | javascript | {
"resource": ""
} | |
q32320 | train | function (jsonObject, path, force, value) {
if (!path) {
return;
}
var newValue, obj;
obj = jsonObject || {};
path.trim().split('.').some(function (key, index, array) {
if (!key && key !== 0) {
return false;
}
newValue = obj[key];
if (index == array.length - 1) {
if (value === ... | javascript | {
"resource": ""
} | |
q32321 | gatherEntityFilters | train | function gatherEntityFilters(context, expression) {
let ii, len, bf, result, obj;
let filter = expression[0];
result = EntityFilter.create();
switch (filter) {
case ANY:
case ANY_FILTER:
case ALL:
case ALL_FILTER:
case NONE:
case NONE_FILTER:
cas... | javascript | {
"resource": ""
} |
q32322 | initialize | train | function initialize() {
var creditcard;
// [square] @import "creditcard/index.js"
this.lib = creditcard;
//
// Create references to elements.
//
this.number = this.$('input[name="full_number"]');
this.cvv = this.$('input[name="cvv"]');
this.year = this.$('select[name="expiration_yea... | javascript | {
"resource": ""
} |
q32323 | digit | train | function digit(event) {
var element = event.element
, code = event.keyCode || event.which
, result;
result = (code >= 48 && code <= 57) || code === 8 || code === 46;
if (!result) event.preventDefault();
return {
allowed: result,
code: code,
removal: code === 8 || code ===... | javascript | {
"resource": ""
} |
q32324 | date | train | function date(event) {
var result = this.lib.expiry(this.month.get('value'), this.year.get('value'))
, className = result ? 'valid' : 'invalid';
//
// Update both select boxes.
//
this.month.removeClass('invalid').addClass(className);
this.year.removeClass('invalid').addClass(className);
... | javascript | {
"resource": ""
} |
q32325 | number | train | function number(event) {
var element = event.element
, value = element.value
, key = this.digit(event)
, valid;
//
// Input must be numerical.
//
if (!key.allowed && event.type !== 'blur') return;
//
// Always format if the event is of type blur. This will ensure the inpu... | javascript | {
"resource": ""
} |
q32326 | cvv | train | function cvv(event) {
var element = event.element
, value = element.value
, key = this.digit(event);
//
// Input must be numerical.
//
if (!key.allowed && event.type !== 'blur') return;
//
// Check if the number is valid.
//
if (this.validate && (value.length >= 3 || ke... | javascript | {
"resource": ""
} |
q32327 | removeItem | train | function removeItem(key) {
delete storage[key];
window.name = qs.stringify(storage, prefix);
windowStorage.length--;
} | javascript | {
"resource": ""
} |
q32328 | train | function(input, options) {
this.preprocess(input, options);
for (var inputIndex=0; inputIndex < this.inputList.length; ++inputIndex)
{
this.input = this.inputList[inputIndex][1][1].replace(/\\/g,'\\\\');
// first stage : configurable crusher
var output = this.findRedundancies(options);
this.inputL... | javascript | {
"resource": ""
} | |
q32329 | train | function(matchIndex) {
var oldToken = this.matchesLookup[matchIndex].token;
for (var j=0;j<this.matchesLookup.length;++j) {
this.matchesLookup[j].usedBy = this.matchesLookup[j].usedBy.split(oldToken).join("");
}
this.matchesLookup[matchIndex].cleared=true;
} | javascript | {
"resource": ""
} | |
q32330 | getTag | train | function getTag(val) {
const tag = Object.prototype.toString.call(val).slice(8, -1)
if (basicTypes.includes(tag.toLowerCase())) {
return tag.toLowerCase()
}
return tag
} | javascript | {
"resource": ""
} |
q32331 | Question | train | function Question(name, message, options) {
if (utils.isObject(name)) {
options = utils.merge({}, message, name);
message = options.message;
name = options.name;
}
if (utils.isObject(message)) {
options = utils.merge({}, options, message);
message = options.message;
}
utils.define(this, ... | javascript | {
"resource": ""
} |
q32332 | createNext | train | function createNext(question) {
if (!question.options.next) return;
if (typeof question.options.next === 'function') {
question.next = function() {
question.options.next.apply(question, arguments);
};
return;
}
if (typeof question.options.next === 'string') {
question.type = 'confirm';
... | javascript | {
"resource": ""
} |
q32333 | _parseConfig | train | function _parseConfig(config) {
const _config = Object.assign({}, {
filename:module.parent.filename,
scope: settings.get('scope') || {},
includeGlobals:false,
proxyGlobal:true,
useSandbox: settings.get('useSandbox') || false,
workspace: [workspaces.DEFAULT_WORKSPACE],
squashErrors: !!(conf... | javascript | {
"resource": ""
} |
q32334 | _createOptions | train | function _createOptions(config) {
return {
filename:config.filename,
displayErrors:true,
timeout: config.timeout || 20*1000
};
} | javascript | {
"resource": ""
} |
q32335 | _createScript | train | function _createScript(config, options, scope={}) {
if (!isString(config.content)) return config.content;
const stringScript = wrap(config.content.replace(/^\#\!.*/, ''), scope);
try {
return new vm.Script(stringScript, options);
} catch(error) { // These are not squashed as not evaluation errors but someth... | javascript | {
"resource": ""
} |
q32336 | wrap | train | function wrap(content, scope) {
const scopeParams = Object.keys(scope).join(',');
const comma = ((scopeParams !== '')?', ':'');
return `(function (exports, require, module, __filename, __dirname${comma}${scopeParams}) {
${content}
});`
} | javascript | {
"resource": ""
} |
q32337 | _getScopeParams | train | function _getScopeParams(config, module, scope={}) {
return [
module.exports,
module.require,
module,
module.filename,
config.basedir || path.dirname(module.filename),
...values(scope)
];
} | javascript | {
"resource": ""
} |
q32338 | _runError | train | function _runError(error, module) {
const _error = new emitter.Error({
target:module.filename,
source:(module.parent || module).filename,
error
});
module.exports = _error;
emitter.emit('error', _error);
return (!!_error.ignore || (_error.ignore && isFunction(_error.ignore) && _error.ignore()));
} | javascript | {
"resource": ""
} |
q32339 | _runScript | train | function _runScript(config, options) {
const useSandbox = ((isFunction(config.useSandbox)) ? _config.useSandbox(_config) || false : config.useSandbox);
const module = new Module(config);
const scopeParams = _getScopeParams(config, module, config.scope);
const script = _createScript(config, options, config.scope... | javascript | {
"resource": ""
} |
q32340 | evaluate | train | function evaluate(config) {
const _config = _parseConfig(config);
const options = _createOptions(_config);
return _runScript(_config, options);
} | javascript | {
"resource": ""
} |
q32341 | hasFileType | train | function hasFileType(file, fileExt) {
file = path.basename(file);
var ext = path.extname(file);
do {
if (ext === fileExt) {
return true;
} else {
file = path.basename(file, ext);
ext = path.extname(file);
}
} while (ext);
return false;
} | javascript | {
"resource": ""
} |
q32342 | train | function (contents, wfCb) {
async.eachSeries(contents.split('\n'), function (line, eachCb) {
setImmediateCompat(function() {
if (line && line.indexOf('#') !== 0) {
var directive = line.match(DIRECTIVE_REGEX);
if (!directive) {
eachCb(new Error('B... | javascript | {
"resource": ""
} | |
q32343 | Namy | train | function Namy(input, callback) {
if (/package.json$/.test(input)) {
return ReadJson(input, function (err, data) {
if (err) { return callback(err); }
if (!data.main) {
return callback(new Error("Cannot find the main field in package.json"));
}
N... | javascript | {
"resource": ""
} |
q32344 | train | function(srcArray, dest, options) {
if (!srcArray.length) {
// both no data, don't add to filesArray. (Don't return undefined.)
return typeof dest === 'string' && fileUpdates.isNew(dest, options);
// But filesArray isn't usable for 'files', 'cause Grunt doesn't support empt... | javascript | {
"resource": ""
} | |
q32345 | train | function(filepath) {
return grunt.file.exists(filepath) ?
Math.floor(fs.statSync(filepath).mtime.getTime() / 1000) : 0;
// mtime before epochtime isn't supported.
} | javascript | {
"resource": ""
} | |
q32346 | train | function(filepath, options) {
// options.mtimeOffset: 3 default
if (!fileUpdates.offset) { fileUpdates.offset = options.mtimeOffset || 3; }
if (!fileUpdates.storeData) {
// Initialize data.
if (grunt.file.exists(fileUpdates.storeDataPath)) {
fileUpdates.storeData ... | javascript | {
"resource": ""
} | |
q32347 | createSymlinks | train | function createSymlinks(symlinks) {
let path = require('path');
let fs = require('fs');
let del = require('del');
del.sync(symlinks.map(sl => sl.dest));
try {
symlinks.forEach(sl => {
let src = path.resolve(sl.src);
fs.symlinkSync(src, sl.dest);
});
} cat... | javascript | {
"resource": ""
} |
q32348 | crawlDirectoryWithFS | train | function crawlDirectoryWithFS(parent, sync) {
return fsCmd('readdir', sync, parent).then(function (things) {
return Q.all(things.map(function (file) {
file = path.join(parent, file);
return Q.all([file, fsCmd('stat', sync, file)]);
}));
}).then(function (stats) {
... | javascript | {
"resource": ""
} |
q32349 | crawlDirectory | train | function crawlDirectory(parent, sync) {
if (sync) {
return crawlDirectory(parent, sync);
}
/* Use `find` if available, because it's fast! */
return exec('find ' + parent + ' -not -type d').spread(function (stdin) {
return stdin.split('\n').filter(function (file) {
return !!fi... | javascript | {
"resource": ""
} |
q32350 | train | function(el, value)
{
!conbo.isEmpty(value)
? el.classList.add('cb-hide')
: el.classList.remove('cb-hide');
} | javascript | {
"resource": ""
} | |
q32351 | train | function(el, value, options, styleName)
{
if (!styleName)
{
conbo.warn('cb-style attributes must specify one or more styles in the format cb-style="myProperty:style-name"');
}
styleName = conbo.toCamelCase(styleName);
el.style[styleName] = value;
} | javascript | {
"resource": ""
} | |
q32352 | train | function(el, value, options)
{
var view = options.view;
var states = value.split(' ');
var stateChangeHandler = (function()
{
this.cbInclude(el, states.indexOf(view.currentState) != -1);
}).bind(this);
view.addEventListener('change:currentState', stateChangeHandler, this);
stateChange... | javascript | {
"resource": ""
} | |
q32353 | train | function(el, value, options)
{
var view = options.view;
var states = value.split(' ');
var stateChangeHandler = function()
{
this.cbExclude(el, states.indexOf(view.currentState) != -1);
};
view.addEventListener('change:currentState', stateChangeHandler, this);
stateChangeHandler.call(... | javascript | {
"resource": ""
} | |
q32354 | train | function(el)
{
if (el.tagName == 'A')
{
el.onclick = function(event)
{
window.location = el.href;
event.preventDefault();
return false;
};
}
} | javascript | {
"resource": ""
} | |
q32355 | train | function(el, validator)
{
var validateFunction;
switch (true)
{
case conbo.isFunction(validator):
{
validateFunction = validator;
break;
}
case conbo.isString(validator):
{
validator = new RegExp(validator);
}
case conbo.isRegExp(validator):
{
... | javascript | {
"resource": ""
} | |
q32356 | train | function(el, value)
{
// TODO Restrict to text input fields?
if (el.cbRestrict)
{
el.removeEventListener('keypress', el.cbRestrict);
}
el.cbRestrict = function(event)
{
if (event.ctrlKey)
{
return;
}
var code = event.keyCode || event.which;
var char = event.... | javascript | {
"resource": ""
} | |
q32357 | train | function(el, value)
{
// TODO Restrict to text input fields?
if (el.cbMaxChars)
{
el.removeEventListener('keypress', el.cbMaxChars);
}
el.cbMaxChars = function(event)
{
if ((el.value || el.innerHTML).length >= value)
{
event.preventDefault();
}
};
el.addEventLi... | javascript | {
"resource": ""
} | |
q32358 | Policy | train | function Policy(name, Transport, options) {
var policy = this;
if ('string' !== typeof name) {
options = Transport;
Transport = name;
name = undefined;
}
if ('function' !== typeof Transport) {
throw new Error('Transport should be a constructor.');
}
policy.name = (name || Transport.protot... | javascript | {
"resource": ""
} |
q32359 | Strategy | train | function Strategy(transports, options) {
var strategy = this;
if (!(strategy instanceof Strategy)) return new Strategy(transports, options);
if (Object.prototype.toString.call(transports) !== '[object Array]') {
options = transports;
transports = [];
}
strategy.transports = []; // List of active... | javascript | {
"resource": ""
} |
q32360 | Segment | train | function Segment(props) {
var segmentStyle = props.segmentStyle;
var fillStyle = props.fillStyle;
var commonStyle = { position: 'absolute' };
return React.createElement(
'div',
{ style: _extends({}, commonStyle, segmentStyle) },
React.createElement('div', { style: _extends({}, commonS... | javascript | {
"resource": ""
} |
q32361 | load_followers_priodically | train | function load_followers_priodically() {
try{
twimap.followersAsync(last_check, function(result) {
if(typeof result != "undefined" && result.length >=1){
//save it in our variable
_followers_list = result;
last_check = now();
msg_followers_thanks();
}
},function (err){
... | javascript | {
"resource": ""
} |
q32362 | msg_followers_thanks | train | function msg_followers_thanks(){
//move cursor
_current_index++;
//if there is no followers OR finished messaging followers stop
if(_current_index >= _followers_list.length ){
_current_index = -1;
_followe_list = null;
return;
}
//otherwise get user name from twitter
twit_cli.get("users/show",{scree... | javascript | {
"resource": ""
} |
q32363 | filter_name | train | function filter_name(name){
if ( typeof name == "undefined" || name=="" || name==null) name = "my friend";
if(name.length > 40 ) name = name.substr(0,40);
return name;
} | javascript | {
"resource": ""
} |
q32364 | random_msg | train | function random_msg(name){
name = filter_name(name);
return util.format(thanks_temp[Math.floor(Math.random()*10)%(thanks_temp.length-1)] , name);
} | javascript | {
"resource": ""
} |
q32365 | train | function(next) {
var source = config.getSource(asset.source);
async.parallel([
getFromSource.bind(null, source, asset, fromVersion, config),
getFromSource.bind(null, source, asset, toVersion, config)
], next);
} | javascript | {
"resource": ""
} | |
q32366 | train | function(files, next) {
var fromFile = files[0],
toFile = files[1];
differ(id, fromFile, toFile, next);
} | javascript | {
"resource": ""
} | |
q32367 | train | function(patch, next) {
var patchObj = toPatchObject(id, fromVersion, toVersion, patch);
//cache it
cacheCb(patchObj);
next(null, patchObj);
} | javascript | {
"resource": ""
} | |
q32368 | combinedData | train | function combinedData(flairs, presenters) {
let result = []
for (let [ flairPattern, normalizedFlair ] of flairs) {
for (let [ presenterPattern, presenter ] of presenters)
result.push([ `${flairPattern}!${presenterPattern}`, normalizedFlair, presenter ])
}
return result
} | javascript | {
"resource": ""
} |
q32369 | joinFlairs | train | function joinFlairs(data) {
let result = []
for (let [ targetStringArray, ...rest ] of data) {
// Raw flair containing only one flair don’t need to be modified.
if (targetStringArray.length < 2) {
result.push([ targetStringArray, ...rest ])
continue
}
// Concatenate the flairs using one,... | javascript | {
"resource": ""
} |
q32370 | padData | train | function padData(data) {
let result = []
for (let [ targetString, ...rest ] of data) {
// We are testing for up to 3 spaces and for empty strings we’ll use this
// condition to prevent duplicates.
if (targetString === '') {
result.push([ ' ', ...rest ])
result.push([ ' ', ...rest ])
r... | javascript | {
"resource": ""
} |
q32371 | column | train | function column(options) {
return this.navigation.slice(0, 5).reduce(function reduce(columns, section) {
return columns + options.fn(section);
}, '');
} | javascript | {
"resource": ""
} |
q32372 | month | train | function month(options) {
var content = ''
, m = this.month;
while(++m <= 12) {
content += options.fn({
month: m,
selected: +this.expiration_month === m ? ' selected' : '',
fullMonth: this.months[m - 1]
});
}
return content;
} | javascript | {
"resource": ""
} |
q32373 | year | train | function year(options) {
var content = ''
, y = this.year;
while(++y < this.max_year) {
content += options.fn({
year: y,
selected: +this.expiration_year === y ? ' selected' : '',
});
}
return content;
} | javascript | {
"resource": ""
} |
q32374 | f_Constructor | train | function f_Constructor(ins_o) {
var self = this;
// Sanitize instance options
if (!ins_o || typeof ins_o !== 'object') {
ins_o = {};
}
if (!ins_o.custom_data || typeof ins_o.custom_data !== 'object') {
ins_o.custom_data = {};
}
// Apply instance modules and properties
for (... | javascript | {
"resource": ""
} |
q32375 | compile | train | function compile(context, commands) {
let ii, cmd, limitOptions;
// log.debug('limit: in-compile cmds:', commands);
// look for the limit commands within the commands
for (ii = commands.length - 1; ii >= 0; ii--) {
cmd = commands[ii];
if (cmd[0] === LIMIT) {
// cmdLimit = c... | javascript | {
"resource": ""
} |
q32376 | emitDone | train | function emitDone(rawArgs) {
if(EventEmitter.listenerCount(emitter, "done") > 0) {
var args = new Array(rawArgs.length + 1);
args[0] = "done";
for(var i = 0; i < rawArgs.length; i++)
args[i + 1] = rawArgs[i];
process.nextTick(function() {
emitter.emit.apply(emitter, args);
});
}
} | javascript | {
"resource": ""
} |
q32377 | errorHandler | train | function errorHandler(err, req, res, next){
if (!req.suppressErrorHandlerConsole && !req.app.suppressErrorHandlerConsole) {
if (req.log) {
req.log.error(err, "Unhandled Error");
} else {
console.log("Unhandled error");
console.log(err.stack || err);
}
}
if (err.status) res.statusCode... | javascript | {
"resource": ""
} |
q32378 | setup | train | function setup(context) {
if (GLOBAL.config) {
console.log('already configured');
console.trace();
return;
}
if (!context) {
context = require('./config.js');
}
GLOBAL.config = context.config;
var svc = { pubsub: pubsub, auth: auth, indexer: indexer, pageCache: pageCache };
GLOBAL.svc =... | javascript | {
"resource": ""
} |
q32379 | setParents | train | function setParents () {
var q = async.queue(processFile, 1)
q.drain = function () { self.emit('drain') }
// Process files with no dependency first
self.nodeps.forEach( q.push )
function processFile (item, cb) {
debug('dep:', item.id)
// Add files with no dependency left to be processed
self.deps
... | javascript | {
"resource": ""
} |
q32380 | bind | train | function bind( fn, scope ) {
var bound, args;
if ( fn.bind === nativeBind && nativeBind ) return nativeBind.apply( fn, Array.prototype.slice.call( arguments, 1 ) );
args = Array.prototype.slice.call( arguments, 2 );
// @todo: don't link this
bound = function() {
if ( !(this instanceof bound)... | javascript | {
"resource": ""
} |
q32381 | Route | train | function Route(method, path, callbacks, options) {
options = options || {};
this.path = path;
this.method = method;
this.callbacks = callbacks;
this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict);
} | javascript | {
"resource": ""
} |
q32382 | train | function () {
if (this._intervalId) {
clearInterval(this._intervalId);
this._intervalId = undefined;
this.trigger(this.options.stoppedEventName, this);
return true;
}
return false;
} | javascript | {
"resource": ""
} | |
q32383 | train | function(bufferOrArray, callback) {
var self = this,
ix = this.offset,
frame = [],
isArray = Object.prototype.toString.call( bufferOrArray) === '[object Array]';
self.frameIx = 0;
while (ix < bufferOrArray.length) {
var value = isArray ? bufferOrArray[ix] : bufferOrArray['rea... | javascript | {
"resource": ""
} | |
q32384 | train | function (options) {
events.EventEmitter.call(this);
var defaultOptions = {
ejsdelimiter: '?',
strictbinding:false
};
this.options = extend(defaultOptions, options);
ejs.delimiter = this.options.ejsdelimiter;
this.binders = {};
this.update = this._update;
this.render = this._render;
this.addBinder = this... | javascript | {
"resource": ""
} | |
q32385 | copyArguments | train | function copyArguments(args) {
var copy = [];
for (var i = 0; i < args.length; i++) {
copy.push(args[i]);
}
return copy;
} | javascript | {
"resource": ""
} |
q32386 | executeSerializedFunction | train | function executeSerializedFunction(id, args) {
SerializedFunctions.forEach(function(sf) {
if (sf.id == id) {
sf.func.apply(null, args);
}
});
} | javascript | {
"resource": ""
} |
q32387 | hidden | train | function hidden(val) {
// return whether the first element in the set
// is hidden
if(val === undefined) {
return this.attr(attr);
// hide on truthy
}else if(val) {
this.attr(attr, '1');
// show on falsey
}else{
this.attr(attr, null);
}
return this;
} | javascript | {
"resource": ""
} |
q32388 | train | function (element) {
var left = 0
, top = 0;
do {
left += element.offsetLeft;
top += element.offsetTop;
} while (element = element.offsetParent);
return {
left: left,
top: top
};
} | javascript | {
"resource": ""
} | |
q32389 | trigger | train | function trigger(event, target) {
target = target || event.type;
if (target === 'mouseout') target = 'mouseover';
return target === $(event.element).get('data-trigger');
} | javascript | {
"resource": ""
} |
q32390 | create | train | function create(event) {
if (!this.trigger(event)) return;
if ('preventDefault' in event) event.preventDefault();
if (this.trigger(event, 'click') && this.remove(event)) return;
//
// Create a new tooltip, but make sure to destroy remaining ones before.
//
this.timer = setTimeout(function e... | javascript | {
"resource": ""
} |
q32391 | remove | train | function remove(event) {
//
// Current event is not set as trigger (e.g. mouse click vs. hover).
//
if (!this.trigger(event)) return false;
if ('preventDefault' in event) event.preventDefault();
clearTimeout(this.timer);
var id = document.getElementById('tooltip');
return id ? !!documen... | javascript | {
"resource": ""
} |
q32392 | render | train | function render(event) {
var tooltip = document.createElement('div')
, element = $(event.element)
, pos = element.get('data-placement')
, offset = this.offset(event.element)
, placement;
//
// Create the tooltip with the proper content and insert.
//
tooltip.id = "tooltip";
... | javascript | {
"resource": ""
} |
q32393 | train | function () {
addCacheItem(params.context.page);
params.context.lunr = params.context.lunr || {};
params.context.lunr.dataPath = params.context.lunr.dataPath || 'search_index.json';
} | javascript | {
"resource": ""
} | |
q32394 | getPathValue | train | function getPathValue(node, path) {
let names = path.split("."), name;
while ( name = names.shift() ) {
if (node == null) {
return names.length ? void 0 : null;
}
node = node[name];
}
return node;
} | javascript | {
"resource": ""
} |
q32395 | tokenNotExpired | train | function tokenNotExpired(tokenName, jwt) {
if (tokenName === void 0) { tokenName = AuthConfigConsts.DEFAULT_TOKEN_NAME; }
var token = jwt || localStorage.getItem(tokenName) || sessionStorage.getItem(tokenName);
var jwtHelper = new JwtHelper();
return token != null && !jwtHelper.isTokenExpired(token);
} | javascript | {
"resource": ""
} |
q32396 | attr | train | function attr(key, val) {
var i, attrs, map = {};
if(!this.length || key !== undefined && !Boolean(key)) {
return this;
}
if(key === undefined && val === undefined) {
// no args, get all attributes for first element as object
attrs = this.dom[0].attributes;
// convert NamedNodeMap to plain obje... | javascript | {
"resource": ""
} |
q32397 | train | function (type) {
var exec = [];
switch (type || this.configs["publish"]) {
case "EPUB":
this.publishEPUB(exec);
break;
case "LATEX":
this.publishLatex(exec);
break;
case "HTML":
this.publishHTML(exec);
default:
... | javascript | {
"resource": ""
} | |
q32398 | waitAndAdvance | train | function waitAndAdvance(step, steps) {
setTimeout(function(){
if (step < steps - 1) {
api.next();
waitAndAdvance(step+1, steps);
}
else {
// after 15 seconds on last slide, exit fullscreen
if(document.cancelFullScreen) {
document.cancelFullScreen();
... | javascript | {
"resource": ""
} |
q32399 | train | function(zCriticalValue) {
var baselineP = this.baseline.pEstimate(zCriticalValue);
var variationP = this.variation.pEstimate(zCriticalValue);
var difference = variationP.value - baselineP.value;
var standardError = Math.sqrt(Math.pow(baselineP.error, 2) + Math.pow(variationP.error, 2));... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.