_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q56000
train
function() { if (typeof this.varsData !== 'string') { if (!this.varsFile) throw 'No theme variables file specified.'; this.varsFile
javascript
{ "resource": "" }
q56001
train
function(source) { if (typeof source === 'object') { this.ast = source; } else if (typeof source === 'string') { // JSON source: if (isJSON(source)) { this.ast = JSON.parse(source); } // Sass source: else {
javascript
{ "resource": "" }
q56002
train
function(opts) { var opts = opts || {}; this._template = !!(opts.hasOwnProperty('template') ? opts.template : this.template); this._treeRemoval = !!(opts.hasOwnProperty('treeRemoval') ? opts.treeRemoval : this.treeRemoval);
javascript
{ "resource": "" }
q56003
train
function(parent) { function error(usage) { return new Error('Template theme fields are not permitted '+ usage +':\n>>> '+ Node.toString(parent)); } // Check for arguments implementation: if (parent.type === NodeType.ARGUMENTS) { throw error('as arguments'); } // Check for interpola...
javascript
{ "resource": "" }
q56004
train
function(field) { if (this.vars.hasOwnProperty(field)) { if (!this.usage.hasOwnProperty(field)) {
javascript
{ "resource": "" }
q56005
train
function(field) { if (this._template) { var match = field.match(this.fieldRegex); return match &&
javascript
{ "resource": "" }
q56006
train
function(opts, done) { if (typeof opts !== 'object') { done = opts; opts = null; } validateCallback(done);
javascript
{ "resource": "" }
q56007
train
function(done) { var isSync = (typeof done !== 'function'); var sass = require('node-sass'); var opts = this.sassCSSOptions(); if (isSync) { try { return sass.renderSync(opts).css.toString(); } catch (err) { throw formatSassError(err, opts.data); } }
javascript
{ "resource": "" }
q56008
train
function(opts, done) { if (typeof opts !== 'object') { done = opts; opts = {}; } validateCallback(done); opts.template = true;
javascript
{ "resource": "" }
q56009
train
function(done) { var isSync = (typeof done !== 'function'); var sass = require('node-sass'); var opts = this.sassTemplateOptions(); var self = this; if (isSync) { try { var result = sass.renderSync(opts); return this.fieldIdentifiersToInterpolations(result.css.toString()); ...
javascript
{ "resource": "" }
q56010
train
function(sass) { var match; while ((match = this.fieldRegexAll.exec(sass)) !== null) { if (this.vars.hasOwnProperty(match[1])) {
javascript
{ "resource": "" }
q56011
formatSassError
train
function formatSassError(err, data) { // Generate three-line preview around the error: var preview = data.split('\n'); preview = preview.slice(Math.max(0, err.line-2), Math.min(err.line+1, preview.length-1)); preview = preview.map(function(src) { return '>>> '+ src }); preview.unshift(err.message);
javascript
{ "resource": "" }
q56012
train
function(base) { for (var i=1; i < arguments.length; i++) { var ext = arguments[i]; for (var key in ext) {
javascript
{ "resource": "" }
q56013
train
function(opts) { return this.extend(gonzales.createNode({ type: 'stylesheet', syntax: 'scss', content: [],
javascript
{ "resource": "" }
q56014
train
function(parentFile, importedFile) { if (parentFile.includedFiles.indexOf(importedFile.file) < 0) { // Add imported file reference: parentFile.includedFiles.push(importedFile.file); // Add all
javascript
{ "resource": "" }
q56015
train
function(file) { if (!AST.cache) { return; } else if (typeof file === 'string') { if (!AST.cache[file]) AST.cache[file]
javascript
{ "resource": "" }
q56016
Importer
train
function Importer(opts) { var self = this; opts = opts || {}; EventEmitter.call(this); this.cwd = opts.cwd ? path.resolve(opts.cwd) : process.cwd(); this.file = opts.file ? path.resolve(opts.cwd, opts.file) : this.cwd; this.data = opts.data; this.includePaths = opts.includePaths || [];
javascript
{ "resource": "" }
q56017
train
function(done) { this.async = true; var self = this; function finish(err, file) { var hasCallback = (typeof done === 'function'); if (err && !hasCallback) return self.emit('error', err); if (err) return done(err); done(null, file); } if (this.data) { this.createFile(t...
javascript
{ "resource": "" }
q56018
train
function() { this.async = false; var file; if (this.data) { file = this.createFile(this.file, this.uri, this.file, this.data); } else { file =
javascript
{ "resource": "" }
q56019
File
train
function File(filepath, data, importer) { this.file = filepath; this.data = data; this.importer = importer;
javascript
{ "resource": "" }
q56020
sectorify
train
function sectorify(file, ssz) { var nsectors = Math.ceil(file.length/ssz)-1; var sectors = new Array(nsectors); for(var i=1; i < nsectors; ++i) sectors[i-1] =
javascript
{ "resource": "" }
q56021
makePath
train
function makePath(object, path, index) { index = index || 0; var obj; if (path.length > index + 1) { obj = object[path[index]]; // we always want the last object in an array if (_.isArray(obj)) obj = _.last(obj); makePath(obj, path, index + 1); } else { obj = object[path[index]]; if (!obj)...
javascript
{ "resource": "" }
q56022
setValueForPath
train
function setValueForPath(object, path, value, index) { index = index || 0; if (path.length > index + 1) { var obj = object[path[index]]; // we always want the last object in an array if (_.isArray(obj)) obj = _.last(obj);
javascript
{ "resource": "" }
q56023
overwriteFile
train
function overwriteFile(path, options) { let fileContent = null; let newData = null; try { fileContent = fs.readFileSync(path, 'utf8'); newData = visit(JSON.parse(fileContent), options); } catch (e) { console.error('Failed to retrieve json object from file'); throw e; } let indent; if (o...
javascript
{ "resource": "" }
q56024
overwrite
train
function overwrite(absolutePaths, options) { const paths = Array.isArray(absolutePaths) ? absolutePaths : [absolutePaths]; const results = paths.map(path =>
javascript
{ "resource": "" }
q56025
visit
train
function visit(old, options) { const sortOptions = options || {}; const ignoreCase = sortOptions.ignoreCase || false; const reverse = sortOptions.reverse || false; const depth = sortOptions.depth || Infinity; const level = sortOptions.level || 1; const processing = level <= depth; if (typeof (old) !== '...
javascript
{ "resource": "" }
q56026
fetchOrders
train
function fetchOrders() { return new Promise((resolve, reject) => { https.get('https://services.odata.org/V4/Northwind/Northwind.svc/Orders', (result) => { var str = '';
javascript
{ "resource": "" }
q56027
prepareDataSource
train
async function prepareDataSource() { const orders = await fetchOrders() const ordersByShipCountry = orders.reduce((a, v) => { a[v.ShipCountry] = a[v.ShipCountry] || [] a[v.ShipCountry].push(v) return a }, {}) return Object.keys(ordersByShipCountry).map((country) => { con...
javascript
{ "resource": "" }
q56028
buildFailureParams
train
function buildFailureParams (test) { const opts = test.error.operator ? { type: test.error.operator, message: test.raw } : { message: test.raw
javascript
{ "resource": "" }
q56029
fetchAndInstantiate
train
function fetchAndInstantiate(url, importObject) { return fetch(url).then(response => response.arrayBuffer()
javascript
{ "resource": "" }
q56030
openDatabase
train
function openDatabase() { return new Promise((resolve, reject) => { var request = indexedDB.open(dbName, dbVersion); request.onerror = reject.bind(null, 'Error opening wasm cache database'); request.onsuccess = () => { resolve(request.result) }; request.onupgradeneeded = event => { v...
javascript
{ "resource": "" }
q56031
lookupInDatabase
train
function lookupInDatabase(db) { return new Promise((resolve, reject) => { var store = db.transaction([storeName]).objectStore(storeName); var request = store.get(url);
javascript
{ "resource": "" }
q56032
storeInDatabase
train
function storeInDatabase(db, module) { var store = db.transaction([storeName], 'readwrite').objectStore(storeName); try { var request = store.put(module, url); request.onerror = err => { console.log(`Failed to store in wasm cache: ${err}`) };
javascript
{ "resource": "" }
q56033
fetchAndInstantiate
train
function fetchAndInstantiate() { return fetch(url).then(response =>
javascript
{ "resource": "" }
q56034
Promise
train
function Promise(back) { this.emitter = new EventEmitter(); this.emitted = {}; this.ended = false;
javascript
{ "resource": "" }
q56035
train
function (root) { var current = root.prototype ? root.prototype.addEventListener : root.addEventListener; var customAddEventListener = function (name, func, capture) { // Branch when a PointerXXX is used if (supportedEventsNames.indexOf(name) !== -1) { setTouchAw...
javascript
{ "resource": "" }
q56036
train
function (root) { var current = root.prototype ? root.prototype.removeEventListener : root.removeEventListener; var customRemoveEventListener = function (name, func, capture) { // Release when a PointerXXX is used if (supportedEventsNames.indexOf(name) !== -1) { ...
javascript
{ "resource": "" }
q56037
pointerDown
train
function pointerDown(e) { // don't register an activePointer if more than one touch is active. var singleFinger = e.pointerType === POINTER_TYPE_MOUSE || e.pointerType === POINTER_TYPE_PEN || (e.pointerType === POINTER_TYPE_TOUCH && e.isPrimary);
javascript
{ "resource": "" }
q56038
pointerUp
train
function pointerUp(e) { // Does our event is the same as the activePointer set by pointerdown? if (activePointer && activePointer.id === e.pointerId) { // Have we moved too much? if (Math.abs(activePointer.x - (e.x || e.pageX)) < 5 && Math.abs(activePointer.y - (e...
javascript
{ "resource": "" }
q56039
makePointertapEvent
train
function makePointertapEvent(sourceEvent) { var evt = document.createEvent('MouseEvents'); var newTarget = document.elementFromPoint(sourceEvent.clientX, sourceEvent.clientY); // According to the MDN docs if the specified point is outside the visible bounds of the document // or either ...
javascript
{ "resource": "" }
q56040
train
function() { _cbt = require('./cbt')(); _options = options || {}; // apply defaults // the min bytes of an incoming reply _options.minBytes = _options.minBytes || 1; // the max bytes of an incoming reply _options.maxBytes = _options.maxBytes || 1024 * 1024; // the group the client wi...
javascript
{ "resource": "" }
q56041
train
function (cb) { _metaBroker.tearUp(function (err) { if (!err) {
javascript
{ "resource": "" }
q56042
train
function(params, cb) { cb = cb || _noop; assert(params.topic); _metaBroker.metadata([params.topic], function(err, cluster) { cluster.topics.forEach(function(topic) {
javascript
{ "resource": "" }
q56043
train
function() { if (_polling) { _closing = true; setTimeout(function() { if( _closing) { _.each(_brokers, function(broker) { broker.tearDown(); }); }
javascript
{ "resource": "" }
q56044
set
train
function set(key, value, options) { options = typeof options ==='object' ? options : { expires: options }; let expires = options.expires != null ? options.expires : defaults.expires; if (typeof expires === 'string' && expires !== '') { expires = new Date(expires); } else if (typeof expires ===...
javascript
{ "resource": "" }
q56045
train
function(topics, cb) { var correlationId = _cbt.put(metaResponse(cb)); var msg = envelope(meta.encode() .correlation(correlationId) .client(_options.clientId)
javascript
{ "resource": "" }
q56046
train
function(params, messages, cb) { var correlationId = _cbt.put(prodResponse(cb)); var msg = envelope(prod.encode() .correlation(correlationId) .client(_options.clientId) .timeout() .topic(params.topic) ...
javascript
{ "resource": "" }
q56047
train
function(params, cb) { var correlationId = _cbt.put(fetchResponse(cb)); var msg = envelope(fech.encode() .correlation(correlationId) .client(_options.clientId) .maxWait(params.maxWait) .minBytes(params.mi...
javascript
{ "resource": "" }
q56048
train
function(params, cb) { var correlationId = _cbt.put(offsetResponse(cb)); var msg = envelope(off.encode() .correlation(correlationId) .client(_options.clientId) .replica() .topic(params.topic) ...
javascript
{ "resource": "" }
q56049
train
function(params, cb) { var correlationId = _cbt.put(offFetchResponse(cb)); var msg = envelope(offFetch.encode(params.fetchFromCoordinator ? 1 : 0) .correlation(correlationId) .client(_options.clientId) .group(params.gro...
javascript
{ "resource": "" }
q56050
train
function(params, cb) { var correlationId = _cbt.put(offCommitResponse(cb)); var msg = envelope(offCommit.encode() .correlation(correlationId) .client(_options.clientId) .group(params.group) ...
javascript
{ "resource": "" }
q56051
train
function(cb) { // return early if already connected if (_socket) { return cb(null, {host: _options.host, port: _options.port}); } _socket = net.createConnection(_options.port, _options.host); _socket.on('connect', function() { if (cb) { cb(null, {host: _options.host, port: _opt...
javascript
{ "resource": "" }
q56052
animationEnd
train
function animationEnd() { let el = document.createElement('tiny'); let animEndEventNames = { WebkitAnimation : 'webkitAnimationEnd', MozAnimation : 'animationend', OAnimation : 'oAnimationEnd oanimationend', animation : 'animationend' }; for (let name in a...
javascript
{ "resource": "" }
q56053
getFixedParent
train
function getFixedParent (el) { let currentParent = el.offsetParent, parent; while (parent === undefined) { if (currentParent === null) { parent = null; break; }
javascript
{ "resource": "" }
q56054
train
function (name, value, options) { if (options) { return validator[name](value, options) ? null : (_a = {}, _a[name] = { valid: false },
javascript
{ "resource": "" }
q56055
getParamValidator
train
function getParamValidator(name) { return function (options) { return function
javascript
{ "resource": "" }
q56056
placeBets
train
function placeBets() { // check input bets list var error; for ( var i = 0; i < req.request.bets.length; ++i) { var desc = req.request.bets[i]; error = checkPlaceBetItem(self, desc); // console.log('EMU bet', desc, "error", error); if (error) ...
javascript
{ "resource": "" }
q56057
cancelBets
train
function cancelBets() { // check request bets list var error; for ( var i = 0; i < req.request.bets.length; ++i) { var desc = req.request.bets[i]; error = checkCancelBetItem(self, desc); // console.log('EMU bet', desc, "error", error); if (error) ...
javascript
{ "resource": "" }
q56058
checkPlaceBetItem
train
function checkPlaceBetItem(self, desc) { if (desc.asianLineId !== '0' || desc.betCategoryType !== 'E') return 'UNKNOWN_ERROR'; if (desc.betPersistenceType !== 'NONE' && desc.betPersistenceType !== 'IP') return 'INVALID_PERSISTENCE'; if (desc.betType !== 'B' && desc.betType !== 'L') ...
javascript
{ "resource": "" }
q56059
skipWhitespace
train
function skipWhitespace() { while (i < input.length) { if (isWhitespace(input[i])) { i++;
javascript
{ "resource": "" }
q56060
DisableIEConditionalComments
train
function DisableIEConditionalComments(state, i){ if (state === htmlState.STATE_COMMENT && this.input[i] === ']' && this.input[i+1] === '>') { // for lazy conversion
javascript
{ "resource": "" }
q56061
train
function (collectionIdentity) { if (!collectionIdentity) return; var schema = connectionObject.collections[collectionIdentity].attributes; if(!schema) return 'id';
javascript
{ "resource": "" }
q56062
securityAssert
train
function securityAssert(ctx) { // all disabled. don't need check if (!csrfEnable && !validateReferrer) return; // pass referrer check const referrer = ctx.get('referrer'); if (validateReferrer && validateReferrer(referrer)) return; if
javascript
{ "resource": "" }
q56063
train
function(conn, cb) { log.debug('teardown:', conn); /* istanbul ignore if: standard waterline-adapter code */ if ( typeof conn == 'function') { cb = conn; conn = null; } /* istanbul ignore if: standard waterline-adapter code */ if (!conn) { connections =
javascript
{ "resource": "" }
q56064
train
function(connection, collection, object, cb) { utils.removeCircularReferences(object);
javascript
{ "resource": "" }
q56065
train
function(node, highlighter) { this.div.classList.add('MJX_LiveRegion_Show'); var rect = node.getBoundingClientRect(); var bot = rect.bottom + 10 + window.pageYOffset; var left = rect.left + window.pageXOffset; this.div.style.top = bot + 'px'; this.div.style.left = left + 'px';
javascript
{ "resource": "" }
q56066
train
function(type) { var element = MathJax.HTML.Element( 'div',
javascript
{ "resource": "" }
q56067
train
function() { if (!Assistive.getOption('speech')) return; LiveRegion.announced = true; MathJax.Ajax.Styles(LiveRegion.styles); var div = LiveRegion.Create('polite'); document.body.appendChild(div);
javascript
{ "resource": "" }
q56068
train
function(msg) { if (!Assistive.hook) return; var script = document.getElementById(msg[1]); if (script && script.id) { var jax = MathJax.Hub.getJaxFor(script.id); if (jax && jax.enriched) {
javascript
{ "resource": "" }
q56069
train
function(jax) { Explorer.RemoveHook(); Explorer.hook = MathJax.Hub.Register.MessageHook( 'End Math', function(message) { var newid = message[1].id + '-Frame'; var math = document.getElementById(newid); if (jax && newid === Explorer.expanded) {
javascript
{ "resource": "" }
q56070
train
function() { if (Explorer.hook) { MathJax.Hub.UnRegister.MessageHook(Explorer.hook);
javascript
{ "resource": "" }
q56071
train
function(script) { var id = script.id + '-Frame'; var sibling = script.previousSibling; if (!sibling) return; var math = sibling.id !== id ? sibling.firstElementChild : sibling; Explorer.AddAria(math); Explorer.AddMouseEvents(math); if (math.className === 'MathJax_MathML') { ...
javascript
{ "resource": "" }
q56072
train
function(math) { var id = math.id; var jax = MathJax.Hub.getJaxFor(id); var mathml = jax.root.toMathML(); if (!math.getAttribute('haslabel')) { Explorer.AddMathLabel(mathml, id); } if (math.getAttribute('hasspeech')) return; switch (Assistive.getOption('generation')) { ...
javascript
{ "resource": "" }
q56073
train
function(mathml, id) { Explorer.MakeSpeechTask( mathml, id, sre.TreeSpeechGenerator,
javascript
{ "resource": "" }
q56074
train
function(mathml, id) { Explorer.MakeSpeechTask( mathml, id, sre.SummarySpeechGenerator, function(math, speech) {
javascript
{ "resource": "" }
q56075
train
function(mathml, id, constructor, onSpeech, time) { var messageID = Explorer.AddMessage(); setTimeout(function() { var speechGenerator = new constructor(); var math = document.getElementById(id); var dummy = new sre.DummyWalker( math, speechGenerator, Explorer.highlighter...
javascript
{ "resource": "" }
q56076
train
function(event) { if (event.keyCode === KEY.ESCAPE) { if (!Explorer.walker) return; Explorer.RemoveHook(); Explorer.DeactivateWalker(); FALSE(event); return; } // If walker is active we redirect there. if (Explorer.walker && Explorer.walker.isActive()) { ...
javascript
{ "resource": "" }
q56077
train
function(node) { sre.HighlighterFactory.addEvents( node, {'mouseover': Explorer.MouseOver, 'mouseout': Explorer.MouseOut},
javascript
{ "resource": "" }
q56078
train
function() { Explorer.liveRegion.Clear(); Explorer.liveRegion.Hide(); Explorer.Unhighlight(); Explorer.currentHighlight = null;
javascript
{ "resource": "" }
q56079
train
function() { Explorer.Reset(); var speechItems = ['Subtitles', 'Generation']; speechItems.forEach( function(x) {
javascript
{ "resource": "" }
q56080
train
function() { for (var i = 0, all = MathJax.Hub.getAllJax(), jax; jax = all[i]; i++) { var math = document.getElementById(jax.inputID + '-Frame'); if (math) {
javascript
{ "resource": "" }
q56081
train
function (jax,id,script) { delete jax.enriched; if (this.config.disabled) return; try { this.running = true; var mml = sre.Enrich.semanticMathmlSync(jax.root.toMathML()); jax.root = MathJax.InputJax.MathML.Parse.prototype.MakeMML(mml); jax.root.inputID = script.id;
javascript
{ "resource": "" }
q56082
train
function (update,menu) { this.config.disabled
javascript
{ "resource": "" }
q56083
train
function() { var items = Array(this.modules.length); for (var i = 0, module; module = this.modules[i]; i++) items[i] = module.placeHolder; var menu = MENU.FindId('Accessibility'); if (menu) { items.unshift(ITEM.RULE()); menu.submenu.items.push.apply(menu.submenu.items,items); ...
javascript
{ "resource": "" }
q56084
copyLICENSE
train
function copyLICENSE(pkg) { fs.copy(__dirname + '/../LICENSE', __dirname + '/../packages/' +
javascript
{ "resource": "" }
q56085
updateVersion
train
function updateVersion(pkg) { fs.readFile(__dirname + '/../package.json', 'utf8', (err, data) => { errorOnFail(err) const globalVersion = JSON.parse(data).version fs.readFile(__dirname + '/../packages/' + pkg + '/package.json', (err, data) => { errorOnFail(err) const packageJSON = JSON.parse...
javascript
{ "resource": "" }
q56086
train
function(tag, nodes) { var xmlNodes = nodes.map(function(x) {return x.xml(xml, opt_brief);}); var tagNode
javascript
{ "resource": "" }
q56087
train
function (element) { if (this.config.disabled) return; this.GetContainerWidths(element); var jax = HUB.getAllJax(element); var state = {collapse: [], jax: jax, m:
javascript
{ "resource": "" }
q56088
train
function (SRE,state) { var w = SRE.width, m = w, M = 1000000; for (var j = SRE.action.length-1; j >= 0; j--) { var action = SRE.action[j], selection = action.selection; if (w > SRE.cwidth) { action.selection = 1; m = action.SREwidth; M = w; } else { acti...
javascript
{ "resource": "" }
q56089
train
function (jax,state) { if (!jax.root.SRE.actionWidths) { MathJax.OutputJax[jax.outputJax].getMetrics(jax); try {this.computeActionWidths(jax)} catch (err) { if (!err.restart) throw err;
javascript
{ "resource": "" }
q56090
train
function (jax) { var SRE = jax.root.SRE, actions = SRE.action, j, state = {}; SRE.width = jax.sreGetRootWidth(state); for (j = actions.length-1; j >= 0; j--) actions[j].selection = 2; for (j = actions.length-1; j >= 0; j--) { var action = actions[j];
javascript
{ "resource": "" }
q56091
train
function (mml,id) { var child = this.FindChild(mml,id);
javascript
{ "resource": "" }
q56092
train
function (mml) { this.UncollapseChild(mml,1); if (mml.complexity > this.COLLAPSE.fenced) { if (mml.attr["data-semantic-role"] === "leftright") { var marker = mml.data[0].data.join("") +
javascript
{ "resource": "" }
q56093
train
function (mml) { this.UncollapseChild(mml,0); if (mml.complexity > this.COLLAPSE.sqrt)
javascript
{ "resource": "" }
q56094
train
function (mml) { if (this.SplitAttribute(mml,"children").length === 1) { var child = (mml.data.length === 1 && mml.data[0].inferred ? mml.data[0] : mml); if (child.data[0] && child.data[0].collapsible) { // // Move menclose into the maction element
javascript
{ "resource": "" }
q56095
train
function (mml) { if (mml.complexity > this.COLLAPSE.bigop || mml.data[0].type !== "mo") { var id = this.SplitAttribute(mml,"content").pop(); var
javascript
{ "resource": "" }
q56096
train
function (mml) { if (mml.complexity > this.COLLAPSE.relseq) { var content = this.SplitAttribute(mml,"content"); var marker = Collapsible.FindChildText(mml,content[0]); if (content.length > 1)
javascript
{ "resource": "" }
q56097
train
function (mml) { this.UncollapseChild(mml,0,2); if (mml.complexity > this.COLLAPSE.superscript) mml
javascript
{ "resource": "" }
q56098
basicWorker
train
function basicWorker (job) { return Promise.try(() => { const tid = getNamespace('ponos').get('tid')
javascript
{ "resource": "" }
q56099
train
function(){ var uri = 'https://img.youtube.com/vi/' + this.url.videoId + '/maxresdefault.jpg'; try { var image = new Image(); image.onload = function(){ // Onload may still be called if YouTube returns the 120x90 error thumbnail if('naturalHeight' in image){ ...
javascript
{ "resource": "" }