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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pissang/claygl | dist/claygl.es.js | function (renderer, size) {
renderer.saveClear();
var viewport = renderer.viewport;
var x = 0, y = 0;
var width = size || viewport.width / 4;
var height = width;
if (this.softShadow === ShadowMapPass.VSM) {
this._outputDepthPass.material.define('fragment', 'US... | javascript | function (renderer, size) {
renderer.saveClear();
var viewport = renderer.viewport;
var x = 0, y = 0;
var width = size || viewport.width / 4;
var height = width;
if (this.softShadow === ShadowMapPass.VSM) {
this._outputDepthPass.material.define('fragment', 'US... | [
"function",
"(",
"renderer",
",",
"size",
")",
"{",
"renderer",
".",
"saveClear",
"(",
")",
";",
"var",
"viewport",
"=",
"renderer",
".",
"viewport",
";",
"var",
"x",
"=",
"0",
",",
"y",
"=",
"0",
";",
"var",
"width",
"=",
"size",
"||",
"viewport",... | Debug rendering of shadow textures
@param {clay.Renderer} renderer
@param {number} size
@memberOf clay.prePass.ShadowMap.prototype | [
"Debug",
"rendering",
"of",
"shadow",
"textures"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L24410-L24431 | train | |
pissang/claygl | dist/claygl.es.js | function (x, y, forcePickAll) {
var out = this.pickAll(x, y, [], forcePickAll);
return out[0] || null;
} | javascript | function (x, y, forcePickAll) {
var out = this.pickAll(x, y, [], forcePickAll);
return out[0] || null;
} | [
"function",
"(",
"x",
",",
"y",
",",
"forcePickAll",
")",
"{",
"var",
"out",
"=",
"this",
".",
"pickAll",
"(",
"x",
",",
"y",
",",
"[",
"]",
",",
"forcePickAll",
")",
";",
"return",
"out",
"[",
"0",
"]",
"||",
"null",
";",
"}"
] | Pick the nearest intersection object in the scene
@param {number} x Mouse position x
@param {number} y Mouse position y
@param {boolean} [forcePickAll=false] ignore ignorePicking
@return {clay.picking.RayPicking~Intersection} | [
"Pick",
"the",
"nearest",
"intersection",
"object",
"in",
"the",
"scene"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L25182-L25185 | train | |
pissang/claygl | dist/claygl.es.js | function (x, y, output, forcePickAll) {
this.renderer.screenToNDC(x, y, this._ndc);
this.camera.castRay(this._ndc, this._ray);
output = output || [];
this._intersectNode(this.scene, output, forcePickAll || false);
output.sort(this._intersectionCompareFunc);
return out... | javascript | function (x, y, output, forcePickAll) {
this.renderer.screenToNDC(x, y, this._ndc);
this.camera.castRay(this._ndc, this._ray);
output = output || [];
this._intersectNode(this.scene, output, forcePickAll || false);
output.sort(this._intersectionCompareFunc);
return out... | [
"function",
"(",
"x",
",",
"y",
",",
"output",
",",
"forcePickAll",
")",
"{",
"this",
".",
"renderer",
".",
"screenToNDC",
"(",
"x",
",",
"y",
",",
"this",
".",
"_ndc",
")",
";",
"this",
".",
"camera",
".",
"castRay",
"(",
"this",
".",
"_ndc",
",... | Pick all intersection objects, wich will be sorted from near to far
@param {number} x Mouse position x
@param {number} y Mouse position y
@param {Array} [output]
@param {boolean} [forcePickAll=false] ignore ignorePicking
@return {Array.<clay.picking.RayPicking~Intersection>} | [
"Pick",
"all",
"intersection",
"objects",
"wich",
"will",
"be",
"sorted",
"from",
"near",
"to",
"far"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L25195-L25206 | train | |
pissang/claygl | dist/claygl.es.js | function () {
for (var i = 0; i < this.nodes.length; i++) {
this.nodes[i].clear();
}
// Traverse all the nodes and build the graph
for (var i = 0; i < this.nodes.length; i++) {
var node = this.nodes[i];
if (!node.inputs) {
continue;
... | javascript | function () {
for (var i = 0; i < this.nodes.length; i++) {
this.nodes[i].clear();
}
// Traverse all the nodes and build the graph
for (var i = 0; i < this.nodes.length; i++) {
var node = this.nodes[i];
if (!node.inputs) {
continue;
... | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"nodes",
"[",
"i",
"]",
".",
"clear",
"(",
")",
";",
"}",
"// Traverse all the nodes and build... | Update links of graph | [
"Update",
"links",
"of",
"graph"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L27548-L27583 | train | |
pissang/claygl | dist/claygl.es.js | function (width, height) {
if (this._gBufferTex1.width === width
&& this._gBufferTex1.height === height
) {
return;
}
this._gBufferTex1.width = width;
this._gBufferTex1.height = height;
this._gBufferTex2.width = width;
this._gBufferTex2.he... | javascript | function (width, height) {
if (this._gBufferTex1.width === width
&& this._gBufferTex1.height === height
) {
return;
}
this._gBufferTex1.width = width;
this._gBufferTex1.height = height;
this._gBufferTex2.width = width;
this._gBufferTex2.he... | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"if",
"(",
"this",
".",
"_gBufferTex1",
".",
"width",
"===",
"width",
"&&",
"this",
".",
"_gBufferTex1",
".",
"height",
"===",
"height",
")",
"{",
"return",
";",
"}",
"this",
".",
"_gBufferTex1",
".",
... | Set G Buffer size.
@param {number} width
@param {number} height | [
"Set",
"G",
"Buffer",
"size",
"."
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L28704-L28721 | train | |
pissang/claygl | dist/claygl.es.js | function() {
var cone = new Cone$1({
topRadius: this.radius,
bottomRadius: this.radius,
capSegments: this.capSegments,
heightSegments: this.heightSegments,
height: this.height
});
this.attributes.position.value = cone.attributes.positi... | javascript | function() {
var cone = new Cone$1({
topRadius: this.radius,
bottomRadius: this.radius,
capSegments: this.capSegments,
heightSegments: this.heightSegments,
height: this.height
});
this.attributes.position.value = cone.attributes.positi... | [
"function",
"(",
")",
"{",
"var",
"cone",
"=",
"new",
"Cone$1",
"(",
"{",
"topRadius",
":",
"this",
".",
"radius",
",",
"bottomRadius",
":",
"this",
".",
"radius",
",",
"capSegments",
":",
"this",
".",
"capSegments",
",",
"heightSegments",
":",
"this",
... | Build cylinder geometry | [
"Build",
"cylinder",
"geometry"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L29252-L29267 | train | |
pissang/claygl | dist/claygl.es.js | function (light) {
var volumeMesh;
if (light.volumeMesh) {
volumeMesh = light.volumeMesh;
}
else {
switch (light.type) {
// Only local light (point and spot) needs volume mesh.
// Directional and ambient light renders in full quad
... | javascript | function (light) {
var volumeMesh;
if (light.volumeMesh) {
volumeMesh = light.volumeMesh;
}
else {
switch (light.type) {
// Only local light (point and spot) needs volume mesh.
// Directional and ambient light renders in full quad
... | [
"function",
"(",
"light",
")",
"{",
"var",
"volumeMesh",
";",
"if",
"(",
"light",
".",
"volumeMesh",
")",
"{",
"volumeMesh",
"=",
"light",
".",
"volumeMesh",
";",
"}",
"else",
"{",
"switch",
"(",
"light",
".",
"type",
")",
"{",
"// Only local light (poin... | Update light volume mesh Light volume mesh is rendered in light accumulate pass instead of full quad. It will reduce pixels significantly when local light is relatively small. And we can use custom volume mesh to shape the light. See "Deferred Shading Optimizations" in GDC2011 | [
"Update",
"light",
"volume",
"mesh",
"Light",
"volume",
"mesh",
"is",
"rendered",
"in",
"light",
"accumulate",
"pass",
"instead",
"of",
"full",
"quad",
".",
"It",
"will",
"reduce",
"pixels",
"significantly",
"when",
"local",
"light",
"is",
"relatively",
"small... | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L29771-L29829 | train | |
pissang/claygl | dist/claygl.es.js | function(out) {
var amount = Math.min(this._particlePool.length, this.amount);
var particle;
for (var i = 0; i < amount; i++) {
particle = this._particlePool.pop();
// Initialize particle status
if (this.position) {
this.position.get(particle.... | javascript | function(out) {
var amount = Math.min(this._particlePool.length, this.amount);
var particle;
for (var i = 0; i < amount; i++) {
particle = this._particlePool.pop();
// Initialize particle status
if (this.position) {
this.position.get(particle.... | [
"function",
"(",
"out",
")",
"{",
"var",
"amount",
"=",
"Math",
".",
"min",
"(",
"this",
".",
"_particlePool",
".",
"length",
",",
"this",
".",
"amount",
")",
";",
"var",
"particle",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"amount",... | Emitter number of particles and push them to a given particle list. Emmit number is defined by amount property
@param {Array.<clay.particle.Particle>} out | [
"Emitter",
"number",
"of",
"particles",
"and",
"push",
"them",
"to",
"a",
"given",
"particle",
"list",
".",
"Emmit",
"number",
"is",
"defined",
"by",
"amount",
"property"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L32704-L32736 | train | |
pissang/claygl | dist/claygl.es.js | function() {
// Put all the particles back
for (var i = 0; i < this._particles.length; i++) {
var p = this._particles[i];
p.emitter.kill(p);
}
this._particles.length = 0;
this._elapsedTime = 0;
this._emitting = true;
} | javascript | function() {
// Put all the particles back
for (var i = 0; i < this._particles.length; i++) {
var p = this._particles[i];
p.emitter.kill(p);
}
this._particles.length = 0;
this._elapsedTime = 0;
this._emitting = true;
} | [
"function",
"(",
")",
"{",
"// Put all the particles back",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_particles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"p",
"=",
"this",
".",
"_particles",
"[",
"i",
"]",
";",
"p",
... | Reset the particle system. | [
"Reset",
"the",
"particle",
"system",
"."
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L32948-L32957 | train | |
pissang/claygl | dist/claygl.es.js | function(ratio) {
this._texture.width = this.width * ratio;
this._texture.height = this.height * ratio;
this.downSampleRatio = ratio;
} | javascript | function(ratio) {
this._texture.width = this.width * ratio;
this._texture.height = this.height * ratio;
this.downSampleRatio = ratio;
} | [
"function",
"(",
"ratio",
")",
"{",
"this",
".",
"_texture",
".",
"width",
"=",
"this",
".",
"width",
"*",
"ratio",
";",
"this",
".",
"_texture",
".",
"height",
"=",
"this",
".",
"height",
"*",
"ratio",
";",
"this",
".",
"downSampleRatio",
"=",
"rati... | Set picking presision
@param {number} ratio | [
"Set",
"picking",
"presision"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33165-L33169 | train | |
pissang/claygl | dist/claygl.es.js | function(scene, camera) {
var renderer = this.renderer;
if (renderer.getWidth() !== this.width || renderer.getHeight() !== this.height) {
this.resize(renderer.width, renderer.height);
}
this._frameBuffer.attach(this._texture);
this._frameBuffer.bind(renderer);
... | javascript | function(scene, camera) {
var renderer = this.renderer;
if (renderer.getWidth() !== this.width || renderer.getHeight() !== this.height) {
this.resize(renderer.width, renderer.height);
}
this._frameBuffer.attach(this._texture);
this._frameBuffer.bind(renderer);
... | [
"function",
"(",
"scene",
",",
"camera",
")",
"{",
"var",
"renderer",
"=",
"this",
".",
"renderer",
";",
"if",
"(",
"renderer",
".",
"getWidth",
"(",
")",
"!==",
"this",
".",
"width",
"||",
"renderer",
".",
"getHeight",
"(",
")",
"!==",
"this",
".",
... | Update the picking framebuffer
@param {number} ratio | [
"Update",
"the",
"picking",
"framebuffer"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33181-L33194 | train | |
pissang/claygl | dist/claygl.es.js | function(x, y) {
var renderer = this.renderer;
var ratio = this.downSampleRatio;
x = Math.ceil(ratio * x);
y = Math.ceil(ratio * (this.height - y));
this._frameBuffer.bind(renderer);
var pixel = new Uint8Array(4);
var _gl = renderer.gl;
// TODO out of bo... | javascript | function(x, y) {
var renderer = this.renderer;
var ratio = this.downSampleRatio;
x = Math.ceil(ratio * x);
y = Math.ceil(ratio * (this.height - y));
this._frameBuffer.bind(renderer);
var pixel = new Uint8Array(4);
var _gl = renderer.gl;
// TODO out of bo... | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"renderer",
"=",
"this",
".",
"renderer",
";",
"var",
"ratio",
"=",
"this",
".",
"downSampleRatio",
";",
"x",
"=",
"Math",
".",
"ceil",
"(",
"ratio",
"*",
"x",
")",
";",
"y",
"=",
"Math",
".",
"c... | Pick the object
@param {number} x Mouse position x
@param {number} y Mouse position y
@return {clay.Node} | [
"Pick",
"the",
"object"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33231-L33253 | train | |
pissang/claygl | dist/claygl.es.js | function (frameTime) {
var target = this.target;
var position = this.target.position;
var xAxis = target.localTransform.x.normalize();
var zAxis = target.localTransform.z.normalize();
if (this.verticalMoveLock) {
zAxis.y = 0;
zAxis.normalize();
}... | javascript | function (frameTime) {
var target = this.target;
var position = this.target.position;
var xAxis = target.localTransform.x.normalize();
var zAxis = target.localTransform.z.normalize();
if (this.verticalMoveLock) {
zAxis.y = 0;
zAxis.normalize();
}... | [
"function",
"(",
"frameTime",
")",
"{",
"var",
"target",
"=",
"this",
".",
"target",
";",
"var",
"position",
"=",
"this",
".",
"target",
".",
"position",
";",
"var",
"xAxis",
"=",
"target",
".",
"localTransform",
".",
"x",
".",
"normalize",
"(",
")",
... | Control update. Should be invoked every frame
@param {number} frameTime Frame time | [
"Control",
"update",
".",
"Should",
"be",
"invoked",
"every",
"frame"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33421-L33454 | train | |
pissang/claygl | dist/claygl.es.js | function() {
/**
* When user begins to interact with connected gamepad:
*
* @see https://w3c.github.io/gamepad/#dom-gamepadevent
*/
vendor.addEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility);
if (this.timeline) {
this.ti... | javascript | function() {
/**
* When user begins to interact with connected gamepad:
*
* @see https://w3c.github.io/gamepad/#dom-gamepadevent
*/
vendor.addEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility);
if (this.timeline) {
this.ti... | [
"function",
"(",
")",
"{",
"/**\n * When user begins to interact with connected gamepad:\n *\n * @see https://w3c.github.io/gamepad/#dom-gamepadevent\n */",
"vendor",
".",
"addEventListener",
"(",
"window",
",",
"'gamepadconnected'",
",",
"this",
".",
"_... | Init. control. | [
"Init",
".",
"control",
"."
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33639-L33654 | train | |
pissang/claygl | dist/claygl.es.js | function() {
vendor.removeEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility);
if (this.timeline) {
this.timeline.off('frame', this.update);
}
vendor.removeEventListener(window, 'gamepaddisconnected', this._disconnectGamepad);
} | javascript | function() {
vendor.removeEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility);
if (this.timeline) {
this.timeline.off('frame', this.update);
}
vendor.removeEventListener(window, 'gamepaddisconnected', this._disconnectGamepad);
} | [
"function",
"(",
")",
"{",
"vendor",
".",
"removeEventListener",
"(",
"window",
",",
"'gamepadconnected'",
",",
"this",
".",
"_checkGamepadCompatibility",
")",
";",
"if",
"(",
"this",
".",
"timeline",
")",
"{",
"this",
".",
"timeline",
".",
"off",
"(",
"'f... | Dispose control. | [
"Dispose",
"control",
"."
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33659-L33669 | train | |
pissang/claygl | dist/claygl.es.js | function (frameTime) {
if (!this._standardGamepadAvailable) {
return;
}
this._scanPressedGamepadButtons();
this._scanInclinedGamepadAxes();
// Update target depending on user input.
var target = this.target;
var position = this.target.position;
... | javascript | function (frameTime) {
if (!this._standardGamepadAvailable) {
return;
}
this._scanPressedGamepadButtons();
this._scanInclinedGamepadAxes();
// Update target depending on user input.
var target = this.target;
var position = this.target.position;
... | [
"function",
"(",
"frameTime",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_standardGamepadAvailable",
")",
"{",
"return",
";",
"}",
"this",
".",
"_scanPressedGamepadButtons",
"(",
")",
";",
"this",
".",
"_scanInclinedGamepadAxes",
"(",
")",
";",
"// Update target ... | Control's update. Should be invoked every frame.
@param {number} frameTime Frame time. | [
"Control",
"s",
"update",
".",
"Should",
"be",
"invoked",
"every",
"frame",
"."
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L33676-L33728 | train | |
pissang/claygl | dist/claygl.es.js | function () {
var dom = this.domElement;
vendor.addEventListener(dom, 'touchstart', this._mouseDownHandler);
vendor.addEventListener(dom, 'mousedown', this._mouseDownHandler);
vendor.addEventListener(dom, 'wheel', this._mouseWheelHandler);
if (this.timeline) {
this... | javascript | function () {
var dom = this.domElement;
vendor.addEventListener(dom, 'touchstart', this._mouseDownHandler);
vendor.addEventListener(dom, 'mousedown', this._mouseDownHandler);
vendor.addEventListener(dom, 'wheel', this._mouseWheelHandler);
if (this.timeline) {
this... | [
"function",
"(",
")",
"{",
"var",
"dom",
"=",
"this",
".",
"domElement",
";",
"vendor",
".",
"addEventListener",
"(",
"dom",
",",
"'touchstart'",
",",
"this",
".",
"_mouseDownHandler",
")",
";",
"vendor",
".",
"addEventListener",
"(",
"dom",
",",
"'mousedo... | Initialize.
Mouse event binding | [
"Initialize",
".",
"Mouse",
"event",
"binding"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34260-L34274 | train | |
pissang/claygl | dist/claygl.es.js | function () {
var dom = this.domElement;
vendor.removeEventListener(dom, 'touchstart', this._mouseDownHandler);
vendor.removeEventListener(dom, 'touchmove', this._mouseMoveHandler);
vendor.removeEventListener(dom, 'touchend', this._mouseUpHandler);
vendor.removeEventListener(do... | javascript | function () {
var dom = this.domElement;
vendor.removeEventListener(dom, 'touchstart', this._mouseDownHandler);
vendor.removeEventListener(dom, 'touchmove', this._mouseMoveHandler);
vendor.removeEventListener(dom, 'touchend', this._mouseUpHandler);
vendor.removeEventListener(do... | [
"function",
"(",
")",
"{",
"var",
"dom",
"=",
"this",
".",
"domElement",
";",
"vendor",
".",
"removeEventListener",
"(",
"dom",
",",
"'touchstart'",
",",
"this",
".",
"_mouseDownHandler",
")",
";",
"vendor",
".",
"removeEventListener",
"(",
"dom",
",",
"'t... | Dispose.
Mouse event unbinding | [
"Dispose",
".",
"Mouse",
"event",
"unbinding"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34280-L34297 | train | |
pissang/claygl | dist/claygl.es.js | function (alpha) {
alpha = Math.max(Math.min(this.maxAlpha, alpha), this.minAlpha);
this._theta = alpha / 180 * Math.PI;
this._needsUpdate = true;
} | javascript | function (alpha) {
alpha = Math.max(Math.min(this.maxAlpha, alpha), this.minAlpha);
this._theta = alpha / 180 * Math.PI;
this._needsUpdate = true;
} | [
"function",
"(",
"alpha",
")",
"{",
"alpha",
"=",
"Math",
".",
"max",
"(",
"Math",
".",
"min",
"(",
"this",
".",
"maxAlpha",
",",
"alpha",
")",
",",
"this",
".",
"minAlpha",
")",
";",
"this",
".",
"_theta",
"=",
"alpha",
"/",
"180",
"*",
"Math",
... | Set alpha rotation angle
@param {number} alpha | [
"Set",
"alpha",
"rotation",
"angle"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34365-L34370 | train | |
pissang/claygl | dist/claygl.es.js | function (beta) {
beta = Math.max(Math.min(this.maxBeta, beta), this.minBeta);
this._phi = -beta / 180 * Math.PI;
this._needsUpdate = true;
} | javascript | function (beta) {
beta = Math.max(Math.min(this.maxBeta, beta), this.minBeta);
this._phi = -beta / 180 * Math.PI;
this._needsUpdate = true;
} | [
"function",
"(",
"beta",
")",
"{",
"beta",
"=",
"Math",
".",
"max",
"(",
"Math",
".",
"min",
"(",
"this",
".",
"maxBeta",
",",
"beta",
")",
",",
"this",
".",
"minBeta",
")",
";",
"this",
".",
"_phi",
"=",
"-",
"beta",
"/",
"180",
"*",
"Math",
... | Set beta rotation angle
@param {number} beta | [
"Set",
"beta",
"rotation",
"angle"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34376-L34381 | train | |
pissang/claygl | dist/claygl.es.js | function () {
for (var i = 0; i < this._animators.length; i++) {
this._animators[i].stop();
}
this._animators.length = 0;
} | javascript | function () {
for (var i = 0; i < this._animators.length; i++) {
this._animators[i].stop();
}
this._animators.length = 0;
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_animators",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"_animators",
"[",
"i",
"]",
".",
"stop",
"(",
")",
";",
"}",
"this",
".",
"_animator... | Stop all animations | [
"Stop",
"all",
"animations"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34500-L34505 | train | |
pissang/claygl | dist/claygl.es.js | function (deltaTime) {
deltaTime = deltaTime || 16;
if (this._rotating) {
var radian = (this.autoRotateDirection === 'cw' ? 1 : -1)
* this.autoRotateSpeed / 180 * Math.PI;
this._phi -= radian * deltaTime / 1000;
this._needsUpdate = true;
}
... | javascript | function (deltaTime) {
deltaTime = deltaTime || 16;
if (this._rotating) {
var radian = (this.autoRotateDirection === 'cw' ? 1 : -1)
* this.autoRotateSpeed / 180 * Math.PI;
this._phi -= radian * deltaTime / 1000;
this._needsUpdate = true;
}
... | [
"function",
"(",
"deltaTime",
")",
"{",
"deltaTime",
"=",
"deltaTime",
"||",
"16",
";",
"if",
"(",
"this",
".",
"_rotating",
")",
"{",
"var",
"radian",
"=",
"(",
"this",
".",
"autoRotateDirection",
"===",
"'cw'",
"?",
"1",
":",
"-",
"1",
")",
"*",
... | Call update each frame
@param {number} deltaTime Frame time | [
"Call",
"update",
"each",
"frame"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L34514-L34549 | train | |
pissang/claygl | dist/claygl.es.js | function (geometry, shallow) {
if (!geometry) {
return null;
}
var data = {
metadata : util$1.extend({}, META)
};
//transferable buffers
var buffers = [];
//dynamic
data.dynamic = geometry.dynamic;
//bounding box
i... | javascript | function (geometry, shallow) {
if (!geometry) {
return null;
}
var data = {
metadata : util$1.extend({}, META)
};
//transferable buffers
var buffers = [];
//dynamic
data.dynamic = geometry.dynamic;
//bounding box
i... | [
"function",
"(",
"geometry",
",",
"shallow",
")",
"{",
"if",
"(",
"!",
"geometry",
")",
"{",
"return",
"null",
";",
"}",
"var",
"data",
"=",
"{",
"metadata",
":",
"util$1",
".",
"extend",
"(",
"{",
"}",
",",
"META",
")",
"}",
";",
"//transferable b... | Convert geometry to a object containing transferable data
@param {Geometry} geometry geometry
@param {Boolean} shallow whether shallow copy
@returns {Object} { data : data, buffers : buffers }, buffers is the transferable list | [
"Convert",
"geometry",
"to",
"a",
"object",
"containing",
"transferable",
"data"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L35242-L35286 | train | |
pissang/claygl | dist/claygl.es.js | function (object) {
if (!object) {
return null;
}
if (object.data && object.buffers) {
return transferableUtil.toGeometry(object.data);
}
if (!object.metadata || object.metadata.generator !== META.generator) {
throw new Error('[util.transferabl... | javascript | function (object) {
if (!object) {
return null;
}
if (object.data && object.buffers) {
return transferableUtil.toGeometry(object.data);
}
if (!object.metadata || object.metadata.generator !== META.generator) {
throw new Error('[util.transferabl... | [
"function",
"(",
"object",
")",
"{",
"if",
"(",
"!",
"object",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"object",
".",
"data",
"&&",
"object",
".",
"buffers",
")",
"{",
"return",
"transferableUtil",
".",
"toGeometry",
"(",
"object",
".",
"dat... | Reproduce a geometry from object generated by toObject
@param {Object} object object generated by toObject
@returns {Geometry} geometry | [
"Reproduce",
"a",
"geometry",
"from",
"object",
"generated",
"by",
"toObject"
] | b157bb50cf8c725fa20f90ebb55481352777f0a7 | https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L35293-L35328 | train | |
webslides/WebSlides | src/js/utils/custom-event.js | canIuseNativeCustom | function canIuseNativeCustom() {
try {
const p = new NativeCustomEvent('t', {
detail: {
a: 'b'
}
});
return 't' === p.type && 'b' === p.detail.a;
} catch (e) { }
/* istanbul ignore next: hard to reproduce on test environment */
return false;
} | javascript | function canIuseNativeCustom() {
try {
const p = new NativeCustomEvent('t', {
detail: {
a: 'b'
}
});
return 't' === p.type && 'b' === p.detail.a;
} catch (e) { }
/* istanbul ignore next: hard to reproduce on test environment */
return false;
} | [
"function",
"canIuseNativeCustom",
"(",
")",
"{",
"try",
"{",
"const",
"p",
"=",
"new",
"NativeCustomEvent",
"(",
"'t'",
",",
"{",
"detail",
":",
"{",
"a",
":",
"'b'",
"}",
"}",
")",
";",
"return",
"'t'",
"===",
"p",
".",
"type",
"&&",
"'b'",
"==="... | Check for the usage of native support for CustomEvents which is lacking
completely on IE.
@return {boolean} Whether it can be used or not. | [
"Check",
"for",
"the",
"usage",
"of",
"native",
"support",
"for",
"CustomEvents",
"which",
"is",
"lacking",
"completely",
"on",
"IE",
"."
] | fb5208218f15eb341d0aab64d86ba67a221aced3 | https://github.com/webslides/WebSlides/blob/fb5208218f15eb341d0aab64d86ba67a221aced3/src/js/utils/custom-event.js#L8-L20 | train |
webslides/WebSlides | src/js/utils/custom-event.js | CustomEvent | function CustomEvent(type, params) {
const e = document.createEvent('CustomEvent');
if (params) {
e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);
} else {
e.initCustomEvent(type, false, false, undefined);
}
return e;
} | javascript | function CustomEvent(type, params) {
const e = document.createEvent('CustomEvent');
if (params) {
e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);
} else {
e.initCustomEvent(type, false, false, undefined);
}
return e;
} | [
"function",
"CustomEvent",
"(",
"type",
",",
"params",
")",
"{",
"const",
"e",
"=",
"document",
".",
"createEvent",
"(",
"'CustomEvent'",
")",
";",
"if",
"(",
"params",
")",
"{",
"e",
".",
"initCustomEvent",
"(",
"type",
",",
"params",
".",
"bubbles",
... | Lousy polyfill for the Custom Event constructor for IE.
@param {!string} type The type of the event.
@param {?Object} params Additional information for the event.
@return {Event}
@constructor
/* istanbul ignore next: hard to reproduce on test environment | [
"Lousy",
"polyfill",
"for",
"the",
"Custom",
"Event",
"constructor",
"for",
"IE",
"."
] | fb5208218f15eb341d0aab64d86ba67a221aced3 | https://github.com/webslides/WebSlides/blob/fb5208218f15eb341d0aab64d86ba67a221aced3/src/js/utils/custom-event.js#L30-L40 | train |
libp2p/js-libp2p | src/util/index.js | emitFirst | function emitFirst (emitter, events, handler) {
handler = once(handler)
events.forEach((e) => {
emitter.once(e, (...args) => {
events.forEach((ev) => {
emitter.removeListener(ev, handler)
})
handler.apply(emitter, args)
})
})
} | javascript | function emitFirst (emitter, events, handler) {
handler = once(handler)
events.forEach((e) => {
emitter.once(e, (...args) => {
events.forEach((ev) => {
emitter.removeListener(ev, handler)
})
handler.apply(emitter, args)
})
})
} | [
"function",
"emitFirst",
"(",
"emitter",
",",
"events",
",",
"handler",
")",
"{",
"handler",
"=",
"once",
"(",
"handler",
")",
"events",
".",
"forEach",
"(",
"(",
"e",
")",
"=>",
"{",
"emitter",
".",
"once",
"(",
"e",
",",
"(",
"...",
"args",
")",
... | Registers `handler` to each event in `events`. The `handler`
will only be called for the first event fired, at which point
the `handler` will be removed as a listener.
Ensures `handler` is only called once.
@example
// will call `callback` when `start` or `error` is emitted by `this`
emitFirst(this, ['error', 'start'... | [
"Registers",
"handler",
"to",
"each",
"event",
"in",
"events",
".",
"The",
"handler",
"will",
"only",
"be",
"called",
"for",
"the",
"first",
"event",
"fired",
"at",
"which",
"point",
"the",
"handler",
"will",
"be",
"removed",
"as",
"a",
"listener",
"."
] | 28c054c21e7ba2796450d2ab2a0bef6542ec3583 | https://github.com/libp2p/js-libp2p/blob/28c054c21e7ba2796450d2ab2a0bef6542ec3583/src/util/index.js#L21-L31 | train |
vue-styleguidist/vue-styleguidist | packages/vue-styleguidist/loaders/utils/getSections.js | getSections | function getSections(sections, config, parentDepth) {
return sections.map(section => processSection(section, config, parentDepth))
} | javascript | function getSections(sections, config, parentDepth) {
return sections.map(section => processSection(section, config, parentDepth))
} | [
"function",
"getSections",
"(",
"sections",
",",
"config",
",",
"parentDepth",
")",
"{",
"return",
"sections",
".",
"map",
"(",
"section",
"=>",
"processSection",
"(",
"section",
",",
"config",
",",
"parentDepth",
")",
")",
"}"
] | Return object for one level of sections.
@param {Array} sections
@param {object} config
@param {number} parentDepth
@returns {Array} | [
"Return",
"object",
"for",
"one",
"level",
"of",
"sections",
"."
] | a039dc0e112a1d59122d84f5a7ce6b328a63c61b | https://github.com/vue-styleguidist/vue-styleguidist/blob/a039dc0e112a1d59122d84f5a7ce6b328a63c61b/packages/vue-styleguidist/loaders/utils/getSections.js#L21-L23 | train |
vue-styleguidist/vue-styleguidist | packages/vue-styleguidist/loaders/utils/getSections.js | processSection | function processSection(section, config, parentDepth) {
const contentRelativePath = section.content
// Try to load section content file
let content
if (contentRelativePath) {
const contentAbsolutePath = path.resolve(config.configDir, contentRelativePath)
if (!fs.existsSync(contentAbsolutePath)) {
throw new ... | javascript | function processSection(section, config, parentDepth) {
const contentRelativePath = section.content
// Try to load section content file
let content
if (contentRelativePath) {
const contentAbsolutePath = path.resolve(config.configDir, contentRelativePath)
if (!fs.existsSync(contentAbsolutePath)) {
throw new ... | [
"function",
"processSection",
"(",
"section",
",",
"config",
",",
"parentDepth",
")",
"{",
"const",
"contentRelativePath",
"=",
"section",
".",
"content",
"// Try to load section content file",
"let",
"content",
"if",
"(",
"contentRelativePath",
")",
"{",
"const",
"... | Return an object for a given section with all components and subsections.
@param {object} section
@param {object} config
@param {number} parentDepth
@returns {object} | [
"Return",
"an",
"object",
"for",
"a",
"given",
"section",
"with",
"all",
"components",
"and",
"subsections",
"."
] | a039dc0e112a1d59122d84f5a7ce6b328a63c61b | https://github.com/vue-styleguidist/vue-styleguidist/blob/a039dc0e112a1d59122d84f5a7ce6b328a63c61b/packages/vue-styleguidist/loaders/utils/getSections.js#L41-L76 | train |
vue-styleguidist/vue-styleguidist | packages/vue-styleguidist/loaders/utils/processComponent.js | getComponentMetadataPath | function getComponentMetadataPath(filepath) {
const extname = path.extname(filepath)
return filepath.substring(0, filepath.length - extname.length) + '.json'
} | javascript | function getComponentMetadataPath(filepath) {
const extname = path.extname(filepath)
return filepath.substring(0, filepath.length - extname.length) + '.json'
} | [
"function",
"getComponentMetadataPath",
"(",
"filepath",
")",
"{",
"const",
"extname",
"=",
"path",
".",
"extname",
"(",
"filepath",
")",
"return",
"filepath",
".",
"substring",
"(",
"0",
",",
"filepath",
".",
"length",
"-",
"extname",
".",
"length",
")",
... | References the filepath of the metadata file.
@param {string} filepath
@returns {object} | [
"References",
"the",
"filepath",
"of",
"the",
"metadata",
"file",
"."
] | a039dc0e112a1d59122d84f5a7ce6b328a63c61b | https://github.com/vue-styleguidist/vue-styleguidist/blob/a039dc0e112a1d59122d84f5a7ce6b328a63c61b/packages/vue-styleguidist/loaders/utils/processComponent.js#L15-L18 | train |
vue-styleguidist/vue-styleguidist | packages/vue-styleguidist/scripts/config.js | findConfigFile | function findConfigFile() {
let configDir
try {
configDir = findup.sync(process.cwd(), CONFIG_FILENAME)
} catch (exception) {
return false
}
return path.join(configDir, CONFIG_FILENAME)
} | javascript | function findConfigFile() {
let configDir
try {
configDir = findup.sync(process.cwd(), CONFIG_FILENAME)
} catch (exception) {
return false
}
return path.join(configDir, CONFIG_FILENAME)
} | [
"function",
"findConfigFile",
"(",
")",
"{",
"let",
"configDir",
"try",
"{",
"configDir",
"=",
"findup",
".",
"sync",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"CONFIG_FILENAME",
")",
"}",
"catch",
"(",
"exception",
")",
"{",
"return",
"false",
"}",
"... | Try to find config file up the file tree.
@return {string|boolean} Config absolute file path. | [
"Try",
"to",
"find",
"config",
"file",
"up",
"the",
"file",
"tree",
"."
] | a039dc0e112a1d59122d84f5a7ce6b328a63c61b | https://github.com/vue-styleguidist/vue-styleguidist/blob/a039dc0e112a1d59122d84f5a7ce6b328a63c61b/packages/vue-styleguidist/scripts/config.js#L62-L71 | train |
Microsoft/Recognizers-Text | JavaScript/samples/simple-console/index.js | runRecognition | function runRecognition() {
var stdin = process.openStdin();
// Read the text to recognize
write('Enter the text to recognize: ');
stdin.addListener('data', function (e) {
var input = e.toString().trim();
if (input) {
// Exit
if (input.toLowerCase() === 'exit') ... | javascript | function runRecognition() {
var stdin = process.openStdin();
// Read the text to recognize
write('Enter the text to recognize: ');
stdin.addListener('data', function (e) {
var input = e.toString().trim();
if (input) {
// Exit
if (input.toLowerCase() === 'exit') ... | [
"function",
"runRecognition",
"(",
")",
"{",
"var",
"stdin",
"=",
"process",
".",
"openStdin",
"(",
")",
";",
"// Read the text to recognize",
"write",
"(",
"'Enter the text to recognize: '",
")",
";",
"stdin",
".",
"addListener",
"(",
"'data'",
",",
"function",
... | Read from Console and recognize | [
"Read",
"from",
"Console",
"and",
"recognize"
] | 08414d1585eaa29a61455aaea95bf29a8d629b23 | https://github.com/Microsoft/Recognizers-Text/blob/08414d1585eaa29a61455aaea95bf29a8d629b23/JavaScript/samples/simple-console/index.js#L11-L44 | train |
jfhbrook/node-ecstatic | lib/ecstatic.js | shouldCompressGzip | function shouldCompressGzip(req) {
const headers = req.headers;
return headers && headers['accept-encoding'] &&
headers['accept-encoding']
.split(',')
.some(el => ['*', 'compress', 'gzip', 'deflate'].indexOf(el.trim()) !== -1)
;
} | javascript | function shouldCompressGzip(req) {
const headers = req.headers;
return headers && headers['accept-encoding'] &&
headers['accept-encoding']
.split(',')
.some(el => ['*', 'compress', 'gzip', 'deflate'].indexOf(el.trim()) !== -1)
;
} | [
"function",
"shouldCompressGzip",
"(",
"req",
")",
"{",
"const",
"headers",
"=",
"req",
".",
"headers",
";",
"return",
"headers",
"&&",
"headers",
"[",
"'accept-encoding'",
"]",
"&&",
"headers",
"[",
"'accept-encoding'",
"]",
".",
"split",
"(",
"','",
")",
... | Check to see if we should try to compress a file with gzip. | [
"Check",
"to",
"see",
"if",
"we",
"should",
"try",
"to",
"compress",
"a",
"file",
"with",
"gzip",
"."
] | ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75 | https://github.com/jfhbrook/node-ecstatic/blob/ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75/lib/ecstatic.js#L36-L44 | train |
jfhbrook/node-ecstatic | lib/ecstatic.js | tryServeWithGzip | function tryServeWithGzip() {
fs.stat(gzippedFile, (err, stat) => {
if (!err && stat.isFile()) {
hasGzipId12(gzippedFile, (gzipErr, isGzip) => {
if (!gzipErr && isGzip) {
file = gzippedFile;
serve(stat);
} else {
statFile();
... | javascript | function tryServeWithGzip() {
fs.stat(gzippedFile, (err, stat) => {
if (!err && stat.isFile()) {
hasGzipId12(gzippedFile, (gzipErr, isGzip) => {
if (!gzipErr && isGzip) {
file = gzippedFile;
serve(stat);
} else {
statFile();
... | [
"function",
"tryServeWithGzip",
"(",
")",
"{",
"fs",
".",
"stat",
"(",
"gzippedFile",
",",
"(",
"err",
",",
"stat",
")",
"=>",
"{",
"if",
"(",
"!",
"err",
"&&",
"stat",
".",
"isFile",
"(",
")",
")",
"{",
"hasGzipId12",
"(",
"gzippedFile",
",",
"(",... | serve gzip file if exists and is valid | [
"serve",
"gzip",
"file",
"if",
"exists",
"and",
"is",
"valid"
] | ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75 | https://github.com/jfhbrook/node-ecstatic/blob/ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75/lib/ecstatic.js#L433-L448 | train |
jfhbrook/node-ecstatic | lib/ecstatic.js | tryServeWithBrotli | function tryServeWithBrotli(shouldTryGzip) {
fs.stat(brotliFile, (err, stat) => {
if (!err && stat.isFile()) {
file = brotliFile;
serve(stat);
} else if (shouldTryGzip) {
tryServeWithGzip();
} else {
statFile();
}
});
} | javascript | function tryServeWithBrotli(shouldTryGzip) {
fs.stat(brotliFile, (err, stat) => {
if (!err && stat.isFile()) {
file = brotliFile;
serve(stat);
} else if (shouldTryGzip) {
tryServeWithGzip();
} else {
statFile();
}
});
} | [
"function",
"tryServeWithBrotli",
"(",
"shouldTryGzip",
")",
"{",
"fs",
".",
"stat",
"(",
"brotliFile",
",",
"(",
"err",
",",
"stat",
")",
"=>",
"{",
"if",
"(",
"!",
"err",
"&&",
"stat",
".",
"isFile",
"(",
")",
")",
"{",
"file",
"=",
"brotliFile",
... | serve brotli file if exists, otherwise try gzip | [
"serve",
"brotli",
"file",
"if",
"exists",
"otherwise",
"try",
"gzip"
] | ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75 | https://github.com/jfhbrook/node-ecstatic/blob/ae7a39b1ecdbe3aa8c0162ab2c3f7365bf9a6d75/lib/ecstatic.js#L451-L462 | train |
rauchg/slackin | lib/assets/superagent.js | getXHR | function getXHR () {
if (root.XMLHttpRequest
&& ('file:' != root.location.protocol || !root.ActiveXObject)) {
return new XMLHttpRequest
} else {
try { return new ActiveXObject('Microsoft.XMLHTTP') } catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0') } catch(e) {}
... | javascript | function getXHR () {
if (root.XMLHttpRequest
&& ('file:' != root.location.protocol || !root.ActiveXObject)) {
return new XMLHttpRequest
} else {
try { return new ActiveXObject('Microsoft.XMLHTTP') } catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0') } catch(e) {}
... | [
"function",
"getXHR",
"(",
")",
"{",
"if",
"(",
"root",
".",
"XMLHttpRequest",
"&&",
"(",
"'file:'",
"!=",
"root",
".",
"location",
".",
"protocol",
"||",
"!",
"root",
".",
"ActiveXObject",
")",
")",
"{",
"return",
"new",
"XMLHttpRequest",
"}",
"else",
... | Determine XHR. | [
"Determine",
"XHR",
"."
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/superagent.js#L446-L457 | train |
rauchg/slackin | lib/assets/superagent.js | params | function params (str){
return reduce(str.split(/ *; */), function (obj, str){
var parts = str.split(/ *= */),
key = parts.shift(),
val = parts.shift()
if (key && val) obj[key] = val
return obj
}, {})
} | javascript | function params (str){
return reduce(str.split(/ *; */), function (obj, str){
var parts = str.split(/ *= */),
key = parts.shift(),
val = parts.shift()
if (key && val) obj[key] = val
return obj
}, {})
} | [
"function",
"params",
"(",
"str",
")",
"{",
"return",
"reduce",
"(",
"str",
".",
"split",
"(",
"/",
" *; *",
"/",
")",
",",
"function",
"(",
"obj",
",",
"str",
")",
"{",
"var",
"parts",
"=",
"str",
".",
"split",
"(",
"/",
" *= *",
"/",
")",
","... | Return header field parameters.
@param {String} str
@return {Object}
@api private | [
"Return",
"header",
"field",
"parameters",
"."
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/superagent.js#L632-L641 | train |
rauchg/slackin | lib/assets/badge.js | search | function search (){
var replaced = 0
var scripts = document.querySelectorAll('script')
var script
for (var i = 0; i < scripts.length; i++) {
script = scripts[i]
if (!script.src) continue
if (/\/slackin\.js(\?.*)?$/.test(script.src)) {
// replace script with iframe
repla... | javascript | function search (){
var replaced = 0
var scripts = document.querySelectorAll('script')
var script
for (var i = 0; i < scripts.length; i++) {
script = scripts[i]
if (!script.src) continue
if (/\/slackin\.js(\?.*)?$/.test(script.src)) {
// replace script with iframe
repla... | [
"function",
"search",
"(",
")",
"{",
"var",
"replaced",
"=",
"0",
"var",
"scripts",
"=",
"document",
".",
"querySelectorAll",
"(",
"'script'",
")",
"var",
"script",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"scripts",
".",
"length",
";",
"i",
... | search for a script tag pointing to slackin.js | [
"search",
"for",
"a",
"script",
"tag",
"pointing",
"to",
"slackin",
".",
"js"
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/badge.js#L12-L29 | train |
rauchg/slackin | lib/assets/badge.js | replace | function replace (script){
var parent = script.parentNode
if (!parent) return
LARGE = /\?large/.test(script.src)
var iframe = document.createElement('iframe')
var iframePath = '/iframe' + (LARGE ? '?large' : '')
iframe.src = script.src.replace(/\/slackin\.js.*/, iframePath)
iframe.style.bor... | javascript | function replace (script){
var parent = script.parentNode
if (!parent) return
LARGE = /\?large/.test(script.src)
var iframe = document.createElement('iframe')
var iframePath = '/iframe' + (LARGE ? '?large' : '')
iframe.src = script.src.replace(/\/slackin\.js.*/, iframePath)
iframe.style.bor... | [
"function",
"replace",
"(",
"script",
")",
"{",
"var",
"parent",
"=",
"script",
".",
"parentNode",
"if",
"(",
"!",
"parent",
")",
"return",
"LARGE",
"=",
"/",
"\\?large",
"/",
".",
"test",
"(",
"script",
".",
"src",
")",
"var",
"iframe",
"=",
"docume... | replace the script tag with an iframe | [
"replace",
"the",
"script",
"tag",
"with",
"an",
"iframe"
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/badge.js#L34-L64 | train |
rauchg/slackin | lib/assets/badge.js | setup | function setup (iframe){
var id = Math.random() * (1 << 24) | 0
iframe.contentWindow.postMessage('slackin:' + id, '*')
window.addEventListener('message', function (e){
if (typeof e.data !== 'string') return
// show dialog upon click
if ('slackin-click:' + id === e.data) {
showDia... | javascript | function setup (iframe){
var id = Math.random() * (1 << 24) | 0
iframe.contentWindow.postMessage('slackin:' + id, '*')
window.addEventListener('message', function (e){
if (typeof e.data !== 'string') return
// show dialog upon click
if ('slackin-click:' + id === e.data) {
showDia... | [
"function",
"setup",
"(",
"iframe",
")",
"{",
"var",
"id",
"=",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"1",
"<<",
"24",
")",
"|",
"0",
"iframe",
".",
"contentWindow",
".",
"postMessage",
"(",
"'slackin:'",
"+",
"id",
",",
"'*'",
")",
"window",
... | setup an "RPC" channel between iframe and us | [
"setup",
"an",
"RPC",
"channel",
"between",
"iframe",
"and",
"us"
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/badge.js#L67-L94 | train |
rauchg/slackin | lib/badge.js | text | function text ({str, x, y}){
return [
svg(`text fill=#010101 fill-opacity=.3 x=${x} y=${y + 1}`, str),
svg(`text fill=#fff x=${x} y=${y}`, str)
]
} | javascript | function text ({str, x, y}){
return [
svg(`text fill=#010101 fill-opacity=.3 x=${x} y=${y + 1}`, str),
svg(`text fill=#fff x=${x} y=${y}`, str)
]
} | [
"function",
"text",
"(",
"{",
"str",
",",
"x",
",",
"y",
"}",
")",
"{",
"return",
"[",
"svg",
"(",
"`",
"${",
"x",
"}",
"${",
"y",
"+",
"1",
"}",
"`",
",",
"str",
")",
",",
"svg",
"(",
"`",
"${",
"x",
"}",
"${",
"y",
"}",
"`",
",",
"s... | generate text with 1px shadow | [
"generate",
"text",
"with",
"1px",
"shadow"
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/badge.js#L26-L31 | train |
rauchg/slackin | lib/assets/client.js | topLevelRedirect | function topLevelRedirect (url) {
if (window === top) location.href = url
else parent.postMessage('slackin-redirect:' + id + ':' + url, '*')
// Q: Why can't we just `top.location.href = url;`?
// A:
// [sandboxing]: http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
// [CSP]: http://www.html... | javascript | function topLevelRedirect (url) {
if (window === top) location.href = url
else parent.postMessage('slackin-redirect:' + id + ':' + url, '*')
// Q: Why can't we just `top.location.href = url;`?
// A:
// [sandboxing]: http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
// [CSP]: http://www.html... | [
"function",
"topLevelRedirect",
"(",
"url",
")",
"{",
"if",
"(",
"window",
"===",
"top",
")",
"location",
".",
"href",
"=",
"url",
"else",
"parent",
".",
"postMessage",
"(",
"'slackin-redirect:'",
"+",
"id",
"+",
"':'",
"+",
"url",
",",
"'*'",
")",
"//... | redirect, using "RPC" to parent if necessary | [
"redirect",
"using",
"RPC",
"to",
"parent",
"if",
"necessary"
] | fa88a860a87cf38d9a1c4007207e6efae4288242 | https://github.com/rauchg/slackin/blob/fa88a860a87cf38d9a1c4007207e6efae4288242/lib/assets/client.js#L89-L97 | train |
facebook/prop-types | factoryWithTypeCheckers.js | getClassName | function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
return ANONYMOUS;
}
return propValue.constructor.name;
} | javascript | function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
return ANONYMOUS;
}
return propValue.constructor.name;
} | [
"function",
"getClassName",
"(",
"propValue",
")",
"{",
"if",
"(",
"!",
"propValue",
".",
"constructor",
"||",
"!",
"propValue",
".",
"constructor",
".",
"name",
")",
"{",
"return",
"ANONYMOUS",
";",
"}",
"return",
"propValue",
".",
"constructor",
".",
"na... | Returns class name of the object, if any. | [
"Returns",
"class",
"name",
"of",
"the",
"object",
"if",
"any",
"."
] | e32c4900f5ab5fd3acea93e9d2f0d09e4a2f2ceb | https://github.com/facebook/prop-types/blob/e32c4900f5ab5fd3acea93e9d2f0d09e4a2f2ceb/factoryWithTypeCheckers.js#L598-L603 | train |
EddyVerbruggen/nativescript-plugin-firebase | publish/scripts/installer.js | writeBuildscriptHookForCrashlytics | function writeBuildscriptHookForCrashlytics(enable) {
var scriptPath = path.join(appRoot, "hooks", "after-prepare", "firebase-crashlytics-buildscript.js");
if (!enable) {
if (fs.existsSync(scriptPath)) {
fs.unlinkSync(scriptPath);
}
return
}
console.log("Install Crashlytics buildscript hook.... | javascript | function writeBuildscriptHookForCrashlytics(enable) {
var scriptPath = path.join(appRoot, "hooks", "after-prepare", "firebase-crashlytics-buildscript.js");
if (!enable) {
if (fs.existsSync(scriptPath)) {
fs.unlinkSync(scriptPath);
}
return
}
console.log("Install Crashlytics buildscript hook.... | [
"function",
"writeBuildscriptHookForCrashlytics",
"(",
"enable",
")",
"{",
"var",
"scriptPath",
"=",
"path",
".",
"join",
"(",
"appRoot",
",",
"\"hooks\"",
",",
"\"after-prepare\"",
",",
"\"firebase-crashlytics-buildscript.js\"",
")",
";",
"if",
"(",
"!",
"enable",
... | Create the iOS build script for uploading dSYM files to Crashlytics
@param {any} enable Is Crashlytics enabled | [
"Create",
"the",
"iOS",
"build",
"script",
"for",
"uploading",
"dSYM",
"files",
"to",
"Crashlytics"
] | e83ac1c4b6e18eb525ab6fb7ca6802f9cd3940ea | https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/e83ac1c4b6e18eb525ab6fb7ca6802f9cd3940ea/publish/scripts/installer.js#L462-L608 | train |
ethantw/Han | src/js/locale/h-ruby.js | renderSimpleRuby | function renderSimpleRuby( $ruby ) {
var frag = $.create( '!' )
var clazz = $ruby.classList
var $rb, $ru
frag.appendChild( $.clone( $ruby ))
$
.tag( 'rt', frag.firstChild )
.forEach(function( $rt ) {
var $rb = $.create( '!' )
var airb = []
var irb
// Consider the previous nodes the impl... | javascript | function renderSimpleRuby( $ruby ) {
var frag = $.create( '!' )
var clazz = $ruby.classList
var $rb, $ru
frag.appendChild( $.clone( $ruby ))
$
.tag( 'rt', frag.firstChild )
.forEach(function( $rt ) {
var $rb = $.create( '!' )
var airb = []
var irb
// Consider the previous nodes the impl... | [
"function",
"renderSimpleRuby",
"(",
"$ruby",
")",
"{",
"var",
"frag",
"=",
"$",
".",
"create",
"(",
"'!'",
")",
"var",
"clazz",
"=",
"$ruby",
".",
"classList",
"var",
"$rb",
",",
"$ru",
"frag",
".",
"appendChild",
"(",
"$",
".",
"clone",
"(",
"$ruby... | 1. Simple ruby polyfill; 2. Inter-character polyfill for Zhuyin | [
"1",
".",
"Simple",
"ruby",
"polyfill",
";",
"2",
".",
"Inter",
"-",
"character",
"polyfill",
"for",
"Zhuyin"
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/locale/h-ruby.js#L11-L46 | train |
ethantw/Han | src/js/locale/h-ruby.js | renderComplexRuby | function renderComplexRuby( $ruby ) {
var frag = $.create( '!' )
var clazz = $ruby.classList
var $cloned, $rb, $ru, maxspan
frag.appendChild( $.clone( $ruby ))
$cloned = frag.firstChild
$rb = $ru = $.tag( 'rb', $cloned )
maxspan = $rb.length
// First of all, deal with Zhuyin containers
// individua... | javascript | function renderComplexRuby( $ruby ) {
var frag = $.create( '!' )
var clazz = $ruby.classList
var $cloned, $rb, $ru, maxspan
frag.appendChild( $.clone( $ruby ))
$cloned = frag.firstChild
$rb = $ru = $.tag( 'rb', $cloned )
maxspan = $rb.length
// First of all, deal with Zhuyin containers
// individua... | [
"function",
"renderComplexRuby",
"(",
"$ruby",
")",
"{",
"var",
"frag",
"=",
"$",
".",
"create",
"(",
"'!'",
")",
"var",
"clazz",
"=",
"$ruby",
".",
"classList",
"var",
"$cloned",
",",
"$rb",
",",
"$ru",
",",
"maxspan",
"frag",
".",
"appendChild",
"(",... | 3. Complex ruby polyfill - Double-lined annotation; - Right-angled annotation. | [
"3",
".",
"Complex",
"ruby",
"polyfill",
"-",
"Double",
"-",
"lined",
"annotation",
";",
"-",
"Right",
"-",
"angled",
"annotation",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/locale/h-ruby.js#L79-L170 | train |
ethantw/Han | src/js/locale/h-ruby.js | getZhuyinHTML | function getZhuyinHTML( rt ) {
// #### Explanation ####
// * `zhuyin`: the entire phonetic annotation
// * `yin`: the plain pronunciation (w/out tone)
// * `diao`: the tone
// * `len`: the length of the plain pronunciation (`yin`)
var zhuyin = typeof rt === 'string' ? rt : rt.textContent
var yin, ... | javascript | function getZhuyinHTML( rt ) {
// #### Explanation ####
// * `zhuyin`: the entire phonetic annotation
// * `yin`: the plain pronunciation (w/out tone)
// * `diao`: the tone
// * `len`: the length of the plain pronunciation (`yin`)
var zhuyin = typeof rt === 'string' ? rt : rt.textContent
var yin, ... | [
"function",
"getZhuyinHTML",
"(",
"rt",
")",
"{",
"// #### Explanation ####",
"// * `zhuyin`: the entire phonetic annotation",
"// * `yin`: the plain pronunciation (w/out tone)",
"// * `diao`: the tone",
"// * `len`: the length of the plain pronunciation (`yin`)",
"var",
"zhuyin",
... | Create a Zhuyin-form HTML string | [
"Create",
"a",
"Zhuyin",
"-",
"form",
"HTML",
"string"
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/locale/h-ruby.js#L246-L262 | train |
ethantw/Han | src/js/method.js | function( target, attr ) {
if ( typeof attr !== 'object' ) return
var len = attr.length
// Native `NamedNodeMap``:
if (
typeof attr[0] === 'object' &&
'name' in attr[0]
) {
for ( var i = 0; i < len; i++ ) {
if ( attr[ i ].value !== undefined ) {
target.setAttrib... | javascript | function( target, attr ) {
if ( typeof attr !== 'object' ) return
var len = attr.length
// Native `NamedNodeMap``:
if (
typeof attr[0] === 'object' &&
'name' in attr[0]
) {
for ( var i = 0; i < len; i++ ) {
if ( attr[ i ].value !== undefined ) {
target.setAttrib... | [
"function",
"(",
"target",
",",
"attr",
")",
"{",
"if",
"(",
"typeof",
"attr",
"!==",
"'object'",
")",
"return",
"var",
"len",
"=",
"attr",
".",
"length",
"// Native `NamedNodeMap``:",
"if",
"(",
"typeof",
"attr",
"[",
"0",
"]",
"===",
"'object'",
"&&",
... | Set attributes all in once with an object. | [
"Set",
"attributes",
"all",
"in",
"once",
"with",
"an",
"object",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/method.js#L91-L118 | train | |
ethantw/Han | src/js/method.js | function( target, object ) {
if ((
typeof target === 'object' ||
typeof target === 'function' ) &&
typeof object === 'object'
) {
for ( var name in object ) {
if (object.hasOwnProperty( name )) {
target[ name ] = object[ name ]
}
}
}
return target
... | javascript | function( target, object ) {
if ((
typeof target === 'object' ||
typeof target === 'function' ) &&
typeof object === 'object'
) {
for ( var name in object ) {
if (object.hasOwnProperty( name )) {
target[ name ] = object[ name ]
}
}
}
return target
... | [
"function",
"(",
"target",
",",
"object",
")",
"{",
"if",
"(",
"(",
"typeof",
"target",
"===",
"'object'",
"||",
"typeof",
"target",
"===",
"'function'",
")",
"&&",
"typeof",
"object",
"===",
"'object'",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"obje... | Extend target with an object. | [
"Extend",
"target",
"with",
"an",
"object",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/method.js#L151-L164 | train | |
ethantw/Han | src/lib/fibre.js/index.js | function() {
var match
var matchIndex = 0
var offset = 0
var regex = this.options.find
var textAggregation = this.getAggregateText()
var matches = []
var self = this
regex = typeof regex === 'string' ? RegExp(escapeRegExp(regex), 'g') : regex
matchAggregation(textA... | javascript | function() {
var match
var matchIndex = 0
var offset = 0
var regex = this.options.find
var textAggregation = this.getAggregateText()
var matches = []
var self = this
regex = typeof regex === 'string' ? RegExp(escapeRegExp(regex), 'g') : regex
matchAggregation(textA... | [
"function",
"(",
")",
"{",
"var",
"match",
"var",
"matchIndex",
"=",
"0",
"var",
"offset",
"=",
"0",
"var",
"regex",
"=",
"this",
".",
"options",
".",
"find",
"var",
"textAggregation",
"=",
"this",
".",
"getAggregateText",
"(",
")",
"var",
"matches",
"... | Searches for all matches that comply with the instance's 'match' option | [
"Searches",
"for",
"all",
"matches",
"that",
"comply",
"with",
"the",
"instance",
"s",
"match",
"option"
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/lib/fibre.js/index.js#L368-L404 | train | |
ethantw/Han | src/lib/fibre.js/index.js | function() {
var elementFilter = this.options.filterElements
var forceContext = this.options.forceContext
return getText(this.node)
/**
* Gets aggregate text of a node without resorting
* to broken innerText/textContent
*/
function getText(node, txt) {
if (no... | javascript | function() {
var elementFilter = this.options.filterElements
var forceContext = this.options.forceContext
return getText(this.node)
/**
* Gets aggregate text of a node without resorting
* to broken innerText/textContent
*/
function getText(node, txt) {
if (no... | [
"function",
"(",
")",
"{",
"var",
"elementFilter",
"=",
"this",
".",
"options",
".",
"filterElements",
"var",
"forceContext",
"=",
"this",
".",
"options",
".",
"forceContext",
"return",
"getText",
"(",
"this",
".",
"node",
")",
"/**\n * Gets aggregate text... | Gets aggregate text within subject node | [
"Gets",
"aggregate",
"text",
"within",
"subject",
"node"
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/lib/fibre.js/index.js#L424-L476 | train | |
ethantw/Han | src/lib/fibre.js/index.js | function() {
var matches = this.matches
var node = this.node
var elementFilter = this.options.filterElements
var startPortion,
endPortion,
innerPortions = [],
curNode = node,
match = matches.shift(),
atIndex = 0, // i.e. nodeAtIndex
matchIndex = 0... | javascript | function() {
var matches = this.matches
var node = this.node
var elementFilter = this.options.filterElements
var startPortion,
endPortion,
innerPortions = [],
curNode = node,
match = matches.shift(),
atIndex = 0, // i.e. nodeAtIndex
matchIndex = 0... | [
"function",
"(",
")",
"{",
"var",
"matches",
"=",
"this",
".",
"matches",
"var",
"node",
"=",
"this",
".",
"node",
"var",
"elementFilter",
"=",
"this",
".",
"options",
".",
"filterElements",
"var",
"startPortion",
",",
"endPortion",
",",
"innerPortions",
"... | Steps through the target node, looking for matches, and
calling replaceFn when a match is found. | [
"Steps",
"through",
"the",
"target",
"node",
"looking",
"for",
"matches",
"and",
"calling",
"replaceFn",
"when",
"a",
"match",
"is",
"found",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/lib/fibre.js/index.js#L482-L586 | train | |
ethantw/Han | src/js/core.js | function( routine ) {
var it = this
var routine = Array.isArray( routine )
? routine
: this.routine
routine
.forEach(function( method ) {
if (
typeof method === 'string' &&
typeof it[ method ] === 'function'
) {
it[ method ]()
} else if (
... | javascript | function( routine ) {
var it = this
var routine = Array.isArray( routine )
? routine
: this.routine
routine
.forEach(function( method ) {
if (
typeof method === 'string' &&
typeof it[ method ] === 'function'
) {
it[ method ]()
} else if (
... | [
"function",
"(",
"routine",
")",
"{",
"var",
"it",
"=",
"this",
"var",
"routine",
"=",
"Array",
".",
"isArray",
"(",
"routine",
")",
"?",
"routine",
":",
"this",
".",
"routine",
"routine",
".",
"forEach",
"(",
"function",
"(",
"method",
")",
"{",
"if... | Note that the routine set up here will execute only once. The method won't alter the routine in the instance or in the prototype chain. | [
"Note",
"that",
"the",
"routine",
"set",
"up",
"here",
"will",
"execute",
"only",
"once",
".",
"The",
"method",
"won",
"t",
"alter",
"the",
"routine",
"in",
"the",
"instance",
"or",
"in",
"the",
"prototype",
"chain",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/core.js#L80-L101 | train | |
ethantw/Han | src/js/find.js | function( selector ) {
return (
this
.filter( selector || null )
.avoid( 'h-jinze' )
.replace(
TYPESET.jinze.touwei,
function( portion, match ) {
var elem = $.create( 'h-jinze', 'touwei' )
elem.innerHTML = match[0]
return (( portion.index === 0 && portion.isEnd ) ... | javascript | function( selector ) {
return (
this
.filter( selector || null )
.avoid( 'h-jinze' )
.replace(
TYPESET.jinze.touwei,
function( portion, match ) {
var elem = $.create( 'h-jinze', 'touwei' )
elem.innerHTML = match[0]
return (( portion.index === 0 && portion.isEnd ) ... | [
"function",
"(",
"selector",
")",
"{",
"return",
"(",
"this",
".",
"filter",
"(",
"selector",
"||",
"null",
")",
".",
"avoid",
"(",
"'h-jinze'",
")",
".",
"replace",
"(",
"TYPESET",
".",
"jinze",
".",
"touwei",
",",
"function",
"(",
"portion",
",",
"... | Force punctuation & biaodian typesetting rules to be applied. | [
"Force",
"punctuation",
"&",
"biaodian",
"typesetting",
"rules",
"to",
"be",
"applied",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/find.js#L86-L128 | train | |
ethantw/Han | src/js/locale/normalize.js | function( context, target ) {
var $$target = $.qsa( target || 'u, ins', context )
var i = $$target.length
traverse: while ( i-- ) {
var $this = $$target[ i ]
var $prev = null
// Ignore all `<wbr>` and comments in between,
// and add class `.adjacent` once two targets
// are n... | javascript | function( context, target ) {
var $$target = $.qsa( target || 'u, ins', context )
var i = $$target.length
traverse: while ( i-- ) {
var $this = $$target[ i ]
var $prev = null
// Ignore all `<wbr>` and comments in between,
// and add class `.adjacent` once two targets
// are n... | [
"function",
"(",
"context",
",",
"target",
")",
"{",
"var",
"$$target",
"=",
"$",
".",
"qsa",
"(",
"target",
"||",
"'u, ins'",
",",
"context",
")",
"var",
"i",
"=",
"$$target",
".",
"length",
"traverse",
":",
"while",
"(",
"i",
"--",
")",
"{",
"var... | Traverse all target elements and address presentational corrections if any two of them are adjacent to each other. | [
"Traverse",
"all",
"target",
"elements",
"and",
"address",
"presentational",
"corrections",
"if",
"any",
"two",
"of",
"them",
"are",
"adjacent",
"to",
"each",
"other",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/locale/normalize.js#L27-L48 | train | |
ethantw/Han | src/js/locale/normalize.js | function( context, target ) {
var method = target ? 'qsa' : 'tag'
var target = target || 'em'
var $target = $[ method ]( target, context )
$target
.forEach(function( elem ) {
var $elem = Han( elem )
if ( Locale.support.textemphasis ) {
$elem
.avoid( 'rt, h-char' )
... | javascript | function( context, target ) {
var method = target ? 'qsa' : 'tag'
var target = target || 'em'
var $target = $[ method ]( target, context )
$target
.forEach(function( elem ) {
var $elem = Han( elem )
if ( Locale.support.textemphasis ) {
$elem
.avoid( 'rt, h-char' )
... | [
"function",
"(",
"context",
",",
"target",
")",
"{",
"var",
"method",
"=",
"target",
"?",
"'qsa'",
":",
"'tag'",
"var",
"target",
"=",
"target",
"||",
"'em'",
"var",
"$target",
"=",
"$",
"[",
"method",
"]",
"(",
"target",
",",
"context",
")",
"$targe... | Traverse all target elements to render emphasis marks. | [
"Traverse",
"all",
"target",
"elements",
"to",
"render",
"emphasis",
"marks",
"."
] | 940014b48dded1eaa7fa92fa5a09d9cfc96429a9 | https://github.com/ethantw/Han/blob/940014b48dded1eaa7fa92fa5a09d9cfc96429a9/src/js/locale/normalize.js#L52-L80 | train | |
fable-compiler/Fable | src/fable-library/Types.js | inherits | function inherits(subClass, superClass) {
// if (typeof superClass !== "function" && superClass !== null) {
// throw new TypeError(
// "Super expression must either be null or a function, not " +
// typeof superClass
// );
// }
subClass.prototype = Object.create(superClass && superClass.prot... | javascript | function inherits(subClass, superClass) {
// if (typeof superClass !== "function" && superClass !== null) {
// throw new TypeError(
// "Super expression must either be null or a function, not " +
// typeof superClass
// );
// }
subClass.prototype = Object.create(superClass && superClass.prot... | [
"function",
"inherits",
"(",
"subClass",
",",
"superClass",
")",
"{",
"// if (typeof superClass !== \"function\" && superClass !== null) {",
"// throw new TypeError(",
"// \"Super expression must either be null or a function, not \" +",
"// typeof superClass",
"// );",
"// }"... | Taken from Babel helpers | [
"Taken",
"from",
"Babel",
"helpers"
] | de59950a5c1ee3f8294bc67b1aeb3961538b464a | https://github.com/fable-compiler/Fable/blob/de59950a5c1ee3f8294bc67b1aeb3961538b464a/src/fable-library/Types.js#L8-L27 | train |
developit/preact-router | src/index.js | canRoute | function canRoute(url) {
for (let i=ROUTERS.length; i--; ) {
if (ROUTERS[i].canRoute(url)) return true;
}
return false;
} | javascript | function canRoute(url) {
for (let i=ROUTERS.length; i--; ) {
if (ROUTERS[i].canRoute(url)) return true;
}
return false;
} | [
"function",
"canRoute",
"(",
"url",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"ROUTERS",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"if",
"(",
"ROUTERS",
"[",
"i",
"]",
".",
"canRoute",
"(",
"url",
")",
")",
"return",
"true",
";",
"}",
"return"... | Check if the given URL can be handled by any router instances. | [
"Check",
"if",
"the",
"given",
"URL",
"can",
"be",
"handled",
"by",
"any",
"router",
"instances",
"."
] | ef8983acdd87b55792e20cdc56401dda0ed80e3f | https://github.com/developit/preact-router/blob/ef8983acdd87b55792e20cdc56401dda0ed80e3f/src/index.js#L54-L59 | train |
developit/preact-router | src/index.js | routeTo | function routeTo(url) {
let didRoute = false;
for (let i=0; i<ROUTERS.length; i++) {
if (ROUTERS[i].routeTo(url)===true) {
didRoute = true;
}
}
for (let i=subscribers.length; i--; ) {
subscribers[i](url);
}
return didRoute;
} | javascript | function routeTo(url) {
let didRoute = false;
for (let i=0; i<ROUTERS.length; i++) {
if (ROUTERS[i].routeTo(url)===true) {
didRoute = true;
}
}
for (let i=subscribers.length; i--; ) {
subscribers[i](url);
}
return didRoute;
} | [
"function",
"routeTo",
"(",
"url",
")",
"{",
"let",
"didRoute",
"=",
"false",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"ROUTERS",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ROUTERS",
"[",
"i",
"]",
".",
"routeTo",
"(",
... | Tell all router instances to handle the given URL. | [
"Tell",
"all",
"router",
"instances",
"to",
"handle",
"the",
"given",
"URL",
"."
] | ef8983acdd87b55792e20cdc56401dda0ed80e3f | https://github.com/developit/preact-router/blob/ef8983acdd87b55792e20cdc56401dda0ed80e3f/src/index.js#L63-L74 | train |
patrick-steele-idem/morphdom | dist/morphdom-esm.js | compareNodeNames | function compareNodeNames(fromEl, toEl) {
var fromNodeName = fromEl.nodeName;
var toNodeName = toEl.nodeName;
if (fromNodeName === toNodeName) {
return true;
}
if (toEl.actualize &&
fromNodeName.charCodeAt(0) < 91 && /* from tag name is upper case */
toNodeName.charCodeAt(0... | javascript | function compareNodeNames(fromEl, toEl) {
var fromNodeName = fromEl.nodeName;
var toNodeName = toEl.nodeName;
if (fromNodeName === toNodeName) {
return true;
}
if (toEl.actualize &&
fromNodeName.charCodeAt(0) < 91 && /* from tag name is upper case */
toNodeName.charCodeAt(0... | [
"function",
"compareNodeNames",
"(",
"fromEl",
",",
"toEl",
")",
"{",
"var",
"fromNodeName",
"=",
"fromEl",
".",
"nodeName",
";",
"var",
"toNodeName",
"=",
"toEl",
".",
"nodeName",
";",
"if",
"(",
"fromNodeName",
"===",
"toNodeName",
")",
"{",
"return",
"t... | Returns true if two node's names are the same.
NOTE: We don't bother checking `namespaceURI` because you will never find two HTML elements with the same
nodeName and different namespace URIs.
@param {Element} a
@param {Element} b The target element
@return {boolean} | [
"Returns",
"true",
"if",
"two",
"node",
"s",
"names",
"are",
"the",
"same",
"."
] | da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7 | https://github.com/patrick-steele-idem/morphdom/blob/da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7/dist/morphdom-esm.js#L97-L115 | train |
patrick-steele-idem/morphdom | dist/morphdom-esm.js | createElementNS | function createElementNS(name, namespaceURI) {
return !namespaceURI || namespaceURI === NS_XHTML ?
doc.createElement(name) :
doc.createElementNS(namespaceURI, name);
} | javascript | function createElementNS(name, namespaceURI) {
return !namespaceURI || namespaceURI === NS_XHTML ?
doc.createElement(name) :
doc.createElementNS(namespaceURI, name);
} | [
"function",
"createElementNS",
"(",
"name",
",",
"namespaceURI",
")",
"{",
"return",
"!",
"namespaceURI",
"||",
"namespaceURI",
"===",
"NS_XHTML",
"?",
"doc",
".",
"createElement",
"(",
"name",
")",
":",
"doc",
".",
"createElementNS",
"(",
"namespaceURI",
",",... | Create an element, optionally with a known namespace URI.
@param {string} name the element name, e.g. 'div' or 'svg'
@param {string} [namespaceURI] the element's namespace URI, i.e. the value of
its `xmlns` attribute or its inferred namespace.
@return {Element} | [
"Create",
"an",
"element",
"optionally",
"with",
"a",
"known",
"namespace",
"URI",
"."
] | da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7 | https://github.com/patrick-steele-idem/morphdom/blob/da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7/dist/morphdom-esm.js#L126-L130 | train |
patrick-steele-idem/morphdom | dist/morphdom-esm.js | moveChildren | function moveChildren(fromEl, toEl) {
var curChild = fromEl.firstChild;
while (curChild) {
var nextChild = curChild.nextSibling;
toEl.appendChild(curChild);
curChild = nextChild;
}
return toEl;
} | javascript | function moveChildren(fromEl, toEl) {
var curChild = fromEl.firstChild;
while (curChild) {
var nextChild = curChild.nextSibling;
toEl.appendChild(curChild);
curChild = nextChild;
}
return toEl;
} | [
"function",
"moveChildren",
"(",
"fromEl",
",",
"toEl",
")",
"{",
"var",
"curChild",
"=",
"fromEl",
".",
"firstChild",
";",
"while",
"(",
"curChild",
")",
"{",
"var",
"nextChild",
"=",
"curChild",
".",
"nextSibling",
";",
"toEl",
".",
"appendChild",
"(",
... | Copies the children of one DOM element to another DOM element | [
"Copies",
"the",
"children",
"of",
"one",
"DOM",
"element",
"to",
"another",
"DOM",
"element"
] | da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7 | https://github.com/patrick-steele-idem/morphdom/blob/da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7/dist/morphdom-esm.js#L135-L143 | train |
patrick-steele-idem/morphdom | dist/morphdom-esm.js | removeNode | function removeNode(node, parentNode, skipKeyedNodes) {
if (onBeforeNodeDiscarded(node) === false) {
return;
}
if (parentNode) {
parentNode.removeChild(node);
}
onNodeDiscarded(node);
walkDiscardedChildNodes(node, ... | javascript | function removeNode(node, parentNode, skipKeyedNodes) {
if (onBeforeNodeDiscarded(node) === false) {
return;
}
if (parentNode) {
parentNode.removeChild(node);
}
onNodeDiscarded(node);
walkDiscardedChildNodes(node, ... | [
"function",
"removeNode",
"(",
"node",
",",
"parentNode",
",",
"skipKeyedNodes",
")",
"{",
"if",
"(",
"onBeforeNodeDiscarded",
"(",
"node",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"parentNode",
")",
"{",
"parentNode",
".",
"removeChil... | Removes a DOM node out of the original DOM
@param {Node} node The node to remove
@param {Node} parentNode The nodes parent
@param {Boolean} skipKeyedNodes If true then elements with keys will be skipped and not discarded.
@return {undefined} | [
"Removes",
"a",
"DOM",
"node",
"out",
"of",
"the",
"original",
"DOM"
] | da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7 | https://github.com/patrick-steele-idem/morphdom/blob/da08ab419ae21d305bc5cfb38f2f3d6c2152d1c7/dist/morphdom-esm.js#L340-L351 | train |
23/resumable.js | resumable.js | processCallbacks | function processCallbacks(items, cb){
if(!items || items.length === 0){
// empty or no list, invoke callback
return cb();
}
// invoke current function, pass the next part as continuation
items[0](function(){
processCallbacks(items.slice(1), cb);
});
} | javascript | function processCallbacks(items, cb){
if(!items || items.length === 0){
// empty or no list, invoke callback
return cb();
}
// invoke current function, pass the next part as continuation
items[0](function(){
processCallbacks(items.slice(1), cb);
});
} | [
"function",
"processCallbacks",
"(",
"items",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"items",
"||",
"items",
".",
"length",
"===",
"0",
")",
"{",
"// empty or no list, invoke callback",
"return",
"cb",
"(",
")",
";",
"}",
"// invoke current function, pass the next... | cps-style list iteration.
invokes all functions in list and waits for their callback to be
triggered.
@param {Function[]} items list of functions expecting callback parameter
@param {Function} cb callback to trigger after the last callback has been invoked | [
"cps",
"-",
"style",
"list",
"iteration",
".",
"invokes",
"all",
"functions",
"in",
"list",
"and",
"waits",
"for",
"their",
"callback",
"to",
"be",
"triggered",
"."
] | 247f339c4a30e10f559a2770a5a0030de0be9363 | https://github.com/23/resumable.js/blob/247f339c4a30e10f559a2770a5a0030de0be9363/resumable.js#L300-L309 | train |
23/resumable.js | resumable.js | processDirectory | function processDirectory (directory, path, items, cb) {
var dirReader = directory.createReader();
var allEntries = [];
function readEntries () {
dirReader.readEntries(function(entries){
if (entries.length) {
allEntries = allEntries.concat(entries);
return re... | javascript | function processDirectory (directory, path, items, cb) {
var dirReader = directory.createReader();
var allEntries = [];
function readEntries () {
dirReader.readEntries(function(entries){
if (entries.length) {
allEntries = allEntries.concat(entries);
return re... | [
"function",
"processDirectory",
"(",
"directory",
",",
"path",
",",
"items",
",",
"cb",
")",
"{",
"var",
"dirReader",
"=",
"directory",
".",
"createReader",
"(",
")",
";",
"var",
"allEntries",
"=",
"[",
"]",
";",
"function",
"readEntries",
"(",
")",
"{",... | recursively traverse directory and collect files to upload
@param {Object} directory directory to process
@param {string} path current path
@param {File[]} items target list of items
@param {Function} cb callback invoked after traversing directory | [
"recursively",
"traverse",
"directory",
"and",
"collect",
"files",
"to",
"upload"
] | 247f339c4a30e10f559a2770a5a0030de0be9363 | https://github.com/23/resumable.js/blob/247f339c4a30e10f559a2770a5a0030de0be9363/resumable.js#L318-L341 | train |
23/resumable.js | resumable.js | loadFiles | function loadFiles(items, event) {
if(!items.length){
return; // nothing to do
}
$.fire('beforeAdd');
var files = [];
processCallbacks(
Array.prototype.map.call(items, function(item){
// bind all properties except for callback
var entry = item;
... | javascript | function loadFiles(items, event) {
if(!items.length){
return; // nothing to do
}
$.fire('beforeAdd');
var files = [];
processCallbacks(
Array.prototype.map.call(items, function(item){
// bind all properties except for callback
var entry = item;
... | [
"function",
"loadFiles",
"(",
"items",
",",
"event",
")",
"{",
"if",
"(",
"!",
"items",
".",
"length",
")",
"{",
"return",
";",
"// nothing to do",
"}",
"$",
".",
"fire",
"(",
"'beforeAdd'",
")",
";",
"var",
"files",
"=",
"[",
"]",
";",
"processCallb... | process items to extract files to be uploaded
@param {File[]} items items to process
@param {Event} event event that led to upload | [
"process",
"items",
"to",
"extract",
"files",
"to",
"be",
"uploaded"
] | 247f339c4a30e10f559a2770a5a0030de0be9363 | https://github.com/23/resumable.js/blob/247f339c4a30e10f559a2770a5a0030de0be9363/resumable.js#L348-L370 | train |
TerriaJS/terriajs | lib/Map/SummaryConcept.js | function(name, options) {
name = defaultValue(name, "Conditions");
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
DisplayVariablesConcept.call(this, name, options);
} | javascript | function(name, options) {
name = defaultValue(name, "Conditions");
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
DisplayVariablesConcept.call(this, name, options);
} | [
"function",
"(",
"name",
",",
"options",
")",
"{",
"name",
"=",
"defaultValue",
"(",
"name",
",",
"\"Conditions\"",
")",
";",
"options",
"=",
"defaultValue",
"(",
"options",
",",
"defaultValue",
".",
"EMPTY_OBJECT",
")",
";",
"DisplayVariablesConcept",
".",
... | Represents the top-level node of a tree which should be displayed using
a different UX to the more usual DisplayVariablesConcept.
Intended for use when the tree is huge, and would take up too much space in the UI.
Contains an items array of Concepts.
@alias SummaryConcept
@constructor
@extends DisplayVariablesConcept
... | [
"Represents",
"the",
"top",
"-",
"level",
"node",
"of",
"a",
"tree",
"which",
"should",
"be",
"displayed",
"using",
"a",
"different",
"UX",
"to",
"the",
"more",
"usual",
"DisplayVariablesConcept",
".",
"Intended",
"for",
"use",
"when",
"the",
"tree",
"is",
... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/SummaryConcept.js#L22-L27 | train | |
TerriaJS/terriajs | lib/Map/SummaryConcept.js | closeDescendants | function closeDescendants(concept) {
concept.isOpen = false;
concept.items.forEach(child => {
if (child.items) {
closeDescendants(child);
}
});
} | javascript | function closeDescendants(concept) {
concept.isOpen = false;
concept.items.forEach(child => {
if (child.items) {
closeDescendants(child);
}
});
} | [
"function",
"closeDescendants",
"(",
"concept",
")",
"{",
"concept",
".",
"isOpen",
"=",
"false",
";",
"concept",
".",
"items",
".",
"forEach",
"(",
"child",
"=>",
"{",
"if",
"(",
"child",
".",
"items",
")",
"{",
"closeDescendants",
"(",
"child",
")",
... | Traverses the concepts' descendants, setting isOpen = false as it goes. | [
"Traverses",
"the",
"concepts",
"descendants",
"setting",
"isOpen",
"=",
"false",
"as",
"it",
"goes",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/SummaryConcept.js#L39-L46 | train |
TerriaJS/terriajs | lib/Models/CatalogFunction.js | function(terria) {
CatalogMember.call(this, terria);
this._loadingPromise = undefined;
this._lastLoadInfluencingValues = undefined;
this._parameters = [];
/**
* Gets or sets a value indicating whether the group is currently loading. This property
* is observable.
* @type {Boolean}
*/
this.isL... | javascript | function(terria) {
CatalogMember.call(this, terria);
this._loadingPromise = undefined;
this._lastLoadInfluencingValues = undefined;
this._parameters = [];
/**
* Gets or sets a value indicating whether the group is currently loading. This property
* is observable.
* @type {Boolean}
*/
this.isL... | [
"function",
"(",
"terria",
")",
"{",
"CatalogMember",
".",
"call",
"(",
"this",
",",
"terria",
")",
";",
"this",
".",
"_loadingPromise",
"=",
"undefined",
";",
"this",
".",
"_lastLoadInfluencingValues",
"=",
"undefined",
";",
"this",
".",
"_parameters",
"=",... | A member of a catalog that does some kind of parameterized processing or analysis.
@alias CatalogFunction
@constructor
@extends CatalogMember
@abstract
@param {Terria} terria The Terria instance. | [
"A",
"member",
"of",
"a",
"catalog",
"that",
"does",
"some",
"kind",
"of",
"parameterized",
"processing",
"or",
"analysis",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/CatalogFunction.js#L28-L50 | train | |
TerriaJS/terriajs | lib/Core/replaceUnderscores.js | replaceUnderscores | function replaceUnderscores(string) {
if (typeof string === "string" || string instanceof String) {
return string.replace(/_/g, " ");
}
return string;
} | javascript | function replaceUnderscores(string) {
if (typeof string === "string" || string instanceof String) {
return string.replace(/_/g, " ");
}
return string;
} | [
"function",
"replaceUnderscores",
"(",
"string",
")",
"{",
"if",
"(",
"typeof",
"string",
"===",
"\"string\"",
"||",
"string",
"instanceof",
"String",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"/",
"_",
"/",
"g",
",",
"\" \"",
")",
";",
"}",
"... | Replace all underscores in the string with spaces. If the argument is not a string, return it unchanged.
@param {} string The string to replace. If the argument is not a string, does nothing.
@return {} The argument with all underscores replaced with spaces. If the argument is not a string, returns the argument unchan... | [
"Replace",
"all",
"underscores",
"in",
"the",
"string",
"with",
"spaces",
".",
"If",
"the",
"argument",
"is",
"not",
"a",
"string",
"return",
"it",
"unchanged",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Core/replaceUnderscores.js#L8-L13 | train |
TerriaJS/terriajs | lib/Models/SensorObservationServiceCatalogItem.js | extractValues | function extractValues(response) {
var observationData =
response.GetObservationResponse &&
response.GetObservationResponse.observationData;
if (defined(observationData)) {
if (!Array.isArray(observationData)) {
observationData = [observationData];
}
var observations = obse... | javascript | function extractValues(response) {
var observationData =
response.GetObservationResponse &&
response.GetObservationResponse.observationData;
if (defined(observationData)) {
if (!Array.isArray(observationData)) {
observationData = [observationData];
}
var observations = obse... | [
"function",
"extractValues",
"(",
"response",
")",
"{",
"var",
"observationData",
"=",
"response",
".",
"GetObservationResponse",
"&&",
"response",
".",
"GetObservationResponse",
".",
"observationData",
";",
"if",
"(",
"defined",
"(",
"observationData",
")",
")",
... | Iterate over all the points in all the time series in all the observations in all the bodies to get individual result rows. | [
"Iterate",
"over",
"all",
"the",
"points",
"in",
"all",
"the",
"time",
"series",
"in",
"all",
"the",
"observations",
"in",
"all",
"the",
"bodies",
"to",
"get",
"individual",
"result",
"rows",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SensorObservationServiceCatalogItem.js#L527-L572 | train |
TerriaJS/terriajs | lib/Models/SensorObservationServiceCatalogItem.js | loadObservationData | function loadObservationData(item) {
if (!item._featureMapping) {
return;
}
var featuresOfInterest = Object.keys(item._featureMapping);
// Are there too many features to load observations (or we've been asked not to try)?
if (
!item.tryToLoadObservationData ||
featuresOfInterest.length > item.requ... | javascript | function loadObservationData(item) {
if (!item._featureMapping) {
return;
}
var featuresOfInterest = Object.keys(item._featureMapping);
// Are there too many features to load observations (or we've been asked not to try)?
if (
!item.tryToLoadObservationData ||
featuresOfInterest.length > item.requ... | [
"function",
"loadObservationData",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"item",
".",
"_featureMapping",
")",
"{",
"return",
";",
"}",
"var",
"featuresOfInterest",
"=",
"Object",
".",
"keys",
"(",
"item",
".",
"_featureMapping",
")",
";",
"// Are there too ... | Given the features already loaded into item._featureMap, this loads the observations according to the user-selected concepts,
and puts them into item._tableStructure.
If there are too many features, fall back to a tableStructure without the observation data.
@param {SensorObservationServiceCatalogItem} item This catal... | [
"Given",
"the",
"features",
"already",
"loaded",
"into",
"item",
".",
"_featureMap",
"this",
"loads",
"the",
"observations",
"according",
"to",
"the",
"user",
"-",
"selected",
"concepts",
"and",
"puts",
"them",
"into",
"item",
".",
"_tableStructure",
".",
"If"... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SensorObservationServiceCatalogItem.js#L851-L948 | train |
TerriaJS/terriajs | lib/Models/SensorObservationServiceCatalogItem.js | createColumnsFromMapping | function createColumnsFromMapping(item, tableStructure, identifiers) {
var featureMapping = item._featureMapping;
var addChartColumn = !defined(identifiers);
if (!defined(identifiers)) {
identifiers = Object.keys(featureMapping);
}
var rows = identifiers.map(identifier => featureMapping[identifier]);
va... | javascript | function createColumnsFromMapping(item, tableStructure, identifiers) {
var featureMapping = item._featureMapping;
var addChartColumn = !defined(identifiers);
if (!defined(identifiers)) {
identifiers = Object.keys(featureMapping);
}
var rows = identifiers.map(identifier => featureMapping[identifier]);
va... | [
"function",
"createColumnsFromMapping",
"(",
"item",
",",
"tableStructure",
",",
"identifiers",
")",
"{",
"var",
"featureMapping",
"=",
"item",
".",
"_featureMapping",
";",
"var",
"addChartColumn",
"=",
"!",
"defined",
"(",
"identifiers",
")",
";",
"if",
"(",
... | Converts the featureMapping output by createMappingFromFeatureMembers into columns for a TableStructure.
@param {SensorObservationServiceCatalogItem} item This catalog item.
@param {TableStructure} [tableStructure] Used to set the columns' tableStructure (parent). If identifiers given, output columns line up with the... | [
"Converts",
"the",
"featureMapping",
"output",
"by",
"createMappingFromFeatureMembers",
"into",
"columns",
"for",
"a",
"TableStructure",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SensorObservationServiceCatalogItem.js#L1066-L1103 | train |
TerriaJS/terriajs | lib/Models/AugmentedVirtuality.js | function(terria) {
const that = this;
this._terria = terria;
// Note: We create a persistant object and define a transient property, since knockout needs a persistant variable
// to track, but for state we want a 'maybe' intervalId.
this._eventLoopState = {};
this._manualAlignment = false;
this.... | javascript | function(terria) {
const that = this;
this._terria = terria;
// Note: We create a persistant object and define a transient property, since knockout needs a persistant variable
// to track, but for state we want a 'maybe' intervalId.
this._eventLoopState = {};
this._manualAlignment = false;
this.... | [
"function",
"(",
"terria",
")",
"{",
"const",
"that",
"=",
"this",
";",
"this",
".",
"_terria",
"=",
"terria",
";",
"// Note: We create a persistant object and define a transient property, since knockout needs a persistant variable",
"// to track, but for state we want a 'may... | Manages state for Augmented Virtuality mode.
This mode uses the devices orientation sensors to change the viewers viewport to match the change in orientation.
Term Augmented Virtuality:
"The use of real-world sensor information (e.g., gyroscopes) to control a virtual environment is an additional form
of augmented vir... | [
"Manages",
"state",
"for",
"Augmented",
"Virtuality",
"mode",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/AugmentedVirtuality.js#L25-L175 | train | |
TerriaJS/terriajs | lib/Models/MapInteractionMode.js | MapInteractionMode | function MapInteractionMode(options) {
/**
* Gets or sets a callback that is invoked when the user cancels the interaction mode. If this property is undefined,
* the interaction mode cannot be canceled.
* @type {Function}
*/
this.onCancel = options.onCancel;
/**
* Gets or sets the details of a cu... | javascript | function MapInteractionMode(options) {
/**
* Gets or sets a callback that is invoked when the user cancels the interaction mode. If this property is undefined,
* the interaction mode cannot be canceled.
* @type {Function}
*/
this.onCancel = options.onCancel;
/**
* Gets or sets the details of a cu... | [
"function",
"MapInteractionMode",
"(",
"options",
")",
"{",
"/**\n * Gets or sets a callback that is invoked when the user cancels the interaction mode. If this property is undefined,\n * the interaction mode cannot be canceled.\n * @type {Function}\n */",
"this",
".",
"onCancel",
"=",
... | A mode for interacting with the map.
@alias MapInteractionMode
@constructor
@param {Object} [options] Object with the following properties:
@param {Function} [options.onCancel] The function to invoke if the user cancels the interaction mode. The cancel button will
only appear if this property is specified.
@param {S... | [
"A",
"mode",
"for",
"interacting",
"with",
"the",
"map",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/MapInteractionMode.js#L18-L62 | train |
TerriaJS/terriajs | lib/Map/MapboxVectorTileImageryProvider.js | function(options) {
this._uriTemplate = new URITemplate(options.url);
if (typeof options.layerName !== "string") {
throw new DeveloperError(
"MapboxVectorTileImageryProvider requires a layer name passed as options.layerName"
);
}
this._layerName = options.layerName;
this._subdomains = defaultV... | javascript | function(options) {
this._uriTemplate = new URITemplate(options.url);
if (typeof options.layerName !== "string") {
throw new DeveloperError(
"MapboxVectorTileImageryProvider requires a layer name passed as options.layerName"
);
}
this._layerName = options.layerName;
this._subdomains = defaultV... | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"_uriTemplate",
"=",
"new",
"URITemplate",
"(",
"options",
".",
"url",
")",
";",
"if",
"(",
"typeof",
"options",
".",
"layerName",
"!==",
"\"string\"",
")",
"{",
"throw",
"new",
"DeveloperError",
"(",
"\... | feature.type == 3 for polygon features | [
"feature",
".",
"type",
"==",
"3",
"for",
"polygon",
"features"
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/MapboxVectorTileImageryProvider.js#L25-L87 | train | |
TerriaJS/terriajs | lib/Map/MapboxVectorTileImageryProvider.js | overzoomGeometry | function overzoomGeometry(rings, nativeTile, newExtent, newTile) {
var diffZ = newTile.level - nativeTile.level;
if (diffZ === 0) {
return rings;
} else {
var newRings = [];
// (offsetX, offsetY) is the (0,0) of the new tile
var offsetX = newExtent * (newTile.x - (nativeTile.x << diffZ));
var ... | javascript | function overzoomGeometry(rings, nativeTile, newExtent, newTile) {
var diffZ = newTile.level - nativeTile.level;
if (diffZ === 0) {
return rings;
} else {
var newRings = [];
// (offsetX, offsetY) is the (0,0) of the new tile
var offsetX = newExtent * (newTile.x - (nativeTile.x << diffZ));
var ... | [
"function",
"overzoomGeometry",
"(",
"rings",
",",
"nativeTile",
",",
"newExtent",
",",
"newTile",
")",
"{",
"var",
"diffZ",
"=",
"newTile",
".",
"level",
"-",
"nativeTile",
".",
"level",
";",
"if",
"(",
"diffZ",
"===",
"0",
")",
"{",
"return",
"rings",
... | Use x,y,level vector tile to produce imagery for newX,newY,newLevel | [
"Use",
"x",
"y",
"level",
"vector",
"tile",
"to",
"produce",
"imagery",
"for",
"newX",
"newY",
"newLevel"
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/MapboxVectorTileImageryProvider.js#L223-L241 | train |
TerriaJS/terriajs | lib/Map/MapboxVectorTileImageryProvider.js | inside | function inside(point, vs) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
var x = point.x,
y = point.y;
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i].x,
yi = vs[i].y;
var xj = v... | javascript | function inside(point, vs) {
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
var x = point.x,
y = point.y;
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i].x,
yi = vs[i].y;
var xj = v... | [
"function",
"inside",
"(",
"point",
",",
"vs",
")",
"{",
"// ray-casting algorithm based on",
"// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html",
"var",
"x",
"=",
"point",
".",
"x",
",",
"y",
"=",
"point",
".",
"y",
";",
"var",
"inside",
"="... | Adapted from npm package "point-in-polygon" by James Halliday Licence included in LICENSE.md | [
"Adapted",
"from",
"npm",
"package",
"point",
"-",
"in",
"-",
"polygon",
"by",
"James",
"Halliday",
"Licence",
"included",
"in",
"LICENSE",
".",
"md"
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/MapboxVectorTileImageryProvider.js#L343-L363 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | updateColumns | function updateColumns(item, newColumns) {
item._tableStructure.columns = newColumns;
if (item._tableStructure.columns.length === 0) {
// Nothing to show, so the attempt to redraw will fail; need to explicitly hide the existing regions.
item._regionMapping.hideImageryLayer();
item.terria.currentViewer.n... | javascript | function updateColumns(item, newColumns) {
item._tableStructure.columns = newColumns;
if (item._tableStructure.columns.length === 0) {
// Nothing to show, so the attempt to redraw will fail; need to explicitly hide the existing regions.
item._regionMapping.hideImageryLayer();
item.terria.currentViewer.n... | [
"function",
"updateColumns",
"(",
"item",
",",
"newColumns",
")",
"{",
"item",
".",
"_tableStructure",
".",
"columns",
"=",
"newColumns",
";",
"if",
"(",
"item",
".",
"_tableStructure",
".",
"columns",
".",
"length",
"===",
"0",
")",
"{",
"// Nothing to show... | Sets the tableStructure's columns to the new columns, redraws the map, and closes the feature info panel. | [
"Sets",
"the",
"tableStructure",
"s",
"columns",
"to",
"the",
"new",
"columns",
"redraws",
"the",
"map",
"and",
"closes",
"the",
"feature",
"info",
"panel",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L627-L636 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | fixSelectedInitially | function fixSelectedInitially(item, conceptDimensions) {
conceptDimensions.forEach(dimension => {
if (defined(item.selectedInitially)) {
var thisSelectedInitially = item.selectedInitially[dimension.id];
if (thisSelectedInitially) {
var valueIds = dimension.values.map(value => value.id);
... | javascript | function fixSelectedInitially(item, conceptDimensions) {
conceptDimensions.forEach(dimension => {
if (defined(item.selectedInitially)) {
var thisSelectedInitially = item.selectedInitially[dimension.id];
if (thisSelectedInitially) {
var valueIds = dimension.values.map(value => value.id);
... | [
"function",
"fixSelectedInitially",
"(",
"item",
",",
"conceptDimensions",
")",
"{",
"conceptDimensions",
".",
"forEach",
"(",
"dimension",
"=>",
"{",
"if",
"(",
"defined",
"(",
"item",
".",
"selectedInitially",
")",
")",
"{",
"var",
"thisSelectedInitially",
"="... | Check if item.selectedInitially has at least one value that exists in dimension.values, and if it doesn't, reset item.selectedInitially. | [
"Check",
"if",
"item",
".",
"selectedInitially",
"has",
"at",
"least",
"one",
"value",
"that",
"exists",
"in",
"dimension",
".",
"values",
"and",
"if",
"it",
"doesn",
"t",
"reset",
"item",
".",
"selectedInitially",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L1164-L1186 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | buildConcepts | function buildConcepts(item, fullDimensions) {
function isInitiallyActive(dimensionId, value, index) {
if (!defined(item.selectedInitially)) {
return index === 0;
}
var dimensionSelectedInitially = item.selectedInitially[dimensionId];
if (!defined(dimensionSelectedInitially)) {
return inde... | javascript | function buildConcepts(item, fullDimensions) {
function isInitiallyActive(dimensionId, value, index) {
if (!defined(item.selectedInitially)) {
return index === 0;
}
var dimensionSelectedInitially = item.selectedInitially[dimensionId];
if (!defined(dimensionSelectedInitially)) {
return inde... | [
"function",
"buildConcepts",
"(",
"item",
",",
"fullDimensions",
")",
"{",
"function",
"isInitiallyActive",
"(",
"dimensionId",
",",
"value",
",",
"index",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"item",
".",
"selectedInitially",
")",
")",
"{",
"return",
... | Build out the concepts displayed in the NowViewing panel. Also fixes selectedInitially, if broken. | [
"Build",
"out",
"the",
"concepts",
"displayed",
"in",
"the",
"NowViewing",
"panel",
".",
"Also",
"fixes",
"selectedInitially",
"if",
"broken",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L1189-L1230 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | canTotalBeCalculatedAndIfNotWarnUser | function canTotalBeCalculatedAndIfNotWarnUser(item) {
if (canResultsBeSummed(item)) {
return true;
}
var conceptItems = item._concepts[0].items;
var changedActive = [];
conceptItems.forEach(concept => {
var numberActive = concept.items.filter(function(subconcept) {
return subconcept.isActive;
... | javascript | function canTotalBeCalculatedAndIfNotWarnUser(item) {
if (canResultsBeSummed(item)) {
return true;
}
var conceptItems = item._concepts[0].items;
var changedActive = [];
conceptItems.forEach(concept => {
var numberActive = concept.items.filter(function(subconcept) {
return subconcept.isActive;
... | [
"function",
"canTotalBeCalculatedAndIfNotWarnUser",
"(",
"item",
")",
"{",
"if",
"(",
"canResultsBeSummed",
"(",
"item",
")",
")",
"{",
"return",
"true",
";",
"}",
"var",
"conceptItems",
"=",
"item",
".",
"_concepts",
"[",
"0",
"]",
".",
"items",
";",
"var... | Only show a warning if more than one value of a concept has been selected. Returns true if the user has been warned. | [
"Only",
"show",
"a",
"warning",
"if",
"more",
"than",
"one",
"value",
"of",
"a",
"concept",
"has",
"been",
"selected",
".",
"Returns",
"true",
"if",
"the",
"user",
"has",
"been",
"warned",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L1264-L1296 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | changedActiveItems | function changedActiveItems(item) {
if (!defined(item._dataflowUrl)) {
// All the data is already here, just update the total columns.
var shownDimensionCombinations = calculateShownDimensionCombinations(
item,
item._fullDimensions
);
var columns = item._tableStructure.columns.slice(
... | javascript | function changedActiveItems(item) {
if (!defined(item._dataflowUrl)) {
// All the data is already here, just update the total columns.
var shownDimensionCombinations = calculateShownDimensionCombinations(
item,
item._fullDimensions
);
var columns = item._tableStructure.columns.slice(
... | [
"function",
"changedActiveItems",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"item",
".",
"_dataflowUrl",
")",
")",
"{",
"// All the data is already here, just update the total columns.",
"var",
"shownDimensionCombinations",
"=",
"calculateShownDimensionCombinat... | Called when the active column changes. Returns a promise. | [
"Called",
"when",
"the",
"active",
"column",
"changes",
".",
"Returns",
"a",
"promise",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L1426-L1457 | train |
TerriaJS/terriajs | lib/Models/SdmxJsonCatalogItem.js | getUrlFromDimensionRequestString | function getUrlFromDimensionRequestString(item, dimensionRequestString) {
var url = item._originalUrl;
if (url[url.length - 1] !== "/") {
url += "/";
}
url += dimensionRequestString + "/" + item.providerId;
if (defined(item.startTime)) {
url += "?startTime=" + item.startTime;
if (defined(item.endT... | javascript | function getUrlFromDimensionRequestString(item, dimensionRequestString) {
var url = item._originalUrl;
if (url[url.length - 1] !== "/") {
url += "/";
}
url += dimensionRequestString + "/" + item.providerId;
if (defined(item.startTime)) {
url += "?startTime=" + item.startTime;
if (defined(item.endT... | [
"function",
"getUrlFromDimensionRequestString",
"(",
"item",
",",
"dimensionRequestString",
")",
"{",
"var",
"url",
"=",
"item",
".",
"_originalUrl",
";",
"if",
"(",
"url",
"[",
"url",
".",
"length",
"-",
"1",
"]",
"!==",
"\"/\"",
")",
"{",
"url",
"+=",
... | Convert a dimension request string like "a+b+c.d.e+f.g" into a URL. | [
"Convert",
"a",
"dimension",
"request",
"string",
"like",
"a",
"+",
"b",
"+",
"c",
".",
"d",
".",
"e",
"+",
"f",
".",
"g",
"into",
"a",
"URL",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/SdmxJsonCatalogItem.js#L1460-L1475 | train |
TerriaJS/terriajs | lib/Core/hashFromString.js | hashFromString | function hashFromString(s) {
return Math.abs(
s.split("").reduce(function(prev, c) {
var hash = (prev << 5) - prev + c.charCodeAt(0);
return hash;
}, 0)
);
} | javascript | function hashFromString(s) {
return Math.abs(
s.split("").reduce(function(prev, c) {
var hash = (prev << 5) - prev + c.charCodeAt(0);
return hash;
}, 0)
);
} | [
"function",
"hashFromString",
"(",
"s",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"s",
".",
"split",
"(",
"\"\"",
")",
".",
"reduce",
"(",
"function",
"(",
"prev",
",",
"c",
")",
"{",
"var",
"hash",
"=",
"(",
"prev",
"<<",
"5",
")",
"-",
"pr... | Returns a 32-bit integer hash of a string. '' => 0. | [
"Returns",
"a",
"32",
"-",
"bit",
"integer",
"hash",
"of",
"a",
"string",
".",
"=",
">",
"0",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Core/hashFromString.js#L4-L11 | train |
TerriaJS/terriajs | lib/Models/LocationMarkerUtils.js | correctEntityHeight | function correctEntityHeight(
entity,
currentCartographicPosition,
terrainProvider,
levelHint
) {
sampleTerrain(terrainProvider, levelHint, [currentCartographicPosition]).then(
function(updatedPositions) {
if (updatedPositions[0].height !== undefined) {
entity.position = Ellipsoid.WGS84.cart... | javascript | function correctEntityHeight(
entity,
currentCartographicPosition,
terrainProvider,
levelHint
) {
sampleTerrain(terrainProvider, levelHint, [currentCartographicPosition]).then(
function(updatedPositions) {
if (updatedPositions[0].height !== undefined) {
entity.position = Ellipsoid.WGS84.cart... | [
"function",
"correctEntityHeight",
"(",
"entity",
",",
"currentCartographicPosition",
",",
"terrainProvider",
",",
"levelHint",
")",
"{",
"sampleTerrain",
"(",
"terrainProvider",
",",
"levelHint",
",",
"[",
"currentCartographicPosition",
"]",
")",
".",
"then",
"(",
... | Gets the most detailed height from terrainProvider at currentCartographicPosition and updates entity position.
It starts querying at levelHint and makes its way down to level zero. | [
"Gets",
"the",
"most",
"detailed",
"height",
"from",
"terrainProvider",
"at",
"currentCartographicPosition",
"and",
"updates",
"entity",
"position",
".",
"It",
"starts",
"querying",
"at",
"levelHint",
"and",
"makes",
"its",
"way",
"down",
"to",
"level",
"zero",
... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/LocationMarkerUtils.js#L79-L101 | train |
TerriaJS/terriajs | lib/Models/CatalogGroup.js | indexWithDescendants | function indexWithDescendants(items, index) {
items.forEach(function(item) {
item.allShareKeys.forEach(function(key) {
var insertionKey = key;
if (index[insertionKey]) {
insertionKey = generateUniqueKey(index, key);
if (item.uniqueId === key) {
// If this duplicate was the ... | javascript | function indexWithDescendants(items, index) {
items.forEach(function(item) {
item.allShareKeys.forEach(function(key) {
var insertionKey = key;
if (index[insertionKey]) {
insertionKey = generateUniqueKey(index, key);
if (item.uniqueId === key) {
// If this duplicate was the ... | [
"function",
"indexWithDescendants",
"(",
"items",
",",
"index",
")",
"{",
"items",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"allShareKeys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"insertionKey",
"=",
"ke... | Adds all passed items to the passed index, and all the children of those items recursively.
@private
@param {CatalogMember[]} items
@param {Object} index | [
"Adds",
"all",
"passed",
"items",
"to",
"the",
"passed",
"index",
"and",
"all",
"the",
"children",
"of",
"those",
"items",
"recursively",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/CatalogGroup.js#L349-L378 | train |
TerriaJS/terriajs | lib/Models/CatalogGroup.js | generateUniqueKey | function generateUniqueKey(index, initialKey) {
var currentCandidate = initialKey;
var counter = 0;
while (index[currentCandidate]) {
var numberAtEndOfKeyMatches = currentCandidate.match(
NUMBER_AT_END_OF_KEY_REGEX
);
if (numberAtEndOfKeyMatches !== null) {
var nextNumber = parseInt(numbe... | javascript | function generateUniqueKey(index, initialKey) {
var currentCandidate = initialKey;
var counter = 0;
while (index[currentCandidate]) {
var numberAtEndOfKeyMatches = currentCandidate.match(
NUMBER_AT_END_OF_KEY_REGEX
);
if (numberAtEndOfKeyMatches !== null) {
var nextNumber = parseInt(numbe... | [
"function",
"generateUniqueKey",
"(",
"index",
",",
"initialKey",
")",
"{",
"var",
"currentCandidate",
"=",
"initialKey",
";",
"var",
"counter",
"=",
"0",
";",
"while",
"(",
"index",
"[",
"currentCandidate",
"]",
")",
"{",
"var",
"numberAtEndOfKeyMatches",
"="... | Generates a unique key from a non-unique one by adding a number after it. If the key already has a number added,
it will increment that number.
@private
@param index An index to check for uniqueness.
@param initialKey The key to start from.
@returns {String} A new, unique key. | [
"Generates",
"a",
"unique",
"key",
"from",
"a",
"non",
"-",
"unique",
"one",
"by",
"adding",
"a",
"number",
"after",
"it",
".",
"If",
"the",
"key",
"already",
"has",
"a",
"number",
"added",
"it",
"will",
"increment",
"that",
"number",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/CatalogGroup.js#L388-L420 | train |
TerriaJS/terriajs | lib/Models/CatalogGroup.js | deIndexWithDescendants | function deIndexWithDescendants(items, index) {
items.forEach(function(item) {
item.allShareKeys.forEach(function(key) {
index[key] = undefined;
}, this);
if (defined(item.items)) {
deIndexWithDescendants(item.items, index);
}
});
} | javascript | function deIndexWithDescendants(items, index) {
items.forEach(function(item) {
item.allShareKeys.forEach(function(key) {
index[key] = undefined;
}, this);
if (defined(item.items)) {
deIndexWithDescendants(item.items, index);
}
});
} | [
"function",
"deIndexWithDescendants",
"(",
"items",
",",
"index",
")",
"{",
"items",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"allShareKeys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"index",
"[",
"key",
"]",
"... | Removes all passed items to the passed index, and all the children of those items recursively.
@param {CatalogMember[]} items
@param {Object} index | [
"Removes",
"all",
"passed",
"items",
"to",
"the",
"passed",
"index",
"and",
"all",
"the",
"children",
"of",
"those",
"items",
"recursively",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/CatalogGroup.js#L428-L438 | train |
TerriaJS/terriajs | lib/Models/CswCatalogGroup.js | findGroup | function findGroup(catalogGroup, keywordsGroups, record) {
for (var i = 0; i < keywordsGroups.length; i++) {
var kg = keywordsGroups[i];
var fields = record[kg.field];
var matched = false;
if (defined(fields)) {
if (fields instanceof String || typeof fields === "string") {
fields = [fiel... | javascript | function findGroup(catalogGroup, keywordsGroups, record) {
for (var i = 0; i < keywordsGroups.length; i++) {
var kg = keywordsGroups[i];
var fields = record[kg.field];
var matched = false;
if (defined(fields)) {
if (fields instanceof String || typeof fields === "string") {
fields = [fiel... | [
"function",
"findGroup",
"(",
"catalogGroup",
",",
"keywordsGroups",
",",
"record",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"keywordsGroups",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"kg",
"=",
"keywordsGroups",
"[",
"i",
"]... | find groups that the record belongs to and create any that don't exist already | [
"find",
"groups",
"that",
"the",
"record",
"belongs",
"to",
"and",
"create",
"any",
"that",
"don",
"t",
"exist",
"already"
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/CswCatalogGroup.js#L635-L670 | train |
TerriaJS/terriajs | lib/ReactViews/Custom/Chart/downloadHrefWorker.js | toArrayOfRows | function toArrayOfRows(columnValueArrays, columnNames) {
if (columnValueArrays.length < 1) {
return;
}
const rows = columnValueArrays[0].map(function(value0, rowIndex) {
return columnValueArrays.map(function(values) {
return values[rowIndex];
});
});
rows.unshift(columnNames);
return rows;... | javascript | function toArrayOfRows(columnValueArrays, columnNames) {
if (columnValueArrays.length < 1) {
return;
}
const rows = columnValueArrays[0].map(function(value0, rowIndex) {
return columnValueArrays.map(function(values) {
return values[rowIndex];
});
});
rows.unshift(columnNames);
return rows;... | [
"function",
"toArrayOfRows",
"(",
"columnValueArrays",
",",
"columnNames",
")",
"{",
"if",
"(",
"columnValueArrays",
".",
"length",
"<",
"1",
")",
"{",
"return",
";",
"}",
"const",
"rows",
"=",
"columnValueArrays",
"[",
"0",
"]",
".",
"map",
"(",
"function... | Convert an array of column values, with column names, to an array of row values.
@param {Array[]} columnValueArrays Array of column values, eg. [[1,2,3], [4,5,6]].
@param {String[]} columnNames Array of column names, eg ['x', 'y'].
@return {Array[]} Array of rows, starting with the column names, eg. [['x', 'y'], [1, ... | [
"Convert",
"an",
"array",
"of",
"column",
"values",
"with",
"column",
"names",
"to",
"an",
"array",
"of",
"row",
"values",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/ReactViews/Custom/Chart/downloadHrefWorker.js#L106-L117 | train |
TerriaJS/terriajs | lib/Map/EarthGravityModel1996.js | getHeightValue | function getHeightValue(data, recordIndex, heightIndex) {
if (recordIndex > 720) {
recordIndex = 720;
} else if (recordIndex < 0) {
recordIndex = 0;
}
if (heightIndex > 1439) {
heightIndex -= 1440;
} else if (heightIndex < 0) {
heightIndex += 1440;
}
return data[recordIndex * 1440 + heig... | javascript | function getHeightValue(data, recordIndex, heightIndex) {
if (recordIndex > 720) {
recordIndex = 720;
} else if (recordIndex < 0) {
recordIndex = 0;
}
if (heightIndex > 1439) {
heightIndex -= 1440;
} else if (heightIndex < 0) {
heightIndex += 1440;
}
return data[recordIndex * 1440 + heig... | [
"function",
"getHeightValue",
"(",
"data",
",",
"recordIndex",
",",
"heightIndex",
")",
"{",
"if",
"(",
"recordIndex",
">",
"720",
")",
"{",
"recordIndex",
"=",
"720",
";",
"}",
"else",
"if",
"(",
"recordIndex",
"<",
"0",
")",
"{",
"recordIndex",
"=",
... | Heights returned by this function are in centimeters. | [
"Heights",
"returned",
"by",
"this",
"function",
"are",
"in",
"centimeters",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/EarthGravityModel1996.js#L120-L134 | train |
TerriaJS/terriajs | lib/Models/PlacesLikeMeCatalogFunction.js | function(terria) {
CatalogFunction.call(this, terria);
this.url = undefined;
this.name = "Regions like this";
this.description =
"Identifies regions that are _most like_ a given region according to a given set of characteristics.";
this._regionTypeParameter = new RegionTypeParameter({
terria: this.t... | javascript | function(terria) {
CatalogFunction.call(this, terria);
this.url = undefined;
this.name = "Regions like this";
this.description =
"Identifies regions that are _most like_ a given region according to a given set of characteristics.";
this._regionTypeParameter = new RegionTypeParameter({
terria: this.t... | [
"function",
"(",
"terria",
")",
"{",
"CatalogFunction",
".",
"call",
"(",
"this",
",",
"terria",
")",
";",
"this",
".",
"url",
"=",
"undefined",
";",
"this",
".",
"name",
"=",
"\"Regions like this\"",
";",
"this",
".",
"description",
"=",
"\"Identifies reg... | A Terria Spatial Inference function to identify regions that are _most like_ a given region according to a
given set of characteristics.
@alias PlacesLikeMeCatalogfunction
@constructor
@extends CatalogFunction
@param {Terria} terria The Terria instance. | [
"A",
"Terria",
"Spatial",
"Inference",
"function",
"to",
"identify",
"regions",
"that",
"are",
"_most",
"like_",
"a",
"given",
"region",
"according",
"to",
"a",
"given",
"set",
"of",
"characteristics",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/PlacesLikeMeCatalogFunction.js#L28-L68 | train | |
TerriaJS/terriajs | lib/Map/TableColumn.js | applyHintsToName | function applyHintsToName(hintSet, name, unallowedTypes) {
for (var i in hintSet) {
if (hintSet[i].hint.test(name)) {
var guess = hintSet[i].type;
if (unallowedTypes.indexOf(guess) === -1) {
return guess;
}
}
}
} | javascript | function applyHintsToName(hintSet, name, unallowedTypes) {
for (var i in hintSet) {
if (hintSet[i].hint.test(name)) {
var guess = hintSet[i].type;
if (unallowedTypes.indexOf(guess) === -1) {
return guess;
}
}
}
} | [
"function",
"applyHintsToName",
"(",
"hintSet",
",",
"name",
",",
"unallowedTypes",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"hintSet",
")",
"{",
"if",
"(",
"hintSet",
"[",
"i",
"]",
".",
"hint",
".",
"test",
"(",
"name",
")",
")",
"{",
"var",
"gues... | Guesses the best variable type based on its name. Returns undefined if no guess.
@private
@param {Object[]} hintSet The hint set to use, eg. [{ hint: /^(.*[_ ])?(year)/i, type: VarSubType.YEAR }].
@param {String} name The variable name, eg. 'Time (AEST)'.
@param {VarType[]|VarSubType[]} unallowedTypes Types not to cons... | [
"Guesses",
"the",
"best",
"variable",
"type",
"based",
"on",
"its",
"name",
".",
"Returns",
"undefined",
"if",
"no",
"guess",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Map/TableColumn.js#L710-L719 | train |
TerriaJS/terriajs | lib/Core/formatPropertyValue.js | formatPropertyValue | function formatPropertyValue(value, options) {
if (typeof value === "number") {
return formatNumberForLocale(value, options);
} else if (typeof value === "string") {
// do not linkify if it contains html elements, which we detect by looking for <x...>
// this could catch some non-html strings such as "a... | javascript | function formatPropertyValue(value, options) {
if (typeof value === "number") {
return formatNumberForLocale(value, options);
} else if (typeof value === "string") {
// do not linkify if it contains html elements, which we detect by looking for <x...>
// this could catch some non-html strings such as "a... | [
"function",
"formatPropertyValue",
"(",
"value",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"number\"",
")",
"{",
"return",
"formatNumberForLocale",
"(",
"value",
",",
"options",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"value",
"=... | Format the value for the description, used by the Feature Info Panel.
Strings have markdown applied to them. Anything else is returned as-is.
@param {} value The value to format.
@param {Object} [options] Number formatting options, passed to formatNumberForLocale. | [
"Format",
"the",
"value",
"for",
"the",
"description",
"used",
"by",
"the",
"Feature",
"Info",
"Panel",
".",
"Strings",
"have",
"markdown",
"applied",
"to",
"them",
".",
"Anything",
"else",
"is",
"returned",
"as",
"-",
"is",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Core/formatPropertyValue.js#L14-L25 | train |
TerriaJS/terriajs | lib/Core/serializeToJson.js | serializeToJson | function serializeToJson(target, filterFunction, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
filterFunction = defaultValue(filterFunction, function() {
return true;
});
var result = {};
for (var propertyName in target) {
if (
target.hasOwnProperty(propertyName) &&
... | javascript | function serializeToJson(target, filterFunction, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
filterFunction = defaultValue(filterFunction, function() {
return true;
});
var result = {};
for (var propertyName in target) {
if (
target.hasOwnProperty(propertyName) &&
... | [
"function",
"serializeToJson",
"(",
"target",
",",
"filterFunction",
",",
"options",
")",
"{",
"options",
"=",
"defaultValue",
"(",
"options",
",",
"defaultValue",
".",
"EMPTY_OBJECT",
")",
";",
"filterFunction",
"=",
"defaultValue",
"(",
"filterFunction",
",",
... | Serializes an object to JSON.
@param {Object} target The object to serialize.
@param {Function} filterFunction A function that, when passed the name of a property as its only parameter, returns true if that property should be serialized and false otherwise.
@param {Object} [options] Optional parameters to custom serial... | [
"Serializes",
"an",
"object",
"to",
"JSON",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Core/serializeToJson.js#L13-L38 | train |
TerriaJS/terriajs | lib/Models/RegionMapping.js | function(catalogItem, tableStructure, tableStyle) {
this._tableStructure = defined(tableStructure)
? tableStructure
: new TableStructure();
if (defined(tableStyle) && !(tableStyle instanceof TableStyle)) {
throw new DeveloperError("Please pass a TableStyle object.");
}
this._tableStyle = tableStyle;... | javascript | function(catalogItem, tableStructure, tableStyle) {
this._tableStructure = defined(tableStructure)
? tableStructure
: new TableStructure();
if (defined(tableStyle) && !(tableStyle instanceof TableStyle)) {
throw new DeveloperError("Please pass a TableStyle object.");
}
this._tableStyle = tableStyle;... | [
"function",
"(",
"catalogItem",
",",
"tableStructure",
",",
"tableStyle",
")",
"{",
"this",
".",
"_tableStructure",
"=",
"defined",
"(",
"tableStructure",
")",
"?",
"tableStructure",
":",
"new",
"TableStructure",
"(",
")",
";",
"if",
"(",
"defined",
"(",
"ta... | A DataSource for table-based data.
Handles the graphical display of lat-lon and region-mapped datasets.
For lat-lon data sets, each row is taken to be a feature. RegionMapping generates Cesium entities for each row.
For region-mapped data sets, each row is a region. The regions are displayed using a WMS imagery layer.
... | [
"A",
"DataSource",
"for",
"table",
"-",
"based",
"data",
".",
"Handles",
"the",
"graphical",
"display",
"of",
"lat",
"-",
"lon",
"and",
"region",
"-",
"mapped",
"datasets",
".",
"For",
"lat",
"-",
"lon",
"data",
"sets",
"each",
"row",
"is",
"taken",
"t... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/RegionMapping.js#L52-L99 | train | |
TerriaJS/terriajs | lib/Models/RegionMapping.js | loadRegionIds | function loadRegionIds(regionMapping, rawRegionDetails) {
var promises = rawRegionDetails.map(function(rawRegionDetail) {
return rawRegionDetail.regionProvider.loadRegionIDs();
});
return when
.all(promises)
.then(function() {
// Cache the details in a nicer format, storing the actual columns ra... | javascript | function loadRegionIds(regionMapping, rawRegionDetails) {
var promises = rawRegionDetails.map(function(rawRegionDetail) {
return rawRegionDetail.regionProvider.loadRegionIDs();
});
return when
.all(promises)
.then(function() {
// Cache the details in a nicer format, storing the actual columns ra... | [
"function",
"loadRegionIds",
"(",
"regionMapping",
",",
"rawRegionDetails",
")",
"{",
"var",
"promises",
"=",
"rawRegionDetails",
".",
"map",
"(",
"function",
"(",
"rawRegionDetail",
")",
"{",
"return",
"rawRegionDetail",
".",
"regionProvider",
".",
"loadRegionIDs",... | Loads region ids from the region providers, and returns the region details. | [
"Loads",
"region",
"ids",
"from",
"the",
"region",
"providers",
"and",
"returns",
"the",
"region",
"details",
"."
] | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/RegionMapping.js#L439-L461 | train |
TerriaJS/terriajs | lib/Models/RegionMapping.js | calculateRegionIndices | function calculateRegionIndices(
regionMapping,
time,
failedMatches,
ambiguousMatches
) {
// As described in load, currently we only use the first possible region column.
var regionDetail = regionMapping._regionDetails[0];
var tableStructure = regionMapping._tableStructure;
var regionColumn = tableStruc... | javascript | function calculateRegionIndices(
regionMapping,
time,
failedMatches,
ambiguousMatches
) {
// As described in load, currently we only use the first possible region column.
var regionDetail = regionMapping._regionDetails[0];
var tableStructure = regionMapping._tableStructure;
var regionColumn = tableStruc... | [
"function",
"calculateRegionIndices",
"(",
"regionMapping",
",",
"time",
",",
"failedMatches",
",",
"ambiguousMatches",
")",
"{",
"// As described in load, currently we only use the first possible region column.",
"var",
"regionDetail",
"=",
"regionMapping",
".",
"_regionDetails"... | Returns an array the same length as regionProvider.regions, mapping each region into the relevant index into the table data source.
Takes the current time into account if a time is provided, and there is a time column with timeIntervals defined.
@private
@param {RegionMapping} regionMapping The table data source.
@para... | [
"Returns",
"an",
"array",
"the",
"same",
"length",
"as",
"regionProvider",
".",
"regions",
"mapping",
"each",
"region",
"into",
"the",
"relevant",
"index",
"into",
"the",
"table",
"data",
"source",
".",
"Takes",
"the",
"current",
"time",
"into",
"account",
"... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/RegionMapping.js#L473-L504 | train |
TerriaJS/terriajs | lib/Models/LegendHelper.js | function(tableColumn, tableStyle, regionProvider, name) {
this.tableColumn = tableColumn;
this.tableStyle = defined(tableStyle) ? tableStyle : new TableStyle(); // instead of defaultValue, so new object only created if needed.
this.tableColumnStyle = getTableColumnStyle(tableColumn, this.tableStyle);
this.name ... | javascript | function(tableColumn, tableStyle, regionProvider, name) {
this.tableColumn = tableColumn;
this.tableStyle = defined(tableStyle) ? tableStyle : new TableStyle(); // instead of defaultValue, so new object only created if needed.
this.tableColumnStyle = getTableColumnStyle(tableColumn, this.tableStyle);
this.name ... | [
"function",
"(",
"tableColumn",
",",
"tableStyle",
",",
"regionProvider",
",",
"name",
")",
"{",
"this",
".",
"tableColumn",
"=",
"tableColumn",
";",
"this",
".",
"tableStyle",
"=",
"defined",
"(",
"tableStyle",
")",
"?",
"tableStyle",
":",
"new",
"TableStyl... | Legends for table columns depend on both the table style and the selected column.
This class brings the two together to generate a legend.
Its key output is legendUrl.
@alias LegendHelper
@constructor
@param {TableColumn} tableColumn The column whose values inform the legend.
@param {TableStyle} [tableStyle] The styl... | [
"Legends",
"for",
"table",
"columns",
"depend",
"on",
"both",
"the",
"table",
"style",
"and",
"the",
"selected",
"column",
".",
"This",
"class",
"brings",
"the",
"two",
"together",
"to",
"generate",
"a",
"legend",
".",
"Its",
"key",
"output",
"is",
"legend... | abcce28ff189f6fdbc0ee541a235ec6cabd90bd5 | https://github.com/TerriaJS/terriajs/blob/abcce28ff189f6fdbc0ee541a235ec6cabd90bd5/lib/Models/LegendHelper.js#L50-L82 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.