_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q41400 | train | function (resolved, val) {
var should = (negate ?
(new Assertion(val)).not :
(new Assertion(val))
);
if (storedAssertions[0][0] !== 'throw' && !resolved) {
throw val;
}
... | javascript | {
"resource": ""
} | |
q41401 | train | function () {
var self = this;
$(this.scope)
.on('click.fndtn.clearing', 'ul[data-clearing] li',
function (e, current, target) {
var current = current || $(this),
target = target || current,
next = current.next('li'),
settings = ... | javascript | {
"resource": ""
} | |
q41402 | Mesh | train | function Mesh(context, isStatic, numVerts, numIndices, vertexAttribs) {
//TODO: use options here...
if (!numVerts)
throw "numVerts not specified, must be > 0";
BaseObject.call(this, context);
this.gl = this.context.gl;
this.numVerts = null;
this.numIndices = null;
this.vertices = null;
this.i... | javascript | {
"resource": ""
} |
q41403 | train | function() {
this.gl = this.context.gl;
var gl = this.gl;
this.vertexBuffer = gl.createBuffer();
//ignore index buffer if we haven't specified any
this.indexBuffer = this.numIndices > 0
? gl.createBuffer()
: null;
this.dirty = true;
} | javascript | {
"resource": ""
} | |
q41404 | train | function(shader) {
var gl = this.gl;
var offset = 0;
var stride = this.vertexStride;
//bind and update our vertex data before binding attributes
this._updateBuffers();
//for each attribtue
for (var i=0; i<this._vertexAttribs.length; i++) {
var a = this._vertexAttribs[i];
//location of the attrib... | javascript | {
"resource": ""
} | |
q41405 | train | function(name, numComponents, location, type, normalize, offsetCount) {
this.name = name;
this.numComponents = numComponents;
this.location = typeof location === "number" ? location : null;
this.type = type;
this.normalize = Boolean(normalize);
this.offsetCount = typeof offsetCount === "number" ? offsetCoun... | javascript | {
"resource": ""
} | |
q41406 | writeJSON | train | function writeJSON(file, json){
var s = file.split(".");
if (s.length > 0) {
var ext = s[s.length - 1];
if (ext != "json"){
file = file + ".json";
}
}
fs.writeFileSync(file, JSON.stringify(json));
} | javascript | {
"resource": ""
} |
q41407 | getDirectories | train | function getDirectories(path){
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path + "/" + file).isDirectory();
});
} | javascript | {
"resource": ""
} |
q41408 | create | train | function create(options) {
return knex(extend({
client: "pg",
debug: debug(),
connection: connection(),
pool: pool()
}, options));
} | javascript | {
"resource": ""
} |
q41409 | connection | train | function connection() {
return {
ssl: JSON.parse(JSON.stringify(process.env.DATABASE_SSL || "")),
host: process.env.DATABASE_HOST || "localhost",
user: process.env.DATABASE_USER || "",
charset: process.env.DATABASE_CHARSET || "utf8",
password: process.env.DATABASE_PASS || "",
database: process... | javascript | {
"resource": ""
} |
q41410 | type | train | function type (response) {
return value => {
if (!(value instanceof Error)) {
response.setHeader(
'Content-Type',
lookup(typeof value === 'object' ? 'json' : 'text')
)
}
return value instanceof Array ? JSON.stringify(value) : value
}
} | javascript | {
"resource": ""
} |
q41411 | status | train | function status (res) {
return err => {
const code = err.statusCode
error(res, code || 500)
if (!code) console.log(err)
}
} | javascript | {
"resource": ""
} |
q41412 | callbacks | train | function callbacks(err) {
var fn = route.callbacks[i++];
try {
if ('route' == err) {
nextRoute();
} else if (err && fn) {
if (fn.length < 4) return callbacks(err);
fn(err, req, res, callbacks);
} else if (fn) {
if (fn.length < 4) return fn(req,... | javascript | {
"resource": ""
} |
q41413 | clear | train | function clear (node) {
const replace = node.cloneNode(false);
node.parentNode.replaceChild(replace, node);
return replace;
} | javascript | {
"resource": ""
} |
q41414 | loadHandler | train | function loadHandler (event) {
const target = event.target;
// change the link to the new file
link.setAttribute('href', target.result);
// make sure checkbox is no longer checked
checkbox.checked = false;
// make link not hidden
link.style.display = '';
// make delete checkbox not h... | javascript | {
"resource": ""
} |
q41415 | uploadHandler | train | function uploadHandler (event) {
const target = event.target;
if (target.files && target.files[0]) {
file = target.files[0];
const reader = new FileReader();
reader.addEventListener('load', loadHandler);
reader.readAsDataURL(file);
}
} | javascript | {
"resource": ""
} |
q41416 | checkboxHandler | train | function checkboxHandler (event) {
const target = event.target;
if (target.checked) {
link.style.display = 'none';
if (upload.value) {
upload.value = '';
link = clear(link);
}
}
else {
link.style.display = '';
}
} | javascript | {
"resource": ""
} |
q41417 | construct | train | function construct(data) {
const basepath = process.cwd();
const files = data.map((f) => {
const fullpath = p.join(basepath, f);
const src = fs.readFileSync(fullpath, 'utf8');
const t = yaml.load(src, {
schema: YAML_FILES_SCHEMA,
filename: fullpath
});
return t;
});
const t = ... | javascript | {
"resource": ""
} |
q41418 | plugin | train | function plugin(cb) {
return function(css) {
if (lodash.isFunction(cb)) {
var token = cb(css.source.input.file);
if (!lodash.isNull(token)) {
css.eachRule(function(rule) {
if (!areSelectorsValid(rule.selectors, token)) {
throw rule.error('Wrong selector');
}
});
}
}
}
} | javascript | {
"resource": ""
} |
q41419 | areSelectorsValid | train | function areSelectorsValid(selectors, token) {
return lodash.every(selectors, function(selector) {
if (lodash.isRegExp(token)) {
return token.test(lodash.trim(selector));
} else {
return lodash.startsWith(lodash.trim(selector), token);
}
});
} | javascript | {
"resource": ""
} |
q41420 | cleanAlphabet | train | function cleanAlphabet(alphabet) {
return alphabet.split('').filter(function (item, pos, self) {
return self.indexOf(item) === pos;
}).join('');
} | javascript | {
"resource": ""
} |
q41421 | generate | train | function generate(index) {
return index instanceof _bigInteger2.default ? (0, _generateBigInt2.default)(index, alphabet) : (0, _generateInt2.default)(index, alphabet);
} | javascript | {
"resource": ""
} |
q41422 | number | train | function number()
{
const number = document.createElement('div')
document.body.appendChild(number)
number.innerHTML = rand(1000)
number.style.fontSize = '300%'
number.style.position = 'fixed'
number.style.left = number.style.top = '50%'
number.style.color = 'r... | javascript | {
"resource": ""
} |
q41423 | train | function(message) {
var pack = {
toMaster: true,
toWorkers: false,
toSource: false,
message: message,
source: process.pid
}
dispatch(pack)
} | javascript | {
"resource": ""
} | |
q41424 | train | function(pack) {
if (pack.toSource !== false || pack.source !== process.pid) {
CALLBACK(pack.message)
}
} | javascript | {
"resource": ""
} | |
q41425 | train | function(pack) {
if (cluster.isMaster) {
if (pack.toWorkers === true) {
for (var key in cluster.workers) {
cluster.workers[key].send(pack)
}
}
}
else {
if (pack.toMaster === true || pack.toWorkers === true) {
process.send(pack)
}
}
} | javascript | {
"resource": ""
} | |
q41426 | train | function(process, callback) {
if (callback !== undefined && typeof callback === 'function') {
CALLBACK = callback
}
if (cluster.isMaster) {
process.on('message', masterHandler)
}
else {
process.on('message', workerHandler)
}
} | javascript | {
"resource": ""
} | |
q41427 | func | train | function func(declarations, functions, functionMatcher, parseArgs) {
if (!declarations) return;
if (false !== parseArgs) parseArgs = true;
declarations.forEach(function(decl){
if ('comment' == decl.type) return;
var generatedFuncs = [], result, generatedFunc;
while (decl.value.match(functionMatcher)... | javascript | {
"resource": ""
} |
q41428 | error500 | train | function error500(options) {
options = _.merge({}, DEF_CONFIG, options);
// pre-compile underscore template if available
if (typeof options.template === 'string' && options.template.length > 0) {
options.template = _.template(options.template);
}
return function (err, req, res, next) {
... | javascript | {
"resource": ""
} |
q41429 | parse | train | function parse(meta) {
if (typeof meta !== 'string') {
throw new Error('`Parse`\'s first argument should be a string')
}
return meta.split(/[\r\n]/)
.filter(function (line) { // remove blank line
return /\S+/.test(line) &&
line.indexOf('==UserScript==') === -1 &&
line.indexOf('==/Us... | javascript | {
"resource": ""
} |
q41430 | stringify | train | function stringify(obj) {
if (!isObject(obj)) {
throw new Error('`Stringify`\'s first argument should be an object')
}
var meta = Object.keys(obj)
.map(function (key) {
return getLine(key, obj[key])
}).join('')
return '// ==UserScript==\n' + meta + '// ==/UserScript==\n'
} | javascript | {
"resource": ""
} |
q41431 | addOutProperty | train | function addOutProperty(out, directory, extensions) {
out[directory] = {
extensions: extensions
};
Object.defineProperty(
out[directory],
'directory',
{
get: function () {
return Config.fileLoaderDirs[directory];
},
set: function (value) {
Config.fileLoaderDirs[directory] = value;
},
e... | javascript | {
"resource": ""
} |
q41432 | arraySubtraction | train | function arraySubtraction(arrA, arrB) {
arrA = arrA.slice();
for (let i = 0; i < arrB.length; ++i) {
arrA = arrA.filter(function (value) {
return value !== arrB[i];
});
}
return arrA;
} | javascript | {
"resource": ""
} |
q41433 | getDirFromPublicPath | train | function getDirFromPublicPath(file) {
return path.posix.dirname(
path.posix.normalize(
path.posix.sep
+ file.path().replace(
new RegExp(
'^' + escapeStringRegExp(path.resolve(Config.publicPath))
),
''
).split(path.sep).join(path.posix.sep)
)
);
} | javascript | {
"resource": ""
} |
q41434 | replaceTplTag | train | function replaceTplTag(dirFromPublicPath, tag, replacements, templateFileLog) {
let tagPath = tag.replace(new RegExp(tplTagPathRegExpStr), '$1');
let tagPathFromPublicPath = path.posix.resolve(dirFromPublicPath, tagPath);
if (
tagPathFromPublicPath in replacements
&&
replacements.hasOwnProperty(tagPathFromPubl... | javascript | {
"resource": ""
} |
q41435 | getCompiledContent | train | function getCompiledContent(file, fragments, tags, replacements, templateFileLog) {
let content = '';
let fragmentStep = numberOfTplTagRegExpParts + 1;
let dirFromPublicPath = getDirFromPublicPath(file);
let i = 0;
for (; i < tags.length; ++i) {
content += fragments[i * fragmentStep];
content += replaceTplTag(... | javascript | {
"resource": ""
} |
q41436 | compileTemplate | train | function compileTemplate(file, replacements, templateFileLog) {
file = File.find(path.resolve(file));
let content = file.read();
let tags = content.match(new RegExp(tplTagRegExpStr, 'g'));
if (tags && tags.length) {
content = getCompiledContent(
file,
content.split(new RegExp(tplTagRegExpStr)),
tags,
... | javascript | {
"resource": ""
} |
q41437 | processTemplates | train | function processTemplates(templates) {
var templateProcessingLog = logger.createTemplateProcessingLog();
var replacements = Mix.manifest.get();
for (let template in templates) {
if (templates.hasOwnProperty(template)) {
// Copy to target
fs.copySync(template, templates[template]);
// Compile
compileTem... | javascript | {
"resource": ""
} |
q41438 | watchFile | train | function watchFile(file, callback) {
let absolutePath = File.find(file).path();
let watcher = chokidar
.watch(
absolutePath,
{
persistent: true
}
)
.on(
'change',
function () {
if (typeof callback === 'function') {
callback(file);
}
watcher.unwatch(absolutePath);
watchFil... | javascript | {
"resource": ""
} |
q41439 | notify | train | function notify(message) {
if (Mix.isUsing('notifications')) {
let contentImage = path.join(__dirname, '../img/sunshine.png');
notifier.notify({
title: 'The Extension of Laravel Mix',
message: message,
contentImage: contentImage,
icon: (os.platform() === 'win32' || os.platform() === 'linux') ? contentI... | javascript | {
"resource": ""
} |
q41440 | TX | train | function TX(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | javascript | {
"resource": ""
} |
q41441 | executeCallback | train | function executeCallback(cb, arg) {
var r = cb(arg)
if(r !== undefined && !isLikeAFuture(r) )
throw Error("Value returned from then or catch ("+r+") is *not* a Future. Callback: "+cb.toString())
return r
} | javascript | {
"resource": ""
} |
q41442 | batchLoop | train | function batchLoop(){
var promisesArray = createBatchJobs();
Q[qFunction](promisesArray).then(function(batchResult){
if(qFunction === "allSettled"){
batchResult = batchResult.filter(function(res){return res.state === "fulfilled"}).map(function(i... | javascript | {
"resource": ""
} |
q41443 | createBatchJobs | train | function createBatchJobs(){
var promises = [];
for(var i=0;i<squadSize && dataCopy.length > 0;i++){
var item = dataCopy.shift();
promises.push(worker(item));
}
return promises;
} | javascript | {
"resource": ""
} |
q41444 | fetchAll | train | async function fetchAll(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
return result || [];
} | javascript | {
"resource": ""
} |
q41445 | analyze | train | function analyze (fileSourceData) {
var analysis = new Analysis();
for (let sample of fileSourceData) {
if (saysHelloWorld(sample.text)) {
analysis.addError({
line: sample.line,
message: 'At least try to look like you didn\'t copy the demo code!'
... | javascript | {
"resource": ""
} |
q41446 | onMouseDown | train | function onMouseDown(event, env, isSideEffectsDisabled) {
mouse.down(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if (mouse.keys[1] && !mouse.keys[3]) {
let focusedObject = focusObject(env.library, env.camera, env.selector);
if (env.selector.... | javascript | {
"resource": ""
} |
q41447 | onMouseUp | train | function onMouseUp(event, env, isSideEffectsDisabled) {
mouse.up(event);
if (!env || isSideEffectsDisabled) {
return;
}
if (objectMoved) {
if(env.selector.isSelectedEditable()) {
events.triggerObjectChange(env.selector.getSelectedObject());
}
objectMoved = ... | javascript | {
"resource": ""
} |
q41448 | onMouseMove | train | function onMouseMove(event, env, isSideEffectsDisabled) {
event.preventDefault();
mouse.move(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if(mouse.keys[1] && !mouse.keys[3]) {
moveObject(env.library, env.camera, env.selector);
} else {
... | javascript | {
"resource": ""
} |
q41449 | rotateObject | train | function rotateObject(obj, rotation, order) {
let originRotation = obj.rotation.clone();
obj.rotation.setFromVector3(originRotation.toVector3().add(rotation), order);
if (obj.isCollided()) {
obj.rotation.setFromVector3(originRotation.toVector3(), originRotation.order);
return false;
}
... | javascript | {
"resource": ""
} |
q41450 | taskMaker | train | function taskMaker(gulp) {
if (!gulp) {
throw new Error('Task maker: No gulp instance provided.');
}
const maker = {
createTask,
};
return maker;
function createTask(task) {
gulp.task(
task.name,
task.desc || false,
task.fn,
... | javascript | {
"resource": ""
} |
q41451 | getFiles | train | function getFiles(folder = srcFolder){
let all = [];
let f = fs.readdirSync(folder);
for(file of f){
all.push(path.join(folder,file))
if(fs.lstatSync(path.join(folder,file)).isDirectory()){
all = all.concat(getFiles(path.join(folder,file)));
}
}
return all;
} | javascript | {
"resource": ""
} |
q41452 | train | function(map, terms) {
for (var i = 0, l = terms.length; i < l; i++) {
var curTerm = terms[i];
map = map[curTerm];
if (!map || curTerm === map) {
return false; // no change
} else if (isString(map)) {
applyChange(terms, map, i);
return true;
... | javascript | {
"resource": ""
} | |
q41453 | onConnection | train | function onConnection(socket) {
var endpoint = new http2.Endpoint(log, 'SERVER', {});
endpoint.pipe(socket).pipe(endpoint);
endpoint.on('stream', function(stream) {
stream.on('headers', function(headers) {
var path = headers[':path'];
var filename = join(__dirname, path);
// Serving server... | javascript | {
"resource": ""
} |
q41454 | train | function (device, desc) {
EventEmitter.call(this);
if (TRACE && DETAIL) {
logger.info({
method: "UpnpService",
device: device,
desc: desc,
}, "called");
}
this.device = device;
this.ok = true;
this.forgotten = false
try {
this.s... | javascript | {
"resource": ""
} | |
q41455 | train | function () {
var tmp = this.elements[0*4+1];
this.elements[0*4+1] = this.elements[1*4+0];
this.elements[1*4+0] = tmp;
tmp = this.elements[0*4+2];
this.elements[0*4+2] = this.elements[2*4+0];
this.elements[2*4+0] = tmp;
tmp = this.elements[0*4+3];
this.elements[0*4+3] = this.elements[3... | javascript | {
"resource": ""
} | |
q41456 | train | function (node, callback) {
return on.makeMultiHandle([
on(node, 'click', callback),
on(node, 'keyup:Enter', callback)
]);
} | javascript | {
"resource": ""
} | |
q41457 | train | function (node, callback) {
// important note!
// starts paused
//
var bHandle = on(node.ownerDocument.documentElement, 'click', function (e) {
var target = e.target;
if (target.nodeType !== 1) {
target = target.parentNode;
}
if (target && !node.contains(target)) {
callback(e);
... | javascript | {
"resource": ""
} | |
q41458 | onDomEvent | train | function onDomEvent (node, eventName, callback) {
node.addEventListener(eventName, callback, false);
return {
remove: function () {
node.removeEventListener(eventName, callback, false);
node = callback = null;
this.remove = this.pause = this.resume = function () {};
},
pause: function () {
... | javascript | {
"resource": ""
} |
q41459 | rename | train | function rename(newName) {
newName = newName.replace(/[\.\/]/g, '');
if (this.isRoot()) {
this._name = newName;
} else {
var newPath = [this.parent.path(), newName].filter(function (e) {
return e !== '';
}).join('.');
this.moveTo(newPath);
}
} | javascript | {
"resource": ""
} |
q41460 | getHrefRec | train | function getHrefRec(element) {
var href = element.getAttribute('href');
if (href) {
return href.replace(location.origin, '');
}
if (element.parentElement && element.parentElement !== document.body) {
return getHrefRec(element.parentElement);
}
return null;
} | javascript | {
"resource": ""
} |
q41461 | _segment | train | function _segment(file) {
console.log();
process.stdout.write(util.format('%s ', file));
} | javascript | {
"resource": ""
} |
q41462 | _success | train | function _success(test, result) {
process.stdout.write('.'.green);
successes.push({ test: test, result: result });
} | javascript | {
"resource": ""
} |
q41463 | _failure | train | function _failure(errors, test, result) {
process.stdout.write('.'.red);
failures.push({ errors: errors, test: test, result: result });
} | javascript | {
"resource": ""
} |
q41464 | _end | train | function _end(debug) {
const DEBUG_FIELDS = ['exitcode', 'output', 'stdout', 'stderr'];
var summary = util.format(
'%d test%s, %d success%s, %d failure%s',
successes.length + failures.length,
(successes.length + failures.length > 1) ? 's' : '',
successes.length,
(successes.length > 1) ? 'es' :... | javascript | {
"resource": ""
} |
q41465 | BindToEventDecorator | train | function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
return function(propertyName, func) {
const scope = this;
const event = _event || propertyName;
const target = !_target ? this.el : document.querySelector(_target);
if (!target) {
console.warn("Couldn't subscribe "+this.name+... | javascript | {
"resource": ""
} |
q41466 | checkStanza | train | function checkStanza(hubClient, stanza, fields, author, opt_sigValue) {
var sig = opt_sigValue === undefined ? stanza.sig : opt_sigValue;
if (!sig) {
throw new errors.AuthenticationError('No `sig` field in stanza');
}
if (!stanza.updatedAt || typeof(stanza.updatedAt) != 'number') {
throw new errors.Auth... | javascript | {
"resource": ""
} |
q41467 | signStanza | train | function signStanza(stanza, fields, privkey) {
stanza.sig = generateStanzaSig(stanza, fields, privkey);
return stanza;
} | javascript | {
"resource": ""
} |
q41468 | srcToMarkdown | train | function srcToMarkdown(src, level, threshold) {
var blocks = srcToBlocks(src);
return blocksToMarkdown(blocks, level, threshold);
} | javascript | {
"resource": ""
} |
q41469 | loadFile | train | function loadFile(filename, level, threshold) {
var out = [];
var file;
out.push('<!-- BEGIN DOC-COMMENT H' + level + ' ' + filename + ' -->\n');
try {
file = fs.readFileSync(filename, {encoding: 'utf-8'});
out.push(srcToMarkdown(file, level, threshold));
} catch (e) {
// I don't see how we can ... | javascript | {
"resource": ""
} |
q41470 | filterDocument | train | function filterDocument(doc, threshold) {
var sections = doc.split(re.mdSplit);
var out = [];
var i = 0;
for (i = 0; i < sections.length; i++) {
// 1. Raw input to preserve
out.push(sections[i]);
// Iterate
i++;
if (i >= sections.length) {
break;
}
// 2. Header level
let... | javascript | {
"resource": ""
} |
q41471 | install | train | function install(Vue) {
for (const name in components) {
const component = components[name].component || components[name]
Vue.component(name, component)
}
Vue.prototype.$actionSheet = $actionSheet
Vue.prototype.$loading = $loading
Vue.prototype.$toast = $toast
Vue.prototype.$dialog = $dialog
} | javascript | {
"resource": ""
} |
q41472 | config | train | function config(name) {
const args = [].slice.call(arguments, 1)
const modules = {
ActionSheet: $actionSheet,
Loading: $loading,
Toast: $toast,
Dialog: $dialog
}
const module = components[name] || modules[name]
if (typeof module.config === 'function') {
module.config.apply(null, args)
}
... | javascript | {
"resource": ""
} |
q41473 | fetchRow | train | async function fetchRow(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
if (result.length >= 1){
// extract data
return result[0];
}else{
return null;
}
} | javascript | {
"resource": ""
} |
q41474 | getStandardModule | train | function getStandardModule(url) {
if (!(url in standardModuleCache)) {
var symbol = new ModuleSymbol(null, null, null, url);
var moduleInstance = traceur.runtime.modules[url];
Object.keys(moduleInstance).forEach((name) => {
symbol.addExport(name, new ExportSymbol(null, name, null));
});
stan... | javascript | {
"resource": ""
} |
q41475 | desc | train | function desc (array) {
// Simply clone
array = [].concat(array);
// Ordered by version DESC
array.sort(semver.rcompare);
return array;
} | javascript | {
"resource": ""
} |
q41476 | scan | train | function scan(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createReadStream(options)
.on('data', function(data) {... | javascript | {
"resource": ""
} |
q41477 | scanIndex | train | function scanIndex(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createKeyStream(options)
.on('data', function(key... | javascript | {
"resource": ""
} |
q41478 | wafr | train | function wafr(options, callback) {
const contractsPath = options.path;
const optimizeCompiler = options.optimize;
const sourcesExclude = options.exclude;
const sourcesInclude = options.include;
const focusContract = options.focus;
const reportLogs = {
contracts: {},
status: 'success',
failure: 0... | javascript | {
"resource": ""
} |
q41479 | parseError | train | function parseError(res, body) {
// Res is optional.
if (body == null) {
body = res;
}
// Status code is required.
const status = parseError.findErrorCode(sliced(arguments));
if (!status) {
return false;
}
// Body can have an error-like object, in which case the attributes will be used.
const ... | javascript | {
"resource": ""
} |
q41480 | train | function (len) {
_.isNumber(len) || (len = 1)
while (len--) {
readline.moveCursor(this.rl.output, -cliWidth(), 0)
readline.clearLine(this.rl.output, 0)
if (len) {
readline.moveCursor(this.rl.output, 0, -1)
}
}
return this
} | javascript | {
"resource": ""
} | |
q41481 | train | function (x) {
_.isNumber(x) || (x = 1)
readline.moveCursor(this.rl.output, 0, -x)
return this
} | javascript | {
"resource": ""
} | |
q41482 | train | function () {
if (!this.cursorPos) {
return this
}
var line = this.rl._prompt + this.rl.line
readline.moveCursor(this.rl.output, -line.length, 0)
readline.moveCursor(this.rl.output, this.cursorPos.cols, 0)
this.cursorPos = null
return this
} | javascript | {
"resource": ""
} | |
q41483 | random | train | function random(min, max) {
var randomNumber = Math.random() * (max - min + 1) + min;
if (!Number.isInteger(min) || !Number.isInteger(max)) {
return randomNumber;
} else {
return Math.floor(randomNumber);
}
} | javascript | {
"resource": ""
} |
q41484 | pidOf | train | function pidOf( procName, callback ){
if ( isString( procName )){
var pids = [];
procStat( procName, function( err, processes ){
processes.object.forEach( function( proc ){
pids.push( proc.pid )
});
callback( err, pids )
})
} else cal... | javascript | {
"resource": ""
} |
q41485 | nameOf | train | function nameOf( pid, callback ){
if( isNumber( pid )){
procStat( pid, function( err, proc ){
callback( err, proc.object[ 0 ].name );
})
} else callback( new Error( 'A non-numeric PID was supplied' ), null )
} | javascript | {
"resource": ""
} |
q41486 | procStat | train | function procStat( proc, callback ){
var type = isNumber( proc ) ? 'PID' : 'IMAGENAME',
arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV',
row = null,
processes = {
array: [],
object: []
};
taskList( arg, function( err, stdout ){
csv.parse( std... | javascript | {
"resource": ""
} |
q41487 | kill | train | function kill( proc, callback ){
var arg = isNumber( proc ) ? '/F /PID ' + proc : '/F /IM ' + proc;
if ( isNumber( proc ) || isString( proc )){
exec( taskKillPath + arg, function( err ){
if( callback ) callback( err )
})
} else {
callback( new Error( 'The first kill() ar... | javascript | {
"resource": ""
} |
q41488 | escapeStringForJavascript | train | function escapeStringForJavascript(content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");
} | javascript | {
"resource": ""
} |
q41489 | train | function(nga, options) {
// create an admin application
var app = ngAdmin.create(nga, options);
// app.dashboard(nga.dashboard().template('<dashboard-page></dashboard-page>'));
// create custom header
if (options.auth) {
app.header('<header-partial></header-part... | javascript | {
"resource": ""
} | |
q41490 | Channel | train | function Channel(client, id){
EE.call(this);
this.client = client;
this.id = id;
this.opened = false;
this.confirmMode = false;
var work = (id, method, err) => {
this.opened = false;
var error = new RabbitClientError(err);
this.emit('close', error, this.id);
if (error) {
this.emit('err... | javascript | {
"resource": ""
} |
q41491 | train | function(uid, sid, group) {
if(!uid || !sid || !group) {
return false;
}
for(let i=0, l=group.length; i<l; i++) {
if(group[i] === uid) {
group.splice(i, 1);
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q41492 | train | function(channelService, route, msg, groups, opts, cb) {
let app = channelService.app;
let namespace = 'sys';
let service = 'channelRemote';
let method = 'pushMessage';
let count = utils.size(groups);
let successFlag = false;
let failIds = [];
logger.debug('[%s] channelService sendMessageByGroup route:... | javascript | {
"resource": ""
} | |
q41493 | train | function () {
process.stdin.resume();
process.stdin.setEncoding('utf8');
_execCtx = [self];
process.stdin.on('data', function (chunk) {
var ctx = _execCtx[0],
cmd = chunk.substr(0,chunk.length-1);
if (cmd.substr(0,2) == '..')
{
cmd = 'if (_execCtx.length>1) _execCtx.shift(); undefined... | javascript | {
"resource": ""
} | |
q41494 | train | function (serverPath)
{
if (!_.isString(serverPath))
return false;
var _sourcePath = cwd+sourcePath,
relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
relativeServerPath = path.relative(cwd,serverPath);
self.e.log("[*] Building new wnServer on `"+serverPath+"`");
if (!fs.exist... | javascript | {
"resource": ""
} | |
q41495 | train | function (servers)
{
if (!_.isObject(servers))
return false;
var modules = {};
for (s in servers)
{
var ref=servers[s],
s = 'server-'+s;
modules[s]=ref;
modules[s].modulePath=(modules[s].serverPath || modules[s].modulePath);
modules[s].class='wnServer';
modules[s].autoInit = ... | javascript | {
"resource": ""
} | |
q41496 | train | function (id)
{
var m = this.getModule('server-'+id, function (server) {
self.e.loadServer(server);
});
_serverModules.push(m);
return m;
} | javascript | {
"resource": ""
} | |
q41497 | train | function (serverPath,relativeMainPath)
{
if (relativeMainPath)
serverPath = path.relative(cwd,path.resolve(mainPath,serverPath));
var serverConfig = {},
consoleID = this.getServerModules().length+1;
serverConfig[consoleID] = { 'modulePath': serverPath, 'serverID': consoleID };
this.e.log('[*] B... | javascript | {
"resource": ""
} | |
q41498 | train | function (id)
{
if (this.hasServer(id))
{
this.e.log('[*] Console active in SERVER#' + id);
this.activeServer = id;
} else {
this.e.log('[*] Console active in NONE');
this.activeServer = -1;
}
} | javascript | {
"resource": ""
} | |
q41499 | train | function(app, opts) {
opts = opts || {};
this.app = app;
this.service = new SessionService(opts);
let getFun = function(m) {
return (function() {
return function() {
return self.service[m].apply(self.service, arguments);
};
})();
};
// proxy the service methods excep... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.