_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q64500
journal
test
function journal() { 'use strict'; var fs = require('fs'); // private properties var eventList = { 'creationEvents' : {}, 'executionEvents' : {} }; var logMode; // sets the log method: 'q', 'v' or 'l' // exposed by the agency constructor function setLogMode(mode) { logMode = mode; ...
javascript
{ "resource": "" }
q64501
logCreationEvent
test
function logCreationEvent(id, type, message, time) { if (logMode === 'l') { if (!eventList.creationEvents[id]) { eventList.creationEvents[id] = []; } eventList.creationEvents[id].push({'type': type, 'event': message, "timestamp": time}); } else if (logMode === 'v') { consol...
javascript
{ "resource": "" }
q64502
logExecutionEvent
test
function logExecutionEvent(id, type, message, time) { if (logMode === 'l') { if (!eventList.executionEvents[id]) { eventList.executionEvents[id] = []; } eventList.executionEvents[id].push({'type': type, 'event': message, "timestamp": time}); } else if (logMode === 'v') { consol...
javascript
{ "resource": "" }
q64503
report
test
function report(logFile) { var defaultLogFile = (new Date()).toJSON() + '.log'; var data = JSON.stringify(eventList, null, 3); if (logFile) { fs.writeFile(logFile, data, function(err) { if(err) { console.log('\nCould not write log to file "' + logFile + '"\n' + err); fs.wr...
javascript
{ "resource": "" }
q64504
scopeUrl
test
function scopeUrl(options, inst) { options = _.extend({}, inst, options) if (!options.teamcenter_team_id) throw new Error('teamcenter_team_id required to make TeamCenterContact instance api calls') if (!options.teamcenter_member_id) throw new Error('teamcenter_member_id require to make TeamCente...
javascript
{ "resource": "" }
q64505
ArticleTranslation
test
function ArticleTranslation(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } ArticleTranslation.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64506
MacroAction
test
function MacroAction(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } MacroAction.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64507
map
test
function map(obj, source, target, isRecursive = true) { // Check if parameters have invalid types if ((typeof obj) != "object") throw new TypeError("The object should be JSON"); if ((typeof source) != "string" && (typeof source) != "array") throw new TypeError("Source should be aither string or array"); if ((typeof...
javascript
{ "resource": "" }
q64508
test
function (visit, onFail, opts) { var fail = onFail ? onFail : utils.ret(false), config = opts || { compact: true }; return function (list) { var p = Promise.resolve(false), results = []; list.forEach(function (l, i) { p = p.then(visit...
javascript
{ "resource": "" }
q64509
test
function() { console.warn('Code is using deprecated teams_advancing, switch to teamsAdvancing') var where = (new Error().stack || '').split('\n', 3)[2] if (where) console.warn(where) this.teamsAdvancing.apply(this, arguments) }
javascript
{ "resource": "" }
q64510
getIndexOfPrimitive
test
function getIndexOfPrimitive(primitive, array, startingPosition) { if (startingPosition === void 0) { startingPosition = 0; } errorIfNotPrimitive_1.errorIfNotPrimitive(primitive); error_if_not_populated_array_1.errorIfNotPopulatedArray(array); errorIfNotInteger_1.errorIfNotInteger(startingPosition); ...
javascript
{ "resource": "" }
q64511
loads
test
function loads(xhr, ee) { var onreadystatechange , onprogress , ontimeout , onabort , onerror , onload , timer; /** * Error listener. * * @param {Event} evt Triggered error event. * @api private */ onerror = xhr.onerror = one(function onerror(evt) { var status = statusc...
javascript
{ "resource": "" }
q64512
addWithDependencies
test
function addWithDependencies (allFiles, newFile, dependencies, currentFiles, cycleCheck) { if (cycleCheck.indexOf(newFile) >= 0) { throw new Error('Dependency cycle found ' + JSON.stringify(cycleCheck)) } cycleCheck.push(newFile) try { // Add dependencies first if (dependencies[newFile]) { dep...
javascript
{ "resource": "" }
q64513
batchForms
test
function batchForms(batch, form, merkle) { // Use commonform-stringify to produce the text to be stored. var stringified = stringify(form) var digest = merkle.digest batch.put(digest, stringified) // Recurse children. form.content .forEach(function(element, index) { if (isChild(element)) { ...
javascript
{ "resource": "" }
q64514
parseJSON
test
function parseJSON(input, callback) { var error var result try { result = JSON.parse(input) } catch (e) { error = e } callback(error, result) }
javascript
{ "resource": "" }
q64515
scopeUrl
test
function scopeUrl(options, inst) { options = _.extend(_.clone(options || {}), inst) var route = [] if (options.season_id) route.push('seasons', options.season_id) if (options.flight_stage_id) route.push('flight_stages', options.flight_stage_id) else if (options.division_id) route.push('divisions', ...
javascript
{ "resource": "" }
q64516
ReconnectingWebSocket
test
function ReconnectingWebSocket(url, opts) { if (!(this instanceof ReconnectingWebSocket)) { throw new TypeError('Cannot call a constructor as a function'); } opts = opts || {}; var self = this; function getOpt(name, def) { return opts.hasOwnProperty(name)? opts[name] : def; } v...
javascript
{ "resource": "" }
q64517
getFirstIndexOfArray
test
function getFirstIndexOfArray(arrayToSearchFor, arrayToSearchInside) { errorIfNotArray_1.errorIfNotArray(arrayToSearchFor); error_if_not_populated_array_1.errorIfNotPopulatedArray(arrayToSearchInside); return arrayToSearchInside.findIndex(function (value) { return (isArray_notArray_1.isArray(value) ...
javascript
{ "resource": "" }
q64518
writePath
test
function writePath(parentDir, path, data) { let files = path.split('/'); let file = files.shift(); // init file if(!parentDir[file]) parentDir[file] = { content: undefined, tree: {} }; if(files.length > 0) { writePath(parentDir[file].tree, files.join('/'), data); } ...
javascript
{ "resource": "" }
q64519
test
function(mainFiles /*, component*/) { for (var i=0; i<mainFiles.length; i++ ){ //Use no-minified version if available var parts = mainFiles[i].split('.'), ext = parts.pop(), min = parts.pop(), ...
javascript
{ "resource": "" }
q64520
test
function() { this.objects = {}; this.index = []; this._objTree = []; this._objList = []; this._properties = {}; this._propID = 0; this._decodeIndex = []; this._objFreq = []; this._objInfeq = []; this.shortNames = true; this.indent = "\t"; this.hasEmbed = false; }
javascript
{ "resource": "" }
q64521
test
function( po ) { this.objects[po.name] = po; if (po.extends) { this._objTree.push([ po.extends, po.name ]); } else if (po.depends) { this._objTree.push([ po.depends, po.name ]); } else { this._objList.push( po.name ); } }
javascript
{ "resource": "" }
q64522
test
function( index_offset, size, depth, prefix, testVar, callback ) { if (size == 0) return prefix + this.indent + "/* No items */\n"; var code = ""; genChunk = (function( s, e, d, pf ) { if (d === 0) { code += pf + "switch ("+testVar+") {\n"; for (var i=s; i<e; ++i) { code += pf + this.inde...
javascript
{ "resource": "" }
q64523
test
function( name ) { var id = this._properties[name]; if (id === undefined) { if (this.shortNames) { id = this._properties[name] = 'p' + (this._propID++).toString() } else { id = this._properties[name] = 'p' + name[0].toUpperCase() + name.substr(1).toLowerCase().replace(/[,\.\- \_]/g, '_') } }...
javascript
{ "resource": "" }
q64524
test
function() { // Reset index this.index = []; // Apply extends to the objects for (var i=0, l=this._objTree.length; i<l; ++i) { if (this.objects[this._objTree[i][0]] === undefined) { throw "Extending unknown object "+this._objTree[i][0]; } // Apply this.objects[this._objTree[i][1]].applyExtend...
javascript
{ "resource": "" }
q64525
test
function() { var pn = Object.keys(this._properties); var code = "var "; for (var i=0, l=pn.length; i<l; ++i) { if (i!==0) code += ",\n"; code += this.indent + this._properties[pn[i]] + " = '"+ pn[i] + "'"; } code += ";\n"; return code; }
javascript
{ "resource": "" }
q64526
test
function() { var code = ""; // Collect object initializers for (var i=0, l=this.index.length; i<l; ++i) { var o = this.index[i]; code += "/**\n * Factory & Initializer of "+o.name+"\n */\n"; code += "var factory_"+o.safeName+" = {\n"; code += this.indent + "props: "+o.properties.length+",\n"; code...
javascript
{ "resource": "" }
q64527
test
function(prefix) { var code = "function( id ) {\n"; code += prefix + this.indent + "if (id < "+MAX_FREQ_ITEMS+") {\n"; code += this.generateDnCif( 0, this._objFreq.length, 3, prefix+this.indent, 'id', (function(i) { return "factory_"+this._objFreq[i].safeName+";\n" }).bind(this)); code += prefix + this.ind...
javascript
{ "resource": "" }
q64528
test
function( prefix ) { var code = "function( inst ) {\n"; for (var i=0, l=this.index.length; i<l; ++i) { var o = this.index[i]; if (i === 0) code += prefix + this.indent + "if"; else code += prefix + this.indent + "} else if"; code += " (inst instanceof "+o.name+") {\n"; code += prefix + this.indent + ...
javascript
{ "resource": "" }
q64529
test
function() { var code = ""; // Collect object initializers for (var i=0, l=this.index.length; i<l; ++i) { var o = this.index[i]; code += "/**\n * Property getter "+o.name+"\n */\n"; code += "function getter_"+o.safeName+"(inst) {\n"; code += this.indent + "return "+o.generatePropertyGetter('inst',thi...
javascript
{ "resource": "" }
q64530
Client
test
function Client(options) { options = options || {}; this.isClient = true; this.subdomain = options.subdomain; this.endpoint = options.endpoint; if (!this.subdomain && !this.endpoint) throw new Error('No subdomain was specified.'); // Determine if we construct a URL from the subdomain or use a custom one ...
javascript
{ "resource": "" }
q64531
Imagesloader
test
function Imagesloader(opts){ /** * @define {object} Collection of public methods. */ var self = {}; /** * @define {object} Options for the constructor */ var opts = opts || {}; /** * @define {object} A image loader object */ var imageloader = Imageloader(); /** * @...
javascript
{ "resource": "" }
q64532
load
test
function load(images){ def = Deferred(); /** * Check if the images is img objects or image src * return string of src */ srcs = convertImagesToSrc(images); /** * Loop through src's and load image */ for (var i = 0; i < srcs.length; i++) { imageloader.load(srcs[i]) .success(function(im...
javascript
{ "resource": "" }
q64533
imageLoaded
test
function imageLoaded(img){ /** Notify the promise */ def.notify("notify"); /** Add the image to the imgs array */ imgs.push(img); /** If the imgs array size is the same as the src's */ if(imgs.length == srcs.length){ /** First sort images, to have the same order as src's */ sortImages(); /** R...
javascript
{ "resource": "" }
q64534
convertImagesToSrc
test
function convertImagesToSrc(imgs){ var src = []; for (var i = 0; i < imgs.length; i++) { /** If the img is an object (img) get the src */ if(typeof imgs[i] == 'object'){ src.push(imgs[i].src); } }; /** If the src array is null return the original imgs array */ return src.length ? src : imgs; ...
javascript
{ "resource": "" }
q64535
sortImages
test
function sortImages(){ var arr = []; /** * Create a double loop * And match the order of the srcs array */ for (var i = 0; i < srcs.length; i++) { for (var j = 0; j < imgs.length; j++) { var str = imgs[j].src.toString(); var reg = new RegExp(srcs[i]) /** If srcs matches the imgs add it the...
javascript
{ "resource": "" }
q64536
builder
test
function builder(envList, envName) { if (envList == null) { envList = DEFAULT_ENV_LIST; } if (envName == null) { envName = DEFAULT_ENV_NAME; } if (!Array.isArray(envList)) { throw new Error('envList must be an array'); } if (typeof envName !== 'string') { throw new Error('envName must be a...
javascript
{ "resource": "" }
q64537
validateId
test
function validateId(id) { if (id && id.trim() && /^[a-zA-Z0-9_]+$/.test(id)) { if (agency.isIdInUse(id)) { err.name = 'DuplicateIdError'; err.message = 'duplication (use a different id)'; return err; } else { return id; } } else { err.name = 'ValidateIdEr...
javascript
{ "resource": "" }
q64538
arrayGetUniques
test
function arrayGetUniques(arr) { var a = []; for (var i=0, l=arr.length; i<l; i++) { if (a.indexOf(arr[i]) === -1 && arr[i] !== '') a.push(arr[i]); } return a; }
javascript
{ "resource": "" }
q64539
setFunction
test
function setFunction(f) { if (canExecute) { if (Object.getPrototypeOf(f) === Function.prototype) { func = f; jn.logCreationEvent(id, 'INFO', 'function definition completed', (new Date()).toJSON()); } else { setCanExecute(false); jn.logCreationEvent(id, 'ERROR', 'function ...
javascript
{ "resource": "" }
q64540
setCallback
test
function setCallback(cb) { if (canExecute) { if (Object.getPrototypeOf(cb) === Function.prototype) { callback = cb; jn.logCreationEvent(id, 'INFO', 'callback definition completed', (new Date()).toJSON()); } else { setCanExecute(false); jn.logCreationEvent(id, 'ERROR', 'ca...
javascript
{ "resource": "" }
q64541
Case
test
function Case(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } Case.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64542
Resource
test
function Resource(parent, definition) { this.parent = parent; this.definition = definition; // add mixins this._link = linkMixin; this._setup(); }
javascript
{ "resource": "" }
q64543
containerSlug
test
function containerSlug(language_slug, project_slug, resource_slug) { if(!language_slug || !project_slug || !resource_slug) throw new Error('Invalid resource container slug parameters'); return language_slug + '_' + project_slug + '_' + resource_slug; }
javascript
{ "resource": "" }
q64544
test
function () { let dir = path.join(container_directory, content_dir); return fs.readdirSync(dir).filter(function(file) { try { return fs.statSync(file).isDirectory(); } catch (err) { console.log(err); retu...
javascript
{ "resource": "" }
q64545
test
function(chapterSlug, chunkSlug) { let file = path.join(container_directory, content_dir, chapterSlug, chunkSlug + '.' + this.chunkExt); return fs.readFileSync(file, {encoding: 'utf8'}); }
javascript
{ "resource": "" }
q64546
makeContainer
test
function makeContainer(container_directory, opts) { return new Promise(function(resolve, reject) { if(fileUtils.fileExists(container_directory)) { reject(new Error('Container already exists')); return; } let package_json = {}; // TODO: build the container ...
javascript
{ "resource": "" }
q64547
openContainer
test
function openContainer(container_archive, container_directory, opts) { opts = opts || { compression_method : 'tar' }; if(fileUtils.fileExists(container_directory)) { return loadContainer(container_directory); } if(!fileUtils.fileExists(container_archive)) return Promise.reject(new Error('Missing...
javascript
{ "resource": "" }
q64548
inspectContainer
test
function inspectContainer(container_path, opts) { return new Promise(function(resolve, reject) { if(path.extname(container_path) !== '.' + spec.file_ext) { reject(new Error('Invalid resource container file extension')); return; } try { ...
javascript
{ "resource": "" }
q64549
UserPreference
test
function UserPreference(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } UserPreference.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64550
getUpdater
test
function getUpdater(errorFn) { errorFn = errorFn || new Function(); return updater; /** * The updater function for the esprima transform * @param {string} file The filename for the Browserify transform * @param {object} ast The esprima syntax tree * @returns {object} The transformed esprima syntax tr...
javascript
{ "resource": "" }
q64551
updater
test
function updater(file, ast) { if (ast.comments) { ast.comments .filter(testDocTag) .map(getAnnotatedNode) .concat(inferAngular(ast)) // find the items that are not explicitly annotated .filter(testFirstOccurrence) // ensure unique values .forEach(processNode); }...
javascript
{ "resource": "" }
q64552
getAnnotatedNode
test
function getAnnotatedNode(comment) { // find the first function declaration or expression following the annotation var result; if (comment.annotates) { var candidateTrees; // consider the context the block is in (i.e. what is its parent) var parent = comment.annotates.parent; // c...
javascript
{ "resource": "" }
q64553
locationStr
test
function locationStr( runtime , line ) { var loc ; loc = 'line: ' + ( line !== undefined ? line : runtime.lineNumber ) ; if ( runtime.file ) { loc += ' -- file: ' + runtime.file ; } return loc ; }
javascript
{ "resource": "" }
q64554
Macro
test
function Macro(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } this.destroy = destroyMixin; Macro.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64555
quickSort
test
function quickSort(a, l, h, k, c) { const s = []; let t = 0; s[t++] = l; s[t++] = h; while (t > 0) { h = s[--t]; l = s[--t]; if (h - l > k) { const p = partition(a, l, h, c); if (p > l) { s[t++] = l; s[t++] = p; } if (p + 1 < h) { s[t++] = p + ...
javascript
{ "resource": "" }
q64556
pivot
test
function pivot(a, l, h, c) { const p = (l + ((h - l) / 2)) | 0; if (c(a[h], a[l]) < 0) { [a[l], a[h]] = [a[h], a[l]]; } if (c(a[p], a[l]) < 0) { [a[l], a[p]] = [a[p], a[l]]; } if (c(a[h], a[p]) < 0) { [a[h], a[p]] = [a[p], a[h]]; } return p; }
javascript
{ "resource": "" }
q64557
partition
test
function partition(a, l, h, c) { const p = a[pivot(a, l, h, c)]; let i = l - 1; let j = h + 1; for (;;) { do { i++; } while (c(a[i], p) < 0); do { j--; } while (c(a[j], p) > 0); if (i < j) { [a[i], a[j]] = [a[j], a[i]]; } else { return j; } } }
javascript
{ "resource": "" }
q64558
insertionSort
test
function insertionSort(a, l, h, c) { for (let i = l + 1; i <= h; i++) { const x = a[i]; let j = i - 1; while (j >= 0 && c(a[j], x) > 0) { a[j + 1] = a[j]; j--; } a[j + 1] = x; } }
javascript
{ "resource": "" }
q64559
search
test
function search(parent, baseUrl, callback) { var resource = new (getResource('page'))(parent, { _links: { self: { href: baseUrl, 'class': 'page' } } }); if (typeof callback == 'function') return resource.exec(callback); return resource; }
javascript
{ "resource": "" }
q64560
createPipeStream
test
function createPipeStream(cmd/*, args, opts*/){ var proc; var command; if(Array.isArray(cmd)){ // We have an array so create a pipe from all elements var firstCmd = cmd.shift(); var open = Array.isArray(firstCmd) ? createPipeStream.apply({}, firstCmd) : createPipeStream(firstCmd); cmd.forEa...
javascript
{ "resource": "" }
q64561
wrapMethods
test
function wrapMethods(self){ var methods = ['on']; var childObjects = ['stdin','stdout','stderr']; // Wrap on method methods.forEach(function(m){ var old = self[m]; self[m] = function(){ old.apply(self, arguments); return self; }; }); // If its a ...
javascript
{ "resource": "" }
q64562
connectEvents
test
function connectEvents(self){ if(self.stdout){ self.stdout.on('data', function(d){ self.emit('data', d); }); self.stderr.on('data', function(d){ self.emit('error', d); }); } }
javascript
{ "resource": "" }
q64563
addEventHandlers
test
function addEventHandlers(self){ self.on('error',function(d){ var fn = self._error; self._cleanUp(); if(fn){ fn('pipeline[' + self._nr + ']:"' + self._command + '" failed with: ' + d.toString()); } }); }
javascript
{ "resource": "" }
q64564
_resolve
test
function _resolve(routes, path, req, res) { return Q.fcall(function() { path = path || []; var obj = routes; // Resolve promises first if(IS.obj(obj) && IS.fun(obj.then)) { var p = obj.then(function(ret) { return _resolve(ret, path, req, res); }); return p; } // Resolve functions first ...
javascript
{ "resource": "" }
q64565
_buildFunction
test
function _buildFunction(resource) { return function(callback) { if (typeof callback == 'function') { if (resource !== null) return resource.exec.call(resource, callback); else return callback(null, null); } return resource; } }
javascript
{ "resource": "" }
q64566
getApiKey
test
function getApiKey () { if (isLocal() && pkg.apiKey) { log.trace('using apiKey in fhconfig'); return pkg.apiKey; } else { log.trace('using api key in FH_APP_API_KEY env var'); return env('FH_APP_API_KEY').asString(); } }
javascript
{ "resource": "" }
q64567
getResource
test
function getResource(name) { if (name in resources) return resources[name]; try { return resources[name] = require('../resource/' + name); } catch(err) { return resources[name] = require('../resource'); } }
javascript
{ "resource": "" }
q64568
signMsg
test
function signMsg(msg, key, alg) { var signer = crypto.createSign(alg); signer.update(msg); return signer.sign(key); }
javascript
{ "resource": "" }
q64569
hashMsg
test
function hashMsg(msg, alg) { var hash = crypto.createHash(alg); hash.update(msg); return hash.digest(); }
javascript
{ "resource": "" }
q64570
addSignatureHeaders
test
function addSignatureHeaders(body, headers, keyId, key) { if (!headers) { headers = {}; } if (!headers.date) { headers.date = (new Date()).toUTCString(); } if (!headers.digest) { headers.digest = 'SHA256=' + hashMsg(JSON.stringify(body), 'sha256') .toString('base64'); } var combine...
javascript
{ "resource": "" }
q64571
waitVariableToBe
test
async function waitVariableToBe (variableExpression, value, timeout) { return await this.waitUntil(async () => { const result = await this.execute(`return ${variableExpression} === ${JSON.stringify(value)}`) return result.value }, timeout, `Timeout to wait expression \`${variableExpression}\` to be \`${JSON...
javascript
{ "resource": "" }
q64572
waitAttributeToBe
test
async function waitAttributeToBe (selector, key, value, timeout) { return await this.waitUntil(async () => { const got = await this.element(selector).getAttribute(key) return [].concat(value).some((value) => got === value || String(got) === String(value)) }, timeout, `Timeout to wait attribute "${key}" on \...
javascript
{ "resource": "" }
q64573
test
function(view) { this.unmount(); this.currentView = view; var renderReturnsView = this.currentView.render(); if (renderReturnsView) { $(SpecialK.mainContainer).empty().append(renderReturnsView.el).fadeIn('slow'); } }
javascript
{ "resource": "" }
q64574
test
function() { if (!this.currentView) return false; $(SpecialK.container).hide(); this.currentView.unbind(); this.currentView.remove(); this.currentView = null; return true; }
javascript
{ "resource": "" }
q64575
mergeAll
test
function mergeAll(safe, obj) { let args = toArray(arguments).slice(2); for (let i = 0; i < args.length; i++) { obj = merge(obj, args[i], safe); } return obj; }
javascript
{ "resource": "" }
q64576
quality
test
function quality(str) { var parts = str.split(/ *; */), val = parts[0]; var q = parts[1] ? parseFloat(parts[1].split(/ *= */)[1]) : 1; return { value: val, quality: q }; }
javascript
{ "resource": "" }
q64577
getBrightness
test
function getBrightness( hex ) { var r = parseInt( hex.substr(2+0*2, 2), 16), g = parseInt( hex.substr(2+1*2, 2), 16), b = parseInt( hex.substr(2+2*2, 2), 16); function lin2log(n) { return n <= 0.0031308 ? n * 12.92 : 1.055 * Math.pow(n,1/2.4) - 0.055; } function log2lin(n) { return n <...
javascript
{ "resource": "" }
q64578
command_exists
test
function command_exists (paths, name) { if (is.string(paths)) { paths = paths.split(':'); } debug.assert(paths).is('array'); return paths.some(dir => fs.existsSync(PATH.join(dir, name))); }
javascript
{ "resource": "" }
q64579
qExec
test
function qExec(command, options) { var d = Q.defer(); exec(command, options, function(err, stdout, stderr) { if(err) { err.stdout = stdout; err.stderr = stderr; return d.reject(err); } return d.resolve(stdout, stderr); }); return d.promise; }
javascript
{ "resource": "" }
q64580
initDynamic
test
function initDynamic() { // bootstrap popover $('a[data-toggle=popover]') .popover() .click(function(e) { e.preventDefault(); }) ; var version = $('#version strong').html(); $('#sidenav li').removeClass('is-new'); if (a...
javascript
{ "resource": "" }
q64581
changeAllVersionCompareTo
test
function changeAllVersionCompareTo(e) { e.preventDefault(); $('article:visible .versions').each(function(){ var $root = $(this).parents('article'); var currentVersion = $root.data('version'); var $foundElement = null; $(this).find('li.version a').each(func...
javascript
{ "resource": "" }
q64582
addArticleSettings
test
function addArticleSettings(fields, entry) { // add unique id // TODO: replace all group-name-version in template with id. fields.id = fields.article.group + '-' + fields.article.name + '-' + fields.article.version; fields.id = fields.id.replace(/\./g, '_'); if (entry.header && ...
javascript
{ "resource": "" }
q64583
renderArticle
test
function renderArticle(group, name, version) { var entry = {}; $.each(apiByGroupAndName[group][name], function(index, currentEntry) { if (currentEntry.version === version) entry = currentEntry; }); var fields = { article: entry, version...
javascript
{ "resource": "" }
q64584
resetArticle
test
function resetArticle(group, name, version) { var $root = $('article[data-group=\'' + group + '\'][data-name=\'' + name + '\']:visible'); var content = renderArticle(group, name, version); $root.after(content); var $content = $root.next(); // Event on.click muss neu zugewiesen ...
javascript
{ "resource": "" }
q64585
loadGoogleFontCss
test
function loadGoogleFontCss() { var host = document.location.hostname.toLowerCase(); var protocol = document.location.protocol.toLowerCase(); var googleCss = '//fonts.googleapis.com/css?family=Source+Code+Pro|Source+Sans+Pro:400,600,700'; if (host == 'localhost' || !host.length || protoco...
javascript
{ "resource": "" }
q64586
sortByOrder
test
function sortByOrder(elements, order, splitBy) { var results = []; order.forEach (function(name) { if (splitBy) elements.forEach (function(element) { var parts = element.split(splitBy); var key = parts[1]; // reference keep for sorting ...
javascript
{ "resource": "" }
q64587
browserifyNgInject
test
function browserifyNgInject(opt) { var options = defaults(opt, { filter: defaultFilter // remove files that cannot be parsed by esprima }), updater = getUpdater(throwError); return esprimaTools.createTransform(updater, options); }
javascript
{ "resource": "" }
q64588
test
function (scope) { if (scope.model) { var modelInData = false; for(var i = 0; i < scope.data.length; i++) { if (angular.equals(scope.data[i], scope.model)) { scope.model = scope.data[i]; modelInData = true; ...
javascript
{ "resource": "" }
q64589
scopeUrl
test
function scopeUrl(options, inst) { options = _.extend(options || {}, inst) if (!options.url && !options.user_id && !options.group_id && !(options.query || options.query.owner_type && options.query.owner_id)) { return callback(new Error('user_id or group_id or (owner_type and owner_id) are required')) ...
javascript
{ "resource": "" }
q64590
processNode
test
function processNode(node) { // check if the function is part of a variable assignment var isVarAssignment = (node.parent.type === 'VariableDeclarator'); // the parameters of the function, converted to literal strings var params = node.params .map(paramToLiteral); // [ 'arg', ..., function(arg) {} ] ...
javascript
{ "resource": "" }
q64591
createApplication
test
function createApplication() { function app(req, res) { app.handle(req, res); } utils.merge(app, application); utils.merge(app, EventEmitter.prototype); app.request = { __proto__ : req }; app.response = { __proto__ : res }; app.init(); return app; }
javascript
{ "resource": "" }
q64592
test
function(){ var chai = require('chai'); chai.should(); global.assert = chai.assert; global.expect = chai.expect; }
javascript
{ "resource": "" }
q64593
Company
test
function Company(parent, definition) { var key; for (key in updateMixin) { this[key] = updateMixin[key]; } Company.super_.apply(this, arguments); }
javascript
{ "resource": "" }
q64594
inferAngular
test
function inferAngular(ast) { return esprimaTools.breadthFirst(ast) .map(getAnnotationCandidates) .filter(Boolean) .map(followReference) .filter(Boolean); }
javascript
{ "resource": "" }
q64595
getAnnotationCandidates
test
function getAnnotationCandidates(node) { var callExpression = testNode.isModuleExpression(node) && node.parent; if (callExpression) { return callExpression['arguments'] .filter(testNode.anyOf(testNode.isFunction, testNode.isIdentifier)) .pop(); } else { return null; } }
javascript
{ "resource": "" }
q64596
followReference
test
function followReference(node) { var result; // immediate function if (testNode.isFunction(node)) { return node; } // follow identifier else { var name = node.name; // find the next highest scope and search for declaration while (node.parent && !result) { node = node.parent; va...
javascript
{ "resource": "" }
q64597
test
function(callback) { // perform all the cleanup and other operations needed prior to shutdown, // but do not actually shutdown. Call the callback function only when // these operations are actually complete. try { TacitServer.app_server.close(); console.log(TacitServer.configs.server_prefix + " - Shutdown app...
javascript
{ "resource": "" }
q64598
transformBody
test
function transformBody(req, input) { req.log.debug('attempting transformation', input); const body = input.data; const { attributes } = body; const { password, referral } = attributes; const { autoGeneratePassword } = config; if (autoGeneratePassword === true && password) { throw new Errors.Validation...
javascript
{ "resource": "" }
q64599
test
function( val, num, max ) { if ( max ) { // make sure the text value is greater than the max numerical value (max) var indx, len = val ? val.length : 0, n = max + num; for ( indx = 0; indx < len; indx++ ) { n += val.charCodeAt( indx )...
javascript
{ "resource": "" }