id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1,200 | openlayers/openlayers | examples/measure.js | createHelpTooltip | function createHelpTooltip() {
if (helpTooltipElement) {
helpTooltipElement.parentNode.removeChild(helpTooltipElement);
}
helpTooltipElement = document.createElement('div');
helpTooltipElement.className = 'ol-tooltip hidden';
helpTooltip = new Overlay({
element: helpTooltipElement,
offset: [15, 0]... | javascript | function createHelpTooltip() {
if (helpTooltipElement) {
helpTooltipElement.parentNode.removeChild(helpTooltipElement);
}
helpTooltipElement = document.createElement('div');
helpTooltipElement.className = 'ol-tooltip hidden';
helpTooltip = new Overlay({
element: helpTooltipElement,
offset: [15, 0]... | [
"function",
"createHelpTooltip",
"(",
")",
"{",
"if",
"(",
"helpTooltipElement",
")",
"{",
"helpTooltipElement",
".",
"parentNode",
".",
"removeChild",
"(",
"helpTooltipElement",
")",
";",
"}",
"helpTooltipElement",
"=",
"document",
".",
"createElement",
"(",
"'di... | Creates a new help tooltip | [
"Creates",
"a",
"new",
"help",
"tooltip"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L243-L255 |
1,201 | openlayers/openlayers | examples/measure.js | createMeasureTooltip | function createMeasureTooltip() {
if (measureTooltipElement) {
measureTooltipElement.parentNode.removeChild(measureTooltipElement);
}
measureTooltipElement = document.createElement('div');
measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
measureTooltip = new Overlay({
element: measur... | javascript | function createMeasureTooltip() {
if (measureTooltipElement) {
measureTooltipElement.parentNode.removeChild(measureTooltipElement);
}
measureTooltipElement = document.createElement('div');
measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
measureTooltip = new Overlay({
element: measur... | [
"function",
"createMeasureTooltip",
"(",
")",
"{",
"if",
"(",
"measureTooltipElement",
")",
"{",
"measureTooltipElement",
".",
"parentNode",
".",
"removeChild",
"(",
"measureTooltipElement",
")",
";",
"}",
"measureTooltipElement",
"=",
"document",
".",
"createElement"... | Creates a new measure tooltip | [
"Creates",
"a",
"new",
"measure",
"tooltip"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L261-L273 |
1,202 | openlayers/openlayers | src/ol/sphere.js | getAreaInternal | function getAreaInternal(coordinates, radius) {
let area = 0;
const len = coordinates.length;
let x1 = coordinates[len - 1][0];
let y1 = coordinates[len - 1][1];
for (let i = 0; i < len; i++) {
const x2 = coordinates[i][0];
const y2 = coordinates[i][1];
area += toRadians(x2 - x1) *
(2 + Ma... | javascript | function getAreaInternal(coordinates, radius) {
let area = 0;
const len = coordinates.length;
let x1 = coordinates[len - 1][0];
let y1 = coordinates[len - 1][1];
for (let i = 0; i < len; i++) {
const x2 = coordinates[i][0];
const y2 = coordinates[i][1];
area += toRadians(x2 - x1) *
(2 + Ma... | [
"function",
"getAreaInternal",
"(",
"coordinates",
",",
"radius",
")",
"{",
"let",
"area",
"=",
"0",
";",
"const",
"len",
"=",
"coordinates",
".",
"length",
";",
"let",
"x1",
"=",
"coordinates",
"[",
"len",
"-",
"1",
"]",
"[",
"0",
"]",
";",
"let",
... | Returns the spherical area for a list of coordinates.
[Reference](https://trs-new.jpl.nasa.gov/handle/2014/40409)
Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for
Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
Laboratory, Pasadena, CA, June 2007
@param {Array<import("./coordinate.js"... | [
"Returns",
"the",
"spherical",
"area",
"for",
"a",
"list",
"of",
"coordinates",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/sphere.js#L153-L168 |
1,203 | openlayers/openlayers | examples/wms-custom-proj.js | DECtoSEX | function DECtoSEX(angle) {
// Extract DMS
const deg = parseInt(angle, 10);
const min = parseInt((angle - deg) * 60, 10);
const sec = (((angle - deg) * 60) - min) * 60;
// Result in degrees sex (dd.mmss)
return deg + min / 100 + sec / 10000;
} | javascript | function DECtoSEX(angle) {
// Extract DMS
const deg = parseInt(angle, 10);
const min = parseInt((angle - deg) * 60, 10);
const sec = (((angle - deg) * 60) - min) * 60;
// Result in degrees sex (dd.mmss)
return deg + min / 100 + sec / 10000;
} | [
"function",
"DECtoSEX",
"(",
"angle",
")",
"{",
"// Extract DMS",
"const",
"deg",
"=",
"parseInt",
"(",
"angle",
",",
"10",
")",
";",
"const",
"min",
"=",
"parseInt",
"(",
"(",
"angle",
"-",
"deg",
")",
"*",
"60",
",",
"10",
")",
";",
"const",
"sec... | Convert DEC angle to SEX DMS | [
"Convert",
"DEC",
"angle",
"to",
"SEX",
"DMS"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/wms-custom-proj.js#L193-L203 |
1,204 | openlayers/openlayers | examples/wms-custom-proj.js | DEGtoSEC | function DEGtoSEC(angle) {
// Extract DMS
const deg = parseInt(angle, 10);
let min = parseInt((angle - deg) * 100, 10);
let sec = (((angle - deg) * 100) - min) * 100;
// Avoid rounding problems with seconds=0
const parts = String(angle).split('.');
if (parts.length == 2 && parts[1].length == 2) {
mi... | javascript | function DEGtoSEC(angle) {
// Extract DMS
const deg = parseInt(angle, 10);
let min = parseInt((angle - deg) * 100, 10);
let sec = (((angle - deg) * 100) - min) * 100;
// Avoid rounding problems with seconds=0
const parts = String(angle).split('.');
if (parts.length == 2 && parts[1].length == 2) {
mi... | [
"function",
"DEGtoSEC",
"(",
"angle",
")",
"{",
"// Extract DMS",
"const",
"deg",
"=",
"parseInt",
"(",
"angle",
",",
"10",
")",
";",
"let",
"min",
"=",
"parseInt",
"(",
"(",
"angle",
"-",
"deg",
")",
"*",
"100",
",",
"10",
")",
";",
"let",
"sec",
... | Convert Degrees angle to seconds | [
"Convert",
"Degrees",
"angle",
"to",
"seconds"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/wms-custom-proj.js#L206-L223 |
1,205 | openlayers/openlayers | src/ol/events.js | getListenerMap | function getListenerMap(target, opt_create) {
let listenerMap = target.ol_lm;
if (!listenerMap && opt_create) {
listenerMap = target.ol_lm = {};
}
return listenerMap;
} | javascript | function getListenerMap(target, opt_create) {
let listenerMap = target.ol_lm;
if (!listenerMap && opt_create) {
listenerMap = target.ol_lm = {};
}
return listenerMap;
} | [
"function",
"getListenerMap",
"(",
"target",
",",
"opt_create",
")",
"{",
"let",
"listenerMap",
"=",
"target",
".",
"ol_lm",
";",
"if",
"(",
"!",
"listenerMap",
"&&",
"opt_create",
")",
"{",
"listenerMap",
"=",
"target",
".",
"ol_lm",
"=",
"{",
"}",
";",... | Get the lookup of listeners.
@param {Object} target Target.
@param {boolean=} opt_create If a map should be created if it doesn't exist.
@return {!Object<string, Array<EventsKey>>} Map of
listeners by event type. | [
"Get",
"the",
"lookup",
"of",
"listeners",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/events.js#L93-L99 |
1,206 | openlayers/openlayers | src/ol/events.js | removeListeners | function removeListeners(target, type) {
const listeners = getListeners(target, type);
if (listeners) {
for (let i = 0, ii = listeners.length; i < ii; ++i) {
/** @type {import("./events/Target.js").default} */ (target).
removeEventListener(type, listeners[i].boundListener);
clear(listeners[i... | javascript | function removeListeners(target, type) {
const listeners = getListeners(target, type);
if (listeners) {
for (let i = 0, ii = listeners.length; i < ii; ++i) {
/** @type {import("./events/Target.js").default} */ (target).
removeEventListener(type, listeners[i].boundListener);
clear(listeners[i... | [
"function",
"removeListeners",
"(",
"target",
",",
"type",
")",
"{",
"const",
"listeners",
"=",
"getListeners",
"(",
"target",
",",
"type",
")",
";",
"if",
"(",
"listeners",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"listeners",
"."... | Clean up all listener objects of the given type. All properties on the
listener objects will be removed, and if no listeners remain in the listener
map, it will be removed from the target.
@param {import("./events/Target.js").EventTargetLike} target Target.
@param {string} type Type. | [
"Clean",
"up",
"all",
"listener",
"objects",
"of",
"the",
"given",
"type",
".",
"All",
"properties",
"on",
"the",
"listener",
"objects",
"will",
"be",
"removed",
"and",
"if",
"no",
"listeners",
"remain",
"in",
"the",
"listener",
"map",
"it",
"will",
"be",
... | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/events.js#L118-L135 |
1,207 | openlayers/openlayers | src/ol/source/Raster.js | getImageData | function getImageData(layer, frameState, layerState) {
const renderer = layer.getRenderer();
if (!renderer) {
throw new Error('Unsupported layer type: ' + layer);
}
if (!renderer.prepareFrame(frameState, layerState)) {
return null;
}
const width = frameState.size[0];
const height = frameState.siz... | javascript | function getImageData(layer, frameState, layerState) {
const renderer = layer.getRenderer();
if (!renderer) {
throw new Error('Unsupported layer type: ' + layer);
}
if (!renderer.prepareFrame(frameState, layerState)) {
return null;
}
const width = frameState.size[0];
const height = frameState.siz... | [
"function",
"getImageData",
"(",
"layer",
",",
"frameState",
",",
"layerState",
")",
"{",
"const",
"renderer",
"=",
"layer",
".",
"getRenderer",
"(",
")",
";",
"if",
"(",
"!",
"renderer",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unsupported layer type: '",
... | Get image data from a layer.
@param {import("../layer/Layer.js").default} layer Layer to render.
@param {import("../PluggableMap.js").FrameState} frameState The frame state.
@param {import("../layer/Layer.js").State} layerState The layer state.
@return {ImageData} The image data. | [
"Get",
"image",
"data",
"from",
"a",
"layer",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/source/Raster.js#L436-L468 |
1,208 | openlayers/openlayers | src/ol/source/Raster.js | createLayers | function createLayers(sources) {
const len = sources.length;
const layers = new Array(len);
for (let i = 0; i < len; ++i) {
layers[i] = createLayer(sources[i]);
}
return layers;
} | javascript | function createLayers(sources) {
const len = sources.length;
const layers = new Array(len);
for (let i = 0; i < len; ++i) {
layers[i] = createLayer(sources[i]);
}
return layers;
} | [
"function",
"createLayers",
"(",
"sources",
")",
"{",
"const",
"len",
"=",
"sources",
".",
"length",
";",
"const",
"layers",
"=",
"new",
"Array",
"(",
"len",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
... | Create layers for all sources.
@param {Array<import("./Source.js").default|import("../layer/Layer.js").default>} sources The sources.
@return {Array<import("../layer/Layer.js").default>} Array of layers. | [
"Create",
"layers",
"for",
"all",
"sources",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/source/Raster.js#L488-L495 |
1,209 | openlayers/openlayers | src/ol/source/Raster.js | createLayer | function createLayer(layerOrSource) {
// @type {import("../layer/Layer.js").default}
let layer;
if (layerOrSource instanceof Source) {
if (layerOrSource instanceof TileSource) {
layer = new TileLayer({source: layerOrSource});
} else if (layerOrSource instanceof ImageSource) {
layer = new Image... | javascript | function createLayer(layerOrSource) {
// @type {import("../layer/Layer.js").default}
let layer;
if (layerOrSource instanceof Source) {
if (layerOrSource instanceof TileSource) {
layer = new TileLayer({source: layerOrSource});
} else if (layerOrSource instanceof ImageSource) {
layer = new Image... | [
"function",
"createLayer",
"(",
"layerOrSource",
")",
"{",
"// @type {import(\"../layer/Layer.js\").default}",
"let",
"layer",
";",
"if",
"(",
"layerOrSource",
"instanceof",
"Source",
")",
"{",
"if",
"(",
"layerOrSource",
"instanceof",
"TileSource",
")",
"{",
"layer",... | Create a layer for the provided source.
@param {import("./Source.js").default|import("../layer/Layer.js").default} layerOrSource The layer or source.
@return {import("../layer/Layer.js").default} The layer. | [
"Create",
"a",
"layer",
"for",
"the",
"provided",
"source",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/source/Raster.js#L503-L516 |
1,210 | openlayers/openlayers | src/ol/render/canvas/ExecutorGroup.js | fillCircleArrayRowToMiddle | function fillCircleArrayRowToMiddle(array, x, y) {
let i;
const radius = Math.floor(array.length / 2);
if (x >= radius) {
for (i = radius; i < x; i++) {
array[i][y] = true;
}
} else if (x < radius) {
for (i = x + 1; i < radius; i++) {
array[i][y] = true;
}
}
} | javascript | function fillCircleArrayRowToMiddle(array, x, y) {
let i;
const radius = Math.floor(array.length / 2);
if (x >= radius) {
for (i = radius; i < x; i++) {
array[i][y] = true;
}
} else if (x < radius) {
for (i = x + 1; i < radius; i++) {
array[i][y] = true;
}
}
} | [
"function",
"fillCircleArrayRowToMiddle",
"(",
"array",
",",
"x",
",",
"y",
")",
"{",
"let",
"i",
";",
"const",
"radius",
"=",
"Math",
".",
"floor",
"(",
"array",
".",
"length",
"/",
"2",
")",
";",
"if",
"(",
"x",
">=",
"radius",
")",
"{",
"for",
... | This method fills a row in the array from the given coordinate to the
middle with `true`.
@param {Array<Array<(boolean|undefined)>>} array The array that will be altered.
@param {number} x X coordinate.
@param {number} y Y coordinate. | [
"This",
"method",
"fills",
"a",
"row",
"in",
"the",
"array",
"from",
"the",
"given",
"coordinate",
"to",
"the",
"middle",
"with",
"true",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/render/canvas/ExecutorGroup.js#L361-L373 |
1,211 | openlayers/openlayers | src/ol/format/TopoJSON.js | concatenateArcs | function concatenateArcs(indices, arcs) {
/** @type {Array<import("../coordinate.js").Coordinate>} */
const coordinates = [];
let index, arc;
for (let i = 0, ii = indices.length; i < ii; ++i) {
index = indices[i];
if (i > 0) {
// splicing together arcs, discard last point
coordinates.pop();
... | javascript | function concatenateArcs(indices, arcs) {
/** @type {Array<import("../coordinate.js").Coordinate>} */
const coordinates = [];
let index, arc;
for (let i = 0, ii = indices.length; i < ii; ++i) {
index = indices[i];
if (i > 0) {
// splicing together arcs, discard last point
coordinates.pop();
... | [
"function",
"concatenateArcs",
"(",
"indices",
",",
"arcs",
")",
"{",
"/** @type {Array<import(\"../coordinate.js\").Coordinate>} */",
"const",
"coordinates",
"=",
"[",
"]",
";",
"let",
"index",
",",
"arc",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"="... | Concatenate arcs into a coordinate array.
@param {Array<number>} indices Indices of arcs to concatenate. Negative
values indicate arcs need to be reversed.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs (already
transformed).
@return {Array<import("../coordinate.js").Coordinate>} Coord... | [
"Concatenate",
"arcs",
"into",
"a",
"coordinate",
"array",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L162-L186 |
1,212 | openlayers/openlayers | src/ol/format/TopoJSON.js | readPointGeometry | function readPointGeometry(object, scale, translate) {
const coordinates = object['coordinates'];
if (scale && translate) {
transformVertex(coordinates, scale, translate);
}
return new Point(coordinates);
} | javascript | function readPointGeometry(object, scale, translate) {
const coordinates = object['coordinates'];
if (scale && translate) {
transformVertex(coordinates, scale, translate);
}
return new Point(coordinates);
} | [
"function",
"readPointGeometry",
"(",
"object",
",",
"scale",
",",
"translate",
")",
"{",
"const",
"coordinates",
"=",
"object",
"[",
"'coordinates'",
"]",
";",
"if",
"(",
"scale",
"&&",
"translate",
")",
"{",
"transformVertex",
"(",
"coordinates",
",",
"sca... | Create a point from a TopoJSON geometry object.
@param {TopoJSONPoint} object TopoJSON object.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension.
@return {Point} Geometry. | [
"Create",
"a",
"point",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L197-L203 |
1,213 | openlayers/openlayers | src/ol/format/TopoJSON.js | readMultiPointGeometry | function readMultiPointGeometry(object, scale, translate) {
const coordinates = object['coordinates'];
if (scale && translate) {
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
transformVertex(coordinates[i], scale, translate);
}
}
return new MultiPoint(coordinates);
} | javascript | function readMultiPointGeometry(object, scale, translate) {
const coordinates = object['coordinates'];
if (scale && translate) {
for (let i = 0, ii = coordinates.length; i < ii; ++i) {
transformVertex(coordinates[i], scale, translate);
}
}
return new MultiPoint(coordinates);
} | [
"function",
"readMultiPointGeometry",
"(",
"object",
",",
"scale",
",",
"translate",
")",
"{",
"const",
"coordinates",
"=",
"object",
"[",
"'coordinates'",
"]",
";",
"if",
"(",
"scale",
"&&",
"translate",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
... | Create a multi-point from a TopoJSON geometry object.
@param {TopoJSONMultiPoint} object TopoJSON object.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension.
@return {MultiPoint} Geometry. | [
"Create",
"a",
"multi",
"-",
"point",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L214-L222 |
1,214 | openlayers/openlayers | src/ol/format/TopoJSON.js | readMultiLineStringGeometry | function readMultiLineStringGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new MultiLineString(coordinates);
} | javascript | function readMultiLineStringGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new MultiLineString(coordinates);
} | [
"function",
"readMultiLineStringGeometry",
"(",
"object",
",",
"arcs",
")",
"{",
"const",
"coordinates",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"object",
"[",
"'arcs'",
"]",
".",
"length",
";",
"i",
"<",
"ii",
";",
"+... | Create a multi-linestring from a TopoJSON geometry object.
@param {TopoJSONMultiLineString} object TopoJSON object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@return {MultiLineString} Geometry. | [
"Create",
"a",
"multi",
"-",
"linestring",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L245-L251 |
1,215 | openlayers/openlayers | src/ol/format/TopoJSON.js | readPolygonGeometry | function readPolygonGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new Polygon(coordinates);
} | javascript | function readPolygonGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
coordinates[i] = concatenateArcs(object['arcs'][i], arcs);
}
return new Polygon(coordinates);
} | [
"function",
"readPolygonGeometry",
"(",
"object",
",",
"arcs",
")",
"{",
"const",
"coordinates",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"object",
"[",
"'arcs'",
"]",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",
"i... | Create a polygon from a TopoJSON geometry object.
@param {TopoJSONPolygon} object TopoJSON object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@return {Polygon} Geometry. | [
"Create",
"a",
"polygon",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L261-L267 |
1,216 | openlayers/openlayers | src/ol/format/TopoJSON.js | readMultiPolygonGeometry | function readMultiPolygonGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
// for each polygon
const polyArray = object['arcs'][i];
const ringCoords = [];
for (let j = 0, jj = polyArray.length; j < jj; ++j) {
// for each ring
ring... | javascript | function readMultiPolygonGeometry(object, arcs) {
const coordinates = [];
for (let i = 0, ii = object['arcs'].length; i < ii; ++i) {
// for each polygon
const polyArray = object['arcs'][i];
const ringCoords = [];
for (let j = 0, jj = polyArray.length; j < jj; ++j) {
// for each ring
ring... | [
"function",
"readMultiPolygonGeometry",
"(",
"object",
",",
"arcs",
")",
"{",
"const",
"coordinates",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"object",
"[",
"'arcs'",
"]",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",... | Create a multi-polygon from a TopoJSON geometry object.
@param {TopoJSONMultiPolygon} object TopoJSON object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@return {MultiPolygon} Geometry. | [
"Create",
"a",
"multi",
"-",
"polygon",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L277-L290 |
1,217 | openlayers/openlayers | src/ol/format/TopoJSON.js | readFeaturesFromGeometryCollection | function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
const geometries = collection['geometries'];
const features = [];
for (let i = 0, ii = geometries.length; i < ii; ++i) {
features[i] = readFeatureFromGeometry(
geometries[i], arcs, scale, trans... | javascript | function readFeaturesFromGeometryCollection(collection, arcs, scale, translate, property, name, opt_options) {
const geometries = collection['geometries'];
const features = [];
for (let i = 0, ii = geometries.length; i < ii; ++i) {
features[i] = readFeatureFromGeometry(
geometries[i], arcs, scale, trans... | [
"function",
"readFeaturesFromGeometryCollection",
"(",
"collection",
",",
"arcs",
",",
"scale",
",",
"translate",
",",
"property",
",",
"name",
",",
"opt_options",
")",
"{",
"const",
"geometries",
"=",
"collection",
"[",
"'geometries'",
"]",
";",
"const",
"featu... | Create features from a TopoJSON GeometryCollection object.
@param {TopoJSONGeometryCollection} collection TopoJSON Geometry
object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for ea... | [
"Create",
"features",
"from",
"a",
"TopoJSON",
"GeometryCollection",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L307-L315 |
1,218 | openlayers/openlayers | src/ol/format/TopoJSON.js | readFeatureFromGeometry | function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
let geometry;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate);
} else {
geom... | javascript | function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
let geometry;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate);
} else {
geom... | [
"function",
"readFeatureFromGeometry",
"(",
"object",
",",
"arcs",
",",
"scale",
",",
"translate",
",",
"property",
",",
"name",
",",
"opt_options",
")",
"{",
"let",
"geometry",
";",
"const",
"type",
"=",
"object",
".",
"type",
";",
"const",
"geometryReader"... | Create a feature from a TopoJSON geometry object.
@param {TopoJSONGeometry} object TopoJSON geometry object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension.
@param {s... | [
"Create",
"a",
"feature",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L331-L356 |
1,219 | openlayers/openlayers | src/ol/format/TopoJSON.js | transformArcs | function transformArcs(arcs, scale, translate) {
for (let i = 0, ii = arcs.length; i < ii; ++i) {
transformArc(arcs[i], scale, translate);
}
} | javascript | function transformArcs(arcs, scale, translate) {
for (let i = 0, ii = arcs.length; i < ii; ++i) {
transformArc(arcs[i], scale, translate);
}
} | [
"function",
"transformArcs",
"(",
"arcs",
",",
"scale",
",",
"translate",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"arcs",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",
"i",
")",
"{",
"transformArc",
"(",
"arcs",
"[",
"i",
"... | Apply a linear transform to array of arcs. The provided array of arcs is
modified in place.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension. | [
"Apply",
"a",
"linear",
"transform",
"to",
"array",
"of",
"arcs",
".",
"The",
"provided",
"array",
"of",
"arcs",
"is",
"modified",
"in",
"place",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L367-L371 |
1,220 | openlayers/openlayers | src/ol/format/TopoJSON.js | transformArc | function transformArc(arc, scale, translate) {
let x = 0;
let y = 0;
for (let i = 0, ii = arc.length; i < ii; ++i) {
const vertex = arc[i];
x += vertex[0];
y += vertex[1];
vertex[0] = x;
vertex[1] = y;
transformVertex(vertex, scale, translate);
}
} | javascript | function transformArc(arc, scale, translate) {
let x = 0;
let y = 0;
for (let i = 0, ii = arc.length; i < ii; ++i) {
const vertex = arc[i];
x += vertex[0];
y += vertex[1];
vertex[0] = x;
vertex[1] = y;
transformVertex(vertex, scale, translate);
}
} | [
"function",
"transformArc",
"(",
"arc",
",",
"scale",
",",
"translate",
")",
"{",
"let",
"x",
"=",
"0",
";",
"let",
"y",
"=",
"0",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"arc",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",
... | Apply a linear transform to an arc. The provided arc is modified in place.
@param {Array<import("../coordinate.js").Coordinate>} arc Arc.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension. | [
"Apply",
"a",
"linear",
"transform",
"to",
"an",
"arc",
".",
"The",
"provided",
"arc",
"is",
"modified",
"in",
"place",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L381-L392 |
1,221 | openlayers/openlayers | src/ol/format/TopoJSON.js | transformVertex | function transformVertex(vertex, scale, translate) {
vertex[0] = vertex[0] * scale[0] + translate[0];
vertex[1] = vertex[1] * scale[1] + translate[1];
} | javascript | function transformVertex(vertex, scale, translate) {
vertex[0] = vertex[0] * scale[0] + translate[0];
vertex[1] = vertex[1] * scale[1] + translate[1];
} | [
"function",
"transformVertex",
"(",
"vertex",
",",
"scale",
",",
"translate",
")",
"{",
"vertex",
"[",
"0",
"]",
"=",
"vertex",
"[",
"0",
"]",
"*",
"scale",
"[",
"0",
"]",
"+",
"translate",
"[",
"0",
"]",
";",
"vertex",
"[",
"1",
"]",
"=",
"verte... | Apply a linear transform to a vertex. The provided vertex is modified in
place.
@param {import("../coordinate.js").Coordinate} vertex Vertex.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension. | [
"Apply",
"a",
"linear",
"transform",
"to",
"a",
"vertex",
".",
"The",
"provided",
"vertex",
"is",
"modified",
"in",
"place",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L403-L406 |
1,222 | openlayers/openlayers | src/ol/pointer/TouchSource.js | touchstart | function touchstart(inEvent) {
this.vacuumTouches_(inEvent);
this.setPrimaryTouch_(inEvent.changedTouches[0]);
this.dedupSynthMouse_(inEvent);
this.clickCount_++;
this.processTouches_(inEvent, this.overDown_);
} | javascript | function touchstart(inEvent) {
this.vacuumTouches_(inEvent);
this.setPrimaryTouch_(inEvent.changedTouches[0]);
this.dedupSynthMouse_(inEvent);
this.clickCount_++;
this.processTouches_(inEvent, this.overDown_);
} | [
"function",
"touchstart",
"(",
"inEvent",
")",
"{",
"this",
".",
"vacuumTouches_",
"(",
"inEvent",
")",
";",
"this",
".",
"setPrimaryTouch_",
"(",
"inEvent",
".",
"changedTouches",
"[",
"0",
"]",
")",
";",
"this",
".",
"dedupSynthMouse_",
"(",
"inEvent",
"... | Handler for `touchstart`, triggers `pointerover`,
`pointerenter` and `pointerdown` events.
@this {TouchSource}
@param {TouchEvent} inEvent The in event. | [
"Handler",
"for",
"touchstart",
"triggers",
"pointerover",
"pointerenter",
"and",
"pointerdown",
"events",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/TouchSource.js#L57-L63 |
1,223 | openlayers/openlayers | examples/mapbox-vector-tiles-advanced.js | tileUrlFunction | function tileUrlFunction(tileCoord) {
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
.replace('{z}', String(tileCoord[0] * 2 - 1))
.replace('{x}', String(tileCoord[1]))
.replace('{y}', String(tileCoord[2]))
.replace('{a-d}', ... | javascript | function tileUrlFunction(tileCoord) {
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
.replace('{z}', String(tileCoord[0] * 2 - 1))
.replace('{x}', String(tileCoord[1]))
.replace('{y}', String(tileCoord[2]))
.replace('{a-d}', ... | [
"function",
"tileUrlFunction",
"(",
"tileCoord",
")",
"{",
"return",
"(",
"'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/'",
"+",
"'{z}/{x}/{y}.vector.pbf?access_token='",
"+",
"key",
")",
".",
"replace",
"(",
"'{z}'",
",",
"String",
"(",
"tileCoord",
"[",
... | Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15. | [
"Calculation",
"of",
"tile",
"urls",
"for",
"zoom",
"levels",
"1",
"3",
"5",
"7",
"9",
"11",
"13",
"15",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/mapbox-vector-tiles-advanced.js#L19-L27 |
1,224 | openlayers/openlayers | config/jsdoc/api/plugins/inline-options.js | function(e) {
if (e.doclet.kind == 'typedef' && e.doclet.properties) {
properties[e.doclet.longname] = e.doclet.properties;
}
} | javascript | function(e) {
if (e.doclet.kind == 'typedef' && e.doclet.properties) {
properties[e.doclet.longname] = e.doclet.properties;
}
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"doclet",
".",
"kind",
"==",
"'typedef'",
"&&",
"e",
".",
"doclet",
".",
"properties",
")",
"{",
"properties",
"[",
"e",
".",
"doclet",
".",
"longname",
"]",
"=",
"e",
".",
"doclet",
".",
"prop... | Collects all typedefs, keyed by longname
@param {Object} e Event object. | [
"Collects",
"all",
"typedefs",
"keyed",
"by",
"longname"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/config/jsdoc/api/plugins/inline-options.js#L14-L18 | |
1,225 | openlayers/openlayers | tasks/generate-info.js | getBinaryPath | function getBinaryPath(binaryName) {
if (isWindows) {
binaryName += '.cmd';
}
const jsdocResolved = require.resolve('jsdoc/jsdoc.js');
const expectedPaths = [
path.join(__dirname, '..', 'node_modules', '.bin', binaryName),
path.resolve(path.join(path.dirname(jsdocResolved), '..', '.bin', binaryName... | javascript | function getBinaryPath(binaryName) {
if (isWindows) {
binaryName += '.cmd';
}
const jsdocResolved = require.resolve('jsdoc/jsdoc.js');
const expectedPaths = [
path.join(__dirname, '..', 'node_modules', '.bin', binaryName),
path.resolve(path.join(path.dirname(jsdocResolved), '..', '.bin', binaryName... | [
"function",
"getBinaryPath",
"(",
"binaryName",
")",
"{",
"if",
"(",
"isWindows",
")",
"{",
"binaryName",
"+=",
"'.cmd'",
";",
"}",
"const",
"jsdocResolved",
"=",
"require",
".",
"resolve",
"(",
"'jsdoc/jsdoc.js'",
")",
";",
"const",
"expectedPaths",
"=",
"[... | Get checked path of a binary.
@param {string} binaryName Binary name of the binary path to find.
@return {string} Path. | [
"Get",
"checked",
"path",
"of",
"a",
"binary",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-info.js#L15-L34 |
1,226 | openlayers/openlayers | tasks/generate-info.js | getPaths | function getPaths() {
return new Promise((resolve, reject) => {
let paths = [];
const walker = walk(sourceDir);
walker.on('file', (root, stats, next) => {
const sourcePath = path.join(root, stats.name);
if (/\.js$/.test(sourcePath)) {
paths.push(sourcePath);
}
next();
... | javascript | function getPaths() {
return new Promise((resolve, reject) => {
let paths = [];
const walker = walk(sourceDir);
walker.on('file', (root, stats, next) => {
const sourcePath = path.join(root, stats.name);
if (/\.js$/.test(sourcePath)) {
paths.push(sourcePath);
}
next();
... | [
"function",
"getPaths",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"paths",
"=",
"[",
"]",
";",
"const",
"walker",
"=",
"walk",
"(",
"sourceDir",
")",
";",
"walker",
".",
"on",
"(",
"'file'... | Generate a list of all .js paths in the source directory.
@return {Promise<Array>} Resolves to an array of source paths. | [
"Generate",
"a",
"list",
"of",
"all",
".",
"js",
"paths",
"in",
"the",
"source",
"directory",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-info.js#L46-L76 |
1,227 | openlayers/openlayers | tasks/generate-info.js | parseOutput | function parseOutput(output) {
if (!output) {
throw new Error('Expected JSON output');
}
let info;
try {
info = JSON.parse(String(output));
} catch (err) {
throw new Error('Failed to parse output as JSON: ' + output);
}
if (!Array.isArray(info.symbols)) {
throw new Error('Expected symbols... | javascript | function parseOutput(output) {
if (!output) {
throw new Error('Expected JSON output');
}
let info;
try {
info = JSON.parse(String(output));
} catch (err) {
throw new Error('Failed to parse output as JSON: ' + output);
}
if (!Array.isArray(info.symbols)) {
throw new Error('Expected symbols... | [
"function",
"parseOutput",
"(",
"output",
")",
"{",
"if",
"(",
"!",
"output",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected JSON output'",
")",
";",
"}",
"let",
"info",
";",
"try",
"{",
"info",
"=",
"JSON",
".",
"parse",
"(",
"String",
"(",
"out... | Parse the JSDoc output.
@param {string} output JSDoc output
@return {Object} Symbol and define info. | [
"Parse",
"the",
"JSDoc",
"output",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-info.js#L84-L103 |
1,228 | openlayers/openlayers | tasks/generate-info.js | spawnJSDoc | function spawnJSDoc(paths) {
return new Promise((resolve, reject) => {
let output = '';
let errors = '';
const cwd = path.join(__dirname, '..');
const child = spawn(jsdoc, ['-c', jsdocConfig].concat(paths), {cwd: cwd});
child.stdout.on('data', data => {
output += String(data);
});
... | javascript | function spawnJSDoc(paths) {
return new Promise((resolve, reject) => {
let output = '';
let errors = '';
const cwd = path.join(__dirname, '..');
const child = spawn(jsdoc, ['-c', jsdocConfig].concat(paths), {cwd: cwd});
child.stdout.on('data', data => {
output += String(data);
});
... | [
"function",
"spawnJSDoc",
"(",
"paths",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"output",
"=",
"''",
";",
"let",
"errors",
"=",
"''",
";",
"const",
"cwd",
"=",
"path",
".",
"join",
"(",
"__di... | Spawn JSDoc.
@param {Array<string>} paths Paths to source files.
@return {Promise<string>} Resolves with the JSDoc output (new metadata).
If provided with an empty list of paths, resolves with null. | [
"Spawn",
"JSDoc",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-info.js#L112-L143 |
1,229 | openlayers/openlayers | src/ol/pointer/MouseSource.js | mousedown | function mousedown(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091
if (POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
const e = prepareEvent(inEvent, this.dispatcher);
... | javascript | function mousedown(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091
if (POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
const e = prepareEvent(inEvent, this.dispatcher);
... | [
"function",
"mousedown",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"// TODO(dfreedman) workaround for some elements not sending mouseup",
"// http://crbug/149091",
"if",
"(",
"POINTER_ID",
".",
"t... | Handler for `mousedown`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mousedown",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L63-L74 |
1,230 | openlayers/openlayers | src/ol/pointer/MouseSource.js | mousemove | function mousemove(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.move(e, inEvent);
}
} | javascript | function mousemove(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.move(e, inEvent);
}
} | [
"function",
"mousemove",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"const",
"e",
"=",
"prepareEvent",
"(",
"inEvent",
",",
"this",
".",
"dispatcher",
")",
";",
"this",
".",
"dispat... | Handler for `mousemove`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mousemove",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L82-L87 |
1,231 | openlayers/openlayers | src/ol/pointer/MouseSource.js | mouseup | function mouseup(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const p = this.pointerMap[POINTER_ID.toString()];
if (p && p.button === inEvent.button) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.up(e, inEvent);
this.cleanupMouse();
}
}
} | javascript | function mouseup(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const p = this.pointerMap[POINTER_ID.toString()];
if (p && p.button === inEvent.button) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.up(e, inEvent);
this.cleanupMouse();
}
}
} | [
"function",
"mouseup",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"const",
"p",
"=",
"this",
".",
"pointerMap",
"[",
"POINTER_ID",
".",
"toString",
"(",
")",
"]",
";",
"if",
"(",
... | Handler for `mouseup`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mouseup",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L95-L105 |
1,232 | openlayers/openlayers | src/ol/pointer/MouseSource.js | mouseover | function mouseover(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
} | javascript | function mouseover(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
} | [
"function",
"mouseover",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"const",
"e",
"=",
"prepareEvent",
"(",
"inEvent",
",",
"this",
".",
"dispatcher",
")",
";",
"this",
".",
"dispat... | Handler for `mouseover`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mouseover",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L113-L118 |
1,233 | openlayers/openlayers | src/ol/pointer/MouseSource.js | mouseout | function mouseout(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.leaveOut(e, inEvent);
}
} | javascript | function mouseout(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.leaveOut(e, inEvent);
}
} | [
"function",
"mouseout",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"const",
"e",
"=",
"prepareEvent",
"(",
"inEvent",
",",
"this",
".",
"dispatcher",
")",
";",
"this",
".",
"dispatc... | Handler for `mouseout`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mouseout",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L126-L131 |
1,234 | openlayers/openlayers | src/ol/interaction/Extent.js | function(point) {
let x_ = null;
let y_ = null;
if (point[0] == extent[0]) {
x_ = extent[2];
} else if (point[0] == extent[2]) {
x_ = extent[0];
}
if (point[1] == extent[1]) {
y_ = extent[3];
} else if (point[1] == extent[3]) {
y_ = extent[1];
... | javascript | function(point) {
let x_ = null;
let y_ = null;
if (point[0] == extent[0]) {
x_ = extent[2];
} else if (point[0] == extent[2]) {
x_ = extent[0];
}
if (point[1] == extent[1]) {
y_ = extent[3];
} else if (point[1] == extent[3]) {
y_ = extent[1];
... | [
"function",
"(",
"point",
")",
"{",
"let",
"x_",
"=",
"null",
";",
"let",
"y_",
"=",
"null",
";",
"if",
"(",
"point",
"[",
"0",
"]",
"==",
"extent",
"[",
"0",
"]",
")",
"{",
"x_",
"=",
"extent",
"[",
"2",
"]",
";",
"}",
"else",
"if",
"(",
... | find the extent corner opposite the passed corner | [
"find",
"the",
"extent",
"corner",
"opposite",
"the",
"passed",
"corner"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Extent.js#L302-L319 | |
1,235 | openlayers/openlayers | src/ol/color.js | fromNamed | function fromNamed(color) {
const el = document.createElement('div');
el.style.color = color;
if (el.style.color !== '') {
document.body.appendChild(el);
const rgb = getComputedStyle(el).color;
document.body.removeChild(el);
return rgb;
} else {
return '';
}
} | javascript | function fromNamed(color) {
const el = document.createElement('div');
el.style.color = color;
if (el.style.color !== '') {
document.body.appendChild(el);
const rgb = getComputedStyle(el).color;
document.body.removeChild(el);
return rgb;
} else {
return '';
}
} | [
"function",
"fromNamed",
"(",
"color",
")",
"{",
"const",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"el",
".",
"style",
".",
"color",
"=",
"color",
";",
"if",
"(",
"el",
".",
"style",
".",
"color",
"!==",
"''",
")",
"{",
... | Return named color as an rgba string.
@param {string} color Named color.
@return {string} Rgb string. | [
"Return",
"named",
"color",
"as",
"an",
"rgba",
"string",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/color.js#L55-L66 |
1,236 | openlayers/openlayers | tasks/generate-index.js | getSymbols | async function getSymbols() {
const info = await generateInfo();
return info.symbols.filter(symbol => symbol.kind != 'member');
} | javascript | async function getSymbols() {
const info = await generateInfo();
return info.symbols.filter(symbol => symbol.kind != 'member');
} | [
"async",
"function",
"getSymbols",
"(",
")",
"{",
"const",
"info",
"=",
"await",
"generateInfo",
"(",
")",
";",
"return",
"info",
".",
"symbols",
".",
"filter",
"(",
"symbol",
"=>",
"symbol",
".",
"kind",
"!=",
"'member'",
")",
";",
"}"
] | Read the symbols from info file.
@return {Promise<Array>} Resolves with an array of symbol objects. | [
"Read",
"the",
"symbols",
"from",
"info",
"file",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L10-L13 |
1,237 | openlayers/openlayers | tasks/generate-index.js | getImport | function getImport(symbol, member) {
const defaultExport = symbol.name.split('~');
const namedExport = symbol.name.split('.');
if (defaultExport.length > 1) {
const from = defaultExport[0].replace(/^module\:/, './');
const importName = from.replace(/[.\/]+/g, '$');
return `import ${importName} from '$... | javascript | function getImport(symbol, member) {
const defaultExport = symbol.name.split('~');
const namedExport = symbol.name.split('.');
if (defaultExport.length > 1) {
const from = defaultExport[0].replace(/^module\:/, './');
const importName = from.replace(/[.\/]+/g, '$');
return `import ${importName} from '$... | [
"function",
"getImport",
"(",
"symbol",
",",
"member",
")",
"{",
"const",
"defaultExport",
"=",
"symbol",
".",
"name",
".",
"split",
"(",
"'~'",
")",
";",
"const",
"namedExport",
"=",
"symbol",
".",
"name",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"... | Generate an import statement.
@param {Object} symbol Symbol.
@param {string} member Member.
@return {string} An import statement. | [
"Generate",
"an",
"import",
"statement",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L21-L33 |
1,238 | openlayers/openlayers | tasks/generate-index.js | formatSymbolExport | function formatSymbolExport(symbol, namespaces, imports) {
const name = symbol.name;
const parts = name.split('~');
const isNamed = parts[0].indexOf('.') !== -1;
const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
const last = nsParts.length - 1;
const importName = isNamed ?
'_' + nsParts... | javascript | function formatSymbolExport(symbol, namespaces, imports) {
const name = symbol.name;
const parts = name.split('~');
const isNamed = parts[0].indexOf('.') !== -1;
const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
const last = nsParts.length - 1;
const importName = isNamed ?
'_' + nsParts... | [
"function",
"formatSymbolExport",
"(",
"symbol",
",",
"namespaces",
",",
"imports",
")",
"{",
"const",
"name",
"=",
"symbol",
".",
"name",
";",
"const",
"parts",
"=",
"name",
".",
"split",
"(",
"'~'",
")",
";",
"const",
"isNamed",
"=",
"parts",
"[",
"0... | Generate code to export a named symbol.
@param {Object} symbol Symbol.
@param {Object<string, string>} namespaces Already defined namespaces.
@param {Object} imports Imports.
@return {string} Export code. | [
"Generate",
"code",
"to",
"export",
"a",
"named",
"symbol",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L43-L60 |
1,239 | openlayers/openlayers | tasks/generate-index.js | generateExports | function generateExports(symbols) {
const namespaces = {};
const imports = [];
let blocks = [];
symbols.forEach(function(symbol) {
const name = symbol.name;
if (name.indexOf('#') == -1) {
const imp = getImport(symbol);
if (imp) {
imports[getImport(symbol)] = true;
}
const... | javascript | function generateExports(symbols) {
const namespaces = {};
const imports = [];
let blocks = [];
symbols.forEach(function(symbol) {
const name = symbol.name;
if (name.indexOf('#') == -1) {
const imp = getImport(symbol);
if (imp) {
imports[getImport(symbol)] = true;
}
const... | [
"function",
"generateExports",
"(",
"symbols",
")",
"{",
"const",
"namespaces",
"=",
"{",
"}",
";",
"const",
"imports",
"=",
"[",
"]",
";",
"let",
"blocks",
"=",
"[",
"]",
";",
"symbols",
".",
"forEach",
"(",
"function",
"(",
"symbol",
")",
"{",
"con... | Generate export code given a list symbol names.
@param {Array<Object>} symbols List of symbols.
@param {Object<string, string>} namespaces Already defined namespaces.
@param {Array<string>} imports List of all imports.
@return {string} Export code. | [
"Generate",
"export",
"code",
"given",
"a",
"list",
"symbol",
"names",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L70-L97 |
1,240 | openlayers/openlayers | src/ol/control/FullScreen.js | requestFullScreen | function requestFullScreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
} | javascript | function requestFullScreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
} | [
"function",
"requestFullScreen",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"requestFullscreen",
")",
"{",
"element",
".",
"requestFullscreen",
"(",
")",
";",
"}",
"else",
"if",
"(",
"element",
".",
"msRequestFullscreen",
")",
"{",
"element",
".",
... | Request to fullscreen an element.
@param {HTMLElement} element Element to request fullscreen | [
"Request",
"to",
"fullscreen",
"an",
"element",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/control/FullScreen.js#L230-L238 |
1,241 | openlayers/openlayers | src/ol/control/FullScreen.js | exitFullScreen | function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
} | javascript | function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
} | [
"function",
"exitFullScreen",
"(",
")",
"{",
"if",
"(",
"document",
".",
"exitFullscreen",
")",
"{",
"document",
".",
"exitFullscreen",
"(",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"msExitFullscreen",
")",
"{",
"document",
".",
"msExitFullscreen",... | Exit fullscreen. | [
"Exit",
"fullscreen",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/control/FullScreen.js#L255-L263 |
1,242 | openlayers/openlayers | src/ol/format/MVT.js | layersPBFReader | function layersPBFReader(tag, layers, pbf) {
if (tag === 3) {
const layer = {
keys: [],
values: [],
features: []
};
const end = pbf.readVarint() + pbf.pos;
pbf.readFields(layerPBFReader, layer, end);
layer.length = layer.features.length;
if (layer.length) {
layers[layer... | javascript | function layersPBFReader(tag, layers, pbf) {
if (tag === 3) {
const layer = {
keys: [],
values: [],
features: []
};
const end = pbf.readVarint() + pbf.pos;
pbf.readFields(layerPBFReader, layer, end);
layer.length = layer.features.length;
if (layer.length) {
layers[layer... | [
"function",
"layersPBFReader",
"(",
"tag",
",",
"layers",
",",
"pbf",
")",
"{",
"if",
"(",
"tag",
"===",
"3",
")",
"{",
"const",
"layer",
"=",
"{",
"keys",
":",
"[",
"]",
",",
"values",
":",
"[",
"]",
",",
"features",
":",
"[",
"]",
"}",
";",
... | Reader callback for parsing layers.
@param {number} tag The tag.
@param {Object} layers The layers object.
@param {PBF} pbf The PBF. | [
"Reader",
"callback",
"for",
"parsing",
"layers",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/MVT.js#L290-L304 |
1,243 | openlayers/openlayers | src/ol/format/MVT.js | layerPBFReader | function layerPBFReader(tag, layer, pbf) {
if (tag === 15) {
layer.version = pbf.readVarint();
} else if (tag === 1) {
layer.name = pbf.readString();
} else if (tag === 5) {
layer.extent = pbf.readVarint();
} else if (tag === 2) {
layer.features.push(pbf.pos);
} else if (tag === 3) {
layer... | javascript | function layerPBFReader(tag, layer, pbf) {
if (tag === 15) {
layer.version = pbf.readVarint();
} else if (tag === 1) {
layer.name = pbf.readString();
} else if (tag === 5) {
layer.extent = pbf.readVarint();
} else if (tag === 2) {
layer.features.push(pbf.pos);
} else if (tag === 3) {
layer... | [
"function",
"layerPBFReader",
"(",
"tag",
",",
"layer",
",",
"pbf",
")",
"{",
"if",
"(",
"tag",
"===",
"15",
")",
"{",
"layer",
".",
"version",
"=",
"pbf",
".",
"readVarint",
"(",
")",
";",
"}",
"else",
"if",
"(",
"tag",
"===",
"1",
")",
"{",
"... | Reader callback for parsing layer.
@param {number} tag The tag.
@param {Object} layer The layer object.
@param {PBF} pbf The PBF. | [
"Reader",
"callback",
"for",
"parsing",
"layer",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/MVT.js#L312-L338 |
1,244 | openlayers/openlayers | src/ol/format/MVT.js | featurePBFReader | function featurePBFReader(tag, feature, pbf) {
if (tag == 1) {
feature.id = pbf.readVarint();
} else if (tag == 2) {
const end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
const key = feature.layer.keys[pbf.readVarint()];
const value = feature.layer.values[pbf.readVarint()];
f... | javascript | function featurePBFReader(tag, feature, pbf) {
if (tag == 1) {
feature.id = pbf.readVarint();
} else if (tag == 2) {
const end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
const key = feature.layer.keys[pbf.readVarint()];
const value = feature.layer.values[pbf.readVarint()];
f... | [
"function",
"featurePBFReader",
"(",
"tag",
",",
"feature",
",",
"pbf",
")",
"{",
"if",
"(",
"tag",
"==",
"1",
")",
"{",
"feature",
".",
"id",
"=",
"pbf",
".",
"readVarint",
"(",
")",
";",
"}",
"else",
"if",
"(",
"tag",
"==",
"2",
")",
"{",
"co... | Reader callback for parsing feature.
@param {number} tag The tag.
@param {Object} feature The feature object.
@param {PBF} pbf The PBF. | [
"Reader",
"callback",
"for",
"parsing",
"feature",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/MVT.js#L346-L361 |
1,245 | openlayers/openlayers | src/ol/format/MVT.js | readRawFeature | function readRawFeature(pbf, layer, i) {
pbf.pos = layer.features[i];
const end = pbf.readVarint() + pbf.pos;
const feature = {
layer: layer,
type: 0,
properties: {}
};
pbf.readFields(featurePBFReader, feature, end);
return feature;
} | javascript | function readRawFeature(pbf, layer, i) {
pbf.pos = layer.features[i];
const end = pbf.readVarint() + pbf.pos;
const feature = {
layer: layer,
type: 0,
properties: {}
};
pbf.readFields(featurePBFReader, feature, end);
return feature;
} | [
"function",
"readRawFeature",
"(",
"pbf",
",",
"layer",
",",
"i",
")",
"{",
"pbf",
".",
"pos",
"=",
"layer",
".",
"features",
"[",
"i",
"]",
";",
"const",
"end",
"=",
"pbf",
".",
"readVarint",
"(",
")",
"+",
"pbf",
".",
"pos",
";",
"const",
"feat... | Read a raw feature from the pbf offset stored at index `i` in the raw layer.
@param {PBF} pbf PBF.
@param {Object} layer Raw layer.
@param {number} i Index of the feature in the raw layer's `features` array.
@return {Object} Raw feature. | [
"Read",
"a",
"raw",
"feature",
"from",
"the",
"pbf",
"offset",
"stored",
"at",
"index",
"i",
"in",
"the",
"raw",
"layer",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/MVT.js#L371-L382 |
1,246 | openlayers/openlayers | examples/raster.js | summarize | function summarize(value, counts) {
const min = counts.min;
const max = counts.max;
const num = counts.values.length;
if (value < min) {
// do nothing
} else if (value >= max) {
counts.values[num - 1] += 1;
} else {
const index = Math.floor((value - min) / counts.delta);
counts.values[index]... | javascript | function summarize(value, counts) {
const min = counts.min;
const max = counts.max;
const num = counts.values.length;
if (value < min) {
// do nothing
} else if (value >= max) {
counts.values[num - 1] += 1;
} else {
const index = Math.floor((value - min) / counts.delta);
counts.values[index]... | [
"function",
"summarize",
"(",
"value",
",",
"counts",
")",
"{",
"const",
"min",
"=",
"counts",
".",
"min",
";",
"const",
"max",
"=",
"counts",
".",
"max",
";",
"const",
"num",
"=",
"counts",
".",
"values",
".",
"length",
";",
"if",
"(",
"value",
"<... | Summarize values for a histogram.
@param {numver} value A VGI value.
@param {Object} counts An object for keeping track of VGI counts. | [
"Summarize",
"values",
"for",
"a",
"histogram",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/raster.js#L31-L43 |
1,247 | openlayers/openlayers | examples/raster.js | function(pixels, data) {
const pixel = pixels[0];
const value = vgi(pixel);
summarize(value, data.counts);
if (value >= data.threshold) {
pixel[0] = 0;
pixel[1] = 255;
pixel[2] = 0;
pixel[3] = 128;
} else {
pixel[3] = 0;
}
return pixel;
} | javascript | function(pixels, data) {
const pixel = pixels[0];
const value = vgi(pixel);
summarize(value, data.counts);
if (value >= data.threshold) {
pixel[0] = 0;
pixel[1] = 255;
pixel[2] = 0;
pixel[3] = 128;
} else {
pixel[3] = 0;
}
return pixel;
} | [
"function",
"(",
"pixels",
",",
"data",
")",
"{",
"const",
"pixel",
"=",
"pixels",
"[",
"0",
"]",
";",
"const",
"value",
"=",
"vgi",
"(",
"pixel",
")",
";",
"summarize",
"(",
"value",
",",
"data",
".",
"counts",
")",
";",
"if",
"(",
"value",
">="... | Run calculations on pixel data.
@param {Array} pixels List of pixels (one per source).
@param {Object} data User data object.
@return {Array} The output pixel. | [
"Run",
"calculations",
"on",
"pixel",
"data",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/raster.js#L67-L80 | |
1,248 | openlayers/openlayers | src/ol/interaction/Draw.js | getMode | function getMode(type) {
let mode;
if (type === GeometryType.POINT ||
type === GeometryType.MULTI_POINT) {
mode = Mode.POINT;
} else if (type === GeometryType.LINE_STRING ||
type === GeometryType.MULTI_LINE_STRING) {
mode = Mode.LINE_STRING;
} else if (type === GeometryType.POLYGON ||
... | javascript | function getMode(type) {
let mode;
if (type === GeometryType.POINT ||
type === GeometryType.MULTI_POINT) {
mode = Mode.POINT;
} else if (type === GeometryType.LINE_STRING ||
type === GeometryType.MULTI_LINE_STRING) {
mode = Mode.LINE_STRING;
} else if (type === GeometryType.POLYGON ||
... | [
"function",
"getMode",
"(",
"type",
")",
"{",
"let",
"mode",
";",
"if",
"(",
"type",
"===",
"GeometryType",
".",
"POINT",
"||",
"type",
"===",
"GeometryType",
".",
"MULTI_POINT",
")",
"{",
"mode",
"=",
"Mode",
".",
"POINT",
";",
"}",
"else",
"if",
"(... | Get the drawing mode. The mode for mult-part geometries is the same as for
their single-part cousins.
@param {GeometryType} type Geometry type.
@return {Mode} Drawing mode. | [
"Get",
"the",
"drawing",
"mode",
".",
"The",
"mode",
"for",
"mult",
"-",
"part",
"geometries",
"is",
"the",
"same",
"as",
"for",
"their",
"single",
"-",
"part",
"cousins",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Draw.js#L1032-L1049 |
1,249 | openlayers/openlayers | src/ol/tilegrid.js | resolutionsFromExtent | function resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize) {
const maxZoom = opt_maxZoom !== undefined ?
opt_maxZoom : DEFAULT_MAX_ZOOM;
const height = getHeight(extent);
const width = getWidth(extent);
const tileSize = toSize(opt_tileSize !== undefined ?
opt_tileSize : DEFAULT_TILE_SIZE);
co... | javascript | function resolutionsFromExtent(extent, opt_maxZoom, opt_tileSize) {
const maxZoom = opt_maxZoom !== undefined ?
opt_maxZoom : DEFAULT_MAX_ZOOM;
const height = getHeight(extent);
const width = getWidth(extent);
const tileSize = toSize(opt_tileSize !== undefined ?
opt_tileSize : DEFAULT_TILE_SIZE);
co... | [
"function",
"resolutionsFromExtent",
"(",
"extent",
",",
"opt_maxZoom",
",",
"opt_tileSize",
")",
"{",
"const",
"maxZoom",
"=",
"opt_maxZoom",
"!==",
"undefined",
"?",
"opt_maxZoom",
":",
"DEFAULT_MAX_ZOOM",
";",
"const",
"height",
"=",
"getHeight",
"(",
"extent",... | Create a resolutions array from an extent. A zoom factor of 2 is assumed.
@param {import("./extent.js").Extent} extent Extent.
@param {number=} opt_maxZoom Maximum zoom level (default is
DEFAULT_MAX_ZOOM).
@param {number|import("./size.js").Size=} opt_tileSize Tile size (default uses
DEFAULT_TILE_SIZE).
@return {!Arra... | [
"Create",
"a",
"resolutions",
"array",
"from",
"an",
"extent",
".",
"A",
"zoom",
"factor",
"of",
"2",
"is",
"assumed",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/tilegrid.js#L120-L138 |
1,250 | openlayers/openlayers | src/ol/format/WKT.js | encode | function encode(geom) {
let type = geom.getType();
const geometryEncoder = GeometryEncoder[type];
const enc = geometryEncoder(geom);
type = type.toUpperCase();
if (typeof /** @type {?} */ (geom).getFlatCoordinates === 'function') {
const dimInfo = encodeGeometryLayout(/** @type {import("../geom/SimpleGeom... | javascript | function encode(geom) {
let type = geom.getType();
const geometryEncoder = GeometryEncoder[type];
const enc = geometryEncoder(geom);
type = type.toUpperCase();
if (typeof /** @type {?} */ (geom).getFlatCoordinates === 'function') {
const dimInfo = encodeGeometryLayout(/** @type {import("../geom/SimpleGeom... | [
"function",
"encode",
"(",
"geom",
")",
"{",
"let",
"type",
"=",
"geom",
".",
"getType",
"(",
")",
";",
"const",
"geometryEncoder",
"=",
"GeometryEncoder",
"[",
"type",
"]",
";",
"const",
"enc",
"=",
"geometryEncoder",
"(",
"geom",
")",
";",
"type",
"=... | Encode a geometry as WKT.
@param {!import("../geom/Geometry.js").default} geom The geometry to encode.
@return {string} WKT string for the geometry. | [
"Encode",
"a",
"geometry",
"as",
"WKT",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/WKT.js#L859-L874 |
1,251 | openlayers/openlayers | src/ol/reproj.js | enlargeClipPoint | function enlargeClipPoint(centroidX, centroidY, x, y) {
const dX = x - centroidX;
const dY = y - centroidY;
const distance = Math.sqrt(dX * dX + dY * dY);
return [Math.round(x + dX / distance), Math.round(y + dY / distance)];
} | javascript | function enlargeClipPoint(centroidX, centroidY, x, y) {
const dX = x - centroidX;
const dY = y - centroidY;
const distance = Math.sqrt(dX * dX + dY * dY);
return [Math.round(x + dX / distance), Math.round(y + dY / distance)];
} | [
"function",
"enlargeClipPoint",
"(",
"centroidX",
",",
"centroidY",
",",
"x",
",",
"y",
")",
"{",
"const",
"dX",
"=",
"x",
"-",
"centroidX",
";",
"const",
"dY",
"=",
"y",
"-",
"centroidY",
";",
"const",
"distance",
"=",
"Math",
".",
"sqrt",
"(",
"dX"... | Enlarge the clipping triangle point by 1 pixel to ensure the edges overlap
in order to mask gaps caused by antialiasing.
@param {number} centroidX Centroid of the triangle (x coordinate in pixels).
@param {number} centroidY Centroid of the triangle (y coordinate in pixels).
@param {number} x X coordinate of the point ... | [
"Enlarge",
"the",
"clipping",
"triangle",
"point",
"by",
"1",
"pixel",
"to",
"ensure",
"the",
"edges",
"overlap",
"in",
"order",
"to",
"mask",
"gaps",
"caused",
"by",
"antialiasing",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/reproj.js#L66-L71 |
1,252 | openlayers/openlayers | src/ol/interaction/Modify.js | pointDistanceToSegmentDataSquared | function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE) {
const circleGeometry = /** @type {import("../geom/Circle.js").default} */ (geometry);
if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {... | javascript | function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE) {
const circleGeometry = /** @type {import("../geom/Circle.js").default} */ (geometry);
if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {... | [
"function",
"pointDistanceToSegmentDataSquared",
"(",
"pointCoordinates",
",",
"segmentData",
")",
"{",
"const",
"geometry",
"=",
"segmentData",
".",
"geometry",
";",
"if",
"(",
"geometry",
".",
"getType",
"(",
")",
"===",
"GeometryType",
".",
"CIRCLE",
")",
"{"... | Returns the distance from a point to a line segment.
@param {import("../coordinate.js").Coordinate} pointCoordinates The coordinates of the point from
which to calculate the distance.
@param {SegmentData} segmentData The object describing the line
segment we are calculating the distance to.
@return {number} The square... | [
"Returns",
"the",
"distance",
"from",
"a",
"point",
"to",
"a",
"line",
"segment",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Modify.js#L1202-L1217 |
1,253 | openlayers/openlayers | src/ol/interaction/Modify.js | closestOnSegmentData | function closestOnSegmentData(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE &&
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
return geometry.getClosestPoint(pointCoordinates);
}
return closestOnSegment(pointCoordinates, segmen... | javascript | function closestOnSegmentData(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE &&
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
return geometry.getClosestPoint(pointCoordinates);
}
return closestOnSegment(pointCoordinates, segmen... | [
"function",
"closestOnSegmentData",
"(",
"pointCoordinates",
",",
"segmentData",
")",
"{",
"const",
"geometry",
"=",
"segmentData",
".",
"geometry",
";",
"if",
"(",
"geometry",
".",
"getType",
"(",
")",
"===",
"GeometryType",
".",
"CIRCLE",
"&&",
"segmentData",
... | Returns the point closest to a given line segment.
@param {import("../coordinate.js").Coordinate} pointCoordinates The point to which a closest point
should be found.
@param {SegmentData} segmentData The object describing the line
segment which should contain the closest point.
@return {import("../coordinate.js").Coor... | [
"Returns",
"the",
"point",
"closest",
"to",
"a",
"given",
"line",
"segment",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Modify.js#L1228-L1236 |
1,254 | openlayers/openlayers | examples/zoomslider.js | createMap | function createMap(divId) {
const source = new OSM();
const layer = new TileLayer({
source: source
});
const map = new Map({
layers: [layer],
target: divId,
view: new View({
center: [0, 0],
zoom: 2
})
});
const zoomslider = new ZoomSlider();
map.addControl(zoomslider);
re... | javascript | function createMap(divId) {
const source = new OSM();
const layer = new TileLayer({
source: source
});
const map = new Map({
layers: [layer],
target: divId,
view: new View({
center: [0, 0],
zoom: 2
})
});
const zoomslider = new ZoomSlider();
map.addControl(zoomslider);
re... | [
"function",
"createMap",
"(",
"divId",
")",
"{",
"const",
"source",
"=",
"new",
"OSM",
"(",
")",
";",
"const",
"layer",
"=",
"new",
"TileLayer",
"(",
"{",
"source",
":",
"source",
"}",
")",
";",
"const",
"map",
"=",
"new",
"Map",
"(",
"{",
"layers"... | Helper method for map-creation.
@param {string} divId The id of the div for the map.
@return {Map} The map instance. | [
"Helper",
"method",
"for",
"map",
"-",
"creation",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/zoomslider.js#L14-L30 |
1,255 | openlayers/openlayers | src/ol/interaction/Snap.js | sortByDistance | function sortByDistance(a, b) {
const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment);
const deltaB = squaredDistanceToSegment(this.pixelCoordinate_, b.segment);
return deltaA - deltaB;
} | javascript | function sortByDistance(a, b) {
const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment);
const deltaB = squaredDistanceToSegment(this.pixelCoordinate_, b.segment);
return deltaA - deltaB;
} | [
"function",
"sortByDistance",
"(",
"a",
",",
"b",
")",
"{",
"const",
"deltaA",
"=",
"squaredDistanceToSegment",
"(",
"this",
".",
"pixelCoordinate_",
",",
"a",
".",
"segment",
")",
";",
"const",
"deltaB",
"=",
"squaredDistanceToSegment",
"(",
"this",
".",
"p... | Sort segments by distance, helper function
@param {SegmentData} a The first segment data.
@param {SegmentData} b The second segment data.
@return {number} The difference in distance.
@this {Snap} | [
"Sort",
"segments",
"by",
"distance",
"helper",
"function"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Snap.js#L623-L627 |
1,256 | nfarina/homebridge | example-plugins/homebridge-samplePlatform/index.js | SamplePlatform | function SamplePlatform(log, config, api) {
log("SamplePlatform Init");
var platform = this;
this.log = log;
this.config = config;
this.accessories = [];
this.requestServer = http.createServer(function(request, response) {
if (request.url === "/add") {
this.addAccessory(new Date().toISOString());... | javascript | function SamplePlatform(log, config, api) {
log("SamplePlatform Init");
var platform = this;
this.log = log;
this.config = config;
this.accessories = [];
this.requestServer = http.createServer(function(request, response) {
if (request.url === "/add") {
this.addAccessory(new Date().toISOString());... | [
"function",
"SamplePlatform",
"(",
"log",
",",
"config",
",",
"api",
")",
"{",
"log",
"(",
"\"SamplePlatform Init\"",
")",
";",
"var",
"platform",
"=",
"this",
";",
"this",
".",
"log",
"=",
"log",
";",
"this",
".",
"config",
"=",
"config",
";",
"this",... | Platform constructor config may be null api may be null if launched from old homebridge version | [
"Platform",
"constructor",
"config",
"may",
"be",
"null",
"api",
"may",
"be",
"null",
"if",
"launched",
"from",
"old",
"homebridge",
"version"
] | 724125dc1b500dfd81048a30a1e3229ff122189a | https://github.com/nfarina/homebridge/blob/724125dc1b500dfd81048a30a1e3229ff122189a/example-plugins/homebridge-samplePlatform/index.js#L23-L65 |
1,257 | facebook/flow | packages/flow-upgrade/src/findFlowFiles.js | done | function done() {
// We don't care if we were rejected.
if (rejected === true) {
return;
}
// Decrement the number of async tasks we are waiting on.
waiting--;
// If we are finished waiting then we want to resolve our promise.
if (waiting <= 0) {
if (waiting ===... | javascript | function done() {
// We don't care if we were rejected.
if (rejected === true) {
return;
}
// Decrement the number of async tasks we are waiting on.
waiting--;
// If we are finished waiting then we want to resolve our promise.
if (waiting <= 0) {
if (waiting ===... | [
"function",
"done",
"(",
")",
"{",
"// We don't care if we were rejected.",
"if",
"(",
"rejected",
"===",
"true",
")",
"{",
"return",
";",
"}",
"// Decrement the number of async tasks we are waiting on.",
"waiting",
"--",
";",
"// If we are finished waiting then we want to re... | Our implementation of resolve that will only actually resolve if we are
done waiting everywhere. | [
"Our",
"implementation",
"of",
"resolve",
"that",
"will",
"only",
"actually",
"resolve",
"if",
"we",
"are",
"done",
"waiting",
"everywhere",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-upgrade/src/findFlowFiles.js#L161-L176 |
1,258 | facebook/flow | packages/flow-remove-types/index.js | isLastNodeRemovedFromLine | function isLastNodeRemovedFromLine(context, node) {
var tokens = context.ast.tokens;
var priorTokenIdx = findTokenIndex(tokens, startOf(node)) - 1;
var token = tokens[priorTokenIdx];
var line = node.loc.end.line;
// Find previous token that was not removed on the same line.
while (
priorTokenIdx >= 0 &... | javascript | function isLastNodeRemovedFromLine(context, node) {
var tokens = context.ast.tokens;
var priorTokenIdx = findTokenIndex(tokens, startOf(node)) - 1;
var token = tokens[priorTokenIdx];
var line = node.loc.end.line;
// Find previous token that was not removed on the same line.
while (
priorTokenIdx >= 0 &... | [
"function",
"isLastNodeRemovedFromLine",
"(",
"context",
",",
"node",
")",
"{",
"var",
"tokens",
"=",
"context",
".",
"ast",
".",
"tokens",
";",
"var",
"priorTokenIdx",
"=",
"findTokenIndex",
"(",
"tokens",
",",
"startOf",
"(",
"node",
")",
")",
"-",
"1",
... | Returns true if node is the last to be removed from a line. | [
"Returns",
"true",
"if",
"node",
"is",
"the",
"last",
"to",
"be",
"removed",
"from",
"a",
"line",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-remove-types/index.js#L409-L427 |
1,259 | facebook/flow | packages/flow-remove-types/index.js | visit | function visit(ast, context, visitor) {
var stack;
var parent;
var keys = [];
var index = -1;
do {
index++;
if (stack && index === keys.length) {
parent = stack.parent;
keys = stack.keys;
index = stack.index;
stack = stack.prev;
} else {
var node = parent ? parent[ke... | javascript | function visit(ast, context, visitor) {
var stack;
var parent;
var keys = [];
var index = -1;
do {
index++;
if (stack && index === keys.length) {
parent = stack.parent;
keys = stack.keys;
index = stack.index;
stack = stack.prev;
} else {
var node = parent ? parent[ke... | [
"function",
"visit",
"(",
"ast",
",",
"context",
",",
"visitor",
")",
"{",
"var",
"stack",
";",
"var",
"parent",
";",
"var",
"keys",
"=",
"[",
"]",
";",
"var",
"index",
"=",
"-",
"1",
";",
"do",
"{",
"index",
"++",
";",
"if",
"(",
"stack",
"&&"... | Given the AST output from the parser, walk through in a depth-first order, calling methods on the given visitor, providing context as the first argument. | [
"Given",
"the",
"AST",
"output",
"from",
"the",
"parser",
"walk",
"through",
"in",
"a",
"depth",
"-",
"first",
"order",
"calling",
"methods",
"on",
"the",
"given",
"visitor",
"providing",
"context",
"as",
"the",
"first",
"argument",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-remove-types/index.js#L461-L490 |
1,260 | facebook/flow | packages/flow-remove-types/index.js | space | function space(size) {
var sp = ' ';
var result = '';
for (;;) {
if ((size & 1) === 1) {
result += sp;
}
size >>>= 1;
if (size === 0) {
break;
}
sp += sp;
}
return result;
} | javascript | function space(size) {
var sp = ' ';
var result = '';
for (;;) {
if ((size & 1) === 1) {
result += sp;
}
size >>>= 1;
if (size === 0) {
break;
}
sp += sp;
}
return result;
} | [
"function",
"space",
"(",
"size",
")",
"{",
"var",
"sp",
"=",
"' '",
";",
"var",
"result",
"=",
"''",
";",
"for",
"(",
";",
";",
")",
"{",
"if",
"(",
"(",
"size",
"&",
"1",
")",
"===",
"1",
")",
"{",
"result",
"+=",
"sp",
";",
"}",
"size",
... | Produce a string full of space characters of a given size. | [
"Produce",
"a",
"string",
"full",
"of",
"space",
"characters",
"of",
"a",
"given",
"size",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-remove-types/index.js#L519-L534 |
1,261 | sass/node-sass | lib/index.js | getOutputFile | function getOutputFile(options) {
var outFile = options.outFile;
if (!outFile || typeof outFile !== 'string' || (!options.data && !options.file)) {
return null;
}
return path.resolve(outFile);
} | javascript | function getOutputFile(options) {
var outFile = options.outFile;
if (!outFile || typeof outFile !== 'string' || (!options.data && !options.file)) {
return null;
}
return path.resolve(outFile);
} | [
"function",
"getOutputFile",
"(",
"options",
")",
"{",
"var",
"outFile",
"=",
"options",
".",
"outFile",
";",
"if",
"(",
"!",
"outFile",
"||",
"typeof",
"outFile",
"!==",
"'string'",
"||",
"(",
"!",
"options",
".",
"data",
"&&",
"!",
"options",
".",
"f... | Get output file
@param {Object} options
@api private | [
"Get",
"output",
"file"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L34-L42 |
1,262 | sass/node-sass | lib/index.js | getSourceMap | function getSourceMap(options) {
var sourceMap = options.sourceMap;
if (sourceMap && typeof sourceMap !== 'string' && options.outFile) {
sourceMap = options.outFile + '.map';
}
return sourceMap && typeof sourceMap === 'string' ? path.resolve(sourceMap) : null;
} | javascript | function getSourceMap(options) {
var sourceMap = options.sourceMap;
if (sourceMap && typeof sourceMap !== 'string' && options.outFile) {
sourceMap = options.outFile + '.map';
}
return sourceMap && typeof sourceMap === 'string' ? path.resolve(sourceMap) : null;
} | [
"function",
"getSourceMap",
"(",
"options",
")",
"{",
"var",
"sourceMap",
"=",
"options",
".",
"sourceMap",
";",
"if",
"(",
"sourceMap",
"&&",
"typeof",
"sourceMap",
"!==",
"'string'",
"&&",
"options",
".",
"outFile",
")",
"{",
"sourceMap",
"=",
"options",
... | Get source map
@param {Object} options
@api private | [
"Get",
"source",
"map"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L51-L59 |
1,263 | sass/node-sass | lib/index.js | buildIncludePaths | function buildIncludePaths(options) {
options.includePaths = options.includePaths || [];
if (process.env.hasOwnProperty('SASS_PATH')) {
options.includePaths = options.includePaths.concat(
process.env.SASS_PATH.split(path.delimiter)
);
}
// Preserve the behaviour people have come to expect.
// ... | javascript | function buildIncludePaths(options) {
options.includePaths = options.includePaths || [];
if (process.env.hasOwnProperty('SASS_PATH')) {
options.includePaths = options.includePaths.concat(
process.env.SASS_PATH.split(path.delimiter)
);
}
// Preserve the behaviour people have come to expect.
// ... | [
"function",
"buildIncludePaths",
"(",
"options",
")",
"{",
"options",
".",
"includePaths",
"=",
"options",
".",
"includePaths",
"||",
"[",
"]",
";",
"if",
"(",
"process",
".",
"env",
".",
"hasOwnProperty",
"(",
"'SASS_PATH'",
")",
")",
"{",
"options",
".",... | Build an includePaths string
from the options.includePaths array and the SASS_PATH environment variable
@param {Object} options
@api private | [
"Build",
"an",
"includePaths",
"string",
"from",
"the",
"options",
".",
"includePaths",
"array",
"and",
"the",
"SASS_PATH",
"environment",
"variable"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L165-L180 |
1,264 | sass/node-sass | lib/index.js | tryCallback | function tryCallback(callback, args) {
try {
return callback.apply(this, args);
} catch (e) {
if (typeof e === 'string') {
return new binding.types.Error(e);
} else if (e instanceof Error) {
return new binding.types.Error(e.message);
} else {
return new binding.types.Error('An unex... | javascript | function tryCallback(callback, args) {
try {
return callback.apply(this, args);
} catch (e) {
if (typeof e === 'string') {
return new binding.types.Error(e);
} else if (e instanceof Error) {
return new binding.types.Error(e.message);
} else {
return new binding.types.Error('An unex... | [
"function",
"tryCallback",
"(",
"callback",
",",
"args",
")",
"{",
"try",
"{",
"return",
"callback",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"typeof",
"e",
"===",
"'string'",
")",
"{",
"return"... | Executes a callback and transforms any exception raised into a sass error
@param {Function} callback
@param {Array} arguments
@api private | [
"Executes",
"a",
"callback",
"and",
"transforms",
"any",
"exception",
"raised",
"into",
"a",
"sass",
"error"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L226-L238 |
1,265 | sass/node-sass | lib/extensions.js | getHumanEnvironment | function getHumanEnvironment(env) {
var binding = env.replace(/_binding\.node$/, ''),
parts = binding.split('-'),
platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]);
if (parts.length !== 3) {
return 'Unknown environment (' + bin... | javascript | function getHumanEnvironment(env) {
var binding = env.replace(/_binding\.node$/, ''),
parts = binding.split('-'),
platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]);
if (parts.length !== 3) {
return 'Unknown environment (' + bin... | [
"function",
"getHumanEnvironment",
"(",
"env",
")",
"{",
"var",
"binding",
"=",
"env",
".",
"replace",
"(",
"/",
"_binding\\.node$",
"/",
",",
"''",
")",
",",
"parts",
"=",
"binding",
".",
"split",
"(",
"'-'",
")",
",",
"platform",
"=",
"getHumanPlatform... | Get a human readable description of where node-sass is running to support
user error reporting when something goes wrong
@param {string} env - The name of the native bindings that is to be parsed
@return {string} A description of what os, architecture, and Node version
that is being run
@api public | [
"Get",
"a",
"human",
"readable",
"description",
"of",
"where",
"node",
"-",
"sass",
"is",
"running",
"to",
"support",
"user",
"error",
"reporting",
"when",
"something",
"goes",
"wrong"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L95-L121 |
1,266 | sass/node-sass | lib/extensions.js | isSupportedEnvironment | function isSupportedEnvironment(platform, arch, abi) {
return (
false !== getHumanPlatform(platform) &&
false !== getHumanArchitecture(arch) &&
false !== getHumanNodeVersion(abi)
);
} | javascript | function isSupportedEnvironment(platform, arch, abi) {
return (
false !== getHumanPlatform(platform) &&
false !== getHumanArchitecture(arch) &&
false !== getHumanNodeVersion(abi)
);
} | [
"function",
"isSupportedEnvironment",
"(",
"platform",
",",
"arch",
",",
"abi",
")",
"{",
"return",
"(",
"false",
"!==",
"getHumanPlatform",
"(",
"platform",
")",
"&&",
"false",
"!==",
"getHumanArchitecture",
"(",
"arch",
")",
"&&",
"false",
"!==",
"getHumanNo... | Check that an environment matches the whitelisted values or the current
environment if no parameters are passed
@param {string} platform - The name of the OS platform(darwin, win32, etc...)
@param {string} arch - The instruction set architecture of the Node environment
@param {string} abi - The Node Application Bin... | [
"Check",
"that",
"an",
"environment",
"matches",
"the",
"whitelisted",
"values",
"or",
"the",
"current",
"environment",
"if",
"no",
"parameters",
"are",
"passed"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L145-L151 |
1,267 | sass/node-sass | lib/extensions.js | getArgument | function getArgument(name, args) {
var flags = args || process.argv.slice(2),
index = flags.lastIndexOf(name);
if (index === -1 || index + 1 >= flags.length) {
return null;
}
return flags[index + 1];
} | javascript | function getArgument(name, args) {
var flags = args || process.argv.slice(2),
index = flags.lastIndexOf(name);
if (index === -1 || index + 1 >= flags.length) {
return null;
}
return flags[index + 1];
} | [
"function",
"getArgument",
"(",
"name",
",",
"args",
")",
"{",
"var",
"flags",
"=",
"args",
"||",
"process",
".",
"argv",
".",
"slice",
"(",
"2",
")",
",",
"index",
"=",
"flags",
".",
"lastIndexOf",
"(",
"name",
")",
";",
"if",
"(",
"index",
"===",... | Get the value of a CLI argument
@param {String} name
@param {Array} args
@api private | [
"Get",
"the",
"value",
"of",
"a",
"CLI",
"argument"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L161-L170 |
1,268 | sass/node-sass | lib/extensions.js | getBinaryUrl | function getBinaryUrl() {
var site = getArgument('--sass-binary-site') ||
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';
r... | javascript | function getBinaryUrl() {
var site = getArgument('--sass-binary-site') ||
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';
r... | [
"function",
"getBinaryUrl",
"(",
")",
"{",
"var",
"site",
"=",
"getArgument",
"(",
"'--sass-binary-site'",
")",
"||",
"process",
".",
"env",
".",
"SASS_BINARY_SITE",
"||",
"process",
".",
"env",
".",
"npm_config_sass_binary_site",
"||",
"(",
"pkg",
".",
"nodeS... | Determine the URL to fetch binary file from.
By default fetch from the node-sass distribution
site on GitHub.
The default URL can be overriden using
the environment variable SASS_BINARY_SITE,
.npmrc variable sass_binary_site or
or a command line option --sass-binary-site:
node scripts/install.js --sass-binary-site ht... | [
"Determine",
"the",
"URL",
"to",
"fetch",
"binary",
"file",
"from",
".",
"By",
"default",
"fetch",
"from",
"the",
"node",
"-",
"sass",
"distribution",
"site",
"on",
"GitHub",
"."
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L240-L248 |
1,269 | sass/node-sass | lib/extensions.js | getBinaryCachePath | function getBinaryCachePath() {
var i,
cachePath,
cachePathCandidates = getCachePathCandidates();
for (i = 0; i < cachePathCandidates.length; i++) {
cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version);
try {
mkdir.sync(cachePath);
return cachePath;
} catch (e) {
... | javascript | function getBinaryCachePath() {
var i,
cachePath,
cachePathCandidates = getCachePathCandidates();
for (i = 0; i < cachePathCandidates.length; i++) {
cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version);
try {
mkdir.sync(cachePath);
return cachePath;
} catch (e) {
... | [
"function",
"getBinaryCachePath",
"(",
")",
"{",
"var",
"i",
",",
"cachePath",
",",
"cachePathCandidates",
"=",
"getCachePathCandidates",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"cachePathCandidates",
".",
"length",
";",
"i",
"++",
")",
... | The most suitable location for caching the binding on disk.
Given the candidates directories provided by `getCachePathCandidates()` this
returns the first writable directory. By treating the candidate directories
as a prioritised list this method is deterministic, assuming no change to the
local environment.
@return ... | [
"The",
"most",
"suitable",
"location",
"for",
"caching",
"the",
"binding",
"on",
"disk",
"."
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L346-L363 |
1,270 | sass/node-sass | lib/extensions.js | getCachedBinary | function getCachedBinary() {
var i,
cachePath,
cacheBinary,
cachePathCandidates = getCachePathCandidates(),
binaryName = getBinaryName();
for (i = 0; i < cachePathCandidates.length; i++) {
cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version);
cacheBinary = path.join(cachePat... | javascript | function getCachedBinary() {
var i,
cachePath,
cacheBinary,
cachePathCandidates = getCachePathCandidates(),
binaryName = getBinaryName();
for (i = 0; i < cachePathCandidates.length; i++) {
cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version);
cacheBinary = path.join(cachePat... | [
"function",
"getCachedBinary",
"(",
")",
"{",
"var",
"i",
",",
"cachePath",
",",
"cacheBinary",
",",
"cachePathCandidates",
"=",
"getCachePathCandidates",
"(",
")",
",",
"binaryName",
"=",
"getBinaryName",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i"... | The cached binding
Check the candidates directories provided by `getCachePathCandidates()` for
the binding file, if it exists. By treating the candidate directories
as a prioritised list this method is deterministic, assuming no change to the
local environment.
@return {String} path to cached binary
@api public | [
"The",
"cached",
"binding"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L376-L393 |
1,271 | sass/node-sass | lib/extensions.js | getVersionInfo | function getVersionInfo(binding) {
return [
['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
} | javascript | function getVersionInfo(binding) {
return [
['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
} | [
"function",
"getVersionInfo",
"(",
"binding",
")",
"{",
"return",
"[",
"[",
"'node-sass'",
",",
"pkg",
".",
"version",
",",
"'(Wrapper)'",
",",
"'[JavaScript]'",
"]",
".",
"join",
"(",
"'\\t'",
")",
",",
"[",
"'libsass '",
",",
"binding",
".",
"libsassVer... | Get Sass version information
@api public | [
"Get",
"Sass",
"version",
"information"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L412-L417 |
1,272 | netlify/netlify-cms | packages/netlify-cms-backend-github/src/implementation.js | isPreviewContext | function isPreviewContext(context, previewContext) {
if (previewContext) {
return context === previewContext;
}
return PREVIEW_CONTEXT_KEYWORDS.some(keyword => context.includes(keyword));
} | javascript | function isPreviewContext(context, previewContext) {
if (previewContext) {
return context === previewContext;
}
return PREVIEW_CONTEXT_KEYWORDS.some(keyword => context.includes(keyword));
} | [
"function",
"isPreviewContext",
"(",
"context",
",",
"previewContext",
")",
"{",
"if",
"(",
"previewContext",
")",
"{",
"return",
"context",
"===",
"previewContext",
";",
"}",
"return",
"PREVIEW_CONTEXT_KEYWORDS",
".",
"some",
"(",
"keyword",
"=>",
"context",
".... | Check a given status context string to determine if it provides a link to a
deploy preview. Checks for an exact match against `previewContext` if given,
otherwise checks for inclusion of a value from `PREVIEW_CONTEXT_KEYWORDS`. | [
"Check",
"a",
"given",
"status",
"context",
"string",
"to",
"determine",
"if",
"it",
"provides",
"a",
"link",
"to",
"a",
"deploy",
"preview",
".",
"Checks",
"for",
"an",
"exact",
"match",
"against",
"previewContext",
"if",
"given",
"otherwise",
"checks",
"fo... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-backend-github/src/implementation.js#L19-L24 |
1,273 | netlify/netlify-cms | packages/netlify-cms-backend-github/src/implementation.js | getPreviewStatus | function getPreviewStatus(statuses, config) {
const previewContext = config.getIn(['backend', 'preview_context']);
return statuses.find(({ context }) => {
return isPreviewContext(context, previewContext);
});
} | javascript | function getPreviewStatus(statuses, config) {
const previewContext = config.getIn(['backend', 'preview_context']);
return statuses.find(({ context }) => {
return isPreviewContext(context, previewContext);
});
} | [
"function",
"getPreviewStatus",
"(",
"statuses",
",",
"config",
")",
"{",
"const",
"previewContext",
"=",
"config",
".",
"getIn",
"(",
"[",
"'backend'",
",",
"'preview_context'",
"]",
")",
";",
"return",
"statuses",
".",
"find",
"(",
"(",
"{",
"context",
"... | Retrieve a deploy preview URL from an array of statuses. By default, a
matching status is inferred via `isPreviewContext`. | [
"Retrieve",
"a",
"deploy",
"preview",
"URL",
"from",
"an",
"array",
"of",
"statuses",
".",
"By",
"default",
"a",
"matching",
"status",
"is",
"inferred",
"via",
"isPreviewContext",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-backend-github/src/implementation.js#L30-L35 |
1,274 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js | createBlock | function createBlock(type, nodes, props = {}) {
if (!isArray(nodes)) {
props = nodes;
nodes = undefined;
}
const node = { object: 'block', type, ...props };
return addNodes(node, nodes);
} | javascript | function createBlock(type, nodes, props = {}) {
if (!isArray(nodes)) {
props = nodes;
nodes = undefined;
}
const node = { object: 'block', type, ...props };
return addNodes(node, nodes);
} | [
"function",
"createBlock",
"(",
"type",
",",
"nodes",
",",
"props",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"isArray",
"(",
"nodes",
")",
")",
"{",
"props",
"=",
"nodes",
";",
"nodes",
"=",
"undefined",
";",
"}",
"const",
"node",
"=",
"{",
"obje... | Create a Slate Inline node. | [
"Create",
"a",
"Slate",
"Inline",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js#L68-L76 |
1,275 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js | createInline | function createInline(type, props = {}, nodes) {
const node = { object: 'inline', type, ...props };
return addNodes(node, nodes);
} | javascript | function createInline(type, props = {}, nodes) {
const node = { object: 'inline', type, ...props };
return addNodes(node, nodes);
} | [
"function",
"createInline",
"(",
"type",
",",
"props",
"=",
"{",
"}",
",",
"nodes",
")",
"{",
"const",
"node",
"=",
"{",
"object",
":",
"'inline'",
",",
"type",
",",
"...",
"props",
"}",
";",
"return",
"addNodes",
"(",
"node",
",",
"nodes",
")",
";... | Create a Slate Block node. | [
"Create",
"a",
"Slate",
"Block",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js#L81-L84 |
1,276 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js | createText | function createText(value, data) {
const node = { object: 'text', data };
const leaves = isArray(value) ? value : [{ text: value }];
return { ...node, leaves };
} | javascript | function createText(value, data) {
const node = { object: 'text', data };
const leaves = isArray(value) ? value : [{ text: value }];
return { ...node, leaves };
} | [
"function",
"createText",
"(",
"value",
",",
"data",
")",
"{",
"const",
"node",
"=",
"{",
"object",
":",
"'text'",
",",
"data",
"}",
";",
"const",
"leaves",
"=",
"isArray",
"(",
"value",
")",
"?",
"value",
":",
"[",
"{",
"text",
":",
"value",
"}",
... | Create a Slate Raw text node. | [
"Create",
"a",
"Slate",
"Raw",
"text",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js#L89-L93 |
1,277 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js | convertNode | function convertNode(node, nodes) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'listItem':
case 'blockquote':
case 'tableRow':
case 'tabl... | javascript | function convertNode(node, nodes) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'listItem':
case 'blockquote':
case 'tableRow':
case 'tabl... | [
"function",
"convertNode",
"(",
"node",
",",
"nodes",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"/**\n * General\n *\n * Convert simple cases that only require a type and children, with no\n * additional properties.\n */",
"case",
"'root'",
":",
... | Convert a single MDAST node to a Slate Raw node. Uses local node factories
that mimic the unist-builder function utilized in the slateRemark
transformer. | [
"Convert",
"a",
"single",
"MDAST",
"node",
"to",
"a",
"Slate",
"Raw",
"node",
".",
"Uses",
"local",
"node",
"factories",
"that",
"mimic",
"the",
"unist",
"-",
"builder",
"function",
"utilized",
"in",
"the",
"slateRemark",
"transformer",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/remarkSlate.js#L171-L342 |
1,278 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/index.js | markdownToRemarkRemoveTokenizers | function markdownToRemarkRemoveTokenizers({ inlineTokenizers }) {
inlineTokenizers &&
inlineTokenizers.forEach(tokenizer => {
delete this.Parser.prototype.inlineTokenizers[tokenizer];
});
} | javascript | function markdownToRemarkRemoveTokenizers({ inlineTokenizers }) {
inlineTokenizers &&
inlineTokenizers.forEach(tokenizer => {
delete this.Parser.prototype.inlineTokenizers[tokenizer];
});
} | [
"function",
"markdownToRemarkRemoveTokenizers",
"(",
"{",
"inlineTokenizers",
"}",
")",
"{",
"inlineTokenizers",
"&&",
"inlineTokenizers",
".",
"forEach",
"(",
"tokenizer",
"=>",
"{",
"delete",
"this",
".",
"Parser",
".",
"prototype",
".",
"inlineTokenizers",
"[",
... | Remove named tokenizers from the parser, effectively deactivating them. | [
"Remove",
"named",
"tokenizers",
"from",
"the",
"parser",
"effectively",
"deactivating",
"them",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/index.js#L85-L90 |
1,279 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/index.js | remarkAllowAllText | function remarkAllowAllText() {
const Compiler = this.Compiler;
const visitors = Compiler.prototype.visitors;
visitors.text = node => node.value;
} | javascript | function remarkAllowAllText() {
const Compiler = this.Compiler;
const visitors = Compiler.prototype.visitors;
visitors.text = node => node.value;
} | [
"function",
"remarkAllowAllText",
"(",
")",
"{",
"const",
"Compiler",
"=",
"this",
".",
"Compiler",
";",
"const",
"visitors",
"=",
"Compiler",
".",
"prototype",
".",
"visitors",
";",
"visitors",
".",
"text",
"=",
"node",
"=>",
"node",
".",
"value",
";",
... | Rewrite the remark-stringify text visitor to simply return the text value,
without encoding or escaping any characters. This means we're completely
trusting the markdown that we receive. | [
"Rewrite",
"the",
"remark",
"-",
"stringify",
"text",
"visitor",
"to",
"simply",
"return",
"the",
"text",
"value",
"without",
"encoding",
"or",
"escaping",
"any",
"characters",
".",
"This",
"means",
"we",
"re",
"completely",
"trusting",
"the",
"markdown",
"tha... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/index.js#L101-L105 |
1,280 | netlify/netlify-cms | packages/netlify-cms-core/src/bootstrap.js | getRoot | function getRoot() {
/**
* Return existing root if found.
*/
const existingRoot = document.getElementById(ROOT_ID);
if (existingRoot) {
return existingRoot;
}
/**
* If no existing root, create and return a new root.
*/
const newRoot = document.createElement('div');
... | javascript | function getRoot() {
/**
* Return existing root if found.
*/
const existingRoot = document.getElementById(ROOT_ID);
if (existingRoot) {
return existingRoot;
}
/**
* If no existing root, create and return a new root.
*/
const newRoot = document.createElement('div');
... | [
"function",
"getRoot",
"(",
")",
"{",
"/**\n * Return existing root if found.\n */",
"const",
"existingRoot",
"=",
"document",
".",
"getElementById",
"(",
"ROOT_ID",
")",
";",
"if",
"(",
"existingRoot",
")",
"{",
"return",
"existingRoot",
";",
"}",
"/**\n ... | Get DOM element where app will mount. | [
"Get",
"DOM",
"element",
"where",
"app",
"will",
"mount",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-core/src/bootstrap.js#L33-L49 |
1,281 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | transform | function transform(node) {
/**
* Combine adjacent text and inline nodes before processing so they can
* share marks.
*/
const combinedChildren = node.nodes && combineTextAndInline(node.nodes);
/**
* Call `transform` recursively on child nodes, and flatten the resulting
* array.
*/
const child... | javascript | function transform(node) {
/**
* Combine adjacent text and inline nodes before processing so they can
* share marks.
*/
const combinedChildren = node.nodes && combineTextAndInline(node.nodes);
/**
* Call `transform` recursively on child nodes, and flatten the resulting
* array.
*/
const child... | [
"function",
"transform",
"(",
"node",
")",
"{",
"/**\n * Combine adjacent text and inline nodes before processing so they can\n * share marks.\n */",
"const",
"combinedChildren",
"=",
"node",
".",
"nodes",
"&&",
"combineTextAndInline",
"(",
"node",
".",
"nodes",
")",
";... | The transform function mimics the approach of a Remark plugin for
conformity with the other serialization functions. This function converts
Slate nodes to MDAST nodes, and recursively calls itself to process child
nodes to arbitrary depth. | [
"The",
"transform",
"function",
"mimics",
"the",
"approach",
"of",
"a",
"Remark",
"plugin",
"for",
"conformity",
"with",
"the",
"other",
"serialization",
"functions",
".",
"This",
"function",
"converts",
"Slate",
"nodes",
"to",
"MDAST",
"nodes",
"and",
"recursiv... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L57-L74 |
1,282 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | combineTextAndInline | function combineTextAndInline(nodes) {
return nodes.reduce((acc, node) => {
const prevNode = last(acc);
const prevNodeLeaves = get(prevNode, 'leaves');
const data = node.data || {};
/**
* If the previous node has leaves and the current node has marks in data
* (only happens when we place th... | javascript | function combineTextAndInline(nodes) {
return nodes.reduce((acc, node) => {
const prevNode = last(acc);
const prevNodeLeaves = get(prevNode, 'leaves');
const data = node.data || {};
/**
* If the previous node has leaves and the current node has marks in data
* (only happens when we place th... | [
"function",
"combineTextAndInline",
"(",
"nodes",
")",
"{",
"return",
"nodes",
".",
"reduce",
"(",
"(",
"acc",
",",
"node",
")",
"=>",
"{",
"const",
"prevNode",
"=",
"last",
"(",
"acc",
")",
";",
"const",
"prevNodeLeaves",
"=",
"get",
"(",
"prevNode",
... | Includes inline nodes as leaves in adjacent text nodes where appropriate, so
that mark node combining logic can apply to both text and inline nodes. This
is necessary because Slate doesn't allow inline nodes to have marks while
inline nodes in MDAST may be nested within mark nodes. Treating them as if
they were text is... | [
"Includes",
"inline",
"nodes",
"as",
"leaves",
"in",
"adjacent",
"text",
"nodes",
"where",
"appropriate",
"so",
"that",
"mark",
"node",
"combining",
"logic",
"can",
"apply",
"to",
"both",
"text",
"and",
"inline",
"nodes",
".",
"This",
"is",
"necessary",
"bec... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L83-L130 |
1,283 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | processCodeMark | function processCodeMark(markTypes) {
const isInlineCode = markTypes.includes('inlineCode');
const filteredMarkTypes = isInlineCode ? without(markTypes, 'inlineCode') : markTypes;
const textNodeType = isInlineCode ? 'inlineCode' : 'html';
return { filteredMarkTypes, textNodeType };
} | javascript | function processCodeMark(markTypes) {
const isInlineCode = markTypes.includes('inlineCode');
const filteredMarkTypes = isInlineCode ? without(markTypes, 'inlineCode') : markTypes;
const textNodeType = isInlineCode ? 'inlineCode' : 'html';
return { filteredMarkTypes, textNodeType };
} | [
"function",
"processCodeMark",
"(",
"markTypes",
")",
"{",
"const",
"isInlineCode",
"=",
"markTypes",
".",
"includes",
"(",
"'inlineCode'",
")",
";",
"const",
"filteredMarkTypes",
"=",
"isInlineCode",
"?",
"without",
"(",
"markTypes",
",",
"'inlineCode'",
")",
"... | Slate treats inline code decoration as a standard mark, but MDAST does
not allow inline code nodes to contain children, only a single text
value. An MDAST inline code node can be nested within mark nodes such
as "emphasis" and "strong", but it cannot contain them.
Because of this, if a "code" mark (translated to MDAST... | [
"Slate",
"treats",
"inline",
"code",
"decoration",
"as",
"a",
"standard",
"mark",
"but",
"MDAST",
"does",
"not",
"allow",
"inline",
"code",
"nodes",
"to",
"contain",
"children",
"only",
"a",
"single",
"text",
"value",
".",
"An",
"MDAST",
"inline",
"code",
... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L142-L147 |
1,284 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | convertTextNode | function convertTextNode(node) {
/**
* If the Slate text node has a "leaves" property, translate the Slate AST to
* a nested MDAST structure. Otherwise, just return an equivalent MDAST text
* node.
*/
if (node.leaves) {
const processedLeaves = node.leaves.map(processLeaves);
// Compensate for Sl... | javascript | function convertTextNode(node) {
/**
* If the Slate text node has a "leaves" property, translate the Slate AST to
* a nested MDAST structure. Otherwise, just return an equivalent MDAST text
* node.
*/
if (node.leaves) {
const processedLeaves = node.leaves.map(processLeaves);
// Compensate for Sl... | [
"function",
"convertTextNode",
"(",
"node",
")",
"{",
"/**\n * If the Slate text node has a \"leaves\" property, translate the Slate AST to\n * a nested MDAST structure. Otherwise, just return an equivalent MDAST text\n * node.\n */",
"if",
"(",
"node",
".",
"leaves",
")",
"{",
"... | Converts a Slate Raw text node to an MDAST text node.
Slate text nodes without marks often simply have a "text" property with
the value. In this case the conversion to MDAST is simple. If a Slate
text node does not have a "text" property, it will instead have a
"leaves" property containing an array of objects, each wi... | [
"Converts",
"a",
"Slate",
"Raw",
"text",
"node",
"to",
"an",
"MDAST",
"text",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L204-L263 |
1,285 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | processLeaves | function processLeaves(leaf) {
/**
* Get an array of the mark types, converted to their MDAST equivalent
* types.
*/
const { marks = [], text } = leaf;
const markTypes = marks.map(mark => markMap[mark.type]);
if (typeof leaf.text === 'string') {
/**
* Code marks must be removed from the marks... | javascript | function processLeaves(leaf) {
/**
* Get an array of the mark types, converted to their MDAST equivalent
* types.
*/
const { marks = [], text } = leaf;
const markTypes = marks.map(mark => markMap[mark.type]);
if (typeof leaf.text === 'string') {
/**
* Code marks must be removed from the marks... | [
"function",
"processLeaves",
"(",
"leaf",
")",
"{",
"/**\n * Get an array of the mark types, converted to their MDAST equivalent\n * types.\n */",
"const",
"{",
"marks",
"=",
"[",
"]",
",",
"text",
"}",
"=",
"leaf",
";",
"const",
"markTypes",
"=",
"marks",
".",
... | Process Slate node leaves in preparation for MDAST transformation. | [
"Process",
"Slate",
"node",
"leaves",
"in",
"preparation",
"for",
"MDAST",
"transformation",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L268-L286 |
1,286 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | getMarkLength | function getMarkLength(markType, nodes) {
let length = 0;
while (nodes[length] && nodes[length].marks.includes(markType)) {
++length;
}
return { markType, length };
} | javascript | function getMarkLength(markType, nodes) {
let length = 0;
while (nodes[length] && nodes[length].marks.includes(markType)) {
++length;
}
return { markType, length };
} | [
"function",
"getMarkLength",
"(",
"markType",
",",
"nodes",
")",
"{",
"let",
"length",
"=",
"0",
";",
"while",
"(",
"nodes",
"[",
"length",
"]",
"&&",
"nodes",
"[",
"length",
"]",
".",
"marks",
".",
"includes",
"(",
"markType",
")",
")",
"{",
"++",
... | Get the number of consecutive Slate nodes containing a given mark beginning
from the first received node. | [
"Get",
"the",
"number",
"of",
"consecutive",
"Slate",
"nodes",
"containing",
"a",
"given",
"mark",
"beginning",
"from",
"the",
"first",
"received",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L373-L379 |
1,287 | netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | convertNode | function convertNode(node, children) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'quote':
case 'list-item':
case 'table':
case 'table-ro... | javascript | function convertNode(node, children) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'quote':
case 'list-item':
case 'table':
case 'table-ro... | [
"function",
"convertNode",
"(",
"node",
",",
"children",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"/**\n * General\n *\n * Convert simple cases that only require a type and children, with no\n * additional properties.\n */",
"case",
"'root'",
":... | Convert a single Slate Raw node to an MDAST node. Uses the unist-builder `u`
function to create MDAST nodes. | [
"Convert",
"a",
"single",
"Slate",
"Raw",
"node",
"to",
"an",
"MDAST",
"node",
".",
"Uses",
"the",
"unist",
"-",
"builder",
"u",
"function",
"to",
"create",
"MDAST",
"nodes",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L385-L510 |
1,288 | netlify/netlify-cms | packages/netlify-cms-core/src/lib/stringTemplate.js | getExplicitFieldReplacement | function getExplicitFieldReplacement(key, data) {
if (!key.startsWith(FIELD_PREFIX)) {
return;
}
const fieldName = key.substring(FIELD_PREFIX.length);
return data.get(fieldName, '');
} | javascript | function getExplicitFieldReplacement(key, data) {
if (!key.startsWith(FIELD_PREFIX)) {
return;
}
const fieldName = key.substring(FIELD_PREFIX.length);
return data.get(fieldName, '');
} | [
"function",
"getExplicitFieldReplacement",
"(",
"key",
",",
"data",
")",
"{",
"if",
"(",
"!",
"key",
".",
"startsWith",
"(",
"FIELD_PREFIX",
")",
")",
"{",
"return",
";",
"}",
"const",
"fieldName",
"=",
"key",
".",
"substring",
"(",
"FIELD_PREFIX",
".",
... | Allow `fields.` prefix in placeholder to override built in replacements like "slug" and "year" with values from fields of the same name. | [
"Allow",
"fields",
".",
"prefix",
"in",
"placeholder",
"to",
"override",
"built",
"in",
"replacements",
"like",
"slug",
"and",
"year",
"with",
"values",
"from",
"fields",
"of",
"the",
"same",
"name",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-core/src/lib/stringTemplate.js#L26-L32 |
1,289 | netlify/netlify-cms | packages/netlify-cms-media-library-uploadcare/src/index.js | isFileGroup | function isFileGroup(files) {
const basePatternString = `~${files.length}/nth/`;
const mapExpression = (val, idx) => new RegExp(`${basePatternString}${idx}/$`);
const expressions = Array.from({ length: files.length }, mapExpression);
return expressions.every(exp => files.some(url => exp.test(url)));
} | javascript | function isFileGroup(files) {
const basePatternString = `~${files.length}/nth/`;
const mapExpression = (val, idx) => new RegExp(`${basePatternString}${idx}/$`);
const expressions = Array.from({ length: files.length }, mapExpression);
return expressions.every(exp => files.some(url => exp.test(url)));
} | [
"function",
"isFileGroup",
"(",
"files",
")",
"{",
"const",
"basePatternString",
"=",
"`",
"${",
"files",
".",
"length",
"}",
"`",
";",
"const",
"mapExpression",
"=",
"(",
"val",
",",
"idx",
")",
"=>",
"new",
"RegExp",
"(",
"`",
"${",
"basePatternString"... | Determine whether an array of urls represents an unaltered set of Uploadcare
group urls. If they've been changed or any are missing, a new group will need
to be created to represent the current values. | [
"Determine",
"whether",
"an",
"array",
"of",
"urls",
"represents",
"an",
"unaltered",
"set",
"of",
"Uploadcare",
"group",
"urls",
".",
"If",
"they",
"ve",
"been",
"changed",
"or",
"any",
"are",
"missing",
"a",
"new",
"group",
"will",
"need",
"to",
"be",
... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-media-library-uploadcare/src/index.js#L24-L29 |
1,290 | netlify/netlify-cms | packages/netlify-cms-media-library-uploadcare/src/index.js | getFileGroup | function getFileGroup(files) {
/**
* Capture the group id from the first file in the files array.
*/
const groupId = new RegExp(`^.+/([^/]+~${files.length})/nth/`).exec(files[0])[1];
/**
* The `openDialog` method handles the jQuery promise object returned by
* `fileFrom`, but requires the promise ret... | javascript | function getFileGroup(files) {
/**
* Capture the group id from the first file in the files array.
*/
const groupId = new RegExp(`^.+/([^/]+~${files.length})/nth/`).exec(files[0])[1];
/**
* The `openDialog` method handles the jQuery promise object returned by
* `fileFrom`, but requires the promise ret... | [
"function",
"getFileGroup",
"(",
"files",
")",
"{",
"/**\n * Capture the group id from the first file in the files array.\n */",
"const",
"groupId",
"=",
"new",
"RegExp",
"(",
"`",
"${",
"files",
".",
"length",
"}",
"`",
")",
".",
"exec",
"(",
"files",
"[",
"0... | Returns a fileGroupInfo object wrapped in a promise-like object. | [
"Returns",
"a",
"fileGroupInfo",
"object",
"wrapped",
"in",
"a",
"promise",
"-",
"like",
"object",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-media-library-uploadcare/src/index.js#L34-L46 |
1,291 | netlify/netlify-cms | packages/netlify-cms-media-library-uploadcare/src/index.js | openDialog | function openDialog(files, config, handleInsert) {
uploadcare.openDialog(files, config).done(({ promise }) =>
promise().then(({ cdnUrl, count }) => {
if (config.multiple) {
const urls = Array.from({ length: count }, (val, idx) => `${cdnUrl}nth/${idx}/`);
handleInsert(urls);
} else {
... | javascript | function openDialog(files, config, handleInsert) {
uploadcare.openDialog(files, config).done(({ promise }) =>
promise().then(({ cdnUrl, count }) => {
if (config.multiple) {
const urls = Array.from({ length: count }, (val, idx) => `${cdnUrl}nth/${idx}/`);
handleInsert(urls);
} else {
... | [
"function",
"openDialog",
"(",
"files",
",",
"config",
",",
"handleInsert",
")",
"{",
"uploadcare",
".",
"openDialog",
"(",
"files",
",",
"config",
")",
".",
"done",
"(",
"(",
"{",
"promise",
"}",
")",
"=>",
"promise",
"(",
")",
".",
"then",
"(",
"("... | Open the standalone dialog. A single instance is created and destroyed for
each use. | [
"Open",
"the",
"standalone",
"dialog",
".",
"A",
"single",
"instance",
"is",
"created",
"and",
"destroyed",
"for",
"each",
"use",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-media-library-uploadcare/src/index.js#L76-L87 |
1,292 | netlify/netlify-cms | packages/netlify-cms-media-library-uploadcare/src/index.js | init | async function init({ options = { config: {} }, handleInsert } = {}) {
const { publicKey, ...globalConfig } = options.config;
const baseConfig = { ...defaultConfig, ...globalConfig };
window.UPLOADCARE_PUBLIC_KEY = publicKey;
/**
* Register the effects tab by default because the effects tab is awesome. Can... | javascript | async function init({ options = { config: {} }, handleInsert } = {}) {
const { publicKey, ...globalConfig } = options.config;
const baseConfig = { ...defaultConfig, ...globalConfig };
window.UPLOADCARE_PUBLIC_KEY = publicKey;
/**
* Register the effects tab by default because the effects tab is awesome. Can... | [
"async",
"function",
"init",
"(",
"{",
"options",
"=",
"{",
"config",
":",
"{",
"}",
"}",
",",
"handleInsert",
"}",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"publicKey",
",",
"...",
"globalConfig",
"}",
"=",
"options",
".",
"config",
";",
"const",
"b... | Initialization function will only run once, returns an API object for Netlify
CMS to call methods on. | [
"Initialization",
"function",
"will",
"only",
"run",
"once",
"returns",
"an",
"API",
"object",
"for",
"Netlify",
"CMS",
"to",
"call",
"methods",
"on",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-media-library-uploadcare/src/index.js#L93-L135 |
1,293 | BrainJS/brain.js | dist/recurrent/matrix/all-ones.js | allOnes | function allOnes(product) {
for (var i = 0; i < product.weights.length; i++) {
product.weights[i] = 1;
product.deltas[i] = 0;
}
} | javascript | function allOnes(product) {
for (var i = 0; i < product.weights.length; i++) {
product.weights[i] = 1;
product.deltas[i] = 0;
}
} | [
"function",
"allOnes",
"(",
"product",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"product",
".",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"product",
".",
"weights",
"[",
"i",
"]",
"=",
"1",
";",
"product",
".",
"delt... | makes matrix weights and deltas all ones
@param {Matrix} product | [
"makes",
"matrix",
"weights",
"and",
"deltas",
"all",
"ones"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/recurrent/matrix/all-ones.js#L11-L16 |
1,294 | BrainJS/brain.js | dist/neural-network-gpu.js | mse | function mse(errors) {
var sum = 0;
for (var i = 0; i < this.constants.size; i++) {
sum += Math.pow(errors[i], 2);
}
return sum / this.constants.size;
} | javascript | function mse(errors) {
var sum = 0;
for (var i = 0; i < this.constants.size; i++) {
sum += Math.pow(errors[i], 2);
}
return sum / this.constants.size;
} | [
"function",
"mse",
"(",
"errors",
")",
"{",
"var",
"sum",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"constants",
".",
"size",
";",
"i",
"++",
")",
"{",
"sum",
"+=",
"Math",
".",
"pow",
"(",
"errors",
"[",
... | mean squared error, reimplemented for GPU | [
"mean",
"squared",
"error",
"reimplemented",
"for",
"GPU"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/neural-network-gpu.js#L521-L527 |
1,295 | BrainJS/brain.js | dist/utilities/random.js | gaussRandom | function gaussRandom() {
if (gaussRandom.returnV) {
gaussRandom.returnV = false;
return gaussRandom.vVal;
}
var u = 2 * Math.random() - 1;
var v = 2 * Math.random() - 1;
var r = u * u + v * v;
if (r == 0 || r > 1) {
return gaussRandom();
}
var c = Math.sqrt(-2 * Math.log(r) / r);
gaussRand... | javascript | function gaussRandom() {
if (gaussRandom.returnV) {
gaussRandom.returnV = false;
return gaussRandom.vVal;
}
var u = 2 * Math.random() - 1;
var v = 2 * Math.random() - 1;
var r = u * u + v * v;
if (r == 0 || r > 1) {
return gaussRandom();
}
var c = Math.sqrt(-2 * Math.log(r) / r);
gaussRand... | [
"function",
"gaussRandom",
"(",
")",
"{",
"if",
"(",
"gaussRandom",
".",
"returnV",
")",
"{",
"gaussRandom",
".",
"returnV",
"=",
"false",
";",
"return",
"gaussRandom",
".",
"vVal",
";",
"}",
"var",
"u",
"=",
"2",
"*",
"Math",
".",
"random",
"(",
")"... | Random numbers utils | [
"Random",
"numbers",
"utils"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/utilities/random.js#L22-L37 |
1,296 | BrainJS/brain.js | examples/stream-example.js | function(obj) {
console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);
const result01 = net.run([0, 1]);
const result00 = net.run([0, 0]);
const result11 = net.run([1, 1]);
const result10 = net.run([1, 0]);
assert(result01[0] > 0.9);
assert(result00[0] < 0.1);... | javascript | function(obj) {
console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);
const result01 = net.run([0, 1]);
const result00 = net.run([0, 0]);
const result11 = net.run([1, 1]);
const result10 = net.run([1, 0]);
assert(result01[0] > 0.9);
assert(result00[0] < 0.1);... | [
"function",
"(",
"obj",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"obj",
".",
"iterations",
"}",
"${",
"obj",
".",
"error",
"}",
"`",
")",
";",
"const",
"result01",
"=",
"net",
".",
"run",
"(",
"[",
"0",
",",
"1",
"]",
")",
";",
"const... | Called when the network is done training. | [
"Called",
"when",
"the",
"network",
"is",
"done",
"training",
"."
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/examples/stream-example.js#L25-L42 | |
1,297 | mozilla-services/react-jsonschema-form | src/validate.js | transformAjvErrors | function transformAjvErrors(errors = []) {
if (errors === null) {
return [];
}
return errors.map(e => {
const { dataPath, keyword, message, params, schemaPath } = e;
let property = `${dataPath}`;
// put data in expected format
return {
name: keyword,
property,
message,
... | javascript | function transformAjvErrors(errors = []) {
if (errors === null) {
return [];
}
return errors.map(e => {
const { dataPath, keyword, message, params, schemaPath } = e;
let property = `${dataPath}`;
// put data in expected format
return {
name: keyword,
property,
message,
... | [
"function",
"transformAjvErrors",
"(",
"errors",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"errors",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"errors",
".",
"map",
"(",
"e",
"=>",
"{",
"const",
"{",
"dataPath",
",",
"keyword",
","... | Transforming the error output from ajv to format used by jsonschema.
At some point, components should be updated to support ajv. | [
"Transforming",
"the",
"error",
"output",
"from",
"ajv",
"to",
"format",
"used",
"by",
"jsonschema",
".",
"At",
"some",
"point",
"components",
"should",
"be",
"updated",
"to",
"support",
"ajv",
"."
] | 1ee343d4654a6d98ac08ece97330ce2a3f9f1de3 | https://github.com/mozilla-services/react-jsonschema-form/blob/1ee343d4654a6d98ac08ece97330ce2a3f9f1de3/src/validate.js#L141-L160 |
1,298 | mozilla-services/react-jsonschema-form | src/components/widgets/CheckboxWidget.js | schemaRequiresTrueValue | function schemaRequiresTrueValue(schema) {
// Check if const is a truthy value
if (schema.const) {
return true;
}
// Check if an enum has a single value of true
if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
return true;
}
// If anyOf has a single value, evaluate the s... | javascript | function schemaRequiresTrueValue(schema) {
// Check if const is a truthy value
if (schema.const) {
return true;
}
// Check if an enum has a single value of true
if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
return true;
}
// If anyOf has a single value, evaluate the s... | [
"function",
"schemaRequiresTrueValue",
"(",
"schema",
")",
"{",
"// Check if const is a truthy value",
"if",
"(",
"schema",
".",
"const",
")",
"{",
"return",
"true",
";",
"}",
"// Check if an enum has a single value of true",
"if",
"(",
"schema",
".",
"enum",
"&&",
... | Check to see if a schema specifies that a value must be true | [
"Check",
"to",
"see",
"if",
"a",
"schema",
"specifies",
"that",
"a",
"value",
"must",
"be",
"true"
] | 1ee343d4654a6d98ac08ece97330ce2a3f9f1de3 | https://github.com/mozilla-services/react-jsonschema-form/blob/1ee343d4654a6d98ac08ece97330ce2a3f9f1de3/src/components/widgets/CheckboxWidget.js#L6-L32 |
1,299 | mozilla-services/react-jsonschema-form | src/components/fields/ArrayField.js | DefaultArrayItem | function DefaultArrayItem(props) {
const btnStyle = {
flex: 1,
paddingLeft: 6,
paddingRight: 6,
fontWeight: "bold",
};
return (
<div key={props.index} className={props.className}>
<div className={props.hasToolbar ? "col-xs-9" : "col-xs-12"}>
{props.children}
</div>
{... | javascript | function DefaultArrayItem(props) {
const btnStyle = {
flex: 1,
paddingLeft: 6,
paddingRight: 6,
fontWeight: "bold",
};
return (
<div key={props.index} className={props.className}>
<div className={props.hasToolbar ? "col-xs-9" : "col-xs-12"}>
{props.children}
</div>
{... | [
"function",
"DefaultArrayItem",
"(",
"props",
")",
"{",
"const",
"btnStyle",
"=",
"{",
"flex",
":",
"1",
",",
"paddingLeft",
":",
"6",
",",
"paddingRight",
":",
"6",
",",
"fontWeight",
":",
"\"bold\"",
",",
"}",
";",
"return",
"(",
"<",
"div",
"key",
... | Used in the two templates | [
"Used",
"in",
"the",
"two",
"templates"
] | 1ee343d4654a6d98ac08ece97330ce2a3f9f1de3 | https://github.com/mozilla-services/react-jsonschema-form/blob/1ee343d4654a6d98ac08ece97330ce2a3f9f1de3/src/components/fields/ArrayField.js#L39-L100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.