_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q14100 | train | function (str) {
// here:xx:xxx??inline
var matches = /^<!--\s*here\:(.*?)\s*-->$/.exec(str.trim())
if (!matches || !matches[1]) return null
var expr = matches[1]
var parts = expr.split('??')
var query = querystring.parse(parts[1] || '')
var isInline = ('inline' i... | javascript | {
"resource": ""
} | |
q14101 | prettyLines | train | function prettyLines(lines, theme) {
if (!lines || !Array.isArray(lines)) throw new Error('Please supply an array of lines');
if (!theme) throw new Error('Please supply a theme');
function prettify(line) {
if (!line) return null;
return exports.line(line, theme);
}
return lines.map(prettify);
} | javascript | {
"resource": ""
} |
q14102 | train | function(fs, ourGlob, negatives, opt) {
// remove path relativity to make globs make sense
ourGlob = resolveGlob(fs, ourGlob, opt);
var ourOpt = extend({}, opt);
delete ourOpt.root;
// create globbing stuff
var globber = new glob.Glob(fs, ourGlob, ourOpt);
// extract base path from glob
... | javascript | {
"resource": ""
} | |
q14103 | train | function(fs, globs, opt) {
if (!opt) opt = {};
if (typeof opt.cwd !== 'string') opt.cwd = fs.resolve('.');
if (typeof opt.dot !== 'boolean') opt.dot = false;
if (typeof opt.silent !== 'boolean') opt.silent = true;
if (typeof opt.nonull !== 'boolean') opt.nonull = false;
if (typeof opt.cwdbase !=... | javascript | {
"resource": ""
} | |
q14104 | extensionsParser | train | function extensionsParser(str) {
// Convert the file extensions string to a list.
var list = str.split(',');
for (var i = 0; i < list.length; i++) {
// Make sure the file extension has the correct format: '.ext'
var ext = '.' + list[i].replace(/(^\s?\.?)|(\s?$)/g, '');
list[i] = ext.toLowerCase();
}
return l... | javascript | {
"resource": ""
} |
q14105 | listParser | train | function listParser(str) {
var list = str.split(',');
for (var i = 0; i < list.length; i++)
list[i] = list[i].replace(/(^\s?)|(\s?$)/g, '');
return list;
} | javascript | {
"resource": ""
} |
q14106 | kill | train | function kill(noMsg, signal) {
if (!instance)
return false;
try {
if (signal)
instance.kill(signal);
else
process.kill(instance.pid);
if ((noMsg || false) !== true)
logger.log('Killed', clc.green(script));
} catch (ex) {
// Process was already dead.
return false;
}
return true;
} | javascript | {
"resource": ""
} |
q14107 | restart | train | function restart() {
logger.log('Restarting', clc.green(script));
notifyWebSocket('restart');
if (!kill(true)) {
// The process wasn't running, start it now.
start(true);
} /*else {
// The process will restart when its 'exit' event is emitted.
}*/
} | javascript | {
"resource": ""
} |
q14108 | notifyWebSocket | train | function notifyWebSocket(message) {
if (!webSocketServer || !message)
return;
// Send the message to all connection in the WebSocket server.
for (var value in webSocketServer.conn) {
var connection = webSocketServer.conn[value];
if (connection)
connection.send(message)
}
} | javascript | {
"resource": ""
} |
q14109 | start | train | function start(noMsg) {
if ((noMsg || false) !== true)
logger.log('Starting', clc.green(script), 'with', clc.magenta(parser));
if (instance)
return;
// Spawn an instance of the parser that will run the script.
instance = spawn(parser, parserParams);
// Redirect the parser/script's output to the console.
... | javascript | {
"resource": ""
} |
q14110 | getLaunchIndex | train | function getLaunchIndex(PromiseArray){
return PromiseArray.map(r => {return (r.isRunning === false && r.isRejected === false && r.isResolved === false)}).indexOf(true)
} | javascript | {
"resource": ""
} |
q14111 | parseAnnotation | train | function parseAnnotation(entity) {
return {
annotations: entity.annotations ? {
bundleURL: entity.annotations['bundle-url'],
guiX: entity.annotations['gui-x'],
guiY: entity.annotations['gui-y']
} : undefined,
modelUUID: entity['model-uuid'],
tag: entity.tag
};
} | javascript | {
"resource": ""
} |
q14112 | parseAnnotations | train | function parseAnnotations(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseAnnotation(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14113 | parseApplication | train | function parseApplication(entity) {
return {
charmURL: entity['charm-url'],
// Config is arbitrary so leave the keys as defined.
config: entity.config,
// Constraints are arbitrary so leave the keys as defined.
constraints: entity.constraints,
exposed: entity.exposed,
life: entity.life,
... | javascript | {
"resource": ""
} |
q14114 | parseApplications | train | function parseApplications(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseApplication(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14115 | parseMachine | train | function parseMachine(entity) {
return {
addresses: entity.addresses ? entity.addresses.map(address => ({
value: address.value,
type: address.type,
scope: address.scope
})) : undefined,
agentStatus: entity['agent-status'] ? {
current: entity['agent-status'].current,
message: ... | javascript | {
"resource": ""
} |
q14116 | parseMachines | train | function parseMachines(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseMachine(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14117 | parseRelation | train | function parseRelation(entity) {
return {
endpoints: entity.endpoints ? entity.endpoints.map(endpoint => ({
applicationName: endpoint['application-name'],
relation: {
name: endpoint.relation.name,
role: endpoint.relation.role,
'interface': endpoint.relation.interface,
o... | javascript | {
"resource": ""
} |
q14118 | parseRelations | train | function parseRelations(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseRelation(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14119 | parseRemoteApplication | train | function parseRemoteApplication(entity) {
return {
life: entity.life,
modelUUID: entity['model-uuid'],
name: entity.name,
offerURL: entity['offer-url'],
offerUUID: entity['offer-uuid'],
status: entity.status ? {
current: entity.status.current,
message: entity.status.message,
... | javascript | {
"resource": ""
} |
q14120 | parseRemoteApplications | train | function parseRemoteApplications(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseRemoteApplication(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14121 | parseUnit | train | function parseUnit(entity) {
return {
agentStatus: entity['agent-status'] ? {
current: entity['agent-status'].current,
message: entity['agent-status'].message,
since: entity['agent-status'].since,
version: entity['agent-status'].version
} : undefined,
application: entity.applicatio... | javascript | {
"resource": ""
} |
q14122 | parseUnits | train | function parseUnits(response) {
let entities = {};
Object.keys(response).forEach(key => {
entities[key] = parseUnit(response[key]);
});
return entities;
} | javascript | {
"resource": ""
} |
q14123 | parseMegaWatcher | train | function parseMegaWatcher(response) {
return {
annotations: parseAnnotations(response.annotations),
applications: parseApplications(response.applications),
machines: parseMachines(response.machines),
relations: parseRelations(response.relations),
remoteApplications: parseRemoteApplications(respons... | javascript | {
"resource": ""
} |
q14124 | init | train | function init() {
var _user = arguments.length <= 0 || arguments[0] === undefined ? 'try' : arguments[0];
var _pw = arguments.length <= 1 || arguments[1] === undefined ? 'try' : arguments[1];
var _clientId = arguments.length <= 2 || arguments[2] === undefined ? 'mqttControlsClient' : arguments[2];
var _broke... | javascript | {
"resource": ""
} |
q14125 | connect | train | function connect() {
console.log('Connecting client: ' + clientId + ' to url:"' + url + '"');
client = mqtt.connect(url, { 'clientId': clientId });
} | javascript | {
"resource": ""
} |
q14126 | disconnect | train | function disconnect() {
var force = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var cb = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
console.log('Disconnecting client: ' + clientId);
stopPub = true;
client.end(force, cb);
} | javascript | {
"resource": ""
} |
q14127 | reconnect | train | function reconnect() {
client.end(false, function () {
console.log('Reconnecting client: ' + clientId);
client.connect(url, { 'clientId': clientId });
});
} | javascript | {
"resource": ""
} |
q14128 | subscribe | train | function subscribe() {
console.log('Subscribing client ' + clientId + ' to topic: ' + topics.subscribe);
client.subscribe(topics.subscribe);
isSubscribed = true;
} | javascript | {
"resource": ""
} |
q14129 | publish | train | function publish() {
console.log('Client ' + clientId + ' is publishing to topic ' + topics.publish);
// client.on('message',()=>{});
// this is just for testing purpouse
// maybe we dont need to stop and start publishing
var timer = setInterval(function () {
client.publish(topics.publish, 'ping');
if... | javascript | {
"resource": ""
} |
q14130 | send | train | function send() {
var message = arguments.length <= 0 || arguments[0] === undefined ? 'hello mqtt-controls' : arguments[0];
var topic = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var t = undefined;
if (topic === null) {
t = topics.publish;
} else {
t = topic;
}
cli... | javascript | {
"resource": ""
} |
q14131 | consoleLogger | train | function consoleLogger(prefix, name, args, value) {
var result = value;
if (typeof value === 'string') {
result = '"' + result + '"';
}
name = prefix + name;
switch (args) {
case 'getter':
console.log(name, '=', result);
break;
case 'setter':
... | javascript | {
"resource": ""
} |
q14132 | train | function() {
var self = this;
if (self._refreshingCache) {
return;
}
self._refreshingCache = true;
Parse._objectEach(this.attributes, function(value, key) {
if (value instanceof Parse.Object) {
value._refreshCache();
} else if (_.isObject(value)) {
... | javascript | {
"resource": ""
} | |
q14133 | train | function(attrs) {
// Check for changes of magic fields.
var model = this;
var specialFields = ["id", "objectId", "createdAt", "updatedAt"];
Parse._arrayEach(specialFields, function(attr) {
if (attrs[attr]) {
if (attr === "objectId") {
model.id = attrs[attr];
... | javascript | {
"resource": ""
} | |
q14134 | train | function(serverData) {
// Copy server data
var tempServerData = {};
Parse._objectEach(serverData, function(value, key) {
tempServerData[key] = Parse._decode(key, value);
});
this._serverData = tempServerData;
// Refresh the attributes.
this._rebuildAllEstimatedData();
... | javascript | {
"resource": ""
} | |
q14135 | train | function(other) {
if (!other) {
return;
}
// This does the inverse of _mergeMagicFields.
this.id = other.id;
this.createdAt = other.createdAt;
this.updatedAt = other.updatedAt;
this._copyServerData(other._serverData);
this._hasData = true;
} | javascript | {
"resource": ""
} | |
q14136 | train | function(opSet, target) {
var self = this;
Parse._objectEach(opSet, function(change, key) {
target[key] = change._estimate(target[key], self, key);
if (target[key] === Parse.Op._UNSET) {
delete target[key];
}
});
} | javascript | {
"resource": ""
} | |
q14137 | train | function() {
var self = this;
var previousAttributes = _.clone(this.attributes);
this.attributes = _.clone(this._serverData);
Parse._arrayEach(this._opSetQueue, function(opSet) {
self._applyOpSet(opSet, self.attributes);
Parse._objectEach(opSet, function(op, key) {
se... | javascript | {
"resource": ""
} | |
q14138 | train | function(attr, amount) {
if (_.isUndefined(amount) || _.isNull(amount)) {
amount = 1;
}
return this.set(attr, new Parse.Op.Increment(amount));
} | javascript | {
"resource": ""
} | |
q14139 | train | function() {
var json = _.clone(_.first(this._opSetQueue));
Parse._objectEach(json, function(op, key) {
json[key] = op.toJSON();
});
return json;
} | javascript | {
"resource": ""
} | |
q14140 | $item | train | function $item(corq, item){
var typeName = item.type;
if (!corq.callbacks[typeName]){
throw "Item handler not found for items of type `" + typeName + "`";
}
$debug(corq, 'Corq: Calling handler for item `' + typeName + '`');
$debug(corq, item.data);
var _next = function(){
var freq = (corq.delay) ? cor... | javascript | {
"resource": ""
} |
q14141 | getOrRegister | train | function getOrRegister(name, definition) {
if(name && !definition) {
return registry.get(name);
}
if(name && definition) {
return registry.register(name, definition);
}
return null;
} | javascript | {
"resource": ""
} |
q14142 | extractHeaderCookies | train | function extractHeaderCookies(headerSet) {
var cookie = headerSet.cookie;
var cookies = cookie ? cookie.split(';') : [];
delete headerSet.cookie;
return cookies;
} | javascript | {
"resource": ""
} |
q14143 | hyperImg | train | function hyperImg(store) {
this.compile = function(input) {
var path = input.split('.');
return {
path: input,
target: path[path.length - 1]
};
};
this.state = function(config, state) {
var res = store.get(config.path, state);
if (!res.completed) return false;
return state.set... | javascript | {
"resource": ""
} |
q14144 | Registry | train | function Registry(opts) {
var defaultOptions = {
resourceCapabilitiesEndPoint:
'http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/reg/resource-caps'
}
var options = opts || {}
this.axiosConfig = {
method: 'get',
withCredentials: true,
crossDomain: true
}
this.resourceCapabilitiesURL = URL.... | javascript | {
"resource": ""
} |
q14145 | getSourceCode | train | function getSourceCode(filepath) {
// The current folder
var dir = filepath.substring(0, filepath.lastIndexOf("/") + 1);
// Regex for file import
var fileRegex = /(?:["'])<!=\s*(.+)\b\s*!>(?:["'])?;?/;
// Regex for file extension
var fileExtRegex = /\..+$/;
// Read the file a... | javascript | {
"resource": ""
} |
q14146 | train | function ( value, index, array ) {
if ( visited.hasOwnProperty(value) ) { return; }
visited[value] = true;
var deps = projectData.dependency[ value ];
if ( !deps ) { return; }
for ( var i = 0; i < deps.length; ++i ) {
var depAbsPath = projectData.id2File[ deps[i] ];
if (... | javascript | {
"resource": ""
} | |
q14147 | writeFileSyncLong | train | function writeFileSyncLong(filepath, contents) {
const options = arguments[2] || { flag: 'w', encoding: 'utf8' };
let lastPath;
const pathNormal = path.normalize(filepath);
if (path.isAbsolute(pathNormal)) {
lastPath = pathNormal;
} else {
lastPath = path.resolve(pathNormal);
}
... | javascript | {
"resource": ""
} |
q14148 | isValid | train | function isValid (value, predicate, self) {
if (predicate instanceof Function) {
return predicate.call(self, value)
}
if (predicate instanceof RegExp) {
return predicate.test(value)
}
return true
} | javascript | {
"resource": ""
} |
q14149 | to12Hour | train | function to12Hour(hour) {
var meridiem = hour < 12 ? 'am' : 'pm';
return {
hour: ((hour + 11) % 12 + 1),
meridiem: meridiem,
meridian: meridiem
};
} | javascript | {
"resource": ""
} |
q14150 | to24Hour | train | function to24Hour(time) {
var meridiem = time.meridiem || time.meridian;
return (meridiem === 'am' ? 0 : 12) + (time.hour % 12);
} | javascript | {
"resource": ""
} |
q14151 | train | function(args) {
var lastArgWasNumber = false;
var numArgs = args.length;
var strs = [];
for (var ii = 0; ii < numArgs; ++ii) {
var arg = args[ii];
if (arg === undefined) {
strs.push('undefined');
} else if (typeof arg === 'number') {
if (lastArgWasNumber) {
s... | javascript | {
"resource": ""
} | |
q14152 | shouldRun | train | function shouldRun(verb) {
// Add extra middleware to check if this method matches the requested HTTP verb
return function wareShouldRun(req, res, next) {
var shouldRun = (this.running && (req.method === verb || verb.toLowerCase() === 'all'));
// Call next in stack if it matches
if (shou... | javascript | {
"resource": ""
} |
q14153 | sendReadyMessage | train | function sendReadyMessage() {
var data = {
namespace: MESSAGE_NAMESPACE,
id: 'iframe-ready'
};
parent.postMessage(JSON.stringify(data), '*');
} | javascript | {
"resource": ""
} |
q14154 | train | function (asset, result) {
var checksum;
result = Microloader.parseResult(result);
Microloader.remainingCachedAssets--;
if (!result.error) {
checksum = Microloader.checksum(result.content, asset.assetConfig.hash);
i... | javascript | {
"resource": ""
} | |
q14155 | train | function (content, delta) {
var output = [],
chunk, i, ln;
if (delta.length === 0) {
return content;
}
for (i = 0,ln = delta.length; i < ln; i++) {
chunk = delta[i];
if (typ... | javascript | {
"resource": ""
} | |
q14156 | train | function(doc, callback) {
audit([doc], function(err) {
if (err) {
return callback(err);
}
docsDb.saveDoc(doc, callback);
});
} | javascript | {
"resource": ""
} | |
q14157 | train | function(docs, options, callback) {
if (!callback) {
callback = options;
options = {};
}
audit(docs, function(err) {
if (err) {
return callback(err);
}
options.docs = docs;
docsDb.bulkDocs(options, callback);
});
... | javascript | {
"resource": ""
} | |
q14158 | train | function(doc, callback) {
audit([doc], 'delete', function(err) {
if (err) {
return callback(err);
}
docsDb.removeDoc(doc._id, doc._rev, callback);
});
} | javascript | {
"resource": ""
} | |
q14159 | train | function(arr, i) {
var ret = arr.slice(0);
for (var j = 0; j < i; j++) {
ret = [ret[ret.length - 1]].concat(ret.slice(0, ret.length - 1));
}
return ret;
} | javascript | {
"resource": ""
} | |
q14160 | train | function(first, second) {
if (_equal(first, second)) {
return true;
}
for (var i = 1; i <= first.length; i++) {
if (_equal(first, _rotated(second, i))) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q14161 | sqlParams | train | function sqlParams(sql, params)
{
var args = [];
var keys = sql.match(/@\w+/g);
var aKeys = sql.match(/\$\d+/g);
if (keys && aKeys)
throw new Error(
'Cannot use both array-style and object-style parametric values');
// Array-style (native)
if (aKeys) {
return { text: sql, values: params };
... | javascript | {
"resource": ""
} |
q14162 | getWordToken | train | function getWordToken(str) {
var word = str.split(/\s/g)[0];
return {text: word, type: 'WORD', length: word.length};
} | javascript | {
"resource": ""
} |
q14163 | contains | train | function contains (obj1, obj2) {
const keys = Object.keys(obj1)
let result = keys.length > 0
let l = keys.length
while (l--) {
const key = keys[l]
result = result && match(obj1[key], obj2[key])
}
return result
} | javascript | {
"resource": ""
} |
q14164 | ravenwall | train | function ravenwall(options) {
if (options instanceof statware) return options
options = options || {}
// set defaults
options.sysstats = !(options.sysstats === false)
options.procstats = !(options.procstats === false)
options.memstats = !(options.memstats === false)
options.push = !(options.push === fal... | javascript | {
"resource": ""
} |
q14165 | normalize | train | function normalize(from, to) {
if (from && (isNaN(from) || from <= 0) || (to && (isNaN(to) || to <= 0))) {
throw new Error('invalid port range: required > 0');
}
if ((from && from > MAX) || (to && to > MAX)) {
throw new Error(f('invalid port range: required < %d', MAX));
}
if (to && to < from) {
t... | javascript | {
"resource": ""
} |
q14166 | cleanObject | train | function cleanObject(Object){
delete Object.resolve;
delete Object.reject;
delete Object.resolveResult;
delete Object.rejectResult;
delete Object.launchPromise;
delete Object.promiseFunc;
} | javascript | {
"resource": ""
} |
q14167 | updateExample | train | function updateExample(app, str) {
var cwd = app.options.dest || app.cwd;
return app.src('example.txt', {cwd: cwd})
.pipe(append(str))
.pipe(app.dest(cwd));
} | javascript | {
"resource": ""
} |
q14168 | erase | train | function erase(num) {
var n = typeof num === 'number' ? num : 1;
return through.obj(function(file, enc, next) {
var lines = file.contents.toString().trim().split('\n');
file.contents = new Buffer(lines.slice(0, -n).join('\n') + '\n');
next(null, file);
});
} | javascript | {
"resource": ""
} |
q14169 | update | train | function update (state) {
assert.ifError(inRenderingTransaction, 'infinite loop detected')
// request a redraw for next frame
if (currentState === null && !redrawScheduled) {
redrawScheduled = true
raf(function redraw () {
redrawScheduled = false
if (!currentState) return
... | javascript | {
"resource": ""
} |
q14170 | Split | train | function Split (options) {
if (!(this instanceof Split)) {
return new Split(options)
}
if (options instanceof RegExp || typeof options === 'string') {
options = { matcher: options }
}
this.options = Object.assign({
matcher: /(\r?\n)/, // emits also newlines
encoding: 'utf8'
}, options)
th... | javascript | {
"resource": ""
} |
q14171 | copyObject | train | function copyObject(obj) {
var ret = {}, name;
for (name in obj) {
if (obj.hasOwnProperty(name)) {
ret[name] = obj[name];
}
}
return ret;
} | javascript | {
"resource": ""
} |
q14172 | setHost | train | function setHost(uri) {
if (uri.auth || uri.hostname || uri.port) {
uri.host = '';
if (uri.auth) uri.host += uri.auth + '@';
if (uri.hostname) uri.host += uri.hostname;
if (uri.port) uri.host += ':' + uri.port;
}
} | javascript | {
"resource": ""
} |
q14173 | setHref | train | function setHref(uri) {
uri.href = '';
if (uri.protocol) uri.href += uri.protocol + '//';
if (uri.host) uri.href += uri.host;
if (uri.path) uri.href += uri.path;
if (uri.hash) uri.href += uri.hash;
} | javascript | {
"resource": ""
} |
q14174 | setPath | train | function setPath(uri) {
if (uri.path || (uri.pathname === undefined && uri.search === undefined)) return;
uri.path = '';
if (uri.pathname) uri.path += uri.pathname;
if (uri.search) uri.path += uri.search;
} | javascript | {
"resource": ""
} |
q14175 | setSearch | train | function setSearch(uri) {
if (typeof uri.search === 'string' || uri.query === undefined) return;
if (typeof uri.query === 'string') {
uri.search = '?' + uri.query;
return;
}
var name, filled = false;
uri.search = '?';
for (name in uri.query) {
filled = true;
uri.search += name + '=' + uri... | javascript | {
"resource": ""
} |
q14176 | parseFilepath | train | function parseFilepath(path) {
if (path === undefined) {
return {filename: null, list: []};
}
var list = path.split('/'),
isDir = (path[path.length - 1] === '/') || (list[list.length - 1].indexOf('.') === -1);
return {
filename: isDir ? null : list.pop(),
list: list
};
} | javascript | {
"resource": ""
} |
q14177 | bin | train | function bin(argv) {
rm(argv, function(err, res, uri) {
console.log('rm of : ' + uri);
});
} | javascript | {
"resource": ""
} |
q14178 | buildError | train | function buildError(err, hackErr) {
var stack1 = err.stack;
var stack2 = hackErr.stack;
var label = hackErr.label;
var stack = [];
stack1.split('\n').forEach(function(line, index, arr) {
if (line.match(/^ at GeneratorFunctionPrototype.next/)) {
stack = stack.concat(arr.slice(0, index));
r... | javascript | {
"resource": ""
} |
q14179 | train | function(argument) {
//console.log("deep.Deferred.resolve : ", argument);
if (this.rejected || this.resolved)
throw new Error("deferred has already been ended !");
if (argument instanceof Error)
return this.reject(argument);
this._success = argument;
this.resolved = true;
var self = th... | javascript | {
"resource": ""
} | |
q14180 | train | function(argument) {
// console.log("DeepDeferred.reject");
if (this.rejected || this.resolved)
throw new Error("deferred has already been ended !");
this._error = argument;
this.rejected = true;
var self = this;
this._promises.forEach(function(promise) {
promise.reject(argument);
... | javascript | {
"resource": ""
} | |
q14181 | train | function() {
var prom = new promise.Promise();
//console.log("deep2.Deffered.promise : ", prom, " r,r,c : ", this.rejected, this.resolved, this.canceled)
if (this.resolved)
return prom.resolve(this._success);
if (this.rejected)
return prom.reject(this._error);
this._promises.push(prom);
... | javascript | {
"resource": ""
} | |
q14182 | init | train | function init()
{
scope._servConn = new ConnectaSocket(scope._url,scope._reconnect,scope._encode);
scope._servConn.onConnected = function(e)
{
scope.id = e;
scope.dispatchEvent("connected");
}
scope._servConn.onError = function(e)
{
... | javascript | {
"resource": ""
} |
q14183 | createPeerInstance | train | function createPeerInstance(id)
{
var peer = new ConnectaPeer(id,stunUrls);
peer.onIceCandidate = gotIceCandidate;
peer.onDescription = createdDescription;
peer.onRemoteStream = gotRemoteStream;
peer.onConnected = onPeerConnected;
peer.onMessa... | javascript | {
"resource": ""
} |
q14184 | getPeerByRTCId | train | function getPeerByRTCId(id)
{
for(var num = 0; num < scope._servConn.roomUsers.length; num++)
{
if(scope._servConn.roomUsers[num].rtcId == id)
{
return scope._servConn.roomUsers[num];
}
}
return null;
} | javascript | {
"resource": ""
} |
q14185 | getOrCreatePeer | train | function getOrCreatePeer(id)
{
if(scope.peers[id])
{
return scope.peers[id];
}
return createPeerInstance(id);
} | javascript | {
"resource": ""
} |
q14186 | onClientJoinedRoom | train | function onClientJoinedRoom(id)
{
if(scope._servConn.useRTC)
{
if(scope.hasWebRTCSupport())
{
var peer = getOrCreatePeer(id);
peer.createOffer();
}
else
{
scope._servConn.sendRTCState(false,id... | javascript | {
"resource": ""
} |
q14187 | onRTCFallback | train | function onRTCFallback(from,data,isArray)
{
var peer = getPeerByRTCId(from);
if(peer)
{
if(isArray == true)
{
data = sliceArray(data,0,data.length-2);// data.slice(0,data.length-2);
}
scope.dispatchEvent("peerMessage",{... | javascript | {
"resource": ""
} |
q14188 | onServerMessage | train | function onServerMessage(data)
{
if(data.ev)
{
scope.dispatchEvent("onServerMessage",data);
scope.dispatchEvent(data.ev,data);
}
} | javascript | {
"resource": ""
} |
q14189 | onPeerConnected | train | function onPeerConnected(peer)
{
if(scope.localStream)
{
peer.updateStream(scope.localStream,false);
}
scope._servConn.sendRTCState(true,peer.id);
scope.dispatchEvent("peerConnected",peer.id);
} | javascript | {
"resource": ""
} |
q14190 | onPeerFailed | train | function onPeerFailed(peer)
{
scope._servConn.sendRTCState(false,peer.id);
scope.dispatchEvent("peerFailed",peer.id);
} | javascript | {
"resource": ""
} |
q14191 | onPeerClose | train | function onPeerClose(peer)
{
var id = peer.id;
scope.removePeer(peer);
sendPeerClose(id);
scope.dispatchEvent("peerDisconnected",id);
} | javascript | {
"resource": ""
} |
q14192 | onIceCandidate | train | function onIceCandidate(id,data)
{
if(scope.hasWebRTCSupport())
{
getOrCreatePeer(id).onServerMessage(JSON.parse(data));
}
} | javascript | {
"resource": ""
} |
q14193 | onPeerMessage | train | function onPeerMessage(peer,msg)
{
scope.dispatchEvent("peerMessage",{message:msg,id:peer.id,rtc:peer.rtcId,array:false,fallback:false});
} | javascript | {
"resource": ""
} |
q14194 | onBytesMessage | train | function onBytesMessage(peer,data)
{
var arr = bufferToArray(scope._servConn.byteType,data);
if(arr)
{
if(scope._servConn.rtcFallback == true)
{
arr = arr.slice(0,arr.length-2);
}
scope.dispatchEvent("peerMessage",{message:arr,... | javascript | {
"resource": ""
} |
q14195 | addText | train | function addText() {
// Add title
dialogEl.querySelector( '#dialog-title' ).innerHTML = options.title
// Add optional description
var descriptionEl = dialogEl.querySelector( '#dialog-description' )
if ( options.description ) {
descriptionEl.innerHTML = options.description
} else {
descriptionEl.p... | javascript | {
"resource": ""
} |
q14196 | tab | train | function tab( event ) {
// Find all focusable elements in the dialog card
var focusable = dialogEl.querySelectorAll('input:not([type=hidden]), textarea, select, button'),
last = focusable[focusable.length - 1],
focused = document.activeElement
// If focused on the last focusable element... | javascript | {
"resource": ""
} |
q14197 | train | function( d ) { // ISO-8601 year number. This has the same value as Y, except that if the ISO
var m = d.getMonth(), w = DATE_PROTO.getISOWeek.call( d ); // week number (W) belongs to the previous or next year, that year is used instead.
return... | javascript | {
"resource": ""
} | |
q14198 | train | function(ac) {
var data = {},
selectedmojit = ac.params.getFromRoute('mojit') || 'none';
data[selectedmojit] = true;
ac.assets.addCss('./index.css');
ac.done(data);
} | javascript | {
"resource": ""
} | |
q14199 | executeCommands | train | function executeCommands(bulkOperation, options, callback) {
if (bulkOperation.s.batches.length === 0) {
return handleCallback(callback, null, new BulkWriteResult(bulkOperation.s.bulkResult));
}
// Ordered execution of the command
const batch = bulkOperation.s.batches.shift();
function resultHandler(err... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.