_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15900 | train | function (str) {
var strlen = str.length;
if (this.html.substr(this.currentChar, strlen).toLowerCase() === str.toLowerCase()) {
this.currentChar += strlen;
return true;
}
return false;
} | javascript | {
"resource": ""
} | |
q15901 | train | function (str) {
var index = this.html.indexOf(str, this.currentChar) + str.length;
if (index === -1)
this.currentChar = this.html.length;
this.currentChar = index;
} | javascript | {
"resource": ""
} | |
q15902 | train | function () {
var c = this.nextChar();
if (c === undefined)
return null;
// Read any text as Text node
if (c !== "<") {
--this.currentChar;
var textNode = new Text();
var n = this.html.indexOf("<", this.currentChar);
if (n === -1) {
textNode.in... | javascript | {
"resource": ""
} | |
q15903 | train | function (html, url) {
this.html = html;
var doc = this.doc = new Document(url);
this.readChildren(doc);
// If this is an HTML document, remove root-level children except for the
// <html> node
if (doc.documentElement) {
for (var i = doc.childNodes.length; --i >= 0;) {
... | javascript | {
"resource": ""
} | |
q15904 | envFromArgs | train | function envFromArgs(args) {
if (!args) return 'prod';
const envIndex = args.indexOf('--env');
const devIndex = args.indexOf('dev');
if (envIndex === devIndex - 1) return 'dev';
return 'prod';
} | javascript | {
"resource": ""
} |
q15905 | profileFromArgs | train | function profileFromArgs(args) {
if (!args) return null;
const profileIndex = args.indexOf('--profile');
if (profileIndex <= 0 || profileIndex >= args.length - 1) return null;
const profileValue = args[profileIndex + 1];
return profileValue ? profileValue : null;
} | javascript | {
"resource": ""
} |
q15906 | train | function(lines) {
let output = [];
let newlineCount = 0;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (!line.trim()) {
newlineCount++;
} else {
newlineCount = 0;
}
if (newlineCount >= 2) continue;
output.push(line);
}
return output;
} | javascript | {
"resource": ""
} | |
q15907 | handleItemDelete | train | function handleItemDelete(state, action) {
let newState = Object.assign({}, state);
const map = {
'FOLDER_DELETE': ['folders', 'selectedFolderId'],
'NOTE_DELETE': ['notes', 'selectedNoteIds'],
'TAG_DELETE': ['tags', 'selectedTagId'],
'SEARCH_DELETE': ['searches', 'selectedSearchId'],
};
const listKey = ma... | javascript | {
"resource": ""
} |
q15908 | train | function(nodeList, filterFn) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
var parentNode = node.parentNode;
if (parentNode) {
if (!filterFn || filterFn.call(this, node, i, nodeList)) {
parentNode.removeChild(node);
}
}
}
} | javascript | {
"resource": ""
} | |
q15909 | train | function(nodeList, newTagName) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
this._setNodeTag(node, newTagName);
}
} | javascript | {
"resource": ""
} | |
q15910 | train | function() {
var slice = Array.prototype.slice;
var args = slice.call(arguments);
var nodeLists = args.map(function(list) {
return slice.call(list);
});
return Array.prototype.concat.apply([], nodeLists);
} | javascript | {
"resource": ""
} | |
q15911 | train | function(node) {
var classesToPreserve = this._classesToPreserve;
var className = (node.getAttribute("class") || "")
.split(/\s+/)
.filter(function(cls) {
return classesToPreserve.indexOf(cls) != -1;
})
.join(" ");
if (className) {
node.setAttribute("class", className)... | javascript | {
"resource": ""
} | |
q15912 | train | function() {
var doc = this._doc;
// Remove all style tags in head
this._removeNodes(doc.getElementsByTagName("style"));
if (doc.body) {
this._replaceBrs(doc.body);
}
this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN");
} | javascript | {
"resource": ""
} | |
q15913 | train | function (node) {
var next = node;
while (next
&& (next.nodeType != this.ELEMENT_NODE)
&& this.REGEXPS.whitespace.test(next.textContent)) {
next = next.nextSibling;
}
return next;
} | javascript | {
"resource": ""
} | |
q15914 | train | function(byline) {
if (typeof byline == 'string' || byline instanceof String) {
byline = byline.trim();
return (byline.length > 0) && (byline.length < 100);
}
return false;
} | javascript | {
"resource": ""
} | |
q15915 | train | function() {
var metadata = {};
var values = {};
var metaElements = this._doc.getElementsByTagName("meta");
// Match "description", or Twitter's "twitter:description" (Cards)
// in name attribute.
var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi;
// Match Facebook's Ope... | javascript | {
"resource": ""
} | |
q15916 | train | function(doc) {
this._removeNodes(doc.getElementsByTagName('script'), function(scriptNode) {
scriptNode.nodeValue = "";
scriptNode.removeAttribute('src');
return true;
});
this._removeNodes(doc.getElementsByTagName('noscript'));
} | javascript | {
"resource": ""
} | |
q15917 | train | function(element) {
// There should be exactly 1 element child which is a P:
if (element.children.length != 1 || element.children[0].tagName !== "P") {
return false;
}
// And there should be no text nodes with real content
return !this._someNode(element.childNodes, function(node) {
retu... | javascript | {
"resource": ""
} | |
q15918 | train | function (element) {
return this._someNode(element.childNodes, function(node) {
return this.DIV_TO_P_ELEMS.indexOf(node.tagName) !== -1 ||
this._hasChildBlockElement(node);
});
} | javascript | {
"resource": ""
} | |
q15919 | train | function(e, normalizeSpaces) {
normalizeSpaces = (typeof normalizeSpaces === 'undefined') ? true : normalizeSpaces;
var textContent = e.textContent.trim();
if (normalizeSpaces) {
return textContent.replace(this.REGEXPS.normalize, " ");
}
return textContent;
} | javascript | {
"resource": ""
} | |
q15920 | train | function(node, tagName, maxDepth, filterFn) {
maxDepth = maxDepth || 3;
tagName = tagName.toUpperCase();
var depth = 0;
while (node.parentNode) {
if (maxDepth > 0 && depth > maxDepth)
return false;
if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode)))
... | javascript | {
"resource": ""
} | |
q15921 | train | function(table) {
var rows = 0;
var columns = 0;
var trs = table.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
var rowspan = trs[i].getAttribute("rowspan") || 0;
if (rowspan) {
rowspan = parseInt(rowspan, 10);
}
rows += (rowspan || 1);
// Now l... | javascript | {
"resource": ""
} | |
q15922 | train | function(helperIsVisible) {
var nodes = this._getAllNodesWithTag(this._doc, ["p", "pre"]);
// Get <div> nodes which have <br> node(s) and append them into the `nodes` variable.
// Some articles' DOM structures might look like
// <div>
// Sentences<br>
// <br>
// Sentences<br>
// <... | javascript | {
"resource": ""
} | |
q15923 | train | function () {
// Avoid parsing too large documents, as per configuration option
if (this._maxElemsToParse > 0) {
var numTags = this._doc.getElementsByTagName("*").length;
if (numTags > this._maxElemsToParse) {
throw new Error("Aborting parsing document; " + numTags + " elements found");
... | javascript | {
"resource": ""
} | |
q15924 | basicDelta | train | async function basicDelta(path, getDirStatFn, options) {
const outputLimit = 50;
const itemIds = await options.allItemIdsHandler();
if (!Array.isArray(itemIds)) throw new Error('Delta API not supported - local IDs must be provided');
const context = basicDeltaContextFromOptions_(options);
let newContext = {
ti... | javascript | {
"resource": ""
} |
q15925 | train | function(target) {
var setFn = function(value, key) {
target[key] = value;
};
for (var i = 1, ilen = arguments.length; i < ilen; ++i) {
helpers.each(arguments[i], setFn);
}
return target;
} | javascript | {
"resource": ""
} | |
q15926 | train | function(point, area) {
var epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error.
return point.x > area.left - epsilon && point.x < area.right + epsilon &&
point.y > area.top - epsilon && point.y < area.bottom + epsilon;
} | javascript | {
"resource": ""
} | |
q15927 | train | function(options) {
var globalDefaults = core_defaults.global;
var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
var font = {
family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily),
lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeig... | javascript | {
"resource": ""
} | |
q15928 | train | function(inputs, context, index) {
var i, ilen, value;
for (i = 0, ilen = inputs.length; i < ilen; ++i) {
value = inputs[i];
if (value === undefined) {
continue;
}
if (context !== undefined && typeof value === 'function') {
value = value(context);
}
if (index !== undefined && helpers_core... | javascript | {
"resource": ""
} | |
q15929 | getRelativePosition | train | function getRelativePosition(e, chart) {
if (e.native) {
return {
x: e.x,
y: e.y
};
}
return helpers$1.getRelativePosition(e, chart);
} | javascript | {
"resource": ""
} |
q15930 | fitBox | train | function fitBox(box) {
var minBoxSize = helpers$1.findNextWhere(minBoxSizes, function(minBox) {
return minBox.box === box;
});
if (minBoxSize) {
if (minBoxSize.horizontal) {
var scaleMargin = {
left: Math.max(outerBoxSizes.left, maxPadding.left),
right: Math.max(outerBoxSizes.right, m... | javascript | {
"resource": ""
} |
q15931 | mergeConfig | train | function mergeConfig(/* config objects ... */) {
return helpers$1.merge({}, [].slice.call(arguments), {
merger: function(key, target, source, options) {
var tval = target[key] || {};
var sval = source[key];
if (key === 'scales') {
// scale config merging is complex. Add our own function here for that
... | javascript | {
"resource": ""
} |
q15932 | train | function() {
var me = this;
helpers$1.each(me.data.datasets, function(dataset, datasetIndex) {
me.getDatasetMeta(datasetIndex).controller.reset();
}, me);
} | javascript | {
"resource": ""
} | |
q15933 | train | function(easingValue) {
var me = this;
var tooltip = me.tooltip;
var args = {
tooltip: tooltip,
easingValue: easingValue
};
if (core_plugins.notify(me, 'beforeTooltipDraw', [args]) === false) {
return;
}
tooltip.draw();
core_plugins.notify(me, 'afterTooltipDraw', [args]);
} | javascript | {
"resource": ""
} | |
q15934 | getConstraintDimension | train | function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = helpers$1._getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = i... | javascript | {
"resource": ""
} |
q15935 | generateTicks | train | function generateTicks(generationOptions, dataRange) {
var ticks = [];
// To get a "nice" value for the tick spacing, we will use the appropriately named
// "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
// for details.
var MIN_SPACING =... | javascript | {
"resource": ""
} |
q15936 | train | function(value) {
var exp = Math.floor(helpers$1.log10(value));
var significand = Math.floor(value / Math.pow(10, exp));
return significand * Math.pow(10, exp);
} | javascript | {
"resource": ""
} | |
q15937 | bindInternal4 | train | function bindInternal4(func, thisContext) {
return function (a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
} | javascript | {
"resource": ""
} |
q15938 | mangleScope | train | function mangleScope(scope) {
let newNames = new Set();
// Sort bindings so that more frequently referenced bindings get shorter names.
let sortedBindings = Object.keys(scope.bindings).sort(
(a, b) =>
scope.bindings[b].referencePaths.length -
scope.bindings[a].referencePaths.length
);
for (l... | javascript | {
"resource": ""
} |
q15939 | mergeBlocks | train | function mergeBlocks(blocks) {
let finalBlock;
for (const block of blocks) {
if (!finalBlock) finalBlock = block;
else {
block.nodes.forEach(node => finalBlock.push(node));
}
}
return finalBlock;
} | javascript | {
"resource": ""
} |
q15940 | morph | train | function morph(object, newProperties) {
for (let key in object) {
delete object[key];
}
for (let key in newProperties) {
object[key] = newProperties[key];
}
} | javascript | {
"resource": ""
} |
q15941 | getFlowConfig | train | function getFlowConfig(asset) {
if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) {
return {
internal: true,
babelVersion: 7,
config: {
plugins: [[require('@babel/plugin-transform-flow-strip-types')]]
}
};
}
return null;
} | javascript | {
"resource": ""
} |
q15942 | syncPromise | train | function syncPromise(promise) {
let isDone = false;
let res, err;
promise.then(
value => {
res = value;
isDone = true;
},
error => {
err = error;
isDone = true;
}
);
deasync.loopWhile(() => !isDone);
if (err) {
throw err;
}
return res;
} | javascript | {
"resource": ""
} |
q15943 | treeShake | train | function treeShake(scope) {
// Keep passing over all bindings in the scope until we don't remove any.
// This handles cases where we remove one binding which had a reference to
// another one. That one will get removed in the next pass if it is now unreferenced.
let removed;
do {
removed = false;
// ... | javascript | {
"resource": ""
} |
q15944 | getUnusedBinding | train | function getUnusedBinding(path, name) {
let binding = path.scope.getBinding(name);
if (!binding) {
return null;
}
let pure = isPure(binding);
if (!binding.referenced && pure) {
return binding;
}
// Is there any references which aren't simple assignments?
let bailout = binding.referencePaths.so... | javascript | {
"resource": ""
} |
q15945 | pad | train | function pad(text, length, align = 'left') {
let pad = ' '.repeat(length - stringWidth(text));
if (align === 'right') {
return pad + text;
}
return text + pad;
} | javascript | {
"resource": ""
} |
q15946 | normalizeError | train | function normalizeError(err) {
let message = 'Unknown error';
if (err) {
if (err instanceof Error) {
return err;
}
message = err.stack || err.message || err;
}
return new Error(message);
} | javascript | {
"resource": ""
} |
q15947 | getJSXConfig | train | async function getJSXConfig(asset, isSourceModule) {
// Don't enable JSX in node_modules
if (!isSourceModule) {
return null;
}
let pkg = await asset.getPackage();
// Find a dependency that we can map to a JSX pragma
let pragma = null;
for (let dep in JSX_PRAGMA) {
if (
pkg &&
((pkg.d... | javascript | {
"resource": ""
} |
q15948 | train | function() {
this.scrollToCurrent();
window.addEventListener('hashchange', this.scrollToCurrent.bind(this));
document.body.addEventListener('click', this.delegateAnchors.bind(this));
} | javascript | {
"resource": ""
} | |
q15949 | train | function() {
let search_box = document.getElementById("search-input")
search_box.onclick = function() {
document.getElementById("search-image").style.display = "none";
search_box.style.outline = "none";
search_box.placeholder = "Search";
search_box.style.paddingLeft = "2px";
}
} | javascript | {
"resource": ""
} | |
q15950 | train | function(nodes) {
var map = {},
imports = [];
// Compute a map from name to node.
nodes.forEach(function(d) {
map[d.name] = d;
});
// For each import, construct a link from the source to target node.
nodes.forEach(function(d) {
if (d.imports) d.imports.for... | javascript | {
"resource": ""
} | |
q15951 | BlocksToMoveVisitor | train | function BlocksToMoveVisitor() {
this.visit = function(element) {
if (isBlock(element)) {
blocksToMove.push(findBlock(element.id));
return false;
}
return true;
}
} | javascript | {
"resource": ""
} |
q15952 | getStyle | train | function getStyle(node, styleProp) {
// if not an element
if( node.nodeType != 1)
return;
var value;
if (node.currentStyle) {
// ie case
styleProp = replaceDashWithCamelNotation(styleProp);
value = node.currentStyle[styleProp];
} else if (window.getComputedStyle) {
// mozilla case
value = document.d... | javascript | {
"resource": ""
} |
q15953 | resizeCanvas | train | function resizeCanvas() {
var divElement = document.getElementById("mainCanvas");
var screenHeight = window.innerHeight || document.body.offsetHeight;
divElement.style.height = (screenHeight - 16) + "px";
} | javascript | {
"resource": ""
} |
q15954 | setMenu | train | function setMenu() {
var url = document.location.href;
// strip extension
url = stripExtension(url);
var ulElement = document.getElementById("menu");
var links = ulElement.getElementsByTagName("A");
var i;
for(i = 0; i < links.length; i++) {
if(url.indexOf(stripExtension(links[i].href)) == 0) {
... | javascript | {
"resource": ""
} |
q15955 | stripExtension | train | function stripExtension(url) {
var lastDotPos = url.lastIndexOf('.');
return (lastDotPos <= 0)? url:
url.substring (0, lastDotPos - 1);
} | javascript | {
"resource": ""
} |
q15956 | getElementCoords | train | function getElementCoords (element, coords) {
coords = coords || element.node().getBBox()
const ctm = element.node().getCTM()
const xn = ctm.e + coords.x * ctm.a
const yn = ctm.f + coords.y * ctm.d
return {
left: xn,
top: yn,
width: coords.width,
height: coords.height
}
} | javascript | {
"resource": ""
} |
q15957 | buildDocsEntry | train | function buildDocsEntry() {
const output = join('docs/src/docs-entry.js');
const getName = fullPath => fullPath.replace(/\/(en|zh)/, '.$1').split('/').pop().replace('.md', '');
const docs = glob
.sync([
join('docs/**/*.md'),
join('packages/**/*.md'),
'!**/node_modules/**'
])
.map(ful... | javascript | {
"resource": ""
} |
q15958 | analyzeDependencies | train | function analyzeDependencies(component) {
const checkList = ['base'];
search(
dependencyTree({
directory: dir,
filename: path.join(dir, component, 'index.js'),
filter: path => !~path.indexOf('node_modules')
}),
component,
checkList
);
if (!whiteList.includes(component)) {
... | javascript | {
"resource": ""
} |
q15959 | compile | train | async function compile() {
let codes;
const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true });
codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8')));
codes = await compileLess(codes, paths);
codes = await compilePostcss(codes, paths);
codes = await compileCsso... | javascript | {
"resource": ""
} |
q15960 | invertCurve | train | function invertCurve(curve){
var out = new Array(curve.length);
for (var j = 0; j < curve.length; j++){
out[j] = 1 - curve[j];
}
return out;
} | javascript | {
"resource": ""
} |
q15961 | _wrapScheduleMethods | train | function _wrapScheduleMethods(method){
return function(value, time){
time = this.toSeconds(time);
method.apply(this, arguments);
var event = this._events.get(time);
var previousEvent = this._events.previousEvent(event);
var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time);
event.ticks = Math.... | javascript | {
"resource": ""
} |
q15962 | computeSplitMapLayers | train | function computeSplitMapLayers(layers) {
const mapLayers = layers.reduce(
(newLayers, currentLayer) => ({
...newLayers,
[currentLayer.id]: generateLayerMetaForSplitViews(currentLayer)
}),
{}
);
return [
{
layers: mapLayers
},
{
layers: mapLayers
}
];
} | javascript | {
"resource": ""
} |
q15963 | removeLayerFromSplitMaps | train | function removeLayerFromSplitMaps(state, layer) {
return state.splitMaps.map(settings => {
const {layers} = settings;
/* eslint-disable no-unused-vars */
const {[layer.id]: _, ...newLayers} = layers;
/* eslint-enable no-unused-vars */
return {
...settings,
layers: newLayers
};
})... | javascript | {
"resource": ""
} |
q15964 | addNewLayersToSplitMap | train | function addNewLayersToSplitMap(splitMaps, layers) {
const newLayers = Array.isArray(layers) ? layers : [layers];
if (!splitMaps || !splitMaps.length || !newLayers.length) {
return splitMaps;
}
// add new layer to both maps,
// don't override, if layer.id is already in splitMaps.settings.layers
retur... | javascript | {
"resource": ""
} |
q15965 | toggleLayerFromSplitMaps | train | function toggleLayerFromSplitMaps(state, layer) {
return state.splitMaps.map(settings => {
const {layers} = settings;
const newLayers = {
...layers,
[layer.id]: generateLayerMetaForSplitViews(layer)
};
return {
...settings,
layers: newLayers
};
});
} | javascript | {
"resource": ""
} |
q15966 | authLink | train | function authLink(path = 'auth') {
return dropbox.getAuthenticationUrl(
`${window.location.origin}/${path}`,
btoa(JSON.stringify({handler: 'dropbox', origin: window.location.origin}))
)
} | javascript | {
"resource": ""
} |
q15967 | shareFile | train | function shareFile(metadata) {
return dropbox.sharingCreateSharedLinkWithSettings({
path: metadata.path_display || metadata.path_lower
}).then(
// Update URL to avoid CORS issue
// Unfortunately this is not the ideal scenario but it will make sure people
// can share dropbox urls with users without ... | javascript | {
"resource": ""
} |
q15968 | getAccessToken | train | function getAccessToken() {
let token = dropbox.getAccessToken();
if (!token && window.localStorage) {
const jsonString = window.localStorage.getItem('dropbox');
token = jsonString && JSON.parse(jsonString).token;
if (token) {
dropbox.setAccessToken(token);
}
}
return (token || '') !== ''... | javascript | {
"resource": ""
} |
q15969 | _appendActionToUpdaters | train | function _appendActionToUpdaters(node, actionMap) {
if (node.members && node.members.static.length) {
node.members.static = node.members.static.map(nd => _appendActionToUpdaters(nd, actionMap));
}
const updater = node.name;
const action = Object.values(actionMap)
.find(action => action.updaters.find(u... | javascript | {
"resource": ""
} |
q15970 | _cleanUpTOCChildren | train | function _cleanUpTOCChildren(node) {
if (!Array.isArray(node.children)) {
return node;
}
if (_isExampleOrParameterLink(node)) {
return null;
}
const filteredChildren = node.children.reduce((accu, nd) => {
accu.push(_cleanUpTOCChildren(nd));
return accu;
}, []).filter(n => n);
if (!filt... | javascript | {
"resource": ""
} |
q15971 | geojsonSizeFieldV0ToV1 | train | function geojsonSizeFieldV0ToV1(config) {
const defaultRaiuds = 10;
const defaultRadiusRange = [0, 50];
// if extruded, sizeField is most likely used for height
if (config.visConfig.extruded) {
return 'heightField';
}
// if show stroke enabled, sizeField is most likely used for stroke
if (config.vis... | javascript | {
"resource": ""
} |
q15972 | mergeActions | train | function mergeActions(actions, userActions) {
const overrides = {};
for (const key in userActions) {
if (userActions.hasOwnProperty(key) && actions.hasOwnProperty(key)) {
overrides[key] = userActions[key];
}
}
return {...actions, ...overrides};
} | javascript | {
"resource": ""
} |
q15973 | loadRemoteRawData | train | function loadRemoteRawData(url) {
if (!url) {
// TODO: we should return reject with an appropriate error
return Promise.resolve(null)
}
return new Promise((resolve, reject) => {
request(url, (error, result) => {
if (error) {
reject(error);
}
const responseError = detectRespo... | javascript | {
"resource": ""
} |
q15974 | loadRemoteSampleMap | train | function loadRemoteSampleMap(options) {
return (dispatch) => {
// Load configuration first
const {configUrl, dataUrl} = options;
Promise
.all([loadRemoteConfig(configUrl), loadRemoteData(dataUrl)])
.then(
([config, data]) => {
// TODO: these two actions can be merged
... | javascript | {
"resource": ""
} |
q15975 | addActionHandler | train | function addActionHandler(path, actionMap, filePath) {
const {init} = path.node;
if (init && Array.isArray(init.properties)) {
init.properties.forEach(property => {
const {key, value} = property;
if (key && value && key.property && value.property) {
const actionType = key.property.name;
... | javascript | {
"resource": ""
} |
q15976 | addActionCreator | train | function addActionCreator(path, actionMap, filePath) {
const {node, parentPath} = path;
if (node.arguments.length && parentPath.node && parentPath.node.id) {
const action = parentPath.node.id.name;
const firstArg = node.arguments[0];
const actionType = firstArg.property ? firstArg.property.name : firs... | javascript | {
"resource": ""
} |
q15977 | getHistogram | train | function getHistogram(domain, mappedValue) {
const histogram = histogramConstruct(domain, mappedValue, histogramBins);
const enlargedHistogram = histogramConstruct(
domain,
mappedValue,
enlargedHistogramBins
);
return {histogram, enlargedHistogram};
} | javascript | {
"resource": ""
} |
q15978 | classifyRings | train | function classifyRings(rings) {
const len = rings.length;
if (len <= 1) return [rings];
const polygons = [];
let polygon;
let ccw;
for (let i = 0; i < len; i++) {
const area = signedArea(rings[i]);
if (area === 0) {
continue;
}
if (ccw === undefined) {
ccw = area < 0;
}
... | javascript | {
"resource": ""
} |
q15979 | CustomSidebarFactory | train | function CustomSidebarFactory(CloseButton) {
const SideBar = SidebarFactory(CloseButton);
const CustomSidebar = (props) => (
<StyledSideBarContainer>
<SideBar {...props}/>
</StyledSideBarContainer>
);
return CustomSidebar;
} | javascript | {
"resource": ""
} |
q15980 | cleanUpFalsyCsvValue | train | function cleanUpFalsyCsvValue(rows) {
for (let i = 0; i < rows.length; i++) {
for (let j = 0; j < rows[i].length; j++) {
// analyzer will set any fields to 'string' if there are empty values
// which will be parsed as '' by d3.csv
// here we parse empty data as null
// TODO: create warning... | javascript | {
"resource": ""
} |
q15981 | hasProblematicOverloading | train | function hasProblematicOverloading(instances) {
// Check if there are same lengthed argument sets
const knownLengths = [];
return instances.map(({ args }) => args.length).reduce((carry, item) => {
if (carry || knownLengths.some((l) => l === item)) {
return true;
}
knownLengths.pus... | javascript | {
"resource": ""
} |
q15982 | isEmpty | train | function isEmpty(obj) {
if (Array.isArray(obj)) {
return obj.length === 0;
} else if (typeof obj === 'object') {
for (var i in obj) {
return false;
}
return true;
} else {
return !obj;
}
} | javascript | {
"resource": ""
} |
q15983 | getAppPath | train | function getAppPath(appPathArray) {
if (appPathArray.length === 0) {
// directory already exists, --overwrite is not set
// exit here
return null;
}
if (appPathArray.length > 1) {
log.warn(
'Warning: This should not be happening, packaged app path contains more than one element:',
app... | javascript | {
"resource": ""
} |
q15984 | maybeNoIconOption | train | function maybeNoIconOption(options) {
const packageOptions = JSON.parse(JSON.stringify(options));
if (options.platform === 'win32' && !isWindows()) {
if (!hasBinary.sync('wine')) {
log.warn(
'Wine is required to set the icon for a Windows app when packaging on non-windows platforms',
);
... | javascript | {
"resource": ""
} |
q15985 | removeInvalidOptions | train | function removeInvalidOptions(options, param) {
const packageOptions = JSON.parse(JSON.stringify(options));
if (options.platform === 'win32' && !isWindows()) {
if (!hasBinary.sync('wine')) {
log.warn(
`Wine is required to use "${param}" option for a Windows app when packaging on non-windows platfo... | javascript | {
"resource": ""
} |
q15986 | findSync | train | function findSync(pattern, basePath, findDir) {
const matches = [];
(function findSyncRecurse(base) {
let children;
try {
children = fs.readdirSync(base);
} catch (exception) {
if (exception.code === 'ENOENT') {
return;
}
throw exception;
}
children.forEach((chi... | javascript | {
"resource": ""
} |
q15987 | wrap | train | function wrap(fieldName, promise, args) {
return promise(args).then((result) => ({
[fieldName]: result,
}));
} | javascript | {
"resource": ""
} |
q15988 | getMatchingIcons | train | function getMatchingIcons(iconsWithScores, maxScore) {
return iconsWithScores
.filter((item) => item.score === maxScore)
.map((item) => Object.assign({}, item, { ext: path.extname(item.url) }));
} | javascript | {
"resource": ""
} |
q15989 | selectAppArgs | train | function selectAppArgs(options) {
return {
name: options.name,
targetUrl: options.targetUrl,
counter: options.counter,
bounce: options.bounce,
width: options.width,
height: options.height,
minWidth: options.minWidth,
minHeight: options.minHeight,
maxWidth: options.maxWidth,
max... | javascript | {
"resource": ""
} |
q15990 | convertToIcnsTmp | train | function convertToIcnsTmp(pngSrc, callback) {
const tempIconDirObj = tmp.dirSync({ unsafeCleanup: true });
const tempIconDirPath = tempIconDirObj.name;
convertToIcns(pngSrc, `${tempIconDirPath}/icon.icns`, callback);
} | javascript | {
"resource": ""
} |
q15991 | debugLog | train | function debugLog(browserWindow, message) {
// need the timeout as it takes time for the preload javascript to be loaded in the window
setTimeout(() => {
browserWindow.webContents.send('debug', message);
}, 3000);
log.info(message);
} | javascript | {
"resource": ""
} |
q15992 | patchDisplay | train | function patchDisplay(cm, updateNumbersFrom, dims) {
let display = cm.display, lineNumbers = cm.options.lineNumbers
let container = display.lineDiv, cur = container.firstChild
function rm(node) {
let next = node.nextSibling
// Works around a throw-scroll bug in OS X Webkit
if (webkit && mac && cm.dis... | javascript | {
"resource": ""
} |
q15993 | skipAtomicInSelection | train | function skipAtomicInSelection(doc, sel, bias, mayClear) {
let out
for (let i = 0; i < sel.ranges.length; i++) {
let range = sel.ranges[i]
let old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]
let newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear)
let ne... | javascript | {
"resource": ""
} |
q15994 | lastChangeEvent | train | function lastChangeEvent(hist, force) {
if (force) {
clearSelectionEvents(hist.done)
return lst(hist.done)
} else if (hist.done.length && !lst(hist.done).ranges) {
return lst(hist.done)
} else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
hist.done.pop()
return lst(his... | javascript | {
"resource": ""
} |
q15995 | getOldSpans | train | function getOldSpans(doc, change) {
let found = change["spans_" + doc.id]
if (!found) return null
let nw = []
for (let i = 0; i < change.text.length; ++i)
nw.push(removeClearedSpans(found[i]))
return nw
} | javascript | {
"resource": ""
} |
q15996 | handleKeyBinding | train | function handleKeyBinding(cm, e) {
let name = keyName(e, true)
if (!name) return false
if (e.shiftKey && !cm.state.keySeq) {
// First try to resolve full name (including 'Shift-'). Failing
// that, see if there is a cursor-motion command (starting with
// 'go') bound to the keyname without 'Shift-'.
... | javascript | {
"resource": ""
} |
q15997 | handleCharBinding | train | function handleCharBinding(cm, e, ch) {
return dispatchKey(cm, "'" + ch + "'", e, b => doHandleBinding(cm, b, true))
} | javascript | {
"resource": ""
} |
q15998 | boxIsAfter | train | function boxIsAfter(box, x, y, left) {
return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
} | javascript | {
"resource": ""
} |
q15999 | runMode | train | function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
let flattenSpans = mode.flattenSpans
if (flattenSpans == null) flattenSpans = cm.options.flattenSpans
let curStart = 0, curStyle = null
let stream = new StringStream(text, cm.options.tabSize, context), style
let inner = cm.options.addMode... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.