_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q49700
LogEvent
train
function LogEvent(timestamp, level, messageTemplate, properties, error) { this.timestamp = timestamp; this.level = level; this.messageTemplate = messageTemplate; this.properties = properties || {}; this.error = error || null; }
javascript
{ "resource": "" }
q49701
MessageTemplate
train
function MessageTemplate(messageTemplate) { if (messageTemplate === null || !messageTemplate.length) { throw new Error('Argument "messageTemplate" is required.'); } this.raw = messageTemplate; this.tokens = this.tokenize(messageTemplate); }
javascript
{ "resource": "" }
q49702
Logger
train
function Logger(pipeline, suppressErrors) { this.suppressErrors = true; this.pipeline = pipeline; this.suppressErrors = typeof suppressErrors === 'undefined' || suppressErrors; }
javascript
{ "resource": "" }
q49703
ImNotTouchingYou
train
function ImNotTouchingYou(element, parent, lrOnly, tbOnly, ignoreBottom) { return OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) === 0; }
javascript
{ "resource": "" }
q49704
GetDimensions
train
function GetDimensions(elem, test){ elem = elem.length ? elem[0] : elem; if (elem === window || elem === document) { throw new Error("I'm sorry, Dave. I'm afraid I can't do that."); } var rect = elem.getBoundingClientRect(), parRect = elem.parentNode.getBoundingClientRect(), winRect = document...
javascript
{ "resource": "" }
q49705
hideHandler
train
function hideHandler( e ) { var inContainer = moduleFilter.contains( e.target ); if ( e.keyCode === 27 || !inContainer ) { if ( e.keyCode === 27 && inContainer ) { moduleSearch.focus(); } dropDown.style.display = "none"; removeEvent( document, "click", hideHandler ); removeEvent...
javascript
{ "resource": "" }
q49706
searchInput
train
function searchInput() { var i, item, searchText = moduleSearch.value.toLowerCase(), listItems = dropDownList.children; for ( i = 0; i < listItems.length; i++ ) { item = listItems[ i ]; if ( !searchText || item.textContent.toLowerCase().indexOf( searchText ) > -1 ) { item.style.display = "";...
javascript
{ "resource": "" }
q49707
emCalc
train
function emCalc(em) { return parseInt(window.getComputedStyle(document.body, null).fontSize, 10) * em; }
javascript
{ "resource": "" }
q49708
indent
train
function indent(extra) { if (!this.multiline) { return ""; } var chr = this.indentChar; if (this.HTML) { chr = chr.replace(/\t/g, " ").replace(/ /g, "&#160;"); } return new Array(this.depth + (extra || 0)).join(chr); }
javascript
{ "resource": "" }
q49709
on
train
function on(eventName, callback) { if (objectType(eventName) !== "string") { throw new TypeError("eventName must be a string when registering a listener"); } else if (!inArray(eventName, SUPPORTED_EVENTS)) { var events = SUPPORTED_EVENTS.join(", "); throw new Error("\"" + eventName + "\" is not a vali...
javascript
{ "resource": "" }
q49710
registerLoggingCallbacks
train
function registerLoggingCallbacks(obj) { var i, l, key, callbackNames = ["begin", "done", "log", "testStart", "testDone", "moduleStart", "moduleDone"]; function registerLoggingCallback(key) { var loggingCallback = function loggingCallback(callback) { if (objectType(callback) !== "fu...
javascript
{ "resource": "" }
q49711
done
train
function done() { var storage = config.storage; ProcessingQueue.finished = true; var runtime = now() - config.started; var passed = config.stats.all - config.stats.bad; emit("runEnd", globalSuite.end(true)); runLoggingCallbacks("done", { passed: passed, failed: config.stats.bad, total: ...
javascript
{ "resource": "" }
q49712
internalStop
train
function internalStop(test) { test.semaphore += 1; config.blocking = true; // Set a recovery timeout, if so configured. if (defined.setTimeout) { var timeoutDuration = void 0; if (typeof test.timeout === "number") { timeoutDuration = test.timeout; } else if (typeof config.testTimeout === ...
javascript
{ "resource": "" }
q49713
internalStart
train
function internalStart(test) { // If semaphore is non-numeric, throw error if (isNaN(test.semaphore)) { test.semaphore = 0; pushFailure("Invalid value on test.semaphore", sourceFromStacktrace(2)); return; } // Don't start until equal number of stop-calls if (test.semaphore > 0) { retur...
javascript
{ "resource": "" }
q49714
onError
train
function onError(error) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } if (config.current) { if (config.current.ignoreGlobalErrors) { return true; } pushFailure.apply(undefined, [error.message...
javascript
{ "resource": "" }
q49715
storeFixture
train
function storeFixture() { // Avoid overwriting user-defined values if (hasOwn.call(config, "fixture")) { return; } var fixture = document.getElementById("qunit-fixture"); if (fixture) { config.fixture = fixture.innerHTML; } }
javascript
{ "resource": "" }
q49716
resetFixture
train
function resetFixture() { if (config.fixture == null) { return; } var fixture = document.getElementById("qunit-fixture"); if (fixture) { fixture.innerHTML = config.fixture; } }
javascript
{ "resource": "" }
q49717
train
function (lang, elt) { var data = lang_data[lang]; if (!data) { data = lang_data[lang] = {}; } // Look for additional dependencies defined on the <code> or <pre> tags var deps = elt.getAttribute('data-dependencies'); if (!deps && elt.parentNode && elt.parentNode.tagName.toLowerCase() === 'pre') { dep...
javascript
{ "resource": "" }
q49718
train
function (langs, success, error) { if (typeof langs === 'string') { langs = [langs]; } var i = 0; var l = langs.length; var f = function () { if (i < l) { loadLanguage(langs[i], function () { i++; f(); }, function () { error && error(langs[i]); }); } else if (i === l) { ...
javascript
{ "resource": "" }
q49719
train
function (lang, success, error) { var load = function () { var force = false; // Do we want to force reload the grammar? if (lang.indexOf('!') >= 0) { force = true; lang = lang.replace('!', ''); } var data = lang_data[lang]; if (!data) { data = lang_data[lang] = {}; } if (success)...
javascript
{ "resource": "" }
q49720
train
function (lang) { if (lang_data[lang] && lang_data[lang].success_callbacks && lang_data[lang].success_callbacks.length) { lang_data[lang].success_callbacks.forEach(function (f) { f(lang); }); } }
javascript
{ "resource": "" }
q49721
train
function (lang) { if (lang_data[lang] && lang_data[lang].error_callbacks && lang_data[lang].error_callbacks.length) { lang_data[lang].error_callbacks.forEach(function (f) { f(lang); }); } }
javascript
{ "resource": "" }
q49722
train
function(plugin, name) { // Object key to use when adding to global Foundation object // Examples: Foundation.Reveal, Foundation.OffCanvas var className = (name || functionName(plugin)); // Object key to use when storing the plugin, also used to create the identifying data attribute for the plugin /...
javascript
{ "resource": "" }
q49723
train
function (func, delay) { var timer = null; return function () { var context = this, args = arguments; if (timer === null) { timer = setTimeout(function () { func.apply(context, args); timer = null; }, delay); } }; }
javascript
{ "resource": "" }
q49724
functionName
train
function functionName(fn) { if (Function.prototype.name === undefined) { var funcNameRegex = /function\s([^(]{1,})\(/; var results = (funcNameRegex).exec((fn).toString()); return (results && results.length > 1) ? results[1].trim() : ""; } else if (fn.prototype === undefined) { return fn.constructo...
javascript
{ "resource": "" }
q49725
GetYoDigits
train
function GetYoDigits(length, namespace){ length = length || 6; return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1) + (namespace ? `-${namespace}` : ''); }
javascript
{ "resource": "" }
q49726
ResponsiveAccordionTabs
train
function ResponsiveAccordionTabs(element, options) { _classCallCheck(this, ResponsiveAccordionTabs); this.$element = $(element); this.options = $.extend({}, this.$element.data(), options); this.rules = this.$element.data('responsive-accordion-tabs'); this.currentMq = null; this.curr...
javascript
{ "resource": "" }
q49727
advance
train
function advance() { const start = now(); config.depth = ( config.depth || 0 ) + 1; while ( config.queue.length && !config.blocking ) { const elapsedTime = now() - start; if ( !defined.setTimeout || config.updateRate <= 0 || elapsedTime < config.updateRate ) { if ( priorityCount > 0 ) { priorityCount--;...
javascript
{ "resource": "" }
q49728
addToQueue
train
function addToQueue( callback, prioritize, seed ) { if ( prioritize ) { config.queue.splice( priorityCount++, 0, callback ); } else if ( seed ) { if ( !unitSampler ) { unitSampler = unitSamplerGenerator( seed ); } // Insert into a random position after all prioritized items const index = Math.floor( uni...
javascript
{ "resource": "" }
q49729
unitSamplerGenerator
train
function unitSamplerGenerator( seed ) { // 32-bit xorshift, requires only a nonzero seed // http://excamera.com/sphinx/article-xorshift.html let sample = parseInt( generateHash( seed ), 16 ) || -1; return function() { sample ^= sample << 13; sample ^= sample >>> 17; sample ^= sample << 5; // ECMAScript ha...
javascript
{ "resource": "" }
q49730
loadLanguage
train
function loadLanguage (lang) { // at first we need to fetch all dependencies for the main language // Note: we need to do this, even if the main language already is loaded (just to be sure..) // // We load an array of all dependencies and call recursively this function on each entry // // dependencies is now an (...
javascript
{ "resource": "" }
q49731
getMultipleSelectors
train
function getMultipleSelectors(selector) { if (Array.isArray(selector)) { var section_selector = selector[0].selector; var real_selector = selector[1].selector; return [section_selector, real_selector]; } else { return selector; } }
javascript
{ "resource": "" }
q49732
assertion
train
function assertion(selector, attribute, regexp) { var _this = this; var msg = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; this.message = msg; if (!this.message) { this.message = _util2.default.format('Testing if element <%s> has attribute <%s> that matches %s', selector, attribute,...
javascript
{ "resource": "" }
q49733
shouldAnimate
train
function shouldAnimate () { // Don’t animate while dragging if (pointerIsDown) return false const finished = current === target && Math.abs(currentSpeed) < 0.5 return !finished }
javascript
{ "resource": "" }
q49734
update
train
function update () { const bestSpeed = (target - current) * springK currentSpeed = linearlyApproach(currentSpeed, bestSpeed, acceleration) current += currentSpeed if (Math.abs(current - target) < 0.1) { current = target } }
javascript
{ "resource": "" }
q49735
linearlyApproach
train
function linearlyApproach (current, target, delta) { if (Math.abs(current - target) < delta) { return target } else if (current < target) { return current + delta } else { return current - delta } }
javascript
{ "resource": "" }
q49736
getProjection
train
function getProjection () { let projection = current let speed = currentSpeed for (let i = 0; i < 600; i++) { const targetSpeed = speed * (1 - springK) speed = linearlyApproach(speed, targetSpeed, acceleration) projection += speed } return projection }
javascript
{ "resource": "" }
q49737
getTargetAngle
train
function getTargetAngle (projection, flipped) { const offset = flipped ? 180 : 0 return Math.round((projection - offset - 1) / 360) * 360 + offset }
javascript
{ "resource": "" }
q49738
getAllTags
train
function getAllTags(version, cwd, repo, cb) { var str = 'git for-each-ref --format="%(tag)" --sort=\'*authordate\' refs/tags | sed \'1!G;h;$!d\''; exec(str, {cwd: cwd}, function (err, stdout, stderr) { var output = ''; if (err) { return cb(err); } var stdoutAsString = stdout.toString('utf8'); //...
javascript
{ "resource": "" }
q49739
runChromeDevTools
train
function runChromeDevTools(context) { var data = fs.readFileSync(AUDIT_FILE, 'utf-8'); data = data + ' var configuration = new axs.AuditConfiguration(' + JSON.stringify(context.config.chromeA11YDevTools.auditConfiguration) + '); return axs.Audit.run(configuration);'; var elementPromises = [], elementStrin...
javascript
{ "resource": "" }
q49740
train
function (utf16Str) { // Shortcut var utf16StrLength = utf16Str.length; // Convert var words = []; for (var i = 0; i < utf16StrLength; i++) { words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); } ...
javascript
{ "resource": "" }
q49741
train
function (msg, src) { /* globals console */ if (TinCan.DEBUG && typeof console !== "undefined" && console.log) { src = src || this.LOG_SRC || "TinCan"; console.log("TinCan." + src + ": " + msg); } }
javascript
{ "resource": "" }
q49742
train
function (stmt, callback) { this.log("sendStatement"); // would prefer to use .bind instead of 'self' var self = this, lrs, statement = this.prepareStatement(stmt), rsCount = this.recordStores.length, i, ...
javascript
{ "resource": "" }
q49743
train
function (stmtId, callback, cfg) { this.log("getStatement"); var lrs; cfg = cfg || {}; cfg.params = cfg.params || {}; if (this.recordStores.length > 0) { // // for statements (for now) we only need to read from the first LRS ...
javascript
{ "resource": "" }
q49744
train
function (stmtId, callback) { this.log("getVoidedStatement"); var lrs; if (this.recordStores.length > 0) { // // for statements (for now) we only need to read from the first LRS // in the future it may make sense to get all from all L...
javascript
{ "resource": "" }
q49745
train
function (stmts, callback) { this.log("sendStatements"); var self = this, lrs, statements = [], rsCount = this.recordStores.length, i, results = [], callbackWrapper, callbackResults = ...
javascript
{ "resource": "" }
q49746
train
function (prop, lang) { var langDict = this[prop], key; if (typeof lang !== "undefined" && typeof langDict[lang] !== "undefined") { return langDict[lang]; } if (typeof langDict.und !== "undefined") { return langDict.und; ...
javascript
{ "resource": "" }
q49747
train
function (cfg) { this.log("sendRequest"); var fullUrl = this.endpoint + cfg.url, headers = {}, prop ; // respect absolute URLs passed in if (cfg.url.indexOf("http") === 0) { fullUrl = cfg.url; } ...
javascript
{ "resource": "" }
q49748
train
function (cfg) { this.log("about"); var requestCfg, requestResult, callbackWrapper; cfg = cfg || {}; requestCfg = { url: "about", method: "GET", params: {} }; if (typ...
javascript
{ "resource": "" }
q49749
train
function (stmt, cfg) { this.log("saveStatement"); var requestCfg = { url: "statements", headers: {} }, versionedStatement, requestAttachments = [], boundary, i; cf...
javascript
{ "resource": "" }
q49750
train
function (stmtId, cfg) { this.log("retrieveStatement"); var requestCfg, requestResult, callbackWrapper, lrs = this; cfg = cfg || {}; cfg.params = cfg.params || {}; requestCfg = { url: "statement...
javascript
{ "resource": "" }
q49751
train
function (cfg) { this.log("queryStatements"); var requestCfg, requestResult, callbackWrapper, lrs = this; cfg = cfg || {}; cfg.params = cfg.params || {}; // // if they misconfigured (possibly due to...
javascript
{ "resource": "" }
q49752
train
function (cfg) { this.log("moreStatements: " + cfg.url); var requestCfg, requestResult, callbackWrapper, parsedURL, serverRoot; cfg = cfg || {}; // to support our interface (to support IE) we need to break ...
javascript
{ "resource": "" }
q49753
train
function (key, cfg) { this.log("retrieveState"); var requestParams = {}, requestCfg = {}, requestResult, callbackWrapper, requestHeaders, self = this; requestHeaders = cfg.requestHeaders || {}; ...
javascript
{ "resource": "" }
q49754
train
function (cfg) { this.log("retrieveStateIds"); var requestParams = {}, requestCfg, requestHeaders, requestResult, callbackWrapper; cfg = cfg || {}; requestHeaders = cfg.requestHeaders || {}; req...
javascript
{ "resource": "" }
q49755
train
function (key, val, cfg) { this.log("saveState"); var requestParams, requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet...
javascript
{ "resource": "" }
q49756
train
function (key, cfg) { this.log("dropState"); var requestParams, requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; requestParams = { activityId: cfg.activity.id }; if (this.versi...
javascript
{ "resource": "" }
q49757
train
function (activityId, cfg) { this.log("retrieveActivity"); var requestCfg = {}, requestResult, callbackWrapper, requestHeaders; requestHeaders = cfg.requestHeaders || {}; requestCfg = { url: "activities", ...
javascript
{ "resource": "" }
q49758
train
function (cfg) { this.log("retrieveActivityProfileIds"); var requestCfg, requestHeaders, requestResult, callbackWrapper; cfg = cfg || {}; requestHeaders = cfg.requestHeaders || {}; requestCfg = { ...
javascript
{ "resource": "" }
q49759
train
function (key, val, cfg) { this.log("saveActivityProfile"); var requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet-stream"; ...
javascript
{ "resource": "" }
q49760
train
function (key, cfg) { this.log("dropActivityProfile"); var requestParams, requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; requestParams = { profileId: key, activityId: cfg.activity.id...
javascript
{ "resource": "" }
q49761
train
function (key, cfg) { this.log("retrieveAgentProfile"); var requestCfg = {}, requestResult, callbackWrapper, requestHeaders, self = this; requestHeaders = cfg.requestHeaders || {}; requestCfg = { ...
javascript
{ "resource": "" }
q49762
train
function (key, val, cfg) { this.log("saveAgentProfile"); var requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet-stream"; } ...
javascript
{ "resource": "" }
q49763
train
function (key, cfg) { this.log("dropAgentProfile"); var requestParams, requestCfg, requestHeaders; requestHeaders = cfg.requestHeaders || {}; requestParams = { profileId: key }; requestCfg = { ...
javascript
{ "resource": "" }
q49764
train
function () { this.log("hasAttachmentWithContent"); var i; if (this.attachments === null) { return false; } for (i = 0; i < this.attachments.length; i += 1) { if (this.attachments[i].content !== null) { ret...
javascript
{ "resource": "" }
q49765
train
function(token) { if (Array.isArray(token)) { var tokens = /**@type {!Array.<number>}*/(token); while (tokens.length) this.tokens.push(tokens.pop()); } else { this.tokens.push(token); } }
javascript
{ "resource": "" }
q49766
train
function(token) { if (Array.isArray(token)) { var tokens = /**@type {!Array.<number>}*/(token); while (tokens.length) this.tokens.unshift(tokens.shift()); } else { this.tokens.unshift(token); } }
javascript
{ "resource": "" }
q49767
TextDecoder
train
function TextDecoder(label, options) { // Web IDL conventions if (!(this instanceof TextDecoder)) throw TypeError('Called as a function. Did you forget \'new\'?'); label = label !== undefined ? String(label) : DEFAULT_ENCODING; options = ToDictionary(options); // A TextDecoder object has an a...
javascript
{ "resource": "" }
q49768
serializeStream
train
function serializeStream(stream) { // 1. Let token be the result of reading from stream. // (Done in-place on array, rather than as a stream) // 2. If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore // BOM flag and BOM seen flag are unset, run these subsubsteps: if (includes(['UTF-8'...
javascript
{ "resource": "" }
q49769
TextEncoder
train
function TextEncoder(label, options) { // Web IDL conventions if (!(this instanceof TextEncoder)) throw TypeError('Called as a function. Did you forget \'new\'?'); options = ToDictionary(options); // A TextEncoder object has an associated encoding and encoder. /** @private */ this._encod...
javascript
{ "resource": "" }
q49770
UTF8Encoder
train
function UTF8Encoder(options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { // 1. If c...
javascript
{ "resource": "" }
q49771
SingleByteDecoder
train
function SingleByteDecoder(index, options) { var fatal = options.fatal; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte read from the stream. * @return {?(number|!Array.<number>)} The next code point(s) * decoded, or null if not enough...
javascript
{ "resource": "" }
q49772
GB18030Decoder
train
function GB18030Decoder(options) { var fatal = options.fatal; // gb18030's decoder has an associated gb18030 first, gb18030 // second, and gb18030 third (all initially 0x00). var /** @type {number} */ gb18030_first = 0x00, /** @type {number} */ gb18030_second = 0x00, /** @type {number} *...
javascript
{ "resource": "" }
q49773
GB18030Encoder
train
function GB18030Encoder(options, gbk_flag) { var fatal = options.fatal; // gb18030's decoder has an associated gbk flag (initially unset). /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s)...
javascript
{ "resource": "" }
q49774
Big5Decoder
train
function Big5Decoder(options) { var fatal = options.fatal; // big5's decoder has an associated big5 lead (initially 0x00). var /** @type {number} */ big5_lead = 0x00; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte read from the stream. ...
javascript
{ "resource": "" }
q49775
Big5Encoder
train
function Big5Encoder(options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { // 1. If c...
javascript
{ "resource": "" }
q49776
EUCJPDecoder
train
function EUCJPDecoder(options) { var fatal = options.fatal; // euc-jp's decoder has an associated euc-jp jis0212 flag // (initially unset) and euc-jp lead (initially 0x00). var /** @type {boolean} */ eucjp_jis0212_flag = false, /** @type {number} */ eucjp_lead = 0x00; /** * @param {St...
javascript
{ "resource": "" }
q49777
ISO2022JPEncoder
train
function ISO2022JPEncoder(options) { var fatal = options.fatal; // iso-2022-jp's encoder has an associated iso-2022-jp encoder // state which is one of ASCII, Roman, and jis0208 (initially // ASCII). /** @enum */ var states = { ASCII: 0, Roman: 1, jis0208: 2 }; var /** ...
javascript
{ "resource": "" }
q49778
ShiftJISDecoder
train
function ShiftJISDecoder(options) { var fatal = options.fatal; // shift_jis's decoder has an associated shift_jis lead (initially // 0x00). var /** @type {number} */ shiftjis_lead = 0x00; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte r...
javascript
{ "resource": "" }
q49779
ShiftJISEncoder
train
function ShiftJISEncoder(options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { // 1. ...
javascript
{ "resource": "" }
q49780
EUCKRDecoder
train
function EUCKRDecoder(options) { var fatal = options.fatal; // euc-kr's decoder has an associated euc-kr lead (initially 0x00). var /** @type {number} */ euckr_lead = 0x00; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte read from the strea...
javascript
{ "resource": "" }
q49781
EUCKREncoder
train
function EUCKREncoder(options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { // 1. If ...
javascript
{ "resource": "" }
q49782
convertCodeUnitToBytes
train
function convertCodeUnitToBytes(code_unit, utf16be) { // 1. Let byte1 be code unit >> 8. var byte1 = code_unit >> 8; // 2. Let byte2 be code unit & 0x00FF. var byte2 = code_unit & 0x00FF; // 3. Then return the bytes in order: // utf-16be flag is set: byte1, then byte2. if (utf16be) ...
javascript
{ "resource": "" }
q49783
UTF16Decoder
train
function UTF16Decoder(utf16_be, options) { var fatal = options.fatal; var /** @type {?number} */ utf16_lead_byte = null, /** @type {?number} */ utf16_lead_surrogate = null; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte read from the st...
javascript
{ "resource": "" }
q49784
UTF16Encoder
train
function UTF16Encoder(utf16_be, options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { ...
javascript
{ "resource": "" }
q49785
XUserDefinedDecoder
train
function XUserDefinedDecoder(options) { var fatal = options.fatal; /** * @param {Stream} stream The stream of bytes being decoded. * @param {number} bite The next byte read from the stream. * @return {?(number|!Array.<number>)} The next code point(s) * decoded, or null if not enough data...
javascript
{ "resource": "" }
q49786
XUserDefinedEncoder
train
function XUserDefinedEncoder(options) { var fatal = options.fatal; /** * @param {Stream} stream Input stream. * @param {number} code_point Next code point read from the stream. * @return {(number|!Array.<number>)} Byte(s) to emit. */ this.handler = function(stream, code_point) { //...
javascript
{ "resource": "" }
q49787
exchangeLR
train
function exchangeLR(offset, mask) { var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; this._rBlock ^= t; this._lBlock ^= t << offset; }
javascript
{ "resource": "" }
q49788
train
function (xformMode, key, cfg) { // Apply config defaults this.cfg = this.cfg.extend(cfg); // Store transform mode and key this._xformMode = xformMode; this._key = key; // Set initial values this.reset(); }
javascript
{ "resource": "" }
q49789
train
function (cipher, ciphertext, key, cfg) { // Apply config defaults cfg = this.cfg.extend(cfg); // Convert string to CipherParams ciphertext = this._parse(ciphertext, cfg.format); // Decrypt var plaintext = cipher.createDecryptor(key, cfg)...
javascript
{ "resource": "" }
q49790
validateOptions
train
function validateOptions (options) { if (typeof options.apiKey !== 'string') { throw new Error('You must provide a valid API key to upload sourcemaps to Bugsnag.') } if (typeof options.sourceMap !== 'string') { throw new Error('You must provide a path to the source map you want to upload.') } if (opti...
javascript
{ "resource": "" }
q49791
stripProjectRoot
train
function stripProjectRoot (projectRoot, filePath) { if (typeof filePath === 'string') { // Check whether the path is an posix absolute file, otherwise check whether it's a // win32 valid absolute file. The order is important here because win32 treats posix // absolute paths as absolute, but posix doesn't ...
javascript
{ "resource": "" }
q49792
readFileJSON
train
function readFileJSON (path) { return new Promise((resolve, reject) => { fs.readFile(path, (err, data) => { if (err) { reject(err) return } try { const json = JSON.parse(String(data)) resolve(json) } catch (err) { reject(err) } }) }) }
javascript
{ "resource": "" }
q49793
transformSourcesMap
train
function transformSourcesMap (options) { return ( readFileJSON(options.sourceMap) .then(sourceMap => ( mapSources(sourceMap, path => { const relativePath = stripProjectRoot(options.projectRoot, path) return doesFileExist(path).then(exists => { if (exists && options.up...
javascript
{ "resource": "" }
q49794
transformOptions
train
function transformOptions (options) { if (options.codeBundleId && options.appVersion) { delete options.appVersion } if (options.addWildcardPrefix && options.minifiedUrl) { if (options.minifiedUrl.indexOf('://') === -1 && options.minifiedUrl[0] !== '*') { options.minifiedUrl = '*' + options.minifiedUrl } ...
javascript
{ "resource": "" }
q49795
sendRequest
train
function sendRequest (args) { // { options, formData } const options = args.options const formData = args.formData return request(options.endpoint, formData).then(() => options) }
javascript
{ "resource": "" }
q49796
cleanupTempFiles
train
function cleanupTempFiles (options) { return new Promise((resolve, reject) => { if (options.tempDir) { if (path.dirname(options.sourceMap) === options.tempDir) { fs.unlinkSync(options.sourceMap) } fs.rmdir(options.tempDir, (err) => { if (err) { reject(err) } els...
javascript
{ "resource": "" }
q49797
upload
train
function upload (options, callback) { const promise = ( Promise.resolve(options) .then(applyDefaults) .then(validateOptions) .then(opts => { options = opts return options }) .then(transformOptions) .then(prepareRequest) .then(sendRequest) .catch(err ...
javascript
{ "resource": "" }
q49798
createWriteHead
train
function createWriteHead (prevWriteHead, listener) { var fired = false // return function with core name and argument list return function writeHead (statusCode) { // set headers from arguments var args = setWriteHeadHeaders.apply(this, arguments) // fire listener if (!fired) { fired = tru...
javascript
{ "resource": "" }
q49799
onHeaders
train
function onHeaders (res, listener) { if (!res) { throw new TypeError('argument res is required') } if (typeof listener !== 'function') { throw new TypeError('argument listener must be a function') } res.writeHead = createWriteHead(res.writeHead, listener) }
javascript
{ "resource": "" }