_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q38000 | compileSingleFile | train | function compileSingleFile (filePath, isDebug, options)
{
var outputPath = "./" + path.dirname(filePath).replace(/(^|\/)assets\/js/, "$1public/js");
var uglifyOptions = {};
gulpUtil.log(gulpUtil.colors.blue("Uglify"), pathHelper.makeRelative(filePath), " -> ", pathHelper.makeRelative(outputPath) + "/" + pa... | javascript | {
"resource": ""
} |
q38001 | validateParameters | train | function validateParameters() {
grunt.verbose.writeln( 'BowerMap::validateParameters' );
//flag used to determine if validation passes
var check = true;
//lib path must be set
//TODO: get default bowerpath from .bowerrc
bowerPath = bowerPath || "bower_components";
if ( typeof bowerPath !== 'string' ) {
... | javascript | {
"resource": ""
} |
q38002 | handleListResults | train | function handleListResults( results ) {
grunt.verbose.writeln( 'BowerMap::handleListResults' );
for ( var k in results ) {
if ( results.hasOwnProperty( k ) ) {
grunt.verbose.writeln( '------------------------------------' );
grunt.verbose.writeln( ' ' + k + ' - ' + results[k] );
if ( ignore.index... | javascript | {
"resource": ""
} |
q38003 | copyComponentFiles | train | function copyComponentFiles( name, files ) {
grunt.verbose.writeln( 'BowerMap::copyComponentFiles - ' + name );
//get map of files to copy
var componentMap = getComponentMapping( name, files );
//copy files
for ( var k in componentMap ) {
if ( componentMap.hasOwnProperty( k ) ) {
//console.log( path.f... | javascript | {
"resource": ""
} |
q38004 | getComponentMapping | train | function getComponentMapping( name, files ) {
grunt.verbose.writeln( 'BowerMap::getComponentMapping - ' + name );
//first get list of all files
var fileList = [];
if ( shim[ name ] !== undefined ) {
grunt.verbose.writeln( ' using shim value' );
//use shim value
fileList = fileList.concat( shim[ na... | javascript | {
"resource": ""
} |
q38005 | getCommonPathBase | train | function getCommonPathBase( paths ) {
var list = [];
var minLength = 999999999;
var commonPath = "";
//break up paths into parts
paths.forEach( function( file ) {
//normalize path seperators
file = file.replace( pathSepRegExp, path.sep );
//get resolved path parts for file directory
if ( file... | javascript | {
"resource": ""
} |
q38006 | urlWeight | train | function urlWeight(config) {
if (isUndefined(config) || config.url == undefined) { // eslint-disable-line eqeqeq
return 0;
}
if (config.url instanceof RegExp) {
return 1 + config.url.toString().length;
}
if (isFunction(config.url)) {
return 1;
}
return 100 + config.ur... | javascript | {
"resource": ""
} |
q38007 | defineProperty | train | function defineProperty(element, propertyName, descriptor, scope) {
assert(element, 'Parameter \'element\' must be defined');
assertType(descriptor, 'object', false, 'Parameter \'descriptor\' must be an object literal');
assertType(descriptor.configurable, 'boolean', true, 'Optional configurable key in descriptor... | javascript | {
"resource": ""
} |
q38008 | train | function(file, opt)
{
//Check the file
if(typeof file !== 'string'){ throw new Error('Missing file argument'); return null; }
//Check the options
if(typeof opt === 'undefined'){ var opt = {}; }
//Save the file name
this._file = file;
//Check the encoding option
this._encoding = (typeof opt.encoding =... | javascript | {
"resource": ""
} | |
q38009 | setup | train | function setup(done) {
crontab.load(function(err, ct) {
if (err) return done(err);
clean(ct);
load(ct);
ct.save(done);
});
} | javascript | {
"resource": ""
} |
q38010 | readCronFile | train | function readCronFile(cronfile) {
var substitutes = {
project: {
baseDir: process.cwd()
},
pkg: pkg
}
var content = _.template(grunt.file.read(cronfile), substitutes);
return JSON.parse(content).jobs;
} | javascript | {
"resource": ""
} |
q38011 | resolveLink | train | function resolveLink(srcUrl, targetUrl) {
// Parse the src URL
var srcUrlObj = url.parse(srcUrl);
// If there isn't a protocol
// DEV: `node@0.8` has this as `undefined`, `node@0.10` has this as `null`
if (!srcUrlObj.protocol) {
// With no protocol, we have everything in pathname. Add on `//` and force t... | javascript | {
"resource": ""
} |
q38012 | RenderTexture | train | function RenderTexture(renderer, width, height, scaleMode, resolution)
{
if (!renderer)
{
throw new Error('Unable to create RenderTexture, you must pass a renderer into the constructor.');
}
width = width || 100;
height = height || 100;
resolution = resolution || CONST.RESOLUTION;
... | javascript | {
"resource": ""
} |
q38013 | train | function (args, done) {
var q = _.clone(args.q)
var qent = args.qent
q.limit$ = 1
var qs = schemastm(qent)
self.connection.all(qs.text, function (err, results) {
if (err) {
return done(err)
}
var schema = {}
results.forEach(function (row) {
... | javascript | {
"resource": ""
} | |
q38014 | promptAsync | train | function promptAsync(prompts) {
return new Promise(function(resolve, reject) {
parent.prompt.call(parent, prompts, function(answers) {
resolve(answers)
});
});
} | javascript | {
"resource": ""
} |
q38015 | remoteAsync | train | function remoteAsync() {
var generator = this.generator;
var username;
var repo;
var branch;
var refresh;
var url;
// With URL and refresh
if (arguments.length <= 2) {
url = arguments[0];
refresh = arguments[1];
} else {
username = arguments[0];
repo = arguments[1];
branch = ar... | javascript | {
"resource": ""
} |
q38016 | TimedSample | train | function TimedSample(dt, timeStamp, persistObj, scaleFactor) {
var time = (dt[0] + dt[1] / 1e9) * 1000 / scaleFactor;
this.scaleFactor = scaleFactor;
this.min = time;
this.max = time;
this.sigma = new StandardDeviation(time);
this.average = new Average(time);
this.timeStamp = timeStamp;
if (persistObj) {
va... | javascript | {
"resource": ""
} |
q38017 | addMode | train | function addMode(middle, mode, settings) {
if (!modes.includes(mode)) throw `Incorrect bodyparser mode ${mode}`;
middle.push(bodyParser[mode](settings[mode]));
} | javascript | {
"resource": ""
} |
q38018 | initEndpoint | train | function initEndpoint(brest, description) {
const settings = _.defaultsDeep(description.bodyParser, settingsDefault);
if (description.bodyParserModes) {
description.bodyParserModes.forEach((mode) => addMode(description.middle, mode, settings));
} else {
const mode = description.bodyParserM... | javascript | {
"resource": ""
} |
q38019 | train | function (e, data) {
ctrl.coreWistia.setError(); //clear any previous errors
data
.submit()
.then(function (result, textStatus, jqXHR) {
ctrl.coreWistia.playVideo(result.hashed_id);
})
.catch(fun... | javascript | {
"resource": ""
} | |
q38020 | train | function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$timeout(function() {
ctrl.coreWistia.setProgress(progress);
});
} | javascript | {
"resource": ""
} | |
q38021 | MongoCrud | train | function MongoCrud(uri, options, gridFS) {
this.uri = uri || 'mongodb://localhost:27017/mongo-crud-test';
this.options = options || {};
this.gridFS = gridFS;
} | javascript | {
"resource": ""
} |
q38022 | help | train | function help() {
var padBtm = [0, 0, 1, 0];
var msg = ' See additional required/optional arguments for each command below. \n';
pargv
.logo('Mustr', 'cyan')
.ui(95)
.join(chalk.magenta('Usage:'), 'mu', chalk.cyan('<cmd>'), '\n')
.div({ text: chalk.bgBlue.white(msg) })
... | javascript | {
"resource": ""
} |
q38023 | generate | train | function generate() {
var parsed = ensureConfig();
if (!parsed.name)
mu.log.error('cannot generate template using name of undefined.\n').write().exit();
// Generate the template.
mu.render(parsed.name, parsed.output, parsed.options);
} | javascript | {
"resource": ""
} |
q38024 | rollback | train | function rollback() {
var parsed = ensureConfig();
var name = parsed.name;
// check if is an index number.
// if yes try to lookup the id
// by its index.
try {
var idx = void 0;
if (/^[0-9]+$/.test(name)) {
idx = parseInt(parsed.name) - 1;
if (idx >= 0) {... | javascript | {
"resource": ""
} |
q38025 | show | train | function show() {
var parsed = ensureConfig();
function showRollbacks() {
var rollbacks = mu.getRollbacks();
var keys = Object.keys(rollbacks);
var padBtm = [0, 0, 1, 0];
var ui = pargv.ui(105);
var i = keys.length;
var hdrNo = { text: " ", width: 5 };
var... | javascript | {
"resource": ""
} |
q38026 | train | function(username, pw) {
return _.ajax({
verb: 'POST',
url: '/login',
data: {
username: username,
password: pw
}
}).then(function(id) {
document.cookie = 'user=' + id;
return id;
});
} | javascript | {
"resource": ""
} | |
q38027 | multiaddrFromUri | train | function multiaddrFromUri (uriStr, opts) {
opts = opts || {}
const defaultDnsType = opts.defaultDnsType || 'dns4'
const { scheme, hostname, port } = parseUri(uriStr)
const parts = [
tupleForHostname(hostname, defaultDnsType),
tupleForPort(port, scheme),
tupleForScheme(scheme)
]
const multiaddrSt... | javascript | {
"resource": ""
} |
q38028 | sign | train | function sign(custom, request) {
/**
* An Epoch timestamp is required for the digital signature.
*/
let epoch = Util.epochInMilliseconds();
/**
* Override the generated Epoch timestamp if a timestamp was included in the
* custom headers.
*/
if (custom.WMSecurity && custom.WMSecu... | javascript | {
"resource": ""
} |
q38029 | digitalSignature | train | function digitalSignature(custom, request, epoch) {
/**
* Node Crypto Sign object that uses the given algorithm.
*
* @see {@link https://nodejs.org/api/crypto.html#crypto_class_sign}
*/
const signer = crypto_1.createSign('RSA-SHA256');
/**
* Walmart API request string to be signed.
... | javascript | {
"resource": ""
} |
q38030 | namespace | train | function namespace(path, scope) {
assertType(path, 'string', true, 'Invalid parameter: path');
assertType(scope, 'object', true, 'Invalid optional parameter: scope');
if (!scope) scope = (window) ? window : {};
if (path === undefined || path === '') return scope;
let groups = path.split('.');
let currentS... | javascript | {
"resource": ""
} |
q38031 | isSpecial | train | function isSpecial( obj, name ) {
if ( !obj ) return false;
if ( typeof obj[ 0 ] !== 'string' ) return false;
if ( typeof name === 'string' ) {
return obj[ 0 ].toLowerCase() === name;
}
return true;
} | javascript | {
"resource": ""
} |
q38032 | createSectionStructure | train | function createSectionStructure() {
return {
init: null,
comments: [],
attribs: {
define: [],
init: []
},
elements: {
define: [],
init: []
},
events: [],
links: [],
ons: [],
statics: []
... | javascript | {
"resource": ""
} |
q38033 | findPath | train | function findPath(path, directories) {
var cwd = directories[0];
if (!cwd) {
return null;
}
return findup(path, {cwd: cwd}) || findPath(path, slice.call(directories, 1));
} | javascript | {
"resource": ""
} |
q38034 | log | train | function log(txt) {
var p = document.createElement("p");
p.style.margin = '2px';
p.style.padding = '1px';
p.style.backgroundColor = "#FFFFF0";
p.style.border = "solid";
p.style.borderWidth = "1px";
p.style.borderColor = "#7F7F8F";
p.style.l... | javascript | {
"resource": ""
} |
q38035 | train | function (ppunit, writer) {
Dependencies.super_.call(this, ppunit, writer)
var self = this
self.subGraphs = []
ppunit.on('start', function () {
writer.write('digraph PPUnit {')
self.printNodes()
self.printSubGraphs()
self.printDependencies()
writer.write('}')
... | javascript | {
"resource": ""
} | |
q38036 | abortXHRRequest | train | function abortXHRRequest(uid, fn) {
if (reqs.hasOwnProperty(uid)) {
if (!reqs[uid]) return;
if (fn) {
fn();
} else {
reqs[uid].abort();
}
delete reqs[uid];
return reqs;
}
} | javascript | {
"resource": ""
} |
q38037 | customError | train | function customError(name, error) {
return {
error: error,
message: error.message,
name: name
};
} | javascript | {
"resource": ""
} |
q38038 | responseStatus | train | function responseStatus(res) {
if (res.status >= 200 && res.status < 300) {
return res;
} else {
var error = new Error(res.statusText);
error.response = res;
throw customError('responseStatus', error);
}
} | javascript | {
"resource": ""
} |
q38039 | buildUploadURL | train | function buildUploadURL(url, uuid, expiration, hmac, filename) {
return url + '?uuid=' + uuid + '&expiration=' + expiration + '&hmac=' + hmac + '&file=' + filename;
} | javascript | {
"resource": ""
} |
q38040 | uploadRequest | train | function uploadRequest(res, fileObject, showProgress) {
var url = res.url;
var expiration = res.expiration;
var hmac = res.hmac;
var uuid = res.uuid;
var file = fileObject.file;
var uid = fileObject.uid;
var upload_url = buildUploadURL(url, uuid, expiration, hmac, file.name);
return new Promise(functi... | javascript | {
"resource": ""
} |
q38041 | parseMiddleware | train | function parseMiddleware(ctx, next) {
try {
ctx.event = JSON.parse(ctx.content.toString());
next();
} catch (e) {
throw e;
}
} | javascript | {
"resource": ""
} |
q38042 | train | function (e)
{
if (!RGraph.Resizing || !RGraph.Resizing.div || !RGraph.Resizing.mousedown) {
return;
}
if (RGraph.Resizing.div) {
var div = RGraph.Resizing.div;
var canvas = div.__canvas__;
... | javascript | {
"resource": ""
} | |
q38043 | _shuffle | train | function _shuffle(sample) {
var shuffle = function shuffle(a, i, j) {
sample(j - i, a, i, j);
};
return shuffle;
} | javascript | {
"resource": ""
} |
q38044 | train | function (token, path, payload, contentFormat) {
return new Promise((resolve,reject)=>{
let zh = NewZestHeader();
zh.code = 2;
zh.token = token;
zh.tkl = token.length;
zh.payload = payload;
zh.oc = 3;
... | javascript | {
"resource": ""
} | |
q38045 | positionAfter | train | function positionAfter (arr, prevChild) {
var idx
if (prevChild === null) {
return 0
} else {
idx = findIndex(arr, prevChild)
return (idx === -1) ? arr.length : idx + 1
}
} | javascript | {
"resource": ""
} |
q38046 | toJS | train | function toJS(node, options, context) {
switch (node.type) {
// process numeric values and units
case 'Dimension':
var value = node.value;
var unit = options.units ? node.unit.toCSS(context) : null;
// if given a list of units to preserve, check if compiled unit ... | javascript | {
"resource": ""
} |
q38047 | createElement | train | function createElement(value) {
if (!document) return null;
assertType(value, 'string', true, 'Value must be a string');
if (value.match(/^([a-z0-9]+-)+[a-z0-9]+$/)) {
return new (getElementRegistry(value))();
}
else {
let div = document.createElement('div');
if (value.indexOf('<') !== 0 && valu... | javascript | {
"resource": ""
} |
q38048 | install | train | function install(definition, Component) {
const Ctor = register(definition, Component);
// no dependencies
if (!definition.components) {
return Ctor;
}
const components = definition.components || {};
// avoid unnecessary re-registering for next time
delete definition.components;
// register comp... | javascript | {
"resource": ""
} |
q38049 | parseHttpHeaders | train | function parseHttpHeaders(headers) {
var meta = {};
for (var headerName in headers) {
var headerValue = headers[headerName];
if (headerName=="x-ratelimit-limit") {
meta.rateLimit = headerValue;
} else if (headerName=="x-ratelimit-remaining") {
meta.r... | javascript | {
"resource": ""
} |
q38050 | getter_THREE_CubeTexture | train | function getter_THREE_CubeTexture(inst) {
return [
inst.name,
inst.mipmaps,
inst.flipY,
inst.mapping,
inst.wrapS,
inst.wrapT,
inst.magFilter,
inst.minFilter,
inst.anisotropy,
inst.format,
inst.type,
inst.offset,
inst.repeat,
inst.unpackAlignment,
inst.image];
} | javascript | {
"resource": ""
} |
q38051 | getter_THREE_LineBasicMaterial | train | function getter_THREE_LineBasicMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAl... | javascript | {
"resource": ""
} |
q38052 | getter_THREE_SpriteMaterial | train | function getter_THREE_SpriteMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAlpha... | javascript | {
"resource": ""
} |
q38053 | getter_THREE_MeshDepthMaterial | train | function getter_THREE_MeshDepthMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAl... | javascript | {
"resource": ""
} |
q38054 | getter_THREE_MeshLambertMaterial | train | function getter_THREE_MeshLambertMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDst... | javascript | {
"resource": ""
} |
q38055 | getter_THREE_MeshPhongMaterial | train | function getter_THREE_MeshPhongMaterial(inst) {
return [
inst.name,
inst.side,
inst.opacity,
inst.blending,
inst.blendSrc,
inst.blendDst,
inst.blendEquation,
inst.depthFunc,
inst.polygonOffsetFactor,
inst.polygonOffsetUnits,
inst.alphaTest,
inst.overdraw,
inst.blendSrcAlpha,
inst.blendDstAl... | javascript | {
"resource": ""
} |
q38056 | getter_THREE_Scene | train | function getter_THREE_Scene(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userDat... | javascript | {
"resource": ""
} |
q38057 | getter_THREE_Mesh | train | function getter_THREE_Mesh(inst) {
return [
inst.name,
inst.up,
inst.position,
inst.quaternion,
inst.scale,
inst.rotationAutoUpdate,
inst.matrix,
inst.matrixWorld,
inst.matrixAutoUpdate,
inst.visible,
inst.castShadow,
inst.receiveShadow,
inst.frustumCulled,
inst.renderOrder,
inst.userData... | javascript | {
"resource": ""
} |
q38058 | getter_THREE_BufferGeometry | train | function getter_THREE_BufferGeometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name,
inst.attributes,
inst.index];
} | javascript | {
"resource": ""
} |
q38059 | getter_THREE_Geometry | train | function getter_THREE_Geometry(inst) {
return [
inst.vertices,
inst.faces,
inst.faceVertexUvs,
inst.morphTargets,
inst.morphNormals,
inst.morphColors,
inst.animations,
inst.boundingSphere,
inst.boundingBox,
inst.name];
} | javascript | {
"resource": ""
} |
q38060 | getter_THREE_Vector4 | train | function getter_THREE_Vector4(inst) {
return [
inst.x,
inst.y,
inst.z,
inst.w];
} | javascript | {
"resource": ""
} |
q38061 | getter_THREE_Face3 | train | function getter_THREE_Face3(inst) {
return [
inst.a,
inst.b,
inst.c,
inst.materialIndex,
inst.normal,
inst.color,
inst.vertexNormals,
inst.vertexColors];
} | javascript | {
"resource": ""
} |
q38062 | getter_THREE_Quaternion | train | function getter_THREE_Quaternion(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._w];
} | javascript | {
"resource": ""
} |
q38063 | getter_THREE_Euler | train | function getter_THREE_Euler(inst) {
return [
inst._x,
inst._y,
inst._z,
inst._order];
} | javascript | {
"resource": ""
} |
q38064 | getter_THREE_BufferAttribute | train | function getter_THREE_BufferAttribute(inst) {
return [
inst.array,
inst.itemSize,
inst.dynamic,
inst.updateRange];
} | javascript | {
"resource": ""
} |
q38065 | getter_THREE_PerspectiveCamera | train | function getter_THREE_PerspectiveCamera(inst) {
return [
inst.fov,
inst.aspect,
inst.near,
inst.far];
} | javascript | {
"resource": ""
} |
q38066 | getter_THREE_OrthographicCamera | train | function getter_THREE_OrthographicCamera(inst) {
return [
inst.left,
inst.right,
inst.top,
inst.bottom,
inst.near,
inst.far];
} | javascript | {
"resource": ""
} |
q38067 | getter_THREE_MD2Character | train | function getter_THREE_MD2Character(inst) {
return [
inst.scale,
inst.animationFPS,
inst.root,
inst.meshBody,
inst.skinsBody,
inst.meshWeapon,
inst.skinsWeapon,
inst.weapons,
inst.activeAnimation];
} | javascript | {
"resource": ""
} |
q38068 | addSetValues | train | function addSetValues(args) {
for (var key in args.from) {
if (args.from[key]) {
args.to[key] = true;
}
}
} | javascript | {
"resource": ""
} |
q38069 | HTTPError | train | function HTTPError() {
var args = Array.prototype.slice.call(arguments);
if(!(this instanceof HTTPError)) {
if(args.length === 1) {
return new HTTPError(args[0]);
} else if(args.length === 2) {
return new HTTPError(args[0], args[1]);
} else if(args.length === 3) {
return new HTTPError(args[0], args[1],... | javascript | {
"resource": ""
} |
q38070 | reduce | train | function reduce(data, fn) {
delete data.package.readmeFilename; // README is already parsed.
delete data.package.versions; // Adds to much bloat.
delete data.package.readme; // README is already parsed.
//
// Remove circular references as it would prevent us from caching in Redis or
// ... | javascript | {
"resource": ""
} |
q38071 | clients | train | function clients(options) {
options = options || {};
options.registry = options.registry || Registry.mirrors.nodejitsu;
var githulk = options.githulk || new GitHulk();
//
// Only create a new Registry instance if we've been supplied with a string.
//
var npm = 'string' !== typeof options.registry
? ... | javascript | {
"resource": ""
} |
q38072 | train | function(text, options) {
var execute, queried;
queried = p.defer();
// caching disabled unless duration is specified
options = options != null ? options : {
duration: 0
};
execute = function(params) {
return db.prepare(text).then(function(stmt) {
return stmt.execute(params).... | javascript | {
"resource": ""
} | |
q38073 | findOrCreateMbaasApp | train | function findOrCreateMbaasApp(req, res, next){
log.logger.debug("findOrCreateMbaasApp ", req.params);
var models = mbaas.getModels();
//Checking For Required Params
var missingParams = _.filter(["appGuid", "apiKey", "coreHost"], function(requiredKey){
return validation.validateParamPresent(requiredKey, re... | javascript | {
"resource": ""
} |
q38074 | findMbaasApp | train | function findMbaasApp(req, res, next){
log.logger.debug("findMbaasApp for appname " + req.params.appname);
getMbaasApp({
'$or': [{name: req.params.appname}, {guid: req.params.appname}]
}, function(err, appMbaas){
if(err){
log.logger.debug("findMbaasApp Error ", err);
return next(err);
}
... | javascript | {
"resource": ""
} |
q38075 | getMbaasApp | train | function getMbaasApp(params, cb){
var models = mbaas.getModels();
models.AppMbaas.findOne(params, cb);
} | javascript | {
"resource": ""
} |
q38076 | updateMbaasApp | train | function updateMbaasApp(req, res, next){
var model = req.appMbaasModel;
model.name = req.params.appname;
model.domain = req.params.domain;
model.environment = req.params.environment;
model.guid = req.body.appGuid;
model.apiKey = req.body.apiKey;
model.coreHost = req.body.coreHost;
model.type = req.body... | javascript | {
"resource": ""
} |
q38077 | execute | train | function execute(req, res) {
// unwatch keys, clear references,
// and destroy the transaction reference on the conn
// and send the reply
req.conn.transaction.destroy(req, res, null, Constants.OK);
} | javascript | {
"resource": ""
} |
q38078 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(!info.conn.transaction) {
throw DiscardWithoutMulti;
}
} | javascript | {
"resource": ""
} |
q38079 | ErrorUnauthorized | train | function ErrorUnauthorized (message) {
Error.call(this);
// Add Information
this.name = 'ErrorUnauthorized';
this.type = 'client';
this.status = 401;
if (message) {
this.message = message;
}
} | javascript | {
"resource": ""
} |
q38080 | allKeys | train | function allKeys(obj) {
if (!isObject(obj)) return [];
var keys = [];
for (var key in obj) keys.push(key);
return keys;
} | javascript | {
"resource": ""
} |
q38081 | showArray | train | function showArray(maxDepth, array) {
return '['
+ array.map(function(a) {
return show(maxDepth - 1, a)
}).join(', ')
+ ']';
} | javascript | {
"resource": ""
} |
q38082 | showObject | train | function showObject(maxDepth, object) {
return '{'
+ pairs(object).map(function(pair){
return showString(pair.key) + ': ' + show(maxDepth - 1, pair.value)
}).join(', ')
+ '}'
} | javascript | {
"resource": ""
} |
q38083 | styledJsxOptions | train | function styledJsxOptions(opts) {
if (!opts) {
return {};
}
if (!Array.isArray(opts.plugins)) {
return opts;
}
opts.plugins = opts.plugins.map(plugin => {
if (Array.isArray(plugin)) {
const [ name, options ] = plugin;
return [ require.resolve(name), options ];
}
return requi... | javascript | {
"resource": ""
} |
q38084 | MongoDB | train | function MongoDB(config) {
var self = this;
this.events = new EventEmitter();
config = protos.extend({
host: 'localhost',
port: 27017,
database: 'default',
storage: null,
username: '',
password: '',
safe: true
}, config || {});
if (typeof confi... | javascript | {
"resource": ""
} |
q38085 | debounce | train | function debounce(method, delay, leading) {
assertType(method, 'function', false, 'Invalid parameter: method');
assertType(delay, 'number', true, 'Invalid optional parameter: delay');
assertType(leading, 'boolean', true, 'Invalid optional parameter: leading');
if (delay === undefined) delay = 0;
if (leading ... | javascript | {
"resource": ""
} |
q38086 | exec | train | function exec(sqlQuery, poolName) {
return new Promise((resolve, reject) => {
db.connect((err, client, done) => {
if (err) {
reject(err);
}
client.query(sqlQuery, (err, results) => {
if (err) {
reject(err);
}
resolve(results);
});
}, poolName |... | javascript | {
"resource": ""
} |
q38087 | _cors | train | function _cors (cookieDomain, publicUrl) {
return ({ acceptServers, acceptAllOrigins }) => {
// accept server 2 server requests by default
acceptServers = acceptServers === undefined ? true : acceptServers
// do not accept call by outside origins by default
acceptAllOrigins = acceptAllOrigins === unde... | javascript | {
"resource": ""
} |
q38088 | _getCookieToken | train | function _getCookieToken (cookies, req, cookieName, cookieDomain, publicUrl) {
let token = cookies.get(cookieName)
if (!token) return null
const reqOrigin = req.headers['origin']
const originDomain = reqOrigin && new URL(reqOrigin).host
// check that the origin of the request is part of the accepted domain
... | javascript | {
"resource": ""
} |
q38089 | _setCookieToken | train | function _setCookieToken (cookies, cookieName, cookieDomain, token, payload) {
const parts = token.split('.')
const opts = { sameSite: 'lax', expires: new Date(payload.exp * 1000) }
if (cookieDomain) {
opts.domain = cookieDomain
// to support subdomains we can't use the sameSite opt
// we rely on our ... | javascript | {
"resource": ""
} |
q38090 | _setOrganization | train | function _setOrganization (cookies, cookieName, req, user) {
if (!user) return
// The order is important. The header can set explicitly on a query even if the cookie contradicts.
const organizationId = req.headers['x-organizationid'] || cookies.get(cookieName + '_org')
if (organizationId) {
user.organizatio... | javascript | {
"resource": ""
} |
q38091 | _verifyToken | train | async function _verifyToken (jwksClient, token) {
const decoded = jwt.decode(token, { complete: true })
const signingKey = await jwksClient.getSigningKeyAsync(decoded.header.kid)
return jwt.verifyAsync(token, signingKey.publicKey || signingKey.rsaPublicKey)
} | javascript | {
"resource": ""
} |
q38092 | _decode | train | function _decode (cookieName, cookieDomain, publicUrl) {
return (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, publicUrl)
if (token) {
req.user = jwt.decode(token)
... | javascript | {
"resource": ""
} |
q38093 | _auth | train | function _auth (privateDirectoryUrl, publicUrl, jwksClient, cookieName, cookieDomain, forceExchange) {
return asyncWrap(async (req, res, next) => {
// JWT in a cookie = already active session
const cookies = new Cookies(req, res)
const token = _getCookieToken(cookies, req, cookieName, cookieDomain, public... | javascript | {
"resource": ""
} |
q38094 | _login | train | function _login (directoryUrl, publicUrl) {
return (req, res) => {
res.redirect(directoryUrl + '/login?redirect=' + encodeURIComponent(req.query.redirect || publicUrl))
}
} | javascript | {
"resource": ""
} |
q38095 | _logout | train | function _logout (cookieName, cookieDomain) {
return (req, res) => {
const cookies = new Cookies(req, res)
cookies.set(cookieName, null, { domain: cookieDomain })
cookies.set(cookieName + '_sign', null, { domain: cookieDomain })
// case where the cookies were set before assigning domain
if (cookie... | javascript | {
"resource": ""
} |
q38096 | refineRangeBoundaries | train | function refineRangeBoundaries(range) {
let startContainer = range.startContainer,
endContainer = range.endContainer,
ancestor = range.commonAncestorContainer,
goDeeper = true;
if (range.endOffset === 0) {
while (!endContainer.previousSibling && endContainer.parentNode !== ances... | javascript | {
"resource": ""
} |
q38097 | groupHighlights | train | function groupHighlights(highlights) {
let order = [],
chunks = {},
grouped = [];
highlights.forEach(function (hl) {
let timestamp = hl.getAttribute(TIMESTAMP_ATTR);
if (typeof chunks[timestamp] === 'undefined') {
chunks[timestamp] = [];
order.push(times... | javascript | {
"resource": ""
} |
q38098 | train | function (nodesToAppend) {
let nodes = Array.prototype.slice.call(nodesToAppend);
for (let i = 0, len = nodes.length; i < len; ++i) {
el.appendChild(nodes[i]);
}
} | javascript | {
"resource": ""
} | |
q38099 | train | function () {
if (!el) {
return;
}
if (el.nodeType === NODE_TYPE.TEXT_NODE) {
while (el.nextSibling && el.nextSibling.nodeType === NODE_TYPE.TEXT_NODE) {
el.nodeValue += el.nextSibling.nodeValue;
el.parentNode.r... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.