_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39700 | hookInstanbul | train | function hookInstanbul(opts) {
return loadJspmConfig(opts).then(loader => {
sh.echo('Registering instrumentation hook to loader...');
systemIstanbul.hookSystemJS(loader, opts.exclude(loader.baseURL));
return loader;
});
} | javascript | {
"resource": ""
} |
q39701 | createReport | train | function createReport(coverage, opts) {
const collector = new istanbul.Collector();
const reporter = new istanbul.Reporter(null, opts.coverage);
const sync = true;
sh.echo('Creating reports...');
collector.add(coverage);
reporter.addAll(opts.reports);
reporter.write(collector, sync, () => sh.echo('Repor... | javascript | {
"resource": ""
} |
q39702 | rejectHandler | train | function rejectHandler(err) {
process.stderr.write(`${err.stack || err}\n`);
if (sh.config.fatal) {
sh.exit(1);
}
return Promise.reject(err);
} | javascript | {
"resource": ""
} |
q39703 | execute | train | function execute(req, res) {
Persistence.save(this.state.store, this.state.conf);
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q39704 | train | function( path ) {
var normalized = [];
var parts = path.split( '/' );
for( var i = 0; i < parts.length; i++ ) {
if( parts[i] === '.' ) {
continue;
}
if( parts[i] === '..' && normalized.length && normalized[normalized.length - 1] !== '..' ) {
normal... | javascript | {
"resource": ""
} | |
q39705 | train | function(queryRunner, options) {
options = options || {};
this.queryParser = new QueryParser(options.paramValueRegEx);
var indexNameBuilder = options.indexNameBuilder || new DefaultIndexNameBuilder();
this.queryBuilder = new EsQueryBuilder(indexNameBuilder, {
defaults: options.queryDefaults
... | javascript | {
"resource": ""
} | |
q39706 | firstCommit | train | function firstCommit(dir, cb) {
if (typeof dir === 'function') {
return firstCommit(process.cwd(), dir);
}
if (typeof cb !== 'function') {
throw new TypeError('expected callback to be a function');
}
lazy.git(dir).log(function(err, history) {
if (err) return cb(err);
history.sort(function(a,... | javascript | {
"resource": ""
} |
q39707 | _readJSONFile | train | function _readJSONFile (file, callback) {
if ("undefined" === typeof file) {
throw new ReferenceError("missing \"file\" argument");
}
else if ("string" !== typeof file) {
throw new TypeError("\"file\" argument is not a string");
}
else if ("" === file.trim()) {
throw new Error("\"file\"... | javascript | {
"resource": ""
} |
q39708 | QuestionsStore | train | function QuestionsStore(options) {
debug('initializing from <%s>', __filename);
Cache.call(this, options);
this.createStores(this, this.options);
this.listen(this);
} | javascript | {
"resource": ""
} |
q39709 | error | train | function error(scope, err, parameters) {
if(err.code == 'EACCES') {
scope.raise(scope.errors.EPERM, parameters);
}
} | javascript | {
"resource": ""
} |
q39710 | execute | train | function execute(argv, bin, args, req) {
var config = this.configure();
var errors = this.errors, scope = this, e;
var dir = config.bin || dirname(argv[1]);
var local = path.join(dir, bin);
var exists = fs.existsSync(local);
var data = {bin: bin, dir: dir, local: local, args: args};
if(!exists) {
e = ... | javascript | {
"resource": ""
} |
q39711 | stringMatch | train | function stringMatch(stringValues) {
return function(testValue) {
for (var i = stringValues.length - 1; i >= 0; i--) {
if (stringValues[i] === testValue) {
return true;
}
}
return false;
};
} | javascript | {
"resource": ""
} |
q39712 | train | function (data) {
var q = _q.defer();
data = data.replace(/\'/g,"\\\'");
data = data.replace(/\"/g,'\\\"');
exec(`echo "${data}" | crontab -`, (err, stdout, stderr) => {
if (err) q.reject(err);
if(stdout)q.resolve(stdout);
else q.resolve(stderr);
});
return q.promise;
} | javascript | {
"resource": ""
} | |
q39713 | train | function(cb) {
if (typeof cb === "function") {
var opts = {
url: uri + 'user',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
els... | javascript | {
"resource": ""
} | |
q39714 | train | function(cb) {
var opts = {
url: uri + 'user/stream',
method: 'GET',
qs: qs,
json: true
};
request(opts,function(e,r,b) {
if (e) cb(e)
else {
if (r.statusCode==200) cb(null, b)
else {
... | javascript | {
"resource": ""
} | |
q39715 | train | function(url,overwrite,cb) {
if (typeof overwrite === "function") {
cb = overwrite;
overwrite = false;
}
var opts = {
url: uri + 'device/'+device+'/callback',
method: 'POST',
qs: qs,
json: { url:url }
};
... | javascript | {
"resource": ""
} | |
q39716 | train | function(start, end, cb) {
if (typeof start === "function") {
cb = start;
start = false;
} else if (typeof end === "function") {
cb = end;
end = false;
}
if (start instanceof Date) start = start.getTime();
if (start) qs.... | javascript | {
"resource": ""
} | |
q39717 | train | function(filter,cb) {
if (!filter) {
filter = {};
} else if (typeof filter == "function") {
cb = filter;
filter = {};
} else if (typeof filter == "string") {
filter = {device_type:filter}; // Backwards compatibility
}
var opts = {
url: uri + 'devices... | javascript | {
"resource": ""
} | |
q39718 | getPrimes | train | function getPrimes(limit) {
var sieve = new Array(limit);
var n, j, k;
var last = Math.floor(Math.sqrt(limit));
for (n=2; n < limit; n++) {
sieve[n] = true;
}
for (n=2; n <= last;) {
for (j= n+n; j < limit; j += n) {
sieve[j] = false;
}
for (j=1; j < l... | javascript | {
"resource": ""
} |
q39719 | fill | train | function fill(size, seed, multiplier) {
var hash = new HashTable(size, seed, multiplier);
var x = agentdb.getX(1, 1); // dummy data Unknown, Unknown
agents.forEach(function (agent) {
if (agent.status < 2) {
var obj = { "a": agent.agent, "x": x };
hash.add('a', obj);
}... | javascript | {
"resource": ""
} |
q39720 | dumpHistory | train | function dumpHistory(history, size, depth) {
console.log("Hash table history, size="+size+", average depth="+depth);
for (var n=0; n < history.length; n++) {
console.log(" Depth=" + n + ", count=" + history[n] + ", percent=" + (history[n] / size));
}
console.log("");
} | javascript | {
"resource": ""
} |
q39721 | getDepth | train | function getDepth(history) {
var total= history[0];
for (var n=1; n < history.length; n++) {
total = total + (n * n * history[n]);
}
var result = total / agents.length;
// console.log("total=" + total+", result=" + result);
return result;
} | javascript | {
"resource": ""
} |
q39722 | main | train | function main() {
if (verbose) { console.log("Finding primes to " + UPPER); }
var primes = getPrimes(UPPER);
if (verbose) { console.log("Done."); }
var bestSize = varySize(LOWER, UPPER, 5381, 33, primes);
var bestSeed = varySeed(0, 8192, bestSize, 33);
var bestMult = varyMultiplier(2, 256, ... | javascript | {
"resource": ""
} |
q39723 | include | train | function include(list) {
var cmd, clazz, i, file, j, name, newname;
for(i = 0;i < list.length;i++) {
file = list[i];
try {
clazz = require(file);
// assume it is already instantiated
if(typeof clazz === 'object') {
cmd = clazz;
}else{
cmd = new cla... | javascript | {
"resource": ""
} |
q39724 | walk | train | function walk(files, cb, list) {
var i = 0;
list = list || [];
function check(file, cb) {
fs.stat(file, function onStat(err, stats) {
if(err) return cb(err);
if(stats.isFile() && !/\.js$/.test(file)) {
log.warning('ignoring %s', file);
return cb();
}
... | javascript | {
"resource": ""
} |
q39725 | validateTextOperationJSON | train | function validateTextOperationJSON (op) {
debug('validateTextOperationJSON %o', op)
assertErr(Array.isArray(op), Error, 'operation must be an array', { op: op })
assertErr(op.length, Error, 'operation cannot be empty', { op: op })
var type
var lastType = ''
op.forEach(function (item) {
if (typeof item =... | javascript | {
"resource": ""
} |
q39726 | trim | train | function trim(str) {
var input = str.replace(/\s\s+/g, ' ').trim();
var words = input.split(' ');
if (_.contains(LANG_WORDS, _.first(words))) {
return words.slice(1).join(' ');
}
return input;
} | javascript | {
"resource": ""
} |
q39727 | InvertFilter | train | function InvertFilter()
{
core.AbstractFilter.call(this,
// vertex shader
null,
// fragment shader
fs.readFileSync(__dirname + '/invert.frag', 'utf8'),
// custom uniforms
{
invert: { type: '1f', value: 1 }
}
);
} | javascript | {
"resource": ""
} |
q39728 | train | function (req, res, next) {
req.mounted = true
req.url = req.url.replace(remove, '')
// clear cached req.path
delete req._path
delete req._pathLength
next()
} | javascript | {
"resource": ""
} | |
q39729 | deleteSelf | train | function deleteSelf(callback) {
var _this = this;
_flowsync2["default"].series([function (done) {
_this.beforeDelete(done);
}, function (done) {
if (_this.constructor.useSoftDelete !== undefined) {
_this.softDestroy(done);
} else {
_this.destroy(done);
}
}, function (done) {
_th... | javascript | {
"resource": ""
} |
q39730 | inject | train | function inject(PromiseConstructor, extName) {
if (typeof PromiseConstructor === 'string') {
extName = PromiseConstructor;
}
extName = typeof extName === 'string' ? extName : 'delay';
PromiseConstructor =
(typeof PromiseConstructor === 'function' && PromiseConstructor) ||
(typeof Promise === 'functio... | javascript | {
"resource": ""
} |
q39731 | generate | train | function generate( arr, comment, _indent ) {
try {
const indent = typeof _indent !== "undefined" ? _indent : " ";
if ( arr.length === 0 ) return "";
let out = '';
if ( comment && comment.length > 0 ) {
let
len = comment.length + 3,
dashes ... | javascript | {
"resource": ""
} |
q39732 | buildViewStatics | train | function buildViewStatics( def, code ) {
try {
let statics = def[ "view.statics" ];
if ( typeof statics === 'undefined' ) return;
if ( typeof statics === 'string' ) statics = [ statics ];
else if ( !Array.isArray( statics ) ) {
throw Error( "view.statics must be a string... | javascript | {
"resource": ""
} |
q39733 | buildViewAttribsFire | train | function buildViewAttribsFire( def, code ) {
code.pm = true;
const attribs = def[ "view.attribs" ];
if ( typeof attribs !== 'object' ) return;
try {
for ( const attName of Object.keys( attribs ) ) {
const camelCaseAttName = camelCase( attName );
if ( !code.isAction( attNa... | javascript | {
"resource": ""
} |
q39734 | buildViewAttribsSpecial | train | function buildViewAttribsSpecial( attName, attValue, code ) {
const
type = attValue[ 0 ],
init = attValue[ 1 ];
let requireConverter = false;
try {
if ( typeof attValue.behind !== 'undefined' ) {
buildViewAttribsSpecialCodeBehind( attName, attValue.behind, code );
... | javascript | {
"resource": ""
} |
q39735 | buildViewAttribsInit | train | function buildViewAttribsInit( attName, attValue, code ) {
try {
if ( typeof attValue === "undefined" ) {
// code.section.attribs.init.push(`this.${attName} = args[${JSON.stringify(attName)}];`);
code.section.attribs.init
.push( `pm.set("${attName}", args[${JSON.strin... | javascript | {
"resource": ""
} |
q39736 | buildViewAttribsInitFire | train | function buildViewAttribsInitFire( attName, code ) {
try {
code.section.attribs.init
.push( `pm.fire("${attName}");` );
} catch ( ex ) {
bubble(
ex,
`buildViewAttribsInitFire(${attName})`
);
}
} | javascript | {
"resource": ""
} |
q39737 | buildFunction | train | function buildFunction( def, code, varName ) {
if ( isSpecial( def, "behind" ) ) {
const behindFunctionName = def[ 1 ];
code.addNeededBehindFunction( behindFunctionName );
code.that = true;
return [
"value => {",
" try {",
` CODE_BEHIND${keySyn... | javascript | {
"resource": ""
} |
q39738 | extractAttribs | train | function extractAttribs( def ) {
var key, val, attribs = { standard: {}, special: {}, implicit: [] };
for ( key in def ) {
val = def[ key ];
if ( RX_INTEGER.test( key ) ) {
attribs.implicit.push( val );
} else if ( RX_STD_ATT.test( key ) ) {
attribs.standard[ key ... | javascript | {
"resource": ""
} |
q39739 | declareRootElement | train | function declareRootElement( def, code ) {
const rootElementName = buildElement( def, code );
code.section.elements.define.push( "//-----------------------" );
code.section.elements.define.push( "// Declare root element." );
code.section.elements.define.push(
"Object.defineProperty( this, '$', ... | javascript | {
"resource": ""
} |
q39740 | outputAll | train | function outputAll( code, moduleName ) {
try {
let out = outputComments( code );
out += " module.exports = function() {\n";
out += outputNeededConstants( code );
out += ` //-------------------
// Class definition.
const ViewClass = function( args ) {
try {
i... | javascript | {
"resource": ""
} |
q39741 | outputComments | train | function outputComments( code ) {
try {
let out = '';
if ( code.section.comments.length > 0 ) {
out += ` /**\n * ${code.section.comments.join("\n * ")}\n */\n`;
}
return out;
} catch ( ex ) {
bubble( ex, "outputComments" );
return null;
}
} | javascript | {
"resource": ""
} |
q39742 | outputNeededConstants | train | function outputNeededConstants( code ) {
try {
let out = arrayToCodeWithNewLine( code.generateRequires(), " " );
out += arrayToCodeWithNewLine( code.generateNeededBehindFunctions(), " " );
out += arrayToCodeWithNewLine( code.generateFunctions(), " " );
out += arrayToCodeWith... | javascript | {
"resource": ""
} |
q39743 | outputClassBody | train | function outputClassBody( code ) {
try {
let out = '';
if ( code.that ) out += " const that = this;\n";
if ( code.pm ) out += " const pm = PM(this);\n";
out += generate( code.section.attribs.define, "Create attributes", " " );
out += generate( code.sectio... | javascript | {
"resource": ""
} |
q39744 | bubble | train | function bubble( ex, origin ) {
if ( typeof ex === 'string' ) {
throw Error( `${ex}\n...in ${origin}` );
}
throw Error( `${ex.message}\n...in ${origin}` );
} | javascript | {
"resource": ""
} |
q39745 | MongoStore | train | function MongoStore(uri, options) {
var self = this;
this.options = options || (options = {});
options.collectionName = options.collectionName || 'sessions';
// 1 day
options.ttl = options.ttl || 24 * 60 * 60 * 1000;
// 60 s
options.cleanupInterval = options.clea... | javascript | {
"resource": ""
} |
q39746 | Message | train | function Message(message, headers, deliveryInfo, obj) {
// Crane uses slash ('/') separators rather than period ('.')
this.topic = deliveryInfo.routingKey.replace(/\./g, '/');
this.headers = headers;
if (deliveryInfo.contentType) { this.headers['content-type'] = deliveryInfo.contentType; }
if (Buffer.isBuf... | javascript | {
"resource": ""
} |
q39747 | train | function(processingQueue, phase) {
var that = this;
verbose && console.log('phase is: ' + phase, processors);
processingQueue.forEach(function(context) {
var processor = processors[phase][context.fileType];
verbose && console.log('runProcessor with ', that, context );
... | javascript | {
"resource": ""
} | |
q39748 | getRoomSlots | train | function getRoomSlots (semester, minRequestSpace = 1000, verbose = false, departments = []) {
validateInput("semester", semester, [1, 2], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
validateInput("verbose", verbose, [true, false], "set");
validateInput("departments",... | javascript | {
"resource": ""
} |
q39749 | getHours | train | function getHours (verbose = false, minRequestSpace = 500) {
validateInput("verbose", verbose, [true, false], "set");
validateInput("minRequestSpace", minRequestSpace, [0, 100000], "range");
return scrapeBuildings(verbose, minRequestSpace);
} | javascript | {
"resource": ""
} |
q39750 | validateInput | train | function validateInput(inputName, input, acceptableValues, acceptableValueType) {
let validInput = true;
if (acceptableValueType == "range") {
if (input < Math.min(...acceptableValues) || input > Math.max(...acceptableValues)) {
validInput = false;
}
} else if (acceptableValueTyp... | javascript | {
"resource": ""
} |
q39751 | parseLine | train | function parseLine(line, lineno, options) {
let command = null;
const lineContinuationRegex = (options && options.lineContinuationRegex
|| TOKEN_LINE_CONTINUATION);
line = line.trim();
if (!line) {
// Ignore empty lines
return { command: null, remainder: '' };
}
if (isComment(line)) {
// Handle comment... | javascript | {
"resource": ""
} |
q39752 | dig | train | function dig(obj) {
var iterateeFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (val, key, iterableParent) {
return val;
};
// eslint-disable-line no-unused-vars
// modifierFn = v => v,
return (0, _each2.default)(obj, function iterator(itValue, key, itObj) {
var proce... | javascript | {
"resource": ""
} |
q39753 | train | function (bbsource) {
var parts = {
Header: '',
Setup: '// Initial Setup',
Events: '// Backbone.Events',
Model: '// Backbone.Model',
Collection: '// Backbone.Collection',
Router: '// Backbone.Router',
History: '// Backbone.History',
View: '// Backbone.View',
Syn... | javascript | {
"resource": ""
} | |
q39754 | train | function (combinations, parts, backboneSrc) {
var src = '';
var allCombinations = [];
parts.forEach(function (part) {
allCombinations.push(combinations[_.str.capitalize(part.toLowerCase())]);
});
var neededParts = _.union.apply(_, allCombinations);
var backboneParts = getBackboneParts(ba... | javascript | {
"resource": ""
} | |
q39755 | namedLevelStore | train | function namedLevelStore (name) {
assert.equal(typeof name, 'string', 'named-level-store: name should be a string')
const location = path.join(process.env.HOME, '.leveldb', name)
mkdirp.sync(location)
const db = level(location)
db.location = location
return db
} | javascript | {
"resource": ""
} |
q39756 | removeSrcDirPrefixFromFile | train | function removeSrcDirPrefixFromFile( srcDir, file ) {
if ( typeof srcDir !== 'string' ) return file;
if ( typeof file !== 'string' ) return file;
if ( file.substr( 0, srcDir.length ) !== srcDir ) {
return file;
}
return file.substr( srcDir.length );
} | javascript | {
"resource": ""
} |
q39757 | train | function (value) {
if (value === null) {
return '';
}
if (value === undefined) {
return '';
}
switch (typeof value) {
case 'object' :
if (value instanceof Blob) {
return value;
} else {
return JSON.stringify(value);
}
break;
case 'string':
return value;
default :
... | javascript | {
"resource": ""
} | |
q39758 | createConfig | train | async function createConfig(optionsArgs) {
const options = {
...DEFAULT_OPTIONS,
...optionsArgs,
};
const { rules, base } = options;
const config = {
...base,
rules: base.rules || {},
};
return Object.keys(config)
.reduce(async (collection, key) => {
const previous = await collec... | javascript | {
"resource": ""
} |
q39759 | SimpleCommand | train | function SimpleCommand(exec, args, workdir) {
this.exec = /^win/.test(process.platform) ? findWindowsExec(exec) : exec;
this.args = args;
this.workdir = workdir;
this.setOptions();
this.commandLine = util.format('%s %s', this.exec, this.args.join(' '));
} | javascript | {
"resource": ""
} |
q39760 | train | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no folders specified to create');
}
items.forEach(function(item) {
try {
_fs.mkdirSync(item);
} catch (e) {
// Eat the ex... | javascript | {
"resource": ""
} | |
q39761 | train | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to create');
}
items.forEach(function(item) {
var contents;
var linkTarget;
var filePath;
if (typeof item === ... | javascript | {
"resource": ""
} | |
q39762 | train | function() {
var items = _utils.getArgArray(arguments);
if (items.length === 0) {
throw new Error('no files specified to clean up');
}
items.forEach(function(item) {
try {
var path = (typeof item === 'string') ? item : item.path;
_f... | javascript | {
"resource": ""
} | |
q39763 | train | function(options) {
// Ensure an instance is created
if (!(this instanceof TimeChunkedStream)) {
return new TimeChunkedStream(options);
}
// Always decode strings
options.decodeStrings = true;
// Initialize base class
Transform.call(this, options);
// Create internal buffer
this._buffer = new ... | javascript | {
"resource": ""
} | |
q39764 | linkBootstrap | train | function linkBootstrap() {
fs.symlink(bootstrap, path.resolve(yeoman, 'bootstrap-less'), 'dir', function(err) {
if (err) return console.log('symlink error:', err);
return console.log('Successfully installed yeoman-bootstrap in', bootstrap,
' and created a symlink in', yeoman);
});
} | javascript | {
"resource": ""
} |
q39765 | toPropertyNamesArray | train | function toPropertyNamesArray(propertyNamesString, separator) {
return propertyNamesString.split(separator || PROPERTY_NAME_SEPARATOR).map(s => trim(s)).filter(s => !!s);
} | javascript | {
"resource": ""
} |
q39766 | linsert | train | function linsert(key, beforeAfter, pivot, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.linsert(beforeAfter, pivot, value);
} | javascript | {
"resource": ""
} |
q39767 | lindex | train | function lindex(key, index, req) {
var val = this.getKey(key, req);
if(!val) return null;
return val.lindex(index);
} | javascript | {
"resource": ""
} |
q39768 | lpush | train | function lpush(key /*value-1, value-N, req*/) {
var val = this.getKey(key, req)
, args = slice.call(arguments, 1)
, req;
if(typeof args[args.length - 1] === 'object') {
req = args.pop();
}
if(val === undefined) {
val = new List();
this.setKey(key, val, undefined, undefined, undefined, req);
... | javascript | {
"resource": ""
} |
q39769 | lpushx | train | function lpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.lpush([value]);
} | javascript | {
"resource": ""
} |
q39770 | rpushx | train | function rpushx(key, value, req) {
var val = this.getKey(key, req);
if(val === undefined) {
return 0;
}
return val.rpush([value]);
} | javascript | {
"resource": ""
} |
q39771 | lpop | train | function lpop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.lpop();
if(val.llen() === 0) {
this.delKey(key, req);
}
return element;
} | javascript | {
"resource": ""
} |
q39772 | lrem | train | function lrem(key, count, value, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.lrem(count, value);
if(val.llen() === 0) {
this.delKey(key, req);
}
return deleted;
} | javascript | {
"resource": ""
} |
q39773 | ltrim | train | function ltrim(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
val.ltrim(start, stop);
if(val.llen() === 0) {
this.delKey(key, req);
}
return OK;
} | javascript | {
"resource": ""
} |
q39774 | lrange | train | function lrange(key, start, stop, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
return val.lrange(start, stop);
} | javascript | {
"resource": ""
} |
q39775 | llen | train | function llen(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.llen();
} | javascript | {
"resource": ""
} |
q39776 | processToken | train | function processToken(token, done) {
var user = _.find(users, function (item) {
return item.username === token[claims.username];
});
if (!user) {
user = {
id : token[claims.id] || currId++,
username : token[claims.username],
email : token... | javascript | {
"resource": ""
} |
q39777 | train | function (options) {
winston.Transport.call(this, options);
options = options || {};
var apiKey = options.apiKey;
var projectId = options.projectId;
var apiHostName = options.apiHostName;
var formatter = options.formatter || 'kvp';
if (!apiKey || !projectId || !apiHostName) {
thro... | javascript | {
"resource": ""
} | |
q39778 | stringify | train | function stringify(js, indent, indentUnit) {
if (typeof indent === 'undefined') indent = '';
if (typeof indentUnit === 'undefined') indentUnit = ' ';
var t = typeof js;
if (t === 'string') {
return JSON.stringify(js);
}
if (t === 'number') {
return js;
}
if (t === 'boole... | javascript | {
"resource": ""
} |
q39779 | main | train | function main (action, argv, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
setImmediate(() => cli.dispatch(argv))
return cli
} | javascript | {
"resource": ""
} |
q39780 | lookup | train | function lookup (action, options) {
options = options || {}
const cli = new CliDispatch(action, options.actions || 'actions', options.base || callersDir())
return cli.lookup()
} | javascript | {
"resource": ""
} |
q39781 | CliDispatch | train | function CliDispatch (action, dir, baseDir) {
this.action = action
this.dir = dir
this.baseDir = baseDir
} | javascript | {
"resource": ""
} |
q39782 | getCliendIdFromCert | train | function getCliendIdFromCert() {
var x509 = require('x509');
var certJson = x509.parseCert(fs.readFileSync(process.cwd()+Constant.CERTIFICATE_PATH).toString());
var cliendId = cert && cert.subject && cert.subject.commonName;
return clientId;
} | javascript | {
"resource": ""
} |
q39783 | verifyPermission | train | function verifyPermission(appId,uaaCredential) {
var deferred = Q.defer();
var cloudControllerUrl = process.env.cloudControllerUrl;
if (!cloudControllerUrl) {
var errMsg = "The system variable 'cloudControllerUrl' is missing.";
ibmlogger.getLogger().error(errMsg);
deferred.reject({code:Constant.MISSING_CLOUDC... | javascript | {
"resource": ""
} |
q39784 | getOAuthAccessToken | train | function getOAuthAccessToken(appId,clientId,imfCert,properties) {
var deferred = Q.defer();
var imfServiceUrl = process.env.imfServiceUrl;
var requestUrl = imfServiceUrl+"/authorization/v1/apps/"+appId+"/token";
var requestOptions = {url: requestUrl,headers: {'Authorization': 'IMFCert '+imfCert}, form:{'grant_typ... | javascript | {
"resource": ""
} |
q39785 | CommandLine | train | function CommandLine(commands) {
this.keys = Object.keys(commands);
this.commands = commands;
this.args = process.argv.slice(2);
this.context = this.args[0] || null;
this.help = {
before: '',
after: ''
}
} | javascript | {
"resource": ""
} |
q39786 | padString | train | function padString(str, len) {
return str.split().concat(new Array(len-str.length)).join(' ');
} | javascript | {
"resource": ""
} |
q39787 | train | function () {
if (this.options.switchRowsAndColumns) {
this.columns = this.rowsToColumns(this.columns);
}
// Interpret the info about series and columns
this.getColumnDistribution();
// Interpret the values into right types
this.parseTypes();
// Handle columns if a handleColumns callback is giv... | javascript | {
"resource": ""
} | |
q39788 | train | function (str, inside) {
if (typeof str === 'string') {
str = str.replace(/^\s+|\s+$/g, '');
// Clear white space insdie the string, like thousands separators
if (inside && /^[0-9\s]+$/.test(str)) {
str = str.replace(/\s/g, '');
}
if (this.decimalRegex) {
str = str.replace(this.decimalRegex,... | javascript | {
"resource": ""
} | |
q39789 | doAction | train | function doAction() {
var now = (new Date()).getTime();
var diff = now - lastTapTime;
var isDiffElemSafeDelay = elem !== lastElemTapped && diff > 200;
var isSameElemSafeDelay = elem === lastElemTapped && diff > sameElemSafeDelay;
if (tapped && (isDiffElemSafe... | javascript | {
"resource": ""
} |
q39790 | getComparator | train | function getComparator(sortOrder) {
if (typeof sortOrder === 'function') {
return sortOrder;
}
const comparators = {
[ASC]: ascendingSort,
[DESC]: descendingSort,
[ASC_LENGTH]: lengthSort,
[DESC_LENGTH]: lengthReverseSort
};
return comparators[sortOrder];
} | javascript | {
"resource": ""
} |
q39791 | stripAndSerializeComment | train | function stripAndSerializeComment( lineNumber, sourceStr ) {
// Strip comment delimiter tokens
let stripped = sourceStr
.replace( patterns.commentBegin, '' )
.replace( patterns.commentEnd, '' )
.split( '\n' )
.map( line => line.replace( rCommentLinePrefix, '' ) );
... | javascript | {
"resource": ""
} |
q39792 | serializeTags | train | function serializeTags( lineNumber, tags ) {
return tags.split( /\n/ )
.reduce( function ( acc, line, index ) {
if ( !index || rTagName.test( line ) ) {
acc.push( `${line}\n` );
}
else {
acc[ acc.length - 1 ] += `${line}\n`;
... | javascript | {
"resource": ""
} |
q39793 | StubServer | train | function StubServer(app) {
_classCallCheck(this, StubServer);
this._app = app;
app.createServer = this.createServer_.bind(this, app.createServer || function () { throw new Error("no registered transport provider"); });
} | javascript | {
"resource": ""
} |
q39794 | getValueAt | train | function getValueAt(dataObject, path)
{
if (_.isUndefined(dataObject)) {
return undefined;
}
if (!_.isString(path)) {
return dataObject;
}
var tokens = path.split('.');
var property = tokens[0];
var subpath = tokens.slice(1).join('.... | javascript | {
"resource": ""
} |
q39795 | matchGroups | train | function matchGroups(groupsConfig, wantedGroups)
{
var defaultGroups = ['default'];
var groups = _.map([groupsConfig, wantedGroups], function(grp) {
if (_.isUndefined(grp)) {
return defaultGroups;
} else if (_.isString(grp)) {
return [grp];
... | javascript | {
"resource": ""
} |
q39796 | RulesConfigurationError | train | function RulesConfigurationError(message, path)
{
var self = new Error();
self.path = path;
self.message = "Rules configuration error : "+message+(path ? " at path : "+path : "");
self.name = 'RulesConfigurationError';
self.__proto__ = RulesConfigurationErro... | javascript | {
"resource": ""
} |
q39797 | train | function(path, fieldValue, errors, errorsContent)
{
var e = {};
var er = {};
if (_.isArray(errors) && errors.length > 0) {
er.errors = errors;
}
if (_.isArray(errorsContent) && errorsContent.length > 0) {
er.content = errorsContent;
}
... | javascript | {
"resource": ""
} | |
q39798 | FieldValidator | train | function FieldValidator(rules, config)
{
this.rules = rules;
this.fieldLabel = undefined;
if (config) {
this.setConfig(config);
}
} | javascript | {
"resource": ""
} |
q39799 | Validator | train | function Validator(type, config)
{
this.type = type;
this.message = undefined;
this.value = undefined;
this.groups = undefined;
this.fieldValidator = undefined;
this.parent = undefined;
if (typeof(config) === 'object'... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.