_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2700 | train | function(callback) {
var errName;
try {
if (self._covered) {
// If coverage is request, we want the testModule to reference the
// code instrumented by istanbul in lib-cov/ instead of any local code in lib/.
// This passage looks for variables assigned to by require('li... | javascript | {
"resource": ""
} | |
q2701 | train | function(callback) {
var queue;
if (exportedFunctionsNames.length === 0) {
callback();
return;
}
function taskFunc(task, callback) {
var setUpFunc = task.setUpFunc, tearDownFunc = task.tearDownFunc;
async.waterfall([
function runSetUp(callback) {
... | javascript | {
"resource": ""
} | |
q2702 | train | function (actualArgs, expectedArgs) {
var i;
if (actualArgs.length !== expectedArgs.length) {
return false;
}
for (i = 0; i < expectedArgs.length; i++) {
if (actualArgs[i] !== expectedArgs[i]) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} | |
q2703 | buildDep | train | function buildDep(file, pkg){
var files = [];
if (file.processed || file.package != pkg)
return files;
file.processed = true;
for (var i = 0, depFile; depFile = file.deps[i++];)
files.push.apply(files, buildDep(depFile, file.package));
files.push(file);
return files;
} | javascript | {
"resource": ""
} |
q2704 | assert | train | function assert (validator, message) {
message = messageBuilder(message || 'vet/utils/assert error!');
if (isFunction(validator)) {
return function() {
var args = arguments;
if (validator.apply(this, args)) {
return true;
} else {
throw new Error(message.apply(this, args));
}
};
} else if (!... | javascript | {
"resource": ""
} |
q2705 | coverage | train | function coverage(data, type) {
var comparisionFunc;
var n = 0;
function isCovered(val) {
return (val > 0);
}
function isMissed(val) {
return !isCovered(val);
}
if (type === 'covered') {
comparisionFunc = isCovered;
}
else if (type === 'missed') {
comparisionFunc = isMissed;
}
e... | javascript | {
"resource": ""
} |
q2706 | aggregateCoverage | train | function aggregateCoverage(files) {
var i, len, file, content, results;
var resultsObj = getEmptyResultObject();
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
content = JSON.parse(fs.readFileSync(file).toString());
resultsObj = populateCoverage(resultsObj, content);
}
return r... | javascript | {
"resource": ""
} |
q2707 | pakoUnzip | train | async function pakoUnzip(inputData) {
let strm
let pos = 0
let i = 0
const chunks = []
let inflator
do {
const remainingInput = inputData.slice(pos)
inflator = new Inflate()
strm = inflator.strm
inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) throw new Error(inflator.msg)
... | javascript | {
"resource": ""
} |
q2708 | sink | train | function sink(modulename, level, message, obj) {
term.puts(sprintf('[green]%s[/green]: %s', modulename, message));
} | javascript | {
"resource": ""
} |
q2709 | indexEntry | train | function indexEntry(entry) {
if (entry.year) entry.year = parseInt(entry.year.toString().split("-")[0]); // first year for series
var n = helpers.simplifyName(entry);
if (!meta[n]) meta[n] = [];
meta[n].push(entry);
byImdb[entry.imdb_id] = entry;
} | javascript | {
"resource": ""
} |
q2710 | File | train | function File(retries, cdn, options) {
options = options || {};
this.backoff = new Backoff({ min: 100, max: 20000 });
this.mime = options.mime || {};
this.retries = retries || 5;
this.client = cdn.client;
this.cdn = cdn;
} | javascript | {
"resource": ""
} |
q2711 | Field | train | function Field(type, config) {
if (utils.typeOf(type) === 'object') {
config = type;
type = null;
}
if (!utils.isObject(config)) {
throw new TypeError('expected config to be an object');
}
this.types = type || config.type || config.types || [];
this.types = typeof this.types === 'string'
?... | javascript | {
"resource": ""
} |
q2712 | train | function (obj, other) {
var notIn = {};
for (var key in obj) {
if (other[key] === undefined) {
notIn[key] = true;
}
}
return _.keys(notIn);
} | javascript | {
"resource": ""
} | |
q2713 | isBetween | train | function isBetween(lower, upper) {
return function (val) {
return isNumber(val) && val > lower && val < upper;
}
} | javascript | {
"resource": ""
} |
q2714 | DockerProc | train | function DockerProc(docker, config) {
EventEmitter.call(this);
this.docker = docker;
this._createConfig = config.create;
this._startConfig = config.start;
this.stdout = new streams.PassThrough();
this.stderr = new streams.PassThrough();
} | javascript | {
"resource": ""
} |
q2715 | train | function(options) {
options = options || {};
if (!('pull' in options)) options.pull = true;
// no pull means no extra stream processing...
if (!options.pull) return this._run();
return new Promise(function(accept, reject) {
// pull the image (or use on in the cache and output status in stdou... | javascript | {
"resource": ""
} | |
q2716 | train | function() {
var that = this;
this.killed = true;
if (this.started) {
this.container.kill();
} else {
this.once('container start', function() {
that.container.kill();
});
}
} | javascript | {
"resource": ""
} | |
q2717 | returns | train | function returns(func, validator, message) {
message = messageBuilder(message || 'vet/utils/returns error!');
return function _returnsInstance() {
var args = arguments;
var result = func.apply(this, arguments);
if (validator(result)) {
return result;
} else {
throw new Error(message.call(this, result)... | javascript | {
"resource": ""
} |
q2718 | setupConn | train | function setupConn(connectCfg, options) {
var conn = amqp.createConnection(connectCfg, options);
conn.on('ready', function() {
debug('received ready event from node-amqp');
var eventName = 'connection';
//Ready event will be emitted when re-connected.
//To keep backward compatible, only ... | javascript | {
"resource": ""
} |
q2719 | autoSubscribe | train | function autoSubscribe() {
//re-add pending subscribers
if (_pendingSubscribers.length > 0) {
async.each(_pendingSubscribers, function(sub, callback) {
debug('Add pending subscriber', sub);
self.subscribeToTopic(sub.exchange, sub.queue, sub.filter, sub.subscriber, sub.opts, function(err) {... | javascript | {
"resource": ""
} |
q2720 | publishCachedMessages | train | function publishCachedMessages() {
if (_cachedPublishMessages.length > 0) {
async.each(_cachedPublishMessages, function(message, callback) {
debug('republish message', message);
self.publishTopic(message.exchange, message.topic, message.message, message.options, function(err) {
if (e... | javascript | {
"resource": ""
} |
q2721 | filter_email | train | function filter_email(value) {
var m = EMAIL_RE.exec(value);
if(m == null) throw OptError('Excpeted an email address.');
return m[1];
} | javascript | {
"resource": ""
} |
q2722 | build_rules | train | function build_rules(filters, arr) {
var rules = [];
for(var i=0; i<arr.length; i++) {
var r = arr[i], rule
if(!contains_expr(r)) throw OptError('Rule MUST contain an option.');
switch(r.length) {
case 1:
rule = build_rule(filters, r[0]);
break... | javascript | {
"resource": ""
} |
q2723 | extend | train | function extend(dest, src) {
var result = dest;
for(var n in src) {
result[n] = src[n];
}
return result;
} | javascript | {
"resource": ""
} |
q2724 | spaces | train | function spaces(arg1, arg2) {
var l, builder = [];
if(arg1.constructor === Number) {
l = arg1;
} else {
if(arg1.length == arg2) return arg1;
l = arg2 - arg1.length;
builder.push(arg1);
}
while(l-- > 0) builder.push(' ');
return builder.join('');
} | javascript | {
"resource": ""
} |
q2725 | train | function(value, fn) {
if(value.constructor === Function ) {
this.default_handler = value;
} else if(value.constructor === Number) {
this.on_args[value] = fn;
} else {
this.on_switches[value] = fn;
}
} | javascript | {
"resource": ""
} | |
q2726 | train | function(args) {
var result = [], callback;
var rules = build_rules(this.filters, this._rules);
var tokens = args.concat([]);
var token;
while(this._halt == false && (token = tokens.shift())) {
if(LONG_SWITCH_RE.test(token) || SHORT_SWITCH_RE.test(token)) {
... | javascript | {
"resource": ""
} | |
q2727 | train | function() {
var builder = [this.banner, '', this.options_title],
shorts = false, longest = 0, rule;
var rules = build_rules(this.filters, this._rules);
for(var i = 0; i < rules.length; i++) {
rule = rules[i];
// Quick-analyze the options.
if(rule.... | javascript | {
"resource": ""
} | |
q2728 | matches | train | function matches(regex) {
return function(val) {
regex.lastIndex = 0;
return isString(val) && regex.test(val);
};
} | javascript | {
"resource": ""
} |
q2729 | netcdfGcms | train | function netcdfGcms(data, options = {}) {
let reader = new NetCDFReader(data);
const globalAttributes = reader.globalAttributes;
let instrument_mfr = reader.getDataVariableAsString('instrument_mfr');
let dataset_origin = reader.attributeExists('dataset_origin');
let mass_values = reader.dataVariableExists('m... | javascript | {
"resource": ""
} |
q2730 | getCardId | train | function getCardId(o) {
return o.master + '#' + o.combination.front.join(',') + '@' + o.combination.back.join(',');
} | javascript | {
"resource": ""
} |
q2731 | addReview | train | function addReview(reviews, review) {
if (!reviews.length) {
return [review];
}
var i = reviews.length - 1;
for (; i >= 0; i -= 1) {
if (reviews[i].ts <= review.ts) {
break;
}
}
var newReviews = reviews.slice(0);
newReviews.splice(i + 1, 0, review);
return newReviews;
} | javascript | {
"resource": ""
} |
q2732 | searchForArrowCloudLogDir | train | function searchForArrowCloudLogDir() {
if (isWritable('/ctlog')) {
return '/ctlog';
}
if (process.env.HOME && isWritable(path.join(process.env.HOME, 'ctlog'))) {
return path.join(process.env.HOME, 'ctlog');
}
if (process.env.USERPROFILE && isWritable(path.join(process.env.USERPROFILE, 'ctlog'))) {
return pat... | javascript | {
"resource": ""
} |
q2733 | isWritable | train | function isWritable(dir) {
debug('checking if ' + dir + ' is writable');
try {
if (!fs.existsSync(dir)) {
debug(' - it does not exist yet, attempting to create it');
fs.mkdirSync(dir);
}
if (fs.accessSync) {
fs.accessSync(dir, fs.W_OK);
} else {
debug(' - fs.accessSync is not available, falling ba... | javascript | {
"resource": ""
} |
q2734 | getPort | train | function getPort(req) {
if (req.connection && req.connection.localPort) {
return req.connection.localPort.toString();
}
const host = req.headers && req.headers.host;
let protocolSrc = 80;
if (host && ((host.match(/:/g) || []).length) === 1) {
const possiblePort = host.split(':')[1];
protocolSrc = isN... | javascript | {
"resource": ""
} |
q2735 | getStatus | train | function getStatus (res) {
let status;
const statusCode = res.statusCode;
if (statusCode) {
status = Math.floor(statusCode / 100) * 100;
}
switch (status) {
case 100:
case 200:
case 300:
return 'success';
default:
return 'failure';
}
} | javascript | {
"resource": ""
} |
q2736 | isWhitelisted | train | function isWhitelisted(url) {
return options.adiPathFilter.some(function (route) {
return url.substr(0, route.length) === route;
});
} | javascript | {
"resource": ""
} |
q2737 | createDefaultLogger | train | function createDefaultLogger(options) {
const ConsoleLogger = require('./console'),
consoleLogger = new ConsoleLogger(options),
config = _.mergeWith({
name: 'logger',
streams: [
{
level: options && options.level || 'trace',
type: 'raw',
stream: consoleLogger
}
]
}, options, functi... | javascript | {
"resource": ""
} |
q2738 | train | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a code
* Finds a code
* @param {String} codeId Id of the code
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Code}
*/
this.findCode = funct... | javascript | {
"resource": ""
} | |
q2739 | ConsoleLogger | train | function ConsoleLogger(options) {
EventEmitter.call(this);
this.options = options || {};
// allow use to customize if they want the label or not
this.prefix = this.options.prefix === undefined ? true : this.options.prefix;
this.showcr = this.options.showcr === undefined ? true : this.options.showcr;
this.showtab ... | javascript | {
"resource": ""
} |
q2740 | isLoadNeeded | train | function isLoadNeeded(newProps, oldProps) {
return !_.isEqual(newProps.formDesign, oldProps.formDesign) || !_.isEqual(newProps.data, oldProps.data);
} | javascript | {
"resource": ""
} |
q2741 | train | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Find organization
* Find organization
* @param {String} organizationId organization id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Organization}
*... | javascript | {
"resource": ""
} | |
q2742 | createLogger | train | function createLogger(fn) {
return function () {
var args = [],
self = this,
c;
for (c = 0; c < arguments.length; c++) {
args[c] = logger.specialObjectClone(arguments[c]);
}
return fn.apply(self, args);
};
} | javascript | {
"resource": ""
} |
q2743 | train | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds organizations page fragment
* Finds single organization page fragment
* @param {String} organizationId Organization id
* @param {String} fragmentId fragment id
* @return {Promise} a {@link https://ww... | javascript | {
"resource": ""
} | |
q2744 | train | function() {
canReflect.onValue( observation, updater,"notify");
if (observation.hasOwnProperty("_value")) {// can-observation 4.1+
compute.value = observation._value;
} else {// can-observation < 4.1
compute.value = observation.value;
}
} | javascript | {
"resource": ""
} | |
q2745 | train | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a phone service channel by id
* Finds a phone service channel by id
* @param {String} phoneServiceChannelId Phone service channel id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with d... | javascript | {
"resource": ""
} | |
q2746 | ProblemLogger | train | function ProblemLogger(options) {
options = options || {};
ConsoleLogger.call(this);
const tmpdir = require('os').tmpdir();
this.filename = path.join(tmpdir, 'logger-' + (+new Date()) + '.log');
this.name = options.problemLogName || ((options.name || 'problem') + '.log');
this.stream = fs.createWriteStream(this.f... | javascript | {
"resource": ""
} |
q2747 | closeStreams | train | function closeStreams(exitCode) {
// default is 0 if not specified
exitCode = exitCode === undefined ? 0 : exitCode;
if (streams.length) {
streams.forEach(function (logger) {
logger.write({ level: bunyan.TRACE, msg: util.format('exited with code %d', exitCode) });
logger.stream.end();
// jscs:disable jsD... | javascript | {
"resource": ""
} |
q2748 | train | function(l) {
debug('Attaching link ' + l.name + ':' + l.handle + ' after begin received');
if (l.state() !== 'attached' && l.state() !== 'attaching') l.attach();
} | javascript | {
"resource": ""
} | |
q2749 | role | train | function role(value) {
if (typeof value === 'boolean')
return value;
if (value !== 'sender' && value !== 'receiver')
throw new errors.EncodingError(value, 'invalid role');
return (value === 'sender') ? false : true;
} | javascript | {
"resource": ""
} |
q2750 | listBuilder | train | function listBuilder(list, bufb, codec, width) {
if (!Array.isArray(list)) {
throw new errors.EncodingError(list, 'Unsure how to encode non-array as list');
}
if (!width && list.length === 0) {
bufb.appendUInt8(0x45);
return;
}
// Encode all elements into a temp buffer to allow us to front-load ... | javascript | {
"resource": ""
} |
q2751 | mapBuilder | train | function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
if (Array.isArray(map)) {
throw new errors.EncodingError(map, 'Unsure how to encode array as map');
}
var keys = Object.keys(map);
if (!wid... | javascript | {
"resource": ""
} |
q2752 | assertArguments | train | function assertArguments(options, argnames) {
if (!argnames) return;
if (!options) throw new TypeError('missing arguments: ' + argnames);
argnames.forEach(function (argname) {
if (!options.hasOwnProperty(argname)) {
throw new TypeError('missing argument: ' + argname);
}
});
} | javascript | {
"resource": ""
} |
q2753 | Sasl | train | function Sasl(mechanism, handler) {
if (!mechanism || !handler) {
throw new errors.NotImplementedError('Need both the mechanism and the handler');
}
this.mechanism = mechanism;
this.handler = handler;
this.receivedHeader = false;
} | javascript | {
"resource": ""
} |
q2754 | Policy | train | function Policy(overrides) {
if (!(this instanceof Policy))
return new Policy(overrides);
u.defaults(this, overrides, {
/**
* support subjects in link names with the following characteristics:
* receiver: "amq.topic/news", means a filter on the ReceiverLink will be made
* for messa... | javascript | {
"resource": ""
} |
q2755 | train | function (onDone) {
// store what to do after connected
// NOTE: may be called repeatedly (if initial attempts fail or disconnect happens)
if (typeof onDone === 'function')
l_onConnect = onDone;
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
... | javascript | {
"resource": ""
} | |
q2756 | train | function (latest_log) {
if (latest_log !== null && latest_log.type !== "SYSTEM_DOWN") {
LOG.warn("server crashed last time", 'handlers.system');
LOG.event("SYSTEM_CRASHED", SR.Settings.SERVER_INFO);
}
LOG.event("SYSTEM_UP", SR.Settings.SERVER_INFO);
} | javascript | {
"resource": ""
} | |
q2757 | train | function () {
if (queue.length > 0) {
if (queue.length % 500 === 0)
LOG.warn('socketio queue: ' + queue.length);
var item = queue.shift();
socket.busy = true;
socket.emit('SRR', item);
}
} | javascript | {
"resource": ""
} | |
q2758 | train | function () {
SR.fs.close(l_logs[log_id].fd,
function () {
console.log(l_name + '::l_closeLog::' + SR.Tags.YELLOW + 'LogID=' + log_id + ' closed.' + SR.Tags.ERREND);
delete l_logs[log_id];
onDone(log_id);
}
);
} | javascript | {
"resource": ""
} | |
q2759 | train | function (appID, locationID) {
// check if location exists
if (l_locations.hasOwnProperty(locationID) === false) {
LOG.error('locationID: ' + locationID + ' does not exist', 'addApp');
return;
}
// check if already exists, ignore action if already exists
if (l_apps.hasOwnProperty(a... | javascript | {
"resource": ""
} | |
q2760 | train | function (upload) {
if (!upload || !upload.path || !upload.name || !upload.size) {
LOG.error('upload object incomplete:', l_name);
return;
}
// record basic file info
var arr = upload.path.split('/');
var upload_name = arr[arr.length-1];
var filename = (preserve_name ... | javascript | {
"resource": ""
} | |
q2761 | train | function (id) {
LOG.warn('server started: ' + server_type, l_name);
// check if we should notify start server request
for (var i=0; i < l_pendingStart.length; i++) {
var task = l_pendingStart[i];
if (task.server_type !== server_type) {
continue;
}
LOG.warn('pending type matched: ' +... | javascript | {
"resource": ""
} | |
q2762 | train | function (exec_path, onExec) {
var onFound = function () {
// if file found, execute directly
// store starting path
args.exec_path = exec_path;
LOG.warn('starting ' + size + ' [' + server_type + '] servers', l_name);
// store an entry for the callback when all servers are started as reque... | javascript | {
"resource": ""
} | |
q2763 | convertApiError | train | function convertApiError(err) {
if (err.error && err.error.response && err.error.response.text) {
const obj = JSON.parse(err.error.response.text);
if (obj.errors && obj.errors.length) {
err = { message: obj.errors[0].message, error:err.error };
}
}
return err;
} | javascript | {
"resource": ""
} |
q2764 | train | function (area, layer) {
// check if layer exists
if (l_layers.hasOwnProperty(layer) === false)
return [];
// get all current subscriptions at this layer
var subs = l_layers[layer];
// prepare list of connection of subscribers matching / covering the area
var connections = [];
// check each subscriptio... | javascript | {
"resource": ""
} | |
q2765 | train | function (event) {
// if event is not from socket, no need to queue
// TODO: remove connection-specific code from here
if (event.conn.type !== 'socket')
return true;
var socket = event.conn.connector;
// if no mechanism to store (such as from a bot), just ignore
// TODO: this is not clean
if (typeof socket.... | javascript | {
"resource": ""
} | |
q2766 | train | function (event) {
// check if connection object exists
if (typeof event.conn === 'undefined') {
LOG.error('no connection records, cannot respond to request', l_name);
return false;
}
// if no mechanism to store (such as from a bot), just ignore
// TODO: cleaner approach?
if (event.conn.type !== 'socket' ||... | javascript | {
"resource": ""
} | |
q2767 | train | function (req, res) {
LOG.warn('handle_request');
// attach custom res methods (borrowed from express)
res = UTIL.mixin(res, response);
LOG.sys('HTTP req received, header', 'SR.REST');
LOG.sys(req.headers, 'SR.REST');
var content_type = req.headers['content-type'];
// NOTE: multi-part needs to be ha... | javascript | {
"resource": ""
} | |
q2768 | train | function (account, data, conn) {
//if (l_logins.hasOwnProperty(account) === true)
//return false;
// check if user's unique data exists
if (typeof data.data !== 'object') {
LOG.error('data field does not exist, cannot add login data');
return false;
}
LOG.warn('account: ' + account + ' data:', 'addLogin... | javascript | {
"resource": ""
} | |
q2769 | train | function (error) {
if (error) {
var err = new Error("set custom data for account [" + account + "] fail");
err.name = "setUser Error";
LOG.error('set custom data for account [' + account + '] fail', 'user');
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('set custom data for account [' + account + ... | javascript | {
"resource": ""
} | |
q2770 | train | function (uid, token) {
// TODO: check if local account already exists, or replace existing one
// multiple accounts storable for one local server
// NOTE: field name is a variable
// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify
... | javascript | {
"resource": ""
} | |
q2771 | train | function (error) {
if (error) {
var err = new Error(error.toString());
err.name = "l_createToken Error";
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('pass_token [' + token + '] stored');
UTIL.safeCall(onDone, null, token);
}
} | javascript | {
"resource": ""
} | |
q2772 | train | function (msgtype, event) {
// we only forward for non-SR user-defined events at lobby
if (SR.Settings.SERVER_INFO.type !== 'lobby' || msgtype.startsWith('SR'))
return false;
// check if we're lobby and same-name app servers are available
var list = SR.AppConn.queryAppServers();
LOG.sys('check forward... | javascript | {
"resource": ""
} | |
q2773 | train | function (response_type, event) {
LOG.sys('handling event response [' + response_type + ']', l_name);
// go over each registered callback function and see which one responds
for (var i=0; i < l_responders[response_type].length; i++) {
// find the callback with matching client id
// call callback and s... | javascript | {
"resource": ""
} | |
q2774 | train | function (e, req, res, host) {
LOG.error('proxy error for host: ' + host + '. remove from active proxy list:', 'SR.Proxy');
LOG.error(e, 'SR.Proxy');
// remove proxy info from list
delete l_proxies[host];
// notify for proxy failure
UTIL.safeCall(onProxyFail, host);
// send back to client about t... | javascript | {
"resource": ""
} | |
q2775 | JobQueue | train | function JobQueue(para) {
this.queue = [];
this.curr = 0;
this.all_passed = true;
this.timeout = ((typeof para === 'object' && typeof para.timeout === 'number') ? para.timeout : 0);
} | javascript | {
"resource": ""
} |
q2776 | train | function () {
if (item.done === false) {
LOG.error('job timeout! please check if the job calls onDone eventually. ' + (item.name ? '[' + item.name + ']' : ''), l_name);
// force this job be done
onJobDone(false);
}
} | javascript | {
"resource": ""
} | |
q2777 | train | function (list) {
for (var i=0; i < list.length; i++) {
for (var j=0; j < l_entries.length; j++) {
if (list[i] === l_entries[j]) {
l_entries.splice(j, 1);
break;
}
}
}
} | javascript | {
"resource": ""
} | |
q2778 | getInput | train | function getInput() {
var account = document.getElementById('account').value;
var email = (document.getElementById('email') ? document.getElementById('email').value : '');
var password = document.getElementById('password').value;
return {account: account, email: email, password: password};
} | javascript | {
"resource": ""
} |
q2779 | train | function (err, data) {
if (err) {
LOG.warn(err.toString());
}
else {
for (var server in data.accounts) {
LOG.warn('local server: ' + server);
var user_list = data.accounts[server];
for (var uid in user_list) {
var token = user_list[uid];
LOG.warn('local uid: ' + uid + ' token: ' + tok... | javascript | {
"resource": ""
} | |
q2780 | train | function (server, uid, token) {
try {
// convert uid to number if not already
if (typeof uid === 'string')
uid = parseInt(uid);
}
catch (e) {
LOG.error('uid cannot be parsed as integer...', 'login.send_remote_login');
return false;
}
SR.User.loginLocal(server, uid, token, function (result) {
// NO... | javascript | {
"resource": ""
} | |
q2781 | train | function (login_id, session, data) {
// acknowledge as 'logined'
l_loginID[login_id] = data.account;
// init session
session['_account'] = data.account;
// TODO: needs to fix this, should read "groups" from DB
session['_groups'] = data.groups;
session['_permissions'] = data.permissions;
session['lastStatu... | javascript | {
"resource": ""
} | |
q2782 | train | function (err, result) {
// if login is successful, we record the user's account in cache
if (err) {
LOG.warn(err.toString());
result = {code: err.code, msg: err.message};
}
else {
if (result.code === 0) {
LOG.warn('login success, result: ');
LOG.warn(result);
var data = {
account: u... | javascript | {
"resource": ""
} | |
q2783 | train | function (arg) {
if ( ! arg.allow ){
return;
}
var exist = false;
for (var i in data.allow) {
if (data.allow[i] === arg.allow) {
exist = true;
}
}
if ( exist === false ) {
data.allow[data.allow.length] = arg.allow;
}
} | javascript | {
"resource": ""
} | |
q2784 | Connection | train | function Connection (type, sender, from) {
// provide default 'from' values
from = from || {};
// connection-specific UUID
this.connID = UTIL.createUUID();
// a project-specific / supplied name (can be account or app name)
this.name = '';
// sender function associated with this connection
this.connector ... | javascript | {
"resource": ""
} |
q2785 | train | function () {
// get a event from the front of queue
var tmdata = queue.dequeue();
// whether to keep processing (default is no)
busy = false;
// check if data exists
if (tmdata === undefined) {
return;
}
// handle the event if handler is a... | javascript | {
"resource": ""
} | |
q2786 | train | function (arr) {
// extract collection name
if (arr && typeof arr._name === 'string') {
var size = arr.length - arr._index;
if (size <= 0)
return false;
LOG.sys('try to store to array [' + arr._name + '], # of elements to store: ' + size, 'SR.Sync');
// TODO: wasteful of space?
// NOTE: only n... | javascript | {
"resource": ""
} | |
q2787 | train | function (arrays, config, onDone) {
var names = [];
// load array's content from DB, if any
SR.DB.getArray(SR.Settings.DB_NAME_SYNC,
function (result) {
// NOTE: if array does not exist it'll return success with an empty array
if (result === null || result.length === 0) {
LOG.warn('no a... | javascript | {
"resource": ""
} | |
q2788 | train | function (args, result, func, extra) {
return new SR.promise(function (resolve, reject) {
UTIL.safeCall(func, args, result, function () {
UTIL.safeCall(resolve);
}, extra);
});
} | javascript | {
"resource": ""
} | |
q2789 | train | function (args, onDone, extra) {
// if args are not provided then we shift the parameters
if (typeof args === 'function') {
extra = onDone;
onDone = args;
args = {};
}
// TODO: perform argument type check (currently there's none, so internal API calls won't do type checks)
// TODO: move checker to h... | javascript | {
"resource": ""
} | |
q2790 | train | function (account) {
// check if DB is initialized
if (typeof l_accounts === 'undefined') {
LOG.error('DB module is not loaded, please enable DB module', l_name);
return false;
}
if (l_accounts.hasOwnProperty(account) === false) {
LOG.error('[' + account + '] not found', l_name);
return false;
}
return ... | javascript | {
"resource": ""
} | |
q2791 | getUIDCallback | train | function getUIDCallback (err, uid) {
if (err) {
return onDone('UID_ERROR');
}
var ip = (extra) ? extra.conn.host : "server";
// NOTE: by default a user is a normal user, user 'groups' can later be customized
var reg = {
uid: uid,
account: args.account,
password: l_encryptPass(args.password),
... | javascript | {
"resource": ""
} |
q2792 | train | function (conn) {
LOG.error('AppManager disconnected', 'SR.AppConnector');
if (SR.Settings.APPSERVER_AUTOSHUT === true) {
// shutdown this frontier
l_dispose();
SR.Settings.FRONTIER.dispose();
}
else {
LOG.warn('auto-shutdown is false, attempt to re-connect AppManager in ' + l_timeout... | javascript | {
"resource": ""
} | |
q2793 | train | function () {
LOG.warn('appinfo sent to lobby:');
LOG.warn(l_appinfo);
// notify AppManager we're ready
l_notifyLobby('SR_APP_READY', l_appinfo, 'SR_APP_READY_RES',
function (event) {
if (event.data.op === true)
LOG.sys('SR_APP_READY returns ok', 'l_HandlerPool');
... | javascript | {
"resource": ""
} | |
q2794 | train | function (ip_port, onDone) {
if (l_appConnector === undefined) {
LOG.warn('appConnector not init, cannot connect');
return;
}
// retrieve from previous connect attempt, also store for later connect attempt
// TODO: will need to change when lobby port becomes not fixed
ip_port = ip_port || l_ip_port;
l_ip_p... | javascript | {
"resource": ""
} | |
q2795 | train | function (req) {
var session = l_getSession(req);
if (session.hasOwnProperty('_user')) {
var login = session._user;
login.admin = (session._user.account === 'admin');
return login;
}
LOG.warn('user not yet logined...');
return {control: {groups: [], permissions: []}};
} | javascript | {
"resource": ""
} | |
q2796 | copyFilesToPack | train | function copyFilesToPack(grunt, buildPath, filesToPack) {
return function(callback) {
grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
try {
var filepathDest;
if (detectDestType(grunt, fileConfig.dest) === 'directory') {
var dest = (fileConfig.orig.expand) ? fileConfig.dest : pa... | javascript | {
"resource": ""
} |
q2797 | writeSpecFile | train | function writeSpecFile(grunt, options, filesToPack) {
return function(callback) {
try {
var specPath = path.join(options.destination, specFolder);
options.files = filesToPack;
var pkg = grunt.file.readJSON('package.json');
grunt.util._.defaults(options, pkg);
options.specFilepath = path.join(specP... | javascript | {
"resource": ""
} |
q2798 | train | function () {
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
if (l_connector === undefined)
l_connector = new SR.Connector(l_config);
// establish connection
LOG.warn('connecting to: ' + l_ip_port);
l_connector.connect(l_ip_port, func... | javascript | {
"resource": ""
} | |
q2799 | train | function (res, res_obj) {
// return response if exist, otherwise response might be returned
// AFTER some callback is done handling (i.e., response will be returned within the handler)
if (typeof res_obj === 'string') {
LOG.sys('replying a string: ' + res_obj);
res.writeHead(200, {'Content... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.