_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q47900
global_names
train
function global_names(ctx, options) { try { var ans = vm.runInContext(options.enum_global, ctx); ans = ans.concat(all_keywords); ans.sort(); var seen = {}; ans.filter(function (item) { if (Object.prototype.hasOwnProperty.call(seen, item)) return false; ...
javascript
{ "resource": "" }
q47901
train
function(element, type, handler) { if(element.addEventListener) { addEvent = function(element, type, handler) { element.addEventListener(type, handler, false); }; } else if(element.attachEvent) { addEvent = function(element, type, handler) { element.attachEvent('on' + type, han...
javascript
{ "resource": "" }
q47902
train
function(arr) { var key = 0; var min = arr[0]; for(var i = 1, len = arr.length; i < len; i++) { if(arr[i] < min) { key = i; min = arr[i]; } } return key; }
javascript
{ "resource": "" }
q47903
train
function(arr) { var key = 0; var max = arr[0]; for(var i = 1, len = arr.length; i < len; i++) { if(arr[i] > max) { key = i; max = arr[i]; } } return key; }
javascript
{ "resource": "" }
q47904
train
function(event) { clearTimeout(noticeDelay); var e = event || window.event; var target = e.target || e.srcElement; if(target.tagName == 'SPAN') { var targetTitle = target.parentNode.tagLine; noticeContainer.innerHTML = (target.className == 'like' ? 'Liked ' : 'Marked ') + '<strong>' + target...
javascript
{ "resource": "" }
q47905
train
function() { return Math.max(MIN_COLUMN_COUNT, Math.floor((document.body.offsetWidth + GAP_WIDTH) / (COLUMN_WIDTH + GAP_WIDTH))); }
javascript
{ "resource": "" }
q47906
train
function(count) { columnHeights = []; for(var i = 0; i < count; i++) { columnHeights.push(0); } cellsContainer.style.width = (count * (COLUMN_WIDTH + GAP_WIDTH) - GAP_WIDTH) + 'px'; }
javascript
{ "resource": "" }
q47907
train
function(num) { if(loading) { // Avoid sending too many requests to get new cells. return; } var xhrRequest = new XMLHttpRequest(); var fragment = document.createDocumentFragment(); var cells = []; var images; xhrRequest.open('GET', 'json.php?n=' + num, true); xhrRequest.onre...
javascript
{ "resource": "" }
q47908
train
function(num) { if(loading) { // Avoid sending too many requests to get new cells. return; } var fragment = document.createDocumentFragment(); var cells = []; var images = [0, 286, 143, 270, 143, 190, 285, 152, 275, 285, 285, 128, 281, 242, 339, 236, 157, 286, 259, 267, 137, 253, 127, 19...
javascript
{ "resource": "" }
q47909
train
function(cells, reflow) { var columnIndex; var columnHeight; for(var j = 0, k = cells.length; j < k; j++) { // Place the cell to column with the minimal height. columnIndex = getMinKey(columnHeights); columnHeight = columnHeights[columnIndex]; cells[j].style.height = (cells[j].offset...
javascript
{ "resource": "" }
q47910
train
function() { // Calculate new column count after resize. columnCount = getColumnCount(); if(columnHeights.length != columnCount) { // Reset array of column heights and container width. resetHeights(columnCount); adjustCells(cellsContainer.children, true); } else { manageCells(); ...
javascript
{ "resource": "" }
q47911
train
function() { // Lock managing state to avoid another async call. See {Function} delayedScroll. managing = true; var cells = cellsContainer.children; var viewportTop = (document.body.scrollTop || document.documentElement.scrollTop) - cellsContainer.offsetTop; var viewportBottom = (window.innerHeight...
javascript
{ "resource": "" }
q47912
train
function() { // Add other event listeners. addEvent(cellsContainer, 'click', updateNotice); addEvent(window, 'resize', delayedResize); addEvent(window, 'scroll', delayedScroll); // Initialize array of column heights and container width. columnCount = getColumnCount(); resetHeights(columnCou...
javascript
{ "resource": "" }
q47913
train
function(time) { if (this._queue.length === 0) return var i = 0, line, oldLines while ((line = this._queue[i++]) && time >= line.t2) 1 oldLines = this._queue.slice(0, i - 1) this._queue = this._queue.slice(i - 1) if (this._queue.length === 0) this....
javascript
{ "resource": "" }
q47914
train
function(t1, v2, duration) { var i = 0, line, newLines = [] // Find the point in the queue where we should insert the new line. while ((line = this._queue[i++]) && (t1 >= line.t2)) 1 this._queue = this._queue.slice(0) if (this._queue.length) { va...
javascript
{ "resource": "" }
q47915
train
function(array, ind) { if (ind >= array.length || ind < 0) throw new Error('$' + (ind + 1) + ': argument number out of range') return array[ind] }
javascript
{ "resource": "" }
q47916
train
function(obj, type, name, nameIsUnique, oldName) { var nameMap, objList this._store[type] = nameMap = this._store[type] || {} nameMap[name] = objList = nameMap[name] || [] // Adding new mapping if (objList.indexOf(obj) === -1) { if (nameIsUnique && objList.length > 0) throw new Error...
javascript
{ "resource": "" }
q47917
train
function(obj, type, name) { var nameMap = this._store[type] , objList = nameMap ? nameMap[name] : null , ind if (!objList) return ind = objList.indexOf(obj) if (ind === -1) return objList.splice(ind, 1) exports.emitter.emit('namedObjects:unregistered:' + type, obj) }
javascript
{ "resource": "" }
q47918
train
function(rate) { if (!_.isNumber(rate)) return console.error('invalid [metro] rate ' + rate) this.rate = Math.max(rate, 1) }
javascript
{ "resource": "" }
q47919
charCodesToString
train
function charCodesToString(charCodes) { // Use these methods to be able to convert large strings if (hasProperty('Buffer')) { return Buffer.from(charCodes).toString(STR_ENCODING) } else if (hasProperty('TextDecoder')) { return new TextDecoder(STR_ENCODING) // eslint-disable-line no-undef .decode(new...
javascript
{ "resource": "" }
q47920
train
function() { if ($(yasqe.getWrapperElement()).offset().top >= tooltip.offset().top) { //shit, move the tooltip down. The tooltip now hovers over the top edge of the yasqe instance tooltip.css("bottom", "auto"); tooltip.css("top", "26px"); } }
javascript
{ "resource": "" }
q47921
setSideConditions
train
function setSideConditions(topSymbol) { if (topSymbol === "prefixDecl") { state.inPrefixDecl = true; } else { state.inPrefixDecl = false; } switch (topSymbol) { case "disallowVars": state.allowVars = false; break; case "allowVars": st...
javascript
{ "resource": "" }
q47922
train
function(yasqe) { yasqe.cursor = $(".CodeMirror-cursor"); if (yasqe.buttons && yasqe.buttons.is(":visible") && yasqe.cursor.length > 0) { if (utils.elementsOverlap(yasqe.cursor, yasqe.buttons)) { yasqe.buttons.find("svg").attr("opacity", "0.2"); } else { yasqe.buttons.find("svg").attr("opacity",...
javascript
{ "resource": "" }
q47923
formatError
train
function formatError(e) { if (!e.err) return e.message; if (e.err.message) return e.err.message; return JSON.stringify(e.err); }
javascript
{ "resource": "" }
q47924
main
train
function main(kayn) { const config = { query: 420, champion: 67, season: 7, } kayn.Summoner.by.name('Contractz').callback(function(error, summoner) { // Note that the grabbing of a matchlist is currently limited by pagination. // This API request only returns the fir...
javascript
{ "resource": "" }
q47925
rangeToPattern
train
function rangeToPattern(start, stop, options) { if (start === stop) { return { pattern: start, count: [], digits: 0 }; } let zipped = zip(start, stop); let digits = zipped.length; let pattern = ''; let count = 0; for (let i = 0; i < digits; i++) { let [startDigit, stopDigit] = zipped[i]; if...
javascript
{ "resource": "" }
q47926
logDiffText
train
function logDiffText(diff, options) { var diffText = getDiffText(diff, options); if (diffText) { console.log(inverseGreen('+ expected'), inverseRed('- actual'), '\n', diffText); } }
javascript
{ "resource": "" }
q47927
_concatNotDiffParts
train
function _concatNotDiffParts(diff) { for (var i = 1; i < diff.length; i++) { var currPart = diff[i], prevPart = diff[i - 1]; if (!_isDiffPart(currPart) && !_isDiffPart(prevPart)) { prevPart.value += currPart.value; diff.splice(i--, 1); } } retur...
javascript
{ "resource": "" }
q47928
modify
train
function modify(value, options) { var modifiedValue = '', parser; parser = new SimpleApiParser({ /** * @param {String} name * @param {String} publicId * @param {String} systemId */ doctype: function (name, publicId, systemId) { modifiedVal...
javascript
{ "resource": "" }
q47929
_getIndexesInArray
train
function _getIndexesInArray(attrs, attr) { var res = []; for (var i = 0; i < attrs.length; i++) { if (attrs[i].name === attr) res.push(i); } return res; }
javascript
{ "resource": "" }
q47930
sortAttrs
train
function sortAttrs(attrs) { return attrs.sort(function (a, b) { if (a.name < b.name) { return -1; } else if (a.name > b.name) { return 1; } else if (a.value < b.value) { return -1; } else if (a.value > b.value) { return 1; } ...
javascript
{ "resource": "" }
q47931
sortCssClasses
train
function sortCssClasses(attrs) { /** * Sorts the given CSS class attribute * @param {String} cssClasses * @returns {String} */ function _sortCssClassesValues(cssClasses) { var classList = (cssClasses || '').split(' '); return _(classList) .filter() .u...
javascript
{ "resource": "" }
q47932
_sortCssClassesValues
train
function _sortCssClassesValues(cssClasses) { var classList = (cssClasses || '').split(' '); return _(classList) .filter() .uniq() .sort() .join(' '); }
javascript
{ "resource": "" }
q47933
sortAttrsValues
train
function sortAttrsValues(attrs, compareAttributesAsJSON) { /** * Recursively sorts the given object by key * @param {Object} obj * @returns {Object} */ function _sortObj(obj) { if (!_.isObject(obj)) { return JSON.stringify(obj); } if (_.isArray(obj)) { ...
javascript
{ "resource": "" }
q47934
_sortObj
train
function _sortObj(obj) { if (!_.isObject(obj)) { return JSON.stringify(obj); } if (_.isArray(obj)) { return '[' + _(obj).map(_sortObj).join(',') + ']'; } return '{' + _(obj) .keys() .sort() .map...
javascript
{ "resource": "" }
q47935
_parseAttr
train
function _parseAttr(val, isClick) { try { if (isClick) { /*jshint evil: true */ var fn = Function(val); return fn ? fn() : {}; } return JSON.parse(val); } catch (err) { return undefined; } }
javascript
{ "resource": "" }
q47936
removeAttrsValues
train
function removeAttrsValues(attrs, ignoreAttributes) { _.forEach(ignoreAttributes, function (attr) { var attrIndexes = _getIndexesInArray(attrs, attr); _.forEach(attrIndexes, function (index) { attrs[index].value = ''; }); }); return attrs; }
javascript
{ "resource": "" }
q47937
removeDuplicateAttributes
train
function removeDuplicateAttributes(attrs) { var attrsNames = [], res = []; _.forEach(attrs, function (attr) { if (attrsNames.indexOf(attr.name) === -1) { res.push(attr); attrsNames.push(attr.name); } }); return res; }
javascript
{ "resource": "" }
q47938
getConditionalComment
train
function getConditionalComment(comment, modify, options) { var START_IF = '^\\s*\\[if .*\\]>', END_IF = '<!\\[endif\\]\\s*$', matchedStartIF = comment.match(new RegExp(START_IF)), matchedEndIF = comment.match(new RegExp(END_IF)); if (comment.match(new RegExp(START_IF + '\\s*$')) || comm...
javascript
{ "resource": "" }
q47939
sortedByScoreDesc
train
function sortedByScoreDesc(players) { return players.slice().sort(function(a, b) { if (b.score == a.score) return a.name.localeCompare(b.name); // stabalize the sort return b.score - a.score; }); }
javascript
{ "resource": "" }
q47940
calcPlayerStyle
train
function calcPlayerStyle(player, delayed) { // delayed if (delayed) return {transition: "250ms", transform: null}; // initial else { var offset = (lastPos.get(player) * 18) - (curPos.get(player) * 18); return { transform: "translateY(" + offset + "px)", transition: null//offset == 0 ? "", };...
javascript
{ "resource": "" }
q47941
buildDistTable
train
function buildDistTable() { var builds = getBuilds(); var branch = getCurBranch(); var colWidths = { build: 0, "min / gz": 0, contents: 0, descr: 0, }; var appendix = []; builds.forEach(function(build, i) { var buildName = build.build; var path = "dist/" + buildName + "/domvm." + buildName + ".mi...
javascript
{ "resource": "" }
q47942
deepSet
train
function deepSet(targ, path, val) { var seg; while (seg = path.shift()) { if (path.length === 0) { targ[seg] = val; } else { targ[seg] = targ = targ[seg] || {}; } } }
javascript
{ "resource": "" }
q47943
patchStyle
train
function patchStyle(n, o) { var ns = (n.attrs || emptyObj).style; var os = o ? (o.attrs || emptyObj).style : null; // replace or remove in full if (ns == null || isVal(ns)) { n.el.style.cssText = ns; } else { for (var nn in ns) { var nv = ns[nn]; if (os == null || nv != null && nv !== os[nn]) {...
javascript
{ "resource": "" }
q47944
ViewModel
train
function ViewModel(view, data, key, opts) { var vm = this; vm.view = view; vm.data = data; vm.key = key; if (opts) { vm.opts = opts; vm.cfg(opts); } var out = isPlainObj(view) ? view : view.call(vm, vm, data, key, opts); if (isFunc(out)) { vm.render = out; } else { vm.render = out.render; vm.cfg(...
javascript
{ "resource": "" }
q47945
VView
train
function VView(view, data, key, opts) { this.view = view; this.data = data; this.key = key; this.opts = opts; }
javascript
{ "resource": "" }
q47946
rendMonth
train
function rendMonth(year, month) { var prevEnd = daysInMonth(year, month - 1), start = firstDayOfMonth(year, month), end = daysInMonth(year, month), // if start of month day < start of week cfg, roll back 1 wk wkOffs = start < wkStart ? -7 : 0; return el("table.month", [ el("caption", months[month]),...
javascript
{ "resource": "" }
q47947
rendYear
train
function rendYear(vm, args) { var prevYear = args.year - 1, nextYear = args.year + 1; return el(".year", [ el("header", [ el("button.prev", {onclick: [api.loadYear, prevYear]}, "< " + prevYear), el("strong", {style: {fontSize: "18pt"}}, args.year), el("button.next", {onclick: [api.loadYear, nextY...
javascript
{ "resource": "" }
q47948
CommentReplyView
train
function CommentReplyView(vm, comment) { var redraw = vm.redraw.bind(vm); var status = prop(LOADED, redraw); var error; var tmpComment = prop("", redraw); function toggleReplyMode(e) { status(INTERACTING); return false; } function postComment(e) { status(SUBMITTING); // TODO: flatten? dry? endPoint...
javascript
{ "resource": "" }
q47949
updateSync
train
function updateSync(newData, newParent, newIdx, withDOM, withRedraw) { var vm = this; if (newData != null) { if (vm.data !== newData) { { devNotify("DATA_REPLACED", [vm, vm.data, newData]); } fireHook(vm.hooks, "willUpdate", vm, newData); vm.data = newData; } } return withRedraw ? vm._redraw(n...
javascript
{ "resource": "" }
q47950
UInt8ArraySerializer
train
function UInt8ArraySerializer(array, buffer, bufferOffset, specArrayLen=null) { const arrLen = array.length; if (specArrayLen === null || specArrayLen < 0) { bufferOffset = buffer.writeUInt32LE(arrLen, bufferOffset, true); } buffer.set(array, bufferOffset); return bufferOffset + arrLen; }
javascript
{ "resource": "" }
q47951
hashMessage
train
function hashMessage(msg) { const sha1 = crypto.createHash('sha1'); sha1.update(msg); return sha1.digest('hex'); }
javascript
{ "resource": "" }
q47952
buildMessageClass
train
function buildMessageClass(msgSpec) { function Message(values) { if (!(this instanceof Message)) { return new Message(values); } var that = this; if (msgSpec.fields) { msgSpec.fields.forEach(function(field) { if (!field.isBuiltin) { // sub-message class // is...
javascript
{ "resource": "" }
q47953
DefaultArrayDeserializer
train
function DefaultArrayDeserializer(deserializeFunc, buffer, bufferOffset, arrayLen=null) { // interpret a negative array len as a variable length array // so we need to parse its length ourselves if (arrayLen === null || arrayLen < 0) { arrayLen = getArrayLen(buffer, bufferOffset); } const array = new Arra...
javascript
{ "resource": "" }
q47954
UInt8ArrayDeserializer
train
function UInt8ArrayDeserializer(buffer, bufferOffset, arrayLen=null) { if (arrayLen === null || arrayLen < 0) { arrayLen = getArrayLen(buffer, bufferOffset); } const array = buffer.slice(bufferOffset[0], bufferOffset[0] + arrayLen); bufferOffset[0] += arrayLen; return array; }
javascript
{ "resource": "" }
q47955
interpose
train
function interpose(coll, separator) { if (arguments.length === 1) { separator = coll; return function(xform) { return new Interpose(separator, xform); }; } return seq(coll, interpose(separator)); }
javascript
{ "resource": "" }
q47956
repeat
train
function repeat(coll, n) { if (arguments.length === 1) { n = coll; return function(xform) { return new Repeat(n, xform); }; } return seq(coll, repeat(n)); }
javascript
{ "resource": "" }
q47957
takeNth
train
function takeNth(coll, nth) { if (arguments.length === 1) { nth = coll; return function(xform) { return new TakeNth(nth, xform); }; } return seq(coll, takeNth(nth)); }
javascript
{ "resource": "" }
q47958
toArray
train
function toArray(coll, xform) { if(!xform) { return reduce(coll, arrayReducer, []); } return transduce(coll, xform, arrayReducer, []); }
javascript
{ "resource": "" }
q47959
destroy_next
train
function destroy_next() { if (old_retired_workers.length <= 0) { return deferred.resolve(); } destroyWorker.call(_self, old_retired_workers.shift().pid, reason, 0); setTimeout(destroy_next, _self.options.spawn_delay); }
javascript
{ "resource": "" }
q47960
isWorkerCmd
train
function isWorkerCmd(cmd) { cmd = cmd.concat(); // make a local copy of the array // a worker has the same command line as the current process! if (cmd.shift() !== process.execPath) return false; // execPath was used when spawning children // workers *may* have more params, we care if all master params exist in t...
javascript
{ "resource": "" }
q47961
collect_worker_stats
train
function collect_worker_stats(worker, worker_type) { var stats; var band = ('band' in worker) ? worker.band : worker.xband; stats = worker.getStats(); if (!('monitor_count' in stats)) stats.monitor_count = 1; else stats.monitor_count++; // TODO: if a given stats object has been used to many times, ...
javascript
{ "resource": "" }
q47962
rule
train
function rule(analyzer) { var debug = require('debug'); analyzer.setMetric('propertyResets'); analyzer.on('selector', function(rule, selector) { var declarations = rule.declarations || [], properties; // prepare the list of properties used in this selector properties = declarations. map(function(declar...
javascript
{ "resource": "" }
q47963
rule
train
function rule(analyzer) { analyzer.setMetric('notMinified'); /** * A simple CSS minification detector */ function isMinified(css) { // analyze the first 1024 characters css = css.trim().substring(0, 1024); // there should be no newline in minified file return /\n/.test(css) === false; } analyzer.on(...
javascript
{ "resource": "" }
q47964
rule
train
function rule(analyzer) { var re = { property: /^(\*|-ms-filter)/, selector: /^(\* html|html\s?>\s?body) /, value: /progid:DXImageTransform\.Microsoft|!ie$/ }; analyzer.setMetric('oldIEFixes'); // * html // below IE7 fix // html>body // IE6 excluded fix // @see http://blogs.msdn.com/b/ie/archive/2005/09/0...
javascript
{ "resource": "" }
q47965
request
train
function request(requestOptions, callback) { var debug = require('debug')('analyze-css:http'), fetch = require('node-fetch'); debug('GET %s', requestOptions.url); debug('Options: %j', requestOptions); fetch(requestOptions.url, requestOptions). then(function(resp) { debug('HTTP %d %s', resp.status, resp.statu...
javascript
{ "resource": "" }
q47966
runner
train
function runner(options, callback) { // call CommonJS module var analyzerOpts = { 'noOffenders': options.noOffenders, 'preprocessor': false, }; function analyze(css) { new analyzer(css, analyzerOpts, callback); } if (options.url) { debug('Fetching remote CSS file: %s', options.url); // @see https://w...
javascript
{ "resource": "" }
q47967
FileWriter
train
function FileWriter (path, opts) { if (!(this instanceof FileWriter)) return new FileWriter(path, opts); Writer.call(this, opts); this.path = path; this.file = fs.createWriteStream(path, opts); this.pipe(this.file); this.on('header', this._onHeader); }
javascript
{ "resource": "" }
q47968
checkUnique
train
async function checkUnique (options, identifyUser, ownId, meta) { debug('checkUnique', identifyUser, ownId, meta); const usersService = options.app.service(options.service); const usersServiceIdName = usersService.id; const allProps = []; const keys = Object.keys(identifyUser).filter( key => !isNu...
javascript
{ "resource": "" }
q47969
AuthManagement
train
function AuthManagement (app) { // eslint-disable-line no-unused-vars if (!(this instanceof AuthManagement)) { return new AuthManagement(app); } const authManagement = app.service('authManagement'); this.checkUnique = async (identifyUser, ownId, ifErrMsg) => await authManagement.create({ actio...
javascript
{ "resource": "" }
q47970
write
train
function write(destPath, options) { var debug = require('../debug').spawn('write'); debug(function() { return 'destPath'; }); debug(function() { return destPath; }); debug(function() { return 'original options';}); debug(function() { return options; }); if (options === undefined && typeof destPath !== 's...
javascript
{ "resource": "" }
q47971
checkPortStatus
train
function checkPortStatus (port) { var args, host, opts, callback args = [].slice.call(arguments, 1) if (typeof args[0] === 'string') { host = args[0] } else if (typeof args[0] === 'object') { opts = args[0] } else if (typeof args[0] === 'function') { callback = args[0] } if (typeof args[1] ...
javascript
{ "resource": "" }
q47972
train
function (callback) { checkPortStatus(port, host, opts, function (error, statusOfPort) { numberOfPortsChecked++ if (statusOfPort === status) { foundPort = true callback(error) } else { port = portList ? portList[numberOfPortsChecked] : port + 1 callback(null) ...
javascript
{ "resource": "" }
q47973
fullScreen
train
function fullScreen(state) { var e, func, doc; // Do nothing when nothing was selected if (!this.length) return this; // We only use the first selected element because it doesn't make sense // to fullscreen multiple elements. e = (/** @type {Element} */ this[0]); // Find the r...
javascript
{ "resource": "" }
q47974
installFullScreenHandlers
train
function installFullScreenHandlers() { var e, change, error; // Determine event name e = document; if (e["webkitCancelFullScreen"]) { change = "webkitfullscreenchange"; error = "webkitfullscreenerror"; } else if (e["msExitFullscreen"]) { change = "MSFullscree...
javascript
{ "resource": "" }
q47975
saveRouteToTheList
train
function saveRouteToTheList(parsedUrl, action) { // used to add options routes later if (typeof allRoutesList[parsedUrl.url] === 'undefined') { allRoutesList[parsedUrl.url] = []; } allRoutesList[parsedUrl.url].push(action); ...
javascript
{ "resource": "" }
q47976
decorateClassDoc
train
function decorateClassDoc(classDoc) { // Resolve all methods and properties from the classDoc. Includes inherited docs. classDoc.methods = resolveMethods(classDoc); classDoc.properties = resolveProperties(classDoc); // Call decorate hooks that can modify the method and property docs. classDoc.metho...
javascript
{ "resource": "" }
q47977
decorateMethodDoc
train
function decorateMethodDoc(methodDoc) { normalizeMethodParameters(methodDoc); // Mark methods with a `void` return type so we can omit show the return type in the docs. methodDoc.showReturns = methodDoc.returnType && methodDoc.returnType != 'void'; }
javascript
{ "resource": "" }
q47978
decoratePropertyDoc
train
function decoratePropertyDoc(propertyDoc) { propertyDoc.isDirectiveInput = isDirectiveInput(propertyDoc); propertyDoc.directiveInputAlias = getDirectiveInputAlias(propertyDoc); propertyDoc.isDirectiveOutput = isDirectiveOutput(propertyDoc); propertyDoc.directiveOutputAlias = getDirectiveOutputAlias(pro...
javascript
{ "resource": "" }
q47979
resolveMethods
train
function resolveMethods(classDoc) { let methods = classDoc.members.filter(member => member.hasOwnProperty('parameters')); if (classDoc.inheritedDoc) { methods = methods.concat(resolveMethods(classDoc.inheritedDoc)); } return methods; }
javascript
{ "resource": "" }
q47980
resolveProperties
train
function resolveProperties(classDoc) { let properties = classDoc.members.filter(member => !member.hasOwnProperty('parameters')); if (classDoc.inheritedDoc) { properties = properties.concat(resolveProperties(classDoc.inheritedDoc)); } return properties; }
javascript
{ "resource": "" }
q47981
onPageStable
train
function onPageStable() { AxeBuilder(browser.driver) .configure(this.config || {}) .analyze(results => handleResults(this, results)); }
javascript
{ "resource": "" }
q47982
handleResults
train
function handleResults(context, results) { if (checkedPages.indexOf(results.url) === -1) { checkedPages.push(results.url); results.violations.forEach(violation => { let specName = `${violation.help} (${results.url})`; let message = '\n' + buildMessage(violation); context.addFailur...
javascript
{ "resource": "" }
q47983
contains
train
function contains(container, contained, className) { var current = contained; while (current && current.ownerDocument && current.nodeType !== 11) { if (className) { if (current === container) { return false; } if (current.c...
javascript
{ "resource": "" }
q47984
intersection
train
function intersection(xArr, yArr, xFilter, yFilter, invert) { var i, j, n, filteredX, filteredY, out = invert ? [].concat(xArr) : []; for (i = 0, n = xArr.length; i < xArr.length; i++) { filteredX = xFilter ? xFilter(xArr[i]) : xArr[i]; for (j = 0; j < yArr.length; j++) { ...
javascript
{ "resource": "" }
q47985
getAction
train
function getAction(key) { const keyString = key.toString(); if (keyString.match(/CERTIFICATE\sREQUEST-{5}$/m)) { return 'req'; } else if (keyString.match(/(PUBLIC|PRIVATE)\sKEY-{5}$/m)) { return 'rsa'; } return 'x509'; }
javascript
{ "resource": "" }
q47986
generateCsr
train
async function generateCsr(opts, csrConfig, key) { let tempConfigFilePath; /* Write key to disk */ const tempKeyFilePath = tempfile(); await fs.writeFileAsync(tempKeyFilePath, key); opts.key = tempKeyFilePath; /* Write config to disk */ if (csrConfig) { tempConfigFilePath = tempfil...
javascript
{ "resource": "" }
q47987
createCsrSubject
train
function createCsrSubject(opts) { const data = { C: opts.country, ST: opts.state, L: opts.locality, O: opts.organization, OU: opts.organizationUnit, CN: opts.commonName || 'localhost', emailAddress: opts.emailAddress }; return Object.entries(data).map...
javascript
{ "resource": "" }
q47988
verifyHttpChallenge
train
async function verifyHttpChallenge(authz, challenge, keyAuthorization, suffix = `/.well-known/acme-challenge/${challenge.token}`) { debug(`Sending HTTP query to ${authz.identifier.value}, suffix: ${suffix}`); const challengeUrl = `http://${authz.identifier.value}${suffix}`; const resp = await axios.get(chal...
javascript
{ "resource": "" }
q47989
verifyDnsChallenge
train
async function verifyDnsChallenge(authz, challenge, keyAuthorization, prefix = '_acme-challenge.') { debug(`Resolving DNS TXT records for ${authz.identifier.value}, prefix: ${prefix}`); let challengeRecord = `${prefix}${authz.identifier.value}`; try { /* Attempt CNAME record first */ debug(...
javascript
{ "resource": "" }
q47990
challengeRemoveFn
train
async function challengeRemoveFn(authz, challenge, keyAuthorization) { /* Do something here */ log(JSON.stringify(authz)); log(JSON.stringify(challenge)); log(keyAuthorization); }
javascript
{ "resource": "" }
q47991
b64encode
train
function b64encode(str) { const buf = Buffer.isBuffer(str) ? str : Buffer.from(str); return b64escape(buf.toString('base64')); }
javascript
{ "resource": "" }
q47992
getPemBody
train
function getPemBody(str) { const pemStr = Buffer.isBuffer(str) ? str.toString() : str; return pemStr.replace(/(\s*-----(BEGIN|END) ([A-Z0-9- ]+)-----|\r|\n)*/g, ''); }
javascript
{ "resource": "" }
q47993
formatResponseError
train
function formatResponseError(resp) { let result; if (resp.data.error) { result = resp.data.error.detail || resp.data.error; } else { result = resp.data.detail || JSON.stringify(resp.data); } return result.replace(/\n/g, ''); }
javascript
{ "resource": "" }
q47994
forgeObjectFromPem
train
function forgeObjectFromPem(input) { const msg = forge.pem.decode(input)[0]; let key; switch (msg.type) { case 'PRIVATE KEY': case 'RSA PRIVATE KEY': key = forge.pki.privateKeyFromPem(input); break; case 'PUBLIC KEY': case 'RSA PUBLIC KEY': ...
javascript
{ "resource": "" }
q47995
createPrivateKey
train
async function createPrivateKey(size = 2048) { let pemKey; /* Native implementation */ if (nativeGenKeyPair) { const result = await nativeGenKeyPair('rsa', { modulusLength: size, publicKeyEncoding: { type: 'spki', format: 'pem' }, privateKeyEncoding: { type: 'pkc...
javascript
{ "resource": "" }
q47996
createCsrSubject
train
function createCsrSubject(subjectObj) { return Object.entries(subjectObj).reduce((result, [shortName, value]) => { if (value) { result.push({ shortName, value }); } return result; }, []); }
javascript
{ "resource": "" }
q47997
transformMedia
train
function transformMedia(media, customMedias) { const transpiledMedias = []; for (const index in media.nodes) { const { value, nodes } = media.nodes[index]; const key = value.replace(customPseudoRegExp, '$1'); if (key in customMedias) { for (const replacementMedia of customMedias[key].nodes) { // use th...
javascript
{ "resource": "" }
q47998
train
function(options) { this.options = { "debug": false, "verbose": false, "socket": "/tmp/node-mpv.sock" } this.options = _.defaults(options || {}, this.options); // intialize the event emitter eventEmitter.call(this); // socket object this.socket = new net.Socket(); // partially "fixes" the EventEmitte...
javascript
{ "resource": "" }
q47999
train
function(file, mode, options) { mode = mode || "replace"; const args = options ? [file, mode].concat(util.formatOptions(options)) : [file, mode]; this.socket.command("loadfile", args); }
javascript
{ "resource": "" }