_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q30800
makeWhiteSpace
train
function makeWhiteSpace(n) { var buffer = [], nb = true; for (; n >
javascript
{ "resource": "" }
q30801
fixSpaces
train
function fixSpaces(string) { if (string.charAt(0) == " ") string = nbsp + string.slice(1); return
javascript
{ "resource": "" }
q30802
makePartSpan
train
function makePartSpan(value, doc) { var text = value; if (value.nodeType == 3) text = value.nodeValue; else value = doc.createTextNode(text); var span =
javascript
{ "resource": "" }
q30803
pointAt
train
function pointAt(node){ var parent = node.parentNode; var next = node.nextSibling; return
javascript
{ "resource": "" }
q30804
writeNode
train
function writeNode(node, c, end) { var toYield = []; forEach(simplifyDOM(node, end), function(part) {
javascript
{ "resource": "" }
q30805
train
function() { var line = cleanText(self.history.textAfter(self.line).slice(self.offset)); var match = (self.caseFold ? line.toLowerCase() : line).indexOf(string); if (match > -1)
javascript
{ "resource": "" }
q30806
train
function() { var firstLine = cleanText(self.history.textAfter(self.line).slice(self.offset)); var match = (self.caseFold ? firstLine.toLowerCase() : firstLine).lastIndexOf(target[0]); if (match == -1 || match != firstLine.length - target[0].length) return false; var startOffset...
javascript
{ "resource": "" }
q30807
saveAfter
train
function saveAfter(pos) { if (self.history.textAfter(pos.node).length > pos.offset) { self.line = pos.node; self.offset = pos.offset + 1; } else {
javascript
{ "resource": "" }
q30808
train
function() { if (!this.container.firstChild) return ""; var accum = []; select.markSelection(this.win);
javascript
{ "resource": "" }
q30809
train
function() { var h = this.history; h.commit(); var start = select.cursorPos(this.container, true), end = select.cursorPos(this.container, false); if (!start || !end) return ""; if (start.node == end.node)
javascript
{ "resource": "" }
q30810
train
function(text) { this.history.commit(); var start = select.cursorPos(this.container, true), end = select.cursorPos(this.container, false); if (!start || !end) return;
javascript
{ "resource": "" }
q30811
train
function(event) { var electric = Editor.Parser.electricChars, self = this; // Hack for Opera, and Firefox on OS X, in which stopping a // keydown event does not prevent the associated keypress event // from happening, so we have to cancel enter and tab again // here. if ((this.frozen...
javascript
{ "resource": "" }
q30812
train
function() { var pos = select.selectionTopNode(this.container, true); var to = select.selectionTopNode(this.container, false); if (pos === false || to === false) return; select.markSelection(this.win);
javascript
{ "resource": "" }
q30813
train
function() { var cur = select.selectionTopNode(this.container, true), start = cur; if (cur === false || !(!cur || cur.isPart || isBR(cur)) || !this.container.firstChild) return false; while (cur && !isBR(cur)) cur = cur.previousSibling; var next = cur ? cur.nextSibling : this.container....
javascript
{ "resource": "" }
q30814
highlight
train
function highlight(node, ok) { if (!node) return; if (self.options.markParen) { self.options.markParen(node, ok); }
javascript
{ "resource": "" }
q30815
paren
train
function paren(node) { if (node.currentText) { var match = node.currentText.match(/^[\s\u00a0]*(
javascript
{ "resource": "" }
q30816
tryFindMatch
train
function tryFindMatch() { var stack = [], ch, ok = true;; for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) { if (runner.className == className && isSpan(runner) && (ch = paren(runner))) { if (forward(ch) == dir) stack.push(...
javascript
{ "resource": "" }
q30817
train
function(direction) { if (!this.container.firstChild) return; // The line has to have up-to-date lexical information, so we // highlight it first. if (!this.highlightAtCursor()) return; var cursor = select.selectionTopNode(this.container, false); // If we couldn't determine the place...
javascript
{ "resource": "" }
q30818
train
function(start, end, direction) { var current = (start = startOfLine(start)), before = start && startOfLine(start.previousSibling); if (!isBR(end)) end = endOfLine(end, this.container); this.addDirtyNode(start); do { var next = endOfLine(current, this.container); if (current) th...
javascript
{ "resource": "" }
q30819
train
function(safe) { // pagehide event hack above if (this.unloaded) { this.win.document.designMode = "off"; this.win.document.designMode = "on"; this.unloaded = false; } if (internetExplorer) { this.container.createTextRange().execCommand("unlink"); this.sel...
javascript
{ "resource": "" }
q30820
train
function(node) { node = node || this.container.firstChild; if (!node) return; for (var i = 0; i < this.dirty.length; i++) if (this.dirty[i] == node) return;
javascript
{ "resource": "" }
q30821
train
function() { // Timeouts are routed through the parent window, because on // some browsers designMode windows do not fire timeouts. var self = this; this.parent.clearTimeout(this.highlightTimeout);
javascript
{ "resource": "" }
q30822
train
function() { while (this.dirty.length > 0) { var found = this.dirty.pop(); // IE8 sometimes throws an unexplainable 'invalid argument' // exception for found.parentNode try { // If the node has been coloured in the meantime, or is no // longer in the document, i...
javascript
{ "resource": "" }
q30823
train
function(force) { // Prevent FF from raising an error when it is firing timeouts // on a page that's no longer loaded. if (!window.select) return; if (!this.options.readOnly) select.markSelection(this.win); var start, endTime = force ? null : time() + this.options.passTime; while ((...
javascript
{ "resource": "" }
q30824
train
function(passTime) { var self = this, pos = null; return function() { // FF timeout weirdness workaround. if (!window.select) return; // If the current node is no longer in the document... oh // well, we start over. if (pos && pos.parentNode != self.container) ...
javascript
{ "resource": "" }
q30825
train
function() { if (this.scanner) { this.parent.clearTimeout(this.documentScan); this.documentScan
javascript
{ "resource": "" }
q30826
tokenPart
train
function tokenPart(token){ var part = makePartSpan(token.value, self.doc);
javascript
{ "resource": "" }
q30827
train
function(){ var part = this.get(); // Allow empty nodes when they are alone on a line, needed // for the FF cursor bug workaround (see select.js, // insertNewlineAtCursor). while (part && isSpan(part) && part.currentText == "") { // Leave empty nodes that ar...
javascript
{ "resource": "" }
q30828
train
function() { this.nodes = []; this.edges = []; // Extract wires for(var i = 0 ; i < this.layer.wires.length ; i++) { var wire = this.layer.wires[i];
javascript
{ "resource": "" }
q30829
train
function(options) { inputEx.IPv4Field.superclass.setOptions.call(this, options); this.options.messages.invalid = inputEx.messages.invalidIPv4; this.options.regexp
javascript
{ "resource": "" }
q30830
train
function(id, container, config) { // Normalize 2.4.0, pre 2.4.0 args var nArgs = this._parseArgs(arguments); id = nArgs.id; container = nArgs.container; config = nArgs.config; this.oDomContainer = Dom.get(container); if (!this.oDomContainer) { this.logger.log("...
javascript
{ "resource": "" }
q30831
train
function() { // Add element button this.addButton = inputEx.cn('img', {src: inputEx.spacerUrl, className: 'inputEx-ListField-addButton'}); Dom.setStyle(this.addButton, 'float', 'left'); this.fieldContainer.appendChild(this.addButton); // Instanciate the new subField this.su...
javascript
{ "resource": "" }
q30832
train
function() { jsBox.WiringEditor.superclass.renderButtons.call(this); // Add the run button to the toolbar var toolbar = YAHOO.util.Dom.get('toolbar'); var runButton
javascript
{ "resource": "" }
q30833
train
function (p_sType, p_aArgs, p_oItem) { var sText = p_aArgs[0], oConfig = this.cfg, oAnchor = this._oAnchor, sHelpText = oConfig.getProperty(_HELP_TEXT), sHelpTextHTML = _EMPTY_STRING, sEmphasisStartTag = _EMPTY_STRING, sEmphasisEndTag = _E...
javascript
{ "resource": "" }
q30834
train
function() { // Remove from DOM if(Dom.inDocument(this.el)) { this.el.parentNode.removeChild(this.el); }
javascript
{ "resource": "" }
q30835
train
function(obj,parentEl) { var ul = inputEx.cn('ul', {className: 'inputEx-JsonTreeInspector'}); for(var key in obj) { if(obj.hasOwnProperty(key)) { var value = obj[key]; var id = Dom.generateId(); var li = inputEx.cn('li', {id: id}, null,...
javascript
{ "resource": "" }
q30836
train
function(e, params) { Event.stopEvent(e); var tgt = Event.getTarget(e);
javascript
{ "resource": "" }
q30837
train
function(li) { var isExpanded = Dom.hasClass(li, 'expanded'); Dom.replaceClass(li, isExpanded ? 'expanded' : 'collapsed' , isExpanded ? 'collapsed':'expanded'); var h = this.hash[li.id]; if(isExpanded) {
javascript
{ "resource": "" }
q30838
train
function(li,maxLevel) { this.expandElement(li); var sub = Dom.getChildrenBy(li, function(c) {return c.tagName == "UL";})[0].childNodes; for(var j = 0 ; j < sub.length ; j++) { var s = sub[j];
javascript
{ "resource": "" }
q30839
train
function(maxLevel) { var ul = this.el.childNodes[0]; var liEls = ul.childNodes; for(var i = 0 ; i < liEls.length ; i++) {
javascript
{ "resource": "" }
q30840
train
function(key) { Y.log("Fetching item at " + key); var item = this._getItem(key); return
javascript
{ "resource": "" }
q30841
train
function(index) { Y.log("Fetching key at " + index); if (YL.isNumber(index) && -1 < index && this.length > index) { var value = this._key(index); if (value) {return value;} } //
javascript
{ "resource": "" }
q30842
train
function(key) { Y.log("removing " + key); if (this.hasKey(key)) { var oldValue = this._getItem(key); if (! oldValue) {oldValue = null;}
javascript
{ "resource": "" }
q30843
train
function(key, data) { Y.log("SETTING " + data + " to " + key); if (YL.isString(key)) { var eventType = this.hasKey(key) ? YU.StorageEvent.TYPE_UPDATE_ITEM : YU.StorageEvent.TYPE_ADD_ITEM, oldValue = this._getItem(key); if (! oldValue) {oldValue = null;} if (this._setItem(key, this._createVal...
javascript
{ "resource": "" }
q30844
train
function(s) { var a = s ? s.split(this.DELIMITER) : []; if (1 == a.length) {return s;} switch (a[0]) { case 'boolean': return 'true' === a[1]; case 'number': return
javascript
{ "resource": "" }
q30845
train
function(engineType, location, conf) { var _cfg = YL.isObject(conf) ? conf : {}, klass = _getClass(_registeredEngineMap[engineType]); if (! klass && ! _cfg.force) { var i, j; if (_cfg.order) { j = _cfg.order.length; for (i = 0; i < j && ! klass; i += 1) { klass = _getClass(_cfg.orde...
javascript
{ "resource": "" }
q30846
train
function(engineConstructor) { if (YL.isFunction(engineConstructor) && YL.isFunction(engineConstructor.isAvailable) && YL.isString(engineConstructor.ENGINE_NAME))
javascript
{ "resource": "" }
q30847
train
function(key) { this._keyMap[key] = this.length;
javascript
{ "resource": "" }
q30848
train
function(key) { var j = this._indexOfKey(key), rest = this._keys.slice(j + 1); delete this._keyMap[key]; for (var k in this._keyMap) {
javascript
{ "resource": "" }
q30849
train
function() { this.logger.log("focus"); this.valueChangeSource = Slider.SOURCE_UI_EVENT; // Focus the background element if possible var el = this.getEl(); if (el.focus) { try { el.focus(); } catch(e) { // Prevent permissio...
javascript
{ "resource": "" }
q30850
train
function(source, newOffset, skipAnim, force, silent) { var t = this.thumb, newX, newY; if (!t.available) { this.logger.log("defer setValue until after onAvailble"); this.deferredSetValue = arguments; return false; } if (this.isLocked() && !force) { ...
javascript
{ "resource": "" }
q30851
train
function() { var xy = getXY(this.getEl()), t = this.thumb; if (!this.thumbCenterPoint || !this.thumbCenterPoint.x) { this.setThumbCenterPoint(); } if (xy) { this.logger.log("newPos: " + xy); if (xy[0] != this.baselinePos[0] || xy[1] !...
javascript
{ "resource": "" }
q30852
train
function(x, y, skipAnim, midMove) { var t = this.thumb, self = this, p,_p,anim; if (!t.available) { this.logger.log("thumb is not available yet, aborting move"); return; } this.logger.log("move thumb, x: " + x + ", y: " + y); t...
javascript
{ "resource": "" }
q30853
train
function(curCoord, finalCoord) { this.logger.log("getNextX: " + curCoord + ", " + finalCoord); var t = this.thumb, thresh, tmp = [], nextCoord = null; if (curCoord[0] > finalCoord[0]) { thresh = t.tickSize - this.thumbCenterPoint.x;
javascript
{ "resource": "" }
q30854
train
function(e) { this.logger.log("background drag"); if (this.backgroundEnabled && !this.isLocked()) { var x = Event.getPageX(e), y = Event.getPageY(e);
javascript
{ "resource": "" }
q30855
train
function (thumbEvent) { var t = this.thumb, newX, newY, newVal; if (!thumbEvent) { t.cachePosition(); } if (! this.isLocked()) { if (t._isRegion) { newX = t.getXValue(); newY = t.getYValue(); if (newX != this.pre...
javascript
{ "resource": "" }
q30856
train
function(options) { inputEx.ColorPickerField.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ColorPickerField'; // Color Picker options object this.options.colorPickerOptions = YAHOO.lang.isUnde...
javascript
{ "resource": "" }
q30857
train
function (userId, doc, fieldNames, modifier) { // only admins can update user roles via the client return Users.isAdmin(userId)
javascript
{ "resource": "" }
q30858
encode
train
function encode(events) { if(!Array.isArray(events)) { return '00'; } let bitmask = 0; for(event in events) { let index = events[event];
javascript
{ "resource": "" }
q30859
decode
train
function decode(events) { let indexList = []; let eventsByte = parseInt(events, 16); if(eventsByte & APPEARANCE_MASK) { indexList.push(APPEARANCE); } if(eventsByte & DISPLACEMENT_MASK) { indexList.push(DISPLACEMENT); } if(eventsByte & PACKETS_MASK) {
javascript
{ "resource": "" }
q30860
measures
train
function measures (meter, measures, builder) { var list var mLen = measureLength(meter) if (!mLen) throw Error('Not valid meter: ' + meter) var seq = [] builder = builder || score.note splitMeasures(measures).forEach(function (measure) { measure = measure.trim() if
javascript
{ "resource": "" }
q30861
chords
train
function chords (meter, data) { return measures(meter, data, function (dur, el) {
javascript
{ "resource": "" }
q30862
measureLength
train
function measureLength (meter) { var m = meter.split('/').map(function
javascript
{ "resource": "" }
q30863
internalResolve
train
function internalResolve ( resolve ) { resolve(window.google
javascript
{ "resource": "" }
q30864
constructFromObject
train
function constructFromObject(instance, source) { instance.transmitterId = identifiers.format(source.transmitterId); instance.transmitterIdType = source.transmitterIdType; instance.rssiSignature = source.rssiSignature || []; instance.rssiSignature.forEach(function(entry) { entry.receiverIdType = entry.recei...
javascript
{ "resource": "" }
q30865
mergeTimes
train
function mergeTimes(source, destination) { if(source.hasOwnProperty('earliestDecodingTime')) { if(destination.hasOwnProperty('earliestDecodingTime')) { let isSourceEarlier = (source.earliestDecodingTime < destination.earliestDecodingTime);
javascript
{ "resource": "" }
q30866
toHexString
train
function toHexString(number, numberOfBytes) { numberOfBytes = numberOfBytes ||
javascript
{ "resource": "" }
q30867
Region
train
function Region(config) { this.config = config; this.appLimit = new RateLimit(this.config.rateLimitTypeApplication,
javascript
{ "resource": "" }
q30868
RateLimit
train
function RateLimit(type, distFactor, config) { this.config = config; this.type = type; this.buckets = this.config.defaultBuckets.map(b => new
javascript
{ "resource": "" }
q30869
dependency
train
function dependency(deps, name) { if (name in deps && typeof deps[name] !== 'undefined') { return deps[name];
javascript
{ "resource": "" }
q30870
train
function(deps) { deps = deps || {}; var grunt = dependency(deps, 'grunt'); var task = dependency(deps, 'task'); var done = task.async(); task.files.forEach(function(subTask) { // make sure an editing function has been provided if (typeof subTask.editor !== 'function') { retu...
javascript
{ "resource": "" }
q30871
create_node
train
function create_node(length) { const node = {}; Object.defineProperty(node, "_", { value: { length: length, //record array length watchers: {}, watcher_key: new Set(), watcher_props: new
javascript
{ "resource": "" }
q30872
create_node_by_path
train
function create_node_by_path(context, path, len, tracker) { let node = context.state.rootNode; for (let i = 0; i < len; i++) { const k = path[i]; if (k == "_") continue; if (k == "#") { node = context.state.rootNode;
javascript
{ "resource": "" }
q30873
apply_patch
train
function apply_patch(context, patch, tracker) { const path = patch[0]; if (path.length == 0) return; //ignore replace root node const value = patch[1]; const len = path.length - 1; const prop = path[len]; if (!Array.isArray(value)) { const node = create_node_by_path(context, path, len, tracker); commit_node_...
javascript
{ "resource": "" }
q30874
calc_patches_any
train
function calc_patches_any(context, patches, path, value, tracker) { const valueType = value_type(value); if (valueType == ValueTypes.OBJECT) { if (value.propertyIsEnumerable("_")) { if (value["_"] == "$ref") { return patches.push([path, [PatchTypes.REFERENCE, value.path]]); } throw new Error("Underscor...
javascript
{ "resource": "" }
q30875
draw
train
function draw (ctx, score) { console.log(score) drawStripes(box, ctx) forEachTime(function (time, note) { var midi = toMidi(note.pitch) console.log(time, note, midi)
javascript
{ "resource": "" }
q30876
exec
train
function exec (ctx, scope, data) { console.log('exec', ctx, scope, data) var fn = getFunction(ctx, scope, data[0]) var elements = data.slice(1) var params = elements.map(function (p) { return Array.isArray(p) ? exec(ctx, scope, p)
javascript
{ "resource": "" }
q30877
format
train
function format(identifier) { if(typeof identifier === 'string') { var hexIdentifier = identifier.replace(/[^A-Fa-f0-9]/g, '');
javascript
{ "resource": "" }
q30878
lengthInBytes
train
function lengthInBytes(type) { switch(type) { case TYPE_UNKNOWN: return LENGTH_UNKNOWN; case TYPE_EUI64: return LENGTH_EUI64; case TYPE_EUI48:
javascript
{ "resource": "" }
q30879
buildType
train
function buildType(t, typeClassification) { let typeDef; switch (typeClassification) { case 'primative': typeDef = { interface: t, builder: t }; break; case...
javascript
{ "resource": "" }
q30880
strip
train
function strip(obj) { if (!obj || ! obj instanceof Object || typeof obj === 'string') { return undefined; } if (obj instanceof Array) { for (const value of obj) { strip(value); } } else
javascript
{ "resource": "" }
q30881
clean
train
function clean(code) { try { const ast = babylon.parse(code, { // parse in strict mode and allow module declarations sourceType: 'module', plugins: [ // enable jsx and flow syntax 'jsx', 'flow' ] }); ...
javascript
{ "resource": "" }
q30882
camelCase
train
function camelCase(str, next) { let output = ''; for (const c of str) { if (c === '_') { next = true; continue;
javascript
{ "resource": "" }
q30883
processProto
train
function processProto(protoFile, root, imported = []) { const protPath = path.format({ dir: root, base: protoFile }); const parser = new ProtoBuf.DotProto.Parser(fs.readFileSync(protPath)); const protoAst = parser.parse(); imported.push(protoFile);
javascript
{ "resource": "" }
q30884
generateFromProto
train
function generateFromProto(outputDir, inputProto, protoDir) { try { fs.accessSync(path.format({ dir: protoDir, base: inputProto })); if (!protoDir) { const absolutePath = fs.realpathSync(inputProto); protoDir = path.dirname(absolutePath); ...
javascript
{ "resource": "" }
q30885
note
train
function note (dur, pitch, data) { if (arguments.length === 1) return function (p, d) { return note(dur, p, d) }
javascript
{ "resource": "" }
q30886
transform
train
function transform (nt, st, pt, ctx, obj) { switch (arguments.length) { case 0: return transform case 1: case 2: case 3: return transformer(nt, st, pt) case 4: return
javascript
{ "resource": "" }
q30887
map
train
function map (fn, ctx, obj) { switch (arguments.length) { case 0: return map case 1: return transform(fn, buildSeq, buildSim) case 2:
javascript
{ "resource": "" }
q30888
extend
train
function extend( obj, var_args ) { for ( var i = 1; i < arguments.length ; i += 1 ) { var other = arguments[ i ]; for ( var p in other ) { var v = Object.getOwnPropertyDescriptor( other, p ); if ( typeof v == "undefined" || typeof v.value == "undefined" ) ...
javascript
{ "resource": "" }
q30889
SSH
train
function SSH(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!");
javascript
{ "resource": "" }
q30890
forEachTime
train
function forEachTime (fn, ctx, obj) { if (arguments.length > 1) return forEachTime(fn)(ctx, obj) return function (ctx, obj) { return score.transform( function (note) { return function (time, ctx) { fn(time, note, ctx) return note.duration } }, function (seq...
javascript
{ "resource": "" }
q30891
events
train
function events (obj, build, compare) { var e = [] forEachTime(function (time, obj) {
javascript
{ "resource": "" }
q30892
SCP
train
function SCP(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!");
javascript
{ "resource": "" }
q30893
merge
train
function merge(source, destination) { source.forEach(function(current) { let matchFound = false; destination.forEach(function(target) { let isSameReceiver = identifiers.areMatch(current.receiverId, current.receiverIdType, ...
javascript
{ "resource": "" }
q30894
compareRssi
train
function compareRssi(a,b) { if(a.rssi < b.rssi) return 1; if(a.rssi
javascript
{ "resource": "" }
q30895
encode
train
function encode(rssi) { if(rssi < MIN_RSSI_DBM) { rssi = MIN_RSSI_DBM; } else if(rssi > MAX_RSSI_DBM) { rssi = MAX_RSSI_DBM; } else {
javascript
{ "resource": "" }
q30896
ttone1
train
function ttone1 (reps, row, key, beat, amp) { var tr = row.split(' ').map(function (n) { return +n +
javascript
{ "resource": "" }
q30897
structureAs
train
function structureAs (name) { return function () { return
javascript
{ "resource": "" }
q30898
Client
train
function Client(arg, port) { if (this instanceof Client === false) { return new Client(arg, port); } if (arg === undefined) { throw new TypeError('arg should be a host address, name or universe'); } this.host = Number.isInteger(arg)
javascript
{ "resource": "" }
q30899
add_sp_n
train
function add_sp_n (cpu, mmu) { const n = mmu.readByte(cpu.pc + 1).signed(); const r = cpu.sp + n;
javascript
{ "resource": "" }