_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q33400 | bootstrap | train | function bootstrap(next) {
if (!options.commands || !options.commands.length) {
return next();
}
var hasErr;
self.ssh({
keys: options.keys,
server: options.server,
commands: options.commands,
remoteUser: options.remoteUser,
tunnel: options.tunnel... | javascript | {
"resource": ""
} |
q33401 | fixOutputPaths | train | function fixOutputPaths(output, files) {
// map directories to use for index files
var dirMap = {};
u.each(files, function(file) {
dirMap[ppath.dirname(file.path)] = true;
// edge case - treat /foo/ as directory too
if (/\/$/.test(file.path) && ppath.dirname(file.path) !== file.path) {
... | javascript | {
"resource": ""
} |
q33402 | addModuleToParentPom | train | function addModuleToParentPom (parentPomPath, properties, yoFs) {
var pomStr = yoFs.read(parentPomPath); | javascript | {
"resource": ""
} |
q33403 | processModules | train | function processModules (resourcesPath, targetPath, directory, modules, parentPomPath, properties, yoFs) {
modules.forEach(module => {
debug('Processing module', module);
var modulePath = path.join(directory, module.dir);
properties.artifactId = pathFiltering.filter(module.dir, properties);
addModuleT... | javascript | {
"resource": ""
} |
q33404 | filesFromFileSet | train | function filesFromFileSet (dirname, fileset) {
if (!fileset.includes || !fileset.includes.length) {
return [];
}
return fileset.includes
| javascript | {
"resource": ""
} |
q33405 | globsToExcludeFromFileSet | train | function globsToExcludeFromFileSet (dirname, fileset) {
if (fileset.excludes && fileset.excludes.length) | javascript | {
"resource": ""
} |
q33406 | filter | train | function filter(selector) {
var arr = [], $ = this.air;
this.each(function(el) {
var selections;
if(typeof selector === 'function') {
if(selector.call(el)) {
arr.push(el);
}
}else{
| javascript | {
"resource": ""
} |
q33407 | exec | train | function exec() {
var result;
while(scripts.length) {
var script = scripts.shift();
if(typeof(script) == 'function') {
result = script();
if(result && typeof(result) == 'object' && typeof(result.then) | javascript | {
"resource": ""
} |
q33408 | WalletService | train | function WalletService() {
if (!initialized)
throw new Error('Server not initialized');
this.lock = lock;
this.storage = storage;
this.blockchainExplorer = blockchainExplorer;
this.blockchainExplorerOpts = | javascript | {
"resource": ""
} |
q33409 | initialize | train | function initialize() {
switch (this.type) {
case 'ga':
ga('create', this.key, this.domain);
| javascript | {
"resource": ""
} |
q33410 | map | train | function map(data) {
var result = {}
, i = this.properties.length; | javascript | {
"resource": ""
} |
q33411 | log | train | function log(e) {
var data = $(e.element).get('track').split(';');
// Revenue only allows numbers remove | javascript | {
"resource": ""
} |
q33412 | google | train | function google(e) {
var tracker = this.tracking.ga;
if (!tracker) return;
ga(function done() {
ga.getByName(tracker).send.apply(
tracker,
| javascript | {
"resource": ""
} |
q33413 | fetchGitHub | train | function fetchGitHub(url) {
return fetch(url).then(res => {
if (res.status === STATUS_NOT_FOUND) {
| javascript | {
"resource": ""
} |
q33414 | getStreaks | train | function getStreaks(contributions) {
const start = contributions[0].date;
const end = contributions.slice(-1)[0].date;
const streak = {days: 0, start: null, end: null, unmeasurable: false};
let currentStreak = Object.assign({}, streak);
let longestStreak = Object.assign({}, streak);
contributions.forEach(re... | javascript | {
"resource": ""
} |
q33415 | parseCalendar | train | function parseCalendar($calendar) {
const data = [];
$calendar.find('rect').each((i, elm) => {
const $rect = cheerio(elm);
| javascript | {
"resource": ""
} |
q33416 | summarizeContributions | train | function summarizeContributions(contributions) {
let busiestDay = null;
let total = 0;
contributions.forEach(d => {
if (d.count > 0 && (!busiestDay || d.count | javascript | {
"resource": ""
} |
q33417 | reload_file | train | function reload_file(arg_file_path)
{
const file_name = path.basename(arg_file_path)
const this_file_name = path.basename(__filename)
if (file_name == this_file_name)
{
console.info('Need to reload after change on ' + this_file_name)
return
}
const exts = ['.js', '.json']
const ext = path.extname(arg_file_... | javascript | {
"resource": ""
} |
q33418 | watch | train | function watch(arg_src_dir)
{
console.info('Watching for change on: ' + arg_src_dir)
const watch_settings = { ignored: /[\/\\]\./, persistent: true }
var | javascript | {
"resource": ""
} |
q33419 | rxServer | train | function rxServer(val) { // {{{2
/**
* Called, when received "server" message as a client.
*/
if (! (
val.space === this.peer.space.name &&
val.peer === this.peer.name
)) {
O.log.error(this, 'This is not the right peer'); | javascript | {
"resource": ""
} |
q33420 | _setVadrDeviceCookie | train | function _setVadrDeviceCookie(){
// setting cookie valid for years set in constants
const cookieValidFor = constants.cookieValidForYears;
const deviceCookieName = constants.deviceCookieName;
const currentDate = new Date();
const laterDate = new | javascript | {
"resource": ""
} |
q33421 | remove | train | function remove() {
var i, el;
for(i = 0;i < this.length;i++) {
el = this.dom[i];
// if for some reason this point to the document element
// an exception will occur, pretty hard to reproduce so
| javascript | {
"resource": ""
} |
q33422 | getEnvNumericalValue | train | function getEnvNumericalValue(envValue, defaultVal) {
var limit = defaultVal;
if (envValue) {
limit = parseInt(envValue,10); | javascript | {
"resource": ""
} |
q33423 | setApplication | train | function setApplication(appId, token, version){
appConfig['appId'] | javascript | {
"resource": ""
} |
q33424 | featureNameFromProperty | train | function featureNameFromProperty(instance, defaultName, candidateMap) {
for (var key in candidateMap) {
if (typeof instance[key] !== 'undefined') {
return candidateMap[key];
}
| javascript | {
"resource": ""
} |
q33425 | train | function(pDefaultMessage, pError, pRequest, pResponse, fNext)
{
var tmpErrorMessage = pDefaultMessage;
var tmpErrorCode = 1;
var tmpScope = null;
var tmpParams = null;
var tmpSessionID = null;
if (typeof(pError) === 'object')
{
tmpErrorMessage = pError.Message;
if (pError.Code)
tmpE... | javascript | {
"resource": ""
} | |
q33426 | train | function(pMessage, pRequest, pResponse, fNext)
{
var tmpSessionID = null;
if (pRequest.UserSession)
{
tmpSessionID = pRequest.UserSession.SessionID;
}
_Log.warn('API | javascript | {
"resource": ""
} | |
q33427 | startWorkers | train | function startWorkers() {
_.range(0, numWorkers).forEach(function (index) {
| javascript | {
"resource": ""
} |
q33428 | startWorker | train | function startWorker(port) {
var worker = child.fork(serverWorker, [
'--port', port,
'--server', serverFile,
'--allowForcedExit', allowForcedExit,
'--config', JSON.stringify(config.app || {}),
| javascript | {
"resource": ""
} |
q33429 | createWorkerExitHandler | train | function createWorkerExitHandler(port) {
return function (code, signal) {
var workerIndex = port - startPort;
workers[workerIndex] = null;
if (code !== 0 || code === null) {
console.log('Worker exited with code: ' + code);
if (!shuttingDown)... | javascript | {
"resource": ""
} |
q33430 | condor_simple | train | function condor_simple(cmd, opts) {
var deferred = Q.defer();
var p = spawn(cmd, opts, {env: get_condor_env()});//, {cwd: __dirname});
//load event
var stdout = "";
p.stdout.on('data', function (data) {
stdout += data;
});
var stderr = "";
p.stderr.on('data', function (data) {
... | javascript | {
"resource": ""
} |
q33431 | describe | train | function describe(composer, trailing) {
return function (method) {
return new Descriptor(function (key, previousValues) {
if ( method !== undefined)
previousValues[trailing ? 'push' : 'unshift' ](method)
//console.log(previousValues)
| javascript | {
"resource": ""
} |
q33432 | parseTaskObject | train | function parseTaskObject(task, options) {
if (Array.isArray(task)) { | javascript | {
"resource": ""
} |
q33433 | registerTask | train | function registerTask(file, options) {
const task = require(file.path);
const taskName = path.basename(file.path, file.ext);
| javascript | {
"resource": ""
} |
q33434 | parseFile | train | function parseFile(dir, filename) {
const filePath = path.join(dir, filename);
const fileStat = fs.statSync(filePath);
const fileExt = path.extname(filename);
| javascript | {
"resource": ""
} |
q33435 | handleFile | train | function handleFile(dir, options) {
return filename => {
const file = parseFile(dir, filename);
debug(`found "${filename}"`);
// Exit early if this item is not a file.
if (!file.stat.isFile()) {
debug(`skipped "${filename}" (not a file)`);
return;
}
// Exit early if this item is | javascript | {
"resource": ""
} |
q33436 | extendDefaultOptions | train | function extendDefaultOptions(options) {
return Object.assign({
| javascript | {
"resource": ""
} |
q33437 | importTasks | train | function importTasks(options) {
const opts = parseOptions(options);
const cwd = process.cwd();
const dir = path.join(cwd, opts.dir);
debug(`importing tasks from "${dir}"...`);
// This synchronously reads the | javascript | {
"resource": ""
} |
q33438 | onmessage | train | function onmessage(data) {
if (!handshaked) {
handshaked = true;
// The handshake output is in the form of URI.
var result = url.parse(data, true).query;
// A newly issued id for HTTP transport. It is used to identify which HTTP transport
// is assoc... | javascript | {
"resource": ""
} |
q33439 | loginTo | train | function loginTo (endpoint, config) {
return global.IS_BROWSER
| javascript | {
"resource": ""
} |
q33440 | loginFromBrowser | train | function loginFromBrowser (endpoint, config) {
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint || window.location.origin + window.location.pathname
break
case AUTH_ENDPOINTS.SECONDARY:
uri = config.fallbackAuthEndpoint
break
}
return new Promi... | javascript | {
"resource": ""
} |
q33441 | loginFromNode | train | function loginFromNode (endpoint, config) {
if (!(config.key && config.cert)) {
throw new Error('Must provide TLS key and cert when running in node')
}
let uri
switch (endpoint) {
case AUTH_ENDPOINTS.PRIMARY:
uri = config.authEndpoint
break
case AUTH_ENDPOINTS.SECONDARY:
uri = co... | javascript | {
"resource": ""
} |
q33442 | midi | train | function midi (note) {
if ((typeof note === 'number' || typeof note === 'string') &&
note > 0 && note < 128) return +note
var p | javascript | {
"resource": ""
} |
q33443 | find | train | function find() {
// If there is no remaining URI, fires `error` and `close` event as it means that all
// tries failed.
if (uris.length === 0) {
// Now that `connecting` event is being fired, there is no `error` and `close` event user
// added. Delays to fire them a little while.
... | javascript | {
"resource": ""
} |
q33444 | onevent | train | function onevent(event) {
// Event should have the following properties:
// * `id: string`: an event identifier.
// * `type: string`: an event type.
// * `data: any`: an event data.
// * `reply: boolean`: true if this event requires the reply.
// If the client sends a pl... | javascript | {
"resource": ""
} |
q33445 | insertGlyphsRules | train | function insertGlyphsRules(rule, result) {
// Reverse order
// make sure to insert the characters in ascending order
let glyphs = result.glyphs.slice(0);
let glyphLen = glyphs.length;
while (glyphLen--) {
let glyph = glyphs[glyphLen];
let node = postcss.rule({
selector: '... | javascript | {
"resource": ""
} |
q33446 | extractTypeSourcesFromMarkdown | train | function extractTypeSourcesFromMarkdown(mdSource) {
var types = lang.string.lines(mdSource).reduce((typesAkk, line) => {
if (line.trim().startsWith("//")) return typesAkk;
if (typesAkk.current && !line.trim().length) {
typesAkk.types.push(typesAkk.current); typesAkk.current = []; | javascript | {
"resource": ""
} |
q33447 | cartesian | train | function cartesian(list)
{
var last, init, keys, product = [];
if (Array.isArray(list))
{
init = [];
last = list.length - 1;
}
else if (typeof list == 'object' && list !== null)
{
init = {};
keys = Object.keys(list);
last = keys.length - 1;
}
else
{
throw new TypeError('Expect... | javascript | {
"resource": ""
} |
q33448 | store | train | function store(obj, elem, key)
{
Array.isArray(obj) | javascript | {
"resource": ""
} |
q33449 | nuclearComponent | train | function nuclearComponent(Component, getDataBindings) {
console.warn('nuclearComponent is deprecated, use `connect()` instead');
// support decorator pattern
// detect all React Components because they have a render method
if (arguments.length === 0 || !Component.prototype.render) {
| javascript | {
"resource": ""
} |
q33450 | train | function (value, defaultValue) {
if (module.exports.isEmpty(value)) {
value = defaultValue
} else if (typeof value === 'string') {
value = value.trim().toLowerCase()
switch (value) {
case 'false':
value = 0
break
case 'true':
value = 1
br... | javascript | {
"resource": ""
} | |
q33451 | perf | train | function perf(Target) {
if (process.env.NODE_ENV === 'production') {
return Target;
}
// eslint-disable-next-line global-require
var ReactPerf = require('react-addons-perf');
var Perf = function (_Component) {
_inherits(Perf, _Component);
function Perf() {
_classCallCheck(this, Perf);
... | javascript | {
"resource": ""
} |
q33452 | provideReactor | train | function provideReactor(Component, additionalContextTypes) {
console.warn('`provideReactor` is deprecated, use `<Provider reactor={reactor} />` instead');
// support decorator pattern
if (arguments.length === 0 || typeof arguments[0] !== 'function') {
additionalContextTypes = arguments[0];
| javascript | {
"resource": ""
} |
q33453 | wsConnect | train | function wsConnect() {
var typeOfConnection;
if (location.protocol === 'https:') {
typeOfConnection = 'wss';
} else {
typeOfConnection = 'ws'
}
self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + loca... | javascript | {
"resource": ""
} |
q33454 | getLocalNodeFiles | train | function getLocalNodeFiles(dir) {
dir = path.resolve(dir);
var result = [];
var files = [];
var icons = [];
try {
files = fs.readdirSync(dir);
} catch(err) {
return {files: [], icons: []};
}
files.sort();
files.forEach(function(fn) {
var stats = fs.statSync(p... | javascript | {
"resource": ""
} |
q33455 | scanTreeForNodesModules | train | function scanTreeForNodesModules(moduleName) {
var dir = settings.coreNodesDir;
var results = [];
var userDir;
if (settings.userDir) {
userDir = path.join(settings.userDir,"node_modules");
results = scanDirForNodesModules(userDir,moduleName);
results.forEach(function(r) { r.loca... | javascript | {
"resource": ""
} |
q33456 | validateGeoJson | train | function validateGeoJson(geoJson) {
if (!geoJson)
throw new Error('No geojson passed');
if (geoJson.type !== 'FeatureCollection' &&
geoJson.type !== 'GeometryCollection' &&
| javascript | {
"resource": ""
} |
q33457 | getCombinedTemplateDirectory | train | function getCombinedTemplateDirectory(templateDirectories) {
// Automatically track and clean up files at exit.
temp.track();
// Create a temporary directory to hold our template files.
var combinedTemplateDirectory = temp.mkdirSync('templates');
// Copy templates from our source directories into ... | javascript | {
"resource": ""
} |
q33458 | addSwigFilters | train | function addSwigFilters() {
/**
* Zero padding function.
* Used as both a filter and internally here.
*
* @param input
* @param length
* @returns {string}
*/
function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; /... | javascript | {
"resource": ""
} |
q33459 | zeropad | train | function zeropad(input, length) {
input = input + ''; // Ensure input is a string.
length = length || 2; // Ensure a length is set.
return input.length | javascript | {
"resource": ""
} |
q33460 | rmdirWalk | train | function rmdirWalk( ls, done ) {
if( ls.length === 0 ) return done()
fs.rmdir( ls.shift().path, function( error ) {
| javascript | {
"resource": ""
} |
q33461 | Session | train | function Session(context) {
this.context = context
this.cookies = context.cookies
| javascript | {
"resource": ""
} |
q33462 | train | function (symbol) {
return symbolDict[symbol.charCodeAt(0)] && symbolDict[symbol.charCodeAt(0)][symbol.charCodeAt(1)] | javascript | {
"resource": ""
} | |
q33463 | train | function(){
STATIC_FILES.forEach(function(file){
addFile(fs.createReadStream(__dirname | javascript | {
"resource": ""
} | |
q33464 | train | function(){
for(var i=0; i<DYNAMIC_FILES.length; i++) {
| javascript | {
"resource": ""
} | |
q33465 | Transport | train | function Transport(settings, levels) {
settings = settings || {};
this.levels = levels;
// Set the base settings
this.settings = {
levels: levels,
timestamp: !!settings.timestamp,
prependLevel: !!settings.prependLevel,
colorize: !!settings.colorize,
name: settings.name
};
// Parse the ... | javascript | {
"resource": ""
} |
q33466 | Logger | train | function Logger(transports, settings) {
var i, len,
transport,
levels,
transportInstances = [],
names = {};
// Normalize the inputs
if (!transports) {
transports = [{}];
} else if (!Array.isArray(transports)) {
transports = [transports];
}
settings = settings || {};
levels... | javascript | {
"resource": ""
} |
q33467 | mapAllNames | train | function mapAllNames(path) {
log("[%s] Mapping %s", self.parentModuleName, path);
fs.readdirSync(path).forEach(function(p){
var absPath = PATH.resolve(path+PATH.sep+p);
var lstat = fs.lstatSync(absPath);
if(lstat.isFile() && isModule(p)) {
var name = getModuleName(p);
self.upd... | javascript | {
"resource": ""
} |
q33468 | findProjectRoot | train | function findProjectRoot(startPath) {
log.trace("findProjectRoot startPath = %s", startPath);
if(isDiskRoot()) {
if(hasPackageJson()) {
return startPath;
} else {
throw new Error("Cannot find project root");
}
} else if(hasPackageJson()) {
return startPath;
} else... | javascript | {
"resource": ""
} |
q33469 | createLongpollTransport | train | function createLongpollTransport(req, res) {
// The current response which can be used to send a message or close the connection. It's not
// null when it's available and null when it's not available.
var response;
// A flag to mark this transport is aborted. It's used when `response` is not available, if
// ... | javascript | {
"resource": ""
} |
q33470 | wrapAsyncMethod | train | function wrapAsyncMethod(fn, ctx) {
return function() {
// Obtain function arguments
var args = [].slice.call(arguments);
// Return a thunkified function that receives a done callback
return new Promise(function(resolve, reject) {
// Add a custom callback to provided arg... | javascript | {
"resource": ""
} |
q33471 | wrapAsync | train | function wrapAsync() {
// Traverse async methods
for (var fn in async) {
// Promisify the method
| javascript | {
"resource": ""
} |
q33472 | Marathon | train | function Marathon(opts) {
if (!(this instanceof Marathon)) {
return new Marathon(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
(opts.host || '127.0.0.1') + ':' +
(opts.port || '8080') + '/v2';
}
opts.name = 'marathon'; | javascript | {
"resource": ""
} |
q33473 | getState | train | function getState(reactor, data) {
var state = {}
each(data, function(value, key) {
state[key] = | javascript | {
"resource": ""
} |
q33474 | fsFileTree | train | function fsFileTree (inputPath, opts, cb) {
let result = {};
if (typeof inputPath === "function") {
cb = inputPath;
inputPath = process.cwd();
opts = {};
} else if (typeof opts === "function") {
cb = opts;
if (typeof inputPath === "object") {
opts = inputP... | javascript | {
"resource": ""
} |
q33475 | walkTree | train | function walkTree(element, context, mergeProps, visitor) {
const Component = element.type;
if (typeof Component === 'function') {
const props = assign({}, Component.defaultProps, element.props, (mergeProps || {}));
let childContext = context;
let child;
// Are we are a react class?
// https:... | javascript | {
"resource": ""
} |
q33476 | getDataFromTree | train | function getDataFromTree(rootElement, rootContext, fetchRoot, mergeProps, isTopLevel){
//console.log(`Now searching element (${rootElement.type.name || rootElement.type.displayName}):`, rootElement);
// Get array of queries (fetchData promises) from tree
// This will traverse down recursively looking for fetchD... | javascript | {
"resource": ""
} |
q33477 | jsonSpec | train | function jsonSpec() {
return parsedArgs.specFile ?
read(parsedArgs.specFile).then(JSON.parse) :
| javascript | {
"resource": ""
} |
q33478 | createWebSocketTransport | train | function createWebSocketTransport(ws) {
// A transport object.
var self = new events.EventEmitter();
// Transport URI contains information like protocol header as query.
self.uri = ws.upgradeReq.url;
// Simply delegates WebSocket's events to transport and transport's behaviors to WebSocket.
ws.onmessage = f... | javascript | {
"resource": ""
} |
q33479 | cloneStateDef | train | function cloneStateDef(stateDef) {
stateDef = (stateDef || {});
return function () {
var ctx = this;
return Object.keys(stateDef).reduce((state, k) => | javascript | {
"resource": ""
} |
q33480 | createUnits | train | function createUnits(conversions, withNames=false) {
const result = {};
conversions.forEach(c => c.names.forEach(name =>
result[unitToLower(normalizeUnitName(name))] = {
name: c.names[0],
prefix: c.prefix,
| javascript | {
"resource": ""
} |
q33481 | createUnitRegex | train | function createUnitRegex(units) {
return Object.keys(units)
.sort((a, b) | javascript | {
"resource": ""
} |
q33482 | train | function (url, key, password) {
var deferred, options, headers, liveapicreator;
liveapicreator = _.extend({}, SDK);
liveapicreator.url = this.stripWrappingSlashes(url);
liveapicreator.params = _.pick(URL.parse(url), 'host', 'path', 'port');
liveapicreator.params.headers = {};
if (url.match('https')) ... | javascript | {
"resource": ""
} | |
q33483 | train | function (options, headers) {
if (!headers) { headers = {}; }
if (options.headers) { | javascript | {
"resource": ""
} | |
q33484 | verifyParameters | train | function verifyParameters(replacements, value, decl, environment) {
if (undefined === replacements[value]) {
throw decl.error(
'Unknown variable ' + value,
{ plugin: plugin.name }
);
}
if (undefined === replacements[value][environment]) {
throw | javascript | {
"resource": ""
} |
q33485 | walkDeclaration | train | function walkDeclaration(decl, environment, replacements) {
decl.value = decl.value.replace(functionRegex, function (match, value) {
| javascript | {
"resource": ""
} |
q33486 | Chronos | train | function Chronos(opts) {
if (!(this instanceof Chronos)) {
return new Chronos(opts);
}
opts = opts || {};
if (!opts.baseUrl) {
opts.baseUrl = (opts.secure ? 'https:' : | javascript | {
"resource": ""
} |
q33487 | train | function (testOverride) {
var ret = '127.0.0.1'
os = testOverride || os
var interfaces = os.networkInterfaces()
Object.keys(interfaces).forEach(function (el) {
interfaces[el].forEach(function (el2) {
| javascript | {
"resource": ""
} | |
q33488 | train | function (string) {
if (!string || string === '' || string.indexOf('\r\n') === -1) {
return {
version: 'HTTP/1.1',
statusText: ''
}
}
var lines = string.split('\r\n')
var status = lines.shift()
// Remove empty strings
lines = lines.filter(Boolean)
// Parse stat... | javascript | {
"resource": ""
} | |
q33489 | train | function (line) {
var pieces = line.split(' ')
// Header string pieces
var output = | javascript | {
"resource": ""
} | |
q33490 | train | function (obj) {
// sanity check
if (!obj || typeof obj !== 'object') {
return []
}
var results = []
Object.keys(obj).forEach(function (name) {
// nested values in query string
if (typeof obj[name] === 'object') {
obj[name].forEach(function (value) {
results.pus... | javascript | {
"resource": ""
} | |
q33491 | train | function (headers, key, def) {
if (headers instanceof Array) {
var regex = new RegExp(key, 'i')
for (var i = 0; i < headers.length; i++) {
if (regex.test(headers[i].name)) { | javascript | {
"resource": ""
} | |
q33492 | train | function (req) {
var keys = Object.keys(req.headers)
var values = keys.map(function (key) {
return req.headers[key]
})
var headers = req.method + req.url + keys.join() | javascript | {
"resource": ""
} | |
q33493 | train | function () {
var done = this.async();
var questions = [];
var choices = [
{
name: 'Standard Preset',
value: 'standard'
},
{
name: 'Minimum Preset',
value: 'minimum'
},
{
name: 'Custom Configuration (Advanced)',
... | javascript | {
"resource": ""
} | |
q33494 | train | function () {
this.cfg = {};
// Copy from prompt settings
Object.keys(this.settings).forEach(function (key) {
this.cfg[key] = this.settings[key];
}.bind(this));
// Boolean config
options.forEach(function (option) {
var name = option.name;
option.choices.forE... | javascript | {
"resource": ""
} | |
q33495 | Wallet | train | function Wallet (options) {
this.priv = typeof options.priv === 'string' ?
bitcoin.ECKey.fromWIF(options.priv) :
options.priv
typeforce(typeforce.Object, this.priv)
typeforce({
blockchain: typeforce.Object,
networkName: typeforce.String
}, options)
assert(options.networkName in bitcoin.netwo... | javascript | {
"resource": ""
} |
q33496 | visitTypedVariableDeclarator | train | function visitTypedVariableDeclarator(traverse, node, path, state) {
var ctx = new Context(state);
if (node.init) {
utils.catchup(node.init.range[0], state);
utils.append(ctx.getProperty('check') + '(', state);
traverse(node.init, path, state);
utils.catchup(node.init.range[1], state);
| javascript | {
"resource": ""
} |
q33497 | visitTypedFunction | train | function visitTypedFunction(traverse, node, path, state) {
var klass = getParentClassDeclaration(path);
var generics = klass && klass.typeParameters ? toLookup(klass.typeParameters.params.map(getName)) : {};
if (node.typeParameters) {
generics = mixin(generics, toLookup(node.typeParameters.params.map(getName)... | javascript | {
"resource": ""
} |
q33498 | visitTypeAlias | train | function visitTypeAlias(traverse, node, path, state) {
var ctx = new Context(state);
utils.catchup(node.range[1], state);
utils.append('var | javascript | {
"resource": ""
} |
q33499 | train | function (type) {
var handlers = { 'html': beautify.html, 'css': beautify.css, 'js': beautify.js };
if (type === undefined) {
return beautify;
}
if (type in | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.