_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2500 | train | function(sourceOrProgram, filename) {
if (!(this instanceof MetaScript)) {
__version = Array.prototype.join.call(arguments, '.');
return;
}
// Whether constructing from a meta program or, otherwise, a source
var isProgram = (sourceOrProgram+="").... | javascript | {
"resource": ""
} | |
q2501 | evaluate | train | function evaluate(expr) {
if (expr.substring(0, 2) === '==') {
return 'write(JSON.stringify('+expr.substring(2).trim()+'));\n';
} else if (expr.substring(0, 1) === '=') {
return 'write('+expr.substring(1).trim()+');\n';
} else if (expr.substring(0, 3) ... | javascript | {
"resource": ""
} |
q2502 | append | train | function append(source) {
if (s === '') return;
var index = 0,
expr = /\n/g,
s,
match;
while (match = expr.exec(source)) {
s = source.substring(index, match.index+1);
if (s !== '') out.push(' write(\''+e... | javascript | {
"resource": ""
} |
q2503 | indent | train | function indent(str, indent) {
if (typeof indent === 'number') {
var indent_str = '';
while (indent_str.length < indent) indent_str += ' ';
indent = indent_str;
}
var lines = str.split(/\n/);
for (var i=0; i<lines.length; i+... | javascript | {
"resource": ""
} |
q2504 | include | train | function include(filename, absolute) {
filename = absolute
? filename
: __dirname + '/' + filename;
var _program = __program, // Previous meta program
_source = __source, // Previous source
_filename = __filename, // Previous ... | javascript | {
"resource": ""
} |
q2505 | escapestr | train | function escapestr(s) {
return s.replace(/\\/g, '\\\\')
.replace(/'/g, '\\\'')
.replace(/"/g, '\\"')
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n');
} | javascript | {
"resource": ""
} |
q2506 | __err2code | train | function __err2code(program, err) {
if (typeof err.stack !== 'string')
return indent(program, 4);
var match = /<anonymous>:(\d+):(\d+)\)/.exec(err.stack);
if (!match) {
return indent(program, 4);
}
var line = parseInt(match[1], ... | javascript | {
"resource": ""
} |
q2507 | train | function(callback) {
bootstrap(behaviour, (bootstrapErr, bootstrapRes) => {
if (bootstrapErr) api.emit("error", bootstrapErr);
if (bootstrapRes && bootstrapRes.virgin) {
bootstrapRes.connection.on("error", (err) => api.emit("error", err));
bootstrapRes.connection.on("close", (why) => api... | javascript | {
"resource": ""
} | |
q2508 | mkdirSync | train | function mkdirSync(dirPath) {
// Get relative path to output
const relativePath = dirPath.replace(`${CWD}${pathSep}`, '');
const dirs = relativePath.split(pathSep);
let currentDir = CWD;
// Check if each dir exists, and if not, create it
dirs.forEach(dir => {
currentDir = path.resolve(curre... | javascript | {
"resource": ""
} |
q2509 | train | function (values, options, callback) {
var deferred = Q.defer();
var args = ArgumentHelpers.prepareArguments(options, callback)
, wrapper = {};
options = args.options;
callback = Qext.makeNodeResolver(deferred, args.callback);
... | javascript | {
"resource": ""
} | |
q2510 | train | function (callback) {
var self = this;
var deferred = Q.defer();
callback = Qext.makeNodeResolver(deferred, callback);
var breakExec = {};
Async.waterfall([
function (next) {
if (!self.collectio... | javascript | {
"resource": ""
} | |
q2511 | train | function (arguments) {
var argData = ArgumentHelpers.prepareCallback(arguments);
var callback = argData.callback;
var args = argData.arguments;
if (callback) {
args.pop();
}
return args;
} | javascript | {
"resource": ""
} | |
q2512 | train | function (functionName, arguments) {
var self = this;
var args = self._getArgs(arguments);
var callback = self._getCallback(arguments);
return self._generic(functionName, args)
.nodeify(callback);
} | javascript | {
"resource": ""
} | |
q2513 | train | function (args) {
var shardKey = this.prototype.shardKey;
var query = !_.isUndefined(args[0]) ? args[0] : {};
var options = !_.isUndefined(args[1]) ? args[1] : {};
var ignoreShardKey = MemberHelpers.getPathPropertyValue(options, 'ignoreShardKey') ? true : ... | javascript | {
"resource": ""
} | |
q2514 | train | function(event) {
if (typeof event.touches != 'undefined' && event.touches.length > 0) {
var c = {
x: event.touches[0].pageX,
y: event.touches[0].pageY
};
} else {
var c = {
x: (event.pageX || (event.clientX + document.body.scrollLeft)),
y: (event.pageY || (ev... | javascript | {
"resource": ""
} | |
q2515 | train | function (bodySchemaModels, defName) {
for (var i in bodySchemaModels) {
if (bodySchemaModels[i]["name"] == defName) {
return bodySchemaModels[i];
}
}
return null;
} | javascript | {
"resource": ""
} | |
q2516 | train | function (values, schema) {
var publicList = find(schema, 'public')
, arrElem;
for (var value in values) {
if (publicList[value]) {
if (_.isArray(publicList[value])) {
for (var thisArrayElem in publicList[value]) {
if (!_.isArray(values[value]))... | javascript | {
"resource": ""
} | |
q2517 | train | function (values, schema, options) {
var virtualList = find(schema, 'virtual');
//Set default value for virtual if not exists in values
if (options && options.query === true) {
}
else {
for (var virtual in virtualList) {
if (_.isArray(virtualList[virtual])) {
f... | javascript | {
"resource": ""
} | |
q2518 | train | function (model, filter, value) {
if (!_.isString(filter)) {
return null;
}
if (model.data) {
var list = findKeys(model.data, filter)
, values = [];
for (var res in list) {
if (value === undefined || list[res][filter] === value) {
values.pu... | javascript | {
"resource": ""
} | |
q2519 | train | function (schema) {
var extendList = find(schema, 'extend');
for (var extendElem in extendList) {
if (extendList[extendElem] && extendList[extendElem].extend && _.isFunction(extendList[extendElem].extend)) {
schema[extendElem] = extendList[extendElem].extend();
}
}
return sc... | javascript | {
"resource": ""
} | |
q2520 | name | train | function name(fp, options) {
var opts = options || {};
if (typeof opts.namespace === 'function') {
return opts.namespace(fp, opts);
}
if (typeof opts.namespace === false) {
return fp;
}
var ext = path.extname(fp);
return path.basename(fp, ext);
} | javascript | {
"resource": ""
} |
q2521 | read | train | function read(fp, opts) {
if (opts && opts.read) {
return opts.read(fp, opts);
}
return readData.call(this, fp, opts);
} | javascript | {
"resource": ""
} |
q2522 | readData | train | function readData(fp, options) {
// shallow clone options
var opts = utils.extend({}, options);
// get the loader for this file.
var ext = opts.lang || path.extname(fp);
if (ext && ext.charAt(0) !== '.') {
ext = '.' + ext;
}
if (!this.dataLoaders.hasOwnProperty(ext)) {
return this.dataLoader('read... | javascript | {
"resource": ""
} |
q2523 | train | function() {
if (common.inlinescripts.length > 0) {
var script_text = '';
for (var i = 0; i < common.inlinescripts.length; i++) {
if (!common.inlinescripts[i] || typeof common.inlinescripts[i] == 'undefined')
continue;
else
script_text += common.inlines... | javascript | {
"resource": ""
} | |
q2524 | saveObjectToJSON | train | function saveObjectToJSON(filePath, data) {
try {
data = JSON.stringify(data, null, 2);
writeFileSync(filePath, data, { encoding: 'utf8' });
return true;
} catch(ex) {
console.warn('Unable to save class JSON');
return false;
}
// NOTE: ASYNC REQUIRES PROMISIFYING ALL OPERA... | javascript | {
"resource": ""
} |
q2525 | assertObject | train | function assertObject(attr, data) {
if (data === null || data === undefined) {
return null;
}
if (typeof data !== 'object' || Array.isArray(data)) {
throw new ParseError(`Attribute ${attr} must be of type "object"`);
}
return data;
} | javascript | {
"resource": ""
} |
q2526 | assertArray | train | function assertArray(attr, data, type) {
if (data === null || data === undefined) {
return [];
}
if (!Array.isArray(data)) {
throw new ParseError(`Attribute ${attr} must be of type "array"`);
}
const clone = [];
for (const d of data) {
if (d !== undefined && d !== null) {
if (typeof d !... | javascript | {
"resource": ""
} |
q2527 | assertUniTypeObject | train | function assertUniTypeObject(attr, data, type) {
data = assertObject(attr, data);
if (data === null) {
return null;
}
Object.keys(data).forEach(key => {
if (type === undefined) {
type = typeof data[key];
}
type = type.toLowerCase();
let msg = `Attribute ${attr} must be of type "obje... | javascript | {
"resource": ""
} |
q2528 | assertString | train | function assertString(attr, data) {
if (data === null || data === undefined) {
return null;
}
if (typeof data !== 'string') {
throw new ParseError(`Attribute ${attr} must be of type "string"`);
}
return data;
} | javascript | {
"resource": ""
} |
q2529 | train | function (values, model, type) {
var deferred = Q.defer();
var modelData = {data: model};
ModelValidator.validate(values, modelData, function (err, data) {
deferred.resolve({data: data, err: err, type: type});
});
return deferred.promise;
} | javascript | {
"resource": ""
} | |
q2530 | train | function (req, controller) {
var parameters = [];
if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.header) {
parameters.push(_checkValues(req.headers, controller.conditions.parameters.header, "header"))
}
if (controller.condit... | javascript | {
"resource": ""
} | |
q2531 | train | function (req, res, next) {
var hostId = req.miajs.route.hostId;
var url = req.miajs.route.url;
var prefix = req.miajs.route.prefix;
var method = req.miajs.route.method;
var group = req.miajs.route.group;
var version = req.miajs.route.version;
var registeredServic... | javascript | {
"resource": ""
} | |
q2532 | train | function () {
Shared.initialize('/config', process.argv[2]);
Shared.setAppHttp(appHttp);
Shared.setAppHttps(appHttps);
Shared.setExpress(express);
// Init memcached
var memcached = Shared.memcached();
// Init redis cache
var redis = Shared.redis(true);
... | javascript | {
"resource": ""
} | |
q2533 | train | function (initFunction) {
if (_.isFunction(initFunction)) {
Logger.info("Run init function");
_customInitFuncton = initFunction;
return initFunction(appHttp)
.then(function () {
return initFunction(appHttps);
});
}
... | javascript | {
"resource": ""
} | |
q2534 | train | function () {
//set logger
if (!module.parent) {
appHttp.use(morgan({format: 'dev'}));
appHttps.use(morgan({format: 'dev'}));
}
return Q();
} | javascript | {
"resource": ""
} | |
q2535 | train | function (host, reInit) {
if (_.isEmpty(host.id) || !_.isString(host.id)) {
throw new Error("Host configuration is invalid. Host id is missing or not a string");
}
if (_.isEmpty(host.host)) {
throw new Error("Host configuration is invalid. Host is missing");
}
... | javascript | {
"resource": ""
} | |
q2536 | train | function (reInit = false) {
//load routes
var environment = Shared.config("environment");
var hosts = environment.hosts;
if (hosts) {
if (!_.isArray(hosts)) {
hosts = [hosts];
}
for (var host in hosts) {
_parseHosts(host... | javascript | {
"resource": ""
} | |
q2537 | train | function () {
const cronJobsToStart = _getNamesOfCronJobsToStart();
if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) {
return CronJobManagerJob.startListening().then(function () {
Logger.tag('Cron').info('Cron Job Manager is started. S... | javascript | {
"resource": ""
} | |
q2538 | train | function () {
const crons = _.get(Shared, 'runtimeArgs.cron') || _.get(Shared, 'runtimeArgs.crons');
if (crons) {
const cronTasks = crons.replace(/\s/g, '').split(',');
return cronTasks.length > 0 ? cronTasks : undefined;
}
return undefined;
} | javascript | {
"resource": ""
} | |
q2539 | setResponsive | train | function setResponsive(name) {
if (name) {
setResponsiveComponents.call(this, name);
} else {
_utils2["default"].forEach(Object.keys(this._component), (function (name) {
setResponsiveComponents.call(this, name);
}).bind(this));
}
if (_utils2["default"].isUndefined(na... | javascript | {
"resource": ""
} |
q2540 | loadDefault | train | function loadDefault() {
return {
port: 8000,
host: '127.0.0.1',
root: './',
logFormat: 'combined',
middlewares: [
{
name: 'cors',
cfg: {
origin: true
}
},
{
name: 'morgan',
cfg: {}
},
{
name: 'serveStatic',
... | javascript | {
"resource": ""
} |
q2541 | loadFromFile | train | function loadFromFile(filename) {
var cfg = {}
Object.assign(
cfg,
loadDefault(),
JSON.parse(fs.readFileSync(filename))
)
return cfg
} | javascript | {
"resource": ""
} |
q2542 | saveToFile | train | function saveToFile(filename, cfg) {
// Use 'wx' flag to fails if filename exists
fs.writeFileSync(filename, JSON.stringify(cfg, null, 2), {flag: 'wx'})
} | javascript | {
"resource": ""
} |
q2543 | loadFromOptions | train | function loadFromOptions(opts) {
var defCfg = loadDefault()
var cfg = opts.config ? loadFromFile(opts.config) : loadDefault()
// Command line config override file loaded config
for (var k in opts) {
defCfg.hasOwnProperty(k) && (defCfg[k] !== opts[k] && (cfg[k] = opts[k]))
}
return cfg
} | javascript | {
"resource": ""
} |
q2544 | train | function (options, iterationInfo) {
var files;
var modules = {};
var result = {};
// remember the starting directory
try {
files = fs.readdirSync(iterationInfo.dirName);
} catch (e) {
if (options.optional)
return {};
el... | javascript | {
"resource": ""
} | |
q2545 | train | function (options, iterationInfo, modules) {
// filename filter
if (options.fileNameFilter) {
var match = iterationInfo.fileName.match(options.fileNameFilter);
if (!match) {
return;
}
}
// Filter spec.js files
var match = itera... | javascript | {
"resource": ""
} | |
q2546 | train | function (modules, options, iterationInfo) {
// load module into memory (unless `dontLoad` is true)
var module = true;
//default is options.dontLoad === false
if (options.dontLoad !== true) {
//if module is to be loaded
module = require(iterationInfo.absoluteFul... | javascript | {
"resource": ""
} | |
q2547 | train | function (options, iterationInfo) {
// Use the identity for the key name
var identity;
if (options.mode === 'list') {
identity = iterationInfo.relativeFullPath;
//identity = identity.toLowerCase();
//find and replace all containments of '/', ':' and '\' within... | javascript | {
"resource": ""
} | |
q2548 | train | function (options, iterationInfo, modules) {
// Ignore explicitly excluded directories
if (options.excludeDirs) {
var match = iterationInfo.fileName.match(options.excludeDirs);
if (match)
return;
}
// Recursively call requireAll on each child dir... | javascript | {
"resource": ""
} | |
q2549 | train | function (level, message, tag, data) {
var env = Shared.config('environment');
var levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'];
var logLevelConfig = env.logLevel || "info";
if (logLevelConfig == "none") {
return;
}
var logLevel = levels.in... | javascript | {
"resource": ""
} | |
q2550 | train | function (obj, tag) {
tag = _.isArray(tag) ? tag.join(',') : tag;
tag = !_.isEmpty(tag) ? tag.toLowerCase() : 'default';
obj.trace = function (message, data) {
_logEvent("trace", message, tag, data);
};
obj.debug = function (message, data) {
_logEvent("d... | javascript | {
"resource": ""
} | |
q2551 | expandField | train | function expandField(input, grunt){
var get = pointer(input);
return function(memo, fin, fout){
if(_.isString(fin)){
var match = fin.match(re.PATH_POINT);
// matched ...with a `$.` ...but not with a `\`
if(match && match[3] === '$.' && !match[1]){
// field name, starts with an ... | javascript | {
"resource": ""
} |
q2552 | action_handler | train | async function action_handler(req, h) {
const data = req.payload
const json = 'string' === typeof data ? tu.parseJSON(data) : data
if (json instanceof Error) {
throw json
}
const seneca = prepare_seneca(req, json)
const msg = tu.internalize_msg(seneca, json)
return await new Promise(... | javascript | {
"resource": ""
} |
q2553 | train | function () {
return ServerHeartbeatModel.find({
status: _statusActive
}).then(function (cursor) {
return Q.ninvoke(cursor, 'toArray').then(function (servers) {
var serverIds = [];
servers.map(function (value) {
serverIds.push(v... | javascript | {
"resource": ""
} | |
q2554 | train | function( input, chunk, context ){
// return given input if there is no dust reference to resolve
var output = input;
// dust compiles a string to function, if there are references
if( typeof input === "function"){
if( ( typeof input.isReference !== "undefined" ) && ( input.isReference === true ) ... | javascript | {
"resource": ""
} | |
q2555 | compactBuffers | train | function compactBuffers(context, node) {
var out = [node[0]], memo;
for (var i=1, len=node.length; i<len; i++) {
var res = dust.filterNode(context, node[i]);
if (res) {
if (res[0] === 'buffer') {
if (memo) {
memo[1] += res[1];
} else {
memo = res;
out.push... | javascript | {
"resource": ""
} |
q2556 | thisModule | train | function thisModule() {
var self = this;
/**
* Generate random hash value
* @returns {*}
*/
self.getClientIP = function (req) {
req = req || {};
req.connection = req.connection || {};
req.socket = req.socket || {};
req.client = req.client || {};
var ip... | javascript | {
"resource": ""
} |
q2557 | train | function (el, cls) {
cls = getString(cls);
if (!cls) return;
if (Array.isArray(cls)) {
cls.forEach(function(c) {
dom.addClass(el, c);
});
} else if (el.classList) {
el.classList.add(cls);
} else {
if (!hasClass(el, c... | javascript | {
"resource": ""
} | |
q2558 | train | function(name, container, args, events) {
/* handling for any default values if args are not specified */
var mergeDefaults = function(args, defaults) {
var args = args || {};
if (typeof defaults == 'object') {
for (var key in defaults) {
if (elation.utils.isNull(args[... | javascript | {
"resource": ""
} | |
q2559 | train | function(description) {
// Look for triple backtick code blocks flagged as `glimmer`;
// define end of block as triple backticks followed by a newline
let matches = description.match(/(```glimmer)(.|\n)*?```/gi);
if (matches && matches.length) {
matches.map(codeBlock => {
let blockEnd = codeBlock.len... | javascript | {
"resource": ""
} | |
q2560 | obMerge | train | function obMerge(prefix, ob1, ob2 /*, ...*/)
{
for (var i=2; i<arguments.length; ++i)
{
for (var nm in arguments[i])
{
if (arguments[i].hasOwnProperty(nm) || typeof arguments[i][nm] == 'function')
{
if (typeof(arguments[i][... | javascript | {
"resource": ""
} |
q2561 | train | function(e, s)
{
var parens = [];
e.tree.push(parens);
parens.parent = e.tree;
e.tree = parens;
} | javascript | {
"resource": ""
} | |
q2562 | train | function(done) {
return {
success: function(res) {
done(null, res);
},
error: function(res, err) {
done(err);
}
};
} | javascript | {
"resource": ""
} | |
q2563 | add | train | function add(base, addend) {
if (util.isDate(base)) {
return new Date(base.getTime() + interval(addend));
}
return interval(base) + interval(addend);
} | javascript | {
"resource": ""
} |
q2564 | renderSass | train | function renderSass(options) {
return new Promise((resolve, reject) => {
try {
// using synchronous rendering because it is faster
let result = sass.renderSync(options);
result.css = fixEOF(result.css);
resolve(result);
} catch(err) {
reject(err);
}
});
} | javascript | {
"resource": ""
} |
q2565 | train | function(obj) {
if (obj.anchor) {
// obj is a plane or line
var P = this.elements.slice();
var C = obj.pointClosestTo(P).elements;
return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))]);
} else {
// obj is a point
var Q = obj.e... | javascript | {
"resource": ""
} | |
q2566 | train | function(obj) {
if (obj.normal) {
// obj is a plane
var A = this.anchor.elements, D = this.direction.elements;
var A1 = A[0], A2 = A[1], A3 = A[2], D1 = D[0], D2 = D[1], D3 = D[2];
var newA = this.anchor.reflectionIn(obj).elements;
// Add the line's direction vector to its anchor... | javascript | {
"resource": ""
} | |
q2567 | getChanges | train | function getChanges(log, regex) {
var changes = [];
var match;
while ((match = regex.exec(log))) {
var change = '';
for (var i = 1, len = match.length; i < len; i++) {
change += match[i];
}
changes.push(change.trim());
}
return changes;
} | javascript | {
"resource": ""
} |
q2568 | getChangelog | train | function getChangelog(log) {
var data = {
date: moment().format('YYYY-MM-DD'),
features: getChanges(log, options.featureRegex),
fixes: getChanges(log, options.fixRegex)
};
return template(data);
} | javascript | {
"resource": ""
} |
q2569 | writeChangelog | train | function writeChangelog(changelog) {
var fileContents = null;
var firstLineFile = null;
var firstLineFileHeader = null;
var regex = null;
if (options.insertType && grunt.file.exists(options.dest)) {
fileContents = grunt.file.read(options.dest);
firstLineFile = fileContents... | javascript | {
"resource": ""
} |
q2570 | train | function (preconditions) {
var errorCodesList = {
"500": ["InternalServerError"],
"400": [
"UnexpectedDefaultValue",
"UnexpectedType",
"MinLengthUnderachieved",
"MaxLengthExceeded",
"MinValueUnderachived",
... | javascript | {
"resource": ""
} | |
q2571 | train | function (attr, attrName) {
if (_.isObject(attr) && !_.isDate(attr) && !_.isBoolean(attr) && !_.isString(attr) && !_.isNumber(attr) && !_.isFunction(attr) && !_.isRegExp(attr) && !_.isArray(attr)) {
//attr = _removeAttributes();
for (var aIndex in attr) {
... | javascript | {
"resource": ""
} | |
q2572 | train | function (parametersList, parameters, section) {
if (parameters[section]) {
for (var name in parameters[section]) {
var addCondition = parameters[section][name];
if (parametersList[section] && parametersList[section][name]) {
/... | javascript | {
"resource": ""
} | |
q2573 | train | function (req, res, next) {
if (!req.miajs.controllerDebugInfo) {
req.miajs.controllerDebugInfo = {};
}
if (controller.name && controller.version) {
req.miajs.controllerDebugInfo[controller.name + '_' + controller.version] = {'runtime': Date.now() - re... | javascript | {
"resource": ""
} | |
q2574 | train | function (routeConfig, methodValue) {
var rateLimits = [];
var environment = Shared.config("environment");
var globalRateLimit = environment.rateLimit;
if (globalRateLimit) {
if (globalRateLimit.interval && _.isNumber(globalRateLimit.interval) && parseInt(globalRateLimit.inte... | javascript | {
"resource": ""
} | |
q2575 | train | function (req, res, next) {
var ip = IPAddressHelper.getClientIP(req)
, route = req.miajs.route
, key = ip + route.path + route.method;
if (_.isEmpty(route.rateLimits)) {
next();
return;
}
RateLimiter.checkRateLimitsByKey(key, route.rateL... | javascript | {
"resource": ""
} | |
q2576 | train | function (range) {
var coeff = 1000 * 60 * range;
return new Date(Math.ceil(new Date(Date.now()).getTime() / coeff) * coeff).getTime() / 1000;
} | javascript | {
"resource": ""
} | |
q2577 | train | function (key, timeInterval, limit) {
//Validate rate limiter settings
if (!_.isNumber(timeInterval) || parseInt(timeInterval) <= 0 || !_.isNumber(limit) || parseInt(limit) <= 0) {
return Q.reject();
}
var cacheKey = Encryption.md5("MiaJSRateLimit" + key + _calculateCurrentTi... | javascript | {
"resource": ""
} | |
q2578 | train | function (key, intervalSize, limit) {
var deferred = Q.defer()
, memcached = Shared.memcached();
if (!memcached) {
deferred.reject();
}
else {
//Get current rate for ip
memcached.get(key, function (err, value) {
if (err) {
... | javascript | {
"resource": ""
} | |
q2579 | train | function(e, win) {
var event = $.event.get(e, win);
var wheel = $.event.getWheel(event);
that.handleEvent('MouseWheel', e, win, wheel);
} | javascript | {
"resource": ""
} | |
q2580 | $E | train | function $E(tag, props) {
var elem = document.createElement(tag);
for(var p in props) {
if(typeof props[p] == "object") {
$.extend(elem[p], props[p]);
} else {
elem[p] = props[p];
}
}
if (tag == "canvas" && !supportsCanvas && G_vmlCanvasManager) {
elem = G_vmlCanv... | javascript | {
"resource": ""
} |
q2581 | getNodesToHide | train | function getNodesToHide(node) {
node = node || this.clickedNode;
if(!this.config.constrained) {
return [];
}
var Geom = this.geom;
var graph = this.graph;
var canvas = this.canvas;
var level = node._depth, nodeArray = [];
graph.eachNode(function(n) {
if(n... | javascript | {
"resource": ""
} |
q2582 | getNodesToShow | train | function getNodesToShow(node) {
var nodeArray = [], config = this.config;
node = node || this.clickedNode;
this.clickedNode.eachLevel(0, config.levelsToShow, function(n) {
if(config.multitree && !('$orn' in n.data)
&& n.anySubnode(function(ch){ return ch.exist && !ch.d... | javascript | {
"resource": ""
} |
q2583 | SubStream | train | function SubStream(stream, name, options) {
if (!(this instanceof SubStream)) return new SubStream(stream, name, options);
options = options || {};
this.readyState = stream.readyState; // Copy the current readyState.
this.stream = stream; // The underlaying stream.
this.name = nam... | javascript | {
"resource": ""
} |
q2584 | fallBack | train | function fallBack () {
var programFilesVar = "ProgramFiles";
if (arch === "(64)") {
console.warn("You are using 32-bit version of Firefox on 64-bit versions of the Windows.\nSome features may not work correctly in this version. You should upgrade Firefox to the latest 64-bit version now!")
p... | javascript | {
"resource": ""
} |
q2585 | listen | train | function listen(event, spark) {
if ('end' === event) return function end() {
if (!spark.streams) return;
for (var stream in spark.streams) {
stream = spark.streams[stream];
if (stream.end) stream.end();
}
};
if ('readyStateChange' === event) return function change(reason)... | javascript | {
"resource": ""
} |
q2586 | createLoggerStream | train | function createLoggerStream(name, level, logglyConfig) {
const streams = [process.stdout];
if (logglyConfig.enabled) {
const logglyStream = new LogglyStream({
token: logglyConfig.token,
subdomain: logglyConfig.subdomain,
name,
environment: logglyConfig.env... | javascript | {
"resource": ""
} |
q2587 | confChanged | train | function confChanged(current, proposed) {
if (stringify(current.conf) !== stringify(proposed.conf)) {
if (current.version >= proposed.version) {
const e = new Error('Schema change, but no version increment.');
e.current = current;
e.proposed = proposed;
throw ... | javascript | {
"resource": ""
} |
q2588 | validatePropertyType | train | function validatePropertyType(property, type, recursive) {
return type && (
(recursive && typeof property === 'object') ||
(type === 'string' && typeof property === 'string') ||
(type === 'number' && typeof property === 'number') ||
(type === 'uuid' && isUuid(property)) ||
(t... | javascript | {
"resource": ""
} |
q2589 | parseObject | train | function parseObject(obj, { name, path, subPaths, type, recursive = true, ...args }) {
let property = get(obj, path);
if (property === null || !validatePropertyType(property, type, recursive)) {
return [];
}
if (type === 'uuidList' && isUuidList(property)) {
return [{ [name]: property.sp... | javascript | {
"resource": ""
} |
q2590 | Entry | train | function Entry(name, hash, status, mode, deed, registrationDate, value, highestBid) {
// TODO: improve Entry constructor so that unknown names can be handled via getEntry
this.name = name;
this.hash = hash;
this.status = status;
this.mode = mode;
this.deed = deed;
this.registrationDate = registrationDate;... | javascript | {
"resource": ""
} |
q2591 | skip | train | function skip(ignoreRouteUrls) {
return function ignoreUrl(req) {
const url = req.originalUrl || req.url;
return ignoreRouteUrls.includes(url);
};
} | javascript | {
"resource": ""
} |
q2592 | omit | train | function omit(req, blacklist) {
return omitBy(req, (value, key) => blacklist.includes(key));
} | javascript | {
"resource": ""
} |
q2593 | morganMiddleware | train | function morganMiddleware(req, res, next) {
const { ignoreRouteUrls, includeReqHeaders, omitReqProperties } = getConfig('logger');
const { format } = getConfig('logger.morgan');
// define custom tokens
morgan.token('operation-hash', request => get(request, 'body.extensions.persistentQuery.sha256Hash'));... | javascript | {
"resource": ""
} |
q2594 | getConfig | train | function getConfig(config) {
// Read a RESTBase configuration from a (optional) path argument, an (optional) CONFIG
// env var, or from /etc/restbase/config.yaml
var conf;
if (config) {
conf = config;
} else if (process.env.CONFIG) {
conf = process.env.CONFIG;
} else {
c... | javascript | {
"resource": ""
} |
q2595 | train | function (name) {
var octave = null;
name = prepareNoteName(name);
// Extract octave number if given
if (/\d$/.test(name)) {
octave = parseInt(name.slice(-1));
name = name.slice(0, -1);
}
// Throw an error for an invalid note name
if (!(/^[A-Ga-g](bb|##|[b#n])?$/).test(name)) {
throw new E... | javascript | {
"resource": ""
} | |
q2596 | train | function (note, number) {
var letter = note.letter;
var index = scale.indexOf(note.letter);
var newIndex = mod(index + number - 1, scale.length);
assert(index > -1);
assert(newIndex > -1 && newIndex < scale.length);
return scale[newIndex];
} | javascript | {
"resource": ""
} | |
q2597 | train | function (letter1, letter2) {
var index1 = scale.indexOf(letter1);
var index2 = scale.indexOf(letter2);
var distance = mod(index2 - index1, scale.length) + 1;
assert(index1 > -1);
assert(index2 > -1);
assert(distance > 0 && distance <= scale.length);
return distance;
} | javascript | {
"resource": ""
} | |
q2598 | train | function (int) {
var map = interval.isPerfect(int.number) ? perfectOffsets : majorOffsets;
var key = _.invert(map)[int.quality];
return parseInt(key, 10);
} | javascript | {
"resource": ""
} | |
q2599 | train | function (number, halfSteps) {
var diatonicHalfSteps = getDiatonicHalfSteps(number);
var halfStepOffset = halfSteps - diatonicHalfSteps;
// Handle various abnormalities
if (halfStepOffset === 11) halfStepOffset = -1;
if (halfStepOffset === -11) halfStepOffset = 1;
return halfStepOffset;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.