_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q29500
defaults
train
function defaults(name, selfie, opts) { return millisecond( name in opts ? opts[name] : (name in selfie ? selfie[name] : Recovery[name]) ); }
javascript
{ "resource": "" }
q29501
Recovery
train
function Recovery(options) { var recovery = this; if (!(recovery instanceof Recovery)) return new Recovery(options); options = options || {}; recovery.attempt = null; // Stores the current reconnect attempt. recovery._fn = null; // Stores the callback. recovery[...
javascript
{ "resource": "" }
q29502
URL
train
function URL(address, location, parser) { if (!(this instanceof URL)) { return new URL(address, location, parser); } var relative = relativere.test(address) , parse, instruction, index, key , type = typeof location , url = this , i = 0; // // The f...
javascript
{ "resource": "" }
q29503
Primus
train
function Primus(url, options) { if (!(this instanceof Primus)) return new Primus(url, options); if ('function' !== typeof this.client) { var message = 'The client library has not been compiled correctly, ' + 'see https://github.com/primus/primus#client-library for more details'; re...
javascript
{ "resource": "" }
q29504
pong
train
function pong() { primus.timers.clear('pong'); // // The network events already captured the offline event. // if (!primus.online) return; primus.online = false; primus.emit('offline'); primus.emit('incoming::end'); }
javascript
{ "resource": "" }
q29505
ping
train
function ping() { var value = +new Date(); primus.timers.clear('ping'); primus._write('primus::ping::'+ value); primus.emit('outgoing::ping', value); primus.timers.setTimeout('pong', pong, primus.options.pong); }
javascript
{ "resource": "" }
q29506
train
function (name, separator) { var fullName, sep = separator || "/"; if (name.indexOf(sep) >= 0) { fullName = name; //already got fully-qualified (theoretically) } else if (name.indexOf("Service") >= 0) { fullName = "Schema" + sep +...
javascript
{ "resource": "" }
q29507
train
function (plugins, func) { var idx, plugin = null; // iterate to process in reverse order without side-effects. for (idx = 1; idx <= plugins.length; idx += 1) { plugin = plugins[plugins.length - idx]; func(plugin); ...
javascript
{ "resource": "" }
q29508
bundleThrough
train
function bundleThrough(options) { options = options || {} var browserifyShouldCreateSourcemaps = options.debug || options.sourcemaps var bundleTransform = through(function (file, enc, callback) { var bundler = browserify(file.path, assign({}, options, {debug: browserifyShouldCreateSourcemaps})) if (o...
javascript
{ "resource": "" }
q29509
createNewFileByContents
train
function createNewFileByContents(file, newContents) { var newFile = file.clone() newFile.contents = newContents return newFile }
javascript
{ "resource": "" }
q29510
fetchStyle
train
function fetchStyle(id) { for (var i = 0; i < styles.length; i++) if (styles[i].id === id) return styles[i]; }
javascript
{ "resource": "" }
q29511
sendFile
train
function sendFile(imagePath) { response.set(headers); response.download(imagePath, request.query.filename); }
javascript
{ "resource": "" }
q29512
Pipeline
train
function Pipeline(actionFactory, pipe) { assert.func(actionFactory, 'actionFactory'); assert.optionalArrayOfFunc(pipe, 'pipe'); let middleware = (pipe || []).slice(); let logger; let module = { /** Clone the middleware pipeline */ clone: () => { return Pipeline(actionFactory, middleware); ...
javascript
{ "resource": "" }
q29513
getMinifiedJSFiles
train
function getMinifiedJSFiles(files) { var minifiedFiles = []; files.forEach(function(path) { minifiedFiles.push('<%- project.uglify %>/' + path.replace('.js', '.min.js').replace('/<%= originalPluginName %>/', '')); }); return minifiedFiles; }
javascript
{ "resource": "" }
q29514
_createStreamPointer
train
function _createStreamPointer(self, stream, serializer) { let id = uuid(); let readable = typeof stream.read === 'function'; let type = readable ? 'readable' : 'writable'; let pointer = `boscar:${type}:${id}`; self.streams.set(id, stream); if (readable) { _bindReadable(pointer, stream, serializer); ...
javascript
{ "resource": "" }
q29515
_bindReadable
train
function _bindReadable(pointer, stream, serializer) { stream.on('data', (data) => { serializer.write(jsonrpc.notification(pointer, [data])); }); stream.on('end', () => { serializer.write(jsonrpc.notification(pointer, [null])); }); stream.on('error', () => { serializer.write(jsonrpc.notification(po...
javascript
{ "resource": "" }
q29516
round
train
function round (value, rules) { let unit = 1.0, roundOp = Math.round; if (rules) { roundOp = Math[rules.type === 'top' ? 'floor' : 'ceil']; if ('object' === typeof rules.grow) { unit = rules.grow[rules.type] || 1.0; } } return roundOp(value / unit) * unit; }
javascript
{ "resource": "" }
q29517
Monitor
train
function Monitor (opt) { opt = opt || {}; this.prefix = opt.prefix || process.env.MONITOR_PREFIX || null; this.host = opt.host || process.env.DATADOG_HOST; this.port = opt.port || process.env.DATADOG_PORT; this.interval = opt.interval || process.env.MONITOR_INTERVAL; if (this.host && this.port) { this.c...
javascript
{ "resource": "" }
q29518
eslint
train
function eslint(options) { if (typeof options === 'boolean') { options = { fail: options } } options = { ...new ESLintOptions(), ...options } return new Promise((resolve, reject) => { const args = generateArguments(options) const child = spawn('node', args, { stdio: options.stdio, cwd: path.resolve...
javascript
{ "resource": "" }
q29519
serializeArray
train
function serializeArray( array, indent = INDENT, pad = 0, space ) { const elements = array .map( element => serialize( element, indent, pad + indent, space ) ); return '[' + serializeList( elements, indent, pad, space ) + ']'; }
javascript
{ "resource": "" }
q29520
serializeObject
train
function serializeObject( object, indent = INDENT, pad = 0, space ) { const properties = Object.keys( object ) .map( key => serializeKey( key ) + ': ' + serialize( object[ key ], indent, pad + indent, space ) ); return '{' + serializeList( properties, indent, pad, space ) + '}'; }
javascript
{ "resource": "" }
q29521
serializeList
train
function serializeList( elements, indent = INDENT, pad = 0, space ) { if( elements.length === 0 ) { return ''; } const length = elements.reduce( ( sum, e ) => sum + e.length + 2, pad ); const multiline = elements.some( element => /\n/.test( element ) ); const compact = length < LIST_LENGTH && !mul...
javascript
{ "resource": "" }
q29522
serializeKey
train
function serializeKey( name ) { const identifier = /^[A-Za-z$_][A-Za-z0-9$_]*$/.test( name ); const keyword = [ 'if', 'else', 'switch', 'case', 'default', 'try', 'catch', 'finally', 'function', 'return', 'var', 'let', 'const' ].indexOf( name ) >= 0; return ( identifier && !key...
javascript
{ "resource": "" }
q29523
serializeValue
train
function serializeValue( value, indent, pad, space ) { return leftpad( JSON.stringify( value, null, indent ), pad, space ); }
javascript
{ "resource": "" }
q29524
leftpad
train
function leftpad( string, pad, space ) { return string.split( '\n' ).join( `\n${spaces( pad, space )}` ); }
javascript
{ "resource": "" }
q29525
Router
train
function Router(req, res, next) { const server = this; const state = { method: req.method.toUpperCase(), params: {}, routes: routes.concat(), routeUnhandled: true, server: server, }; run(state, req, res, err => { req...
javascript
{ "resource": "" }
q29526
train
function(_name){ var _cookie = document.cookie, _search = '\\b'+_name+'=', _index1 = _cookie.search(_search); if (_index1<0) return ''; _index1 += _search.length-2; var _index2 = _cookie.indexOf(';',_index1); if (_index2<0) _ind...
javascript
{ "resource": "" }
q29527
add
train
function add(item) { var newEnd = (end + 1) % BUF_SIZE; if(end >= 0 && newEnd === begin) { throw Error('Buffer overflow: Buffer exceeded max size: ' + BUF_SIZE); } buffer[newEnd] = item; end = newEnd; }
javascript
{ "resource": "" }
q29528
next
train
function next() { var next; if (end < 0) { // Buffer is empty return null; } next = buffer[begin]; delete buffer[begin]; if (begin === end) { // Last element initBuffer(); } else { begin = (begin + 1) % BUF_SIZE; } return next; }
javascript
{ "resource": "" }
q29529
dispatchWorkItems
train
function dispatchWorkItems() { var i, workItem; if (!buffer.isEmpty()) { i = workerJobCount.indexOf(0); if(i >= 0) { //Free worker found workItem = buffer.next(); // Send task to worker workerExec(i, workItem); //Check for more free workers dispatchWorkItems(); } } }
javascript
{ "resource": "" }
q29530
handleArrayResult
train
function handleArrayResult(m, workerIdx) { var job = jobs[m.context.jobID], partition = m.context.partition, subResult = m.result, result = [], i; job.result[partition] = subResult; // Increase callback count. job.cbCount++; // When all workers are finished return result if(job.cbCount === workers.le...
javascript
{ "resource": "" }
q29531
handleExecResult
train
function handleExecResult(m, workerIdx) { var job = jobs[m.context.jobID]; job.cb(m.err, m.result); // Worker is finished. workerJobCount[workerIdx]--; dispatchWorkItems(); }
javascript
{ "resource": "" }
q29532
handleMessage
train
function handleMessage(m, workerIdx) { var job = jobs[m.context.jobID]; switch(job.type) { case 'func': handleArrayResult(m, workerIdx); break; case 'exec': handleExecResult(m, workerIdx); break; default: throw Error('Invalid job type: ' + job.type); } }
javascript
{ "resource": "" }
q29533
executeParallel
train
function executeParallel(op, arr, iter, cb) { var chunkSize = Math.floor(arr.length / numCPUs), worker, iterStr, task, offset, i; // Lazy initialization init(); // Check params if (!cb) { throw Error('Expected callback'); } if (arr == null) { cb(null, []); return; } if (!Array.isArray(a...
javascript
{ "resource": "" }
q29534
merge
train
function merge(arrays, comp) { var mid, a1, i1, a2, i2, result; if (arrays.length === 1) { return arrays[0]; } else if (arrays.length === 2) { // merge two arrays a1 = arrays[0]; a2 = arrays[1]; i1 = i2 = 0; result = []; while(i1 < a1.length && i2 < a2.length) { if (comp(a2[i2],...
javascript
{ "resource": "" }
q29535
defaultComp
train
function defaultComp(a,b) { var as = '' + a, bs = '' + b; if (as < bs) { return -1; } else if (as > bs) { return 1; } else { return 0; } }
javascript
{ "resource": "" }
q29536
constructSortingFunction
train
function constructSortingFunction(comp) { var funcStr = 'function(arr) { return arr.sort(%comp%); };', func; funcStr = funcStr.replace('%comp%', comp.toString()); // Eval is evil but necessary in this case eval('func = '+ funcStr); return func; }
javascript
{ "resource": "" }
q29537
mergeResults
train
function mergeResults(newResults) { if (newResults.definitions) results.definitions = utilApi.joinArray(results.definitions, newResults.definitions); if (newResults.dependencies) results.dependencies = utilApi.joinArray(results.dependencies, newResults.dependencies); if (newResults.module) ...
javascript
{ "resource": "" }
q29538
findScript
train
function findScript(scripts, property, value) { for (var i = 0; i < scripts.length; i++) { if ((Object.prototype.toString.call(scripts[i][property]) === '[object Array]' && scripts[i][property].indexOf(value) > -1) || (scripts[i][property] === value) ) { return scripts[i]; } } r...
javascript
{ "resource": "" }
q29539
findLongestDependencyChains
train
function findLongestDependencyChains(scripts, script, modulesToIgnore) { var chains = []; if (!script) script = scripts[0]; // Avoid circular dependencies if (modulesToIgnore && script.module && modulesToIgnore.indexOf(script.module) !== -1) return chains; // Get script dependencies if (script.dependenci...
javascript
{ "resource": "" }
q29540
buildTree
train
function buildTree(scripts) { var chains = []; var tree = { children: [] }; var currentTreeNode = tree; // Get the longest dependency chain for each script with the highest dependency // as the first element of the chain scripts.forEach(function(script) { chains = chains.concat(findLongestDepende...
javascript
{ "resource": "" }
q29541
train
function(list, name) { if (Object.prototype.toString.call(list) === '[object Array]' && Object.prototype.toString.call(name) === '[object String]') { for (var i = 0; i < list.length; i++) { if (list[i] === name) { return true; } } } return false; }
javascript
{ "resource": "" }
q29542
isInstanceOf
train
function isInstanceOf(cls) { var i, l, bases = this.constructor._meta.bases; for (i = 0, l = bases.length; i < l; i += 1) { if (bases[i] === cls) { return true; } } return this instanceof cls; }
javascript
{ "resource": "" }
q29543
safeMixin
train
function safeMixin(target, source) { var name, t; // add props adding metadata for incoming functions skipping a constructor for (name in source) { t = source[name]; if ((t !== op[name] || !(name in op)) && name !== cname) { if (opts.call(t) === "[object F...
javascript
{ "resource": "" }
q29544
toLink
train
function toLink( data ) { if ( data && typeof data === 'object' ) { if ( data.constructor.name === 'ObjectID' || data.constructor.name === 'ObjectId' ) { return { _id: data } ; } data._id = toObjectId( data._id ) ; } else if ( typeof data === 'string' ) { try { data = { _id: mongodb.ObjectID( data ) }...
javascript
{ "resource": "" }
q29545
quote
train
function quote(s) { if (typeof(s) === 'string') { return "'" + s.replace(/'/g, "''") + "'"; } else if (s instanceof Array) { return _.map(s, quote).join(', '); } return s; }
javascript
{ "resource": "" }
q29546
ToJSON
train
function ToJSON(jsonName) { if (jsonName === 'result') jsonName = 'default'; let args = Array.prototype.slice.call(arguments); if (typeof jsonName === 'undefined') { jsonName = 'default'; } else if (typeof jsonName === 'string') { args.splice(0, 1); //remove the name...
javascript
{ "resource": "" }
q29547
switchPersonStr
train
function switchPersonStr( str ) { var switchPersonStrVerb = {} ; return str.replace( /\s+|(i|you|he|she|it|we|they)\s+(\S+)(?=\s)/gi , ( match , pronoun , verb ) => { if ( ! pronoun ) { return match ; } var person = null , plural = null , switchedPronoun = null ; pronoun = pronoun.toLowerCase() ; verb = ve...
javascript
{ "resource": "" }
q29548
on
train
function on(eventNamesOrPatterns, handler) { if (!eventNamesOrPatterns) { throw new Error('Must pass at least one event name or matching RegEx'); } assert.func(handler, 'handler'); if (!Array.isArray(eventNamesOrPatterns)) { eventNamesOrPatterns = [eventNamesOrPatterns]; } for (let i...
javascript
{ "resource": "" }
q29549
once
train
function once(eventNamesOrPatterns, handler) { if (!eventNamesOrPatterns) { throw new Error('Must pass at least one event name or matching RegEx'); } assert.func(handler, 'handler'); if (!Array.isArray(eventNamesOrPatterns)) { eventNamesOrPatterns = [eventNamesOrPatterns]; } let defe...
javascript
{ "resource": "" }
q29550
setupHealth
train
function setupHealth(expressRouter, baseURI, dependenciesDef, logger) { if (typeof (dependenciesDef) === 'string') { if (!dependenciesDef.startsWith('/')) { dependenciesDef = `${process.cwd()}/${dependenciesDef}`; } if (!fs.existsSync(dependenciesDef)) { throw new Error(`Health dependencies fi...
javascript
{ "resource": "" }
q29551
train
function(_id){ var _input = _e._$get(_id); _cache[_id] = 2; if (!!_input.value) return; _e._$setStyle( _e._$wrapInline(_input,_ropt), 'display','none' ); }
javascript
{ "resource": "" }
q29552
train
function(_input,_clazz){ var _id = _e._$id(_input), _label = _e._$wrapInline(_input,{ tag:'label', clazz:_clazz, nid:_ropt.nid }); _label.htmlFor = _id; var _text = _e._$attr(_input,'placeholder')||''; ...
javascript
{ "resource": "" }
q29553
inc
train
function inc(importance) { var git = require('gulp-git'), bump = require('gulp-bump'), filter = require('gulp-filter'), tag_version = require('gulp-tag-version'); // get all the files to bump version in return gulp.src(['./package.json', './bower.json']) // bump the version ...
javascript
{ "resource": "" }
q29554
Binder
train
function Binder(topology, logger) { assert.object(topology, 'connectionInfo'); assert.object(logger, 'logger'); /** * Ensures the topology is created for a route * @private * @param {Object} route - the route * @returns {Promise} a promise that is fulfilled with the resulting topology names after the...
javascript
{ "resource": "" }
q29555
train
function() { $._.$.log && $._.$.log.debug('Cron ' + spec.name + ' waking up'); var cb0 = function(err) { if (err) { $._.$.log && $._.$.log.debug('pulser_cron ' + myUtils.errToPrettyStr(err)); } e...
javascript
{ "resource": "" }
q29556
resolveExtensions
train
function resolveExtensions(schema) { var xprops, props; xprops = getExtendedProperties(schema, []); //unwind the property stack so that the earliest gets inheritance link schema.properties = schema.properties || {}; function copy...
javascript
{ "resource": "" }
q29557
resolveExtendedParameters
train
function resolveExtendedParameters(obj) { // assume all references are resolved, just copy parameters down the // inheritence chain. If I am derived check base first. if (obj["extends"]) { resolveExtendedParameters(obj["extends"]); ...
javascript
{ "resource": "" }
q29558
resolveProperties
train
function resolveProperties(schema) { logger.debug("Resolving sub-properties for " + schema.id); // resolve inherited global parameters resolveExtendedParameters(schema); Object.keys(schema.services || {}).forEach(function (key) { ...
javascript
{ "resource": "" }
q29559
train
function () { var names = []; Object.keys(this.smd.services || {}).forEach(function (serviceName) { names.push(serviceName); }); return names; }
javascript
{ "resource": "" }
q29560
train
function () { var services = [], smdServices = this.smd.services; Object.keys(smdServices || []).forEach(function (serviceName) { services.push(smdServices[serviceName]); }); return services; }
javascript
{ "resource": "" }
q29561
train
function (methodName) { var names = [], params = this.getParameters(methodName); params.forEach(function (param) { names.push(param.name); }); return names; }
javascript
{ "resource": "" }
q29562
train
function (methodName) { var parameters = this.smd.parameters || []; parameters = parameters.concat(this.smd.services[methodName].parameters || []); return parameters; }
javascript
{ "resource": "" }
q29563
train
function (methodName, argName) { var required = this.findParameter(methodName, argName).required; //default is false, so if "required" is undefined, return false anyway if (required) { return true; } return false; }
javascript
{ "resource": "" }
q29564
train
function (methodName, args) { var service = this.smd.services[methodName], basePath = this.getRootPath(), url, parameters = this.enumerateParameters(service); //if no service target, it sits at the root url = basePath + (servi...
javascript
{ "resource": "" }
q29565
train
function (methodName) { var params = this.getParameters(methodName), ret; params.forEach(function (param) { if (param && (param.envelope === 'JSON' || param.envelope === 'ENTITY')) { ret = param; }...
javascript
{ "resource": "" }
q29566
train
function (methodName) { var smd = this.smd, method = smd.services[methodName], payloadName = (method && method.payload) || smd.payload; return payloadName; }
javascript
{ "resource": "" }
q29567
train
function (methodName) { var response = this.getResponseSchema(methodName), payloadName = this.getResponsePayloadName(methodName), isList = false; if (response.type !== "null") { if ((payloadName && response.properties[payloadName] && respons...
javascript
{ "resource": "" }
q29568
defaultAssets
train
function defaultAssets( { name, category, descriptor } ) { switch( category ) { case 'themes': return { assetUrls: [ descriptor.styleSource || 'css/theme.css' ] }; case 'layouts': case 'widgets': case 'controls': return { assetsForTheme: [ de...
javascript
{ "resource": "" }
q29569
buildAssets
train
function buildAssets( artifact, themes = [] ) { const { descriptor } = artifact; const { assets, assetUrls, assetsForTheme, assetUrlsForTheme } = extendAssets( descriptor, defaultAssets( artifact ) ); return Promise.all( [ assetResolver ....
javascript
{ "resource": "" }
q29570
train
function() { var cb = function(err, meta) { if (err) { var error = new Error('BUG: __external_ca_touch__ ' + 'should not return app error'); error['err'] = err; that.close(error); } ...
javascript
{ "resource": "" }
q29571
replaceSpecialChars
train
function replaceSpecialChars(item) { if (!j79.isString(item)) { return item; } var result = item; var specialChars = Object.keys(SPECIAL_CHARS_MAP); for (var index in specialChars) { result = replaceSpecialChar(result, specialChars[index]); } return result; }
javascript
{ "resource": "" }
q29572
validateClassConfig
train
function validateClassConfig(obj) { /** If configuration is not plain object, throw error */ if ( typeof obj != `object` || obj.constructor.name != `Object` ) throw new Error(`ezobjects.validateClassConfig(): Invalid table configuration argument, must be plain object.`); /** If configuration has missing ...
javascript
{ "resource": "" }
q29573
train
function(req, res) { return function(err) { err = err || new Error('wsFinalHandler error'); err.msg = req.body; var code = json_rpc.ERROR_CODES.methodNotFound; var error = json_rpc.newSysError(req.body, code, ...
javascript
{ "resource": "" }
q29574
init
train
function init (router) { router.use((err, req, res, next) => { res._headers = res._headers || {} next(err) }) }
javascript
{ "resource": "" }
q29575
staticViews
train
function staticViews (router, options) { if (!options) { return } Object.keys(options).filter(urlPath => options[urlPath]).forEach((urlPath) => { const filePath = options[urlPath] router.get(urlPath, (req, res) => { res.render(filePath) }) }) }
javascript
{ "resource": "" }
q29576
train
function (name, pointcutOrPlugin) { var method, matchstr; matchstr = (pointcutOrPlugin && (pointcutOrPlugin.pointcut || pointcutOrPlugin.pattern)) || pointcutOrPlugin; if ((pointcutOrPlugin && pointcutOrPlugin.pointcut) || typeof (pointcutOrPlugin) === 'string') { m...
javascript
{ "resource": "" }
q29577
train
function (name, pointcut) { var regexString, regex, ret; pointcut = pointcut || "*.*"; regexString = pointcut.replace(/\./g, "\\.").replace(/\*/g, ".*"); logger.debug("pointcut is: " + pointcut); //adds word boundaries at ei...
javascript
{ "resource": "" }
q29578
train
function (serviceName, methodNames, type, plugins) { var newPlugins = []; if (plugins && plugins.length > 0) { plugins.forEach(function (plugin) { var match = this.matchingMethodNames(serviceName, methodNames, plugin); if (match.length &&...
javascript
{ "resource": "" }
q29579
train
function (serviceName, methodNames, pointCut) { var fullName, ret = []; methodNames.forEach(function (name) { fullName = serviceName + "." + name; var match = this.match(fullName, pointCut); if (match) { ret.push(name); ...
javascript
{ "resource": "" }
q29580
train
function (serviceName, methodName, factoryPlugins, servicePlugins, invokePlugins) { var ret = util.mixin({}, this.defaults), that = this; Object.keys(ret).forEach(function (key) { var pf = that.list(serviceName, methodName, key, factoryPlugins), ps = that.li...
javascript
{ "resource": "" }
q29581
onWhichEvent
train
function onWhichEvent(sense, name, nbFinger) { var prefix = 'Short'; if (sense.hasPaused) prefix = 'Long'; var onEventName = 'on' + prefix + name + nbFinger; if (a4p.isDefined(sense[onEventName]) && (sense[onEventName] != null)) { return onEventName; } if (sen...
javascript
{ "resource": "" }
q29582
clearDrops
train
function clearDrops(sense) { sense.dropsStarted = []; sense.dropOver = null; sense.dropEvt = { dataType: 'text/plain', dataTransfer: '' }; }
javascript
{ "resource": "" }
q29583
AccessError
train
function AccessError(message) { Error.captureStackTrace(this, this.constructor); Object.defineProperties(this, { /** * Error message. * * @property message * @type String * @final */ message: {value: message, writable: true}, /** * Error name. * * @propert...
javascript
{ "resource": "" }
q29584
through
train
function through(transform) { var th = new Transform({objectMode: true}) th._transform = transform return th }
javascript
{ "resource": "" }
q29585
read
train
function read(uri) { "use strict"; var parsedUrl = url.parse(uri, false, true); var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http); var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80; var agent = parsedUr...
javascript
{ "resource": "" }
q29586
download
train
function download(uri, dest, progressCallback) { "use strict"; progressCallback = progressCallback || function() {}; var parsedUrl = url.parse(uri, false, true); var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http); var serverPort = parsedUrl.port ?...
javascript
{ "resource": "" }
q29587
writeStream
train
async function writeStream (filename, contents) { await new Promise((resolve, reject) => { contents.pipe(fs.createWriteStream(filename)) .on('finish', function () { resolve(filename) }) .on('error', /* istanbul ignore next */ function (err) { reject(err) }) }) return fi...
javascript
{ "resource": "" }
q29588
downloadFile
train
function downloadFile(cb) { if(task.file_path) { // Download the file var stream = fs.createWriteStream(path); // Store error if statusCode !== 200 var err; stream.on("finish", function() { cb(err); }); var urlToDownload = url.parse(task.file_pat...
javascript
{ "resource": "" }
q29589
train
function (payload, plugins, ioArgs) { var writePayload = payload || "", intermediate, that = this; // Very simiplistic payload type coercion if (this.requestPayloadName && !payload[this.requestPayloadName]) { payload = {}; pa...
javascript
{ "resource": "" }
q29590
train
function (statusCode, data, plugins, ioArgs) { var isList = this.reader.isListResponse(this.name), //TODO: "any" is JSONSchema default if no type is defined. this should come through a model though so we aren't tacking it on everywhere returnType = this.reader.getR...
javascript
{ "resource": "" }
q29591
HouseholdAddresses
train
function HouseholdAddresses (f1, householdID) { if (!householdID) { throw new Error('HouseholdAddresses requires a household ID!') } Addresses.call(this, f1, { path: '/Households/' + householdID + '/Addresses' }) }
javascript
{ "resource": "" }
q29592
train
function(v,node){ var format = this.__dataset(node,'format')||'yyyy-MM-dd'; return !v||(!isNaN(this.__doParseDate(v)) && _u._$format(this.__doParseDate(v),format) == v); }
javascript
{ "resource": "" }
q29593
train
function(_node){ var _type = _node.type, _novalue = !_node.value, _nocheck = (_type=='checkbox'|| _type=='radio')&&!_node.checked; if (_nocheck||_novalue) return -1; }
javascript
{ "resource": "" }
q29594
train
function(_node,_options){ var _reg = this.__treg[_options.type], _val = _node.value.trim(), _tested = !!_reg.test&&!_reg.test(_val), _funced = _u._$isFunction(_reg)&&!_reg.call(this,_val,_node); if (_tested||_funced) return -2; ...
javascript
{ "resource": "" }
q29595
train
function(_node,_options){ var _number = this.__number( _node.value, _options.type, _options.time ); if (isNaN(_number)|| _number<_options.min) return -6; }
javascript
{ "resource": "" }
q29596
train
function(_value,_node){ // for multiple select if (!!_node.multiple){ var _map; if (!_u._$isArray(_value)){ _map[_value] = _value; }else{ _map = _u._$array2object(_value); } _u...
javascript
{ "resource": "" }
q29597
train
function(_value,_node){ if (_reg0.test(_node.type||'')){ // radio/checkbox _node.checked = _value==_node.value; }else if(_node.tagName=='SELECT'){ // for select node _doSetSelect(_value,_node); }else{ // ...
javascript
{ "resource": "" }
q29598
train
function(callbackUUID, result) { var callback = apiListeners[callbackUUID]; if (callback) { if ( !(result && result instanceof Array )) { if(window.console && console.error){ console.error('received result is not an array.', result); } } callback.apply(this, result); ...
javascript
{ "resource": "" }
q29599
train
function(options, callback, errorCallback){ if(typeof options == 'function'){ callback = options; options = {}; } UT.Expression._callAPI( 'document.textInput', [options.value || null, options.max || null, options.multiline || false], callback ); }
javascript
{ "resource": "" }