_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q59200 | validation | function(command) {
// Backbone.model set() and Backbone.collection add() allow to pass an option parameter.
// That is also kept within the command. It skips validation if requested.
if (command.options && command.options.validation === false) return true;
var handoverErr;
_.each(this._map[command.action], fun... | javascript | {
"resource": ""
} | |
q59201 | validation | function(path, options) {
var cell = this.options.cellView.model;
var value = joint.util.getByPath(cell.attributes, path, '/');
if (_.isUndefined(value) && !_.isUndefined(options.defaultValue)) {
value = options.defaultValue;
}
if (options.valueRegExp) {
... | javascript | {
"resource": ""
} | |
q59202 | validation | function(type, value, targetElement) {
switch (type) {
case 'number':
value = parseFloat(value);
break;
case 'toggle':
value = targetElement.checked;
break;
default:
value = value;
break;
}
... | javascript | {
"resource": ""
} | |
q59203 | findMinSlack | validation | function findMinSlack() {
var result,
eSlack = Number.POSITIVE_INFINITY;
minLen.forEach(function(mle /* minLen entry */) {
if (remaining.has(mle.u) !== remaining.has(mle.v)) {
var mleSlack = rankUtil.slack(g, mle.u, mle.v, mle.len);
if (mleSlack < eSlack) {
if (!remaining... | javascript | {
"resource": ""
} |
q59204 | dfs | validation | function dfs(n) {
var children = spanningTree.successors(n);
for (var c in children) {
var child = children[c];
dfs(child);
}
if (n !== spanningTree.graph().root) {
setCutValue(graph, spanningTree, n);
}
} | javascript | {
"resource": ""
} |
q59205 | redirect | validation | function redirect(v) {
var edges = tree.inEdges(v);
for (var i in edges) {
var e = edges[i];
var u = tree.source(e);
var value = tree.edge(e);
redirect(u);
tree.delEdge(e);
value.reversed = !value.reversed;
tree.addEdge(e, v, u, value);
}
} | javascript | {
"resource": ""
} |
q59206 | Set | validation | function Set(initialKeys) {
this._size = 0;
this._keys = {};
if (initialKeys) {
for (var i = 0, il = initialKeys.length; i < il; ++i) {
this.add(initialKeys[i]);
}
}
} | javascript | {
"resource": ""
} |
q59207 | createCanvas | validation | function createCanvas() {
canvas = document.createElement('canvas');
canvas.width = imageWidth;
canvas.height = imageHeight;
// Draw rectangle of a certain color covering the whole canvas area.
// A JPEG image has black background by default and it might not be desirable.
context = canva... | javascript | {
"resource": ""
} |
q59208 | on | validation | function on (el, types, fn, context) {
types.split(' ').forEach(function (type) {
L.DomEvent.on(el, type, fn, context)
})
} | javascript | {
"resource": ""
} |
q59209 | validation | function( eventaur, settings ) {
var gith = this;
this.settings = settings || {};
// make this bad boy an event emitter
EventEmitter2.call( this, {
delimiter: ':',
maxListeners: 0
});
// handle bound payloads
eventaur.on( 'payload', function( originalPayload ) {
// make a simpler payload
... | javascript | {
"resource": ""
} | |
q59210 | buildConfig | validation | function buildConfig(wantedEnv) {
let isValid = wantedEnv && wantedEnv.length > 0 && allowedEnvs.indexOf(wantedEnv) !== -1;
let validEnv = isValid ? wantedEnv : 'dev';
let config = require(path.join(__dirname, 'cfg/' + validEnv));
return config;
} | javascript | {
"resource": ""
} |
q59211 | createImageData | validation | function createImageData(image) {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
const width = image.naturalWidth
const height = image.naturalHeight
canvas.width = width
canvas.height = height
ctx.drawImage(image, 0, 0)
return ctx.getImageData(0, 0, image.naturalW... | javascript | {
"resource": ""
} |
q59212 | getImageDataFromSource | validation | async function getImageDataFromSource(source) {
const isStringSource = typeof source === 'string'
const isURLSource = isStringSource ? isUrl(source) : false
const { tagName } = source
return new Promise((resolve, reject) => {
// String source
if (isStringSource) {
// Read file in Node.js
if... | javascript | {
"resource": ""
} |
q59213 | stdopts | validation | function stdopts (opts) {
opts = opts || {}
opts.keys = opts.keys !== false // default keys to true
opts.values = opts.values !== false // default values to true
return opts
} | javascript | {
"resource": ""
} |
q59214 | update_time | validation | function update_time(element)
{
var settings = element.data("easydate.settings");
var element_id = $.data(element[0]);
elements[element_id] = element;
delete updates[element_id];
var date = get_date(element, settings);
if(isNaN(date))
... | javascript | {
"resource": ""
} |
q59215 | validation | function(type) {
var qp = {error: type, state: props.state};
res.redirect(props.redirect_uri + "?" + qs.stringify(qp));
} | javascript | {
"resource": ""
} | |
q59216 | validation | function(props) {
var inst,
cls = this,
key = props[cls.keyAttr];
if (key && _.has(cls.cache, key)) {
inst = cls.cache[key];
// Check the updated flag
inst.merge(props);
} else {
inst =... | javascript | {
"resource": ""
} | |
q59217 | validation | function(range, touchingIsIntersecting) {
assertRangeValid(this);
if (getRangeDocument(range) != getRangeDocument(this)) {
throw new DOMException("WRONG_DOCUMENT_ERR");
}
var startComparison = dom.comparePoints(this.startContainer, this.startOffset, rang... | javascript | {
"resource": ""
} | |
q59218 | validation | function(sel, range) {
var ranges = sel.getAllRanges(), removed = false;
sel.removeAllRanges();
for (var i = 0, len = ranges.length; i < len; ++i) {
if (removed || range !== ranges[i]) {
sel.addRange(ranges[i]);
} else {
// According to the... | javascript | {
"resource": ""
} | |
q59219 | validation | function(needle) {
if (arr.indexOf) {
return arr.indexOf(needle) !== -1;
} else {
for (var i=0, length=arr.length; i<length; i++) {
if (arr[i] === needle) { return true; }
}
return false;
}
} | javascript | {
"resource": ""
} | |
q59220 | _wrapMatchesInNode | validation | function _wrapMatchesInNode(textNode) {
var parentNode = textNode.parentNode,
tempElement = _getTempElement(parentNode.ownerDocument);
// We need to insert an empty/temporary <span /> to fix IE quirks
// Elsewise IE would strip white space in the beginning
tempElement.innerHTML = "<span></... | javascript | {
"resource": ""
} |
q59221 | parse | validation | function parse(elementOrHtml, rules, context, cleanUp) {
wysihtml5.lang.object(currentRules).merge(defaultRules).merge(rules).get();
context = context || elementOrHtml.ownerDocument || document;
var fragment = context.createDocumentFragment(),
isString = typeof(elementOrHtml... | javascript | {
"resource": ""
} |
q59222 | validation | function(iframe) {
// don't resume when the iframe got unloaded (eg. by removing it from the dom)
if (!wysihtml5.dom.contains(doc.documentElement, iframe)) {
return;
}
var that = this,
iframeWindow = iframe.contentWindow,
iframeDocument = iframe.contentWi... | javascript | {
"resource": ""
} | |
q59223 | validation | function(html) {
var range = rangy.createRange(this.doc),
node = range.createContextualFragment(html),
lastChild = node.lastChild;
this.insertNode(node);
if (lastChild) {
this.setAfter(lastChild);
}
} | javascript | {
"resource": ""
} | |
q59224 | validation | function(node) {
var range = this.getRange();
if (!range) {
return;
}
try {
// This only works when the range boundaries are not overlapping other elements
range.surroundContents(node);
this.selectNode(node);
} catch(e) {
// fallback
node.ap... | javascript | {
"resource": ""
} | |
q59225 | validation | function(textNodes, range) {
var firstNode = textNodes[0], lastNode = textNodes[textNodes.length - 1];
var merges = [], currentMerge;
var rangeStartNode = firstNode, rangeEndNode = lastNode;
var rangeStartOffset = 0, rangeEndOffset = lastNode.length;
var textNode, precedingTextNode;
... | javascript | {
"resource": ""
} | |
q59226 | validation | function(command) {
var obj = wysihtml5.commands[command],
method = obj && obj.value;
if (method) {
return method.call(obj, this.composer, command);
} else {
try {
// try/catch for buggy firefox
return this.doc.queryCommandValue(command);
} catch(e) {
r... | javascript | {
"resource": ""
} | |
q59227 | _isBlankTextNode | validation | function _isBlankTextNode(node) {
return node.nodeType === wysihtml5.TEXT_NODE && !wysihtml5.lang.string(node.data).trim();
} | javascript | {
"resource": ""
} |
q59228 | _getPreviousSiblingThatIsNotBlank | validation | function _getPreviousSiblingThatIsNotBlank(node) {
var previousSibling = node.previousSibling;
while (previousSibling && _isBlankTextNode(previousSibling)) {
previousSibling = previousSibling.previousSibling;
}
return previousSibling;
} | javascript | {
"resource": ""
} |
q59229 | _getNextSiblingThatIsNotBlank | validation | function _getNextSiblingThatIsNotBlank(node) {
var nextSibling = node.nextSibling;
while (nextSibling && _isBlankTextNode(nextSibling)) {
nextSibling = nextSibling.nextSibling;
}
return nextSibling;
} | javascript | {
"resource": ""
} |
q59230 | _removeLineBreakBeforeAndAfter | validation | function _removeLineBreakBeforeAndAfter(node) {
var nextSibling = _getNextSiblingThatIsNotBlank(node),
previousSibling = _getPreviousSiblingThatIsNotBlank(node);
if (nextSibling && _isLineBreak(nextSibling)) {
nextSibling.parentNode.removeChild(nextSibling);
}
if (previousSibling && _... | javascript | {
"resource": ""
} |
q59231 | _execCommand | validation | function _execCommand(doc, command, nodeName, className) {
if (className) {
var eventListener = dom.observe(doc, "DOMNodeInserted", function(event) {
var target = event.target,
displayStyle;
if (target.nodeType !== wysihtml5.ELEMENT_NODE) {
return;
}
displ... | javascript | {
"resource": ""
} |
q59232 | validation | function(avoidHiddenFields) {
var field,
fieldName,
newValue,
focusedElement = document.querySelector(":focus"),
fields = this.container.querySelectorAll(SELECTOR_FIELDS),
length = fields.length,
i = 0;
for (; i<length;... | javascript | {
"resource": ""
} | |
q59233 | validation | function(elementToChange) {
var that = this,
firstField = this.container.querySelector(SELECTOR_FORM_ELEMENTS);
this.elementToChange = elementToChange;
this._observe();
this._interpolate();
if (elementToChange) {
this.interval = setInterval(function() { that._inte... | javascript | {
"resource": ""
} | |
q59234 | validation | function() {
this.observe("paste:composer", function() {
var keepScrollPosition = true,
that = this;
that.composer.selection.executeAndRestore(function() {
wysihtml5.quirks.cleanPastedHTML(that.composer.element);
that.parse(that.composer.element);
... | javascript | {
"resource": ""
} | |
q59235 | getParameterList | validation | function getParameterList(parameters) {
if (parameters == null) {
return [];
}
if (typeof parameters != "object") {
return OAuth.decodeForm(parameters + "");
}
if (parameters instanceof Array) {
return parameters;
}
var list = [... | javascript | {
"resource": ""
} |
q59236 | getParameterMap | validation | function getParameterMap(parameters) {
if (parameters == null) {
return {};
}
if (typeof parameters != "object") {
return OAuth.getParameterMap(OAuth.decodeForm(parameters + ""));
}
if (parameters instanceof Array) {
var map = {};
f... | javascript | {
"resource": ""
} |
q59237 | getAuthorizationHeader | validation | function getAuthorizationHeader(realm, parameters) {
var header = 'OAuth realm="' + OAuth.percentEncode(realm) + '"';
var list = OAuth.getParameterList(parameters);
for (var p = 0; p < list.length; ++p) {
var parameter = list[p];
var name = parameter[0];
if (n... | javascript | {
"resource": ""
} |
q59238 | correctTimestampFromSrc | validation | function correctTimestampFromSrc(parameterName) {
parameterName = parameterName || "oauth_timestamp";
var scripts = document.getElementsByTagName('script');
if (scripts == null || !scripts.length) return;
var src = scripts[scripts.length-1].src;
if (!src) return;
var q = ... | javascript | {
"resource": ""
} |
q59239 | sign | validation | function sign(message) {
var baseString = OAuth.SignatureMethod.getBaseString(message);
var signature = this.getSignature(baseString);
OAuth.setParameter(message, "oauth_signature", signature);
return signature; // just in case someone's interested
} | javascript | {
"resource": ""
} |
q59240 | initialize | validation | function initialize(name, accessor) {
var consumerSecret;
if (accessor.accessorSecret != null
&& name.length > 9
&& name.substring(name.length-9) == "-Accessor")
{
consumerSecret = accessor.accessorSecret;
} else {
consumerSecret = accessor... | javascript | {
"resource": ""
} |
q59241 | newMethod | validation | function newMethod(name, accessor) {
var impl = OAuth.SignatureMethod.REGISTERED[name];
if (impl != null) {
var method = new impl();
method.initialize(name, accessor);
return method;
}
var err = new Error("signature_method_rejected");
var accep... | javascript | {
"resource": ""
} |
q59242 | makeSubclass | validation | function makeSubclass(getSignatureFunction) {
var superClass = OAuth.SignatureMethod;
var subClass = function() {
superClass.call(this);
};
subClass.prototype = new superClass();
// Delete instance variables from prototype:
// delete subclass.prototype... Ther... | javascript | {
"resource": ""
} |
q59243 | processInitialData | validation | function processInitialData(value, name) {
if (name == View.prototype.modelName) {
options.model = def.models[name].unique(value);
} else if (def.models[name]) {
options.data[name] = def.models[name].unique(value);
} else {
opti... | javascript | {
"resource": ""
} |
q59244 | vendor | validation | function vendor(el, prop) {
var s = el.style
, pp
, i
if(s[prop] !== undefined) return prop
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
for(i=0; i<prefixes.length; i++) {
pp = prefixes[i]+prop
if(s[pp] !== undefined) return pp
}
} | javascript | {
"resource": ""
} |
q59245 | css | validation | function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n)||n] = prop[n]
return el
} | javascript | {
"resource": ""
} |
q59246 | merge | validation | function merge(obj) {
for (var i=1; i < arguments.length; i++) {
var def = arguments[i]
for (var n in def)
if (obj[n] === undefined) obj[n] = def[n]
}
return obj
} | javascript | {
"resource": ""
} |
q59247 | pos | validation | function pos(el) {
var o = { x:el.offsetLeft, y:el.offsetTop }
while((el = el.offsetParent))
o.x+=el.offsetLeft, o.y+=el.offsetTop
return o
} | javascript | {
"resource": ""
} |
q59248 | splitVal | validation | function splitVal(string, separator) {
var val, i, l;
if (string === null || string.length < 1) return [];
val = string.split(separator);
for (i = 0, l = val.length; i < l; i = i + 1) val[i] = $.trim(val[i]);
return val;
} | javascript | {
"resource": ""
} |
q59249 | installFilteredMouseMove | validation | function installFilteredMouseMove(element) {
element.on("mousemove", function (e) {
var lastpos = lastMousePosition;
if (lastpos === undefined || lastpos.x !== e.pageX || lastpos.y !== e.pageY) {
$(e.target).trigger("mousemove-filtered", e);
}
});
... | javascript | {
"resource": ""
} |
q59250 | thunk | validation | function thunk(formula) {
var evaluated = false,
value;
return function() {
if (evaluated === false) { value = formula(); evaluated = true; }
return value;
};
} | javascript | {
"resource": ""
} |
q59251 | checkFormatter | validation | function checkFormatter(formatter, formatterName) {
if ($.isFunction(formatter)) return true;
if (!formatter) return false;
throw new Error(formatterName +" must be a function or a falsy value");
} | javascript | {
"resource": ""
} |
q59252 | defaultTokenizer | validation | function defaultTokenizer(input, selection, selectCallback, opts) {
var original = input, // store the original so we can compare and know if we need to tell the search to update its text
dupe = false, // check for whether a token we extracted represents a duplicate selected choice
token... | javascript | {
"resource": ""
} |
q59253 | clazz | validation | function clazz(SuperClass, methods) {
var constructor = function () {};
constructor.prototype = new SuperClass;
constructor.prototype.constructor = constructor;
constructor.prototype.parent = SuperClass.prototype;
constructor.prototype = $.extend(constructor.prototype, methods);
... | javascript | {
"resource": ""
} |
q59254 | validation | function () {
var el = this.opts.element, sync;
el.on("change.select2", this.bind(function (e) {
if (this.opts.element.data("select2-change-triggered") !== true) {
this.initSelection();
}
}));
sync = this.bind(function... | javascript | {
"resource": ""
} | |
q59255 | validation | function() {
var cid = this.containerId,
scroll = "scroll." + cid,
resize = "resize."+cid,
orient = "orientationchange."+cid,
mask, maskCss;
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
... | javascript | {
"resource": ""
} | |
q59256 | SubEmitterSocket | validation | function SubEmitterSocket() {
this.sock = new SubSocket;
this.sock.onmessage = this.onmessage.bind(this);
this.bind = this.sock.bind.bind(this.sock);
this.connect = this.sock.connect.bind(this.sock);
this.close = this.sock.close.bind(this.sock);
this.listeners = [];
} | javascript | {
"resource": ""
} |
q59257 | PubEmitterSocket | validation | function PubEmitterSocket() {
this.sock = new PubSocket;
this.emit = this.sock.send.bind(this.sock);
this.bind = this.sock.bind.bind(this.sock);
this.connect = this.sock.connect.bind(this.sock);
this.close = this.sock.close.bind(this.sock);
} | javascript | {
"resource": ""
} |
q59258 | toRegExp | validation | function toRegExp(str) {
if (str instanceof RegExp) return str;
str = escape(str);
str = str.replace(/\\\*/g, '(.+)');
return new RegExp('^' + str + '$');
} | javascript | {
"resource": ""
} |
q59259 | ReqSocket | validation | function ReqSocket() {
Socket.call(this);
this.n = 0;
this.ids = 0;
this.callbacks = {};
this.identity = this.get('identity');
this.use(queue());
} | javascript | {
"resource": ""
} |
q59260 | Node | validation | function Node(kind, docs, location) {
this.kind = kind;
if (docs) {
this.leadingComments = docs;
}
if (location) {
this.loc = location;
}
} | javascript | {
"resource": ""
} |
q59261 | validation | function() {
let location = null;
const args = Array.prototype.slice.call(arguments);
args.push(docs);
if (typeof result.preBuild === "function") {
result.preBuild(arguments);
}
if (self.withPositions || self.withSource) {
let src = null;
if (self.withSource) {
src = pa... | javascript | {
"resource": ""
} | |
q59262 | validation | function() {
const ch = this._input[this.offset - 1];
const fn = this.tokenTerminals[ch];
if (fn) {
return fn.apply(this, []);
} else {
return this.yytext;
}
} | javascript | {
"resource": ""
} | |
q59263 | validation | function(text, doubleQuote) {
if (!doubleQuote) {
// single quote fix
return text.replace(/\\['\\]/g, function(seq) {
return specialChar[seq];
});
}
return text.replace(/\\[rntvef"'\\$]/g, function(seq) {
return specialChar[seq];
});
} | javascript | {
"resource": ""
} | |
q59264 | validation | function(expr) {
let result, offset;
const node = this.node("offsetlookup");
if (this.token === "[") {
offset = this.next().read_expr();
if (this.expect("]")) this.next();
result = node(expr, offset);
} else if (this.token === this.tok.T_DOLLAR_OPEN_CURLY_BRACES) {
offset = this.... | javascript | {
"resource": ""
} | |
q59265 | validation | function(expect, isBinary = false) {
let node = this.node("encapsed");
this.next();
const start = this.lexer.yylloc.prev_offset - (isBinary ? 1 : 0);
const value = [];
let type = null;
if (expect === "`") {
type = this.ast.encapsed.TYPE_SHELL;
} else if (expect === '"') {
type =... | javascript | {
"resource": ""
} | |
q59266 | validation | function() {
const revert = this.offset;
if (
this._input[this.offset - 1] === "<" &&
this._input[this.offset] === "<" &&
this._input[this.offset + 1] === "<"
) {
this.offset += 3;
// optional tabs / spaces
if (this.is_TABSPACE()) {
while (this.offset < this.size... | javascript | {
"resource": ""
} | |
q59267 | validation | function() {
// @fixme : check if out of text limits
if (
this._input.substring(
this.offset - 1,
this.offset - 1 + this.heredoc_label.length
) === this.heredoc_label
) {
const ch = this._input[this.offset - 1 + this.heredoc_label.length];
if (ch === "\n" || ch === "\... | javascript | {
"resource": ""
} | |
q59268 | validation | function() {
const result = this.node("if");
let body = null;
let alternate = null;
let shortForm = false;
let test = null;
test = this.next().read_if_expr();
if (this.token === ":") {
shortForm = true;
this.next();
body = this.node("block");
const items = [];
... | javascript | {
"resource": ""
} | |
q59269 | read_constant_declaration | validation | function read_constant_declaration() {
const result = this.node("constant");
let constName = null;
let value = null;
if (
this.token === this.tok.T_STRING ||
(this.php7 && this.is("IDENTIFIER"))
) {
constName = this.node("identifier");
cons... | javascript | {
"resource": ""
} |
q59270 | validation | function(asInterface) {
const result = [-1, -1, -1];
if (this.is("T_MEMBER_FLAGS")) {
let idx = 0,
val = 0;
do {
switch (this.token) {
case this.tok.T_PUBLIC:
idx = 0;
val = 0;
break;
case this.tok.T_PROTECTED:
idx =... | javascript | {
"resource": ""
} | |
q59271 | validation | function(read_only, encapsed, byref) {
let result;
// check the byref flag
if (!byref && this.token === "&") {
byref = true;
this.next();
}
// reads the entry point
if (this.is([this.tok.T_VARIABLE, "$"])) {
result = this.read_reference_variable(encapsed, byref);
} else i... | javascript | {
"resource": ""
} | |
q59272 | validation | function(what, encapsed) {
const result = this.node("staticlookup");
let offset, name;
if (this.next().is([this.tok.T_VARIABLE, "$"])) {
offset = this.read_reference_variable(encapsed, false);
} else if (
this.token === this.tok.T_STRING ||
this.token === this.tok.T_CLASS ||
(thi... | javascript | {
"resource": ""
} | |
q59273 | validation | function(options) {
if (typeof this === "function") {
return new this(options);
}
this.tokens = tokens;
this.lexer = new lexer(this);
this.ast = new AST();
this.parser = new parser(this.lexer, this.ast);
if (options && typeof options === "object") {
// disable php7 from lexer if already disabled f... | javascript | {
"resource": ""
} | |
q59274 | validation | function() {
while (this.offset < this.size) {
const ch = this.input();
if (ch === "\n" || ch === "\r") {
return this.tok.T_COMMENT;
} else if (
ch === "?" &&
!this.aspTagMode &&
this._input[this.offset] === ">"
) {
this.unput(1);
return this.t... | javascript | {
"resource": ""
} | |
q59275 | validation | function(token) {
const body = this.node("block");
const items = [];
if (this.expect(":")) this.next();
while (this.token != this.EOF && this.token !== token) {
items.push(this.read_inner_statement());
}
if (this.expect(token)) this.next();
this.expectEndOfStatement();
return body(... | javascript | {
"resource": ""
} | |
q59276 | validation | function() {
return this.read_list(function() {
const node = this.node("staticvariable");
let variable = this.node("variable");
// plain variable name
if (this.expect(this.tok.T_VARIABLE)) {
const name = this.text().substring(1);
this.next();
variable = variable(name,... | javascript | {
"resource": ""
} | |
q59277 | findChunkFile | validation | function findChunkFile(chunk, chunkId, outputFilePath) {
for (let i = 0; i < chunk.files.length; i++) {
const chunkFile = chunk.files[i];
let normalizedOutputFilePath = outputFilePath.replace(/^\.\//, '');
if (!/\.js$/.test(chunkFile)) {
normalizedOutputFilePath = normalizedOutputFilePath.substr(
... | javascript | {
"resource": ""
} |
q59278 | findAncestorDistance | validation | function findAncestorDistance(src, target, currentDistance) {
if (target === src) {
return currentDistance;
}
const distances = [];
src.getParents().forEach((srcParentChunkGroup) => {
const distance = findAncestorDistance(
srcParentChunkGroup,
target,
currentDistance + 1
);
if... | javascript | {
"resource": ""
} |
q59279 | findNearestCommonParentChunk | validation | function findNearestCommonParentChunk(chunkGroups, currentDistance = 0) {
// Map of chunk name to distance from target
const distances = new Map();
for (let i = 1; i < chunkGroups.length; i++) {
const distance = findAncestorDistance(
chunkGroups[i],
chunkGroups[0],
currentDistance
);
... | javascript | {
"resource": ""
} |
q59280 | validation | function(page, data) {
if (page.flagAniBind == true) return;
// do callback when animation start/end
["animationstart", "animationend"].forEach(function(animationkey, index) {
var animition = paramsIn[animationkey], webkitkey = "webkit" + animationkey.replace(/^a|s|e/g, function(matchs) {
return match... | javascript | {
"resource": ""
} | |
q59281 | updateProps | validation | function updateProps (domNode, oldVirtualNode, oldProps, newVirtualNode, newProps) {
if (oldProps) {
for (var name in oldProps) {
if (name === 'ref' || name === 'on') continue
if (name in EVENT_LISTENER_PROPS) continue
if (!newProps || !(name in newProps)) {
if (name === 'dataset') {
... | javascript | {
"resource": ""
} |
q59282 | initialize | validation | function initialize(component) {
if (typeof component.update !== 'function') {
throw new Error('Etch components must implement `update(props, children)`.')
}
let virtualNode = component.render()
if (!isValidVirtualNode(virtualNode)) {
let namePart = component.constructor && component.constructor.name ?... | javascript | {
"resource": ""
} |
q59283 | updateSync | validation | function updateSync (component, replaceNode=true) {
if (!isValidVirtualNode(component.virtualNode)) {
throw new Error(`${component.constructor ? component.constructor.name + ' instance' : component} is not associated with a valid virtualNode. Perhaps this component was never initialized?`)
}
if (component.el... | javascript | {
"resource": ""
} |
q59284 | destroy | validation | function destroy (component, removeNode=true) {
if (syncUpdatesInProgressCounter > 0 || syncDestructionsInProgressCounter > 0) {
destroySync(component, removeNode)
return Promise.resolve()
}
let scheduler = getScheduler()
scheduler.updateDocument(function () {
destroySync(component, removeNode)
}... | javascript | {
"resource": ""
} |
q59285 | destroySync | validation | function destroySync (component, removeNode=true) {
syncDestructionsInProgressCounter++
destroyChildComponents(component.virtualNode)
if (syncDestructionsInProgressCounter === 1 && removeNode) component.element.remove()
syncDestructionsInProgressCounter--
} | javascript | {
"resource": ""
} |
q59286 | enlargeUUID | validation | function enlargeUUID(shortId, translator) {
var uu1 = translator(shortId);
var leftPad = "";
var m;
// Pad out UUIDs beginning with zeros (any number shorter than 32 characters of hex)
for (var i = 0, len = 32-uu1.length; i < len; ++i) {
leftPad += "0";
}
// Join the zero padding a... | javascript | {
"resource": ""
} |
q59287 | cleanFilter | validation | function cleanFilter() {
sbSearch.reset();
if (!templateOpts.sidebar.enabled || !$sidebarNodes) return;
setFilterBtnStates();
if ($txtSearch) $txtSearch.val('');
$sidebarNodes.removeClass('hidden');
if ($btnClean) $btnClean.hide();
$('.toolbar-buttons > span').c... | javascript | {
"resource": ""
} |
q59288 | filterSidebarNodes | validation | function filterSidebarNodes(strSearch) {
if (!templateOpts.sidebar.enabled) return;
strSearch = (strSearch || '').trim().toLowerCase();
if (!strSearch) {
cleanFilter();
return;
}
if ($btnClean) $btnClean.show();
// expand all sub-trees, so any fo... | javascript | {
"resource": ""
} |
q59289 | toggleHamMenu | validation | function toggleHamMenu(show) {
if (!$nbmBtn) return;
var fn = show ? 'addClass' : 'removeClass';
$nbmBtn[fn]('toggled');
$navOverlay[fn]('toggled'); // toggle overlay / backdrop
$navbarMenu[fn]('toggled');
// disable body scroll if menu is open
helper.toggleBodySc... | javascript | {
"resource": ""
} |
q59290 | getFilterClickHandler | validation | function getFilterClickHandler(filter) {
var isKind = filter === 'kind';
var has = isKind ? sbSearch.hasKind : sbSearch.hasScope;
var add = isKind ? sbSearch.addKind : sbSearch.addScope;
var remove = isKind ? sbSearch.removeKind : sbSearch.removeScope;
return... | javascript | {
"resource": ""
} |
q59291 | getWithResolvedData | validation | function getWithResolvedData(ctx, cur, down) {
return function(data) {
return ctx.push(data)._get(cur, down);
};
} | javascript | {
"resource": ""
} |
q59292 | cleanName | validation | function cleanName(name) {
// e.g. <anonymous>~obj.doStuff —» obj.doStuff
name = getStr(name)
.replace(/([^>]+>)?~?(.*)/, '$2')
// e.g. '"./node_modules/eventemitter3/index.js"~EventEmitter'.
.replace(/^"[^"]+"\.?~?([^"]+)$/, '$1')
.replace(/^(module\.)?exports\./, '')
.r... | javascript | {
"resource": ""
} |
q59293 | computeInputVariants | validation | function computeInputVariants(str, n) {
var variants = [ str ];
for (var i = 1; i < n; i++) {
var pos = Math.floor(Math.random() * str.length);
var chr = String.fromCharCode((str.charCodeAt(pos) + Math.floor(Math.random() * 128)) % 128);
variants[i] = str.substring(0, pos) + chr + str.substring(pos + 1,... | javascript | {
"resource": ""
} |
q59294 | BenchmarkSuite | validation | function BenchmarkSuite(name, reference, benchmarks) {
this.name = name;
this.reference = reference;
this.benchmarks = benchmarks;
BenchmarkSuite.suites.push(this);
} | javascript | {
"resource": ""
} |
q59295 | RunNextSetup | validation | function RunNextSetup() {
if (index < length) {
try {
suite.benchmarks[index].Setup();
} catch (e) {
suite.NotifyError(e);
return null;
}
return RunNextBenchmark;
}
suite.NotifyResult();
return null;
} | javascript | {
"resource": ""
} |
q59296 | sendPacket | validation | function sendPacket(socket, srcMAC, type, serverIP, yourIP) {
// Request info option
const opt55 = {
id: 55,
bytes: [
1, // subnet
3, // router
6, // dns
],
};
let options;
if (serverIP && yourIP) {
const opt54 = {
id: 54,
bytes: [serverIP.a, serverIP.b, serverIP... | javascript | {
"resource": ""
} |
q59297 | TimerEvent | validation | function TimerEvent(label, color, pause, thread_id) {
assert(thread_id >= 0 && thread_id < kNumThreads, "invalid thread id");
this.label = label;
this.color = color;
this.pause = pause;
this.ranges = [];
this.thread_id = thread_id;
this.index = ++num_timer_event;
} | javascript | {
"resource": ""
} |
q59298 | validation | function(timestamp) {
int_timestamp = parseInt(timestamp);
assert(int_timestamp >= last_timestamp, "Inconsistent timestamps.");
last_timestamp = int_timestamp;
distortion += distortion_per_entry;
return int_timestamp / 1000 - distortion;
} | javascript | {
"resource": ""
} | |
q59299 | RegExpGetFlags | validation | function RegExpGetFlags() {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(
kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this));
}
var result = '';
if (this.global) result += 'g';
if (this.ignoreCase) result += 'i';
if (this.multiline) result += 'm';
if (this.unicode) result += 'u';
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.