_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q37800 | coord | train | function coord(coordOrColumn, row) {
if (arguments.length == 1) { // copy incoming coord object
return {
column: coordOrColumn.column,
row: coordOrColumn.row
};
} else if (arguments.length == 2) { // create coord object
return {
column: coordOrColumn,
row: row
};
}
} | javascript | {
"resource": ""
} |
q37801 | calcDirection | train | function calcDirection(start, end) {
var direction = new Vec2(end);
direction.subtract(start);
direction.normalize();
return direction;
} | javascript | {
"resource": ""
} |
q37802 | train | function(newAction) {
// ignore init and feedback actions
if (newAction.type === "init" || newAction.type === "feedback") { return; }
var action = parson.whatWeDidPreviously();
// if we have been here before (action not undefined) and more than one line in solution...
if (action && action.output && ... | javascript | {
"resource": ""
} | |
q37803 | train | function(title, message, callback, options) {
var buttons = {};
buttons[options?(options.buttonTitle || "OK"):"OK"] = function() {
$(this).dialog( "close" );
};
var opts = $.extend(true,
{ buttons: buttons,
modal: true,
ti... | javascript | {
"resource": ""
} | |
q37804 | train | function(duration) {
$("#header").addClass("timer");
$("#timer").show().animate({width: "100%"}, duration, function() {
$("#header").removeClass("timer");
$("#timer").hide().css({width: "0"});
});
} | javascript | {
"resource": ""
} | |
q37805 | train | function(feedback) {
var isCorrect = ($.isArray(feedback) && feedback.length === 0) ||
('feedback' in feedback && feedback.success);
// correctly solved but collection has more exercises
if (isCorrect && $.isFunction(PARSONS_SETTINGS.next)) {
$("#ul-sortable").sortable("destroy");... | javascript | {
"resource": ""
} | |
q37806 | train | function (events, func) {
for (var i = 0; i < events.length; i++) {
obj.once(events[i], func)
listeners[events[i]] = func
}
} | javascript | {
"resource": ""
} | |
q37807 | max | train | function max(array) {
var length = array.length;
if (length === 0) {
return 0;
}
var index = -1;
var result = array[++index];
while (++index < length) {
if (array[index] > result) {
result = array[index];
}
}
return result;
} | javascript | {
"resource": ""
} |
q37808 | buildRoutes | train | function buildRoutes(obj) {
var routes = obj.http;
if (routes && !Array.isArray(routes)) {
routes = [routes];
}
// overidden
if (routes) {
// patch missing verbs / routes
routes.forEach(function (r) {
r.verb = String(r.verb || 'all').toLowerCase();
r... | javascript | {
"resource": ""
} |
q37809 | create2x2 | train | function create2x2(a, b, c, d){
if (undef(a)) throw new Error("At least one argument must be provided.");
if (undef(b)){
// Everything = a
b = a;
c = a;
d = a;
}
else{
// we have a and b
if(undef(c)){
c = a;
d = b;
}
... | javascript | {
"resource": ""
} |
q37810 | drillRec | train | function drillRec(v){
const next = v.get(0);
if(v.length > 1 || !isAVector(next)) return v;
return drillRec(next);
} | javascript | {
"resource": ""
} |
q37811 | mapToValues | train | function mapToValues(v){
function mapRec(e){
if(!isAVector(e)) return e;
return mapRec(e.get(0));
}
return v.map(mapRec);
} | javascript | {
"resource": ""
} |
q37812 | lazy | train | function lazy(arg) {
var conf = this.configure();
var action = arg.action();
if(!conf.command.dir || action !== undefined) return false;
var file = path.join(conf.command.dir, getModulePath.call(this, arg))
try{
action = require(file);
if(typeof action !== 'function') {
return this.raise(this.er... | javascript | {
"resource": ""
} |
q37813 | rewriteRequires | train | function rewriteRequires (filename) {
var basedir = path.dirname(filename)
return wrapListener(
function (nodePath) {
if (nodePath.isLiteral() && !path.isAbsolute(nodePath.node.value)) {
var match = nodePath.node.value.match(/^compile!(.+)$/)
nodePath.node.value = match
... | javascript | {
"resource": ""
} |
q37814 | ActivityPoller | train | function ActivityPoller(name, domain, options) {
if (!(this instanceof ActivityPoller)) {
return new ActivityPoller(name, domain, options);
}
events.EventEmitter.call(this);
if (!_.isString(name)) {
throw new Error('A `name` is required');
}
if (!_.isString(domain)) {
throw new Error('A `doma... | javascript | {
"resource": ""
} |
q37815 | train | function(obj, method_name, force_call_after = 1000){
if(typeof obj[method_name] != 'function') throw new TypeError("collateCalls(): Not a method '"+method_name+ "' on "+obj.toString())
var original_fn = obj[method_name],
scheduled_runs = {}
function requestRun(...args){
var str = JSON.stringify(args... | javascript | {
"resource": ""
} | |
q37816 | train | function() {
singulars = {};
for (var k in plurals) {
if (!plurals.hasOwnProperty(k)) continue;
singulars[plurals[k]] = k;
}
} | javascript | {
"resource": ""
} | |
q37817 | execute | train | function execute(req, res) {
ScriptManager.evalsha(req, res, '' + req.args[0], req.args.slice(1));
} | javascript | {
"resource": ""
} |
q37818 | send | train | function send(data, cb) {
if (enabled) {
var send_data = new Buffer(data);
try {
socket.send(send_data, 0, send_data.length, port, host, function(err, bytes) {
if (cb) {
return cb(err, bytes);
}
});
} catch (x) {
// Purposely ignored..
... | javascript | {
"resource": ""
} |
q37819 | codeGenerator | train | async function codeGenerator(length = 6) {
const code = new Array(length)
.fill('0')
.map(() => CHARS_SET[Math.floor(random() * (charsSetLength - 1))])
.join('');
log('debug', `Generated a new code:`, code);
return code;
} | javascript | {
"resource": ""
} |
q37820 | getModel | train | function getModel(resource) {
var name = resource.name;
// if not already in the model cache, get it
if (!cache.models[name]) {
var schema = new mongoose.Schema(resource.fields, { collection: name });
// loop through indexes and add them to the schema
_.each(resource.indexes, funct... | javascript | {
"resource": ""
} |
q37821 | saveIndexInfo | train | function saveIndexInfo() {
// reset the cache
var tmpCache = cache.idxInfo;
cache.idxInfo = {};
var promises = [];
// add promise for each things being saved/updated
_.each(tmpCache, function (idxInfo, key) {
var where = { str: key };
var select = '_id count';
var pro... | javascript | {
"resource": ""
} |
q37822 | train | function(cb) {
var self = this;
var request;
try {
request = IndexedDB.open(self.setup.database, self.setup.version);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuccess = function(event) {
self.idb = event.target.result;
if (isFunction(cb)) return cb(... | javascript | {
"resource": ""
} | |
q37823 | train | function(cb) {
if (IndexedDB.deleteDatabase) {
var request = IndexedDB.deleteDatabase(this.setup.database);
// It's always in an order of onblocked -> onsuccess,
// ignoring other handlers, for now.
request.onsuccess = function(event) {
if (isFunction(cb)) return cb(null, event.targe... | javascript | {
"resource": ""
} | |
q37824 | train | function(storeNames, mode, result, cb) {
var transaction;
try {
transaction = this.idb.transaction(storeNames, mode);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
transaction.onabort = function(event) {
if (isFunction(cb)) return cb(event.target.error);
};
transact... | javascript | {
"resource": ""
} | |
q37825 | train | function(storeName, transaction, cb) {
try {
return transaction.objectStore(storeName);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
} | javascript | {
"resource": ""
} | |
q37826 | train | function(storeName, value, key, cb) {
// For usage of out-of-line keys a `key` argument have to be specified,
// otherwise the `request` will be made assuming in-line key or key generator.
// For detailed possibilities see what you can't do in `DataError` section here:
// `https://developer.mozilla.org/... | javascript | {
"resource": ""
} | |
q37827 | train | function(storeName, key, cb) {
if (!Array.isArray(key)) {
key = [key];
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var _del = function(key) {
var request;
try {
reque... | javascript | {
"resource": ""
} | |
q37828 | train | function(storeName, query, each, cb) {
if (arguments.length === 3) {
cb = each;
each = null;
}
if (arguments.length === 2) {
cb = query;
query = null;
each = null;
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var... | javascript | {
"resource": ""
} | |
q37829 | train | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.count();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuc... | javascript | {
"resource": ""
} | |
q37830 | train | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.clear();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsu... | javascript | {
"resource": ""
} | |
q37831 | validate | train | function validate(harvested, report, next, options) {
report.setChecklist('CodeUsage', 'Static code analysis');
var illegalIdentifiers = ['geolocation'];
function analyze(content, sourceURL, origin) {
var ast;
var trace = {
'trace': {
'sourceURL': sourceURL
... | javascript | {
"resource": ""
} |
q37832 | PrimitiveError | train | function PrimitiveError(code, metadata, cause) {
if (code === undefined || code === null) {
throw new TypeError('`code` is a required argument!');
}
PrimitiveError.super_.call(this, this.constructor.ERRORS[code]);
if (metadata instanceof Error) {
cause = metadata;
metadata = undefined;
}
/**
... | javascript | {
"resource": ""
} |
q37833 | Client | train | function Client(socket) {
// flag whether an external or internal client socket
this._tcp = (socket instanceof Socket);
// index into the connections array
this._index = -1;
// file descriptor
this._fd = socket._handle.fd;
// remote ip address
this._remoteAddress = socket.remoteAddress;
// remote... | javascript | {
"resource": ""
} |
q37834 | getObject | train | function getObject() {
var o = {}
, i
, fields = arguments.length
? Array.prototype.slice.call(arguments, 0) : keys;
for(i = 0;i < fields.length;i++) {
o[fields[i]] = this[fields[i]];
}
return o;
} | javascript | {
"resource": ""
} |
q37835 | _configFilter | train | function _configFilter ( f ) {
var parts = f.split("."),
ext = parts[ parts.length - 1 ],
pre = parts[ parts.length - 2 ],
name = parts[ parts.length - 3];
return !!(ext === "dist" && pre === "json" &&
exports.__ignores.indexOf( name ) === -1 && e... | javascript | {
"resource": ""
} |
q37836 | train | function (directory, filename) {
return Path.join(directory, filename).replace(/^[a-z]:\\/i, '/').replace(/\\/g, '/');
} | javascript | {
"resource": ""
} | |
q37837 | train | function (base, path, noStartingSlash) {
if (base === path) {
return '';
}
// Sanitize inputs, convert windows to posix style slashes, ensure trailing slash for base
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, '') + '/';
path = path.repla... | javascript | {
"resource": ""
} | |
q37838 | Log | train | function Log(namespace) {
// If it's called without new, still return a new instance.
if (!(this instanceof Log)) { return new Log(namespace); }
// Configure Log if it hasn't already
if (!logger) { Log.configure(); }
// This gets all of the log levels and applies them to this
Object.keys(logger.levels).fo... | javascript | {
"resource": ""
} |
q37839 | genSalt | train | function genSalt() {
var len = arguments[0] === undefined ? 16 : arguments[0];
var encoding = arguments[1] === undefined ? 'hex' : arguments[1];
return (0, _token2['default'])(len, encoding);
} | javascript | {
"resource": ""
} |
q37840 | parse | train | function parse(str) {
// find the prefix expressions and the main value
var stringMatches = str.match(stringRegex)
var allExpString = stringMatches[1] || ''
var value = stringMatches[2]
// parse each prefix expression
var expressions = execAll(allExpressionsRegex, allExpString)
// grab the expression ... | javascript | {
"resource": ""
} |
q37841 | set | train | function set(key, value /*, exflag, secs, pxflag, ms, xflag, req*/) {
var i
, arg
// expiry flag: EX | PX
, flag
// expiry value: number
, expiry
// exists flag: NX | XX
, xflag
// request object when available
, req;
for(i = 0;i < arguments.length;i++) {
arg = arguments[i];... | javascript | {
"resource": ""
} |
q37842 | setnx | train | function setnx(key, value, req) {
var res = this.setKey(
key, value, undefined, undefined, Constants.NX, req);
return res ? 1 : 0;
} | javascript | {
"resource": ""
} |
q37843 | setex | train | function setex(key, secs, value, req) {
return this.setKey(
key, value, Constants.EX, secs, undefined, req);
} | javascript | {
"resource": ""
} |
q37844 | psetex | train | function psetex(key, ms, value, req) {
return this.setKey(
key, value, Constants.PX, ms, undefined, req);
} | javascript | {
"resource": ""
} |
q37845 | getset | train | function getset(key, value, req) {
var val = this.getKey(key, req);
this.setKey(key, value, undefined, undefined, undefined, req);
return val || null;
} | javascript | {
"resource": ""
} |
q37846 | mset | train | function mset() {
var args = slice.call(arguments)
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(var i = 0;i < args.length;i += 2) {
this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
}
return OK;
} | javascript | {
"resource": ""
} |
q37847 | msetnx | train | function msetnx() {
var args = slice.call(arguments)
, i
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(i = 0;i < args.length;i += 2) {
if(this.keyExists(args[i], req)) {
return 0;
}
}
for(i = 0;i < args.length;i += 2) {
t... | javascript | {
"resource": ""
} |
q37848 | mget | train | function mget() {
var args = slice.call(arguments)
, list = [];
// got a req object
if(typeof args[args.length -1] === 'object') {
args.pop();
}
for(var i = 0;i < args.length;i++) {
list.push(this.get(args[i]));
}
return list;
} | javascript | {
"resource": ""
} |
q37849 | incrbyfloat | train | function incrbyfloat(key, amount, req) {
var val = utils.strtofloat(this.getKey(key, req));
amount = utils.strtofloat(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | javascript | {
"resource": ""
} |
q37850 | incrby | train | function incrby(key, amount, req) {
var val = utils.strtoint(this.getKey(key, req));
amount = utils.strtoint(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | javascript | {
"resource": ""
} |
q37851 | append | train | function append(key, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string';
// doesn't exist becomes the empty string
if(val === undefined) val = new Buffer('');
if(!(val instanceof Buffer)) val = new Buffer('' + val);
if(!(value instanceof Buffer)) value = new Buffer('' + value);
... | javascript | {
"resource": ""
} |
q37852 | getrange | train | function getrange(key, start, end, req) {
var val = this.getKey(key, req);
if(!val) return '';
start = parseInt(start);
end = parseInt(end);
if(start < 0) start = val.length + start;
if(end < 0) end = val.length + end;
// TODO: buffer compat
return (val + '').substr(start, end + 1);
} | javascript | {
"resource": ""
} |
q37853 | setrange | train | function setrange(key, offset, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string'
, len
, buf;
if(val && !(val instanceof Buffer)) val = new Buffer(val);
if(typeof val === 'number') val = new Buffer('' + val);
if(typeof value === 'string') {
value = new Buffer(value);
... | javascript | {
"resource": ""
} |
q37854 | getbit | train | function getbit(key, bitoffset, req) {
var buf = this.getValueBuffer(key, req)
, byte = bitoffset >> 3
, bit = 7 - (bitoffset & 0x7)
, bitval = 0;
if(buf === undefined) return 0;
if(byte < buf.length) {
bitval = buf[byte] & (1 << bit);
}
return bitval ? 1 : 0;
} | javascript | {
"resource": ""
} |
q37855 | bitpos | train | function bitpos(key, bit, start, end /* req */) {
var req = typeof arguments[arguments.length - 1] === 'object'
? arguments[arguments.length - 1] : null
, buf = this.getValueBuffer(key, req, true)
, i
, ind;
if(buf === undefined) buf = new Buffer('');
if(bit && !buf.length) return -1;
// got s... | javascript | {
"resource": ""
} |
q37856 | setbit | train | function setbit(key, offset, value, req) {
var buf = this.getValueBuffer(key, req, true)
, zeros
, pos
, shift
, byte
, bit;
if(buf === undefined) buf = new Buffer('');
pos = Math.floor(offset / 8);
bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);
if(pos + 1 >= buf.length) {
... | javascript | {
"resource": ""
} |
q37857 | graphvizualize | train | function graphvizualize(data, cb) {
var cp = exec('dot -Tsvg');
// buffer stdout
var buf = '';
cp.stdout.on('data', function (data) {
buf += data;
});
cp.on('error', function () {});
cp.on('close', function (code) {
cb(null, code > 0 ? '' : buf);
});
// set dot to stdin
cp.stdin.end(data);... | javascript | {
"resource": ""
} |
q37858 | parseLines | train | function parseLines(lines) {
var propertyMap = {};
lines.forEach(function (line) {
var parsed = parseLine(line);
if (!parsed) {
throw new Error('Cannot parse line: ', line);
}
propertyMap[parsed[1]] = parsed[2];
});
return p... | javascript | {
"resource": ""
} |
q37859 | parseValues | train | function parseValues(obj) {
Object.keys(obj).forEach(function (key) {
obj[key] = parseValue(obj[key]);
});
return obj;
} | javascript | {
"resource": ""
} |
q37860 | train | function () {
try {
// we're creating a simple reporter to:
// 1. track stats on the specs run
// 2. mimic a 'finished' callback
function FinishedReporter () {
this.total = this.passed = this.failed = 0;
}
FinishedReporter.prototype = {
report... | javascript | {
"resource": ""
} | |
q37861 | addToChildRegistry | train | function addToChildRegistry(childRegistry, child, name) {
assertType(childRegistry, 'object', false, 'Invalid child registry specified');
assertType(child, [Node, Array], false, 'Invalid child(ren) specified');
assertType(name, 'string', true, 'Invalid name specified');
let inferredName = getInstanceNameFromEl... | javascript | {
"resource": ""
} |
q37862 | renderPdf | train | function renderPdf( runtime , data ) {
prepareRenderPdf( runtime , data ) ;
runtime.pendingPdfCommands.push( data ) ;
} | javascript | {
"resource": ""
} |
q37863 | ElementConstructor | train | function ElementConstructor() {
var attr,
i;
// Trigger an initial attribute change
for (i = 0; i < this.attributes.length; i++) {
attr = this.attributes[i];
this.attributeChangedCallback(attr.name, null, attr.value, true);
}
} | javascript | {
"resource": ""
} |
q37864 | getPrivate | train | function getPrivate(instance) {
var map = weak_properties.get(instance);
if (!map) {
map = {
// Attribute configurations
attributes : {},
// Attribute values for use in property getters
prop_values : {},
// Attribute string values
values : {},
// New values that are beign set
new_... | javascript | {
"resource": ""
} |
q37865 | renderCustomTemplate | train | function renderCustomTemplate() {
var that = this,
child,
vars = {},
i;
for (i = 0; i < this.children.length; i++) {
child = this.children[i];
if (!child.getAttribute) {
continue;
}
if (child.getAttribute('slot')) {
vars[child.getAttribute('slot')] = child;
}
}
Hawkejs.removeChil... | javascript | {
"resource": ""
} |
q37866 | execute | train | function execute(req, res) {
// TODO: ensure a conflict is triggered on all watched keys
req.db.flushdb();
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q37867 | wrap | train | function wrap (value, ...parts) {
if (value === null || value === undefined || value === '' || parts.length < 2) {
return value
}
if (parts.length >= 4) {
return parts[0] + [].concat(value).map((val) => parts[1] + val + parts[2]) + parts[3]
}
return parts[0] + value + parts[1]
} | javascript | {
"resource": ""
} |
q37868 | getOnError | train | function getOnError (msg) {
return function getLastFoundDevicesErrorHandler (err) {
console.error('An Error', err, msg, err.stack);
var errDefered = q.defer();
errDefered.reject(err);
return errDefered.promise;
};
} | javascript | {
"resource": ""
} |
q37869 | f_temp_sil_kurum | train | function f_temp_sil_kurum(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurum(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurumIstenmeyen(_tahta_id))
].allX();
}
else {
return null;
}
} | javascript | {
"resource": ""
} |
q37870 | f_temp_sil_kalem | train | function f_temp_sil_kalem(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalem(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemTumu(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemIstenmeyen(_tahta_id)),
... | javascript | {
"resource": ""
} |
q37871 | f_temp_sil_anahtar | train | function f_temp_sil_anahtar(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaIhale(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaAnahtarIhaleleri(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.zsetTahtaIhaleSiraliIhaleTarihi... | javascript | {
"resource": ""
} |
q37872 | f_provider_raw_sil | train | function f_provider_raw_sil(_kullanici) {
//hata almamak için elastic e eklemeden önce providers içindeki raw bilgisi siliniyor
if (_kullanici.Providers.GP) {
delete _kullanici.Providers.GP.raw;
} else if (_kullanici.Providers.TW) {
delete _kullanici.Providers.TW.raw;
} else if (_k... | javascript | {
"resource": ""
} |
q37873 | f_temp_sil_tahta | train | function f_temp_sil_tahta(_tahta_id) {
return db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKullanici(_tahta_id));
} | javascript | {
"resource": ""
} |
q37874 | getTempBuildDir | train | function getTempBuildDir(packageName, version) {
return temp.mkdirAsync('makdeb')
.then(function(tempDir) {
return path.join(tempDir, packageName +'-'+ version);
});
} | javascript | {
"resource": ""
} |
q37875 | tarDir | train | function tarDir(dir) {
var archiveName = path.basename(dir) +'.orig.tar.xz';
var archivePath = path.join(path.dirname(dir), archiveName);
return exec('tar cfJ '+ archivePath +' '+ dir);
} | javascript | {
"resource": ""
} |
q37876 | writeDebianFiles | train | function writeDebianFiles(tempBuildDir, options) {
var debianDir = path.join(tempBuildDir, 'DEBIAN');
return fse.ensureDirAsync(debianDir)
.then(function() {
// Read the control file template.
return fse.readFileAsync(path.join(TEMPLATE_FILES_DIR, 'control.tmpl'), 'utf8');
})
.then(... | javascript | {
"resource": ""
} |
q37877 | train | function() {
var data, json, log = accessLogFormat.call(self, this.request, this, app);
if (format == 'json') {
log = app.applyFilters('access_log_data', log, this.request, app);
json = JSON.stringify(log);
data = [log, json]; // msg (object), log (text)
app.emit('access_log', json, data... | javascript | {
"resource": ""
} | |
q37878 | _initCollections | train | function _initCollections() {
if (!this._collections) {
return;
}
for (var coll in this._collections) {
this[coll] = new this._collections[coll](null, { parent: this, parse: true });
}
} | javascript | {
"resource": ""
} |
q37879 | _initChildren | train | function _initChildren() {
if (!this._children) {
return;
}
for (var child in this._children) {
var childAttrs = this._attrs && this._attrs[child] ? this._attrs[child] : {};
this[child] = new this._children[child](childAttrs, { parent: this, parse: true });
this.listenTo(this[child],... | javascript | {
"resource": ""
} |
q37880 | getAttributes | train | function getAttributes(opts, raw) {
var options = (0, _lodash2.default)({
session: false,
props: false,
derived: false,
children: true,
collections: true
}, opts || {});
var res = {};
for (var item in this._definition) {
var def = this._definition[item];
if (opt... | javascript | {
"resource": ""
} |
q37881 | parse | train | function parse(data) {
// If this comes from a collection, there won't be a data property.
// If it comes from querying the model API directly, it will.
if (!data || !data.data && !data.id) {
return {};
}
var model = data.data ? data.data : data;
/** The attributes on the model. */
... | javascript | {
"resource": ""
} |
q37882 | save | train | function save(key, val, opts) {
var _this = this;
var options = {};
var attrs = {};
var method = '';
var sync = null;
function wrapError(model, modelOptions) {
var error = modelOptions.error;
modelOptions.error = function (resp) {
if (error) {
error(model, resp, m... | javascript | {
"resource": ""
} |
q37883 | serialize | train | function serialize() {
var _this2 = this;
var res = this.getAttributes({
props: true,
children: false,
collections: false
}, true);
var id = res.id;
var relationships = {};
(0, _lodash4.default)(this._children, function (value, key) {
relationships[key] = {
data... | javascript | {
"resource": ""
} |
q37884 | onScroll | train | function onScroll(body, evt) {
if (body.scrollTop > 0) {
$.addClass(body, "top");
} else {
$.removeClass(body, "top");
}
if (body.scrollHeight - body.scrollTop > body.clientHeight) {
$.addClass(body, "bottom");
} else {
$.removeClass(body, "bottom");
}
} | javascript | {
"resource": ""
} |
q37885 | train | function(ast, source) {
if(!ast) return;
for(var i=0;i<ast.length;i++) {
var node=ast[i];
if(node && node.length>=3 && node[0]=='=') {
// looking for ['=', id, val]
runtime.ast()[node[1]] = {'ast': [node]};
runtime.source()[node[1]] = source;
}
}
... | javascript | {
"resource": ""
} | |
q37886 | stream | train | function stream(nodeStream, linebreak) {
linebreak = (typeof linebreak !== 'undefined' ? linebreak : '\n');
var mw = core.base();
mw.enabled = true;
mw.stream = nodeStream;
mw.linebreak = linebreak;
mw.writeln = function (line) {
if (mw.enabled) {
mw.stream.write(line + linebreak);
... | javascript | {
"resource": ""
} |
q37887 | WriteFteTable | train | function WriteFteTable() {
for (var i = 0; i < test_languages.length; i++) {
var retval = '';
retval += '<tr id="fte_row' + i + '">';
retval += '<td class="obfuscatorName">fte</td>';
retval += '<td class="testNum">' + test_languages[i]['description'] + '</td>';
retval += '<td class="testProto">' +... | javascript | {
"resource": ""
} |
q37888 | train | function(amount) {
var hsl = this.toHSL();
hsl.l += amount;
hsl.l = clamp(hsl.l);
return Color.fromHSL(hsl);
} | javascript | {
"resource": ""
} | |
q37889 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var start
, end;
if(args.length !== 1 && args.length !== 3) {
throw new CommandArgLength(cmd);
}
if(args.length > 1) {
start = parseInt('' + args[1]);
if(isNaN(start)) throw IntegerRange;
args... | javascript | {
"resource": ""
} |
q37890 | readCookie | train | function readCookie (cookiePath) {
var cookie
try {
var c = fs.readFileSync(cookiePath)
debug('loaded cookie', JSON.parse(c))
var sid = c['connect-sid']
debug('serialized', sid)
} catch (e) {
debug(e)
}
return cookie
} | javascript | {
"resource": ""
} |
q37891 | writeCookie | train | function writeCookie (response, cookiePath) {
try {
debug('got response')
var cookies = cookie.parse(response.headers['set-cookie'][0])
debug('connect.sid', cookies['connect.sid'])
fs.writeFileSync(cookiePath, JSON.stringify(cookies))
} catch (e) {
debug(e)
}
} | javascript | {
"resource": ""
} |
q37892 | updateLastSeen | train | function updateLastSeen (params, config) {
qpm_media.updateLastSeen(params, config).then(function (ret) {
if (ret.conn) {
var conn = ret.conn
conn.close()
}
}).catch(function (err) {
if (err.conn) {
var conn = err.conn
conn.close()
}
console.error(err.err)
})
} | javascript | {
"resource": ""
} |
q37893 | getType | train | function getType (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[1]) {
ret = parseInt(a[1])
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | {
"resource": ""
} |
q37894 | getFile | train | function getFile (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[2]) {
ret = a[2]
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | {
"resource": ""
} |
q37895 | getStart | train | function getStart (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[0]) {
var end = a[0]
ret = parseInt(end)
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | {
"resource": ""
} |
q37896 | sort | train | function sort(property) {
// sort by multiple properties
function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b)... | javascript | {
"resource": ""
} |
q37897 | multisort | train | function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b);
i++;
}
return result;
};
} | javascript | {
"resource": ""
} |
q37898 | exception | train | function exception(exceptionObj) {
const errorMessage = getErrorMessage(exceptionObj);
const errorDetails = getErrorDetails(exceptionObj);
return {
ok: false,
error: errorMessage,
details: errorDetails,
};
} | javascript | {
"resource": ""
} |
q37899 | connect | train | function connect() {
if (!redis) {
debug('createClient ' + key + ' at ' + host + ':' + port);
redis = redisLib.createClient(port, host, redisOpts); }
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.