_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q39900 | getTopImages | train | function getTopImages(params, config, conn) {
// defaults
config = config || require('../config/config.js')
var limit = 10
if (!isNaN(params.limit)) {
limit = params.limit
}
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
... | javascript | {
"resource": ""
} |
q39901 | getTags | train | function getTags(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params.limit = 100
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
if (params.uri) {
var sql = 'SELECT t.tag from Med... | javascript | {
"resource": ""
} |
q39902 | getRandomUnseenImage | train | function getRandomUnseenImage(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
var max = config.db.max || 0
var optimization = config.optimization || 0
var offset = Math.floor(Math.random() * max)
params.optimization = optimization
params.of... | javascript | {
"resource": ""
} |
q39903 | getLastSeen | train | function getLastSeen(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
params.webid = params.webid || 'http://melvincarvalho.com/#me'
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.d... | javascript | {
"resource": ""
} |
q39904 | astroViewer | train | function astroViewer (options, cb) {
request({
url: 'http://astroviewer-sat2c.appspot.com/predictor',
qs: {
var: 'passesData',
lat: options.lat,
lon: options.lon,
name: options.name
},
headers: {
'User-Agent': 'request'
}
}, function (error, response, body) {
if... | javascript | {
"resource": ""
} |
q39905 | listPasses | train | function listPasses (data, cb) {
var index = 0
var passes = data.passes
var newpasses = ''
if (passes.length === 0) {
newpasses += ':( No results found for **' + data.location.name + '**'
} else {
passes.map(function (obj) {
if (index === 0) {
newpasses += '**' + data.location.name + '**... | javascript | {
"resource": ""
} |
q39906 | closeConnection | train | function closeConnection(errMsg) {
if (ftp) {
ftp.raw.quit(function(err, res) {
if (err) {
grunt.log.error(err);
done(false);
}
ftp.destroy();
grunt.log.ok("FTP connection closed!");
done();
});
} else if (errMsg) {
grunt.log.warn(errMsg);
done(false);
} else {
done();... | javascript | {
"resource": ""
} |
q39907 | getNextClar | train | function getNextClar(params, string, files) {
if (params === 'all') {
files.push(string);
return true;
}
if (Array.isArray(params)){
params.forEach(function(item, i, array) {
files.push(string + '.' + item + '$');
return true;
});
}else if (typeof params === 'object'){
var param;
for (... | javascript | {
"resource": ""
} |
q39908 | createDownloadList | train | function createDownloadList() {
uploadFiles = [];
files.forEach(function(item, i, arr) {
var preg = new RegExp(item);
var check = false;
serverFonts.forEach(function(item, i, arr) {
if (preg.test(item)) {
uploadFiles.push(item);
check = true;
// serverFonts.remove(item);
}
... | javascript | {
"resource": ""
} |
q39909 | removeFonts | train | function removeFonts(files){
var dest = normalizeDir(options.dest);
files.forEach(function(item, i, arr){
grunt.file.delete(dest + item);
grunt.log.warn('File ' + item + ' remove.');
});
} | javascript | {
"resource": ""
} |
q39910 | getFilesList | train | function getFilesList(pattern) {
//If pattern empty return all avaliable fonts
if (pattern === undefined || pattern === '') {
formatingFontsArray(serverFonts);
closeConnection();
return; // We are completed, close connection and end the program
}
var serverFiles = [],
preg = new RegExp('[\\w\\-\\.]... | javascript | {
"resource": ""
} |
q39911 | formatingFontsArray | train | function formatingFontsArray(array) {
var fileContent = '',
file = [],
buffer = array[0].split('.')[0],
exp = [];
function writeResult() {
var str = buffer + ' [' + exp.join(', ') + ']';
fileContent += str + '\n';
grunt.log.ok(str);
}
array.forEach(function(item, i, arr) {
file = item.spl... | javascript | {
"resource": ""
} |
q39912 | sourceReplacer | train | function sourceReplacer(source, replacements) {
// shared
var getBefore = getField('before');
var getAfter = getField('after');
// split source code into lines, include the delimiter
var lines = source.split(/(\r?\n)/g);
// split each line further by the replacements
for (var i = 0; i < lines.length; ... | javascript | {
"resource": ""
} |
q39913 | getColumnAfter | train | function getColumnAfter(lineIndex, columnIndex) {
if (lineIndex in lines) {
var line = lines[lineIndex];
var count = 0;
var offset = 0;
for (var i = 0; i < line.length; i++) {
var widthBefore = getBefore(line[i]).length;
var widthAfter = getAfter(line[i]).length;
... | javascript | {
"resource": ""
} |
q39914 | train | function(args) {
if (!args) {
return [];
}
if (args[0] instanceof Array) {
return args[0];
}
return Array.prototype.slice.call(args, 0);
} | javascript | {
"resource": ""
} | |
q39915 | Reporter | train | function Reporter (opts) {
this.events = opts.events;
this.config = opts.config;
this.data = {};
this.actionQueue = [];
this.data.tests = [];
this.browser = null;
var defaultReportFolder = 'report';
this.dest = this.config.get('json-reporter') && this.config.get('json-reporter').dest ? this.config.get(... | javascript | {
"resource": ""
} |
q39916 | train | function (data) {
this.data.tests.push({
id: data.id,
name: data.name,
browser: this.browser,
status: data.status,
passedAssertions: data.passedAssertions,
failedAssertions: data.failedAssertions,
actions: this.actionQueue
});
return this;
} | javascript | {
"resource": ""
} | |
q39917 | train | function (data) {
this.data.elapsedTime = data.elapsedTime;
this.data.status = data.status;
this.data.assertions = data.assertions;
this.data.assertionsFailed = data.assertionsFailed;
this.data.assertionsPassed = data.assertionsPassed;
var contents = JSON.stringify(this.data, false, 4);
if... | javascript | {
"resource": ""
} | |
q39918 | cloneArray | train | function cloneArray(a) {
var b = [], i = a.length
while (i--) b[ i ] = a[ i ]
return b
} | javascript | {
"resource": ""
} |
q39919 | installPlugin | train | function installPlugin(nameOrPlugin, options) {
assert(nameOrPlugin, 'name or plugin is required')
var plugin,
ctor,
self = this,
parent = module.parent
if (typeof nameOrPlugin === 'string')
try {
// local plugin
if (nameOrPlugin.substring(0, 2) ==... | javascript | {
"resource": ""
} |
q39920 | failed | train | function failed(err, userId, channel, target) {
if (err && typeof err === 'object') {
err.userId = userId
err.channel = channel
err.target = target
}
errors.push(err)
done()
} | javascript | {
"resource": ""
} |
q39921 | done | train | function done() {
var arg = errors.length ? errors : null
--pending || process.nextTick(callback, arg)
} | javascript | {
"resource": ""
} |
q39922 | registerTarget | train | function registerTarget(userId, channel, target, callback) {
this.save(userId, channel, target, function (err) {
// ensure that we're firing the callback asynchronously
process.nextTick(callback, err)
})
// make it chainable
return this
} | javascript | {
"resource": ""
} |
q39923 | unregisterTargets | train | function unregisterTargets(userId, channel, targets, callback) {
var self = this
// no target list specified, so we need to load all the targets
// of the supplied channel
if (arguments.length < 4) {
// probably we've got the callback as the third arg
callback = targets
this.lo... | javascript | {
"resource": ""
} |
q39924 | removeTargets | train | function removeTargets(self, userId, channel, targets, callback) {
// dereference the original array,
// because that may not be trustworthy
targets = cloneArray(targets)
var pending = targets.length,
errors = []
if (pending)
targets.forEach(function (target) {
self.re... | javascript | {
"resource": ""
} |
q39925 | unreference | train | function unreference() {
var plugins = this._plugins
Object.keys(plugins).forEach(function (name) {
var plugin = plugins[ name ]
// `unref()` is preferred
if (typeof plugin.unref === 'function')
plugin.unref()
// if we cannot stop gracefully then destroy open
... | javascript | {
"resource": ""
} |
q39926 | train | function (path, callback) {
fs.stat(path, function (err, stats) {
failOn(err, "Error while reading the resolver path:", err);
if (stats.isFile()) {
TomahawkJS.loadAxe(path, _.partial(statResolver, callback));
} else if (stats.isDirectory()) {
// Load the resolver from... | javascript | {
"resource": ""
} | |
q39927 | concat | train | function concat (target, data) {
target = target || []
if(Object.prototype.toString.call(data)!=='[object Array]') {
data = [data]
}
Array.prototype.push.apply(target, data)
return target
} | javascript | {
"resource": ""
} |
q39928 | train | function(doc, nodes, selector, after) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) {
//Try to create the parent recursively if necessary
try {
var parentToCreate = et.XML('<' + path.basename(selector) + '>'),
parentS... | javascript | {
"resource": ""
} | |
q39929 | train | function(doc, nodes, selector) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) return false;
nodes.forEach(function (node) {
var matchingKid = null;
if ((matchingKid = findChild(node, parent)) !== null) {
// stupid elementtree tak... | javascript | {
"resource": ""
} | |
q39930 | train | function(doc, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
if (xml.oldAttrib) {
target.attrib = _.extend({}, xml.oldAttrib);
}
return true;
} | javascript | {
"resource": ""
} | |
q39931 | findInsertIdx | train | function findInsertIdx(children, after) {
var childrenTags = children.map(function(child) { return child.tag; });
var afters = after.split(';');
var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); });
var foundIndex = _.find(afterIndexes, function(index) { return ... | javascript | {
"resource": ""
} |
q39932 | attachToScope | train | function attachToScope(model, itemsToAttach) {
var me = this;
_.each(itemsToAttach, function (item) {
if (me.pancakes.exists(item, null)) {
model[item] = me.pancakes.cook(item, null);
}
});
} | javascript | {
"resource": ""
} |
q39933 | getAppFileNames | train | function getAppFileNames(appName, dir) {
var partialsDir = this.pancakes.getRootDir() + delim + 'app' + delim + appName + delim + dir;
return fs.existsSync(partialsDir) ? fs.readdirSync(partialsDir) : [];
} | javascript | {
"resource": ""
} |
q39934 | dotToCamelCase | train | function dotToCamelCase(name) {
if (!name) { return name; }
if (name.substring(name.length - 3) === '.js') {
name = name.substring(0, name.length - 3);
}
name = name.toLowerCase();
var parts = name.split('.');
name = parts[0];
for (var i = 1; i < parts.length; i++) {
name ... | javascript | {
"resource": ""
} |
q39935 | registerJytPlugins | train | function registerJytPlugins() {
var rootDir = this.pancakes.getRootDir();
var pluginDir = path.normalize(rootDir + '/app/common/jyt.plugins');
var me = this;
// if plugin dir doesn't exist, just return
if (!fs.existsSync(pluginDir)) { return; }
// else get all plugin files from the jyt.plugin... | javascript | {
"resource": ""
} |
q39936 | isMobileApp | train | function isMobileApp() {
var isMobile = false;
var appConfigs = this.pancakes.cook('appConfigs', null);
_.each(appConfigs, function (appConfig) {
if (appConfig.isMobile) {
isMobile = true;
}
});
return isMobile;
} | javascript | {
"resource": ""
} |
q39937 | doesFileExist | train | function doesFileExist(filePath) {
if (!fileExistsCache.hasOwnProperty(filePath)) {
fileExistsCache[filePath] = fs.existsSync(filePath);
}
return fileExistsCache[filePath];
} | javascript | {
"resource": ""
} |
q39938 | isCyclic | train | function isCyclic(obj) {
let seenObjects = [];
const detect = obj => {
if (obj && typeof obj === "object") {
if (seenObjects.includes(obj)) {
return true;
}
seenObjects.push(obj);
for (const key in obj) {
if (obj.hasOwnPro... | javascript | {
"resource": ""
} |
q39939 | train | function (req, res, next) {
if (options.forceAuthorize) {
return next();
}
var userId = req.oauth2.user.id;
var clientId = req.oauth2.client.id;
var scope = req.oauth2.req.scope;
models.Permissions.isAuthorized(clientId, userId, sco... | javascript | {
"resource": ""
} | |
q39940 | train | function (req, res, next) {
if (options.decisionPage) {
var urlObj = {
pathname: options.decisionPage,
query: {
transactionId: req.oauth2.transactionID,
userId: req.oauth2.user.id,
... | javascript | {
"resource": ""
} | |
q39941 | clientLogin | train | function clientLogin(clientId, clientSecret, done) {
debug('clientLogin: %s', clientId);
clientId = parseInt(clientId);
if (!clientId && clientId !== 0) {
return done(null, false);
}
models.Clients.findByClientId(clientId, function (err, client) {
if (er... | javascript | {
"resource": ""
} |
q39942 | train | function (namespaces) {
_.forEach(namespaces, function (level, namespace) {
cache.add(namespace, level);
});
return this;
} | javascript | {
"resource": ""
} | |
q39943 | train | function(level, title, format, filters, needstack, args) {
var msg = utils.format.apply(this, args)
var data = {
timestamp : dateFormat(new Date(), _config.dateformat),
message : msg,
title : title,
level : level,
args : args
}
... | javascript | {
"resource": ""
} | |
q39944 | withFilePath | train | function withFilePath (file, msg) {
if (file && file.path) {
msg += `\n ${file.path}`;
}
return msg;
} | javascript | {
"resource": ""
} |
q39945 | _createRequestParams | train | function _createRequestParams(params){
var resourcePath = params.resourcePath;
resourcePath = resourcePath.replace(":domain", params.domain)
.replace(":projectid", params.projectid)
.replace(":guid", params.appid);
log.logger.debug("Creating Request Params For Core ", params);
var coreHost = params.ap... | javascript | {
"resource": ""
} |
q39946 | _createResponseHandler | train | function _createResponseHandler(req, next, skipDataResult){
return function(err, httpResponse, responseBody){
log.logger.debug("Performing Core Action ", req.url, err, httpResponse.statusCode, responseBody);
if(err || (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 204)){
return next(er... | javascript | {
"resource": ""
} |
q39947 | checkFormAssociation | train | function checkFormAssociation(req, res, next){
var requestedFormId = req.params.id;
req.appformsResultPayload = req.appformsResultPayload || {};
var formsAssociatedWithProject = req.appformsResultPayload.data || [];
var foundForm = _.find(formsAssociatedWithProject, function(formId){
return requestedFormId... | javascript | {
"resource": ""
} |
q39948 | notifySubmissionComplete | train | function notifySubmissionComplete(req, res, next){
req.appformsResultPayload = req.appformsResultPayload || {};
var completeStatus = req.appformsResultPayload.data;
var submission = completeStatus.formSubmission;
//The Submission Is Not Complete, No need to send a notification.
if("complete" !== completeStat... | javascript | {
"resource": ""
} |
q39949 | replaceMacro | train | function replaceMacro(code) {
if (!re) return getKeys(code);
var match = code.match(re);
if (!match) return getKeys(code);
var includeFile = match[1];
includeFile = path.relative(self.config.root, path.join(path.dirname(fileName), includeFile));
self._parse(includeFile, function (err, includeCode) {
if... | javascript | {
"resource": ""
} |
q39950 | done | train | function done(code) {
// calculate shasum and cache info
var shasum = crypto.createHash('sha1');
shasum.update(code);
self._shasums[scriptName] = shasum.digest('hex');
self._scripts[scriptName] = code;
self._files[fileName] = code;
// make dublicate entries for both script and script.lua
if (path.extna... | javascript | {
"resource": ""
} |
q39951 | exec | train | function exec(cmd, args, options) {
// If true user wants stdout to output value
// instead of using inherit outputting
// to process.stdout stream.
if (options === true)
options = { stdio: 'pipe' };
options = chek_1.extend({}, spawnDefaults, options);
if (chek_1.isString(args))
... | javascript | {
"resource": ""
} |
q39952 | processArguments | train | function processArguments(props, args, defaults) {
debug('processArguments',props,args,defaults);
values = Object.assign({}, defaults);
let properties = Object.getOwnPropertyNames(values);
// First execute any single-arg functions to create dynamic defaults
for (property of properties) {
... | javascript | {
"resource": ""
} |
q39953 | create | train | function create(defaults) {
let props = Object.getOwnPropertyNames(defaults);
/** Immutable class created from defaults.
*
*/
const immutableClass = class {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied ov... | javascript | {
"resource": ""
} |
q39954 | extend | train | function extend(to_extend, new_defaults = {}) {
let new_default_props = Object.getOwnPropertyNames(new_defaults);
let old_props = to_extend.getImmutablePropertyNames();
let new_props = new_default_props.filter(e => old_props.indexOf(e) < 0);
//let overriden_props = new_default_props.filter(e => old_pro... | javascript | {
"resource": ""
} |
q39955 | withSharo | train | function withSharo(nextConfig = {}) {
// https://github.com/zeit/next-plugins/issues/320
const withMdx = require('@zeit/next-mdx')({
// Allow regular markdown files (*.md) to be imported.
extension: /\.mdx?$/
})
return (
withSass(withMdx(
Object.assign(
// ==============================... | javascript | {
"resource": ""
} |
q39956 | insert | train | function insert(node, parent, tight) {
var children = parent.children;
var length = children.length;
var last = children[length - 1];
var isLoose = false;
var index;
var item;
if (node.depth === 1) {
item = listItem();
item.children.push({
type: PARAGRAPH,
... | javascript | {
"resource": ""
} |
q39957 | GFSupload | train | function GFSupload(mongoinst, prefix) {
this.mongo = mongoinst;
this.db = this.mongo.db;
this.Grid = this.mongo.Grid;
this.GridStore = this.mongo.GridStore;
this.ObjectID = this.mongo.ObjectID;
this.prefix = prefix || this.GridStore.DEFAULT_ROOT_COLLECTION;
return this;
} | javascript | {
"resource": ""
} |
q39958 | train | function (name, guild) {
let emoji = guild.emojis.find('name', name);
if (emoji === undefined || emoji === null)
return name;
return `<:${name}:${emoji.id}>`;
} | javascript | {
"resource": ""
} | |
q39959 | train | function (name, guild) {
return guild.members.filter((item) => item.user.username.toLowerCase() === this.name.toLowerCase()).join();
} | javascript | {
"resource": ""
} | |
q39960 | train | function (name, guild) {
return guild.channels.filter((item) => item.type === "text").filter((item) => item.name === this.name).join();
} | javascript | {
"resource": ""
} | |
q39961 | validate | train | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var withscores;
if(args.length > 3) {
withscores = ('' + args[3]).toLowerCase();
if(withscores !== Constants.ZSET.WITHSCORES) {
throw CommandSyntax;
}
args[3] = withscores;
}
} | javascript | {
"resource": ""
} |
q39962 | _printItem | train | function _printItem (item) {
switch(item.type) {
case 'option':
console.log(item.index + ': ' + item.label);
break;
case 'break':
for (var breakString = ''; breakString.length < item.charCount;) {
breakString += item.character;
}
console.log(breakString);
break;
... | javascript | {
"resource": ""
} |
q39963 | buildImages | train | function buildImages(conf, undertaker) {
const imageMinConfig = {
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
cleanupIDs: true
}, {
cleanupAttrs: true
}]
};
const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src,... | javascript | {
"resource": ""
} |
q39964 | render | train | function render(element, opts) {
opts = opts || {};
var prepend = opts.prepend;
var model = opts.model || {};
var indentLevel = opts.indentLevel || 0;
var isPretty = opts.isPretty;
var jtPrintIndent = isPretty ? '\t' : '';
var jtPrintNewline = isPretty ? '\n' : '';
var indent = '', i, l... | javascript | {
"resource": ""
} |
q39965 | addElemsToScope | train | function addElemsToScope(scope) {
var prop;
for (prop in elems) {
if (elems.hasOwnProperty(prop)) {
scope[prop] = elems[prop];
}
}
scope.elem = elem;
} | javascript | {
"resource": ""
} |
q39966 | registerComponents | train | function registerComponents(elemNames) {
if (!elemNames) { return; }
var elemNameDashCase, elemNameCamelCase;
for (var i = 0; i < elemNames.length; i++) {
elemNameDashCase = elemNames[i];
elemNameCamelCase = utils.dashToCamelCase(elemNameDashCase);
elems[elemNameCamelCase] = makeEle... | javascript | {
"resource": ""
} |
q39967 | init | train | function init() {
var tagName;
for (var i = 0; i < allTags.length; i++) {
tagName = allTags[i];
elems[tagName] = makeElem(tagName);
}
} | javascript | {
"resource": ""
} |
q39968 | getBundleMinIf | train | function getBundleMinIf(bundle, build, min) {
// Disable minification?
if (bundle.noMin)
return false;
// Glob filter paths to exlude and include files for minification.
// Start by excluding absolute paths of pre-minified files.
var minGlobs = lodash.map(min, function minAbsPath(relPath) {
return bui... | javascript | {
"resource": ""
} |
q39969 | Sprite | train | function Sprite(texture)
{
Container.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting the anchor to 0.5,0.5 means the texture's origin is centered
* Setting the anchor to 1,1 would mean the text... | javascript | {
"resource": ""
} |
q39970 | processSync | train | function processSync(filename, content, updater, format) {
var text = String(content);
// parse code to AST using esprima
var ast = esprima.parse(text, {
loc : true,
comment: true,
source : filename
});
// sort nodes before changing the source-map
var sorted = orderNodes(ast);
// associa... | javascript | {
"resource": ""
} |
q39971 | depthFirst | train | function depthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
par... | javascript | {
"resource": ""
} |
q39972 | breadthFirst | train | function breadthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// begin the queue with the given node
var queue = [{node:node, parent:parent}];
while (queue.length) {
// pull the next item from the front of the queue
var item = queue.shift();
node ... | javascript | {
"resource": ""
} |
q39973 | nodeSplicer | train | function nodeSplicer(candidate, offset) {
offset = offset || 0;
return function setter(value) {
var found = findReferrer(candidate);
if (found) {
var key = found.key;
var obj = found.object;
var array = Array.isArray(obj) && obj;
if (!array) {
obj[key] = value;
}
... | javascript | {
"resource": ""
} |
q39974 | compareLocation | train | function compareLocation(nodeA, nodeB) {
var locA = nodeA && nodeA.loc;
var locB = nodeB && nodeB.loc;
if (!locA && !locB) {
return 0;
}
else if (Boolean(locA) !== Boolean(locB)) {
return locA ? +1 : locB ? -1 : 0;
}
else {
var result =
isOrdered(locB.end, locA.start) ? +1 : isOrdered(... | javascript | {
"resource": ""
} |
q39975 | isOrdered | train | function isOrdered(tupleA, tupleB) {
return (tupleA.line < tupleB.line) || ((tupleA.line === tupleB.line) && (tupleA.column < tupleB.column));
} | javascript | {
"resource": ""
} |
q39976 | compareIndex | train | function compareIndex(nodeA, nodeB) {
var indexA = nodeA && nodeA.sortIndex;
var indexB = nodeB && nodeB.sortIndex;
if (!indexA && !indexB) {
return 0;
}
else if (Boolean(indexA) !== Boolean(indexB)) {
return indexA ? +1 : indexB ? -1 : 0;
}
else {
return indexA - indexB;
}
} | javascript | {
"resource": ""
} |
q39977 | findReferrer | train | function findReferrer(candidate, container) {
var result;
if (candidate) {
// initially for the parent of the candidate node
container = container || candidate.parent;
// consider keys in the node until we have a result
var keys = getKeys(container);
for (var i = 0; !result && (i < keys.length... | javascript | {
"resource": ""
} |
q39978 | getKeys | train | function getKeys(container) {
function arrayIndex(value, i) {
return i;
}
if (typeof container === 'object') {
return Array.isArray(container) ? container.map(arrayIndex) : Object.keys(container);
} else {
return [];
}
} | javascript | {
"resource": ""
} |
q39979 | tagResultFunction | train | function tagResultFunction(fn, tokenDescription, replacement) {
const description = tag(fn);
if (description) {
tokenDescription = description.replace(tokenDescription, replacement);
}
tag(fn, tokenDescription);
fn.toString = tokenToString;
return fn;
} | javascript | {
"resource": ""
} |
q39980 | findRoot | train | function findRoot() {
let rootPath;
try {
rootPath = glob.sync('../**/Drupal.php', {ignore: ['../vendor/**', '../node_modules/**']});
} catch (err) {
throw new Error('No Drupal root found.');
}
// If we found no results for Drupal.php..then bomb out.
if (rootPath.length === 0) {
throw new Err... | javascript | {
"resource": ""
} |
q39981 | train | function(name) {
var i;
if (this.$editables.length) {
//activate by name
if (angular.isString(name)) {
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].name === name) {
this.$editables[i].activate();
return;
}
... | javascript | {
"resource": ""
} | |
q39982 | getUserForToken | train | function getUserForToken(decodedToken) {
var userId = decodedToken._id;
var authToken = decodedToken.authToken;
var cacheKey = userId + authToken;
var conditions = {
caller: userService.admin,
where: { _id: userId, authToken: authToken, status: 'created' },
... | javascript | {
"resource": ""
} |
q39983 | validateToken | train | function validateToken(req, reply) {
var authorization = req.headers.authorization;
if (!authorization) {
return reply.continue();
}
// this is hack fix so that localStorage and cookies can either have Bearer or not
// if in local storate, it is serialized, so need t... | javascript | {
"resource": ""
} |
q39984 | init | train | function init(ctx) {
var server = ctx.server;
if (!privateKey) {
throw new Error('Please set config.security.token.privateKey');
}
server.ext('onPreAuth', validateToken);
return new Q(ctx);
} | javascript | {
"resource": ""
} |
q39985 | execute | train | function execute(req, res) {
req.conn.unwatch(req.db);
res.send(null, Constants.OK);
} | javascript | {
"resource": ""
} |
q39986 | getLibStateAccessor | train | function getLibStateAccessor(libState) {
/** The current state name */
return { get actionName() {
return libState.actionName;
}
/** Is in idle state (no more states to progress to) */
, get isIdle() {
return libState.isIdle;
}
/** State can be pau... | javascript | {
"resource": ""
} |
q39987 | _shouldActivityUpdate | train | function _shouldActivityUpdate(_ref5) {
var type = _ref5.type;
var pageX = _ref5.pageX;
var pageY = _ref5.pageY;
if (type !== 'mousemove') return true;
var _stores$fast = stores.fast;
var lastActive = _stores$fast.lastActive;
var _stores$fast$lastEven = _stores$fast.lastEvent... | javascript | {
"resource": ""
} |
q39988 | onActivity | train | function onActivity(e) {
if (!_shouldActivityUpdate(e)) return;
if (_shouldRestart()) return dispatch(context.actions.start());
/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */
setState(_constants.IDLEMONITOR_ACTIVITY, { lastActive: +new Date(), lastEvent: { x: e.pageX, y: e.pageY } ... | javascript | {
"resource": ""
} |
q39989 | schedule | train | function schedule(actionName) {
timeout.clear();
var timeoutMS = timeout.timeoutMS(actionName);
log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
if (timeoutMS > 0) return setTimeout(funct... | javascript | {
"resource": ""
} |
q39990 | execute | train | function execute(_ref7) {
var actionName = _ref7.actionName;
var isPaused = _ref7.isPaused;
var nextActionName = getNextActionName(actionName);
var wasPaused = stores.redux.isPaused;
/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */
... | javascript | {
"resource": ""
} |
q39991 | train | function (e) {
var elem = e.target;
if (this.scrollIfAnchor(elem.getAttribute('href'), true)) {
e.preventDefault();
}
} | javascript | {
"resource": ""
} | |
q39992 | train | function(key, defaultValue){
var value = this.get(key, defaultValue);
if($ExpressSESSION.session.store[key]){
delete $ExpressSESSION.session.store[key];
}
return value;
} | javascript | {
"resource": ""
} | |
q39993 | merge | train | function merge(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) return target;
var source = sources.shift();
if ((0, _isObject2.default)(target) && (0, _isObject2.default)(so... | javascript | {
"resource": ""
} |
q39994 | readQueue | train | function readQueue() {
disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
if(err) {
self.emit('error', err);
}
else {
jobs.forEach(function(job) {
pendingMessages++;
... | javascript | {
"resource": ""
} |
q39995 | dst | train | function dst(lat1, lon1, lat2, lon2) {
// generally used geo measurement function
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) *
Math.cos(lat2 * Math.... | javascript | {
"resource": ""
} |
q39996 | renderLayout | train | function renderLayout(appName, layoutName, isAmp, dependencies) {
var layout = this.pancakes.cook('app/' + appName + '/layouts/' + layoutName + '.layout');
var layoutView = this.pancakes.cook(layout.view, { dependencies: dependencies });
return jangular.render(layoutView, dependencies.model, { strip: false,... | javascript | {
"resource": ""
} |
q39997 | checkOnScopeChangeVals | train | function checkOnScopeChangeVals(partial, partialName) {
var remodelOnScopeChange = partial.remodelOnScopeChange || (partial.remodel && partial.remodel.onScopeChange);
var rerenderOnScopeChange = partial.rerenderOnScopeChange || (partial.rerender && partial.rerender.onScopeChange);
var scope = partial.scope ... | javascript | {
"resource": ""
} |
q39998 | getSubviews | train | function getSubviews(subviewFlapjacks) {
var renderedSubviews = {};
var jangularDeps = this.getJangularDeps();
var me = this;
_.each(subviewFlapjacks, function (subview, subviewName) {
renderedSubviews[subviewName] = me.pancakes.cook(subview, { dependencies: jangularDeps });
});
return... | javascript | {
"resource": ""
} |
q39999 | getPartialRenderFn | train | function getPartialRenderFn(partial, partialName) {
var jangularDeps = this.getJangularDeps();
var me = this;
return function renderPartial(model, elem, attrs) {
me.isolateScope(model, partial.scope, attrs);
// throw error if onScopeChange values not in the scope {} definition
me.c... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.