_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q58400 | toAbsoluteURL | validation | function toAbsoluteURL(url) {
const a = document.createElement('a');
a.setAttribute('href', url); // <a href="hoge.html">
// @ts-ignore
return a.cloneNode(false).href; // -> "http://example.com/hoge.html"
} | javascript | {
"resource": ""
} |
q58401 | normalize | validation | function normalize(node) {
if (!(isElement(node) || isDocument(node) || isDocumentFragment(node))) {
return;
}
if (!node.childNodes) {
return;
}
var textRangeStart = -1;
for (var i = node.childNodes.length - 1, n = void 0; i >= 0; i--) {
n = node.childNodes[i];
if (isTextNode(n)) {
if ... | javascript | {
"resource": ""
} |
q58402 | getTextContent | validation | function getTextContent(node) {
if (isCommentNode(node)) {
return node.data || '';
}
if (isTextNode(node)) {
return node.value || '';
}
var subtree = nodeWalkAll(node, isTextNode);
return subtree.map(getTextContent).join('');
} | javascript | {
"resource": ""
} |
q58403 | setTextContent | validation | function setTextContent(node, value) {
if (isCommentNode(node)) {
node.data = value;
} else if (isTextNode(node)) {
node.value = value;
} else {
var tn = newTextNode(value);
tn.parentNode = node;
node.childNodes = [tn];
}
} | javascript | {
"resource": ""
} |
q58404 | treeMap | validation | function treeMap(node, mapfn) {
var results = [];
nodeWalk(node, function(node) {
results = results.concat(mapfn(node));
return false;
});
return results;
} | javascript | {
"resource": ""
} |
q58405 | nodeWalk | validation | function nodeWalk(node, predicate, getChildNodes) {
if (getChildNodes === void 0) {
getChildNodes = module.exports.defaultChildNodes;
}
if (predicate(node)) {
return node;
}
var match = null;
var childNodes = getChildNodes(node);
if (childNodes) {
for (var i = 0; i < childNodes.length; i++) {
... | javascript | {
"resource": ""
} |
q58406 | nodeWalkAll | validation | function nodeWalkAll(node, predicate, matches, getChildNodes) {
if (getChildNodes === void 0) {
getChildNodes = module.exports.defaultChildNodes;
}
if (!matches) {
matches = [];
}
if (predicate(node)) {
matches.push(node);
}
var childNodes = getChildNodes(node);
if (childNodes) {
for (va... | javascript | {
"resource": ""
} |
q58407 | nodeWalkAncestors | validation | function nodeWalkAncestors(node, predicate) {
var parent = node.parentNode;
if (!parent) {
return undefined;
}
if (predicate(parent)) {
return parent;
}
return nodeWalkAncestors(parent, predicate);
} | javascript | {
"resource": ""
} |
q58408 | query | validation | function query(node, predicate, getChildNodes) {
if (getChildNodes === void 0) {
getChildNodes = module.exports.defaultChildNodes;
}
var elementPredicate = AND(isElement, predicate);
return nodeWalk(node, elementPredicate, getChildNodes);
} | javascript | {
"resource": ""
} |
q58409 | queryAll | validation | function queryAll(node, predicate, matches, getChildNodes) {
if (getChildNodes === void 0) {
getChildNodes = module.exports.defaultChildNodes;
}
var elementPredicate = AND(isElement, predicate);
return nodeWalkAll(node, elementPredicate, matches, getChildNodes);
} | javascript | {
"resource": ""
} |
q58410 | insertNode | validation | function insertNode(parent, index, newNode, replace) {
if (!parent.childNodes) {
parent.childNodes = [];
}
var newNodes = [];
var removedNode = replace ? parent.childNodes[index] : null;
if (newNode) {
if (isDocumentFragment(newNode)) {
if (newNode.childNodes) {
newNodes = Array.from(new... | javascript | {
"resource": ""
} |
q58411 | removeNodeSaveChildren | validation | function removeNodeSaveChildren(node) {
// We can't save the children if there's no parent node to provide
// for them.
var fosterParent = node.parentNode;
if (!fosterParent) {
return;
}
var children = (node.childNodes || []).slice();
for (var _i = 0, children_1 = children; _i < children_1.length; _i+... | javascript | {
"resource": ""
} |
q58412 | getCode | validation | function getCode(filePath) {
// take code from cache if available
const cachedCode = esm.compiler.getCached(filePath);
if (cachedCode) {
return cachedCode;
}
if (!fs.existsSync(filePath)) {
throw new Error(`File does not exist: ${filePath}`);
}
// otherwise read code from file and compile it
c... | javascript | {
"resource": ""
} |
q58413 | wrapTransitioningContext | validation | function wrapTransitioningContext(Comp) {
return props => {
return (
<TransitioningContext.Consumer>
{context => <Comp context={context} {...props} />}
</TransitioningContext.Consumer>
);
};
} | javascript | {
"resource": ""
} |
q58414 | split_linebreaks | validation | function split_linebreaks(s) {
//return s.split(/\x0d\x0a|\x0a/);
s = s.replace(acorn.allLineBreaks, '\n');
var out = [],
idx = s.indexOf("\n");
while (idx !== -1) {
out.push(s.substring(0, idx));
s = s.substring(idx + 1);
idx = s.indexOf("\n");
}
if (s.length) {
out.push(s);
}
retu... | javascript | {
"resource": ""
} |
q58415 | onOutputError | validation | function onOutputError(err) {
if (err.code === 'EACCES') {
console.error(err.path + " is not writable. Skipping!");
} else {
console.error(err);
process.exit(0);
}
} | javascript | {
"resource": ""
} |
q58416 | dasherizeShorthands | validation | function dasherizeShorthands(hash) {
// operate in-place
Object.keys(hash).forEach(function(key) {
// each key value is an array
var val = hash[key][0];
// only dasherize one-character shorthands
if (key.length === 1 && val.indexOf('_') > -1) {
hash[dasherizeFlag(val)... | javascript | {
"resource": ""
} |
q58417 | filterUnusedSelectors | validation | function filterUnusedSelectors(selectors, ignore, usedSelectors) {
/* There are some selectors not supported for matching, like
* :before, :after
* They should be removed only if the parent is not found.
* Example: '.clearfix:before' should be removed only if there
* is no '.clearfix'... | javascript | {
"resource": ""
} |
q58418 | filterEmptyAtRules | validation | function filterEmptyAtRules(css) {
/* Filter media queries with no remaining rules */
css.walkAtRules((atRule) => {
if (atRule.name === 'media' && atRule.nodes.length === 0) {
atRule.remove();
}
});
} | javascript | {
"resource": ""
} |
q58419 | filterUnusedRules | validation | function filterUnusedRules(pages, css, ignore, usedSelectors) {
let ignoreNextRule = false,
ignoreNextRulesStart = false,
unusedRules = [],
unusedRuleSelectors,
usedRuleSelectors;
/* Rule format:
* { selectors: [ '...', '...' ],
* declarations: [ { property: '...', ... | javascript | {
"resource": ""
} |
q58420 | parseUncssrc | validation | function parseUncssrc(filename) {
let options = JSON.parse(fs.readFileSync(filename, 'utf-8'));
/* RegExps can't be stored as JSON, therefore we need to parse them manually.
* A string is a RegExp if it starts with '/', since that wouldn't be a valid CSS selector.
*/
options.ignore = options.igno... | javascript | {
"resource": ""
} |
q58421 | parsePaths | validation | function parsePaths(source, stylesheets, options) {
return stylesheets.map((sheet) => {
let sourceProtocol;
const isLocalFile = sheet.substr(0, 5) === 'file:';
if (sheet.substr(0, 4) === 'http') {
/* No need to parse, it's already a valid path */
return sheet;
... | javascript | {
"resource": ""
} |
q58422 | readStylesheets | validation | function readStylesheets(files, outputBanner) {
return Promise.all(files.map((filename) => {
if (isURL(filename)) {
return new Promise((resolve, reject) => {
request({
url: filename,
headers: { 'User-Agent': 'UnCSS' }
}, (er... | javascript | {
"resource": ""
} |
q58423 | getHTML | validation | function getHTML(files, options) {
if (_.isString(files)) {
files = [files];
}
files = _.flatten(files.map((file) => {
if (!isURL(file) && !isHTML(file)) {
return glob.sync(file);
}
return file;
}));
if (!files.length) {
return Promise.reject(new... | javascript | {
"resource": ""
} |
q58424 | processWithTextApi | validation | function processWithTextApi([options, pages, stylesheets]) {
/* If we specified a raw string of CSS, add it to the stylesheets array */
if (options.raw) {
if (_.isString(options.raw)) {
stylesheets.push(options.raw);
} else {
throw new Error('UnCSS: options.raw - expected... | javascript | {
"resource": ""
} |
q58425 | init | validation | function init(files, options, callback) {
if (_.isFunction(options)) {
/* There were no options, this argument is actually the callback */
callback = options;
options = {};
} else if (!_.isFunction(callback)) {
throw new TypeError('UnCSS: expected a callback');
}
/* Try... | javascript | {
"resource": ""
} |
q58426 | fromSource | validation | function fromSource(src, options) {
const config = {
features: {
FetchExternalResources: ['script'],
ProcessExternalResources: ['script']
},
virtualConsole: jsdom.createVirtualConsole().sendTo(console),
userAgent: options.userAgent
};
// The htmlroot ... | javascript | {
"resource": ""
} |
q58427 | getStylesheets | validation | function getStylesheets(window, options) {
if (Array.isArray(options.media) === false) {
options.media = [options.media];
}
const media = _.union(['', 'all', 'screen'], options.media);
const elements = window.document.querySelectorAll('link[rel="stylesheet"]');
return Array.prototype.map.c... | javascript | {
"resource": ""
} |
q58428 | findAll | validation | function findAll(window, sels) {
const document = window.document;
// Unwrap noscript elements.
const elements = document.getElementsByTagName('noscript');
Array.prototype.forEach.call(elements, (ns) => {
const wrapper = document.createElement('div');
wrapper.innerHTML = ns.textContent;... | javascript | {
"resource": ""
} |
q58429 | openDB | validation | function openDB(name, version, { blocked, upgrade, blocking } = {}) {
const request = indexedDB.open(name, version);
const openPromise = wrap(request);
if (upgrade) {
request.addEventListener('upgradeneeded', (event) => {
upgrade(wrap(request.result), event.oldVersion, event.newVers... | javascript | {
"resource": ""
} |
q58430 | deleteDB | validation | function deleteDB(name, { blocked } = {}) {
const request = indexedDB.deleteDatabase(name);
if (blocked)
request.addEventListener('blocked', () => blocked());
return wrap(request).then(() => undefined);
} | javascript | {
"resource": ""
} |
q58431 | getCursorAdvanceMethods | validation | function getCursorAdvanceMethods() {
return cursorAdvanceMethods || (cursorAdvanceMethods = [
IDBCursor.prototype.advance,
IDBCursor.prototype.continue,
IDBCursor.prototype.continuePrimaryKey,
]);
} | javascript | {
"resource": ""
} |
q58432 | resolveOrReject | validation | function resolveOrReject(data) {
if (data.filename) {
console.warn(data);
}
if (!options.async) {
head.removeChild(style);
}
} | javascript | {
"resource": ""
} |
q58433 | validation | function(t) {
return function() {
var obj = Object.create(t.prototype);
t.apply(obj, Array.prototype.slice.call(arguments, 0));
return obj;
};
} | javascript | {
"resource": ""
} | |
q58434 | addReplacementIntoPath | validation | function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {
var newSelectorPath, lastSelector, newJoinedSelector;
// our new selector path
newSelectorPath = [];
// construct the joined selector - if & is the first thing this will be empty,
// if ... | javascript | {
"resource": ""
} |
q58435 | addAllReplacementsIntoPath | validation | function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {
var j;
for (j = 0; j < beginningPath.length; j++) {
var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);
result.push(... | javascript | {
"resource": ""
} |
q58436 | replaceParentSelector | validation | function replaceParentSelector(paths, context, inSelector) {
// The paths are [[Selector]]
// The first list is a list of comma separated selectors
// The inner list is a list of inheritance separated selectors
// e.g.
// .a, .b {
// .c {
// }
// }
... | javascript | {
"resource": ""
} |
q58437 | validation | function (value, unit) {
this.value = parseFloat(value);
if (isNaN(this.value)) {
throw new Error('Dimension is not a number.');
}
this.unit = (unit && unit instanceof Unit) ? unit :
new Unit(unit ? [unit] : undefined);
this.setParent(this.unit, this);
} | javascript | {
"resource": ""
} | |
q58438 | parseNode | validation | function parseNode(str, parseList, currentIndex, fileInfo, callback) {
var result, returnNodes = [];
var parser = parserInput;
try {
parser.start(str, false, function fail(msg, index) {
callback({
message: msg,
index: index + c... | javascript | {
"resource": ""
} |
q58439 | validation | function (str, callback, additionalData) {
var root, error = null, globalVars, modifyVars, ignored, preText = '';
globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + '\n' : '';
modifyVars = (additionalData && additionalData.... | javascript | {
"resource": ""
} | |
q58440 | validation | function () {
if (parserInput.commentStore.length) {
var comment = parserInput.commentStore.shift();
return new(tree.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo);
}
} | javascript | {
"resource": ""
} | |
q58441 | validation | function (forceEscaped) {
var str, index = parserInput.i, isEscaped = false;
parserInput.save();
if (parserInput.$char('~')) {
isEscaped = true;
} else if (forceEscaped) {
parserInput.restore... | javascript | {
"resource": ""
} | |
q58442 | validation | function () {
var ch, name, index = parserInput.i;
parserInput.save();
if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) {
ch = parserInput.currentChar();
if (ch === '(' || ch === ... | javascript | {
"resource": ""
} | |
q58443 | validation | function () {
if (parserInput.peekNotNumeric()) {
return;
}
var value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i);
if (value) {
return new(tree.Dimension)(value[1], value[2]);
... | javascript | {
"resource": ""
} | |
q58444 | validation | function () {
var js, index = parserInput.i;
parserInput.save();
var escape = parserInput.$char('~');
var jsQuote = parserInput.$char('`');
if (!jsQuote) {
parserInput.restore();
... | javascript | {
"resource": ""
} | |
q58445 | validation | function (parsedName) {
var lookups, important, i = parserInput.i,
inValue = !!parsedName, name = parsedName;
parserInput.save();
if (name || (parserInput.currentChar() === '@'
&& (name = parserInput.$re(/^(@[\w-]+)(\(\s*\))?/))))... | javascript | {
"resource": ""
} | |
q58446 | validation | function () {
var name, params = [], match, ruleset, cond, variadic = false;
if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') ||
parserInput.peek(/^[^{]*\}/)) {
return;
}
... | javascript | {
"resource": ""
} | |
q58447 | validation | function () {
var entities = this.entities;
return this.comment() || entities.literal() || entities.variable() || entities.url() ||
entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) ||
entities.javascript();
... | javascript | {
"resource": ""
} | |
q58448 | validation | function () {
var index = parserInput.i, name, value, rules, nonVendorSpecificName,
hasIdentifier, hasExpression, hasUnknown, hasBlock = true, isRooted = true;
if (parserInput.currentChar() !== '@') { return; }
value = this['import']() || this.plugin... | javascript | {
"resource": ""
} | |
q58449 | validation | function () {
var entities = this.entities, negate;
if (parserInput.peek(/^-[@\$\(]/)) {
negate = parserInput.$char('-');
}
var o = this.sub() || entities.dimension() ||
entities.color() || entities.variable() ... | javascript | {
"resource": ""
} | |
q58450 | validation | function () {
var entities = [], e, delim, index = parserInput.i;
do {
e = this.comment();
if (e) {
entities.push(e);
continue;
}
e = this.addition() || this.e... | javascript | {
"resource": ""
} | |
q58451 | validation | function (name, args, index, currentFileInfo) {
this.name = name;
this.args = args;
this.calc = name === 'calc';
this._index = index;
this._fileInfo = currentFileInfo;
} | javascript | {
"resource": ""
} | |
q58452 | validation | function(less) {
this.less = less;
this.require = function(prefix) {
prefix = path.dirname(prefix);
return function(id) {
var str = id.substr(0, 2);
if (str === '..' || str === './') {
return require(path.join(prefix, id));
}
else {... | javascript | {
"resource": ""
} | |
q58453 | validation | function(less, context, rootFileInfo) {
this.less = less;
this.rootFilename = rootFileInfo.filename;
this.paths = context.paths || []; // Search paths, when importing
this.contents = {}; // map - filename to contents of all the files
this.contentsIgnoredChars = {}; /... | javascript | {
"resource": ""
} | |
q58454 | hasFakeRuleset | validation | function hasFakeRuleset(atRuleNode) {
var bodyRules = atRuleNode.rules;
return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);
} | javascript | {
"resource": ""
} |
q58455 | bind | validation | function bind(func, thisArg) {
var curryArgs = Array.prototype.slice.call(arguments, 2);
return function() {
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
return func.apply(thisArg, args);
};
} | javascript | {
"resource": ""
} |
q58456 | getNodeTransitions | validation | function getNodeTransitions(oldData, nextData) {
const oldDataKeyed = oldData && getKeyedData(oldData);
const nextDataKeyed = nextData && getKeyedData(nextData);
return {
entering: oldDataKeyed && getKeyedDataDifference(nextDataKeyed, oldDataKeyed),
exiting: nextDataKeyed && getKeyedDataDifference(oldDat... | javascript | {
"resource": ""
} |
q58457 | getInitialTransitionState | validation | function getInitialTransitionState(oldChildren, nextChildren) {
let nodesWillExit = false;
let nodesWillEnter = false;
const getTransition = (oldChild, newChild) => {
if (!newChild || oldChild.type !== newChild.type) {
return {};
}
const { entering, exiting } =
getNodeTransitions(getChil... | javascript | {
"resource": ""
} |
q58458 | omit | validation | function omit(originalObject, keys = []) {
// code based on babel's _objectWithoutProperties
const newObject = {};
for (const key in originalObject) {
if (keys.indexOf(key) >= 0) {
continue;
}
if (!Object.prototype.hasOwnProperty.call(originalObject, key)) {
continue;
}
newObject[k... | javascript | {
"resource": ""
} |
q58459 | createDomainFunction | validation | function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
getDomainFromDataFunction = isFunction(getDomainFromDataFunction)
? getDomainFromDataFunction
: getDomainFromData;
formatDomainFunction = isFunction(formatDomainFunction) ? formatDomainFunction : formatDomain;
return (props, ... | javascript | {
"resource": ""
} |
q58460 | formatDomain | validation | function formatDomain(domain, props, axis) {
return cleanDomain(padDomain(domain, props, axis), props, axis);
} | javascript | {
"resource": ""
} |
q58461 | getDomainFromCategories | validation | function getDomainFromCategories(props, axis, categories) {
categories = categories || Data.getCategories(props, axis);
const { polar, startAngle = 0, endAngle = 360 } = props;
if (!categories) {
return undefined;
}
const minDomain = getMinFromProps(props, axis);
const maxDomain = getMaxFromProps(props,... | javascript | {
"resource": ""
} |
q58462 | getDomainFromData | validation | function getDomainFromData(props, axis, dataset) {
dataset = dataset || Data.getData(props);
const { polar, startAngle = 0, endAngle = 360 } = props;
const minDomain = getMinFromProps(props, axis);
const maxDomain = getMaxFromProps(props, axis);
if (dataset.length < 1) {
return minDomain !== undefined && ... | javascript | {
"resource": ""
} |
q58463 | getDomainFromMinMax | validation | function getDomainFromMinMax(min, max) {
const getSinglePointDomain = (val) => {
// d3-scale does not properly resolve very small differences.
// eslint-disable-next-line no-magic-numbers
const verySmallNumber = val === 0 ? 2 * Math.pow(10, -10) : Math.pow(10, -10);
const verySmallDate = 1;
const ... | javascript | {
"resource": ""
} |
q58464 | getDomainFromProps | validation | function getDomainFromProps(props, axis) {
const minDomain = getMinFromProps(props, axis);
const maxDomain = getMaxFromProps(props, axis);
if (isPlainObject(props.domain) && props.domain[axis]) {
return props.domain[axis];
} else if (Array.isArray(props.domain)) {
return props.domain;
} else if (minDo... | javascript | {
"resource": ""
} |
q58465 | getDomainWithZero | validation | function getDomainWithZero(props, axis) {
const propsDomain = getDomainFromProps(props, axis);
if (propsDomain) {
return propsDomain;
}
const dataset = Data.getData(props);
const y0Min = dataset.reduce((min, datum) => (datum._y0 < min ? datum._y0 : min), Infinity);
const ensureZero = (domain) => {
... | javascript | {
"resource": ""
} |
q58466 | getMaxFromProps | validation | function getMaxFromProps(props, axis) {
if (isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {
return props.maxDomain[axis];
}
return typeof props.maxDomain === "number" ? props.maxDomain : undefined;
} | javascript | {
"resource": ""
} |
q58467 | getMinFromProps | validation | function getMinFromProps(props, axis) {
if (isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {
return props.minDomain[axis];
}
return typeof props.minDomain === "number" ? props.minDomain : undefined;
} | javascript | {
"resource": ""
} |
q58468 | getSymmetricDomain | validation | function getSymmetricDomain(domain, values) {
const processedData = sortedUniq(values.sort((a, b) => a - b));
const step = processedData[1] - processedData[0];
return [domain[0], domain[1] + step];
} | javascript | {
"resource": ""
} |
q58469 | isDomainComponent | validation | function isDomainComponent(component) {
const getRole = (child) => {
return child && child.type ? child.type.role : "";
};
let role = getRole(component);
if (role === "portal") {
const children = React.Children.toArray(component.props.children);
role = children.length ? getRole(children[0]) : "";
... | javascript | {
"resource": ""
} |
q58470 | generateDataArray | validation | function generateDataArray(props, axis) {
const propsDomain = isPlainObject(props.domain) ? props.domain[axis] : props.domain;
const domain = propsDomain || Scale.getBaseScale(props, axis).domain();
const samples = props.samples || 1;
const domainMax = Math.max(...domain);
const domainMin = Math.min(...domain... | javascript | {
"resource": ""
} |
q58471 | sortData | validation | function sortData(dataset, sortKey, sortOrder = "ascending") {
if (!sortKey) {
return dataset;
}
// Ensures previous VictoryLine api for sortKey prop stays consistent
if (sortKey === "x" || sortKey === "y") {
sortKey = `_${sortKey}`;
}
const order = sortOrder === "ascending" ? "asc" : "desc";
ret... | javascript | {
"resource": ""
} |
q58472 | getEventKey | validation | function getEventKey(key) {
// creates a data accessor function
// given a property key, path, array index, or null for identity.
if (isFunction(key)) {
return key;
} else if (key === null || key === undefined) {
return () => undefined;
}
// otherwise, assume it is an array index, property key or pa... | javascript | {
"resource": ""
} |
q58473 | addEventKeys | validation | function addEventKeys(props, data) {
const hasEventKeyAccessor = !!props.eventKey;
const eventKeyAccessor = getEventKey(props.eventKey);
return data.map((datum) => {
if (datum.eventKey !== undefined) {
return datum;
} else if (hasEventKeyAccessor) {
const eventKey = eventKeyAccessor(datum);
... | javascript | {
"resource": ""
} |
q58474 | createStringMap | validation | function createStringMap(props, axis) {
const stringsFromAxes = getStringsFromAxes(props, axis);
const stringsFromCategories = getStringsFromCategories(props, axis);
const stringsFromData = getStringsFromData(props, axis);
const allStrings = uniq([...stringsFromAxes, ...stringsFromCategories, ...stringsFromDat... | javascript | {
"resource": ""
} |
q58475 | downsample | validation | function downsample(data, maxPoints, startingIndex = 0) {
// ensures that the downampling of data while zooming looks good.
const dataLength = getLength(data);
if (dataLength > maxPoints) {
// limit k to powers of 2, e.g. 64, 128, 256
// so that the same points will be chosen reliably, reducing flicker on... | javascript | {
"resource": ""
} |
q58476 | formatData | validation | function formatData(dataset, props, expectedKeys) {
const isArrayOrIterable = Array.isArray(dataset) || Immutable.isIterable(dataset);
if (!isArrayOrIterable || getLength(dataset) < 1) {
return [];
}
const defaultKeys = ["x", "y", "y0"];
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : default... | javascript | {
"resource": ""
} |
q58477 | generateData | validation | function generateData(props) {
const xValues = generateDataArray(props, "x");
const yValues = generateDataArray(props, "y");
const values = xValues.map((x, i) => {
return { x, y: yValues[i] };
});
return values;
} | javascript | {
"resource": ""
} |
q58478 | getCategories | validation | function getCategories(props, axis) {
return props.categories && !Array.isArray(props.categories)
? props.categories[axis]
: props.categories;
} | javascript | {
"resource": ""
} |
q58479 | getData | validation | function getData(props) {
return props.data ? formatData(props.data, props) : formatData(generateData(props), props);
} | javascript | {
"resource": ""
} |
q58480 | getStringsFromAxes | validation | function getStringsFromAxes(props, axis) {
const { tickValues, tickFormat } = props;
let tickValueArray;
if (!tickValues || (!Array.isArray(tickValues) && !tickValues[axis])) {
tickValueArray = tickFormat && Array.isArray(tickFormat) ? tickFormat : [];
} else {
tickValueArray = tickValues[axis] || tickV... | javascript | {
"resource": ""
} |
q58481 | getStringsFromCategories | validation | function getStringsFromCategories(props, axis) {
if (!props.categories) {
return [];
}
const categories = getCategories(props, axis);
const categoryStrings = categories && categories.filter((val) => typeof val === "string");
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
} | javascript | {
"resource": ""
} |
q58482 | getStringsFromData | validation | function getStringsFromData(props, axis) {
const isArrayOrIterable = Array.isArray(props.data) || Immutable.isIterable(props.data);
if (!isArrayOrIterable) {
return [];
}
const key = props[axis] === undefined ? axis : props[axis];
const accessor = Helpers.createAccessor(key);
// support immutable data... | javascript | {
"resource": ""
} |
q58483 | findAxisComponents | validation | function findAxisComponents(childComponents, predicate) {
predicate = predicate || identity;
const findAxes = (children) => {
return children.reduce((memo, child) => {
if (child.type && child.type.role === "axis" && predicate(child)) {
return memo.concat(child);
} else if (child.props && chi... | javascript | {
"resource": ""
} |
q58484 | getDomainFromData | validation | function getDomainFromData(props, axis) {
const { polar, startAngle = 0, endAngle = 360 } = props;
const tickValues = getTickArray(props);
if (!Array.isArray(tickValues)) {
return undefined;
}
const minDomain = Domain.getMinFromProps(props, axis);
const maxDomain = Domain.getMaxFromProps(props, axis);
... | javascript | {
"resource": ""
} |
q58485 | getDomain | validation | function getDomain(props, axis) {
const inherentAxis = getAxis(props);
if (axis && axis !== inherentAxis) {
return undefined;
}
return Domain.createDomainFunction(getDomainFromData)(props, inherentAxis);
} | javascript | {
"resource": ""
} |
q58486 | fillData | validation | function fillData(props, datasets) {
const { fillInMissingData } = props;
const xMap = datasets.reduce((prev, dataset) => {
dataset.forEach((datum) => {
prev[datum._x instanceof Date ? datum._x.getTime() : datum._x] = true;
});
return prev;
}, {});
const xKeys = keys(xMap).map((k) => +k);
co... | javascript | {
"resource": ""
} |
q58487 | updateState | validation | function updateState() {
history.replaceState(
{
left_top: split_left.scrollTop,
right_top: split_right.scrollTop
},
document.title
);
} | javascript | {
"resource": ""
} |
q58488 | _applyRemainingDefaultOptions | validation | function _applyRemainingDefaultOptions(opts) {
opts.icon = opts.hasOwnProperty('icon') ? opts.icon : '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
opts.visible = opts.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always' & 'touch'
opts.placement ... | javascript | {
"resource": ""
} |
q58489 | _addBaselineStyles | validation | function _addBaselineStyles() {
// We don't want to add global baseline styles if they've been added before.
if (document.head.querySelector('style.anchorjs') !== null) {
return;
}
var style = document.createElement('style'),
linkRule =
' .anchorjs-link {' +
... | javascript | {
"resource": ""
} |
q58490 | getClaimValue | validation | function getClaimValue(entity, prop) {
if (!entity.claims) return;
if (!entity.claims[prop]) return;
let value, c;
for (let i = 0; i < entity.claims[prop].length; i++) {
c = entity.claims[prop][i];
if (c.rank === 'deprecated') continue;
if (c.mainsnak.snaktype !== 'value') conti... | javascript | {
"resource": ""
} |
q58491 | checkWikipedia | validation | function checkWikipedia(brands) {
Object.keys(brands).forEach(k => {
['brand:wikipedia', 'operator:wikipedia'].forEach(t => {
let wp = brands[k].tags[t];
if (wp && !/^[a-z_]{2,}:[^_]*$/.test(wp)) {
_wrongFormat.push([k, wp, t]);
}
});
});
} | javascript | {
"resource": ""
} |
q58492 | buildReverseIndex | validation | function buildReverseIndex(obj) {
let warnCollisions = [];
for (let k in obj) {
checkAmbiguous(k);
if (obj[k].match) {
for (let i = obj[k].match.length - 1; i >= 0; i--) {
let match = obj[k].match[i];
checkAmbiguous(match);
if (rInde... | javascript | {
"resource": ""
} |
q58493 | validation | function (KEY, exec) {
var fn = (_core.Object || {})[KEY] || Object[KEY];
var exp = {};
exp[KEY] = exec(fn);
_export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
} | javascript | {
"resource": ""
} | |
q58494 | validation | function (it) {
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
return it;
} | javascript | {
"resource": ""
} | |
q58495 | isObject | validation | function isObject(obj) {
// incase of arrow function and array
return Object(obj) === obj && String(obj) === '[object Object]' && !isFunction(obj) && !isArray(obj);
} | javascript | {
"resource": ""
} |
q58496 | isNode$2 | validation | function isNode$2(obj) {
return !!((typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? obj instanceof Node : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string');
} | javascript | {
"resource": ""
} |
q58497 | isElement | validation | function isElement(obj) {
return !!((typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? obj instanceof HTMLElement : obj && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string');
} | javascript | {
"resource": ""
} |
q58498 | isPosterityNode | validation | function isPosterityNode(parent, child) {
if (!isNode$2(parent) || !isNode$2(child)) {
return false;
}
while (child.parentNode) {
child = child.parentNode;
if (child === parent) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q58499 | genTraversalHandler | validation | function genTraversalHandler(fn) {
var setter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (target, key, value) {
target[key] = value;
};
// use recursive to move what in source to the target
// if you do not provide a target, we will create a new target
function recursi... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.