_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q50300
routeObjToRouteName
train
function routeObjToRouteName(route, path) { var name = route.controllerAs; var controller = route.controller; if (!name && controller) { if (angular.isArray(controller)) { controller = controller[controller.length - 1]; } name = controller.name; } if (!name) { var s...
javascript
{ "resource": "" }
q50301
Validator
train
function Validator(options) { options = options || {}; this.cwd = options.cwd || process.cwd(); this.debug = !!options.debug; }
javascript
{ "resource": "" }
q50302
hmsToSeconds
train
function hmsToSeconds(time) { var arr = time.split(':'), s = 0, m = 1; while (arr.length > 0) { s += m * parseInt(arr.pop(), 10); m *= 60; } return s; }
javascript
{ "resource": "" }
q50303
secondsToHms
train
function secondsToHms(seconds) { var h = Math.floor(seconds / 3600); var m = Math.floor((seconds / 60) % 60); var s = seconds % 60; var pad = function (n) { n = String(n); return n.length >= 2 ? n : "0" + n; }; if (h > 0) { return pad(h) + ':' + pad(m) + ':' + pad(s); } else { return pad(m) + ':' + pa...
javascript
{ "resource": "" }
q50304
timeParamToSeconds
train
function timeParamToSeconds(param) { var componentValue = function (si) { var regex = new RegExp('(\\d+)' + si); return param.match(regex) ? parseInt(RegExp.$1, 10) : 0; }; return componentValue('h') * 3600 + componentValue('m') * 60 + componentValue('s'); }
javascript
{ "resource": "" }
q50305
internalAction
train
function internalAction(scope, page) { // Block clicks we try to load the active page if (scope.page == page) { return; } // Block if we are forcing disabled if(scope.isDisabled) { return; } // Update the page in scope s...
javascript
{ "resource": "" }
q50306
addRange
train
function addRange(start, finish, scope) { // Add our items where i is the page number var i = 0; for (i = start; i <= finish; i++) { var pgHref = scope.pgHref.replace(regex, i); var liClass = scope.page == i ? scope.activeClass : ''; // Handle items th...
javascript
{ "resource": "" }
q50307
buildDataTable
train
function buildDataTable() { var self = this; var dataTable = new google.visualization.DataTable(); _.each(self.columns, function (value) { dataTable.addColumn(value); }); if (!_.isEmpty(self.rows)) { dataTable.addRows(self.rows); } return dataTable; }
javascript
{ "resource": "" }
q50308
updateDataTable
train
function updateDataTable() { var self = this; // Remove all data from the datatable. self.dataTable.removeRows(0, self.dataTable.getNumberOfRows()); self.dataTable.removeColumns(0, self.dataTable.getNumberOfColumns()); // Add _.each(self.columns, function (value) { self.dat...
javascript
{ "resource": "" }
q50309
buildWrapper
train
function buildWrapper(chartType, dataTable, options, containerId) { var wrapper = new google.visualization.ChartWrapper({ chartType: chartType, dataTable: dataTable, options: options, containerId: containerId }); return wrapper; }
javascript
{ "resource": "" }
q50310
buildChart
train
function buildChart() { var self = this; // If dataTable isn't set, build it var dataTable = _.isEmpty(self.dataTable) ? self.buildDataTable() : self.dataTable; self.wrapper = self.buildWrapper(self.chartType, dataTable, self.options, self.chartId); // Set the datatable on this instance...
javascript
{ "resource": "" }
q50311
drawChart
train
function drawChart() { var self = this; // We don't have any (usable) data, or we don't have columns. We can't draw a chart without those. if (!_.isEmpty(self.rows) && !_.isObjectLike(self.rows) || _.isEmpty(self.columns)) { return; } if (_.isNull(self.chart)) { // We hav...
javascript
{ "resource": "" }
q50312
prepareParams
train
function prepareParams(msg, config) { var params = {}, inputlang = config.inputlang ? config.inputlang : 'en', outputlang = config.outputlang ? config.outputlang : 'en'; if (msg.piparams) { if (msg.piparams.inputlanguage && -1 < VALID_INPUT_LANGUAGES.indexOf(msg.piparams.inputlang...
javascript
{ "resource": "" }
q50313
Node
train
function Node(config) { RED.nodes.createNode(this,config); var node = this, message = ''; this.on('input', function (msg) { node.status({}); payloadCheck(msg) .then(function(){ return wordcountCheck(msg, config); }) .then(function(){ return credentialsCh...
javascript
{ "resource": "" }
q50314
AlchemyFeatureExtractNode
train
function AlchemyFeatureExtractNode (config) { RED.nodes.createNode(this, config); var node = this; this.on('input', function (msg) { if (!msg.payload) { this.status({fill:'red', shape:'ring', text:'missing payload'}); var message = 'Missing property: msg.payload'; node.error(m...
javascript
{ "resource": "" }
q50315
NLUNode
train
function NLUNode (config) { RED.nodes.createNode(this, config); var node = this; this.on('input', function (msg) { var message = '', options = {}; node.status({}); username = sUsername || this.credentials.username; password = sPassword || this.credentials.password; a...
javascript
{ "resource": "" }
q50316
overrideCheck
train
function overrideCheck(msg) { if (msg.srclang){ var langCode = payloadutils.langTransToSTTFormat(msg.srclang); config.lang = langCode; } return Promise.resolve(); }
javascript
{ "resource": "" }
q50317
payloadNonStreamCheck
train
function payloadNonStreamCheck(msg) { var message = ''; // The input comes in on msg.payload, and can either be an audio file or a string // representing a URL. if (!msg.payload instanceof Buffer || !typeof msg.payload === 'string') { message = 'Invalid property: msg.payload, can only b...
javascript
{ "resource": "" }
q50318
processInputStream
train
function processInputStream(msg) { var tmp = msg.payload; if ('string' === typeof msg.payload) { msg.payload = JSON.parse(tmp); } if (msg.payload.action) { if ('start' === msg.payload.action) { startPacket = msg.payload; } } else { msg.payload = {...
javascript
{ "resource": "" }
q50319
connectIfNeeded
train
function connectIfNeeded() { // console.log('re-establishing the connect'); websocket = null; socketCreationInProcess = false; // The token may have expired so test for it. getToken(determineService()) .then(() => { return processSTTSocketStart(false); }) ...
javascript
{ "resource": "" }
q50320
train
function(serviceName, returnBoolean, alchemyRegex) { var regex = alchemyRegex ? RegExp('(http|https)(://)('+serviceName+').*') : RegExp('(http|https)(://)([^\/]+)(/)('+serviceName+').*'); var services = appEnv.getServices(); for (var service in services) { if (service...
javascript
{ "resource": "" }
q50321
train
function(credentials) { var taSettings = {}; username = sUsername || credentials.username; password = sPassword || credentials.password; apikey = sApikey || credentials.apikey; if (apikey) { taSettings.iam_apikey = apikey; } else if (username && password) { taSettings.username = us...
javascript
{ "resource": "" }
q50322
train
function(msg, node) { var message = null, taSettings = null; taSettings = checkCreds(node.credentials); if (!taSettings) { message = 'Missing Tone Analyzer service credentials'; } else if (msg.payload) { message = toneutils.checkPayload(msg.payload); } else { message = 'Mi...
javascript
{ "resource": "" }
q50323
train
function(msg, config, node) { checkConfiguration(msg, node) .then(function(settings) { var options = toneutils.parseOptions(msg, config); options = toneutils.parseLanguage(msg, config, options); node.status({fill:'blue', shape:'dot', text:'requesting'}); return invokeService(co...
javascript
{ "resource": "" }
q50324
Node
train
function Node (config) { RED.nodes.createNode(this, config); var node = this; // Invoked when the node has received an input as part of a flow. this.on('input', function (msg) { processOnInput(msg, config, node); }); }
javascript
{ "resource": "" }
q50325
performAction
train
function performAction(params, feature, cbdone, cbcleanup) { var alchemy_vision = watson.alchemy_vision( { api_key: apikey } ); if (feature == 'imageFaces') { alchemy_vision.recognizeFaces(params, cbdone); } else if (feature == 'imageLink') { alchemy_vision.getImageLinks(params, cbdone); ...
javascript
{ "resource": "" }
q50326
train
function(err, keywords) { if (err || keywords.status === 'ERROR') { node.status({fill:'red', shape:'ring', text:'call to alchmeyapi vision service failed'}); console.log('Error:', msg, err); node.error(err, msg); } else { msg.result = keywords[FEATURE_RESP...
javascript
{ "resource": "" }
q50327
executeListExamples
train
function executeListExamples(node, conv, params, msg) { var p = new Promise(function resolver(resolve, reject){ conv.listExamples(params, function (err, response) { if (err) { reject(err); } else { msg['examples'] = response.examples ? ...
javascript
{ "resource": "" }
q50328
buildParams
train
function buildParams(msg, method, config, params) { var p = buildWorkspaceParams(msg, method, config, params) .then(function(){ return buildIntentParams(msg, method, config, params); }) .then(function(){ return buildExampleParams(msg, method, config, params); }) .then(f...
javascript
{ "resource": "" }
q50329
setWorkspaceParams
train
function setWorkspaceParams(method, params, workspaceObject) { var workspace_id = null; var stash = {}; if ('object' !== typeof workspaceObject) { return Promise.reject('json content expected as input on payload'); } switch(method) { case 'updateIntent': if (params['old_intent']) {...
javascript
{ "resource": "" }
q50330
processFileForWorkspace
train
function processFileForWorkspace(info, method) { var workspaceObject = null; switch (method) { case 'createWorkspace': case 'updateWorkspace': case 'createIntent': case 'updateIntent': case 'createEntity': case 'updateEntity': case 'updateEntityValue': case 'createDialogNode': ...
javascript
{ "resource": "" }
q50331
loadFile
train
function loadFile(node, method, params, msg) { var fileInfo = null; var p = openTheFile() .then(function(info){ fileInfo = info; return syncTheFile(fileInfo, msg); }) .then(function(){ return processFileForWorkspace(fileInfo, method); }) .then(function(works...
javascript
{ "resource": "" }
q50332
Node
train
function Node (config) { RED.nodes.createNode(this, config); var node = this; this.on('input', function (msg) { var method = config['cwm-custom-mode'], message = '', params = {}; username = sUsername || this.credentials.username; password = sPassword || this.credentials.p...
javascript
{ "resource": "" }
q50333
doTranslate
train
function doTranslate(language_translator, msg, model_id) { var p = new Promise(function resolver(resolve, reject){ // Please be careful when reading the below. The first parameter is // a structure, and the tabbing enforced by codeacy imho obfuscates // the code, rather than making it clea...
javascript
{ "resource": "" }
q50334
performCreate
train
function performCreate(node,dialog,msg) { var params = {} node.status({fill:'blue', shape:'dot', text:'requesting create of new dialog template'}); //if ('file' in msg.dialog_params && 'dialog_name' in msg.dialog_params) { if ('dialog_name' in msg.dialog_params) { // extension supported : only...
javascript
{ "resource": "" }
q50335
performDelete
train
function performDelete(node,dialog,msg, config) { var params = {}; var message = ''; node.status({fill:'blue', shape:'dot', text:'requesting delete of a dialog instance'}); if (!config.dialog || '' != config.dialog) { params.dialog_id = config.dialog; dialog.deleteDialog(params, func...
javascript
{ "resource": "" }
q50336
performList
train
function performList(node,dialog,msg) { node.status({fill:'blue', shape:'dot', text:'requesting list of dialogs'}); dialog.getDialogs({}, function(err, dialogs){ node.status({}); if (err) { node.status({fill:'red', shape:'ring', text:'call to dialog service failed'}); node.error(err, m...
javascript
{ "resource": "" }
q50337
performDeleteAll
train
function performDeleteAll(node,dialog,msg) { node.status({fill:'blue', shape:'dot', text:'requesting Delete All dialogs'}); dialog.getDialogs({}, function(err, dialogs){ node.status({}); if (err) { node.status({fill:'red', shape:'ring', text:'Delete All : call to getDialogs service fai...
javascript
{ "resource": "" }
q50338
addTask
train
function addTask(asyncTasks, msg, k, listParams, node) { asyncTasks.push(function(callback) { var buffer = msg.params[k]; temp.open({ suffix: '.' + fileType(buffer).ext }, function(err, info) { if (err) { node.status({ fill: 'red', shape: 'ring', ...
javascript
{ "resource": "" }
q50339
Node
train
function Node (config) { RED.nodes.createNode(this, config); var node = this; this.on('input', function (msg) { var method = config['tts-custom-mode'], message = '', params = {}; username = sUsername || this.credentials.username; password = sPassword || this.credentials.p...
javascript
{ "resource": "" }
q50340
assertCollectionSizeLeast
train
function assertCollectionSizeLeast(_super) { return function(n) { if (utils.flag(this, 'immutable.collection.size')) { assertIsIterable(this._obj); const { size } = this._obj; new Assertion(size).a('number'); this.assert( size >= n, 'expected #{this} to ha...
javascript
{ "resource": "" }
q50341
request
train
function request( host, method, path, params, query, headers, options, file, cb, debug ) { if (!options) options = {}; // Remove leading/trailing slash from the path/host so that we can join // the two together no matter which way the user chose to provide them. if (path[0] === FSLASH) { path = path.sl...
javascript
{ "resource": "" }
q50342
eachEndpoint
train
function eachEndpoint(iterator) { for (var namespace in endpoints) { var methods = endpoints[namespace]; for (var name in methods) { var method = methods[name]; iterator(namespace, name, method); } } return endpoints; }
javascript
{ "resource": "" }
q50343
paperspace
train
function paperspace(options) { if (options && !isAnyAuthOptionPresent(options)) { throw NO_CREDS; } var api = {}; eachEndpoint(function _eachEndpoint(namespace, name, method) { if (!api[namespace]) api[namespace] = {}; api[namespace][name] = wrapMethod(method, options); }); return api; }
javascript
{ "resource": "" }
q50344
client
train
function client(method, path, inputs, headers, file, cb) { var body = null; var query = {}; var options = {}; // It's assumed these will be provided, but just in case... if (!headers) headers = {}; headers.ps_client_name = clientName; headers.ps_client_version = clientVersion; // Send input params as the que...
javascript
{ "resource": "" }
q50345
isSafePositiveInteger
train
function isSafePositiveInteger(x) { // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // Is it a number? return Object.prototype.toString.call(x) === '[object Number]' && // Is it an ...
javascript
{ "resource": "" }
q50346
train
function(srcUrl, targetStream, opts, callback) { var listenerErrorIndicator = { errored: false }; if (typeof callback === 'undefined' && typeof opts === 'function') { callback = opts; opts = {}; } if (!validateArgs(srcUrl, opts, callback)) { // bad args, bail return; } /...
javascript
{ "resource": "" }
q50347
train
function(srcStream, targetUrl, opts, callback) { var listenerErrorIndicator = { errored: false }; if (typeof callback === 'undefined' && typeof opts === 'function') { callback = opts; opts = {}; } validateArgs(targetUrl, opts, callback); opts = Object.assign({}, defaults(), opts); c...
javascript
{ "resource": "" }
q50348
downloadRemainingBatches
train
function downloadRemainingBatches(log, db, ee, startTime, batchesPerDownloadSession, parallelism) { var total = 0; // running total of documents downloaded so far var noRemainingBatches = false; // Generate a set of batches (up to batchesPerDownloadSession) to download from the // log file and download them. S...
javascript
{ "resource": "" }
q50349
readBatchSetIdsFromLogFile
train
function readBatchSetIdsFromLogFile(log, batchesPerDownloadSession, callback) { logfilesummary(log, function processSummary(err, summary) { if (!summary.changesComplete) { callback(new error.BackupError('IncompleteChangesInLogFile', 'WARNING: Changes did not finish spooling')); return; } ...
javascript
{ "resource": "" }
q50350
processBatchSet
train
function processBatchSet(db, parallelism, log, batches, ee, start, grandtotal, callback) { var hasErrored = false; var total = grandtotal; // queue to process the fetch requests in an orderly fashion using _bulk_get var q = async.queue(function(payload, done) { var output = []; var thisBatch = payload....
javascript
{ "resource": "" }
q50351
getPropertyNames
train
function getPropertyNames(obj, count) { // decide which batch numbers to deal with var batchestofetch = []; var j = 0; for (var i in obj) { batchestofetch.push(parseInt(i)); j++; if (j >= count) break; } return batchestofetch; }
javascript
{ "resource": "" }
q50352
bucketAccessible
train
function bucketAccessible(s3, bucketName) { return new Promise(function(resolve, reject) { var params = { Bucket: bucketName }; s3.headBucket(params, function(err, data) { if (err) { reject(new VError(err, 'S3 bucket not accessible')); } else { resolve(); } }); ...
javascript
{ "resource": "" }
q50353
backupToS3
train
function backupToS3(sourceUrl, s3Client, s3Bucket, s3Key, shallow) { return new Promise((resolve, reject) => { debug(`Setting up S3 upload to ${s3Bucket}/${s3Key}`); // A pass through stream that has couchbackup's output // written to it and it then read by the S3 upload client. // It has a 64MB high...
javascript
{ "resource": "" }
q50354
train
function(obj) { if (obj.command === 't') { state[obj.batch] = true; } else if (obj.command === 'd') { delete state[obj.batch]; } else if (obj.command === 'changes_complete') { changesComplete = true; } }
javascript
{ "resource": "" }
q50355
createBackupFile
train
function createBackupFile(sourceUrl, backupTmpFilePath) { return new Promise((resolve, reject) => { couchbackup.backup( sourceUrl, fs.createWriteStream(backupTmpFilePath), (err) => { if (err) { return reject(new VError(err, 'CouchBackup process failed')); } debu...
javascript
{ "resource": "" }
q50356
uploadNewBackup
train
function uploadNewBackup(s3, backupTmpFilePath, bucket, key) { return new Promise((resolve, reject) => { debug(`Uploading from ${backupTmpFilePath} to ${bucket}/${key}`); function uploadFromStream(s3, bucket, key) { const pass = new stream.PassThrough(); const params = { Bucket: bucket, ...
javascript
{ "resource": "" }
q50357
apiDefaults
train
function apiDefaults() { return { parallelism: 5, bufferSize: 500, requestTimeout: 120000, log: tmp.fileSync().name, resume: false, mode: 'full' }; }
javascript
{ "resource": "" }
q50358
processBuffer
train
function processBuffer(flush, callback) { function taskCallback(err, payload) { if (err && !didError) { debug(`Queue task failed with error ${err.name}`); didError = true; q.kill(); writer.emit('error', err); } } if (flush || buffer.length >= bufferSize) { ...
javascript
{ "resource": "" }
q50359
train
function() { // if we encountered an error, stop this until loop if (didError) { return true; } if (flush) { return q.idle() && q.length() === 0; } else { return q.length() <= parallelism * 2; } }
javascript
{ "resource": "" }
q50360
train
function(lastOne) { if (buffer.length >= bufferSize || (lastOne && buffer.length > 0)) { debug('writing', buffer.length, 'changes to the backup file'); var b = { docs: buffer.splice(0, bufferSize), batch: batch }; logStream.write(':t batch' + batch + ' ' + JSON.stringify(b.docs) + '\n'); ee....
javascript
{ "resource": "" }
q50361
train
function(c) { if (c) { if (c.error) { ee.emit('error', new error.BackupError('InvalidChange', `Received invalid change: ${c}`)); } else if (c.changes) { var obj = { id: c.id }; buffer.push(obj); processBuffer(false); } else if (c.last_seq) { lastSeq = c.last...
javascript
{ "resource": "" }
q50362
train
function(n) { if (n == Infinity) { return 'Infinity'; } else if (n > 1e9) { n = Math.round(n/1e8); return n/10 + 'B'; } else if (n > 1e6) { n = Math.round(n/1e5); return n/10 + 'M'; } else if (n > 1e3) { n = Math.round(n/1e2); return n/10 +...
javascript
{ "resource": "" }
q50363
train
function(count) { var me = this; // Make sure calibration tests have run if (!me.isCalibration && Test.calibrate(function() {me.run(count);})) return; this.error = null; try { var start, f = this.f, now, i = count; // Start the timer start = new Date(); ...
javascript
{ "resource": "" }
q50364
train
function(/**Boolean*/ normalize) { var p = this.period; // Adjust period based on the calibration test time if (normalize && !this.isCalibration) { var cal = Test.CALIBRATIONS[this.loopArg ? 0 : 1]; // If the period is within 20% of the calibration time, then zero the // it o...
javascript
{ "resource": "" }
q50365
train
function() { var el = jsl.$('jslitmus_container'); if (!el) document.body.appendChild(el = document.createElement('div')); el.innerHTML = MARKUP; // Render the UI for all our tests for (var i=0; i < JSLitmus._tests.length; i++) JSLitmus.renderTest(JSLitmus._tests[i]); }
javascript
{ "resource": "" }
q50366
train
function(name, f) { // Create the Test object var test = new Test(name, f); JSLitmus._tests.push(test); // Re-render if the test state changes test.onChange = JSLitmus.renderTest; // Run the next test if this one finished test.onStop = function(test) { if (JSLitmus.on...
javascript
{ "resource": "" }
q50367
train
function(e) { e = e || window.event; var reverse = e && e.shiftKey, len = JSLitmus._tests.length; for (var i = 0; i < len; i++) { JSLitmus._queueTest(JSLitmus._tests[!reverse ? i : (len - i - 1)]); } }
javascript
{ "resource": "" }
q50368
train
function() { while (JSLitmus._queue.length) { var test = JSLitmus._queue.shift(); JSLitmus.renderTest(test); } }
javascript
{ "resource": "" }
q50369
train
function() { if (!JSLitmus.currentTest) { var test = JSLitmus._queue.shift(); if (test) { jsl.$('stop_button').disabled = false; JSLitmus.currentTest = test; test.run(); JSLitmus.renderTest(test); if (JSLitmus.onTestStart) JSLitmus.onTestStart(test...
javascript
{ "resource": "" }
q50370
train
function(test) { if (jsl.indexOf(JSLitmus._queue, test) >= 0) return; JSLitmus._queue.push(test); JSLitmus.renderTest(test); JSLitmus._nextTest(); }
javascript
{ "resource": "" }
q50371
train
function() { var n = JSLitmus._tests.length, markers = [], data = []; var d, min = 0, max = -1e10; var normalize = jsl.$('test_normalize').checked; // Gather test data for (var i=0; i < JSLitmus._tests.length; i++) { var test = JSLitmus._tests[i]; if (test.count) { ...
javascript
{ "resource": "" }
q50372
mapBreakpointToMedia
train
function mapBreakpointToMedia(stylesheet) { if (angular.isDefined(options.breakpoints)) { if (stylesheet.breakpoint in options.breakpoints) { stylesheet.media = options.breakpoints[stylesheet.breakpoint]; } delete stylesheet.breakpoints; } }
javascript
{ "resource": "" }
q50373
addViaMediaQuery
train
function addViaMediaQuery(stylesheet) { if (!stylesheet) { if(DEBUG) $log.error('No stylesheet provided'); return; } // Media query object mediaQuery[stylesheet.href] = $window.matchMedia(stylesheet.media); // Media Query Listener function mediaQue...
javascript
{ "resource": "" }
q50374
removeViaMediaQuery
train
function removeViaMediaQuery(stylesheet) { if (!stylesheet) { if(DEBUG) $log.error('No stylesheet provided'); return; } // Remove media query listener if ($rootScope && angular.isDefined(mediaQuery) && mediaQuery[stylesheet.href] && angular.isD...
javascript
{ "resource": "" }
q50375
requireReporter
train
function requireReporter(name) { const prefix = capitalize(camelcase(name)); const locations = [`./reporters/${prefix}Reporter`, name, path.resolve(name)]; let result = null; for (const location of locations) { try { // eslint-disable-next-line import/no-dynamic-require, global-require result =...
javascript
{ "resource": "" }
q50376
sanitize
train
function sanitize(config) { const configs = [].concat(config).map((conf) => { const result = merge({}, conf); delete result.progress; delete result.reporter; delete result.watchStdin; // TODO: remove the need for this for (const property of ['entry', 'output']) { const target = result[p...
javascript
{ "resource": "" }
q50377
minusJS
train
function minusJS(name) { var idx = name.indexOf(".js"); return idx === -1 ? name : name.substr(0, idx); }
javascript
{ "resource": "" }
q50378
getLoader
train
function getLoader(data) { if(typeof Loader !== "undefined" && (data instanceof global.Loader)) { return data; } else if(typeof LoaderPolyfill !== "undefined" && (data instanceof global.LoaderPolyfill)) { return data; } else { return data.steal.System; } }
javascript
{ "resource": "" }
q50379
adjustBundlesPath
train
function adjustBundlesPath(data, options) { var path = require("path"); var configuration = clone(data.configuration); var bundlesPath = configuration.bundlesPath; Object.defineProperty(configuration, "bundlesPath", { configurable: true, get: function() { return path.join(bundlesPath, options.target); } ...
javascript
{ "resource": "" }
q50380
mergeIntoMasterAndAddBundle
train
function mergeIntoMasterAndAddBundle(opts) { var mains = opts.mains; var loader = opts.loader; var newGraph = opts.newGraph; var bundleName = opts.bundleName; var masterGraph = opts.masterGraph; for(var name in newGraph) { var oldNode = masterGraph[name]; var newNode = newGraph[name]; if(!oldNode || hasNe...
javascript
{ "resource": "" }
q50381
createModuleConfig
train
function createModuleConfig(loader) { var tmp = require("tmp"); var config = {}; var virtualModules = loader.virtualModules || {}; for(var moduleName in virtualModules) { var filename = tmp.fileSync().name; var source = virtualModules[moduleName]; fs.writeFileSync(filename, source, "utf8"); var paths = con...
javascript
{ "resource": "" }
q50382
copyIfSet
train
function copyIfSet(src, dest, prop) { if (src[prop]) { dest[prop] = src[prop]; } }
javascript
{ "resource": "" }
q50383
addPluginName
train
function addPluginName(data) { var loader = data.loader; var bundles = data.bundles; var promises = bundles.map(function(bundle) { if (!isJavaScriptBundle(bundle)) { return loader.normalize(bundle.name).then(function(name) { bundle.pluginName = name.substring(name.indexOf("!") + 1); }); } }); retur...
javascript
{ "resource": "" }
q50384
getWeightOf
train
function getWeightOf(bundle) { var isCss = bundle.buildType === "css"; var isMainBundle = bundle.bundles.length === 1; if (isCss) { return 1; } else if (isMainBundle) { return 2; } else { return 3; } }
javascript
{ "resource": "" }
q50385
getSharedBundlesOf
train
function getSharedBundlesOf(name, baseUrl, bundles, mains) { var shared = {}; var normalize = require("normalize-path"); // this will ensure that we only add the main bundle if there is a single // main; not a multi-main project. var singleMain = mains.length === 1 && mains[0]; bundles.forEach(function(bundle) {...
javascript
{ "resource": "" }
q50386
getBundlesPaths
train
function getBundlesPaths(configuration){ // If a bundlesPath is not provided, the paths are not needed because they are // already set up in steal.js if(!configuration.loader.bundlesPath) { return ""; } var bundlesPath = configuration.bundlesPathURL; // Get the dist directory and set the paths output var path...
javascript
{ "resource": "" }
q50387
regenerate
train
function regenerate(moduleName, done){ var cfg = clone(config, true); // if the moduleName is not in the graph, make it the main. if(moduleName && !cachedData.graph[moduleName]) { cfg.main = moduleName; } makeBundleGraph(cfg, options).then(function(data){ var graph = data.graph; var oldGraph = cache...
javascript
{ "resource": "" }
q50388
diff
train
function diff(node) { var oldBundle = (cachedData.loader.bundle || []).slice(); return getDependencies(node.load).then(function(result){ var newBundle = (cachedData.loader.bundle || []).slice(); // If the deps are the same we can return the existing graph. if(same(node.deps, result.deps) && same(ol...
javascript
{ "resource": "" }
q50389
inlineNodeEnvironmentVariables
train
function inlineNodeEnvironmentVariables(data) { var dependencyGraph = data.graph; var configuration = data.configuration; var options = configuration.options; if (options.envify) { winston.info("Inlining Node-style environment variables..."); envifyGraph(dependencyGraph, options); envifyGraph(data.configGrap...
javascript
{ "resource": "" }
q50390
getPresetName
train
function getPresetName(preset) { if (includesPresetName(preset)) { return _.isString(preset) ? preset : _.head(preset); } else { return null; } }
javascript
{ "resource": "" }
q50391
includesPresetName
train
function includesPresetName(preset) { return _.isString(preset) || _.isArray(preset) && _.isString(_.head(preset)); }
javascript
{ "resource": "" }
q50392
isBuiltinPreset
train
function isBuiltinPreset(name) { var isNpmPresetName = /^(?:babel-preset-)/; var availablePresets = babel.availablePresets || {}; var shorthand = isNpmPresetName.test(name) ? name.replace("babel-preset-", "") : name; return !!availablePresets[shorthand]; }
javascript
{ "resource": "" }
q50393
loadNodeBuilder
train
function loadNodeBuilder(data) { return new Promise(function(resolve, reject) { var graph = data.graph; var loader = data.loader; var promises = keys(graph).map(function(nodeName) { var node = graph[nodeName]; // pluginBuilder | extensionBuilder is a module identifier that // should be loaded to repla...
javascript
{ "resource": "" }
q50394
normalize
train
function normalize(loader, mods) { var modNames = (mods && !Array.isArray(mods)) ? [mods] : mods; return (modNames || []).map(function(moduleName) { return !_.isString(moduleName) ? Promise.resolve(moduleName) : loader.normalize(moduleName); }); }
javascript
{ "resource": "" }
q50395
isExcludedFromBuild
train
function isExcludedFromBuild(node) { if (node.load.excludeFromBuild) { return true; } if ( node.load.metadata && node.load.metadata.hasOwnProperty("bundle") && node.load.metadata.bundle === false ) { return true; } if ( node.isPlugin && !node.value.includeInBuild && !node.load.metadata.includeIn...
javascript
{ "resource": "" }
q50396
ignoredMetas
train
function ignoredMetas(cfgs, metas){ cfgs = cfgs || {}; Object.keys(metas).forEach(function(name){ var cfg = metas[name]; if(cfg && cfg.bundle === false) { cfgs[name] = cfg; } }); return { meta: cfgs }; }
javascript
{ "resource": "" }
q50397
processPlugins
train
function processPlugins(baseURL, plugins) { var normalized = []; // path.resolve does not work correctly if baseURL starts with "file:" baseURL = baseURL.replace("file:", ""); plugins = plugins || []; plugins.forEach(function(plugin) { var name = getPluginName(plugin); if (isPluginFunction(plugin) || isBuil...
javascript
{ "resource": "" }
q50398
isPluginFunction
train
function isPluginFunction(plugin) { return _.isFunction(plugin) || _.isFunction(_.head(plugin)); }
javascript
{ "resource": "" }
q50399
getPluginName
train
function getPluginName(plugin) { if (isPluginFunction(plugin)) return null; return _.isString(plugin) ? plugin : _.head(plugin); }
javascript
{ "resource": "" }