_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q26600
parseScopeSyntax
train
function parseScopeSyntax(text) { // the regex below was built using the following pseudo-code: // double_quoted_string = `"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"` // single_quoted_string = `'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'` // text_out_of_quotes = `[^"']*?` // expr_parts = double_quoted_string + "|" + single_...
javascript
{ "resource": "" }
q26601
execute
train
function execute(args) { try { const currentOptions = options.parse(args) return executeOptions(currentOptions) } catch (error) { console.error(error.message) return 1 } }
javascript
{ "resource": "" }
q26602
getJsonBufferPadded
train
function getJsonBufferPadded(json) { let string = JSON.stringify(json); const boundary = 4; const byteLength = Buffer.byteLength(string); const remainder = byteLength % boundary; const padding = (remainder === 0) ? 0 : boundary - remainder; let whitespace = ''; for (let i = 0; i < padding; ...
javascript
{ "resource": "" }
q26603
readLines
train
function readLines(path, callback) { return new Promise(function(resolve, reject) { const stream = fsExtra.createReadStream(path); stream.on('error', reject); stream.on('end', resolve); const lineReader = readline.createInterface({ input : stream }); line...
javascript
{ "resource": "" }
q26604
gltfToGlb
train
function gltfToGlb(gltf, binaryBuffer) { const buffer = gltf.buffers[0]; if (defined(buffer.uri)) { binaryBuffer = Buffer.alloc(0); } // Create padded binary scene string const jsonBuffer = getJsonBufferPadded(gltf); // Allocate buffer (Global header) + (JSON chunk header) + (JSON chun...
javascript
{ "resource": "" }
q26605
obj2gltf
train
function obj2gltf(objPath, options) { const defaults = obj2gltf.defaults; options = defaultValue(options, {}); options.binary = defaultValue(options.binary, defaults.binary); options.separate = defaultValue(options.separate, defaults.separate); options.separateTextures = defaultValue(options.separat...
javascript
{ "resource": "" }
q26606
loadTexture
train
function loadTexture(texturePath, options) { options = defaultValue(options, {}); options.checkTransparency = defaultValue(options.checkTransparency, false); options.decode = defaultValue(options.decode, false); return fsExtra.readFile(texturePath) .then(function(source) { const nam...
javascript
{ "resource": "" }
q26607
Texture
train
function Texture() { this.transparent = false; this.source = undefined; this.name = undefined; this.extension = undefined; this.path = undefined; this.pixels = undefined; this.width = undefined; this.height = undefined; }
javascript
{ "resource": "" }
q26608
getBufferPadded
train
function getBufferPadded(buffer) { const boundary = 4; const byteLength = buffer.length; const remainder = byteLength % boundary; if (remainder === 0) { return buffer; } const padding = (remainder === 0) ? 0 : boundary - remainder; const emptyBuffer = Buffer.alloc(padding); retur...
javascript
{ "resource": "" }
q26609
createGltf
train
function createGltf(objData, options) { const nodes = objData.nodes; let materials = objData.materials; const name = objData.name; // Split materials used by primitives with different types of attributes materials = splitIncompatibleMaterials(nodes, materials, options); const gltf = { ...
javascript
{ "resource": "" }
q26610
writeGltf
train
function writeGltf(gltf, options) { return encodeTextures(gltf) .then(function() { const binary = options.binary; const separate = options.separate; const separateTextures = options.separateTextures; const promises = []; if (separateTextures) { ...
javascript
{ "resource": "" }
q26611
ls
train
function ls (onEnd) { const FN = require('fstream-npm') const color = require('chalk') const glob = require('glob') const exclude = require('lodash.difference') const included = [ ] const all = glob.sync('**/**', { ignore : [ 'node_modules/**/**' ], nodir : true }) FN({ path: process.cwd() })...
javascript
{ "resource": "" }
q26612
createBitbucketEnterpriseCommitLink
train
function createBitbucketEnterpriseCommitLink () { const pkg = require(process.cwd() + '/package') const repository = pkg.repository.url return function (commit) { const commitStr = commit.substring(0,8) return repository ? `[${commitStr}](${repository}/commits/${commitStr})` : commitStr } }
javascript
{ "resource": "" }
q26613
writeChangelog
train
function writeChangelog (options, done) { options.repoType = options.repoType || 'github' log('Using repo type: ', colors.magenta(options.repoType)) const pkg = require(process.cwd() + '/package') const opts = { log: log, repository: pkg.repository.url, version: options.version } // Github u...
javascript
{ "resource": "" }
q26614
caller
train
function caller() { const returnedArgs = Array.prototype.slice.call(arguments) const fn = returnedArgs.shift() const self = this return wrapPromise(function (resolve, reject) { returnedArgs.push(function (err, args) { if (err) { reject(err) return } resolve(args) }) ...
javascript
{ "resource": "" }
q26615
defaultWorkerPolicies
train
function defaultWorkerPolicies(version, workspaceSid, workerSid) { var activities = new Policy({ url: _.join([TASKROUTER_BASE_URL, version, 'Workspaces', workspaceSid, 'Activities'], '/'), method: 'GET', allow: true }); var tasks = new Policy({ url: _.join([TASKROUTER_BASE_URL, version, 'Workspace...
javascript
{ "resource": "" }
q26616
defaultEventBridgePolicies
train
function defaultEventBridgePolicies(accountSid, channelId) { var url = _.join([EVENT_URL_BASE, accountSid, channelId], '/'); return [ new Policy({ url: url, method: 'GET', allow: true }), new Policy({ url: url, method: 'POST', allow: true }) ]; }
javascript
{ "resource": "" }
q26617
workspacesUrl
train
function workspacesUrl(workspaceSid) { return _.join( _.filter([TASKROUTER_BASE_URL, TASKROUTER_VERSION, 'Workspaces', workspaceSid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26618
taskQueuesUrl
train
function taskQueuesUrl(workspaceSid, taskQueueSid) { return _.join( _.filter([workspacesUrl(workspaceSid), 'TaskQueues', taskQueueSid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26619
tasksUrl
train
function tasksUrl(workspaceSid, taskSid) { return _.join( _.filter([workspacesUrl(workspaceSid), 'Tasks', taskSid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26620
activitiesUrl
train
function activitiesUrl(workspaceSid, activitySid) { return _.join( _.filter([workspacesUrl(workspaceSid), 'Activities', activitySid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26621
workersUrl
train
function workersUrl(workspaceSid, workerSid) { return _.join( _.filter([workspacesUrl(workspaceSid), 'Workers', workerSid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26622
reservationsUrl
train
function reservationsUrl(workspaceSid, workerSid, reservationSid) { return _.join( _.filter([workersUrl(workspaceSid, workerSid), 'Reservations', reservationSid], _.isString), '/' ); }
javascript
{ "resource": "" }
q26623
Policy
train
function Policy(options) { options = options || {}; this.url = options.url; this.method = options.method || 'GET'; this.queryFilter = options.queryFilter || {}; this.postFilter = options.postFilter || {}; this.allow = options.allow || true; }
javascript
{ "resource": "" }
q26624
getExpectedTwilioSignature
train
function getExpectedTwilioSignature(authToken, url, params) { if (url.indexOf('bodySHA256') != -1) params = {}; var data = Object.keys(params) .sort() .reduce((acc, key) => acc + key + params[key], url); return crypto .createHmac('sha1', authToken) .update(Buffer.from(data, 'utf-8')) .diges...
javascript
{ "resource": "" }
q26625
validateRequest
train
function validateRequest(authToken, twilioHeader, url, params) { var expectedSignature = getExpectedTwilioSignature(authToken, url, params); return scmp(Buffer.from(twilioHeader), Buffer.from(expectedSignature)); }
javascript
{ "resource": "" }
q26626
validateRequestWithBody
train
function validateRequestWithBody(authToken, twilioHeader, requestUrl, body) { var urlObject = new url.URL(requestUrl); return validateRequest(authToken, twilioHeader, requestUrl, {}) && validateBody(body, urlObject.searchParams.get('bodySHA256')); }
javascript
{ "resource": "" }
q26627
getTruncatedOptions
train
function getTruncatedOptions(options, maxResults) { if (!maxResults || maxResults >= options.length) { return options; } return options.slice(0, maxResults); }
javascript
{ "resource": "" }
q26628
gpmMouse
train
function gpmMouse( mode ) { var self = this ; if ( this.root.gpmHandler ) { this.root.gpmHandler.close() ; this.root.gpmHandler = undefined ; } if ( ! mode ) { //console.log( '>>>>> off <<<<<' ) ; return ; } this.root.gpmHandler = gpm.createHandler( { stdin: this.root.stdin , raw: false , mode: mode }...
javascript
{ "resource": "" }
q26629
TextBuffer
train
function TextBuffer( options = {} ) { this.ScreenBuffer = options.ScreenBuffer || ( options.dst && options.dst.constructor ) || termkit.ScreenBuffer ; // a screenBuffer this.dst = options.dst ; // virtually infinity by default this.width = options.width || Infinity ; this.height = options.height || Infinity ; ...
javascript
{ "resource": "" }
q26630
onResize
train
function onResize() { if ( this.stdout.columns && this.stdout.rows ) { this.width = this.stdout.columns ; this.height = this.stdout.rows ; } this.emit( 'resize' , this.width , this.height ) ; }
javascript
{ "resource": "" }
q26631
parseValueOfType
train
function parseValueOfType(value, type, options) { switch (type) { case String: return { value } case Number: case 'Integer': case Integer: // The global isFinite() function determines // whether the passed value is a finite number. // If needed, the parameter is first convert...
javascript
{ "resource": "" }
q26632
MergeRowsWithHeaders
train
function MergeRowsWithHeaders(obj1, obj2) { for(var p in obj2){ if(obj1[p] instanceof Array && obj1[p] instanceof Array){ obj1[p] = obj1[p].concat(obj2[p]) } else { obj1[p] = obj2[p] } } return obj1; }
javascript
{ "resource": "" }
q26633
parse
train
function parse() { var self = this var value = String(self.file) var start = {line: 1, column: 1, offset: 0} var content = xtend(start) var node // Clean non-unix newlines: `\r\n` and `\r` are all changed to `\n`. // This should not affect positional information. value = value.replace(lineBreaksExpress...
javascript
{ "resource": "" }
q26634
alignment
train
function alignment(value, index) { var start = value.lastIndexOf(lineFeed, index) var end = value.indexOf(lineFeed, index) var char end = end === -1 ? value.length : end while (++start < end) { char = value.charAt(start) if ( char !== colon && char !== dash && char !== space && ...
javascript
{ "resource": "" }
q26635
protocol
train
function protocol(value) { var val = value.slice(-6).toLowerCase() return val === mailto || val.slice(-5) === https || val.slice(-4) === http }
javascript
{ "resource": "" }
q26636
Compiler
train
function Compiler(tree, file) { this.inLink = false this.inTable = false this.tree = tree this.file = file this.options = xtend(this.options) this.setOptions({}) }
javascript
{ "resource": "" }
q26637
pedanticListItem
train
function pedanticListItem(ctx, value, position) { var offsets = ctx.offset var line = position.line // Remove the list-item’s bullet. value = value.replace(pedanticBulletExpression, replacer) // The initial line was also matched by the below, so we reset the `line`. line = position.line return value.re...
javascript
{ "resource": "" }
q26638
normalListItem
train
function normalListItem(ctx, value, position) { var offsets = ctx.offset var line = position.line var max var bullet var rest var lines var trimmedLines var index var length // Remove the list-item’s bullet. value = value.replace(bulletExpression, replacer) lines = value.split(lineFeed) tri...
javascript
{ "resource": "" }
q26639
indentation
train
function indentation(value) { var index = 0 var indent = 0 var character = value.charAt(index) var stops = {} var size while (character === tab || character === space) { size = character === tab ? tabSize : spaceSize indent += size if (size > 1) { indent = Math.floor(indent / size) * si...
javascript
{ "resource": "" }
q26640
all
train
function all(parent) { var self = this var children = parent.children var length = children.length var results = [] var index = -1 while (++index < length) { results[index] = self.visit(children[index], parent) } return results }
javascript
{ "resource": "" }
q26641
factory
train
function factory(ctx, key) { return unescape // De-escape a string using the expression at `key` in `ctx`. function unescape(value) { var prev = 0 var index = value.indexOf(backslash) var escape = ctx[key] var queue = [] var character while (index !== -1) { queue.push(value.slice(p...
javascript
{ "resource": "" }
q26642
paragraph
train
function paragraph(eat, value, silent) { var self = this var settings = self.options var commonmark = settings.commonmark var gfm = settings.gfm var tokenizers = self.blockTokenizers var interruptors = self.interruptParagraph var index = value.indexOf(lineFeed) var length = value.length var position ...
javascript
{ "resource": "" }
q26643
keys
train
function keys(value) { var result = [] var key for (key in value) { result.push(key) } return result }
javascript
{ "resource": "" }
q26644
updatePosition
train
function updatePosition(subvalue) { var lastIndex = -1 var index = subvalue.indexOf('\n') while (index !== -1) { line++ lastIndex = index index = subvalue.indexOf('\n', index + 1) } if (lastIndex === -1) { column += subvalue.length } else { c...
javascript
{ "resource": "" }
q26645
now
train
function now() { var pos = {line: line, column: column} pos.offset = self.toOffset(pos) return pos }
javascript
{ "resource": "" }
q26646
add
train
function add(node, parent) { var children = parent ? parent.children : tokens var prev = children[children.length - 1] var fn if ( prev && node.type === prev.type && (node.type === 'text' || node.type === 'blockquote') && mergeable(prev) && mergeable(node...
javascript
{ "resource": "" }
q26647
eat
train
function eat(subvalue) { var indent = getOffset() var pos = position() var current = now() validateEat(subvalue) apply.reset = reset reset.test = test apply.test = test value = value.substring(subvalue.length) updatePosition(subvalue) indent = indent() ...
javascript
{ "resource": "" }
q26648
mergeable
train
function mergeable(node) { var start var end if (node.type !== 'text' || !node.position) { return true } start = node.position.start end = node.position.end // Only merge nodes which occupy the same size as their `value`. return ( start.line !== end.line || end.column - start.column === node....
javascript
{ "resource": "" }
q26649
factory
train
function factory(ctx) { decoder.raw = decodeRaw return decoder // Normalize `position` to add an `indent`. function normalize(position) { var offsets = ctx.offset var line = position.line var result = [] while (++line) { if (!(line in offsets)) { break } result.push...
javascript
{ "resource": "" }
q26650
normalize
train
function normalize(position) { var offsets = ctx.offset var line = position.line var result = [] while (++line) { if (!(line in offsets)) { break } result.push((offsets[line] || 0) + 1) } return {start: position, indent: result} }
javascript
{ "resource": "" }
q26651
setOptions
train
function setOptions(options) { var self = this var current = self.options var ruleRepetition var key if (options == null) { options = {} } else if (typeof options === 'object') { options = xtend(options) } else { throw new Error('Invalid value `' + options + '` for setting `options`') } ...
javascript
{ "resource": "" }
q26652
encodeFactory
train
function encodeFactory(type) { var options = {} if (type === 'false') { return identity } if (type === 'true') { options.useNamedReferences = true } if (type === 'escape') { options.escapeOnly = true options.useNamedReferences = true } return wrapped // Encode HTML entities using ...
javascript
{ "resource": "" }
q26653
getLocaleDateTimeFormat
train
function getLocaleDateTimeFormat(locale, width) { var data = findLocaleData(locale); var dateTimeFormatData = data[12 /* DateTimeFormat */]; return getLastDefinedValue(dateTimeFormatData, width); }
javascript
{ "resource": "" }
q26654
getLastDefinedValue
train
function getLastDefinedValue(data, index) { for (var i = index; i > -1; i--) { if (typeof data[i] !== 'undefined') { return data[i]; } } throw new Error('Locale data API: locale data undefined'); }
javascript
{ "resource": "" }
q26655
findLocaleData
train
function findLocaleData(locale) { var normalizedLocale = locale.toLowerCase().replace(/_/g, '-'); var match = LOCALE_DATA[normalizedLocale]; if (match) { return match; } // let's try to find a parent locale var parentLocale = normalizedLocale.split('-')[0]; match = LOCALE_DATA[parent...
javascript
{ "resource": "" }
q26656
getNumberOfCurrencyDigits
train
function getNumberOfCurrencyDigits(code) { var digits; var currency = CURRENCIES_EN[code]; if (currency) { digits = currency[2 /* NbOfDigits */]; } return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS; }
javascript
{ "resource": "" }
q26657
dateStrGetter
train
function dateStrGetter(name, width, form, extended) { if (form === void 0) { form = FormStyle.Format; } if (extended === void 0) { extended = false; } return function (date, locale) { return getDateTranslation(date, locale, name, width, form, extended); }; }
javascript
{ "resource": "" }
q26658
toDate
train
function toDate(value) { if (isDate(value)) { return value; } if (typeof value === 'number' && !isNaN(value)) { return new Date(value); } if (typeof value === 'string') { value = value.trim(); var parsedNb = parseFloat(value); // any string that only contains ...
javascript
{ "resource": "" }
q26659
toPercent
train
function toPercent(parsedNumber) { // if the number is 0, don't do anything if (parsedNumber.digits[0] === 0) { return parsedNumber; } // Getting the current number of decimals var fractionLen = parsedNumber.digits.length - parsedNumber.integerLen; if (parsedNumber.exponent) { pa...
javascript
{ "resource": "" }
q26660
HttpHeaderResponse
train
function HttpHeaderResponse(init) { if (init === void 0) { init = {}; } var _this = _super.call(this, init) || this; _this.type = HttpEventType.ResponseHeader; return _this; }
javascript
{ "resource": "" }
q26661
HttpResponse
train
function HttpResponse(init) { if (init === void 0) { init = {}; } var _this = _super.call(this, init) || this; _this.type = HttpEventType.Response; _this.body = init.body !== undefined ? init.body : null; return _this; }
javascript
{ "resource": "" }
q26662
getResponseUrl
train
function getResponseUrl(xhr) { if ('responseURL' in xhr && xhr.responseURL) { return xhr.responseURL; } if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) { return xhr.getResponseHeader('X-Request-URL'); } return null; }
javascript
{ "resource": "" }
q26663
train
function () { if (headerResponse !== null) { return headerResponse; } // Read status and normalize an IE9 bug (http://bugs.jquery.com/ticket/1450). var status = xhr.status === 1223 ? 204 : xhr.status; var statusText = xh...
javascript
{ "resource": "" }
q26664
train
function () { // Read response state from the memoized partial data. var _a = partialFromXhr(), headers = _a.headers, status = _a.status, statusText = _a.statusText, url = _a.url; // The body will be read out if present. var body = null; if...
javascript
{ "resource": "" }
q26665
train
function (error) { var res = new HttpErrorResponse({ error: error, status: xhr.status || 0, statusText: xhr.statusText || 'Unknown Error', }); observer.error(res); }
javascript
{ "resource": "" }
q26666
train
function (event) { // Send the HttpResponseHeaders event if it hasn't been sent already. if (!sentHeaders) { observer.next(partialFromXhr()); sentHeaders = true; } // Start building the download progress event to del...
javascript
{ "resource": "" }
q26667
train
function (event) { // Upload progress events are simpler. Begin building the progress // event. var progress = { type: HttpEventType.UploadProgress, loaded: event.loaded, }; // If the total number of ...
javascript
{ "resource": "" }
q26668
defineInjector
train
function defineInjector(options) { return { factory: options.factory, providers: options.providers || [], imports: options.imports || [], }; }
javascript
{ "resource": "" }
q26669
resolveForwardRef
train
function resolveForwardRef(type) { if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') && type.__forward_ref__ === forwardRef) { return type(); } else { return type; } }
javascript
{ "resource": "" }
q26670
resolveReflectiveProvider
train
function resolveReflectiveProvider(provider) { return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false); }
javascript
{ "resource": "" }
q26671
EventEmitter
train
function EventEmitter(isAsync) { if (isAsync === void 0) { isAsync = false; } var _this = _super.call(this) || this; _this.__isAsync = isAsync; return _this; }
javascript
{ "resource": "" }
q26672
registerModuleFactory
train
function registerModuleFactory(id, factory) { var existing = moduleFactories.get(id); if (existing) { throw new Error("Duplicate module registered for " + id + " - " + existing.moduleType.name + " vs " + factory.moduleType.name); } moduleFactories.set(id, factory); }
javascript
{ "resource": "" }
q26673
shouldCallLifecycleInitHook
train
function shouldCallLifecycleInitHook(view, initState, index) { if ((view.state & 1792 /* InitState_Mask */) === initState && view.initIndex <= index) { view.initIndex = index + 1; return true; } return false; }
javascript
{ "resource": "" }
q26674
viewParentEl
train
function viewParentEl(view) { var parentView = view.parent; if (parentView) { return view.parentNodeDef.parent; } else { return null; } }
javascript
{ "resource": "" }
q26675
queueLifecycleHooks
train
function queueLifecycleHooks(flags, tView) { if (tView.firstTemplatePass) { var start = flags >> 14 /* DirectiveStartingIndexShift */; var count = flags & 4095 /* DirectiveCountMask */; var end = start + count; // It's necessary to loop through the directives at elementEnd() (rather ...
javascript
{ "resource": "" }
q26676
queueContentHooks
train
function queueContentHooks(def, tView, i) { if (def.afterContentInit) { (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentInit); } if (def.afterContentChecked) { (tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentChecked); (tView.content...
javascript
{ "resource": "" }
q26677
queueViewHooks
train
function queueViewHooks(def, tView, i) { if (def.afterViewInit) { (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewInit); } if (def.afterViewChecked) { (tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewChecked); (tView.viewCheckHooks || (tView.viewCheck...
javascript
{ "resource": "" }
q26678
queueDestroyHooks
train
function queueDestroyHooks(def, tView, i) { if (def.onDestroy != null) { (tView.destroyHooks || (tView.destroyHooks = [])).push(i, def.onDestroy); } }
javascript
{ "resource": "" }
q26679
executeInitHooks
train
function executeInitHooks(currentView, tView, creationMode) { if (currentView[FLAGS] & 16 /* RunInit */) { executeHooks(currentView[DIRECTIVES], tView.initHooks, tView.checkHooks, creationMode); currentView[FLAGS] &= ~16 /* RunInit */; } }
javascript
{ "resource": "" }
q26680
executeHooks
train
function executeHooks(data, allHooks, checkHooks, creationMode) { var hooksToCall = creationMode ? allHooks : checkHooks; if (hooksToCall) { callHooks(data, hooksToCall); } }
javascript
{ "resource": "" }
q26681
throwErrorIfNoChangesMode
train
function throwErrorIfNoChangesMode(creationMode, checkNoChangesMode, oldValue, currValue) { if (checkNoChangesMode) { var msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'."; if (cre...
javascript
{ "resource": "" }
q26682
flatten$1
train
function flatten$1(list) { var result = []; var i = 0; while (i < list.length) { var item = list[i]; if (Array.isArray(item)) { if (item.length > 0) { list = item.concat(list.slice(i + 1)); i = 0; } else { i+...
javascript
{ "resource": "" }
q26683
loadInternal
train
function loadInternal(index, arr) { ngDevMode && assertDataInRangeInternal(index + HEADER_OFFSET, arr); return arr[index + HEADER_OFFSET]; }
javascript
{ "resource": "" }
q26684
getChildLNode
train
function getChildLNode(node) { if (node.tNode.child) { var viewData = node.tNode.type === 2 /* View */ ? node.data : node.view; return readElementValue(viewData[node.tNode.child.index]); } return null; }
javascript
{ "resource": "" }
q26685
walkLNodeTree
train
function walkLNodeTree(startingNode, rootNode, action, renderer, renderParentNode, beforeNode) { var node = startingNode; var projectionNodeIndex = -1; while (node) { var nextNode = null; var parent_1 = renderParentNode ? renderParentNode.native : null; var nodeType = node.tNode.type...
javascript
{ "resource": "" }
q26686
destroyViewTree
train
function destroyViewTree(rootView) { // If the view has no children, we can clean it up and return early. if (rootView[TVIEW].childIndex === -1) { return cleanUpView(rootView); } var viewOrContainer = getLViewChild(rootView); while (viewOrContainer) { var next = null; if (vie...
javascript
{ "resource": "" }
q26687
insertView
train
function insertView(container, viewNode, index) { var state = container.data; var views = state[VIEWS]; var lView = viewNode.data; if (index > 0) { // This is a new view, we need to add it to the children. views[index - 1].data[NEXT] = lView; } if (index < views.length) { ...
javascript
{ "resource": "" }
q26688
detachView
train
function detachView(container, removeIndex) { var views = container.data[VIEWS]; var viewNode = views[removeIndex]; if (removeIndex > 0) { views[removeIndex - 1].data[NEXT] = viewNode.data[NEXT]; } views.splice(removeIndex, 1); if (!container.tNode.detached) { addRemoveViewFromCo...
javascript
{ "resource": "" }
q26689
removeView
train
function removeView(container, removeIndex) { var viewNode = container.data[VIEWS][removeIndex]; detachView(container, removeIndex); destroyLView(viewNode.data); return viewNode; }
javascript
{ "resource": "" }
q26690
getLViewChild
train
function getLViewChild(viewData) { if (viewData[TVIEW].childIndex === -1) return null; var hostNode = viewData[viewData[TVIEW].childIndex]; return hostNode.data ? hostNode.data : hostNode.dynamicLContainerNode.data; }
javascript
{ "resource": "" }
q26691
getParentState
train
function getParentState(state, rootView) { var node; if ((node = state[HOST_NODE]) && node.tNode.type === 2 /* View */) { // if it's an embedded view, the state needs to go up to the container, in case the // container has a next return getParentLNode(node).data; } else { ...
javascript
{ "resource": "" }
q26692
cleanUpView
train
function cleanUpView(viewOrContainer) { if (viewOrContainer[TVIEW]) { var view = viewOrContainer; removeListeners(view); executeOnDestroys(view); executePipeOnDestroys(view); // For component views only, the local renderer is destroyed as clean up time. if (view[TVIEW...
javascript
{ "resource": "" }
q26693
removeListeners
train
function removeListeners(viewData) { var cleanup = viewData[TVIEW].cleanup; if (cleanup != null) { for (var i = 0; i < cleanup.length - 1; i += 2) { if (typeof cleanup[i] === 'string') { // This is a listener with the native renderer var native = readElementVa...
javascript
{ "resource": "" }
q26694
executeOnDestroys
train
function executeOnDestroys(view) { var tView = view[TVIEW]; var destroyHooks; if (tView != null && (destroyHooks = tView.destroyHooks) != null) { callHooks(view[DIRECTIVES], destroyHooks); } }
javascript
{ "resource": "" }
q26695
executePipeOnDestroys
train
function executePipeOnDestroys(viewData) { var pipeDestroyHooks = viewData[TVIEW] && viewData[TVIEW].pipeDestroyHooks; if (pipeDestroyHooks) { callHooks(viewData, pipeDestroyHooks); } }
javascript
{ "resource": "" }
q26696
canInsertNativeNode
train
function canInsertNativeNode(parent, currentView) { // We can only insert into a Component or View. Any other type should be an Error. ngDevMode && assertNodeOfPossibleTypes(parent, 3 /* Element */, 2 /* View */); if (parent.tNode.type === 3 /* Element */) { // Parent is an element. if (pare...
javascript
{ "resource": "" }
q26697
appendChild
train
function appendChild(parent, child, currentView) { if (child !== null && canInsertNativeNode(parent, currentView)) { var renderer = currentView[RENDERER]; if (parent.tNode.type === 2 /* View */) { var container = getParentLNode(parent); var renderParent = container.data[RENDE...
javascript
{ "resource": "" }
q26698
removeChild
train
function removeChild(parent, child, currentView) { if (child !== null && canInsertNativeNode(parent, currentView)) { // We only remove the element if not in View or not projected. var renderer = currentView[RENDERER]; isProceduralRenderer(renderer) ? renderer.removeChild(parent.native, child...
javascript
{ "resource": "" }
q26699
appendProjectedNode
train
function appendProjectedNode(node, currentParent, currentView, renderParent) { appendChild(currentParent, node.native, currentView); if (node.tNode.type === 0 /* Container */) { // The node we are adding is a container and we are adding it to an element which // is not a component (no more re-pr...
javascript
{ "resource": "" }