_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q46800
Autodoc
train
function Autodoc(options) { options = Lazy(options || {}) .defaults(Autodoc.options) .toObject(); this.codeParser = wrapParser(options.codeParser); this.commentParser = wrapParser(options.commentParser); this.markdownParser = wrapParser(options.markdownParser, Autodoc.processInte...
javascript
{ "resource": "" }
q46801
splitCamelCase
train
function splitCamelCase(string) { var matcher = /[^A-Z]([A-Z])|([A-Z])[^A-Z]/g, tokens = [], position = 0, index, match; string || (string = ''); while (match = matcher.exec(string)) { index = typeof match[1] === 'string' ? match.index + 1 : match.index; if (position...
javascript
{ "resource": "" }
q46802
divide
train
function divide(string, divider) { var seam = string.indexOf(divider); if (seam === -1) { return [string]; } return [string.substring(0, seam), string.substring(seam + divider.length)]; }
javascript
{ "resource": "" }
q46803
unindent
train
function unindent(string, skipFirstLine) { var lines = string.split('\n'), skipFirst = typeof skipFirstLine !== 'undefined' ? skipFirstLine : true, start = skipFirst ? 1 : 0; var indentation, smallestIndentation = Infinity; for (var i = start, len = lines.length; i < len; ++i) { ...
javascript
{ "resource": "" }
q46804
firstLine
train
function firstLine(string) { var lineBreak = string.indexOf('\n'); if (lineBreak === -1) { return string; } return string.substring(0, lineBreak) + ' (...)'; }
javascript
{ "resource": "" }
q46805
exampleHandlers
train
function exampleHandlers(customHandlers) { return (customHandlers || []).concat([ { pattern: /^(\w[\w\.\(\)\[\]'"]*)\s*===?\s*(.*)$/, template: 'equality', data: function(match) { return { left: match[1], right: match[2] }; } },...
javascript
{ "resource": "" }
q46806
train
function(string, delimiter) { var start = 0, parts = [], index = string.indexOf(delimiter); if (delimiter === '') { while (index < string.length) { parts.push(string.charAt(index++)); } return parts; } while (index !== -1 & index < string.length) { parts...
javascript
{ "resource": "" }
q46807
train
function(string) { var chars = new Array(string.length); var charCode; for (var i = 0, len = chars.length; i < len; ++i) { charCode = string.charCodeAt(i); if (charCode > 96 && charCode < 123) { charCode -= 32; } chars[i] = String.fromCharCode(charCode); } return c...
javascript
{ "resource": "" }
q46808
printEvens
train
function printEvens(N) { try { var i = -1; beginning: do { if (++i < N) { if (i % 2 !== 0) { continue beginning; } printNumber(i); } break; } while (true); } catch (e) { debugger; } }
javascript
{ "resource": "" }
q46809
validateVar
train
function validateVar({ spec = {}, name, rawValue }) { if (typeof spec._parse !== 'function') { throw new EnvError(`Invalid spec for "${name}"`) } const value = spec._parse(rawValue) if (spec.choices) { if (!Array.isArray(spec.choices)) { throw new TypeError(`"choices" must b...
javascript
{ "resource": "" }
q46810
formatSpecDescription
train
function formatSpecDescription(spec) { const egText = spec.example ? ` (eg. "${spec.example}")` : '' const docsText = spec.docs ? `. See ${spec.docs}` : '' return `${spec.desc}${egText}${docsText}` || '' }
javascript
{ "resource": "" }
q46811
extendWithDotEnv
train
function extendWithDotEnv(inputEnv, dotEnvPath = '.env') { let dotEnvBuffer = null try { dotEnvBuffer = fs.readFileSync(dotEnvPath) } catch (err) { if (err.code === 'ENOENT') return inputEnv throw err } const parsed = dotenv.parse(dotEnvBuffer) return extend(parsed, input...
javascript
{ "resource": "" }
q46812
useSingleQuote
train
function useSingleQuote(node, options) { return ( !node.isDoubleQuote || (options.singleQuote && !node.raw.match(/\\n|\\t|\\r|\\t|\\v|\\e|\\f/) && !node.value.match( /["'$\n]|\\[0-7]{1,3}|\\x[0-9A-Fa-f]{1,2}|\\u{[0-9A-Fa-f]+}/ )) ); }
javascript
{ "resource": "" }
q46813
doSearch
train
function doSearch(docClient, tableName, scanParams, limit, startKey, progress, readOperation = 'scan') { limit = limit !== undefined ? limit : null startKey = startKey !== undefined ? startKey : null let params = { TableName: tableName, } if (scanParams !== undefined && scanParams) { ...
javascript
{ "resource": "" }
q46814
loadDynamoConfig
train
function loadDynamoConfig(env, AWS) { const dynamoConfig = { endpoint: 'http://localhost:8000', sslEnabled: false, region: 'us-east-1', accessKeyId: 'key', secretAccessKey: env.AWS_SECRET_ACCESS_KEY || 'secret' } loadDynamoEndpoint(env, dynamoConfig) if (AWS.config) { if (AWS.config.re...
javascript
{ "resource": "" }
q46815
metrics
train
function metrics(context) { //x-height context.fillStyle = 'blue' context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight) //ascender context.fillStyle = 'pink' context.fillRect(27, -layout.height, 36, layout.ascender) //cap height context.fillStyle = 'yellow' context.fillRect(110,...
javascript
{ "resource": "" }
q46816
createNav
train
function createNav(sources) { const defaultCategory = 'Uncategorized'; const sourcesByCategories = sources. // get category names reduce((categories, source) => categories. concat(source.attrs.category || defaultCategory), []). // remove duplicates filter((value, i, self) => self.indexOf(val...
javascript
{ "resource": "" }
q46817
focusFirst
train
function focusFirst() { const controls = node.queryAll('input,select,button,textarea,*[contentEditable=true]'). filter(inputNode => getStyles(inputNode).display !== 'none'); if (controls.length) { controls[0].focus(); } }
javascript
{ "resource": "" }
q46818
dock
train
function dock() { onBeforeDock(); panel.classList.add(DOCKED_CSS_CLASS_NAME); if (dockedPanelClass) { panel.classList.add(dockedPanelClass); } isDocked = true; }
javascript
{ "resource": "" }
q46819
checkPanelPosition
train
function checkPanelPosition() { const currentPanelRect = panel.getBoundingClientRect(); if (currentPanelRect.top + currentPanelRect.height > getScrollContainerHeight() && !isDocked) { dock(); } else if ( isDocked && currentPanelRect.top + currentPanelRect...
javascript
{ "resource": "" }
q46820
startOldBrowsersDetector
train
function startOldBrowsersDetector(onOldBrowserDetected) { previousWindowErrorHandler = window.onerror; window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) { if (onOldBrowserDetected) { onOldBrowserDetected(); } if (previousWindowErrorHandler) { return previousWind...
javascript
{ "resource": "" }
q46821
focusOnElement
train
function focusOnElement(element) { if (!element) { return; } if (element.hasAttribute(RING_SELECT) || element.tagName.toLowerCase() === RING_SELECT) { focusOnElement(element.querySelector(RING_SELECT_SELECTOR)); return; } if (element.matches(FOCUSABLE_ELEMENTS) && element.focus) ...
javascript
{ "resource": "" }
q46822
scrollSpeed
train
function scrollSpeed(date) { const monthStart = moment(date).startOf('month'); const monthEnd = moment(date).endOf('month'); return (monthEnd - monthStart) / monthHeight(monthStart); }
javascript
{ "resource": "" }
q46823
getModifierClassNames
train
function getModifierClassNames(props) { return modifierKeys.reduce((result, key) => { if (props[key]) { return result.concat(styles[`${key}-${props[key]}`]); } return result; }, []); }
javascript
{ "resource": "" }
q46824
watch
train
function watch (glob, watchOpt) { if (!started) { deferredWatch = emitter.watch.bind(null, glob, watchOpt) } else { // destroy previous if (fileWatcher) fileWatcher.close() glob = glob && glob.length > 0 ? glob : defaultWatchGlob glob = Array.isArray(glob) ? glob : [ glob ] w...
javascript
{ "resource": "" }
q46825
live
train
function live (liveOpts) { if (!started) { deferredLive = emitter.live.bind(null, liveOpts) } else { // destroy previous if (reloader) reloader.close() // pass some options for the server middleware server.setLiveOptions(xtend(liveOpts)) // create a web socket server for li...
javascript
{ "resource": "" }
q46826
parseError
train
function parseError (err) { var filePath, lineNum, splitLines var result = {} // For root files that syntax-error doesn't pick up: var parseFilePrefix = 'Parsing file ' if (err.indexOf(parseFilePrefix) === 0) { var pathWithErr = err.substring(parseFilePrefix.length) filePath = getFilePa...
javascript
{ "resource": "" }
q46827
getFilePath
train
function getFilePath (str) { var hasRoot = /^[a-z]:/i.exec(str) var colonLeftIndex = 0 if (hasRoot) { colonLeftIndex = hasRoot[0].length } var pathEnd = str.split('\n')[0].indexOf(':', colonLeftIndex) if (pathEnd === -1) { // invalid string, return non-formattable result return...
javascript
{ "resource": "" }
q46828
update
train
function update (e) { // tab indent if (e.keyCode === 9) { e.preventDefault(); var selection = window.getSelection(); var range = selection.getRangeAt(0); var text = document.createTextNode('\t'); range.deleteContents(); range.insertNode(text); range.setSta...
javascript
{ "resource": "" }
q46829
options
train
function options(defaults, opts) { for (var p in opts) { if (opts[p] && opts[p].constructor && opts[p].constructor === Object) { defaults[p] = defaults[p] || {}; options(defaults[p], opts[p]); } else { defaults[p] = opts[p]; } } return defaults; }
javascript
{ "resource": "" }
q46830
line
train
function line (line, left, right, intersection){ var width = 0 , line = left + repeat(line, totalWidth - 2) + right; colWidths.forEach(function (w, i){ if (i == colWidths.length - 1) return; width += w + 1; line = line.substr(0, width) + intersection + line.sub...
javascript
{ "resource": "" }
q46831
lineTop
train
function lineTop (){ var l = line(chars.top , chars['top-left'] || chars.top , chars['top-right'] || chars.top , chars['top-mid']); if (l) ret += l + "\n"; }
javascript
{ "resource": "" }
q46832
string
train
function string (str, index){ var str = String(typeof str == 'object' && str.text ? str.text : str) , length = utils.strlen(str) , width = colWidths[index] - (style['padding-left'] || 0) - (style['padding-right'] || 0) , align = options.colAligns[index] || 'left'; return r...
javascript
{ "resource": "" }
q46833
charset
train
function charset (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) var mime = match && db[match[1].toLowerCase()] if (mime && mime.charset) { return mime.charset } // default text/* to utf-8 if (match && TEXT...
javascript
{ "resource": "" }
q46834
contentType
train
function contentType (str) { // TODO: should this even be in this module? if (!str || typeof str !== 'string') { return false } var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str if (!mime) { return false } // TODO: use content-type or other module if (mime.indexOf('charse...
javascript
{ "resource": "" }
q46835
extension
train
function extension (type) { if (!type || typeof type !== 'string') { return false } // TODO: use media-typer var match = EXTRACT_TYPE_REGEXP.exec(type) // get extensions var exts = match && exports.extensions[match[1].toLowerCase()] if (!exts || !exts.length) { return false } return exts[0...
javascript
{ "resource": "" }
q46836
populateMaps
train
function populateMaps (extensions, types) { // source preference (least -> most) var preference = ['nginx', 'apache', undefined, 'iana'] Object.keys(db).forEach(function forEachMimeType (type) { var mime = db[type] var exts = mime.extensions if (!exts || !exts.length) { return } // mi...
javascript
{ "resource": "" }
q46837
getGitFolderPath
train
function getGitFolderPath(currentPath) { var git = path.resolve(currentPath, '.git') if (!exists(git) || !fs.lstatSync(git).isDirectory()) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git); var newPath = path.resolve(currentPath, '..'); // Stop if we on to...
javascript
{ "resource": "" }
q46838
Hook
train
function Hook(fn, options) { if (!this) return new Hook(fn, options); options = options || {}; this.options = options; // Used for testing only. Ignore this. Don't touch. this.config = {}; // pre-commit configuration from the `package.json`. this.json = {}; // Actual content of the ...
javascript
{ "resource": "" }
q46839
loadView
train
function loadView(view) { $errorMessage.empty(); var ctrl = loadCtrl(view); if (!ctrl) return; // Check if View Requires Authentication if (ctrl.requireADLogin && !authContext.getCachedUser()) { authContext.config.redirectUri = window.location.href; ...
javascript
{ "resource": "" }
q46840
getSourceList
train
function getSourceList(playlist) { return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src); }
javascript
{ "resource": "" }
q46841
getGoToTrackState
train
function getGoToTrackState({ prevState, index, track, shouldPlay = true, shouldForceLoad = false }) { const isNewTrack = prevState.activeTrackIndex !== index; const shouldLoadAsNew = Boolean(isNewTrack || shouldForceLoad); const currentTime = track.startingTime || 0; return { duration: getInitialD...
javascript
{ "resource": "" }
q46842
pxToEmOrRem
train
function pxToEmOrRem(breakpoints, ratio = 16, unit) { const newBreakpoints = {}; for (let key in breakpoints) { const point = breakpoints[key]; if (String(point).includes('px')) { newBreakpoints[key] = +(parseInt(point) / ratio) + unit; continue; } newBreakpoints[key] = point; } ...
javascript
{ "resource": "" }
q46843
Manager
train
function Manager (uri, opts, fn) { if (!uri) { throw Error('No connection URI provided.') } if (!(this instanceof Manager)) { return new Manager(uri, opts, fn) } if (typeof opts === 'function') { fn = opts opts = {} } opts = opts || {} this._collectionOptions = objectAssign({}, DEFAU...
javascript
{ "resource": "" }
q46844
tapename
train
function tapename(req, body) { var hash = opts.hash || messageHash.sync; return hash(req, Buffer.concat(body)) + '.js'; }
javascript
{ "resource": "" }
q46845
write
train
function write(filename, data) { return Promise.fromCallback(function (done) { debug('write', filename); fs.writeFile(filename, data, done); }); }
javascript
{ "resource": "" }
q46846
createNewTask
train
function createNewTask(task) { console.log("Creating task..."); //set up the new list item const listItem = document.createElement("li"); const checkBox = document.createElement("input"); const label = document.createElement("label"); //pull the inputed text into label...
javascript
{ "resource": "" }
q46847
addTask
train
function addTask() { const task = newTask.value.trim(); console.log("Adding task: " + task); // ***** // *** we need to add a task to the fluence cluster after we pressed the `Add task` button // ***** addTaskToFluence(task); updateTaskList(task) }
javascript
{ "resource": "" }
q46848
deleteTask
train
function deleteTask() { console.log("Deleting task..."); const listItem = this.parentNode; const ul = listItem.parentNode; const task = listItem.getElementsByTagName('label')[0].innerText; // ***** // *** delete a task from the cluster when we press `Delete` button on ...
javascript
{ "resource": "" }
q46849
onLocalModuleBinding
train
function onLocalModuleBinding(ident, ast, acc) { traverse(ast, { CallExpression({ node: callExpression }) { // left must be a member expression if (t.isMemberExpression(callExpression.callee) === false) { return; } const memberExpression = callExpression.callee; /** ...
javascript
{ "resource": "" }
q46850
onInstanceThenFn
train
function onInstanceThenFn(fn, acc) { if (t.isArrowFunctionExpression(fn) === false) { throw new Error("Unsupported function type: " + fn.type); } let [localIdent] = fn.params; /** * `then(({exports}) => ...)` * * We need to resolve the identifier (binding) from the ObjectPattern. * * TODO(s...
javascript
{ "resource": "" }
q46851
configureMonaco
train
function configureMonaco() { monaco.languages.register({ id: "wast" }); monaco.languages.setMonarchTokensProvider("wast", { tokenizer: { root: [ [REGEXP_KEYWORD, "keyword"], [REGEXP_KEYWORD_ASSERTS, "keyword"], [REGEXP_NUMBER, "number"], [/\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\...
javascript
{ "resource": "" }
q46852
encodeBufferCommon
train
function encodeBufferCommon(buffer, signed) { let signBit; let bitCount; if (signed) { signBit = bits.getSign(buffer); bitCount = signedBitCount(buffer); } else { signBit = 0; bitCount = unsignedBitCount(buffer); } const byteCount = Math.ceil(bitCount / 7); const result = bufs.alloc(byte...
javascript
{ "resource": "" }
q46853
encodedLength
train
function encodedLength(encodedBuffer, index) { let result = 0; while (encodedBuffer[index + result] >= 0x80) { result++; } result++; // to account for the last byte if (index + result > encodedBuffer.length) { // FIXME(sven): seems to cause false positives // throw new Error("integer representa...
javascript
{ "resource": "" }
q46854
decodeBufferCommon
train
function decodeBufferCommon(encodedBuffer, index, signed) { index = index === undefined ? 0 : index; let length = encodedLength(encodedBuffer, index); const bitLength = length * 7; let byteLength = Math.ceil(bitLength / 8); let result = bufs.alloc(byteLength); let outIndex = 0; while (length > 0) { ...
javascript
{ "resource": "" }
q46855
vhost
train
function vhost (hostname, handle) { if (!hostname) { throw new TypeError('argument hostname is required') } if (!handle) { throw new TypeError('argument handle is required') } if (typeof handle !== 'function') { throw new TypeError('argument handle must be a function') } // create regular e...
javascript
{ "resource": "" }
q46856
hostnameof
train
function hostnameof (req) { var host = req.headers.host if (!host) { return } var offset = host[0] === '[' ? host.indexOf(']') + 1 : 0 var index = host.indexOf(':', offset) return index !== -1 ? host.substring(0, index) : host }
javascript
{ "resource": "" }
q46857
hostregexp
train
function hostregexp (val) { var source = !isregexp(val) ? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE) : val.source // force leading anchor matching if (source[0] !== '^') { source = '^' + source } // force trailing anchor matching if (!END_ANCH...
javascript
{ "resource": "" }
q46858
vhostof
train
function vhostof (req, regexp) { var host = req.headers.host var hostname = hostnameof(req) if (!hostname) { return } var match = regexp.exec(hostname) if (!match) { return } var obj = Object.create(null) obj.host = host obj.hostname = hostname obj.length = match.length - 1 for (va...
javascript
{ "resource": "" }
q46859
analyzeField
train
function analyzeField (field) { var obj = {} var namedType = field.type obj.name = field.name obj.isDeprecated = field.isDeprecated obj.deprecationReason = field.deprecationReason obj.defaultValue = field.defaultValue if (namedType.kind === 'NON_NULL') { obj.isRequired = true namedType = namedType...
javascript
{ "resource": "" }
q46860
processType
train
function processType (item, entities, types) { var type = _.find(types, { name: item }) var additionalTypes = [] // get the type names of the union or interface's possible types, given its type name var addPossibleTypes = typeName => { var union = _.find(types, { name: typeName }) var possibleTypes = _...
javascript
{ "resource": "" }
q46861
walkBFS
train
function walkBFS (obj, iter) { var q = _.map(_.keys(obj), k => { return { key: k, path: '["' + k + '"]' } }) var current var currentNode var retval var push = (v, k) => { q.push({ key: k, path: current.path + '["' + k + '"]' }) } while (q.length) { current = q.shift() currentNode = _.ge...
javascript
{ "resource": "" }
q46862
isEnabled
train
function isEnabled (obj) { var enabled = false if (obj.isEnumType) { enabled = !this.theme.enums.hide } else if (obj.isInputType) { enabled = !this.theme.inputs.hide } else if (obj.isInterfaceType) { enabled = !this.theme.interfaces.hide } else if (obj.isUnionType) { enabled = !this.theme.unio...
javascript
{ "resource": "" }
q46863
getColor
train
function getColor (obj) { var color = this.theme.types.color if (obj.isEnumType && !this.theme.enums.hide) { color = this.theme.enums.color } else if (obj.isInputType && !this.theme.inputs.hide) { color = this.theme.inputs.color } else if (obj.isInterfaceType && !this.theme.interfaces.hide) { color ...
javascript
{ "resource": "" }
q46864
createTable
train
function createTable (context) { var result = '"' + context.typeName + '" ' result += '[label=<<TABLE COLOR="' + context.color + '" BORDER="0" CELLBORDER="1" CELLSPACING="0">' result += '<TR><TD PORT="__title"' + (this.theme.header.invert ? ' BGCOLOR="' + context.color + '"' : '') + '><FON...
javascript
{ "resource": "" }
q46865
graph
train
function graph (processedTypes, typeTheme) { var result = '' if (typeTheme.group) { result += 'subgraph cluster_' + groupId++ + ' {' if (typeTheme.color) { result += 'color=' + typeTheme.color + ';' } if (typeTheme.groupLabel) { result += 'label="' + typeTheme.groupLabel + '";' } ...
javascript
{ "resource": "" }
q46866
fatal
train
function fatal (e, text) { console.error('ERROR processing input. Use --verbose flag to see output.') console.error(e.message) if (cli.flags.verbose) { console.error(text) } process.exit(1) }
javascript
{ "resource": "" }
q46867
introspect
train
function introspect (text) { return new Promise(function (resolve, reject) { try { var astDocument = parse(text) var schema = buildASTSchema(astDocument) graphql(schema, graphqlviz.query) .then(function (data) { resolve(data) }) .catch(function (e) { r...
javascript
{ "resource": "" }
q46868
train
function (done) { if (called) return; called = true; // wait for req events to fire process.nextTick(function() { if (waitend && req.readable) { // dump rest of request req.resume(); req.once('end', done); return; } done(); ...
javascript
{ "resource": "" }
q46869
Metrics
train
function Metrics(requests) { this.requests = requests; // The total amount of requests send this.connections = 0; // Connections established this.disconnects = 0; // Closed connections this.failures = 0; // Connections that received an error thi...
javascript
{ "resource": "" }
q46870
write
train
function write(socket, task, id, fn) { session[binary ? 'binary' : 'utf8'](task.size, function message(err, data) { var start = socket.last = Date.now(); socket.send(data, { binary: binary, mask: masked }, function sending(err) { if (err) { process.send({ type: 'error', message:...
javascript
{ "resource": "" }
q46871
toBuffer
train
function toBuffer (typed) { var ab = typed.buffer; var buffer = new Buffer(ab.byteLength); var view = new Uint8Array(ab); for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; } return buffer; }
javascript
{ "resource": "" }
q46872
ByteBuffer
train
function ByteBuffer(arg) { var initial_size; if (arg == null) { initial_size = 1024 * 1024; } else if (typeof arg === "number") { initial_size = arg; } else if (arg instanceof Uint8Array) { this.buffer = arg; this.position = 0; // Overwrite return; } else { ...
javascript
{ "resource": "" }
q46873
train
function (callback) { async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) { loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) { if(err) { return _callback(err); } ...
javascript
{ "resource": "" }
q46874
train
function (callback) { loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) { if(err) { return callback(err); } var cc_buffer = new Int16Array(buffer); dic.loadConnectionCosts(cc_buffer); c...
javascript
{ "resource": "" }
q46875
DynamicDictionaries
train
function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) { if (trie != null) { this.trie = trie; } else { this.trie = doublearray.builder(0).build([ {k: "", v: 1} ]); } if (token_info_dictionary != null) { this.token_info...
javascript
{ "resource": "" }
q46876
ViterbiNode
train
function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) { this.name = node_name; this.cost = node_cost; this.start_pos = start_pos; this.length = length; this.left_id = left_id; this.right_id = right_id; this.prev = null; this.surface_form = s...
javascript
{ "resource": "" }
q46877
MultiId
train
function MultiId(node) { this.nodes = Object.create(null); this.nodes[node._nid] = node; this.length = 1; this.firstNode = undefined; }
javascript
{ "resource": "" }
q46878
isA
train
function isA(elt, set) { if (typeof set === 'string') { // convenience case for testing a particular HTML element return elt.namespaceURI === NAMESPACE.HTML && elt.localName === set; } var tagnames = set[elt.namespaceURI]; return tagnames && tagnames[elt.localName]; }
javascript
{ "resource": "" }
q46879
equal
train
function equal(newelt, oldelt, oldattrs) { if (newelt.localName !== oldelt.localName) return false; if (newelt._numattrs !== oldattrs.length) return false; for(var i = 0, n = oldattrs.length; i < n; i++) { var oldname = oldattrs[i][0]; var oldval = oldattrs[i][1]; if (!newelt.hasAttribute(...
javascript
{ "resource": "" }
q46880
train
function() { var frag = doc.createDocumentFragment(); var root = doc.firstChild; while(root.hasChildNodes()) { frag.appendChild(root.firstChild); } return frag; }
javascript
{ "resource": "" }
q46881
handleSimpleAttribute
train
function handleSimpleAttribute() { SIMPLEATTR.lastIndex = nextchar-1; var matched = SIMPLEATTR.exec(chars); if (!matched) throw new Error("should never happen"); var name = matched[1]; if (!name) return false; var value = matched[2]; var len = value.length; switch(value[0]) { case '"...
javascript
{ "resource": "" }
q46882
getMatchingChars
train
function getMatchingChars(pattern) { pattern.lastIndex = nextchar - 1; var match = pattern.exec(chars); if (match && match.index === nextchar - 1) { match = match[0]; nextchar += match.length - 1; /* Careful! Make sure we haven't matched the EOF character! */ if (input_complete && n...
javascript
{ "resource": "" }
q46883
emitCharsWhile
train
function emitCharsWhile(pattern) { pattern.lastIndex = nextchar-1; var match = pattern.exec(chars)[0]; if (!match) return false; emitCharString(match); nextchar += match.length - 1; return true; }
javascript
{ "resource": "" }
q46884
emitCharString
train
function emitCharString(s) { if (textrun.length > 0) flushText(); if (ignore_linefeed) { ignore_linefeed = false; if (s[0] === "\n") s = s.substring(1); if (s.length === 0) return; } insertToken(TEXT, s); }
javascript
{ "resource": "" }
q46885
insertElement
train
function insertElement(eltFunc) { var elt; if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) { elt = fosterParent(eltFunc); } else if (stack.top instanceof impl.HTMLTemplateElement) { // "If the adjusted insertion location is inside a template element, // let it instead be ...
javascript
{ "resource": "" }
q46886
after_attribute_name_state
train
function after_attribute_name_state(c) { switch(c) { case 0x0009: // CHARACTER TABULATION (tab) case 0x000A: // LINE FEED (LF) case 0x000C: // FORM FEED (FF) case 0x0020: // SPACE /* Ignore the character. */ break; case 0x002F: // SOLIDUS // Keep in sync with before_attribute_n...
javascript
{ "resource": "" }
q46887
before_html_mode
train
function before_html_mode(t,value,arg3,arg4) { var elt; switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ ...
javascript
{ "resource": "" }
q46888
before_head_mode
train
function before_head_mode(t,value,arg3,arg4) { switch(t) { case 1: // TEXT value = value.replace(LEADINGWS, ""); // Ignore spaces if (value.length === 0) return; // Are we done? break; // Handle anything non-space text below case 5: // DOCTYPE /* ignore the token */ return; ...
javascript
{ "resource": "" }
q46889
in_head_noscript_mode
train
function in_head_noscript_mode(t, value, arg3, arg4) { switch(t) { case 5: // DOCTYPE return; case 4: // COMMENT in_head_mode(t, value); return; case 1: // TEXT var ws = value.match(LEADINGWS); if (ws) { in_head_mode(t, ws[0]); value = value.substring(ws[0]....
javascript
{ "resource": "" }
q46890
train
function(event) { return (this._armed !== null && event.type === 'mouseup' && event.isTrusted && event.button === 0 && event.timeStamp - this._armed.t < 1000 && Math.abs(event.clientX - this._armed.x) < 10 && Math.abs(event.clientY - this._armed.Y) < 10); }
javascript
{ "resource": "" }
q46891
train
function(filter){ var buffer = "", c = this.read(); while(c !== null && filter(c)){ buffer += c; c = this.read(); } return buffer; }
javascript
{ "resource": "" }
q46892
train
function(matcher){ var source = this._input.substring(this._cursor), value = null; //if it's a string, just do a straight match if (typeof matcher === "string"){ if (source.indexOf(matcher) === 0){ value = this.readCount(matcher.length); } ...
javascript
{ "resource": "" }
q46893
TokenStreamBase
train
function TokenStreamBase(input, tokenData){ /** * The string reader for easy access to the text. * @type StringReader * @property _reader * @private */ this._reader = input ? new StringReader(input.toString()) : null; /** * Token object for the last consumed token. * @ty...
javascript
{ "resource": "" }
q46894
Attr
train
function Attr(elt, lname, prefix, namespace, value) { // localName and namespace are constant for any attr object. // But value may change. And so can prefix, and so, therefore can name. this.localName = lname; this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix); this.namespaceURI = (namespac...
javascript
{ "resource": "" }
q46895
train
function(version) { var result; /** local */ var ensure = function(key) { return function(r) { if (r && !r[key]) { throw new Error('result missing ' + key); } return r; }; }; return plugins.first(function(plugin) { return Promise.resolve() .then(function() { return plugin.match(ver...
javascript
{ "resource": "" }
q46896
train
function(error) { return util.format(' %s: %s', chalk.magenta(error.plugin.name), error.message); }
javascript
{ "resource": "" }
q46897
train
function() { return Promise.resolve() .then(function() { return npm.loadAsync(); }) .then(function(npm) { npm.config.set('spin', false); npm.config.set('global', true); npm.config.set('depth', 0); return Promise.promisify(npm.commands.list)([], true); }) .then(function(data) { return data; });...
javascript
{ "resource": "" }
q46898
addTodo
train
function addTodo(text) { var todo = { _id: new Date().toISOString(), title: text, completed: false }; db.put(todo, function callback (err, result) { if (!err) { console.log('Successfully posted a todo!'); } }); }
javascript
{ "resource": "" }
q46899
showTodos
train
function showTodos() { db.allDocs({ include_docs: true, descending: true }, function(err, doc) { redrawTodosUI(doc.rows); }); }
javascript
{ "resource": "" }