_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q24200 | _addOneHandler | train | async function _addOneHandler(
ownerModel,
ownerId,
childModel,
childId,
associationName,
request,
Log
) {
try {
let ownerObject = await ownerModel
.findOne({ _id: ownerId })
.select(associationName)
let payload = Object.assign({}, request.payload)
if (ownerObject) {
if (!p... | javascript | {
"resource": ""
} |
q24201 | _removeOne | train | function _removeOne(
ownerModel,
ownerId,
childModel,
childId,
associationName,
Log
) {
let request = { params: { ownerId: ownerId, childId: childId } }
return _removeOneHandler(
ownerModel,
ownerId,
childModel,
childId,
associationName,
request,
Log
)
} | javascript | {
"resource": ""
} |
q24202 | _removeOneHandler | train | async function _removeOneHandler(
ownerModel,
ownerId,
childModel,
childId,
associationName,
request,
Log
) {
try {
let ownerObject = await ownerModel
.findOne({ _id: ownerId })
.select(associationName)
if (ownerObject) {
try {
if (
ownerModel.routeOptions &&
... | javascript | {
"resource": ""
} |
q24203 | _addMany | train | function _addMany(
ownerModel,
ownerId,
childModel,
associationName,
payload,
Log
) {
let request = { params: { ownerId: ownerId }, payload: payload }
return _addManyHandler(
ownerModel,
ownerId,
childModel,
associationName,
request,
Log
)
} | javascript | {
"resource": ""
} |
q24204 | _addManyHandler | train | async function _addManyHandler(
ownerModel,
ownerId,
childModel,
associationName,
request,
Log
) {
try {
// EXPL: make a copy of the payload so that request.payload remains unchanged
let payload = request.payload.map(item => {
return _.isObject(item) ? _.assignIn({}, item) : item
})
... | javascript | {
"resource": ""
} |
q24205 | _removeMany | train | function _removeMany(
ownerModel,
ownerId,
childModel,
associationName,
payload,
Log
) {
let request = { params: { ownerId: ownerId }, payload: payload }
return _removeManyHandler(
ownerModel,
ownerId,
childModel,
associationName,
request,
Log
)
} | javascript | {
"resource": ""
} |
q24206 | _removeManyHandler | train | async function _removeManyHandler(
ownerModel,
ownerId,
childModel,
associationName,
request,
Log
) {
try {
// EXPL: make a copy of the payload so that request.payload remains unchanged
let payload = request.payload.map(item => {
return _.isObject(item) ? _.assignIn({}, item) : item
})
... | javascript | {
"resource": ""
} |
q24207 | _getAll | train | function _getAll(ownerModel, ownerId, childModel, associationName, query, Log) {
let request = { params: { ownerId: ownerId }, query: query }
return _getAllHandler(
ownerModel,
ownerId,
childModel,
associationName,
request,
Log
)
} | javascript | {
"resource": ""
} |
q24208 | filterDeletedEmbeds | train | function filterDeletedEmbeds(result, parent, parentkey, depth, Log) {
if (_.isArray(result)) {
result = result.filter(function(obj) {
let keep = filterDeletedEmbeds(obj, result, parentkey, depth + 1, Log)
// Log.log("KEEP:", keep);
return keep
})
// Log.log("UPDATED:", parentkey);
//... | javascript | {
"resource": ""
} |
q24209 | train | function(model, logger) {
assert(
model.schema,
"model not mongoose format. 'schema' property required."
)
assert(
model.schema.paths,
"model not mongoose format. 'schema.paths' property required."
)
assert(
model.schema.tree,
"model not mongoose format. 'schema.t... | javascript | {
"resource": ""
} | |
q24210 | train | function(server, model, options, logger) {
const Log = logger.bind('Password Update')
let Boom = require('boom')
let collectionName = model.collectionDisplayName || model.modelName
Log.note('Generating Password Update endpoint for ' + collectionName)
let handler = as... | javascript | {
"resource": ""
} | |
q24211 | getLogger | train | function getLogger(label) {
let config = defaultConfig
extend(true, config, module.exports.config)
let rootLogger = logging.getLogger(chalk.gray(label))
rootLogger.logLevel = config.loglevel
return rootLogger
} | javascript | {
"resource": ""
} |
q24212 | mongooseInit | train | function mongooseInit(mongoose, logger, config) {
const Log = logger.bind('mongoose-init')
mongoose.Promise = Promise
logUtil.logActionStart(
Log,
'Connecting to Database',
_.omit(config.mongo, ['pass'])
)
mongoose.connect(config.mongo.URI)
globals.mongoose = mongoose
Log.log('mongoose co... | javascript | {
"resource": ""
} |
q24213 | registerMrHorse | train | async function registerMrHorse(server, logger, config) {
const Log = logger.bind('register-MrHorse')
let policyPath = ''
if (config.enablePolicies) {
if (config.absolutePolicyPath === true) {
policyPath = config.policyPath
} else {
policyPath = __dirname.replace(
'node_modules/rest-h... | javascript | {
"resource": ""
} |
q24214 | registerHapiSwagger | train | async function registerHapiSwagger(server, logger, config) {
const Log = logger.bind('register-hapi-swagger')
let swaggerOptions = {
documentationPath: '/',
host: config.swaggerHost,
expanded: config.docExpansion,
swaggerUI: config.enableSwaggerUI,
documentationPage: config.enableSwaggerUI,
... | javascript | {
"resource": ""
} |
q24215 | train | function(model, query, mongooseQuery, logger) {
// This line has to come first
validationHelper.validateModel(model, logger)
const Log = logger.bind()
// (email == 'test@user.com' && (firstName == 'test2@user.com' || firstName == 'test4@user.com')) && (age < 15 || age > 30)
// LITERAL
// {
/... | javascript | {
"resource": ""
} | |
q24216 | train | function(model, logger) {
// This line has to come first
validationHelper.validateModel(model, logger)
let readableFields = []
let fields = model.schema.paths
for (let fieldName in fields) {
let field = fields[fieldName].options
if (!field.exclude && fieldName !== '__v') {
rea... | javascript | {
"resource": ""
} | |
q24217 | train | function(model, logger) {
// This line has to come first
validationHelper.validateModel(model, logger)
const Log = logger.bind()
let sortableFields = this.getReadableFields(model, Log)
for (let i = sortableFields.length - 1; i >= 0; i--) {
let descendingField = '-' + sortableFields[i]
... | javascript | {
"resource": ""
} | |
q24218 | train | function(model, logger) {
// This line has to come first
validationHelper.validateModel(model, logger)
let queryableFields = []
let fields = model.schema.paths
let fieldNames = Object.keys(fields)
let associations = model.routeOptions
? model.routeOptions.associations
: null
... | javascript | {
"resource": ""
} | |
q24219 | train | function(query, mongooseQuery, logger) {
const Log = logger.bind()
if (query.$page) {
mongooseQuery = this.setPage(query, mongooseQuery, Log)
} else {
mongooseQuery = this.setSkip(query, mongooseQuery, Log)
}
mongooseQuery = this.setLimit(query, mongooseQuery, Log)
return mongooseQ... | javascript | {
"resource": ""
} | |
q24220 | train | function(query, mongooseQuery, logger) {
if (query.$exclude) {
if (!Array.isArray(query.$exclude)) {
query.$exclude = query.$exclude.split(',')
}
mongooseQuery.where({ _id: { $nin: query.$exclude } })
delete query.$exclude
}
return mongooseQuery
} | javascript | {
"resource": ""
} | |
q24221 | train | function(query, model, logger) {
const Log = logger.bind()
if (query.$term) {
query.$or = [] // TODO: allow option to choose ANDing or ORing of searchFields/queryableFields
let queryableFields = this.getQueryableFields(model, Log)
let stringFields = this.getStringFields(model, Log)
// E... | javascript | {
"resource": ""
} | |
q24222 | train | function(query, mongooseQuery, logger) {
if (query.$sort) {
if (Array.isArray(query.$sort)) {
query.$sort = query.$sort.join(' ')
}
mongooseQuery.sort(query.$sort)
delete query.$sort
}
return mongooseQuery
} | javascript | {
"resource": ""
} | |
q24223 | getReference | train | function getReference(model, embed, logger) {
let property = model.schema.obj[embed]
while (_.isArray(property)) {
property = property[0]
}
if (property && property.ref) {
return {
model: property.ref,
include: { model: globals.mongoose.model(property.ref), as: embed }
}
} else {
r... | javascript | {
"resource": ""
} |
q24224 | train | function(model, type, logger) {
let routeScope = model.routeOptions.routeScope || {}
let rootScope = routeScope.rootScope
let scope = []
let additionalScope = null
switch (type) {
case 'create':
additionalScope = routeScope.createScope
break
case 'read':
additio... | javascript | {
"resource": ""
} | |
q24225 | showError | train | function showError(error) {
console.error(logSymbols.error, "Error");
console.error(`${error.message}\n`);
console.error(logSymbols.error, "Stack trace");
console.error(error.stack);
} | javascript | {
"resource": ""
} |
q24226 | parse | train | function parse(text) {
const ast = remark.parse(text);
const src = new StructuredSource(text);
traverse(ast).forEach(function(node) {
// eslint-disable-next-line no-invalid-this
if (this.notLeaf) {
if (node.type) {
const replacedType = SyntaxMap[node.type];
... | javascript | {
"resource": ""
} |
q24227 | createParagraph | train | function createParagraph(nodes) {
const firstNode = nodes[0];
const lastNode = nodes[nodes.length - 1];
return {
type: Syntax.Paragraph,
raw: nodes
.map(function(node) {
return node.raw;
})
.join(""),
range: [firstNode.range[0], las... | javascript | {
"resource": ""
} |
q24228 | parse | train | function parse(text) {
const textLineByLine = text.split(LINEBREAKE_MARK);
// it should be alternately Str and Break
let startIndex = 0;
const lastLineIndex = textLineByLine.length - 1;
const isLasEmptytLine = (line, index) => {
return index === lastLineIndex && line === "";
};
const... | javascript | {
"resource": ""
} |
q24229 | time | train | function time(cmd, runs, runNumber, results, cb) {
var start = process.hrtime();
exec(cmd, { silent: true }, function() {
var diff = process.hrtime(start),
actual = diff[0] * 1e3 + diff[1] / 1e6; // ms
results.push(actual);
echo("Performance Run #" + runNumber + ": %dms", a... | javascript | {
"resource": ""
} |
q24230 | getParents | train | function getParents(node) {
var result = [];
var parent = node.parent;
while (parent != null) {
result.push(parent);
parent = parent.parent;
}
return result;
} | javascript | {
"resource": ""
} |
q24231 | isNodeWrapped | train | function isNodeWrapped(node, types) {
var parents = getParents(node);
var parentsTypes = parents.map(function(parent) {
return parent.type;
});
return types.some(function(type) {
return parentsTypes.some(function(parentType) {
return parentType === type;
});
});
} | javascript | {
"resource": ""
} |
q24232 | cubism_graphiteParse | train | function cubism_graphiteParse(text) {
var i = text.indexOf("|"),
meta = text.substring(0, i),
c = meta.lastIndexOf(","),
b = meta.lastIndexOf(",", c - 1),
a = meta.lastIndexOf(",", b - 1),
start = meta.substring(a + 1, b) * 1000,
step = meta.substring(c + 1) * 1000;
return text
... | javascript | {
"resource": ""
} |
q24233 | prepare | train | function prepare(start1, stop) {
var steps = Math.min(size, Math.round((start1 - start) / step));
if (!steps || fetching) return; // already fetched, or fetching!
fetching = true;
steps = Math.min(size, steps + cubism_metricOverlap);
var start0 = new Date(stop - steps * step);
request(start0, st... | javascript | {
"resource": ""
} |
q24234 | beforechange | train | function beforechange(start1, stop1) {
if (!isFinite(start)) start = start1;
values.splice(0, Math.max(0, Math.min(size, Math.round((start1 - start) / step))));
start = start1;
stop = stop1;
} | javascript | {
"resource": ""
} |
q24235 | cubism_metricShift | train | function cubism_metricShift(request, offset) {
return function(start, stop, step, callback) {
request(new Date(+start + offset), new Date(+stop + offset), step, callback);
};
} | javascript | {
"resource": ""
} |
q24236 | expireSessionIDs | train | function expireSessionIDs(){
var tssec = Date.now();
var expired = [];
for(var sid in sessionIDs){
if(sessionIDs[sid] < (tssec + 500)){
expired.push(sid);
}
}
for(var i=0;i<expired.length;i++){
delete sessionIDs[expired[i]];
debug('Session ID expired: %s',... | javascript | {
"resource": ""
} |
q24237 | processOptions | train | function processOptions(options){
if(!options) return;
for(var op in swsUtil.supportedOptions){
if(op in options){
swsOptions[op] = options[op];
}
}
// update standard path
pathUI = swsOptions.uriPath+'/ui';
pathDist = swsOptions.uriPath+'/dist';
pathStats = sws... | javascript | {
"resource": ""
} |
q24238 | train | function (options) {
processOptions(options);
processor = new swsProcessor();
processor.init(swsOptions);
return function trackingMiddleware(req, res, next) {
// Respond to requests handled by swagger-stats
// swagger-stats requests will not be counted in stat... | javascript | {
"resource": ""
} | |
q24239 | getIPs | train | function getIPs(callback) {
if (typeof document === 'undefined' || typeof document.getElementById !== 'function') {
return;
}
var ipDuplicates = {};
//compatibility for firefox and chrome
var RTCPeerConnection = window.RTCPeerConnection || wi... | javascript | {
"resource": ""
} |
q24240 | getObject | train | function getObject() {
return objectPool.pop() || {
'array': null,
'cache': null,
'criteria': null,
'false': false,
'index': 0,
'null': false,
'number': null,
'object': null,
'push': null,
'string': null,
'true': false,
'undefined': false,
... | javascript | {
"resource": ""
} |
q24241 | releaseArray | train | function releaseArray(array) {
array.length = 0;
if (arrayPool.length < maxPoolSize) {
arrayPool.push(array);
}
} | javascript | {
"resource": ""
} |
q24242 | releaseObject | train | function releaseObject(object) {
var cache = object.cache;
if (cache) {
releaseObject(cache);
}
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
if (objectPool.length < maxPoolSize) {
objectPool.push(object);
}
} | javascript | {
"resource": ""
} |
q24243 | create | train | function create(prototype, properties) {
var result = baseCreate(prototype);
return properties ? assign(result, properties) : result;
} | javascript | {
"resource": ""
} |
q24244 | memoize | train | function memoize(func, resolver) {
if (!isFunction(func)) {
throw new TypeError;
}
var memoized = function() {
var cache = memoized.cache,
key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0];
return hasOwnProperty.call(cache, key)
... | javascript | {
"resource": ""
} |
q24245 | boolMatch | train | function boolMatch(s, matchers) {
var i, matcher, down = s.toLowerCase();
matchers = [].concat(matchers);
for (i = 0; i < matchers.length; i += 1) {
matcher = matchers[i];
if (!matcher) continue;
if (matcher.test && matcher.test(s)) return true;
if (matcher.toLowerCase() === down) re... | javascript | {
"resource": ""
} |
q24246 | compareArrays | train | function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length),
lengthDiff = Math.abs(array1.length - array2.length),
diffs = 0,
i;
for (i = 0; i < len; i++) {
if ((dontConvert && array1[i] !== array2[i]) ||
... | javascript | {
"resource": ""
} |
q24247 | getLangDefinition | train | function getLangDefinition(key) {
var i = 0, j, lang, next, split,
get = function (k) {
if (!languages[k] && hasModule) {
try {
require('./lang/' + k);
} catch (e) { }
}
return languages[k... | javascript | {
"resource": ""
} |
q24248 | makeGetterAndSetter | train | function makeGetterAndSetter(name, key) {
moment.fn[name] = moment.fn[name + 's'] = function (input) {
var utc = this._isUTC ? 'UTC' : '';
if (input != null) {
this._d['set' + utc + key](input);
moment.updateOffset(this);
return this;
... | javascript | {
"resource": ""
} |
q24249 | unformatNumeral | train | function unformatNumeral (n, string) {
var stringOriginal = string,
thousandRegExp,
millionRegExp,
billionRegExp,
trillionRegExp,
suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
bytesMultiplier = false,
power;
if (string.indexOf(':') > -1) {
n._value... | javascript | {
"resource": ""
} |
q24250 | multiplier | train | function multiplier(x) {
var parts = x.toString().split('.');
if (parts.length < 2) {
return 1;
}
return Math.pow(10, parts[1].length);
} | javascript | {
"resource": ""
} |
q24251 | correctionFactor | train | function correctionFactor() {
var args = Array.prototype.slice.call(arguments);
return args.reduce(function (prev, next) {
var mp = multiplier(prev),
mn = multiplier(next);
return mp > mn ? mp : mn;
}, -Infinity);
} | javascript | {
"resource": ""
} |
q24252 | dot | train | function dot(arr, arg) {
if (!isArray(arr[0])) arr = [ arr ];
if (!isArray(arg[0])) arg = [ arg ];
// convert column to row vector
var left = (arr[0].length === 1 && arr.length !== 1) ? jStat.transpose(arr) : arr,
right = (arg[0].length === 1 && arg.length !== 1) ? jStat.transpose(arg) : arg,
re... | javascript | {
"resource": ""
} |
q24253 | pow | train | function pow(arr, arg) {
return jStat.map(arr, function(value) { return Math.pow(value, arg); });
} | javascript | {
"resource": ""
} |
q24254 | aug | train | function aug(a, b) {
var newarr = a.slice(),
i = 0;
for (; i < newarr.length; i++) {
push.apply(newarr[i], b[i]);
}
return newarr;
} | javascript | {
"resource": ""
} |
q24255 | det | train | function det(a) {
var alen = a.length,
alend = alen * 2,
vals = new Array(alend),
rowshift = alen - 1,
colshift = alend - 1,
mrow = rowshift - alen + 1,
mcol = colshift,
i = 0,
result = 0,
j;
// check for special 2x2 case
if (alen === 2) {
return a[0][0] * a[1][1] -... | javascript | {
"resource": ""
} |
q24256 | train | function () {
if (this.done) {
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token,
match,
tempMatch,
index;
if (!this._more) {
this.yytext = '';
this.match = '';
... | javascript | {
"resource": ""
} | |
q24257 | train | function (type) {
var error = Exception.errors.filter(function (item) {
return item.type === type || item.output === type;
})[0];
return error ? error.output : null;
} | javascript | {
"resource": ""
} | |
q24258 | train | function (id) {
var filtered = instance.matrix.data.filter(function (cell) {
if (cell.deps) {
return cell.deps.indexOf(id) > -1;
}
});
var deps = [];
filtered.forEach(function (cell) {
if (deps.indexOf(cell.id) === -1) {
deps.push(ce... | javascript | {
"resource": ""
} | |
q24259 | train | function (id) {
var deps = getDependencies(id);
if (deps.length) {
deps.forEach(function (refId) {
if (allDependencies.indexOf(refId) === -1) {
allDependencies.push(refId);
var item = instance.matrix.getItem(refId);
if (item.deps.length) ... | javascript | {
"resource": ""
} | |
q24260 | train | function (element) {
var allDependencies = instance.matrix.getElementDependencies(element),
id = element.getAttribute('id');
allDependencies.forEach(function (refId) {
var item = instance.matrix.getItem(refId);
if (item && item.formula) {
var refElement = document.getEle... | javascript | {
"resource": ""
} | |
q24261 | train | function (formula, element) {
// to avoid double translate formulas, update item data in parser
var parsed = parse(formula, element),
value = parsed.result,
error = parsed.error,
nodeName = element.nodeName.toUpperCase();
instance.matrix.updateElementItem(element, {value... | javascript | {
"resource": ""
} | |
q24262 | train | function (element) {
var id = element.getAttribute('id'),
formula = element.getAttribute('data-formula');
if (formula) {
// add item with basic properties to data array
instance.matrix.addItem({
id: id,
formula: formula
});
calculateElementFor... | javascript | {
"resource": ""
} | |
q24263 | train | function (element) {
var id = element.getAttribute('id');
// on db click show formula
element.addEventListener('dblclick', function () {
var item = instance.matrix.getItem(id);
if (item && item.formula) {
item.formulaEdit = true;
element.value = '=' + item.formula... | javascript | {
"resource": ""
} | |
q24264 | train | function (cell) {
var num = cell.match(/\d+$/),
alpha = cell.replace(num, '');
return {
alpha: alpha,
num: parseInt(num[0], 10)
}
} | javascript | {
"resource": ""
} | |
q24265 | train | function (cell, counter) {
var alphaNum = instance.utils.getCellAlphaNum(cell),
alpha = alphaNum.alpha,
col = alpha,
row = parseInt(alphaNum.num + counter, 10);
if (row < 1) {
row = 1;
}
return col + '' + row;
} | javascript | {
"resource": ""
} | |
q24266 | train | function (cell, counter) {
var alphaNum = instance.utils.getCellAlphaNum(cell),
alpha = alphaNum.alpha,
col = instance.utils.toChar(parseInt(instance.utils.toNum(alpha) + counter, 10)),
row = alphaNum.num;
if (!col || col.length === 0) {
col = 'A';
}
var f... | javascript | {
"resource": ""
} | |
q24267 | train | function (formula, direction, delta) {
var type,
counter;
// left, right -> col
if (['left', 'right'].indexOf(direction) !== -1) {
type = 'col';
} else if (['up', 'down'].indexOf(direction) !== -1) {
type = 'row'
}
// down, up -> row
if (['down', 'ri... | javascript | {
"resource": ""
} | |
q24268 | train | function (cell) {
var num = cell.match(/\d+$/),
alpha = cell.replace(num, '');
return {
row: parseInt(num[0], 10) - 1,
col: instance.utils.toNum(alpha)
};
} | javascript | {
"resource": ""
} | |
q24269 | train | function (startCell, endCell, callback) {
var result = {
index: [], // list of cell index: A1, A2, A3
value: [] // list of cell value
};
var cols = {
start: 0,
end: 0
};
if (endCell.col >= startCell.col) {
cols = {
start: startCell.col,
... | javascript | {
"resource": ""
} | |
q24270 | train | function (type, exp1, exp2) {
var result;
switch (type) {
case '&':
result = exp1.toString() + exp2.toString();
break;
}
return result;
} | javascript | {
"resource": ""
} | |
q24271 | train | function (type, exp1, exp2) {
var result;
switch (type) {
case '=':
result = (exp1 === exp2);
break;
case '>':
result = (exp1 > exp2);
break;
case '<':
result = (exp1 < exp2);
break;
case '>=':
result =... | javascript | {
"resource": ""
} | |
q24272 | train | function (type, number1, number2) {
var result;
number1 = helper.number(number1);
number2 = helper.number(number2);
if (isNaN(number1) || isNaN(number2)) {
if (number1[0] === '=' || number2[0] === '=') {
throw Error('NEED_UPDATE');
}
throw Error('VALUE');
... | javascript | {
"resource": ""
} | |
q24273 | train | function (fn, args) {
fn = fn.toUpperCase();
args = args || [];
if (instance.helper.SUPPORTED_FORMULAS.indexOf(fn) > -1) {
if (instance.formulas[fn]) {
return instance.formulas[fn].apply(this, args);
}
}
throw Error('NAME');
} | javascript | {
"resource": ""
} | |
q24274 | train | function (args) {
args = args || [];
var str = args[0];
if (str) {
str = str.toUpperCase();
if (instance.formulas[str]) {
return ((typeof instance.formulas[str] === 'function') ? instance.formulas[str].apply(this, args) : instance.formulas[str]);
}
}
thr... | javascript | {
"resource": ""
} | |
q24275 | train | function (cell) {
var value,
fnCellValue = instance.custom.cellValue,
element = this,
item = instance.matrix.getItem(cell);
// check if custom cellValue fn exists
if (instance.utils.isFunction(fnCellValue)) {
var cellCoords = instance.utils.cellCoords(cell),
... | javascript | {
"resource": ""
} | |
q24276 | train | function (start, end) {
var fnCellValue = instance.custom.cellValue,
coordsStart = instance.utils.cellCoords(start),
coordsEnd = instance.utils.cellCoords(end),
element = this;
// iterate cells to get values and indexes
var cells = instance.utils.iterateCells.call(this, ... | javascript | {
"resource": ""
} | |
q24277 | train | function (id) {
id = id.replace(/\$/g, '');
return instance.helper.cellValue.call(this, id);
} | javascript | {
"resource": ""
} | |
q24278 | train | function (start, end) {
start = start.replace(/\$/g, '');
end = end.replace(/\$/g, '');
return instance.helper.cellRangeValue.call(this, start, end);
} | javascript | {
"resource": ""
} | |
q24279 | train | function (formula, element) {
var result = null,
error = null;
try {
parser.setObj(element);
result = parser.parse(formula);
var id;
if (element instanceof HTMLElement) {
id = element.getAttribute('id');
} else if (element && element.id) {
id = element.i... | javascript | {
"resource": ""
} | |
q24280 | train | function () {
instance = this;
parser = new FormulaParser(instance);
instance.formulas = Formula;
instance.matrix = new Matrix();
instance.custom = {};
if (rootElement) {
instance.matrix.scan();
}
} | javascript | {
"resource": ""
} | |
q24281 | train | function (connection, mechanisms) {
this.connection = connection;
this.transport = new Transport(connection.amqp_transport.identifier, SASL_PROTOCOL_ID, frames.TYPE_SASL, this);
this.next = connection.amqp_transport;
this.mechanisms = mechanisms;
this.mechanism = undefined;
this.outcome = undefi... | javascript | {
"resource": ""
} | |
q24282 | train | function(){
if (this.options.placeholder) return this.options.placeholder;
if (this.options.language){
var firstLanguage = this.options.language.split(",")[0];
var language = subtag.language(firstLanguage);
var localizedValue = localization.placeholder[language];
if (localizedValue) ret... | javascript | {
"resource": ""
} | |
q24283 | train | function(language){
var browserLocale = navigator.language || navigator.userLanguage || navigator.browserLanguage;
this.options.language = language || this.options.language || browserLocale;
return this;
} | javascript | {
"resource": ""
} | |
q24284 | train | function(selected){
// clean up any old marker that might be present
this._removeMarker();
var defaultMarkerOptions = {
color: '#4668F2'
}
var markerOptions = extend({}, defaultMarkerOptions, this.options.marker)
this.mapMarker = new this._mapboxgl.Marker(markerOptions);
this.mapMarker... | javascript | {
"resource": ""
} | |
q24285 | MapboxEventManager | train | function MapboxEventManager(options) {
this.origin = options.origin || 'https://api.mapbox.com';
this.endpoint = 'events/v2';
this.access_token = options.accessToken;
this.version = '0.2.0'
this.sessionID = this.generateSessionID();
this.userAgent = this.getUserAgent();
this.options = options;
this.sen... | javascript | {
"resource": ""
} |
q24286 | train | function(selected, geocoder){
var resultIndex = this.getSelectedIndex(selected, geocoder);
var payload = this.getEventPayload('search.select', geocoder);
payload.resultIndex = resultIndex;
payload.resultPlaceName = selected.place_name;
payload.resultId = selected.id;
if ((resultIndex === this.l... | javascript | {
"resource": ""
} | |
q24287 | train | function (payload, callback) {
if (!this.enableEventLogging) {
if (callback) return callback();
return;
}
var options = this.getRequestOptions(payload);
this.request(options, function(err){
if (err) return this.handleError(err, callback);
if (callback) {
return callback()... | javascript | {
"resource": ""
} | |
q24288 | train | function(payload){
if (!Array.isArray(payload)) payload = [payload];
var options = {
// events must be sent with POST
method: "POST",
host: this.origin,
path: this.endpoint + "?access_token=" + this.access_token,
headers: {
'Content-Type': 'application/json'
},
... | javascript | {
"resource": ""
} | |
q24289 | train | function (event, geocoder) {
var proximity;
if (!geocoder.options.proximity) proximity = null;
else proximity = [geocoder.options.proximity.longitude, geocoder.options.proximity.latitude];
var zoom = (geocoder._map) ? geocoder._map.getZoom() : null;
var payload = {
event: event,
created... | javascript | {
"resource": ""
} | |
q24290 | train | function (opts, callback) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 ) {
if (this.status == 204){
//success
return callback(null);
}else {
return callback(this.statusText);
}
}
};
... | javascript | {
"resource": ""
} | |
q24291 | train | function(selected, geocoder){
if (!geocoder._typeahead) return;
var results = geocoder._typeahead.data;
var selectedID = selected.id;
var resultIDs = results.map(function (feature) {
return feature.id;
});
var selectedIdx = resultIDs.indexOf(selectedID);
return selectedIdx;
} | javascript | {
"resource": ""
} | |
q24292 | train | function(options){
if (options.enableEventLogging === false) return false;
if (options.origin && options.origin.indexOf('api.mapbox.com') == -1) return false;
// hard to make sense of events when a local instance is suplementing results from origin
if (options.localGeocoder) return false;
// hard to... | javascript | {
"resource": ""
} | |
q24293 | train | function(){
if (this.eventQueue.length > 0){
this.send(this.eventQueue);
this.eventQueue = new Array();
}
// //reset the timer
if (this.timer) clearTimeout(this.timer);
if (this.flushInterval) this.timer = setTimeout(this.flush.bind(this), this.flushInterval)
} | javascript | {
"resource": ""
} | |
q24294 | train | function(evt, forceFlush){
this.eventQueue.push(evt);
if (this.eventQueue.length >= this.maxQueueSize || forceFlush){
this.flush();
}
} | javascript | {
"resource": ""
} | |
q24295 | buildConsoleLogger | train | function buildConsoleLogger (level = 'info') {
return function (api) {
return winston.createLogger({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.colorize(),
winston.format.printf(info => {
return `${api.id} @ ${info.timestamp} - ${info.level}:... | javascript | {
"resource": ""
} |
q24296 | getListeners | train | function getListeners(element) {
var id = idHandler.get(element);
if (id === undefined) {
return [];
}
return eventListeners[id] || [];
} | javascript | {
"resource": ""
} |
q24297 | addListener | train | function addListener(element, listener) {
var id = idHandler.get(element);
if(!eventListeners[id]) {
eventListeners[id] = [];
}
eventListeners[id].push(listener);
} | javascript | {
"resource": ""
} |
q24298 | getId | train | function getId(element) {
var state = getState(element);
if (state && state.id !== undefined) {
return state.id;
}
return null;
} | javascript | {
"resource": ""
} |
q24299 | setId | train | function setId(element) {
var state = getState(element);
if (!state) {
throw new Error("setId required the element to have a resize detection state.");
}
var id = idGenerator.generate();
state.id = id;
return id;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.