_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20100 | train | function(ev) {
if (sourceElem === target[0] && ev.target === target[0]) {
ev.stopPropagation();
ev.preventDefault();
smartClose();
}
} | javascript | {
"resource": ""
} | |
q20101 | configureAria | train | function configureAria(element, options) {
var role = (options.$type === 'alert') ? 'alertdialog' : 'dialog';
var dialogContent = element.find('md-dialog-content');
var existingDialogId = element.attr('id');
var dialogContentId = 'dialogContent_' + (existingDialogId || $mdUtil.nextUid());
... | javascript | {
"resource": ""
} |
q20102 | lockScreenReader | train | function lockScreenReader(element, options) {
var isHidden = true;
// get raw DOM node
walkDOM(element[0]);
options.unlockScreenReader = function () {
isHidden = false;
walkDOM(element[0]);
options.unlockScreenReader = null;
};
/**
* Get all of an e... | javascript | {
"resource": ""
} |
q20103 | getParents | train | function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if i... | javascript | {
"resource": ""
} |
q20104 | walkDOM | train | function walkDOM(element) {
var elements = getParents(element);
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('aria-hidden', isHidden);
}
} | javascript | {
"resource": ""
} |
q20105 | stretchDialogContainerToViewport | train | function stretchDialogContainerToViewport(container, options) {
var isFixed = $window.getComputedStyle($document[0].body).position == 'fixed';
var backdrop = options.backdrop ? $window.getComputedStyle(options.backdrop[0]) : null;
var height = backdrop ? Math.min($document[0].body.clientHeight, Math.c... | javascript | {
"resource": ""
} |
q20106 | dialogPopIn | train | function dialogPopIn(container, options) {
// Add the `md-dialog-container` to the DOM
options.parent.append(container);
options.reverseContainerStretch = stretchDialogContainerToViewport(container, options);
var dialogEl = container.find('md-dialog');
var animator = $mdUtil.dom.animator;... | javascript | {
"resource": ""
} |
q20107 | dialogPopOut | train | function dialogPopOut(container, options) {
return options.reverseAnimate().then(function() {
if (options.contentElement) {
// When we use a contentElement, we want the element to be the same as before.
// That means, that we have to clear all the animation properties, like transform.
... | javascript | {
"resource": ""
} |
q20108 | watchAttributes | train | function watchAttributes() {
attr.$observe('value', function(value) {
var percentValue = clamp(value);
element.attr('aria-valuenow', percentValue);
if (mode() != MODE_QUERY) animateIndicator(bar2, percentValue);
});
attr.$observe('mdBufferValue', function(value) {
ani... | javascript | {
"resource": ""
} |
q20109 | validateMode | train | function validateMode() {
if (angular.isUndefined(attr.mdMode)) {
var hasValue = angular.isDefined(attr.value);
var mode = hasValue ? MODE_DETERMINATE : MODE_INDETERMINATE;
var info = "Auto-adding the missing md-mode='{0}' to the ProgressLinear element";
element.attr("md-mode", mod... | javascript | {
"resource": ""
} |
q20110 | mode | train | function mode() {
var value = (attr.mdMode || "").trim();
if (value) {
switch (value) {
case MODE_DETERMINATE:
case MODE_INDETERMINATE:
case MODE_BUFFER:
case MODE_QUERY:
break;
default:
value = MODE_INDETERMINATE;
... | javascript | {
"resource": ""
} |
q20111 | updateInputCursor | train | function updateInputCursor() {
if (isValidInput) {
var inputLength = input[0].value.length;
try {
input[0].selectionStart = input[0].selectionEnd = inputLength;
} catch (e) {
// Chrome does not allow setting a selection for number in... | javascript | {
"resource": ""
} |
q20112 | getBoundingRect | train | function getBoundingRect(el) {
const clientRect = el.getBoundingClientRect();
const bound = {
left: clientRect.left,
top: clientRect.top,
width: clientRect.width,
height: clientRect.height
};
let frame = el.ownerDocument.defaultView.frameElement;
while (frame) {
const ... | javascript | {
"resource": ""
} |
q20113 | getPageScaleFactor | train | function getPageScaleFactor() {
const pageScaleFactor = chrome.gpuBenchmarking.pageScaleFactor;
return pageScaleFactor ? pageScaleFactor.apply(chrome.gpuBenchmarking) : 1;
} | javascript | {
"resource": ""
} |
q20114 | getBoundingVisibleRect | train | function getBoundingVisibleRect(el) {
// Get the element bounding rect in the layout viewport.
const rect = getBoundingRect(el);
// Apply the visual viewport transform (i.e. pinch-zoom) to the bounding
// rect. The viewportX|Y values are in CSS pixels so they don't change
// with page scale. We fir... | javascript | {
"resource": ""
} |
q20115 | mutablePropertyChange | train | function mutablePropertyChange(inst, property, value, old, mutableData) {
let isObject;
if (mutableData) {
isObject = (typeof value === 'object' && value !== null);
// Pull `old` for Objects from temp cache, but treat `null` as a primitive
if (isObject) {
old = inst.__dataTemp[property];
}
}... | javascript | {
"resource": ""
} |
q20116 | wire | train | function wire (httpMethodName, contentSource, body, headers, withCredentials){
var oboeBus = pubSub();
// Wire the input stream in if we are given a content source.
// This will usually be the case. If not, the instance created
// will have to be passed content from an external source.
if( conten... | javascript | {
"resource": ""
} |
q20117 | oboe | train | function oboe(arg1) {
// We use duck-typing to detect if the parameter given is a stream, with the
// below list of parameters.
// Unpipe and unshift would normally be present on a stream but this breaks
// compatibility with Request streams.
// See https://github.com/jimhigson/oboe.js/issues/65
... | javascript | {
"resource": ""
} |
q20118 | announceAccessibleMessage | train | function announceAccessibleMessage(msg) {
var element = document.createElement('div');
element.setAttribute('aria-live', 'polite');
element.style.position = 'relative';
element.style.left = '-9999px';
element.style.height = '0px';
element.innerText = msg;
document.body.appendChild(element);
window.setTi... | javascript | {
"resource": ""
} |
q20119 | url | train | function url(s) {
// http://www.w3.org/TR/css3-values/#uris
// Parentheses, commas, whitespace characters, single quotes (') and double
// quotes (") appearing in a URI must be escaped with a backslash
var s2 = s.replace(/(\(|\)|\,|\s|\'|\"|\\)/g, '\\$1');
// WebKit has a bug when it comes to URLs that end wi... | javascript | {
"resource": ""
} |
q20120 | parseQueryParams | train | function parseQueryParams(location) {
var params = {};
var query = unescape(location.search.substring(1));
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[pair[0]] = pair[1];
}
return params;
} | javascript | {
"resource": ""
} |
q20121 | setQueryParam | train | function setQueryParam(location, key, value) {
var query = parseQueryParams(location);
query[encodeURIComponent(key)] = encodeURIComponent(value);
var newQuery = '';
for (var q in query) {
newQuery += (newQuery ? '&' : '?') + q + '=' + query[q];
}
return location.origin + location.pathname + newQuery ... | javascript | {
"resource": ""
} |
q20122 | disableTextSelectAndDrag | train | function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) {
// Disable text selection.
document.onselectstart = function(e) {
if (!(opt_allowSelectStart && opt_allowSelectStart.call(this, e)))
e.preventDefault();
};
// Disable dragging.
document.ondragstart = function(e) {
if ... | javascript | {
"resource": ""
} |
q20123 | queryRequiredElement | train | function queryRequiredElement(selectors, opt_context) {
var element = (opt_context || document).querySelector(selectors);
return assertInstanceof(element, HTMLElement,
'Missing required element: ' + selectors);
} | javascript | {
"resource": ""
} |
q20124 | appendParam | train | function appendParam(url, key, value) {
var param = encodeURIComponent(key) + '=' + encodeURIComponent(value);
if (url.indexOf('?') == -1)
return url + '?' + param;
return url + '&' + param;
} | javascript | {
"resource": ""
} |
q20125 | createElementWithClassName | train | function createElementWithClassName(type, className) {
var elm = document.createElement(type);
elm.className = className;
return elm;
} | javascript | {
"resource": ""
} |
q20126 | setScrollTopForDocument | train | function setScrollTopForDocument(doc, value) {
doc.documentElement.scrollTop = doc.body.scrollTop = value;
} | javascript | {
"resource": ""
} |
q20127 | setScrollLeftForDocument | train | function setScrollLeftForDocument(doc, value) {
doc.documentElement.scrollLeft = doc.body.scrollLeft = value;
} | javascript | {
"resource": ""
} |
q20128 | varArgs | train | function varArgs(fn){
var numberOfFixedArguments = fn.length -1,
slice = Array.prototype.slice;
if( numberOfFixedArguments == 0 ) {
// an optimised case for when there are no fixed args:
return function(){
return fn.call(this, slice.call(... | javascript | {
"resource": ""
} |
q20129 | ascentManager | train | function ascentManager(oboeBus, handlers){
"use strict";
var listenerId = {},
ascent;
function stateAfter(handler) {
return function(param){
ascent = handler( ascent, param);
}
}
for( var eventName in handlers ) {
oboeBus(eventName).on(stateAfter(handlers[event... | javascript | {
"resource": ""
} |
q20130 | PASSIVE_TOUCH | train | function PASSIVE_TOUCH(eventName) {
if (isMouseEvent(eventName) || eventName === 'touchend') {
return;
}
if (HAS_NATIVE_TA && SUPPORTS_PASSIVE && passiveTouchGestures) {
return {passive: true};
} else {
return;
}
} | javascript | {
"resource": ""
} |
q20131 | _add | train | function _add(node, evType, handler) {
let recognizer = gestures[evType];
let deps = recognizer.deps;
let name = recognizer.name;
let gobj = node[GESTURE_KEY];
if (!gobj) {
node[GESTURE_KEY] = gobj = {};
}
for (let i = 0, dep, gd; i < deps.length; i++) {
dep = deps[i];
// don't add mouse handl... | javascript | {
"resource": ""
} |
q20132 | _remove | train | function _remove(node, evType, handler) {
let recognizer = gestures[evType];
let deps = recognizer.deps;
let name = recognizer.name;
let gobj = node[GESTURE_KEY];
if (gobj) {
for (let i = 0, dep, gd; i < deps.length; i++) {
dep = deps[i];
gd = gobj[dep];
if (gd && gd[name]) {
gd[... | javascript | {
"resource": ""
} |
q20133 | _fire | train | function _fire(target, type, detail) {
let ev = new Event(type, { bubbles: true, cancelable: true, composed: true });
ev.detail = detail;
target.dispatchEvent(ev);
// forward `preventDefault` in a clean way
if (ev.defaultPrevented) {
let preventer = detail.preventer || detail.sourceEvent;
if (prevente... | javascript | {
"resource": ""
} |
q20134 | pubSub | train | function pubSub(){
var singles = {},
newListener = newSingle('newListener'),
removeListener = newSingle('removeListener');
function newSingle(eventName) {
return singles[eventName] = singleEventPubSub(
eventName,
newListener,
removeListener
);
}
/** pu... | javascript | {
"resource": ""
} |
q20135 | listAsArray | train | function listAsArray(list){
return foldR( function(arraySoFar, listItem){
arraySoFar.unshift(listItem);
return arraySoFar;
}, [], list );
} | javascript | {
"resource": ""
} |
q20136 | map | train | function map(fn, list) {
return list
? cons(fn(head(list)), map(fn,tail(list)))
: emptyList
;
} | javascript | {
"resource": ""
} |
q20137 | without | train | function without(list, test, removedFn) {
return withoutInner(list, removedFn || noop);
function withoutInner(subList, removedFn) {
return subList
? ( test(head(subList))
? (removedFn(head(subList)), tail(subList))
: cons(head(subList), withoutInner(tail... | javascript | {
"resource": ""
} |
q20138 | all | train | function all(fn, list) {
return !list ||
( fn(head(list)) && all(fn, tail(list)) );
} | javascript | {
"resource": ""
} |
q20139 | applyEach | train | function applyEach(fnList, args) {
if( fnList ) {
head(fnList).apply(null, args);
applyEach(tail(fnList), args);
}
} | javascript | {
"resource": ""
} |
q20140 | reverseList | train | function reverseList(list){
// js re-implementation of 3rd solution from:
// http://www.haskell.org/haskellwiki/99_questions/Solutions/5
function reverseInner( list, reversedAlready ) {
if( !list ) {
return reversedAlready;
}
return reverseInner(tail(list), cons(head(list... | javascript | {
"resource": ""
} |
q20141 | handleBatch | train | function handleBatch(results, showingTriaged) {
const alerts = [];
const nextRequests = [];
const triagedRequests = [];
let totalCount = 0;
for (const {body, response} of results) {
alerts.push.apply(alerts, response.anomalies);
if (body.count_limit) totalCount += response.count;
const cursor = ... | javascript | {
"resource": ""
} |
q20142 | loadMore | train | function loadMore(batches, alertGroups, nextRequests, triagedRequests,
triagedMaxStartRevision, started) {
const minStartRevision = tr.b.math.Statistics.min(
alertGroups, group => tr.b.math.Statistics.min(
group.alerts, a => a.startRevision));
if (!triagedMaxStartRevision ||
(minStartRevi... | javascript | {
"resource": ""
} |
q20143 | patternAdapter | train | function patternAdapter(oboeBus, jsonPathCompiler) {
var predicateEventMap = {
node:oboeBus(NODE_CLOSED)
, path:oboeBus(NODE_OPENED)
};
function emitMatchingNode(emitMatch, node, ascent) {
/*
We're now calling to the outside world where Lisp-style
lists will... | javascript | {
"resource": ""
} |
q20144 | protectedCallback | train | function protectedCallback( callback ) {
return function() {
try{
return callback.apply(oboeApi, arguments);
}catch(e) {
setTimeout(function() {
throw new Error(e.message);
});
}
}
} | javascript | {
"resource": ""
} |
q20145 | addMultipleNodeOrPathListeners | train | function addMultipleNodeOrPathListeners(eventId, listenerMap) {
for( var pattern in listenerMap ) {
addSingleNodeOrPathListener(eventId, pattern, listenerMap[pattern]);
}
} | javascript | {
"resource": ""
} |
q20146 | consumeParenthesised | train | function consumeParenthesised(parser, string) {
var nesting = 0;
for (var n = 0; n < string.length; n++) {
if (/\s|,/.test(string[n]) && nesting == 0) {
break;
} else if (string[n] == '(') {
nesting++;
} else if (string[n] == ')') {
nesting--;
if (nesting == 0)
... | javascript | {
"resource": ""
} |
q20147 | doScrollCheck | train | function doScrollCheck() {
if ( jQuery.isReady ) {
return;
}
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll("left");
} catch(e) {
setTimeout( doScrollCheck, 1 );
return;
}
// and execute any waiting functions
j... | javascript | {
"resource": ""
} |
q20148 | createFlags | train | function createFlags( flags ) {
var object = flagsCache[ flags ] = {},
i, length;
flags = flags.split( /\s+/ );
for ( i = 0, length = flags.length; i < length; i++ ) {
object[ flags[i] ] = true;
}
return object;
} | javascript | {
"resource": ""
} |
q20149 | train | function( obj ) {
if ( obj == null ) {
obj = promise;
} else {
for ( var key in promise ) {
obj[ key ] = promise[ key ];
}
}
return obj;
} | javascript | {
"resource": ""
} | |
q20150 | isEmptyDataObject | train | function isEmptyDataObject( obj ) {
for ( var name in obj ) {
// if the public data object is empty, the private is still empty
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
continue;
}
if ( name !== "toJSON" ) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q20151 | fixDefaultChecked | train | function fixDefaultChecked( elem ) {
if ( elem.type === "checkbox" || elem.type === "radio" ) {
elem.defaultChecked = elem.checked;
}
} | javascript | {
"resource": ""
} |
q20152 | findInputs | train | function findInputs( elem ) {
var nodeName = ( elem.nodeName || "" ).toLowerCase();
if ( nodeName === "input" ) {
fixDefaultChecked( elem );
// Skip scripts, get other children
} else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
jQuery.grep( elem.getElementsByTagName("input... | javascript | {
"resource": ""
} |
q20153 | ajaxConvert | train | function ajaxConvert( s, response ) {
// Apply the dataFilter if provided
if ( s.dataFilter ) {
response = s.dataFilter( response, s.dataType );
}
var dataTypes = s.dataTypes,
converters = {},
i,
key,
length = dataTypes.length,
tmp,
// Current and previous dataTypes
current = dataTypes[ 0 ],
pre... | javascript | {
"resource": ""
} |
q20154 | onError | train | function onError(e) {
window.__error = 'Media error: ' + e.type + ', code:' + e.target.error.code;
throw new Error(window.__error);
} | javascript | {
"resource": ""
} |
q20155 | GridBounds | train | function GridBounds(bounds) {
// [sw, ne]
this.minX = Math.min(bounds[0].x, bounds[1].x);
this.maxX = Math.max(bounds[0].x, bounds[1].x);
this.minY = Math.min(bounds[0].y, bounds[1].y);
this.maxY = Math.max(bounds[0].y, bounds[1].y);
} | javascript | {
"resource": ""
} |
q20156 | ProjectionHelperOverlay | train | function ProjectionHelperOverlay(map) {
this.setMap(map);
var TILEFACTOR = 8;
var TILESIDE = 1 << TILEFACTOR;
var RADIUS = 7;
this._map = map;
this._zoom = -1;
this._X0 =
this._Y0 =
this._X1 =
this._Y1 = -1;
} | javascript | {
"resource": ""
} |
q20157 | hasAllProperties | train | function hasAllProperties(fieldList, o) {
return (o instanceof Object)
&&
all(function (field) {
return (field in o);
}, fieldList);
} | javascript | {
"resource": ""
} |
q20158 | incrementalContentBuilder | train | function incrementalContentBuilder( oboeBus ) {
var emitNodeOpened = oboeBus(NODE_OPENED).emit,
emitNodeClosed = oboeBus(NODE_CLOSED).emit,
emitRootOpened = oboeBus(ROOT_PATH_FOUND).emit,
emitRootClosed = oboeBus(ROOT_NODE_FOUND).emit;
function arrayIndicesAreKeys( possiblyInconsistentAscen... | javascript | {
"resource": ""
} |
q20159 | keyFound | train | function keyFound(ascent, newDeepestName, maybeNewDeepestNode) {
if( ascent ) { // if not root
// If we have the key but (unless adding to an array) no known value
// yet. Put that key in the output but against no defined value:
appendBuiltContent( ascent, newDeepestName, ... | javascript | {
"resource": ""
} |
q20160 | nodeClosed | train | function nodeClosed( ascent ) {
emitNodeClosed( ascent);
return tail( ascent) ||
// If there are no nodes left in the ascent the root node
// just closed. Emit a special event for this:
emitRootClosed(nodeOf(head(ascent)));
} | javascript | {
"resource": ""
} |
q20161 | skip1 | train | function skip1(previousExpr) {
if( previousExpr == always ) {
/* If there is no previous expression this consume command
is at the start of the jsonPath.
Since JSONPath specifies what we'd like to find but not
necessarily everything leading down to it, when r... | javascript | {
"resource": ""
} |
q20162 | statementExpr | train | function statementExpr(lastClause) {
return function(ascent) {
// kick off the evaluation by passing through to the last clause
var exprMatch = lastClause(ascent);
return exprMatch === true ? head(ascent) : exprMatch;
... | javascript | {
"resource": ""
} |
q20163 | expressionsReader | train | function expressionsReader( exprs, parserGeneratedSoFar, detection ) {
// if exprs is zero-length foldR will pass back the
// parserGeneratedSoFar as-is so we don't need to treat
// this as a special case
return foldR(
function( parserGenerated... | javascript | {
"resource": ""
} |
q20164 | generateClauseReaderIfTokenFound | train | function generateClauseReaderIfTokenFound (
tokenDetector, clauseEvaluatorGenerators,
jsonPath, parserGeneratedSoFar, onSuccess) {
var detected = tokenDetector(jsonPath);
if(detected) {
var com... | javascript | {
"resource": ""
} |
q20165 | compileJsonPathToFunction | train | function compileJsonPathToFunction( uncompiledJsonPath,
parserGeneratedSoFar ) {
/**
* On finding a match, if there is remaining text to be compiled
* we want to either continue parsing using a recursive call to
* compileJsonPathToFunction. Otherwise,... | javascript | {
"resource": ""
} |
q20166 | callAdoptionAgency | train | function callAdoptionAgency(p, token) {
for (var i = 0; i < AA_OUTER_LOOP_ITER; i++) {
var formattingElementEntry = aaObtainFormattingElementEntry(p, token, formattingElementEntry);
if (!formattingElementEntry)
break;
var furthestBlock = aaObtainFurthestBlock(p, formattingEleme... | javascript | {
"resource": ""
} |
q20167 | readSingleFile | train | function readSingleFile(e) {
const file = e.target.files[0];
if (!file) {
return;
}
// Extract data from file and distribute it in some relevant structures:
// results for all guid-related( for now they are not
// divided in 3 parts depending on the type ) and
// all results with sample-value-rela... | javascript | {
"resource": ""
} |
q20168 | applyTemplateContent | train | function applyTemplateContent(inst, node, nodeInfo) {
if (nodeInfo.templateInfo) {
node._templateInfo = nodeInfo.templateInfo;
}
} | javascript | {
"resource": ""
} |
q20169 | isCrossOrigin | train | function isCrossOrigin(pageLocation, ajaxHost) {
/*
* NB: defaultPort only knows http and https.
* Returns undefined otherwise.
*/
function defaultPort(protocol) {
return {'http:':80, 'https:':443}[protocol];
}
function portOf(location) {
// pageLocation should always have a pro... | javascript | {
"resource": ""
} |
q20170 | ensureOwnEffectMap | train | function ensureOwnEffectMap(model, type) {
let effects = model[type];
if (!effects) {
effects = model[type] = {};
} else if (!model.hasOwnProperty(type)) {
effects = model[type] = Object.create(model[type]);
for (let p in effects) {
let protoFx = effects[p];
let instFx = effects[p] = Array... | javascript | {
"resource": ""
} |
q20171 | runEffectsForProperty | train | function runEffectsForProperty(inst, effects, dedupeId, prop, props, oldProps, hasPaths, extraArgs) {
let ran = false;
let rootProperty = hasPaths ? root$0(prop) : prop;
let fxs = effects[rootProperty];
if (fxs) {
for (let i=0, l=fxs.length, fx; (i<l) && (fx=fxs[i]); i++) {
if ((!fx.info || fx.info.la... | javascript | {
"resource": ""
} |
q20172 | runObserverEffect | train | function runObserverEffect(inst, property, props, oldProps, info) {
let fn = typeof info.method === "string" ? inst[info.method] : info.method;
let changedProp = info.property;
if (fn) {
fn.call(inst, inst.__data[changedProp], oldProps[changedProp]);
} else if (!info.dynamicFn) {
console.warn('observer ... | javascript | {
"resource": ""
} |
q20173 | runNotifyEffects | train | function runNotifyEffects(inst, notifyProps, props, oldProps, hasPaths) {
// Notify
let fxs = inst[TYPES.NOTIFY];
let notified;
let id = dedupeId++;
// Try normal notify effects; if none, fall back to try path notification
for (let prop in notifyProps) {
if (notifyProps[prop]) {
if (fxs && runEffe... | javascript | {
"resource": ""
} |
q20174 | runNotifyEffect | train | function runNotifyEffect(inst, property, props, oldProps, info, hasPaths) {
let rootProperty = hasPaths ? root$0(property) : property;
let path = rootProperty != property ? property : null;
let value = path ? get$0(inst, path) : inst.__data[property];
if (path && value === undefined) {
value = props[propert... | javascript | {
"resource": ""
} |
q20175 | runReflectEffect | train | function runReflectEffect(inst, property, props, oldProps, info) {
let value = inst.__data[property];
if (sanitizeDOMValue) {
value = sanitizeDOMValue(value, info.attrName, 'attribute', /** @type {Node} */(inst));
}
inst._propertyToAttribute(property, info.attrName, value);
} | javascript | {
"resource": ""
} |
q20176 | runComputedEffects | train | function runComputedEffects(inst, changedProps, oldProps, hasPaths) {
let computeEffects = inst[TYPES.COMPUTE];
if (computeEffects) {
let inputProps = changedProps;
while (runEffects(inst, computeEffects, inputProps, oldProps, hasPaths)) {
Object.assign(oldProps, inst.__dataOld);
Object.assign(c... | javascript | {
"resource": ""
} |
q20177 | runComputedEffect | train | function runComputedEffect(inst, property, props, oldProps, info) {
let result = runMethodEffect(inst, property, props, oldProps, info);
let computedProp = info.methodInfo;
if (inst.__dataHasAccessor && inst.__dataHasAccessor[computedProp]) {
inst._setPendingProperty(computedProp, result, true);
} else {
... | javascript | {
"resource": ""
} |
q20178 | computeLinkedPaths | train | function computeLinkedPaths(inst, path, value) {
let links = inst.__dataLinkedPaths;
if (links) {
let link;
for (let a in links) {
let b = links[a];
if (isDescendant(a, path)) {
link = translate(a, b, path);
inst._setPendingPropertyOrPath(link, value, true, true);
} else if... | javascript | {
"resource": ""
} |
q20179 | addEffectForBindingPart | train | function addEffectForBindingPart(constructor, templateInfo, binding, part, index) {
if (!part.literal) {
if (binding.kind === 'attribute' && binding.target[0] === '-') {
console.warn('Cannot set attribute ' + binding.target +
' because "-" is not a valid attribute starting character');
} else {
... | javascript | {
"resource": ""
} |
q20180 | computeBindingValue | train | function computeBindingValue(node, value, binding, part) {
if (binding.isCompound) {
let storage = node.__dataCompoundStorage[binding.target];
storage[part.compoundIndex] = value;
value = storage.join('');
}
if (binding.kind !== 'attribute') {
// Some browsers serialize `undefined` to `"undefined"... | javascript | {
"resource": ""
} |
q20181 | setupBindings | train | function setupBindings(inst, templateInfo) {
// Setup compound storage, dataHost, and notify listeners
let {nodeList, nodeInfoList} = templateInfo;
if (nodeInfoList.length) {
for (let i=0; i < nodeInfoList.length; i++) {
let info = nodeInfoList[i];
let node = nodeList[i];
let bindings = info... | javascript | {
"resource": ""
} |
q20182 | addNotifyListener | train | function addNotifyListener(node, inst, binding) {
if (binding.listenerEvent) {
let part = binding.parts[0];
node.addEventListener(binding.listenerEvent, function(e) {
handleNotification(e, inst, binding.target, part.source, part.negate);
});
}
} | javascript | {
"resource": ""
} |
q20183 | runMethodEffect | train | function runMethodEffect(inst, property, props, oldProps, info) {
// Instances can optionally have a _methodHost which allows redirecting where
// to find methods. Currently used by `templatize`.
let context = inst._methodHost || inst;
let fn = context[info.methodName];
if (fn) {
let args = marshalArgs(in... | javascript | {
"resource": ""
} |
q20184 | literalFromParts | train | function literalFromParts(parts) {
let s = '';
for (let i=0; i<parts.length; i++) {
let literal = parts[i].literal;
s += literal || '';
}
return s;
} | javascript | {
"resource": ""
} |
q20185 | parseArgs | train | function parseArgs(argList, sig) {
sig.args = argList.map(function(rawArg) {
let arg = parseArg(rawArg);
if (!arg.literal) {
sig.static = false;
}
return arg;
}, this);
return sig;
} | javascript | {
"resource": ""
} |
q20186 | marshalArgs | train | function marshalArgs(data, args, path, props) {
let values = [];
for (let i=0, l=args.length; i<l; i++) {
let arg = args[i];
let name = arg.name;
let v;
if (arg.literal) {
v = arg.value;
} else {
if (arg.structured) {
v = get$0(data, name);
// when data is not stored ... | javascript | {
"resource": ""
} |
q20187 | notifySplice | train | function notifySplice(inst, array, path, index, addedCount, removed) {
notifySplices(inst, array, path, [{
index: index,
addedCount: addedCount,
removed: removed,
object: array,
type: 'splice'
}]);
} | javascript | {
"resource": ""
} |
q20188 | getService | train | function getService(privateKeyDetails) {
return OAuth2.createService('PerfDash:' + Session.getActiveUser().getEmail())
// Set the endpoint URL.
.setTokenUrl('https://accounts.google.com/o/oauth2/token')
// Set the private key and issuer.
.setPrivateKey(privateKeyDetails['private_key'])
... | javascript | {
"resource": ""
} |
q20189 | getPrivateKeyDetailsFromDriveFile | train | function getPrivateKeyDetailsFromDriveFile(driveFileId) {
var file = DriveApp.getFileById(driveFileId);
return JSON.parse(file.getAs('application/json').getDataAsString());
} | javascript | {
"resource": ""
} |
q20190 | writeHexString | train | function writeHexString(bytes, out) {
function byteToPaddedHex(b) {
let str = b.toString(16).toUpperCase();
if (str.length < 2) {
str = '0' + str;
}
return str;
}
const kBytesPerLine = 16;
// Returns pretty printed kBytesPerLine bytes starting from
// bytes[startInde... | javascript | {
"resource": ""
} |
q20191 | writeParameters | train | function writeParameters(entry, out) {
// If headers are in an object, convert them to an array for better
// display.
entry = reformatHeaders(entry);
// Use any parameter writer available for this event type.
const paramsWriter = getParameterWriterForEventType(entry.type);
const consumedParams... | javascript | {
"resource": ""
} |
q20192 | getParameterWriterForEventType | train | function getParameterWriterForEventType(eventType) {
switch (eventType) {
case EventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS:
case EventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS:
case EventType.TYPE_HTTP_CACHE_CALLER_REQUEST_HEADERS:
return writeParamsForRequestHeaders;
case Event... | javascript | {
"resource": ""
} |
q20193 | tryParseHexToBytes | train | function tryParseHexToBytes(hexStr) {
if ((hexStr.length % 2) !== 0) {
return null;
}
const result = [];
for (let i = 0; i < hexStr.length; i += 2) {
const value = parseInt(hexStr.substr(i, 2), 16);
if (isNaN(value)) {
return null;
}
result.push(value);
}
... | javascript | {
"resource": ""
} |
q20194 | tryParseBase64ToBytes | train | function tryParseBase64ToBytes(b64Str) {
let decodedStr;
try {
decodedStr = atob(b64Str);
} catch (e) {
return null;
}
return Uint8Array.from(decodedStr, c => c.charCodeAt(0));
} | javascript | {
"resource": ""
} |
q20195 | defaultWriteParameter | train | function defaultWriteParameter(key, value, out) {
if (key === 'headers' && value instanceof Array) {
out.writeArrowIndentedLines(value);
return;
}
// For transferred bytes, display the bytes in hex and ASCII.
// TODO(eroman): 'hex_encoded_bytes' was removed in M73, and
// ... | javascript | {
"resource": ""
} |
q20196 | getSymbolicString | train | function getSymbolicString(bitmask, valueToName, zeroName) {
const matchingFlagNames = [];
for (const k in valueToName) {
if (bitmask & valueToName[k]) {
matchingFlagNames.push(k);
}
}
// If no flags were matched, returns a special value.
if (matchingFlagNames.length === 0) {
... | javascript | {
"resource": ""
} |
q20197 | reformatHeaders | train | function reformatHeaders(entry) {
// If there are no headers, or it is not an object other than an array,
// return |entry| without modification.
if (!entry.params || entry.params.headers === undefined ||
typeof entry.params.headers !== 'object' ||
entry.params.headers instanceof Array) {
... | javascript | {
"resource": ""
} |
q20198 | writeParamsForRequestHeaders | train | function writeParamsForRequestHeaders(entry, out, consumedParams) {
const params = entry.params;
if (!(typeof params.line === 'string') ||
!(params.headers instanceof Array)) {
// Unrecognized params.
return;
}
// Strip the trailing CRLF that params.line contains.
const lineWit... | javascript | {
"resource": ""
} |
q20199 | writeParamsForCertificates | train | function writeParamsForCertificates(entry, out, consumedParams) {
writeCertificateParam(entry.params, out, consumedParams, 'certificates');
if (typeof(entry.params.verified_cert) === 'object') {
writeCertificateParam(
entry.params.verified_cert, out, consumedParams, 'verified_cert');
}
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.