_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31400 | isInt | train | function isInt(obj) {
var type = sType(obj);
return (_.has(obj, '$value') && (type === 'xsd:int' || type === 'int'));
} | javascript | {
"resource": ""
} |
q31401 | hasKeys | train | function hasKeys(obj) {
return (!Array.isArray(obj) && _.isObject(obj) && _.keys(obj).length > 0);
} | javascript | {
"resource": ""
} |
q31402 | filterValidPaths | train | function filterValidPaths(type, paths, version) {
var valid = [];
version = env.schema[version] || env.schema['5.1'];
_.forEach(paths, function(p) {
if (env.schema.hasProperty(version, type, p)) {
valid.push(p);
}
});
return valid;
} | javascript | {
"resource": ""
} |
q31403 | newError | train | function newError(errorCode, errorMessage) {
var errObj;
if (_.isObject(errorCode)) {
errObj = errorCode;
}
else if (typeof(errorCode) === 'number') {
errObj = {
errorCode: errorCode,
};
if (errorMessage) {
errObj.message = errorMessage;
}
}
else {
errObj = {errorCode: 50... | javascript | {
"resource": ""
} |
q31404 | getSessionId | train | function getSessionId(cookie) {
if (typeof(cookie.cookies) === 'string') {
var idx = cookie.cookies.indexOf('=');
if (idx !== -1) {
return _.trim(cookie.cookies.substring(idx + 1), '"') || null;
}
}
return null;
} | javascript | {
"resource": ""
} |
q31405 | log | train | function log(obj, message) {
obj = obj || [];
obj.push({
time: new Date(),
log: message
});
return obj;
} | javascript | {
"resource": ""
} |
q31406 | train | function() {
if(savedMessageFromLastFail) {
// Last time we tried to publish there was a failure preventing it from ending up on the wall.
// In such a case, we want to pre-populate the user's message with the same message from last time.
// See 20552: ('Write Something..' te... | javascript | {
"resource": ""
} | |
q31407 | genSession | train | function genSession (baseUrl, devId, authHash, platform) {
let url = baseUrl + 'createsessionjson/' + devId + '/' +
authHash + '/' + util.getUtcTime()
return new Promise((resolve, reject) => {
request(url, (error, response, body) => {
if (!error && response.statusCode === 200) {
let sessionID ... | javascript | {
"resource": ""
} |
q31408 | taskAsync | train | function taskAsync(args, result) {
// format the result
result = env.format(result);
// if the delete should not be asyncronous and the task should be monitored
if (args.async === false) {
// set the polling period and timeout defaults
args.delay = !isNaN(args.delay) ? args.delay : 1000;
args.... | javascript | {
"resource": ""
} |
q31409 | assignRequest | train | function assignRequest (target, source, obj = {}, term) {
_.merge(target, _.omit(source, ['term']), obj)
if (term == true) target.term = source.term
} | javascript | {
"resource": ""
} |
q31410 | processTerm | train | function processTerm (handler, obj = {}, isDefault) {
let req = {
term: this._request.term.then(value => {
assignRequest(req, this._request, obj)
if (this._request.error && !isDefault) return null
if (isDefault) req.error = null
return handler(value, req)
})
}
return new v(this._cl... | javascript | {
"resource": ""
} |
q31411 | processBranch | train | function processBranch (args, resolve, reject) {
let condition = args.shift()
let val = args.shift()
let las = _.last(args)
return Promise.resolve(condition)
.then(c => {
if (c === true) {
return Promise.resolve(_.isFunction(val) ? val() : val)
.then(resolve, reject)
} else if... | javascript | {
"resource": ""
} |
q31412 | performRetrieve | train | function performRetrieve (req) {
return this._client.retrieve(req.args, req.options)
.then(result => {
req.args = {}
req.options = {}
return result
})
} | javascript | {
"resource": ""
} |
q31413 | train | function(url, done) {
var urlParts = urlUtil.parse(url, true),
filename = urlParts.pathname,
auth = urlParts.auth;
if (S(filename).endsWith("/")) filename += "index"; // Append
var filePath = path.resolve(
process.cwd(),
outPath,
... | javascript | {
"resource": ""
} | |
q31414 | rootSearch | train | function rootSearch(args) {
// get the datacenters
return _client.retrieve({
type: 'Datacenter',
properties: ['name', 'datastoreFolder', 'hostFolder', 'networkFolder', 'vmFolder']
})
.then(function(dcs) {
// look through each of the dcs and map the return values
return Promise.map(dcs, function(... | javascript | {
"resource": ""
} |
q31415 | findByNameEx | train | function findByNameEx(args, matches) {
// create a variable to store the matches
matches = matches || [];
// set option defaults
args.name = Array.isArray(args.name) ? args.name : [args.name];
args.recursive = (typeof(args.recursive) === 'boolean') ? args.recursive : false;
args.limit = !isN... | javascript | {
"resource": ""
} |
q31416 | findByName | train | function findByName(args) {
// validate the types
if (!args.type || !_.includes(['Datastore', 'HostSystem', 'Network', 'VirtualMachine'], args.type)) {
return new Promise(function(resolve, reject) {
reject({
errorCode: 400,
message: 'Invalid search type. Valid types are Datastore, HostSystem, Ne... | javascript | {
"resource": ""
} |
q31417 | Resource | train | function Resource(spec, options) {
if (!(this instanceof Resource)) {
return new Resource(spec, options);
}
if (typeof spec !== 'object') {
throw new Error('resource spec must be an object');
}
debug('create resource %s', spec.path, spec);
this.spec = spec;
this.list = [];
this.options = opti... | javascript | {
"resource": ""
} |
q31418 | c | train | function c(color, text) {
if(chaiParam.config.disableColors)
return text;
return chalk[color](text);
} | javascript | {
"resource": ""
} |
q31419 | fillEmptyOptionsFromPrompt | train | function fillEmptyOptionsFromPrompt (options, args, callback, startPosition) {
if (typeof startPosition === 'undefined') {
startPosition = 0
}
if (startPosition < 0) {
throw new RangeError('Start position must not be negative')
}
if (startPosition > args.length) {
throw new RangeError('Start posit... | javascript | {
"resource": ""
} |
q31420 | train | function (program) {
var verbosity = program.verbose
if (program.quiet) {
verbosity = 0
} else if (typeof verbosity === 'undefined') {
verbosity = 1
}
return verbosity
} | javascript | {
"resource": ""
} | |
q31421 | train | function (title, confirm, callback) {
var fullTitle = title.indexOf('Confirm') === 0 ? title : 'Enter ' + title
fullTitle += ':'
read({
prompt: fullTitle,
silent: true
}, function (error, result) {
if (error) {
process.stdout.write('\n')
callback(provisionUtil.createFor... | javascript | {
"resource": ""
} | |
q31422 | train | function (hostname, command) {
var hostInfo = {hostname: hostname, user: '', password: ''}
var hostInfoKeys = ['port', 'user', 'password', 'truststore']
hostInfoKeys.forEach(function (hostInfoKey) {
if (command[hostInfoKey]) {
hostInfo[hostInfoKey] = command[hostInfoKey]
delete command... | javascript | {
"resource": ""
} | |
q31423 | Api | train | function Api(spec, options) {
if (!(this instanceof Api)) {
return new Api(spec, options);
}
if (typeof spec !== 'object') {
throw new Error('api spec must be an object');
}
options = options || {};
// path alias for both resourcePath and doc path
if (spec.path) {
if (!spec.resourcePath) sp... | javascript | {
"resource": ""
} |
q31424 | train | function(self, obj)
{
self.stack = '';
for(var key in obj)
{
self[key] = obj[key];
}
} | javascript | {
"resource": ""
} | |
q31425 | train | function(s, p, o)
{
if(p in s)
{
if(s[p].constructor === Array)
{
s[p].push(o);
}
else
{
s[p] = [s[p], o];
}
}
else
{
s[p] = o;
}
} | javascript | {
"resource": ""
} | |
q31426 | train | function(ctx)
{
// TODO: reduce calls to this function by caching keywords in processor
// state
var rval =
{
'@id': '@id',
'@language': '@language',
'@literal': '@literal',
'@type': '@type'
};
if(ctx)
{
// gather keyword aliases from context
var keywords... | javascript | {
"resource": ""
} | |
q31427 | train | function(ctx, term)
{
var rval = null;
if(term in ctx)
{
if(ctx[term].constructor === String)
{
rval = ctx[term];
}
else if(ctx[term].constructor === Object && '@id' in ctx[term])
{
rval = ctx[term]['@id'];
}
}
return rval;
} | javascript | {
"resource": ""
} | |
q31428 | train | function(ctx, iri, usedCtx)
{
var rval = null;
// check the context for a term that could shorten the IRI
// (give preference to terms over prefixes)
for(var key in ctx)
{
// skip special context keys (start with '@')
if(key.length > 0 && key[0] !== '@')
{
// compact to a t... | javascript | {
"resource": ""
} | |
q31429 | train | function(ctx, term, usedCtx)
{
var rval = term;
// get JSON-LD keywords
var keywords = _getKeywords(ctx);
// 1. If the property has a colon, it is a prefix or an absolute IRI:
var idx = term.indexOf(':');
if(idx !== -1)
{
// get the potential prefix
var prefix = term.substr(0, i... | javascript | {
"resource": ""
} | |
q31430 | train | function(ctx)
{
// sort keys
var rval = {};
var keys = Object.keys(ctx).sort();
for(var k in keys)
{
var key = keys[k];
rval[key] = ctx[key];
}
return rval;
} | javascript | {
"resource": ""
} | |
q31431 | train | function(value)
{
var rval = false;
// Note: A value is a subject if all of these hold true:
// 1. It is an Object.
// 2. It is not a literal.
// 3. It has more than 1 key OR any existing key is not '@id'.
if(value !== null && value.constructor === Object && !('@literal' in value))
{
var ... | javascript | {
"resource": ""
} | |
q31432 | train | function(v1, v2)
{
var rval = 0;
if(v1.constructor === Array && v2.constructor === Array)
{
for(var i = 0; i < v1.length && rval === 0; ++i)
{
rval = _compare(v1[i], v2[i]);
}
}
else
{
rval = (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0));
}
return rval;
} | javascript | {
"resource": ""
} | |
q31433 | train | function(o1, o2, key)
{
var rval = 0;
if(key in o1)
{
if(key in o2)
{
rval = _compare(o1[key], o2[key]);
}
else
{
rval = -1;
}
}
else if(key in o2)
{
rval = 1;
}
return rval;
} | javascript | {
"resource": ""
} | |
q31434 | train | function(o1, o2)
{
var rval = 0;
if(o1.constructor === String)
{
if(o2.constructor !== String)
{
rval = -1;
}
else
{
rval = _compare(o1, o2);
}
}
else if(o2.constructor === String)
{
rval = 1;
}
else
{
rval = _compareObject... | javascript | {
"resource": ""
} | |
q31435 | train | function(a, b)
{
var rval = 0;
/*
3. For each property, compare sorted object values.
3.1. The bnode with fewer objects is first.
3.2. For each object value, compare only literals and non-bnodes.
3.2.1. The bnode with fewer non-bnodes is first.
3.2.2. The bnode with a string object is first.
... | javascript | {
"resource": ""
} | |
q31436 | train | function(prefix)
{
var count = -1;
var ng = {
next: function()
{
++count;
return ng.current();
},
current: function()
{
return '_:' + prefix + count;
},
inNamespace: function(iri)
{
return iri.indexOf('_:' + prefix) === 0;
}... | javascript | {
"resource": ""
} | |
q31437 | train | function(parent, parentProperty, value, subjects)
{
var flattened = null;
if(value === null)
{
// drop null values
}
else if(value.constructor === Array)
{
// list of objects or a disjoint graph
for(var i in value)
{
_flatten(parent, parentProperty, value[i], subje... | javascript | {
"resource": ""
} | |
q31438 | train | function(b)
{
var rval = '';
var first = true;
for(var p in b)
{
if(p !== '@id')
{
if(first)
{
first = false;
}
else
{
rval += '|';
}
// property
rval += '<' + p + '>';
... | javascript | {
"resource": ""
} | |
q31439 | train | function(input, frame)
{
var rval = false;
// check if type(s) are specified in frame and input
var type = '@type';
if('@type' in frame &&
input.constructor === Object && type in input)
{
var tmp = (input[type].constructor === Array) ?
input[type] : [input[type]];
var types... | javascript | {
"resource": ""
} | |
q31440 | train | function(input, frame)
{
var rval = false;
// frame must not have a specific type
var type = '@type';
if(!(type in frame))
{
// get frame properties that must exist on input
var props = Object.keys(frame).filter(function(e)
{
// filter non-keywords
return e.indexOf... | javascript | {
"resource": ""
} | |
q31441 | train | function(iri)
{
var iris = Object.keys(embeds);
for(var i in iris)
{
i = iris[i];
if(i in embeds && embeds[i].parent !== null &&
embeds[i].parent['@id'] === iri)
{
delete embeds[i];
... | javascript | {
"resource": ""
} | |
q31442 | train | function(
subjects, input, frame, embeds, autoembed, parent, parentKey, options)
{
var rval = null;
// prepare output, set limit, get array of frames
var limit = -1;
var frames;
if(frame.constructor === Array)
{
rval = [];
frames = frame;
if(frames.length === 0)
{
... | javascript | {
"resource": ""
} | |
q31443 | RDFMakeTerm | train | function RDFMakeTerm(formula,val, canonicalize) {
if (typeof val != 'object') {
if (typeof val == 'string')
return new N3Parser.Literal(val);
if (typeof val == 'number')
return new N3Parser.Literal(val); // @@ differet types
if (typeof val == 'boolean')
return new N3Parser.Literal... | javascript | {
"resource": ""
} |
q31444 | Environment | train | function Environment(options) {
if (!(this instanceof Environment)) {
return new Environment(options);
}
// defaults
options = lodash.defaults(options || {}, {
setup: true,
});
this.env = jjv();
this.env.defaultOptions.checkRequired = true;
this.env.defaultOptions.useDefault = true;
this.env... | javascript | {
"resource": ""
} |
q31445 | updateBrokerCertChain | train | function updateBrokerCertChain (configDir, certChainFile, certChain, verbosity) {
var caBundleFileName = util.getConfigFilePath(configDir, certChainFile)
if (verbosity) {
console.log('Updating certs in ' + caBundleFileName)
}
provisionUtil.saveToFile(caBundleFileName, certChain)
} | javascript | {
"resource": ""
} |
q31446 | updateBrokerListInConfigFile | train | function updateBrokerListInConfigFile (configFileName, brokerLines, verbosity) {
if (verbosity) {
console.log('Updating DXL config file at ' + configFileName)
}
var inBrokerSection = false
var linesAfterBrokerSection = []
var configFileData = util.getConfigFileData(configFileName)
// Replace the curre... | javascript | {
"resource": ""
} |
q31447 | train | function(models, options) {
var i, l, index, model;
options || (options = {});
models = _.isArray(models) ? models.slice() : [models];
for (i = 0, l = models.length; i < l; i++) {
model = this.getByCid(models[i]) || this.get(models[i]);
if (!model) continue;
delete this._... | javascript | {
"resource": ""
} | |
q31448 | add | train | function add(table, inp, state, action, next) {
table[state<<8|inp] = ((action | 0) << 4) | ((next === undefined) ? state : next);
} | javascript | {
"resource": ""
} |
q31449 | add_list | train | function add_list(table, inps, state, action, next) {
for (var i=0; i<inps.length; i++)
add(table, inps[i], state, action, next);
} | javascript | {
"resource": ""
} |
q31450 | AnsiParser | train | function AnsiParser(terminal) {
this.initial_state = 0; // 'GROUND' is default
this.current_state = this.initial_state|0;
// clone global transition table
this.transitions = new Uint8Array(4095);
this.transitions.set(TRANSITION_TABLE);
// global non pushable buffers fo... | javascript | {
"resource": ""
} |
q31451 | getSetting | train | function getSetting (config, section, setting, required, readFromFile,
configPath) {
if (typeof (required) === 'undefined') { required = true }
if (typeof (configPath) === 'undefined') { configPath = null }
if (!config[section]) {
if (required) {
throw new DxlError('Required sectio... | javascript | {
"resource": ""
} |
q31452 | mergeOptions | train | function mergeOptions(parsedOptions) {
return Object.keys(autoflowOptions).reduce(function (accum, k) {
if (!accum[k]) accum[k] = autoflowOptions[k];
return accum;
}, parsedOptions);
} | javascript | {
"resource": ""
} |
q31453 | describe | train | function describe(ctx) {
try {
return ctx.operation.spec.method + ' ' +
ctx.operation.resource.spec.path + ' ';
} catch (err) {
return '';
}
} | javascript | {
"resource": ""
} |
q31454 | validate | train | function validate(res, result) {
if (!result) return true;
var err = new Error('Validation failed');
try {
err.errors = result.errors();
} catch (err) {
err.errors = [result.validation];
}
err.expose = true;
err.statusCode = 400;
err.toJSON = function() {
return {
message: this.messag... | javascript | {
"resource": ""
} |
q31455 | lookup | train | function lookup(obj, type, name) {
while (obj) {
if (obj[type] && obj[type].hasOwnProperty(name)) {
return obj[type][name];
}
obj = obj.parent;
}
} | javascript | {
"resource": ""
} |
q31456 | validateOptions | train | function validateOptions(operation, type, useCoerce) {
var options = { useCoerce: useCoerce };
// capitalize type
var suffix = type[0].toUpperCase() + type.slice(1);
// Get remove option (ex: options.removeHeader)
var removeAdditional = lookup(operation, 'options', 'remove' + suffix);
if (typeof removeAd... | javascript | {
"resource": ""
} |
q31457 | before | train | function before(ctx) {
var fn = lookup(ctx.operation, 'middleware', 'before');
var prefix = describe(ctx);
if (fn) {
return fn(ctx);
} else {
debug(prefix + 'before middleware disabled (not defined)');
}
} | javascript | {
"resource": ""
} |
q31458 | header | train | function header(ctx) {
var prefix = describe(ctx);
var schema = transform.parameters(ctx.operation.spec, 'header');
if (!schema) {
debug(prefix + 'header middleware disabled (no schema)');
return;
}
var env = ctx.operation.resource.api.env;
var options = validateOptions(ctx.operation, 'header', tr... | javascript | {
"resource": ""
} |
q31459 | produces | train | function produces(ctx) {
var mimes = ctx.operation.spec.produces ||
ctx.operation.resource.api.spec.produces || [];
var prefix = describe(ctx);
if (!mimes.length) {
debug(prefix + 'produces validation disabled (no produces)');
}
return function(req, res, next) {
req.sf.accept = accepts(req);
... | javascript | {
"resource": ""
} |
q31460 | query | train | function query(ctx) {
var prefix = describe(ctx);
var schema = transform.parameters(ctx.operation.spec, 'query');
if (!schema) {
debug(prefix + 'query middleware disabled (no schema)');
return;
}
var env = ctx.operation.resource.api.env;
var options = validateOptions(ctx.operation, 'query', true);... | javascript | {
"resource": ""
} |
q31461 | authenticate | train | function authenticate(ctx) {
var fn = lookup(ctx.operation, 'middleware', 'authenticate');
var prefix = describe(ctx);
if (fn) {
return fn(ctx);
} else {
debug(prefix + 'authenticate middleware disabled (not defined)');
}
} | javascript | {
"resource": ""
} |
q31462 | consumes | train | function consumes(ctx) {
if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;
var mimes = ctx.operation.spec.consumes ||
ctx.operation.resource.api.spec.consumes || [];
var prefix = describe(ctx);
if (!mimes.length) {
debug(prefix + 'consumes middleware disabled (no consumes)');
re... | javascript | {
"resource": ""
} |
q31463 | raw | train | function raw(ctx) {
if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;
var limit = lookup(ctx.operation, 'options', 'bodyLimit') || '100kb';
return function(req, res, next) {
rawBody(req, {
length: req.headers['content-length'],
limit: limit,
encoding: http.CHARSET
},... | javascript | {
"resource": ""
} |
q31464 | form | train | function form(ctx) {
if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;
var mimes = ctx.operation.spec.consumes ||
ctx.operation.resource.api.spec.consumes || [];
var mime = 'application/x-www-form-urlencoded';
var prefix = describe(ctx);
var decode = ctx.router.decoder[mime];
if (mi... | javascript | {
"resource": ""
} |
q31465 | body | train | function body(ctx) {
if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;
var consumeMimes = ctx.operation.spec.consumes ||
ctx.operation.resource.api.spec.consumes || [];
var mimes = lodash.intersection(consumeMimes,
Object.keys(ctx.router.decoder));
var prefix = describe(ctx);
if (... | javascript | {
"resource": ""
} |
q31466 | authorize | train | function authorize(ctx) {
var fn = lookup(ctx.operation, 'middleware', 'authorize');
var prefix = describe(ctx);
if (fn) {
return fn(ctx);
} else {
debug(prefix + 'authorize middleware disabled (not defined)');
}
} | javascript | {
"resource": ""
} |
q31467 | after | train | function after(ctx) {
var fn = lookup(ctx.operation, 'middleware', 'after');
var prefix = describe(ctx);
if (fn) {
return fn(ctx);
} else {
debug(prefix + 'after middleware disabled (not defined)');
}
} | javascript | {
"resource": ""
} |
q31468 | getScript | train | function getScript(cfg) {
var script = function(cfg) {
$('#J_Qrcode').qrcode({
'render': 'canvas',
'size': cfg.size || 150,
'color': '#3a3',
'text': cfg.text
});
var canvas = $('#J_Qrcode canvas')[0];
// here is the most important part because if you dont replace you will get... | javascript | {
"resource": ""
} |
q31469 | startInlineServices | train | function startInlineServices() {
// Provide a webhook definition
var hook = {
name: 'Inline Sample',
events: ['message.sent'],
path: '/inline_sample_message_sent',
};
// Register this webhook with Layer's Services
webhooksServices.register({
secret: SECRET,
url: HOST + ':' + PORT,
hoo... | javascript | {
"resource": ""
} |
q31470 | _typedParse | train | function _typedParse(loc, type, data, callback) {
switch(type.toLowerCase()) {
case 'text':
case 'plain':
case 'text/plain':
callback(null, data);
break;
case 'json':
case 'jsonld':
case 'json-ld':
case 'ld+json':
case 'application/json':
case 'application/ld+json':
... | javascript | {
"resource": ""
} |
q31471 | requestProvisionConfig | train | function requestProvisionConfig (managementService, csr, verbosity, callback) {
managementService.request('Requesting client certificate', PROVISION_COMMAND,
{csrString: csr}, verbosity, callback)
} | javascript | {
"resource": ""
} |
q31472 | brokersForConfig | train | function brokersForConfig (brokerLines) {
return brokerLines.reduce(function (acc, brokerLine) {
var brokerElements = brokerLine.split('=')
if (brokerElements.length !== 2) {
throw new DxlError('Invalid key value pair for broker entry: ' +
brokerLine)
}
acc[brokerElements[0]] = brokerEle... | javascript | {
"resource": ""
} |
q31473 | storeProvisionConfig | train | function storeProvisionConfig (config, configDir, filePrefix,
privateKeyFileName, verbosity) {
if (typeof config !== 'string') {
throw new DxlError('Unexpected data type for response: ' +
typeof config)
}
var configElements = config.split(',')
if (configElements.length <... | javascript | {
"resource": ""
} |
q31474 | ManagementService | train | function ManagementService (hostInfo) {
if (!hostInfo.hostname) {
throw new TypeError('Hostname is required for management service requests')
}
if (!hostInfo.user) {
throw new TypeError('User name is required for management service requests')
}
if (!hostInfo.password) {
throw new TypeError('Passwo... | javascript | {
"resource": ""
} |
q31475 | httpGet | train | function httpGet (description, currentRedirects, requestOptions, verbosity,
responseCallback) {
var requestUrl = toUrlString(requestOptions)
var responseBody = ''
if (verbosity > 1) {
console.log('HTTP request to: ' + requestUrl)
}
var request = https.get(requestOptions, function (resp... | javascript | {
"resource": ""
} |
q31476 | Assemble | train | function Assemble(options) {
if (!(this instanceof Assemble)) {
return new Assemble(options);
}
Templates.call(this, options);
this.is('assemble');
this.initCore();
} | javascript | {
"resource": ""
} |
q31477 | train | function(e) {
this._tabReset();
if (e.which == 9) {
this.flags.keyTab = true;
if (e.shiftKey) { this.flags.keyShift = true; }
}
} | javascript | {
"resource": ""
} | |
q31478 | train | function(current, $scope) {
var $selfRef = this;
var selectables = $selfRef._tabItems($scope);
var nextIndex = 0;
if ($(current).length === 1){
var currentIndex = selectables.index(current);
if (currentIndex + 1 < selectables.length) {
... | javascript | {
"resource": ""
} | |
q31479 | Operation | train | function Operation(spec, options, fn) {
if (typeof options === 'function') {
fn = [].slice.call(arguments).slice(1);
options = {};
} else if (Array.isArray(options)) {
fn = options;
options = {};
} else if (!Array.isArray(fn)) {
fn = [].slice.call(arguments).slice(2);
}
if (!(this instanc... | javascript | {
"resource": ""
} |
q31480 | train | function(n, symbol, dp, callback) {
if (n < 0 || n > 7) {
throw "Invalid digit number";
}
if (!(symbol in MAX7219._Font)) {
throw "Invalid symbol string";
}
var byte = MAX7219._Font[symbol] | (dp ? (1 << 7) : 0);
this._shiftOut(MAX7219._Registers["Digit" + n], byte, callback);
} | javascript | {
"resource": ""
} | |
q31481 | train | function(callback) {
if (!this._decodeModes) {
this.setDecodeNone();
}
for (var i = 0; i < this._decodeModes.length; i++) {
var mode = this._decodeModes[i];
if (mode == 0) {
this.setDigitSegmentsByte(i, 0x00, callback);
} else {
this.setDigitSymbol(i, " ", false, cal... | javascript | {
"resource": ""
} | |
q31482 | train | function(brightness, callback) {
if (brightness < 0 || brightness > 15) {
throw "Invalid brightness number";
}
this._shiftOut(MAX7219._Registers.Intensity, brightness, callback);
} | javascript | {
"resource": ""
} | |
q31483 | train | function(limit, callback) {
if (limit < 1 || limit > 8) {
throw "Invalid scan limit number";
}
this._shiftOut(MAX7219._Registers.ScanLimit, limit - 1, callback);
} | javascript | {
"resource": ""
} | |
q31484 | train | function(firstByte, secondByte, callback) {
if (!this._spi) {
throw "SPI device not initialized";
}
for (var i = 0; i < this._buffer.length; i += 2) {
this._buffer[i] = MAX7219._Registers.NoOp;
this._buffer[i + 1] = 0x00;
}
var offset = this._activeController * 2;
this._buffe... | javascript | {
"resource": ""
} | |
q31485 | registerService | train | function registerService (client, service) {
clearTtlTimeout(service)
if (client.connected) {
var request = new Request(DXL_SERVICE_REGISTER_REQUEST_TOPIC)
request.payload = JSON.stringify({
serviceType: service.info.serviceType,
metaData: service.info.metadata,
requestChannels: service.i... | javascript | {
"resource": ""
} |
q31486 | unregisterService | train | function unregisterService (client, service, callback) {
if (client.connected) {
var request = new Request(DXL_SERVICE_UNREGISTER_REQUEST_TOPIC)
request.payload = JSON.stringify({
serviceGuid: service.info.serviceId})
var unregisterCallback = null
if (callback) {
unregisterCallback = funct... | javascript | {
"resource": ""
} |
q31487 | findOpenSslBin | train | function findOpenSslBin (opensslBin) {
if (opensslBin) {
if (!fs.existsSync(opensslBin)) {
throw new DxlError('Unable to find openssl at: ' + opensslBin)
}
} else {
opensslBin = which.sync('openssl', {nothrow: true})
if (!opensslBin && (os.platform() === 'win32')) {
opensslBin = DEFAULT_... | javascript | {
"resource": ""
} |
q31488 | indentedLogOutput | train | function indentedLogOutput (logOutput) {
logOutput = logOutput.toString()
if (logOutput) {
logOutput = '\n ' + logOutput.toString().replace(/(\r?\n)/g, '$1 ')
}
return logOutput
} | javascript | {
"resource": ""
} |
q31489 | buildCsrSubject | train | function buildCsrSubject (commonName, options) {
var subject = '/CN=' + commonName
Object.keys(SUBJECT_ATTRIBUTES).forEach(function (key) {
if (options[key]) {
subject = subject + '/' + SUBJECT_ATTRIBUTES[key].name + '=' +
options[key]
}
})
return subject
} | javascript | {
"resource": ""
} |
q31490 | train | function (description, commandArgs, opensslBin, verbosity,
input) {
opensslBin = findOpenSslBin(opensslBin)
if (verbosity) {
if (description) {
console.log(description)
}
if (verbosity > 1) {
console.log("Running openssl. Path: '" + opensslBin +
... | javascript | {
"resource": ""
} | |
q31491 | adjust | train | function adjust(r, e, time, def) {
const requested = r[def.field];
const current = def.get(time, e.options);
if(r.relationToCurrent === 'auto') {
if(requested < current) {
time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
} else {
time = def.set(time, requested, e.options);
}
} el... | javascript | {
"resource": ""
} |
q31492 | traverse | train | function traverse(value, cbs) {
cbs = cbs || {};
if (Array.isArray(value)) {
if (cbs.beforeArray) value = cbs.beforeArray(value, cbs);
value = value.map(function(v) {
return traverse(v, cbs);
});
if (cbs.afterArray) value = cbs.afterArray(value, cbs);
} else if (typeof value === 'object')... | javascript | {
"resource": ""
} |
q31493 | transform | train | function transform(value, options) {
options = options || {};
return traverse(value, {
beforeObject: function(v) {
if (options.removeFormats &&
typeof v.format === 'string' &&
typeof v.type === 'string' &&
v.type !== 'string') {
delete v.format;
}
return... | javascript | {
"resource": ""
} |
q31494 | model | train | function model(spec) {
var schema = lodash.cloneDeep(spec);
delete schema.id;
schema = transform(schema, {
removeFormats: true,
});
return schema;
} | javascript | {
"resource": ""
} |
q31495 | getText | train | function getText(msg) {
return msg.parts.filter(function (part) {
return part.mime_type === 'text/plain';
}).map(function (part) {
return part.body;
}).join('; ');
} | javascript | {
"resource": ""
} |
q31496 | rollTheDie | train | function rollTheDie(msg, text) {
var conversationId = msg.conversation.id;
var matches = text.match(/die (\d+)/i);
if (matches && matches[1]) {
var dieCount = Number(matches[1]);
var result = [];
if (dieCount > 20) {
layerClient.messages.sendTextFromName(conversationId, 'Die-bot',... | javascript | {
"resource": ""
} |
q31497 | foodTalk | train | function foodTalk (msg, text) {
var conversationId = msg.conversation.id;
var matches = text.match(/eat my (.+?)\b/i);
if (matches) {
layerClient.messages.sendTextFromName(conversationId, 'Food-bot', 'My ' + matches[1] + ' taste a lot better than yours');
} else {
var messages = [
'... | javascript | {
"resource": ""
} |
q31498 | logEvents | train | function logEvents(flowFn, eventWildcard) {
if (typeof(flowFn) !== 'function') { // only wildcard provided
eventWildcard = flowFn;
flowFn = undefined;
}
if (!flowFn) flowFn = autoflow; // use global
trackTasks();
return logEventsMod.logEvents(flowFn, eventWildcard);
} | javascript | {
"resource": ""
} |
q31499 | train | function (command, id) {
id = id || '';
if (id) {
this.queue.push(id);
}
SocketService.emit('execute', {
command: command,
id: id
});
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.