_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q43600 | train | function( selector ) {
var removeTmpId = createTmpId( this ),
list = new CKEDITOR.dom.nodeList(
this.$.querySelectorAll( getContextualizedSelector( this, selector ) )
);
removeTmpId();
return list;
} | javascript | {
"resource": ""
} | |
q43601 | train | function( selector ) {
var removeTmpId = createTmpId( this ),
found = this.$.querySelector( getContextualizedSelector( this, selector ) );
removeTmpId();
return found ? new CKEDITOR.dom.element( found ) : null;
} | javascript | {
"resource": ""
} | |
q43602 | pushTo | train | function pushTo(array) {
return map(function (file, cb) {
array.push(file);
cb(null, file);
});
} | javascript | {
"resource": ""
} |
q43603 | processBundleFile | train | function processBundleFile(file, bundleExt, variables, bundleHandler, errorCallback) {
// get bundle files
var lines = file.contents.toString().split('\n');
var resultFilePaths = [];
lines.forEach(function (line) {
var filePath = getFilePathFromLine(file, line, variables);
if (filePath)
resultFilePaths.push(... | javascript | {
"resource": ""
} |
q43604 | getFilePathFromLine | train | function getFilePathFromLine(bundleFile, line, variables) {
// handle variables
var varRegex = /@{([^}]+)}/;
var match;
while (match = line.match(varRegex)) {
var varName = match[1];
if (!variables || typeof (variables[varName]) === 'undefined')
throw new gutil.PluginError(pluginName, bundleFile.path + ': va... | javascript | {
"resource": ""
} |
q43605 | recursiveBundle | train | function recursiveBundle(bundleExt, variables, errorCallback) {
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
// standart file push to callback
if (path.extname(file.path).toLowerCase() != bundleExt)
return cb(null, file);
// bundle file should be parsed
processBund... | javascript | {
"resource": ""
} |
q43606 | train | function (variables, bundleHandler) {
// handle if bundleHandler specified in first argument
if (!bundleHandler && typeof (variables) === 'function') {
bundleHandler = variables;
variables = null;
}
return through2.obj(function (file, enc, cb) {
if (!checkFile(file, cb))
return;
var ext = path... | javascript | {
"resource": ""
} | |
q43607 | DispatchError | train | function DispatchError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'DispatchError';
this.message = message;
} | javascript | {
"resource": ""
} |
q43608 | delegateOptional | train | function delegateOptional (self) {
if (hasOwn(self, 'actual') && hasOwn(self, 'expected')) {
var kindOf = tryRequire('kind-of-extra', 'kind-error')
delegate(self, {
orig: {
actual: self.actual,
expected: self.expected
},
type: {
actual: kindOf(self.actual),
ex... | javascript | {
"resource": ""
} |
q43609 | messageFormat | train | function messageFormat (type, inspect) {
var msg = this.detailed
? 'expect %s `%s`, but %s `%s` given'
: 'expect `%s`, but `%s` given'
return this.detailed
? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
: util.format(msg, type.expected, type.actual)
} | javascript | {
"resource": ""
} |
q43610 | remap | train | function remap (map, str) {
str = string.call(str) === '[object String]' ? str : ''
for (var key in map) {
if (str.match(new RegExp(key, 'i'))) return map[key]
}
return ''
} | javascript | {
"resource": ""
} |
q43611 | add | train | function add (a, b) {
var fifths = a[0] + b[0]
var octaves = a[1] === null || b[1] === null ? null : a[1] + b[1]
return [fifths, octaves]
} | javascript | {
"resource": ""
} |
q43612 | subtract | train | function subtract (a, b) {
var fifths = b[0] - a[0]
var octaves = a[1] !== null && b[1] !== null ? b[1] - a[1] : null
return [fifths, octaves]
} | javascript | {
"resource": ""
} |
q43613 | nth | train | function nth (n, array) {
return n < 0 ? array[array.length + n] : array[n]
} | javascript | {
"resource": ""
} |
q43614 | scanErr | train | function scanErr(err, pathname) {
log.debug(err);
if ('ENOENT' === err.code) {
callback(pathname + ' does not exist.');
} else {
callback('Unexpected error.');
}
// cli does process.exit() in callback, but unit tests don't.
callback = function () {};
} | javascript | {
"resource": ""
} |
q43615 | getCurrentServerTimeAndBlock | train | async function getCurrentServerTimeAndBlock() {
await retrieveDynGlobProps();
if(props.time) {
lastCommitedBlock = props.last_irreversible_block_num;
trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
return {
time : Date.parse(pr... | javascript | {
"resource": ""
} |
q43616 | filter | train | function filter(obj) {
var result = {}, fieldDefine, value;
for(var field in options) {
fieldDefine = options[field];
value = obj[field];
if(!fieldDefine.private && value !== undefined) {
result[field] = value;
}
}
return result;
} | javascript | {
"resource": ""
} |
q43617 | Container | train | function Container(name, token, url) {
this._name = name;
this._url = url;
this._token = token;
this.isNew = false;
} | javascript | {
"resource": ""
} |
q43618 | waitForJobToFinish | train | function waitForJobToFinish(driver, options) {
return new Promise(function (resolve, reject) {
var start = Date.now();
var timingOut = false;
function check() {
var checkedForExceptions;
if (options.allowExceptions) {
checkedForExceptions = Promise.resolve(null);
} else {
... | javascript | {
"resource": ""
} |
q43619 | Range | train | function Range(){
if (!(this instanceof Range)) {
return new Range();
}
// maximize int.
var max = Math.pow(2, 32) - 1;
// default options.
this.options = {
min: -max,
max: max,
res: {
range : /^[\s\d\-~,]+$/,
blank : /\s+/g,
number : /^\-?\d+$/,
min2num: /^~\-?\d+... | javascript | {
"resource": ""
} |
q43620 | train | function(s, opts){
var r = s.split('~').map(function(d){
return parseFloat(d);
});
// number at position 1 must greater than position 0.
if (r[0] > r[1]) {
return r.reverse();
}
return r;
} | javascript | {
"resource": ""
} | |
q43621 | rename | train | function rename(node, it, to){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.forEach(function(dec){
if (dec.id.name == it) dec.id.name = to
if (dec.init) rename(dec.init, it, to)
})
case 'FunctionDeclaration':
if (node.id.name == it) node.id.name =... | javascript | {
"resource": ""
} |
q43622 | freshVars | train | function freshVars(node){
switch (node.type) {
case 'VariableDeclaration':
return node.declarations.map(function(n){ return n.id })
case 'FunctionExpression': return [] // early exit
case 'FunctionDeclaration':
return [node.id]
}
return children(node)
.map(freshVars)
.reduce(concat... | javascript | {
"resource": ""
} |
q43623 | train | function (filename) {
var resume = filename === true; // should only ever be set by resume calls
var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
var buffer = new Buffer(4096);
var bytesRead;
var current = '';
var remainder = resume ? this._remainder : '';
while (!this._paused && (byte... | javascript | {
"resource": ""
} | |
q43624 | init | train | function init(){
//modules load
terminal.colors.default= chalk.white.bold;
terminal.default="";
//set the colors of the terminal
checkUserColors(terminal.colors);
bool=true;
//to control the view properties and colors
properties= Object.getOwnPropertyNames(terminal);
colors=Object.getOwnPropertyNames(terminal.colors);
... | javascript | {
"resource": ""
} |
q43625 | fertilise | train | function fertilise(objectName, value, color, blockPos){
if(!blockPos) throw new Error("incorrect call to fertilise method");
var name= objectName.slice(2);
terminal[name]=value;
terminal.colors[name]=color;
setOnBlock(objectName, blockPos);
checkUserColors(terminal.colors);
init();
} | javascript | {
"resource": ""
} |
q43626 | checkUserColors | train | function checkUserColors(colorUser){
if(terminal.colors){
for(var name in colorUser){
colorUser[name]= setUserColor(colorUser[name]);
}
}
else{
throw new Error("There is no colors object defined");
}
} | javascript | {
"resource": ""
} |
q43627 | setOnBlock | train | function setOnBlock(objectName, blockPos){
switch(blockPos){//check where to add in the structure
case 'header':
terminal.header.push(objectName);
break;
case 'body':
terminal.body.push(objectName);
break;
case 'footer':
terminal.footer.push(objectName);
break;
}
} | javascript | {
"resource": ""
} |
q43628 | checkColors | train | function checkColors(name){
var colors=Object.getOwnPropertyNames(terminal.colors);
var bul=false; // boolean to control if its defined the property
for(var i=0; i<colors.length; i++){//iterate over prop names
if(colors[i] === name){//if it is
bul=true;
}
}
if(bul!==true){//if its finded the s... | javascript | {
"resource": ""
} |
q43629 | checkProperties | train | function checkProperties(name){
var bul=false; // boolean to control if its defined the property
for(var i=0; i<properties.length; i++){//iterate over prop names
if(properties[i] === name){//if it is
bul=true;
}
}
if(bul!==true){// it isn't finded the statement of the tag
throw new Error('Not... | javascript | {
"resource": ""
} |
q43630 | aError | train | function aError(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.error(terminal.symbolProgress+" Error: "+errorObject.message)+ " " +terminal.colors.aux(errorObject.aux));
... | javascript | {
"resource": ""
} |
q43631 | aSuccess | train | function aSuccess(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.success(terminal.symbolProgress+" Success: "+errorObject.message) +" " +terminal.colors.aux(errorObject.aux));... | javascript | {
"resource": ""
} |
q43632 | aWarning | train | function aWarning(errorObject){
if(!terminal.symbolProgress) terminal.symbolProgress="? ";
if(errorObject.aux){
if(!terminal.colors.aux) terminal.colors.aux= chalk.white;
console.log(terminal.colors.warning(terminal.symbolProgress+" Warning: "+errorObject.message)+" " +terminal.colors.aux(errorObject.aux));... | javascript | {
"resource": ""
} |
q43633 | addStaticAssetRoute | train | function addStaticAssetRoute(server, scaffold) {
assert(scaffold.path, `TransomScaffold staticRoute requires "path" to be specified.`);
const contentFolder = scaffold.folder || path.sep;
const serveStatic = scaffold.serveStatic || restify.plugins.serveStatic;
const defaultAsset = scaffo... | javascript | {
"resource": ""
} |
q43634 | addRedirectRoute | train | function addRedirectRoute(server, scaffold) {
assert(scaffold.path && scaffold.target, `TransomScaffold redirectRoute requires 'path' and 'target' to be specified.`);
server.get(scaffold.path, function (req, res, next) {
res.redirect(scaffold.target, next);
});
} | javascript | {
"resource": ""
} |
q43635 | addTemplateRoute | train | function addTemplateRoute(server, scaffold) {
server.get(scaffold.path, function (req, res, next) {
const transomTemplate = server.registry.get(scaffold.templateHandler);
const contentType = scaffold.contentType || 'text/html';
const p = new Promise(function (resolve, reject... | javascript | {
"resource": ""
} |
q43636 | resolveNodeSkel | train | function resolveNodeSkel(index, nodeName) {
var idx = +graph.nameToIndex[nodeName];
argh = [idx, +index]
if(Number.isNaN(idx)) {
throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
}
if(index !== undefined && idx > +index) {
throw "Unable to get index... | javascript | {
"resource": ""
} |
q43637 | resolveValueOrNodeSkel | train | function resolveValueOrNodeSkel(index, val, valDefault) {
switch (typeof(val)) {
case "string":
return resolveNodeSkel(index, val);
case "undefined":
if (valDefault === undefined) {
throw "Unable to get value'" + val + "'";
}
return () => valDefault;
defau... | javascript | {
"resource": ""
} |
q43638 | initialize | train | function initialize() {
var scene = ds = exports.ds = {
"time": 0,
"song": null,
"graph": null,
"shaders": {},
"textures": {},
"texturesToLoad": 0,
"audio": { "loaded": false, "playing": false },
"isLoaded": function() {
return this.graph !== null && this.texturesToLoad === 0 && ... | javascript | {
"resource": ""
} |
q43639 | sumObjectValues | train | function sumObjectValues(object, depth, level = 1) {
let sum = 0;
for (const i in object) {
const value = object[i];
if (isNumber(value)) {
sum += parseFloat(value);
} else if (isObject(value) && (depth < 1 || depth > level)) {
sum += sumObjectValues(value, depth,... | javascript | {
"resource": ""
} |
q43640 | sumov | train | function sumov(object, depth = 0) {
if (isNumber(object)) {
return parseFloat(object);
} else if (isObject(object) && Number.isInteger(depth)) {
return sumObjectValues(object, depth);
}
return 0;
} | javascript | {
"resource": ""
} |
q43641 | shuffleObjArrays | train | function shuffleObjArrays( map, options ) {
var newMap = !! options && true === options.copy ? {} : map;
var copyNonArrays = !! options && true === options.copy && true === ( options.copyNonArrays || options.copyNonArray );
var values = null;
for ( var key in map ) {
values = map[ key ];
... | javascript | {
"resource": ""
} |
q43642 | crypto_stream_salsa20_xor | train | function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
var z = new Uint8Array(16), x = new Uint8Array(64);
var u, i;
for (i = 0; i < 16; i++) z[i] = 0;
for (i = 0; i < 8; i++) z[i] = n[i];
while (b >= 64) {
crypto_core_salsa20(x,z,k,sigma);
for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
... | javascript | {
"resource": ""
} |
q43643 | handler | train | function handler(instance, context, func, index, callback) {
return function() {
var old = instance.results[index];
instance.results[index] = tryExpr(func, context);
if (old === instance.results[index])
return;
if (instance.dependenciesCount === 1 || !Interpolable.allowDelayedUpdate)
callback(instance.ou... | javascript | {
"resource": ""
} |
q43644 | directOutput | train | function directOutput(context) {
var o = tryExpr(this.parts[1].func, context);
return (typeof o === 'undefined' && !this._strict) ? '' : o;
} | javascript | {
"resource": ""
} |
q43645 | train | function(context, callback, binds) {
var instance = new Instance(this);
var count = 0,
binded = false;
for (var i = 1, len = this.parts.length; i < len; i = i + 2) {
var block = this.parts[i];
if (block.binded) {
binded = true;
var h = handler(instance, context, block.func, count, callback),
... | javascript | {
"resource": ""
} | |
q43646 | train | function(context) {
if (this.directOutput)
return this.directOutput(context);
var out = "",
odd = true,
parts = this.parts;
for (var j = 0, len = parts.length; j < len; ++j) {
if (odd)
out += parts[j];
else {
var r = tryExpr(parts[j].func, context);
if (typeof r === 'undefined') {
... | javascript | {
"resource": ""
} | |
q43647 | tree | train | function tree(app, options) {
var opts = extend({}, options);
var node = {
label: getLabel(app, opts),
metadata: getMetadata(app, opts)
};
// get the names of the children to lookup
var names = arrayify(opts.names || ['nodes']);
return names.reduce(function(acc, name) {
var children = app[name]... | javascript | {
"resource": ""
} |
q43648 | getLabel | train | function getLabel(app, options) {
if (typeof options.getLabel === 'function') {
return options.getLabel(app, options);
}
return app.full_name || app.nickname || app.name;
} | javascript | {
"resource": ""
} |
q43649 | train | function(template, templateUrl) {
var deferred = $q.defer();
if (template) {
deferred.resolve(template);
} else if (templateUrl) {
// Check to see if the template has already been loaded.
var cachedTemplate = $templateCache.get(templateUrl);
... | javascript | {
"resource": ""
} | |
q43650 | train | function(e) {
this.touch.cur = 'dragging';
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
//tilt
delta = e.gesture.deltaY - this.touch.lastY;
this.angleX += delta;
} else if (this.touch.lastX && (e.gesture.direction == 'left' ||... | javascript | {
"resource": ""
} | |
q43651 | train | function(e) {
this.touch.cur = 'shifting';
var factor = 5e-3;
var delta = 0;
if (this.touch.lastY && (e.gesture.direction == 'up' || e.gesture.direction == 'down')) {
this.touch.shiftControl
.removeClass('shift-horizontal')
.addClass('shift-vertical')
.css('top', e.g... | javascript | {
"resource": ""
} | |
q43652 | train | function(initial_csg) {
var csg = initial_csg.canonicalized();
var mesh = new GL.Mesh({ normals: true, colors: true });
var meshes = [ mesh ];
var vertexTag2Index = {};
var vertices = [];
var colors = [];
var triangles = [];
// set to true if we want to use interpolated vertex normals
... | javascript | {
"resource": ""
} | |
q43653 | train | function(err, objs) {
that.worker = null;
if(err) {
that.setError(err);
that.setStatus("Error.");
that.state = 3; // incomplete
} else {
that.setCurrentObjects(objs);
that.setStatus("Ready.");
that.state = 2; // complete
}
... | javascript | {
"resource": ""
} | |
q43654 | runBranch | train | function runBranch (index, options) {
var { tree, signal, start, promise } = options;
var currentBranch = tree.branches[index];
if (!currentBranch && tree.branches === signal.branches) {
if (tree.branches[index - 1]) {
tree.branches[index - 1].duration = Date.now() - start;
}
signal.isExecutin... | javascript | {
"resource": ""
} |
q43655 | runAsyncBranch | train | function runAsyncBranch (index, currentBranch, options) {
var { tree, args, signal, state, promise, start, services } = options;
var promises = currentBranch
.map(action => {
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, true);
var o... | javascript | {
"resource": ""
} |
q43656 | runSyncBranch | train | function runSyncBranch (index, currentBranch, options) {
var { args, tree, signal, state, start, promise, services } = options;
try {
var action = currentBranch;
var actionFunc = tree.actions[action.actionIndex];
var actionArgs = createActionArgs(args, action, state, false);
var outputs = action.ou... | javascript | {
"resource": ""
} |
q43657 | addOutputs | train | function addOutputs (next, outputs) {
if (Array.isArray(outputs)) {
outputs.forEach(key => {
next[key] = next.bind(null, key);
});
}
return next;
} | javascript | {
"resource": ""
} |
q43658 | createNextFunction | train | function createNextFunction (action, resolver) {
return function next (...args) {
var path = typeof args[0] === 'string' ? args[0] : null;
var arg = path ? args[1] : args[0];
var result = {
path: path ? path : action.defaultOutput,
args: arg
};
if (resolver) {
resolver(result);... | javascript | {
"resource": ""
} |
q43659 | getStateMutatorsAndAccessors | train | function getStateMutatorsAndAccessors (state, action, isAsync) {
var mutators = [
'apply',
'concat',
'deepMerge',
'push',
'merge',
'unset',
'set',
'splice',
'unshift'
];
var accessors = [
'get',
'exists'
];
var methods = [];
if (isAsync) {
methods = methods... | javascript | {
"resource": ""
} |
q43660 | staticTree | train | function staticTree (signalActions) {
var actions = [];
var branches = transformBranch(signalActions, [], [], actions, false);
return { actions, branches };
} | javascript | {
"resource": ""
} |
q43661 | transformBranch | train | function transformBranch (action, ...args) {
return Array.isArray(action) ?
transformAsyncBranch.apply(null, [action, ...args]) :
transformSyncBranch.apply(null, [action, ...args]);
} | javascript | {
"resource": ""
} |
q43662 | transformAsyncBranch | train | function transformAsyncBranch (action, parentAction, path, actions, isSync) {
action = action.slice();
isSync = !isSync;
return action
.map((subAction, index) => {
path.push(index);
var result = transformBranch(subAction, action, path, actions, isSync);
path.pop();
return result;
}... | javascript | {
"resource": ""
} |
q43663 | transformSyncBranch | train | function transformSyncBranch (action, parentAction, path, actions, isSync) {
var branch = {
name: getFunctionName(action),
args: {},
output: null,
duration: 0,
mutations: [],
isAsync: !isSync,
outputPath: null,
isExecuting: false,
hasExecuted: false,
path: path.slice(),
out... | javascript | {
"resource": ""
} |
q43664 | analyze | train | function analyze (actions) {
if (!Array.isArray(actions)) {
throw new Error('State: Signal actions should be array');
}
actions.forEach((action, index) => {
if (typeof action === 'undefined' || typeof action === 'string') {
throw new Error(
`
State: Action number "${index}" in s... | javascript | {
"resource": ""
} |
q43665 | getFunctionName | train | function getFunctionName (fn) {
var name = fn.toString();
name = name.substr('function '.length);
name = name.substr(0, name.indexOf('('));
return name;
} | javascript | {
"resource": ""
} |
q43666 | Player | train | function Player(params) {
this.platformID = this.key = params.key;
this.kills = params.kills;
this.deaths = params.deaths;
this.name = params.name;
this.rank = params.rank;
this.weapon = params.weapon;
} | javascript | {
"resource": ""
} |
q43667 | Cms | train | function Cms(module, with_app) {
if (!module)
throw new Error('Requires a module');
if (!module.config)
throw new Error('Module requires config');
if (!module.config.name)
logger.info('No name specified in config. Calling it null.')
if (!module.config.mongoConnectString)
throw new Error('Config ... | javascript | {
"resource": ""
} |
q43668 | handlePromise | train | function handlePromise(query, q, model, resultsPerPage) {
return Promise.all([
query.exec(),
model.count(q).exec()
]).spread(function(results, count) {
return [
results,
Math.ceil(count / resultsPerPage) || 1,
count
]
});
} | javascript | {
"resource": ""
} |
q43669 | handleCallback | train | function handleCallback(query, q, model, resultsPerPage, callback) {
return async.parallel({
results: function(callback) {
query.exec(callback);
},
count: function(callback) {
model.count(q, function(err, count) {
callback(err, count);
});
}
}, function(error, data) {
i... | javascript | {
"resource": ""
} |
q43670 | foreachInDir | train | function foreachInDir (dirpath, fnc, done) {
// Read the files
fs.readdir(dirpath, function (err, files) {
// Return error
if (err) {
return done(err);
}
// Process each file
parallel(files.map(function (f) {
return fnc.bind(null, f);
}), done);
});
} | javascript | {
"resource": ""
} |
q43671 | rdf | train | function rdf(argv, callback) {
var command = argv[2];
var exec;
if (!command) {
console.log('rdf help for command list');
process.exit(-1);
}
try {
exec = require('./bin/' + command + '.js');
} catch (err) {
console.error(command + ': command not found');
process.exit(-1);
}
argv.... | javascript | {
"resource": ""
} |
q43672 | bin | train | function bin() {
rdf(process.argv, function(err, res) {
if (Array.isArray(res)) {
for (var i=0; i<res.length; i++) {
console.log(res[i]);
}
} else {
console.log(res);
}
});
} | javascript | {
"resource": ""
} |
q43673 | update | train | function update(options) {
var reqOpt = {
host: url.parse(options.updateVersionURL).host,
uri: url.parse(options.updateVersionURL),
path: url.parse(options.updateVersionURL).pathname,
port: options.port
};
options.error = options.error || function () {
};
options.su... | javascript | {
"resource": ""
} |
q43674 | train | function(start, end, query) {
//console.log("deep.store.Collection.range : ", start, end, query);
var res = null;
var total = 0;
query = query || "";
return deep.when(this.get(query))
.done(function(res) {
total = res.length;
if (typeof start === 'string')
start = parseInt(st... | javascript | {
"resource": ""
} | |
q43675 | train | function (lintFile) {
var deferred = new Deferred();
parseJslintXml(lintFile, function (err, lintErrors) {
if (lintErrors) {
deferred.resolve(lintErrors);
} else {
if (err && err.code === 'ENOENT') {
console.warn('No jslint xml file found at:', lintFile);
} else if (err) {
... | javascript | {
"resource": ""
} | |
q43676 | train | function (lintFile, callback) {
fs.readFile(lintFile, function (err, data) {
if (err) {
callback(err);
} else {
var parser = new xml2js.Parser({
mergeAttrs: true
});
parser.parseString(data, function (err, result) {
if (err) {
callback(err);
} else if ... | javascript | {
"resource": ""
} | |
q43677 | train | function (req, res, lintErrors) {
var html = template({
lintErrors: lintErrors
});
res.end(html);
} | javascript | {
"resource": ""
} | |
q43678 | train | function(predicate, asyncFunction) {
if (predicate()) {
return asyncFunction().then(function() {
return Parse.Promise._continueWhile(predicate, asyncFunction);
});
}
return Parse.Promise.as();
} | javascript | {
"resource": ""
} | |
q43679 | train | function(resolvedCallback, rejectedCallback) {
var promise = new Parse.Promise();
var wrappedResolvedCallback = function() {
var result = arguments;
if (resolvedCallback) {
result = [resolvedCallback.apply(this, result)];
}
if (result.length === 1 && Parse.Promise.... | javascript | {
"resource": ""
} | |
q43680 | train | function(optionsOrCallback, model) {
var options;
if (_.isFunction(optionsOrCallback)) {
var callback = optionsOrCallback;
options = {
success: function(result) {
callback(result, null);
},
error: function(error) {
callback(null, error);
... | javascript | {
"resource": ""
} | |
q43681 | train | function( s ){
if( s.match(/\./ ) ){
var l = s.split( /\./ );
for( var i = 0; i < l.length-1; i++ ){
l[ i ] = '_children.' + l[ i ];
}
return l.join( '.' );
} else {
return s;
}
} | javascript | {
"resource": ""
} | |
q43682 | train | function( filters, fieldPrefix, selectorWithoutBells ){
return {
querySelector: this._makeMongoConditions( filters.conditions || {}, fieldPrefix, selectorWithoutBells ),
sortHash: this._makeMongoSortHash( filters.sort || {}, fieldPrefix )
};
} | javascript | {
"resource": ""
} | |
q43683 | train | function( cb ){
if( ! self.positionField ){
cb( null );
} else {
// If repositioning is required, do it
if( self.positionField ){
var where, beforeId;
if( ! options.position ){
where = 'e... | javascript | {
"resource": ""
} | |
q43684 | train | function( state ) {
if ( this._.state == state )
return false;
this._.state = state;
var element = CKEDITOR.document.getById( this._.id );
if ( element ) {
element.setState( state, 'cke_button' );
state == CKEDITOR.TRISTATE_DISABLED ?
element.setAttribute( 'aria-disabled', t... | javascript | {
"resource": ""
} | |
q43685 | rPath | train | function rPath (htmlyFile, sourceFilepath) {
htmlyFile = pathResolve(__dirname, htmlyFile)
htmlyFile = pathRelative(dirname(sourceFilepath), htmlyFile)
htmlyFile = slash(htmlyFile)
if (!/^(\.|\/)/.test(htmlyFile)) {
return './' + htmlyFile
} else {
return htmlyFile
}
} | javascript | {
"resource": ""
} |
q43686 | warning | train | function warning() {
let sentence = "";
const avoidList = getWords("avoid_list");
const avoid = nu.chooseFrom(avoidList);
const rnum = Math.floor(Math.random() * 10);
if (rnum <= 3) {
sentence = `You would be well advised to avoid ${avoid}`;
} else if (rnum <= 6){
sentence = `Avoid ${avoid} at all c... | javascript | {
"resource": ""
} |
q43687 | getIterableObjectEntries | train | function getIterableObjectEntries(obj) {
let index = 0;
const propKeys = Reflect.ownKeys(obj);
return {
[Symbol.iterator]() {
return this;
},
next() {
if (index < propKeys.length) {
const key = propKeys[index];
index += 1;
return {"value": [key, obj[key]]};
... | javascript | {
"resource": ""
} |
q43688 | findWhere | train | function findWhere(arr, key, value) {
return arr.find(elem => {
for (const [k, v] of getIterableObjectEntries(elem)) {
if (k === key && v === value) {
return true;
}
}
});
} | javascript | {
"resource": ""
} |
q43689 | findWhereKey | train | function findWhereKey(arr, key) {
return arr.find(elem => {
for (const [k] of getIterableObjectEntries(elem)) {
if (k === key) {
return true;
}
}
});
} | javascript | {
"resource": ""
} |
q43690 | load | train | function load(module) {
var toTransform,
transformedModule = {};
if (typeof module === "string") {
toTransform = require(module);
} else {
toTransform = module;
}
for (var item in toTransform) {
// transform only sync/async methods to promiseable since having utility meth... | javascript | {
"resource": ""
} |
q43691 | rebuildAsPromise | train | function rebuildAsPromise(_thisObject, name, fn) {
// if is a regular function, that has an async correspondent also make it promiseable
if (!isFunctionAsync(_thisObject, name, fn)) {
return function() {
var that = this,
args = arguments;
return blinkts.lang.prom... | javascript | {
"resource": ""
} |
q43692 | train | function(err, res) {
if (err) return callback(err);
self._rawResponse = res;
if (!res || !res['cps:reply']) return callback(new Error("Invalid reply"));
self.seconds = res['cps:reply']['cps:seconds'];
if (res['cps:reply']['cps:content']) {
var content = res['cps:reply... | javascript | {
"resource": ""
} | |
q43693 | TypedNumber | train | function TypedNumber (config) {
const number = this;
// validate min
if (config.hasOwnProperty('min') && !util.isNumber(config.min)) {
const message = util.propertyErrorMessage('min', config.min, 'Must be a number.');
throw Error(message);
}
// validate max
if (config.hasOwnPro... | javascript | {
"resource": ""
} |
q43694 | recursiveMapping | train | function recursiveMapping(source) {
if (source.type === 'array') {
if (source.items['$ref'] || source.items.type === 'object') {
source.items = mapSimpleField(source.items);
}
else if (source.items.type === 'object') {
recursiveMapping(source.items);
}
else mapSimpleField(source);
}
... | javascript | {
"resource": ""
} |
q43695 | train | function (yamlContent, context, callback) {
var jsonAPISchema;
try {
jsonAPISchema = yamljs.parse(yamlContent);
}
catch (e) {
return callback({"code": 851, "msg": e.message});
}
try {
swagger.validateYaml(jsonAPISchema);
}
catch (e) {
return callback({"code": 173, "msg": e.message});
... | javascript | {
"resource": ""
} | |
q43696 | train | function (yamlJson) {
if (typeof yamlJson !== 'object') {
throw new Error("Yaml file was converted to a string");
}
if (!yamlJson.paths || Object.keys(yamlJson.paths).length === 0) {
throw new Error("Yaml file is missing api schema");
}
//loop in path
for (var onePath in yamlJson.paths) {
//l... | javascript | {
"resource": ""
} | |
q43697 | train | function (obj) {
if (typeof obj !== "object" || obj === null) {
return obj;
}
if (obj instanceof Date) {
return new Date(obj.getTime());
}
if (obj instanceof RegExp) {
return new RegExp(obj);
}
if (obj instanceof Array && Object.keys(obj).every(function (k) {
return !isNaN(k);
}))... | javascript | {
"resource": ""
} | |
q43698 | train | function (serviceInfo) {
var config = {
"type": "service",
"prerequisites": {
"cpu": " ",
"memory": " "
},
"swagger": true,
"injection": true,
"serviceName": serviceInfo.serviceName,
"serviceGroup": serviceInfo.serviceGroup,
"serviceVersion": serviceInfo.serviceVersion,
"servicePort... | javascript | {
"resource": ""
} | |
q43699 | train | function (yamlJson, cb) {
let all_apis = {};
let all_errors = {};
let paths = reformatPaths(yamlJson.paths);
let definitions = yamlJson.definitions;
let parameters = yamlJson.parameters;
let convertedDefinitions = {};
let convertedParameters = {};
// convert definitions first
if (definitio... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.