id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
|---|---|---|---|---|---|---|---|---|---|---|---|
9,600
|
aws/aws-xray-sdk-node
|
packages/core/lib/patchers/aws_p.js
|
captureAWS
|
function captureAWS(awssdk) {
if (!semver.gte(awssdk.VERSION, minVersion))
throw new Error ('AWS SDK version ' + minVersion + ' or greater required.');
for (var prop in awssdk) {
if (awssdk[prop].serviceIdentifier) {
var Service = awssdk[prop];
Service.prototype.customizeRequests(captureAWSRequest);
}
}
return awssdk;
}
|
javascript
|
function captureAWS(awssdk) {
if (!semver.gte(awssdk.VERSION, minVersion))
throw new Error ('AWS SDK version ' + minVersion + ' or greater required.');
for (var prop in awssdk) {
if (awssdk[prop].serviceIdentifier) {
var Service = awssdk[prop];
Service.prototype.customizeRequests(captureAWSRequest);
}
}
return awssdk;
}
|
[
"function",
"captureAWS",
"(",
"awssdk",
")",
"{",
"if",
"(",
"!",
"semver",
".",
"gte",
"(",
"awssdk",
".",
"VERSION",
",",
"minVersion",
")",
")",
"throw",
"new",
"Error",
"(",
"'AWS SDK version '",
"+",
"minVersion",
"+",
"' or greater required.'",
")",
";",
"for",
"(",
"var",
"prop",
"in",
"awssdk",
")",
"{",
"if",
"(",
"awssdk",
"[",
"prop",
"]",
".",
"serviceIdentifier",
")",
"{",
"var",
"Service",
"=",
"awssdk",
"[",
"prop",
"]",
";",
"Service",
".",
"prototype",
".",
"customizeRequests",
"(",
"captureAWSRequest",
")",
";",
"}",
"}",
"return",
"awssdk",
";",
"}"
] |
Configures the AWS SDK to automatically capture information for the segment.
All created clients will automatically be captured. See 'captureAWSClient'
for additional details.
@param {AWS} awssdk - The Javascript AWS SDK.
@alias module:aws_p.captureAWS
@returns {AWS}
@see https://github.com/aws/aws-sdk-js
|
[
"Configures",
"the",
"AWS",
"SDK",
"to",
"automatically",
"capture",
"information",
"for",
"the",
"segment",
".",
"All",
"created",
"clients",
"will",
"automatically",
"be",
"captured",
".",
"See",
"captureAWSClient",
"for",
"additional",
"details",
"."
] |
ad817e5ccfbb803ec4140cd8a457be579ea3cc1c
|
https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/patchers/aws_p.js#L31-L43
|
9,601
|
aws/aws-xray-sdk-node
|
packages/core/lib/database/sql_data.js
|
SqlData
|
function SqlData(databaseVer, driverVer, user, url, queryType) {
this.init(databaseVer, driverVer, user, url, queryType);
}
|
javascript
|
function SqlData(databaseVer, driverVer, user, url, queryType) {
this.init(databaseVer, driverVer, user, url, queryType);
}
|
[
"function",
"SqlData",
"(",
"databaseVer",
",",
"driverVer",
",",
"user",
",",
"url",
",",
"queryType",
")",
"{",
"this",
".",
"init",
"(",
"databaseVer",
",",
"driverVer",
",",
"user",
",",
"url",
",",
"queryType",
")",
";",
"}"
] |
Represents a SQL database call.
@constructor
@param {string} databaseVer - The version on the database (user supplied).
@param {string} driverVer - The version on the database driver (user supplied).
@param {string} user - The user associated to the database call.
@param {string} queryType - The SQL query type.
|
[
"Represents",
"a",
"SQL",
"database",
"call",
"."
] |
ad817e5ccfbb803ec4140cd8a457be579ea3cc1c
|
https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/database/sql_data.js#L10-L12
|
9,602
|
aws/aws-xray-sdk-node
|
packages/core/lib/capture.js
|
captureFunc
|
function captureFunc(name, fcn, parent) {
validate(name, fcn);
var current, executeFcn;
var parentSeg = contextUtils.resolveSegment(parent);
if (!parentSeg) {
logger.getLogger().warn('Failed to capture function.');
return fcn();
}
current = parentSeg.addNewSubsegment(name);
executeFcn = captureFcn(fcn, current);
try {
executeFcn(current);
current.close();
} catch (e) {
current.close(e);
throw(e);
}
}
|
javascript
|
function captureFunc(name, fcn, parent) {
validate(name, fcn);
var current, executeFcn;
var parentSeg = contextUtils.resolveSegment(parent);
if (!parentSeg) {
logger.getLogger().warn('Failed to capture function.');
return fcn();
}
current = parentSeg.addNewSubsegment(name);
executeFcn = captureFcn(fcn, current);
try {
executeFcn(current);
current.close();
} catch (e) {
current.close(e);
throw(e);
}
}
|
[
"function",
"captureFunc",
"(",
"name",
",",
"fcn",
",",
"parent",
")",
"{",
"validate",
"(",
"name",
",",
"fcn",
")",
";",
"var",
"current",
",",
"executeFcn",
";",
"var",
"parentSeg",
"=",
"contextUtils",
".",
"resolveSegment",
"(",
"parent",
")",
";",
"if",
"(",
"!",
"parentSeg",
")",
"{",
"logger",
".",
"getLogger",
"(",
")",
".",
"warn",
"(",
"'Failed to capture function.'",
")",
";",
"return",
"fcn",
"(",
")",
";",
"}",
"current",
"=",
"parentSeg",
".",
"addNewSubsegment",
"(",
"name",
")",
";",
"executeFcn",
"=",
"captureFcn",
"(",
"fcn",
",",
"current",
")",
";",
"try",
"{",
"executeFcn",
"(",
"current",
")",
";",
"current",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"current",
".",
"close",
"(",
"e",
")",
";",
"throw",
"(",
"e",
")",
";",
"}",
"}"
] |
Wrap to automatically capture information for the segment.
@param {string} name - The name of the new subsegment.
@param {function} fcn - The function context to wrap. Can take a single 'subsegment' argument.
@param {Segment|Subsegment} [parent] - The parent for the new subsegment, for manual mode.
@alias module:capture.captureFunc
|
[
"Wrap",
"to",
"automatically",
"capture",
"information",
"for",
"the",
"segment",
"."
] |
ad817e5ccfbb803ec4140cd8a457be579ea3cc1c
|
https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/capture.js#L18-L40
|
9,603
|
aws/aws-xray-sdk-node
|
packages/core/lib/middleware/sampling/sampling_rule.js
|
SamplingRule
|
function SamplingRule(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType) {
this.init(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType);
}
|
javascript
|
function SamplingRule(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType) {
this.init(name, priority, rate, reservoirSize,
host, httpMethod, urlPath, serviceName, serviceType);
}
|
[
"function",
"SamplingRule",
"(",
"name",
",",
"priority",
",",
"rate",
",",
"reservoirSize",
",",
"host",
",",
"httpMethod",
",",
"urlPath",
",",
"serviceName",
",",
"serviceType",
")",
"{",
"this",
".",
"init",
"(",
"name",
",",
"priority",
",",
"rate",
",",
"reservoirSize",
",",
"host",
",",
"httpMethod",
",",
"urlPath",
",",
"serviceName",
",",
"serviceType",
")",
";",
"}"
] |
The data model for a sampling rule defined using X-Ray API CreateSamplingRules.
It should be only instantiated directly from the X-Ray API response.
@constructor
|
[
"The",
"data",
"model",
"for",
"a",
"sampling",
"rule",
"defined",
"using",
"X",
"-",
"Ray",
"API",
"CreateSamplingRules",
".",
"It",
"should",
"be",
"only",
"instantiated",
"directly",
"from",
"the",
"X",
"-",
"Ray",
"API",
"response",
"."
] |
ad817e5ccfbb803ec4140cd8a457be579ea3cc1c
|
https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/middleware/sampling/sampling_rule.js#L10-L14
|
9,604
|
aws/aws-xray-sdk-node
|
packages/core/lib/aws-xray.js
|
function(plugins) {
var pluginData = {};
plugins.forEach(function(plugin) {
plugin.getData(function(data) {
if (data) {
for (var attribute in data) { pluginData[attribute] = data[attribute]; }
}
});
segmentUtils.setOrigin(plugin.originName);
segmentUtils.setPluginData(pluginData);
});
}
|
javascript
|
function(plugins) {
var pluginData = {};
plugins.forEach(function(plugin) {
plugin.getData(function(data) {
if (data) {
for (var attribute in data) { pluginData[attribute] = data[attribute]; }
}
});
segmentUtils.setOrigin(plugin.originName);
segmentUtils.setPluginData(pluginData);
});
}
|
[
"function",
"(",
"plugins",
")",
"{",
"var",
"pluginData",
"=",
"{",
"}",
";",
"plugins",
".",
"forEach",
"(",
"function",
"(",
"plugin",
")",
"{",
"plugin",
".",
"getData",
"(",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
")",
"{",
"for",
"(",
"var",
"attribute",
"in",
"data",
")",
"{",
"pluginData",
"[",
"attribute",
"]",
"=",
"data",
"[",
"attribute",
"]",
";",
"}",
"}",
"}",
")",
";",
"segmentUtils",
".",
"setOrigin",
"(",
"plugin",
".",
"originName",
")",
";",
"segmentUtils",
".",
"setPluginData",
"(",
"pluginData",
")",
";",
"}",
")",
";",
"}"
] |
Enables use of plugins to capture additional data for segments.
@param {Array} plugins - A configurable subset of AWSXRay.plugins.
@memberof AWSXRay
@see AWSXRay.plugins
|
[
"Enables",
"use",
"of",
"plugins",
"to",
"capture",
"additional",
"data",
"for",
"segments",
"."
] |
ad817e5ccfbb803ec4140cd8a457be579ea3cc1c
|
https://github.com/aws/aws-xray-sdk-node/blob/ad817e5ccfbb803ec4140cd8a457be579ea3cc1c/packages/core/lib/aws-xray.js#L56-L67
|
|
9,605
|
nats-io/node-nats-streaming
|
lib/stan.js
|
Message
|
function Message(stanClient, msg, subscription) {
this.stanClient = stanClient;
this.msg = msg;
this.subscription = subscription;
}
|
javascript
|
function Message(stanClient, msg, subscription) {
this.stanClient = stanClient;
this.msg = msg;
this.subscription = subscription;
}
|
[
"function",
"Message",
"(",
"stanClient",
",",
"msg",
",",
"subscription",
")",
"{",
"this",
".",
"stanClient",
"=",
"stanClient",
";",
"this",
".",
"msg",
"=",
"msg",
";",
"this",
".",
"subscription",
"=",
"subscription",
";",
"}"
] |
Represents a message received from the streaming server.
@param stanClient
@param msg
@param subscription
@constructor
|
[
"Represents",
"a",
"message",
"received",
"from",
"the",
"streaming",
"server",
"."
] |
d7a3cdc758c1c8a7f08f5aa8d8311fd5f189c6dd
|
https://github.com/nats-io/node-nats-streaming/blob/d7a3cdc758c1c8a7f08f5aa8d8311fd5f189c6dd/lib/stan.js#L881-L885
|
9,606
|
BabylonJS/Spector.js
|
sample/js/transient.js
|
runTransient
|
function runTransient() {
var c = document.createElement('canvas');
var gl = c.getContext('webgl');
var ext = gl.getExtension('WEBGL_debug_renderer_info');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
console.log(renderer);
}
|
javascript
|
function runTransient() {
var c = document.createElement('canvas');
var gl = c.getContext('webgl');
var ext = gl.getExtension('WEBGL_debug_renderer_info');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
console.log(renderer);
}
|
[
"function",
"runTransient",
"(",
")",
"{",
"var",
"c",
"=",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
";",
"var",
"gl",
"=",
"c",
".",
"getContext",
"(",
"'webgl'",
")",
";",
"var",
"ext",
"=",
"gl",
".",
"getExtension",
"(",
"'WEBGL_debug_renderer_info'",
")",
";",
"var",
"renderer",
"=",
"gl",
".",
"getParameter",
"(",
"ext",
".",
"UNMASKED_RENDERER_WEBGL",
")",
";",
"console",
".",
"log",
"(",
"renderer",
")",
";",
"}"
] |
start Called when the canvas is created to get the ball rolling.
|
[
"start",
"Called",
"when",
"the",
"canvas",
"is",
"created",
"to",
"get",
"the",
"ball",
"rolling",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L51-L57
|
9,607
|
BabylonJS/Spector.js
|
sample/js/transient.js
|
initWebGL
|
function initWebGL() {
gl = null;
try {
gl = canvas.getContext("experimental-webgl");
}
catch(e) {
alert(e);
}
// If we don't have a GL context, give up now
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
}
}
|
javascript
|
function initWebGL() {
gl = null;
try {
gl = canvas.getContext("experimental-webgl");
}
catch(e) {
alert(e);
}
// If we don't have a GL context, give up now
if (!gl) {
alert("Unable to initialize WebGL. Your browser may not support it.");
}
}
|
[
"function",
"initWebGL",
"(",
")",
"{",
"gl",
"=",
"null",
";",
"try",
"{",
"gl",
"=",
"canvas",
".",
"getContext",
"(",
"\"experimental-webgl\"",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"alert",
"(",
"e",
")",
";",
"}",
"// If we don't have a GL context, give up now",
"if",
"(",
"!",
"gl",
")",
"{",
"alert",
"(",
"\"Unable to initialize WebGL. Your browser may not support it.\"",
")",
";",
"}",
"}"
] |
initWebGL Initialize WebGL, returning the GL context or null if WebGL isn't available or could not be initialized.
|
[
"initWebGL",
"Initialize",
"WebGL",
"returning",
"the",
"GL",
"context",
"or",
"null",
"if",
"WebGL",
"isn",
"t",
"available",
"or",
"could",
"not",
"be",
"initialized",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L95-L110
|
9,608
|
BabylonJS/Spector.js
|
sample/js/transient.js
|
getShader
|
function getShader(gl, source, isVertex) {
var shader = gl.createShader(isVertex ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
gl.shaderSource(shader, source);
gl.compileShader(shader);
// See if it compiled successfully
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader));
return null;
}
return shader;
}
|
javascript
|
function getShader(gl, source, isVertex) {
var shader = gl.createShader(isVertex ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
gl.shaderSource(shader, source);
gl.compileShader(shader);
// See if it compiled successfully
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader));
return null;
}
return shader;
}
|
[
"function",
"getShader",
"(",
"gl",
",",
"source",
",",
"isVertex",
")",
"{",
"var",
"shader",
"=",
"gl",
".",
"createShader",
"(",
"isVertex",
"?",
"gl",
".",
"VERTEX_SHADER",
":",
"gl",
".",
"FRAGMENT_SHADER",
")",
";",
"gl",
".",
"shaderSource",
"(",
"shader",
",",
"source",
")",
";",
"gl",
".",
"compileShader",
"(",
"shader",
")",
";",
"// See if it compiled successfully",
"if",
"(",
"!",
"gl",
".",
"getShaderParameter",
"(",
"shader",
",",
"gl",
".",
"COMPILE_STATUS",
")",
")",
"{",
"alert",
"(",
"\"An error occurred compiling the shaders: \"",
"+",
"gl",
".",
"getShaderInfoLog",
"(",
"shader",
")",
")",
";",
"return",
"null",
";",
"}",
"return",
"shader",
";",
"}"
] |
getShader Loads a shader program
|
[
"getShader",
"Loads",
"a",
"shader",
"program"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/transient.js#L345-L358
|
9,609
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.objFileLoader.js
|
function (arr, obj) {
if (!arr[obj[0]])
arr[obj[0]] = { normals: [], idx: [] };
var idx = arr[obj[0]].normals.indexOf(obj[1]);
return idx === -1 ? -1 : arr[obj[0]].idx[idx];
}
|
javascript
|
function (arr, obj) {
if (!arr[obj[0]])
arr[obj[0]] = { normals: [], idx: [] };
var idx = arr[obj[0]].normals.indexOf(obj[1]);
return idx === -1 ? -1 : arr[obj[0]].idx[idx];
}
|
[
"function",
"(",
"arr",
",",
"obj",
")",
"{",
"if",
"(",
"!",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
")",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
"=",
"{",
"normals",
":",
"[",
"]",
",",
"idx",
":",
"[",
"]",
"}",
";",
"var",
"idx",
"=",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
".",
"normals",
".",
"indexOf",
"(",
"obj",
"[",
"1",
"]",
")",
";",
"return",
"idx",
"===",
"-",
"1",
"?",
"-",
"1",
":",
"arr",
"[",
"obj",
"[",
"0",
"]",
"]",
".",
"idx",
"[",
"idx",
"]",
";",
"}"
] |
Search for obj in the given array.
This function is called to check if a couple of data already exists in an array.
If found, returns the index of the founded tuple index. Returns -1 if not found
@param arr Array<{ normals: Array<number>, idx: Array<number> }>
@param obj Array<number>
@returns {boolean}
|
[
"Search",
"for",
"obj",
"in",
"the",
"given",
"array",
".",
"This",
"function",
"is",
"called",
"to",
"check",
"if",
"a",
"couple",
"of",
"data",
"already",
"exists",
"in",
"an",
"array",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L305-L310
|
|
9,610
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.objFileLoader.js
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
//For each element in the triangles array.
//This var could contains 1 to an infinity of triangles
for (var k = 0; k < triangles.length; k++) {
// Set position indice
var indicePositionFromObj = parseInt(triangles[k]) - 1;
setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
positions[indicePositionFromObj], //Get the vectors data
BABYLON.Vector2.Zero(), BABYLON.Vector3.Up() //Create default vectors
);
}
//Reset variable for the next line
triangles = [];
}
|
javascript
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
//For each element in the triangles array.
//This var could contains 1 to an infinity of triangles
for (var k = 0; k < triangles.length; k++) {
// Set position indice
var indicePositionFromObj = parseInt(triangles[k]) - 1;
setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
positions[indicePositionFromObj], //Get the vectors data
BABYLON.Vector2.Zero(), BABYLON.Vector3.Up() //Create default vectors
);
}
//Reset variable for the next line
triangles = [];
}
|
[
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"//For each element in the triangles array.",
"//This var could contains 1 to an infinity of triangles",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"// Set position indice",
"var",
"indicePositionFromObj",
"=",
"parseInt",
"(",
"triangles",
"[",
"k",
"]",
")",
"-",
"1",
";",
"setData",
"(",
"indicePositionFromObj",
",",
"0",
",",
"0",
",",
"//In the pattern 1, normals and uvs are not defined",
"positions",
"[",
"indicePositionFromObj",
"]",
",",
"//Get the vectors data",
"BABYLON",
".",
"Vector2",
".",
"Zero",
"(",
")",
",",
"BABYLON",
".",
"Vector3",
".",
"Up",
"(",
")",
"//Create default vectors",
")",
";",
"}",
"//Reset variable for the next line",
"triangles",
"=",
"[",
"]",
";",
"}"
] |
Create triangles and push the data for each polygon for the pattern 1
In this pattern we get vertice positions
@param face
@param v
|
[
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"1",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L430-L445
|
|
9,611
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.objFileLoader.js
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1"
//Split the data for getting position and uv
var point = triangles[k].split("/"); // ["1", "1"]
//Set position indice
var indicePositionFromObj = parseInt(point[0]) - 1;
//Set uv indice
var indiceUvsFromObj = parseInt(point[1]) - 1;
setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
positions[indicePositionFromObj], //Get the values for each element
uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
);
}
//Reset variable for the next line
triangles = [];
}
|
javascript
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1"
//Split the data for getting position and uv
var point = triangles[k].split("/"); // ["1", "1"]
//Set position indice
var indicePositionFromObj = parseInt(point[0]) - 1;
//Set uv indice
var indiceUvsFromObj = parseInt(point[1]) - 1;
setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
positions[indicePositionFromObj], //Get the values for each element
uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
);
}
//Reset variable for the next line
triangles = [];
}
|
[
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//triangle[k] = \"1/1\"",
"//Split the data for getting position and uv",
"var",
"point",
"=",
"triangles",
"[",
"k",
"]",
".",
"split",
"(",
"\"/\"",
")",
";",
"// [\"1\", \"1\"]",
"//Set position indice",
"var",
"indicePositionFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"0",
"]",
")",
"-",
"1",
";",
"//Set uv indice",
"var",
"indiceUvsFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"1",
"]",
")",
"-",
"1",
";",
"setData",
"(",
"indicePositionFromObj",
",",
"indiceUvsFromObj",
",",
"0",
",",
"//Default value for normals",
"positions",
"[",
"indicePositionFromObj",
"]",
",",
"//Get the values for each element",
"uvs",
"[",
"indiceUvsFromObj",
"]",
",",
"BABYLON",
".",
"Vector3",
".",
"Up",
"(",
")",
"//Default value for normals",
")",
";",
"}",
"//Reset variable for the next line",
"triangles",
"=",
"[",
"]",
";",
"}"
] |
Create triangles and push the data for each polygon for the pattern 2
In this pattern we get vertice positions and uvsu
@param face
@param v
|
[
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"2",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"and",
"uvsu"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L452-L470
|
|
9,612
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.objFileLoader.js
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1/1"
//Split the data for getting position, uv, and normals
var point = triangles[k].split("/"); // ["1", "1", "1"]
// Set position indice
var indicePositionFromObj = parseInt(point[0]) - 1;
// Set uv indice
var indiceUvsFromObj = parseInt(point[1]) - 1;
// Set normal indice
var indiceNormalFromObj = parseInt(point[2]) - 1;
setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
);
}
//Reset variable for the next line
triangles = [];
}
|
javascript
|
function (face, v) {
//Get the indices of triangles for each polygon
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1/1/1"
//Split the data for getting position, uv, and normals
var point = triangles[k].split("/"); // ["1", "1", "1"]
// Set position indice
var indicePositionFromObj = parseInt(point[0]) - 1;
// Set uv indice
var indiceUvsFromObj = parseInt(point[1]) - 1;
// Set normal indice
var indiceNormalFromObj = parseInt(point[2]) - 1;
setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
);
}
//Reset variable for the next line
triangles = [];
}
|
[
"function",
"(",
"face",
",",
"v",
")",
"{",
"//Get the indices of triangles for each polygon",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//triangle[k] = \"1/1/1\"",
"//Split the data for getting position, uv, and normals",
"var",
"point",
"=",
"triangles",
"[",
"k",
"]",
".",
"split",
"(",
"\"/\"",
")",
";",
"// [\"1\", \"1\", \"1\"]",
"// Set position indice",
"var",
"indicePositionFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"0",
"]",
")",
"-",
"1",
";",
"// Set uv indice",
"var",
"indiceUvsFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"1",
"]",
")",
"-",
"1",
";",
"// Set normal indice",
"var",
"indiceNormalFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"2",
"]",
")",
"-",
"1",
";",
"setData",
"(",
"indicePositionFromObj",
",",
"indiceUvsFromObj",
",",
"indiceNormalFromObj",
",",
"positions",
"[",
"indicePositionFromObj",
"]",
",",
"uvs",
"[",
"indiceUvsFromObj",
"]",
",",
"normals",
"[",
"indiceNormalFromObj",
"]",
"//Set the vector for each component",
")",
";",
"}",
"//Reset variable for the next line",
"triangles",
"=",
"[",
"]",
";",
"}"
] |
Create triangles and push the data for each polygon for the pattern 3
In this pattern we get vertice positions, uvs and normals
@param face
@param v
|
[
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"3",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"uvs",
"and",
"normals"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L477-L495
|
|
9,613
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.objFileLoader.js
|
function (face, v) {
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1//1"
//Split the data for getting position and normals
var point = triangles[k].split("//"); // ["1", "1"]
// We check indices, and normals
var indicePositionFromObj = parseInt(point[0]) - 1;
var indiceNormalFromObj = parseInt(point[1]) - 1;
setData(indicePositionFromObj, 1, //Default value for uv
indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
}
//Reset variable for the next line
triangles = [];
}
|
javascript
|
function (face, v) {
getTriangles(face, v);
for (var k = 0; k < triangles.length; k++) {
//triangle[k] = "1//1"
//Split the data for getting position and normals
var point = triangles[k].split("//"); // ["1", "1"]
// We check indices, and normals
var indicePositionFromObj = parseInt(point[0]) - 1;
var indiceNormalFromObj = parseInt(point[1]) - 1;
setData(indicePositionFromObj, 1, //Default value for uv
indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
}
//Reset variable for the next line
triangles = [];
}
|
[
"function",
"(",
"face",
",",
"v",
")",
"{",
"getTriangles",
"(",
"face",
",",
"v",
")",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"triangles",
".",
"length",
";",
"k",
"++",
")",
"{",
"//triangle[k] = \"1//1\"",
"//Split the data for getting position and normals",
"var",
"point",
"=",
"triangles",
"[",
"k",
"]",
".",
"split",
"(",
"\"//\"",
")",
";",
"// [\"1\", \"1\"]",
"// We check indices, and normals",
"var",
"indicePositionFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"0",
"]",
")",
"-",
"1",
";",
"var",
"indiceNormalFromObj",
"=",
"parseInt",
"(",
"point",
"[",
"1",
"]",
")",
"-",
"1",
";",
"setData",
"(",
"indicePositionFromObj",
",",
"1",
",",
"//Default value for uv",
"indiceNormalFromObj",
",",
"positions",
"[",
"indicePositionFromObj",
"]",
",",
"//Get each vector of data",
"BABYLON",
".",
"Vector2",
".",
"Zero",
"(",
")",
",",
"normals",
"[",
"indiceNormalFromObj",
"]",
")",
";",
"}",
"//Reset variable for the next line",
"triangles",
"=",
"[",
"]",
";",
"}"
] |
Create triangles and push the data for each polygon for the pattern 4
In this pattern we get vertice positions and normals
@param face
@param v
|
[
"Create",
"triangles",
"and",
"push",
"the",
"data",
"for",
"each",
"polygon",
"for",
"the",
"pattern",
"4",
"In",
"this",
"pattern",
"we",
"get",
"vertice",
"positions",
"and",
"normals"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.objFileLoader.js#L502-L517
|
|
9,614
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
Color3
|
function Color3(r, g, b) {
if (r === void 0) { r = 0; }
if (g === void 0) { g = 0; }
if (b === void 0) { b = 0; }
this.r = r;
this.g = g;
this.b = b;
}
|
javascript
|
function Color3(r, g, b) {
if (r === void 0) { r = 0; }
if (g === void 0) { g = 0; }
if (b === void 0) { b = 0; }
this.r = r;
this.g = g;
this.b = b;
}
|
[
"function",
"Color3",
"(",
"r",
",",
"g",
",",
"b",
")",
"{",
"if",
"(",
"r",
"===",
"void",
"0",
")",
"{",
"r",
"=",
"0",
";",
"}",
"if",
"(",
"g",
"===",
"void",
"0",
")",
"{",
"g",
"=",
"0",
";",
"}",
"if",
"(",
"b",
"===",
"void",
"0",
")",
"{",
"b",
"=",
"0",
";",
"}",
"this",
".",
"r",
"=",
"r",
";",
"this",
".",
"g",
"=",
"g",
";",
"this",
".",
"b",
"=",
"b",
";",
"}"
] |
Creates a new Color3 object from red, green, blue values, all between 0 and 1.
|
[
"Creates",
"a",
"new",
"Color3",
"object",
"from",
"red",
"green",
"blue",
"values",
"all",
"between",
"0",
"and",
"1",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L183-L190
|
9,615
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
Quaternion
|
function Quaternion(x, y, z, w) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (z === void 0) { z = 0.0; }
if (w === void 0) { w = 1.0; }
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
|
javascript
|
function Quaternion(x, y, z, w) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (z === void 0) { z = 0.0; }
if (w === void 0) { w = 1.0; }
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
|
[
"function",
"Quaternion",
"(",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
"{",
"if",
"(",
"x",
"===",
"void",
"0",
")",
"{",
"x",
"=",
"0.0",
";",
"}",
"if",
"(",
"y",
"===",
"void",
"0",
")",
"{",
"y",
"=",
"0.0",
";",
"}",
"if",
"(",
"z",
"===",
"void",
"0",
")",
"{",
"z",
"=",
"0.0",
";",
"}",
"if",
"(",
"w",
"===",
"void",
"0",
")",
"{",
"w",
"=",
"1.0",
";",
"}",
"this",
".",
"x",
"=",
"x",
";",
"this",
".",
"y",
"=",
"y",
";",
"this",
".",
"z",
"=",
"z",
";",
"this",
".",
"w",
"=",
"w",
";",
"}"
] |
Creates a new Quaternion from the passed floats.
|
[
"Creates",
"a",
"new",
"Quaternion",
"from",
"the",
"passed",
"floats",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L2393-L2402
|
9,616
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
Path2
|
function Path2(x, y) {
this._points = new Array();
this._length = 0.0;
this.closed = false;
this._points.push(new Vector2(x, y));
}
|
javascript
|
function Path2(x, y) {
this._points = new Array();
this._length = 0.0;
this.closed = false;
this._points.push(new Vector2(x, y));
}
|
[
"function",
"Path2",
"(",
"x",
",",
"y",
")",
"{",
"this",
".",
"_points",
"=",
"new",
"Array",
"(",
")",
";",
"this",
".",
"_length",
"=",
"0.0",
";",
"this",
".",
"closed",
"=",
"false",
";",
"this",
".",
"_points",
".",
"push",
"(",
"new",
"Vector2",
"(",
"x",
",",
"y",
")",
")",
";",
"}"
] |
Creates a Path2 object from the starting 2D coordinates x and y.
|
[
"Creates",
"a",
"Path2",
"object",
"from",
"the",
"starting",
"2D",
"coordinates",
"x",
"and",
"y",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L4376-L4381
|
9,617
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
getMergedStore
|
function getMergedStore(target) {
var classKey = target.getClassName();
if (__mergedStore[classKey]) {
return __mergedStore[classKey];
}
__mergedStore[classKey] = {};
var store = __mergedStore[classKey];
var currentTarget = target;
var currentKey = classKey;
while (currentKey) {
var initialStore = __decoratorInitialStore[currentKey];
for (var property in initialStore) {
store[property] = initialStore[property];
}
var parent_1 = void 0;
var done = false;
do {
parent_1 = Object.getPrototypeOf(currentTarget);
if (!parent_1.getClassName) {
done = true;
break;
}
if (parent_1.getClassName() !== currentKey) {
break;
}
currentTarget = parent_1;
} while (parent_1);
if (done) {
break;
}
currentKey = parent_1.getClassName();
currentTarget = parent_1;
}
return store;
}
|
javascript
|
function getMergedStore(target) {
var classKey = target.getClassName();
if (__mergedStore[classKey]) {
return __mergedStore[classKey];
}
__mergedStore[classKey] = {};
var store = __mergedStore[classKey];
var currentTarget = target;
var currentKey = classKey;
while (currentKey) {
var initialStore = __decoratorInitialStore[currentKey];
for (var property in initialStore) {
store[property] = initialStore[property];
}
var parent_1 = void 0;
var done = false;
do {
parent_1 = Object.getPrototypeOf(currentTarget);
if (!parent_1.getClassName) {
done = true;
break;
}
if (parent_1.getClassName() !== currentKey) {
break;
}
currentTarget = parent_1;
} while (parent_1);
if (done) {
break;
}
currentKey = parent_1.getClassName();
currentTarget = parent_1;
}
return store;
}
|
[
"function",
"getMergedStore",
"(",
"target",
")",
"{",
"var",
"classKey",
"=",
"target",
".",
"getClassName",
"(",
")",
";",
"if",
"(",
"__mergedStore",
"[",
"classKey",
"]",
")",
"{",
"return",
"__mergedStore",
"[",
"classKey",
"]",
";",
"}",
"__mergedStore",
"[",
"classKey",
"]",
"=",
"{",
"}",
";",
"var",
"store",
"=",
"__mergedStore",
"[",
"classKey",
"]",
";",
"var",
"currentTarget",
"=",
"target",
";",
"var",
"currentKey",
"=",
"classKey",
";",
"while",
"(",
"currentKey",
")",
"{",
"var",
"initialStore",
"=",
"__decoratorInitialStore",
"[",
"currentKey",
"]",
";",
"for",
"(",
"var",
"property",
"in",
"initialStore",
")",
"{",
"store",
"[",
"property",
"]",
"=",
"initialStore",
"[",
"property",
"]",
";",
"}",
"var",
"parent_1",
"=",
"void",
"0",
";",
"var",
"done",
"=",
"false",
";",
"do",
"{",
"parent_1",
"=",
"Object",
".",
"getPrototypeOf",
"(",
"currentTarget",
")",
";",
"if",
"(",
"!",
"parent_1",
".",
"getClassName",
")",
"{",
"done",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"parent_1",
".",
"getClassName",
"(",
")",
"!==",
"currentKey",
")",
"{",
"break",
";",
"}",
"currentTarget",
"=",
"parent_1",
";",
"}",
"while",
"(",
"parent_1",
")",
";",
"if",
"(",
"done",
")",
"{",
"break",
";",
"}",
"currentKey",
"=",
"parent_1",
".",
"getClassName",
"(",
")",
";",
"currentTarget",
"=",
"parent_1",
";",
"}",
"return",
"store",
";",
"}"
] |
Return the list of properties flagged as serializable
@param target: host object
|
[
"Return",
"the",
"list",
"of",
"properties",
"flagged",
"as",
"serializable"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L5104-L5138
|
9,618
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function () {
var boundingBox = this.boundingBox;
var size = boundingBox.maximumWorld.subtract(boundingBox.minimumWorld);
return size.length();
}
|
javascript
|
function () {
var boundingBox = this.boundingBox;
var size = boundingBox.maximumWorld.subtract(boundingBox.minimumWorld);
return size.length();
}
|
[
"function",
"(",
")",
"{",
"var",
"boundingBox",
"=",
"this",
".",
"boundingBox",
";",
"var",
"size",
"=",
"boundingBox",
".",
"maximumWorld",
".",
"subtract",
"(",
"boundingBox",
".",
"minimumWorld",
")",
";",
"return",
"size",
".",
"length",
"(",
")",
";",
"}"
] |
Gets the world distance between the min and max points of the bounding box
|
[
"Gets",
"the",
"world",
"distance",
"between",
"the",
"min",
"and",
"max",
"points",
"of",
"the",
"bounding",
"box"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L12235-L12239
|
|
9,619
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
RenderingGroup
|
function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
this.index = index;
this._opaqueSubMeshes = new BABYLON.SmartArray(256);
this._transparentSubMeshes = new BABYLON.SmartArray(256);
this._alphaTestSubMeshes = new BABYLON.SmartArray(256);
this._depthOnlySubMeshes = new BABYLON.SmartArray(256);
this._particleSystems = new BABYLON.SmartArray(256);
this._spriteManagers = new BABYLON.SmartArray(256);
this._edgesRenderers = new BABYLON.SmartArray(16);
this._scene = scene;
this.opaqueSortCompareFn = opaqueSortCompareFn;
this.alphaTestSortCompareFn = alphaTestSortCompareFn;
this.transparentSortCompareFn = transparentSortCompareFn;
}
|
javascript
|
function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
this.index = index;
this._opaqueSubMeshes = new BABYLON.SmartArray(256);
this._transparentSubMeshes = new BABYLON.SmartArray(256);
this._alphaTestSubMeshes = new BABYLON.SmartArray(256);
this._depthOnlySubMeshes = new BABYLON.SmartArray(256);
this._particleSystems = new BABYLON.SmartArray(256);
this._spriteManagers = new BABYLON.SmartArray(256);
this._edgesRenderers = new BABYLON.SmartArray(16);
this._scene = scene;
this.opaqueSortCompareFn = opaqueSortCompareFn;
this.alphaTestSortCompareFn = alphaTestSortCompareFn;
this.transparentSortCompareFn = transparentSortCompareFn;
}
|
[
"function",
"RenderingGroup",
"(",
"index",
",",
"scene",
",",
"opaqueSortCompareFn",
",",
"alphaTestSortCompareFn",
",",
"transparentSortCompareFn",
")",
"{",
"if",
"(",
"opaqueSortCompareFn",
"===",
"void",
"0",
")",
"{",
"opaqueSortCompareFn",
"=",
"null",
";",
"}",
"if",
"(",
"alphaTestSortCompareFn",
"===",
"void",
"0",
")",
"{",
"alphaTestSortCompareFn",
"=",
"null",
";",
"}",
"if",
"(",
"transparentSortCompareFn",
"===",
"void",
"0",
")",
"{",
"transparentSortCompareFn",
"=",
"null",
";",
"}",
"this",
".",
"index",
"=",
"index",
";",
"this",
".",
"_opaqueSubMeshes",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_transparentSubMeshes",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_alphaTestSubMeshes",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_depthOnlySubMeshes",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_particleSystems",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_spriteManagers",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"256",
")",
";",
"this",
".",
"_edgesRenderers",
"=",
"new",
"BABYLON",
".",
"SmartArray",
"(",
"16",
")",
";",
"this",
".",
"_scene",
"=",
"scene",
";",
"this",
".",
"opaqueSortCompareFn",
"=",
"opaqueSortCompareFn",
";",
"this",
".",
"alphaTestSortCompareFn",
"=",
"alphaTestSortCompareFn",
";",
"this",
".",
"transparentSortCompareFn",
"=",
"transparentSortCompareFn",
";",
"}"
] |
Creates a new rendering group.
@param index The rendering group index
@param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
@param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
@param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
|
[
"Creates",
"a",
"new",
"rendering",
"group",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L16290-L16306
|
9,620
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
UniformBuffer
|
function UniformBuffer(engine, data, dynamic) {
this._engine = engine;
this._noUBO = !engine.supportsUniformBuffers;
this._dynamic = dynamic;
this._data = data || [];
this._uniformLocations = {};
this._uniformSizes = {};
this._uniformLocationPointer = 0;
this._needSync = false;
if (this._noUBO) {
this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
this.updateFloat = this._updateFloatForEffect;
this.updateFloat2 = this._updateFloat2ForEffect;
this.updateFloat3 = this._updateFloat3ForEffect;
this.updateFloat4 = this._updateFloat4ForEffect;
this.updateMatrix = this._updateMatrixForEffect;
this.updateVector3 = this._updateVector3ForEffect;
this.updateVector4 = this._updateVector4ForEffect;
this.updateColor3 = this._updateColor3ForEffect;
this.updateColor4 = this._updateColor4ForEffect;
}
else {
this._engine._uniformBuffers.push(this);
this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
this.updateFloat = this._updateFloatForUniform;
this.updateFloat2 = this._updateFloat2ForUniform;
this.updateFloat3 = this._updateFloat3ForUniform;
this.updateFloat4 = this._updateFloat4ForUniform;
this.updateMatrix = this._updateMatrixForUniform;
this.updateVector3 = this._updateVector3ForUniform;
this.updateVector4 = this._updateVector4ForUniform;
this.updateColor3 = this._updateColor3ForUniform;
this.updateColor4 = this._updateColor4ForUniform;
}
}
|
javascript
|
function UniformBuffer(engine, data, dynamic) {
this._engine = engine;
this._noUBO = !engine.supportsUniformBuffers;
this._dynamic = dynamic;
this._data = data || [];
this._uniformLocations = {};
this._uniformSizes = {};
this._uniformLocationPointer = 0;
this._needSync = false;
if (this._noUBO) {
this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
this.updateFloat = this._updateFloatForEffect;
this.updateFloat2 = this._updateFloat2ForEffect;
this.updateFloat3 = this._updateFloat3ForEffect;
this.updateFloat4 = this._updateFloat4ForEffect;
this.updateMatrix = this._updateMatrixForEffect;
this.updateVector3 = this._updateVector3ForEffect;
this.updateVector4 = this._updateVector4ForEffect;
this.updateColor3 = this._updateColor3ForEffect;
this.updateColor4 = this._updateColor4ForEffect;
}
else {
this._engine._uniformBuffers.push(this);
this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
this.updateFloat = this._updateFloatForUniform;
this.updateFloat2 = this._updateFloat2ForUniform;
this.updateFloat3 = this._updateFloat3ForUniform;
this.updateFloat4 = this._updateFloat4ForUniform;
this.updateMatrix = this._updateMatrixForUniform;
this.updateVector3 = this._updateVector3ForUniform;
this.updateVector4 = this._updateVector4ForUniform;
this.updateColor3 = this._updateColor3ForUniform;
this.updateColor4 = this._updateColor4ForUniform;
}
}
|
[
"function",
"UniformBuffer",
"(",
"engine",
",",
"data",
",",
"dynamic",
")",
"{",
"this",
".",
"_engine",
"=",
"engine",
";",
"this",
".",
"_noUBO",
"=",
"!",
"engine",
".",
"supportsUniformBuffers",
";",
"this",
".",
"_dynamic",
"=",
"dynamic",
";",
"this",
".",
"_data",
"=",
"data",
"||",
"[",
"]",
";",
"this",
".",
"_uniformLocations",
"=",
"{",
"}",
";",
"this",
".",
"_uniformSizes",
"=",
"{",
"}",
";",
"this",
".",
"_uniformLocationPointer",
"=",
"0",
";",
"this",
".",
"_needSync",
"=",
"false",
";",
"if",
"(",
"this",
".",
"_noUBO",
")",
"{",
"this",
".",
"updateMatrix3x3",
"=",
"this",
".",
"_updateMatrix3x3ForEffect",
";",
"this",
".",
"updateMatrix2x2",
"=",
"this",
".",
"_updateMatrix2x2ForEffect",
";",
"this",
".",
"updateFloat",
"=",
"this",
".",
"_updateFloatForEffect",
";",
"this",
".",
"updateFloat2",
"=",
"this",
".",
"_updateFloat2ForEffect",
";",
"this",
".",
"updateFloat3",
"=",
"this",
".",
"_updateFloat3ForEffect",
";",
"this",
".",
"updateFloat4",
"=",
"this",
".",
"_updateFloat4ForEffect",
";",
"this",
".",
"updateMatrix",
"=",
"this",
".",
"_updateMatrixForEffect",
";",
"this",
".",
"updateVector3",
"=",
"this",
".",
"_updateVector3ForEffect",
";",
"this",
".",
"updateVector4",
"=",
"this",
".",
"_updateVector4ForEffect",
";",
"this",
".",
"updateColor3",
"=",
"this",
".",
"_updateColor3ForEffect",
";",
"this",
".",
"updateColor4",
"=",
"this",
".",
"_updateColor4ForEffect",
";",
"}",
"else",
"{",
"this",
".",
"_engine",
".",
"_uniformBuffers",
".",
"push",
"(",
"this",
")",
";",
"this",
".",
"updateMatrix3x3",
"=",
"this",
".",
"_updateMatrix3x3ForUniform",
";",
"this",
".",
"updateMatrix2x2",
"=",
"this",
".",
"_updateMatrix2x2ForUniform",
";",
"this",
".",
"updateFloat",
"=",
"this",
".",
"_updateFloatForUniform",
";",
"this",
".",
"updateFloat2",
"=",
"this",
".",
"_updateFloat2ForUniform",
";",
"this",
".",
"updateFloat3",
"=",
"this",
".",
"_updateFloat3ForUniform",
";",
"this",
".",
"updateFloat4",
"=",
"this",
".",
"_updateFloat4ForUniform",
";",
"this",
".",
"updateMatrix",
"=",
"this",
".",
"_updateMatrixForUniform",
";",
"this",
".",
"updateVector3",
"=",
"this",
".",
"_updateVector3ForUniform",
";",
"this",
".",
"updateVector4",
"=",
"this",
".",
"_updateVector4ForUniform",
";",
"this",
".",
"updateColor3",
"=",
"this",
".",
"_updateColor3ForUniform",
";",
"this",
".",
"updateColor4",
"=",
"this",
".",
"_updateColor4ForUniform",
";",
"}",
"}"
] |
Uniform buffer objects.
Handles blocks of uniform on the GPU.
If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
For more information, please refer to :
https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
|
[
"Uniform",
"buffer",
"objects",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L26585-L26621
|
9,621
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
ColorGradingTexture
|
function ColorGradingTexture(url, scene) {
var _this = _super.call(this, scene) || this;
if (!url) {
return _this;
}
_this._textureMatrix = BABYLON.Matrix.Identity();
_this.name = url;
_this.url = url;
_this.hasAlpha = false;
_this.isCube = false;
_this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
_this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
_this.anisotropicFilteringLevel = 1;
_this._texture = _this._getFromCache(url, true);
if (!_this._texture) {
if (!scene.useDelayedTextureLoading) {
_this.loadTexture();
}
else {
_this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
}
}
return _this;
}
|
javascript
|
function ColorGradingTexture(url, scene) {
var _this = _super.call(this, scene) || this;
if (!url) {
return _this;
}
_this._textureMatrix = BABYLON.Matrix.Identity();
_this.name = url;
_this.url = url;
_this.hasAlpha = false;
_this.isCube = false;
_this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
_this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
_this.anisotropicFilteringLevel = 1;
_this._texture = _this._getFromCache(url, true);
if (!_this._texture) {
if (!scene.useDelayedTextureLoading) {
_this.loadTexture();
}
else {
_this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
}
}
return _this;
}
|
[
"function",
"ColorGradingTexture",
"(",
"url",
",",
"scene",
")",
"{",
"var",
"_this",
"=",
"_super",
".",
"call",
"(",
"this",
",",
"scene",
")",
"||",
"this",
";",
"if",
"(",
"!",
"url",
")",
"{",
"return",
"_this",
";",
"}",
"_this",
".",
"_textureMatrix",
"=",
"BABYLON",
".",
"Matrix",
".",
"Identity",
"(",
")",
";",
"_this",
".",
"name",
"=",
"url",
";",
"_this",
".",
"url",
"=",
"url",
";",
"_this",
".",
"hasAlpha",
"=",
"false",
";",
"_this",
".",
"isCube",
"=",
"false",
";",
"_this",
".",
"wrapU",
"=",
"BABYLON",
".",
"Texture",
".",
"CLAMP_ADDRESSMODE",
";",
"_this",
".",
"wrapV",
"=",
"BABYLON",
".",
"Texture",
".",
"CLAMP_ADDRESSMODE",
";",
"_this",
".",
"anisotropicFilteringLevel",
"=",
"1",
";",
"_this",
".",
"_texture",
"=",
"_this",
".",
"_getFromCache",
"(",
"url",
",",
"true",
")",
";",
"if",
"(",
"!",
"_this",
".",
"_texture",
")",
"{",
"if",
"(",
"!",
"scene",
".",
"useDelayedTextureLoading",
")",
"{",
"_this",
".",
"loadTexture",
"(",
")",
";",
"}",
"else",
"{",
"_this",
".",
"delayLoadState",
"=",
"BABYLON",
".",
"Engine",
".",
"DELAYLOADSTATE_NOTLOADED",
";",
"}",
"}",
"return",
"_this",
";",
"}"
] |
Instantiates a ColorGradingTexture from the following parameters.
@param url The location of the color gradind data (currently only supporting 3dl)
@param scene The scene the texture will be used in
|
[
"Instantiates",
"a",
"ColorGradingTexture",
"from",
"the",
"following",
"parameters",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L31449-L31472
|
9,622
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (value) {
if (this._transparencyMode === value) {
return;
}
this._transparencyMode = value;
if (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND) {
this._forceAlphaTest = true;
}
else {
this._forceAlphaTest = false;
}
this._markAllSubMeshesAsTexturesDirty();
}
|
javascript
|
function (value) {
if (this._transparencyMode === value) {
return;
}
this._transparencyMode = value;
if (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND) {
this._forceAlphaTest = true;
}
else {
this._forceAlphaTest = false;
}
this._markAllSubMeshesAsTexturesDirty();
}
|
[
"function",
"(",
"value",
")",
"{",
"if",
"(",
"this",
".",
"_transparencyMode",
"===",
"value",
")",
"{",
"return",
";",
"}",
"this",
".",
"_transparencyMode",
"=",
"value",
";",
"if",
"(",
"value",
"===",
"BABYLON",
".",
"PBRMaterial",
".",
"PBRMATERIAL_ALPHATESTANDBLEND",
")",
"{",
"this",
".",
"_forceAlphaTest",
"=",
"true",
";",
"}",
"else",
"{",
"this",
".",
"_forceAlphaTest",
"=",
"false",
";",
"}",
"this",
".",
"_markAllSubMeshesAsTexturesDirty",
"(",
")",
";",
"}"
] |
Sets the transparency mode of the material.
|
[
"Sets",
"the",
"transparency",
"mode",
"of",
"the",
"material",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L34801-L34813
|
|
9,623
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
PBRMetallicRoughnessMaterial
|
function PBRMetallicRoughnessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useRoughnessFromMetallicTextureAlpha = false;
_this._useRoughnessFromMetallicTextureGreen = true;
_this._useMetallnessFromMetallicTextureBlue = true;
return _this;
}
|
javascript
|
function PBRMetallicRoughnessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useRoughnessFromMetallicTextureAlpha = false;
_this._useRoughnessFromMetallicTextureGreen = true;
_this._useMetallnessFromMetallicTextureBlue = true;
return _this;
}
|
[
"function",
"PBRMetallicRoughnessMaterial",
"(",
"name",
",",
"scene",
")",
"{",
"var",
"_this",
"=",
"_super",
".",
"call",
"(",
"this",
",",
"name",
",",
"scene",
")",
"||",
"this",
";",
"_this",
".",
"_useRoughnessFromMetallicTextureAlpha",
"=",
"false",
";",
"_this",
".",
"_useRoughnessFromMetallicTextureGreen",
"=",
"true",
";",
"_this",
".",
"_useMetallnessFromMetallicTextureBlue",
"=",
"true",
";",
"return",
"_this",
";",
"}"
] |
Instantiates a new PBRMetalRoughnessMaterial instance.
@param name The material name
@param scene The scene the material will be use in.
|
[
"Instantiates",
"a",
"new",
"PBRMetalRoughnessMaterial",
"instance",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L35676-L35682
|
9,624
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
PBRSpecularGlossinessMaterial
|
function PBRSpecularGlossinessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useMicroSurfaceFromReflectivityMapAlpha = true;
return _this;
}
|
javascript
|
function PBRSpecularGlossinessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useMicroSurfaceFromReflectivityMapAlpha = true;
return _this;
}
|
[
"function",
"PBRSpecularGlossinessMaterial",
"(",
"name",
",",
"scene",
")",
"{",
"var",
"_this",
"=",
"_super",
".",
"call",
"(",
"this",
",",
"name",
",",
"scene",
")",
"||",
"this",
";",
"_this",
".",
"_useMicroSurfaceFromReflectivityMapAlpha",
"=",
"true",
";",
"return",
"_this",
";",
"}"
] |
Instantiates a new PBRSpecularGlossinessMaterial instance.
@param name The material name
@param scene The scene the material will be use in.
|
[
"Instantiates",
"a",
"new",
"PBRSpecularGlossinessMaterial",
"instance",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L35784-L35788
|
9,625
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (value) {
var previousNeedCube = this.needCube();
this._direction = value;
if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
this._shadowGenerator.recreateShadowMap();
}
}
|
javascript
|
function (value) {
var previousNeedCube = this.needCube();
this._direction = value;
if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
this._shadowGenerator.recreateShadowMap();
}
}
|
[
"function",
"(",
"value",
")",
"{",
"var",
"previousNeedCube",
"=",
"this",
".",
"needCube",
"(",
")",
";",
"this",
".",
"_direction",
"=",
"value",
";",
"if",
"(",
"this",
".",
"needCube",
"(",
")",
"!==",
"previousNeedCube",
"&&",
"this",
".",
"_shadowGenerator",
")",
"{",
"this",
".",
"_shadowGenerator",
".",
"recreateShadowMap",
"(",
")",
";",
"}",
"}"
] |
In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
|
[
"In",
"case",
"of",
"direction",
"provided",
"the",
"shadow",
"will",
"not",
"use",
"a",
"cube",
"texture",
"but",
"simulate",
"a",
"spot",
"shadow",
"as",
"a",
"fallback"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L38480-L38486
|
|
9,626
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function () {
for (var index = 0; index < this.actions.length; index++) {
var action = this.actions[index];
if (action.trigger >= ActionManager._OnPickTrigger && action.trigger <= ActionManager._OnPointerOutTrigger) {
return true;
}
}
return false;
}
|
javascript
|
function () {
for (var index = 0; index < this.actions.length; index++) {
var action = this.actions[index];
if (action.trigger >= ActionManager._OnPickTrigger && action.trigger <= ActionManager._OnPointerOutTrigger) {
return true;
}
}
return false;
}
|
[
"function",
"(",
")",
"{",
"for",
"(",
"var",
"index",
"=",
"0",
";",
"index",
"<",
"this",
".",
"actions",
".",
"length",
";",
"index",
"++",
")",
"{",
"var",
"action",
"=",
"this",
".",
"actions",
"[",
"index",
"]",
";",
"if",
"(",
"action",
".",
"trigger",
">=",
"ActionManager",
".",
"_OnPickTrigger",
"&&",
"action",
".",
"trigger",
"<=",
"ActionManager",
".",
"_OnPointerOutTrigger",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Does this action manager has pointer triggers
@return {boolean} whether or not it has pointer triggers
|
[
"Does",
"this",
"action",
"manager",
"has",
"pointer",
"triggers"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L40749-L40757
|
|
9,627
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function () {
for (var t in ActionManager.Triggers) {
if (ActionManager.Triggers.hasOwnProperty(t)) {
var t_int = parseInt(t);
if (t_int >= ActionManager._OnPickTrigger && t_int <= ActionManager._OnPickUpTrigger) {
return true;
}
}
}
return false;
}
|
javascript
|
function () {
for (var t in ActionManager.Triggers) {
if (ActionManager.Triggers.hasOwnProperty(t)) {
var t_int = parseInt(t);
if (t_int >= ActionManager._OnPickTrigger && t_int <= ActionManager._OnPickUpTrigger) {
return true;
}
}
}
return false;
}
|
[
"function",
"(",
")",
"{",
"for",
"(",
"var",
"t",
"in",
"ActionManager",
".",
"Triggers",
")",
"{",
"if",
"(",
"ActionManager",
".",
"Triggers",
".",
"hasOwnProperty",
"(",
"t",
")",
")",
"{",
"var",
"t_int",
"=",
"parseInt",
"(",
"t",
")",
";",
"if",
"(",
"t_int",
">=",
"ActionManager",
".",
"_OnPickTrigger",
"&&",
"t_int",
"<=",
"ActionManager",
".",
"_OnPickUpTrigger",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Does exist one action manager with at least one pick trigger
@return {boolean} whether or not it exists one action manager with one pick trigger
|
[
"Does",
"exist",
"one",
"action",
"manager",
"with",
"at",
"least",
"one",
"pick",
"trigger"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L40799-L40809
|
|
9,628
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (name, params) {
var newInstance = Object.create(BABYLON.Tools.Instantiate("BABYLON." + name).prototype);
newInstance.constructor.apply(newInstance, params);
return newInstance;
}
|
javascript
|
function (name, params) {
var newInstance = Object.create(BABYLON.Tools.Instantiate("BABYLON." + name).prototype);
newInstance.constructor.apply(newInstance, params);
return newInstance;
}
|
[
"function",
"(",
"name",
",",
"params",
")",
"{",
"var",
"newInstance",
"=",
"Object",
".",
"create",
"(",
"BABYLON",
".",
"Tools",
".",
"Instantiate",
"(",
"\"BABYLON.\"",
"+",
"name",
")",
".",
"prototype",
")",
";",
"newInstance",
".",
"constructor",
".",
"apply",
"(",
"newInstance",
",",
"params",
")",
";",
"return",
"newInstance",
";",
"}"
] |
instanciate a new object
|
[
"instanciate",
"a",
"new",
"object"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L40935-L40939
|
|
9,629
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (value) {
if (this._intersectionThreshold === value) {
return;
}
this._intersectionThreshold = value;
if (this.geometry) {
this.geometry.boundingBias = new BABYLON.Vector2(0, value);
}
}
|
javascript
|
function (value) {
if (this._intersectionThreshold === value) {
return;
}
this._intersectionThreshold = value;
if (this.geometry) {
this.geometry.boundingBias = new BABYLON.Vector2(0, value);
}
}
|
[
"function",
"(",
"value",
")",
"{",
"if",
"(",
"this",
".",
"_intersectionThreshold",
"===",
"value",
")",
"{",
"return",
";",
"}",
"this",
".",
"_intersectionThreshold",
"=",
"value",
";",
"if",
"(",
"this",
".",
"geometry",
")",
"{",
"this",
".",
"geometry",
".",
"boundingBias",
"=",
"new",
"BABYLON",
".",
"Vector2",
"(",
"0",
",",
"value",
")",
";",
"}",
"}"
] |
The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
This margin is expressed in world space coordinates, so its value may vary.
@param value the new threshold to apply
|
[
"The",
"intersection",
"Threshold",
"is",
"the",
"margin",
"applied",
"when",
"intersection",
"a",
"segment",
"of",
"the",
"LinesMesh",
"with",
"a",
"Ray",
".",
"This",
"margin",
"is",
"expressed",
"in",
"world",
"space",
"coordinates",
"so",
"its",
"value",
"may",
"vary",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L45158-L45166
|
|
9,630
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
getChildByName
|
function getChildByName(node, name) {
return node.getChildMeshes(false, function (n) { return n.name === name; })[0];
}
|
javascript
|
function getChildByName(node, name) {
return node.getChildMeshes(false, function (n) { return n.name === name; })[0];
}
|
[
"function",
"getChildByName",
"(",
"node",
",",
"name",
")",
"{",
"return",
"node",
".",
"getChildMeshes",
"(",
"false",
",",
"function",
"(",
"n",
")",
"{",
"return",
"n",
".",
"name",
"===",
"name",
";",
"}",
")",
"[",
"0",
"]",
";",
"}"
] |
Look through all children recursively. This will return null if no mesh exists with the given name.
|
[
"Look",
"through",
"all",
"children",
"recursively",
".",
"This",
"will",
"return",
"null",
"if",
"no",
"mesh",
"exists",
"with",
"the",
"given",
"name",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L54933-L54935
|
9,631
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
getImmediateChildByName
|
function getImmediateChildByName(node, name) {
return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
}
|
javascript
|
function getImmediateChildByName(node, name) {
return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
}
|
[
"function",
"getImmediateChildByName",
"(",
"node",
",",
"name",
")",
"{",
"return",
"node",
".",
"getChildMeshes",
"(",
"true",
",",
"function",
"(",
"n",
")",
"{",
"return",
"n",
".",
"name",
"==",
"name",
";",
"}",
")",
"[",
"0",
"]",
";",
"}"
] |
Look through only immediate children. This will return null if no mesh exists with the given name.
|
[
"Look",
"through",
"only",
"immediate",
"children",
".",
"This",
"will",
"return",
"null",
"if",
"no",
"mesh",
"exists",
"with",
"the",
"given",
"name",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L54937-L54939
|
9,632
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (subMesh) {
var mesh = subMesh.getRenderingMesh();
if (_this._meshExcluded(mesh)) {
return;
}
var scene = mesh.getScene();
var engine = scene.getEngine();
// Culling
engine.setState(subMesh.getMaterial().backFaceCulling);
// Managing instances
var batch = mesh._getInstancesRenderList(subMesh._id);
if (batch.mustReturn) {
return;
}
var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
if (_this.isReady(subMesh, hardwareInstancedRendering)) {
var effect = _this._volumetricLightScatteringPass;
if (mesh === _this.mesh) {
if (subMesh.effect) {
effect = subMesh.effect;
}
else {
effect = subMesh.getMaterial().getEffect();
}
}
engine.enableEffect(effect);
mesh._bind(subMesh, effect, BABYLON.Material.TriangleFillMode);
if (mesh === _this.mesh) {
subMesh.getMaterial().bind(mesh.getWorldMatrix(), mesh);
}
else {
var material = subMesh.getMaterial();
_this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
// Alpha test
if (material && material.needAlphaTesting()) {
var alphaTexture = material.getAlphaTestTexture();
_this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
if (alphaTexture) {
_this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
}
}
// Bones
if (mesh.useBones && mesh.computeBonesUsingShaders) {
_this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
}
}
// Draw
mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, BABYLON.Material.TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
}
}
|
javascript
|
function (subMesh) {
var mesh = subMesh.getRenderingMesh();
if (_this._meshExcluded(mesh)) {
return;
}
var scene = mesh.getScene();
var engine = scene.getEngine();
// Culling
engine.setState(subMesh.getMaterial().backFaceCulling);
// Managing instances
var batch = mesh._getInstancesRenderList(subMesh._id);
if (batch.mustReturn) {
return;
}
var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
if (_this.isReady(subMesh, hardwareInstancedRendering)) {
var effect = _this._volumetricLightScatteringPass;
if (mesh === _this.mesh) {
if (subMesh.effect) {
effect = subMesh.effect;
}
else {
effect = subMesh.getMaterial().getEffect();
}
}
engine.enableEffect(effect);
mesh._bind(subMesh, effect, BABYLON.Material.TriangleFillMode);
if (mesh === _this.mesh) {
subMesh.getMaterial().bind(mesh.getWorldMatrix(), mesh);
}
else {
var material = subMesh.getMaterial();
_this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
// Alpha test
if (material && material.needAlphaTesting()) {
var alphaTexture = material.getAlphaTestTexture();
_this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
if (alphaTexture) {
_this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
}
}
// Bones
if (mesh.useBones && mesh.computeBonesUsingShaders) {
_this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
}
}
// Draw
mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, BABYLON.Material.TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
}
}
|
[
"function",
"(",
"subMesh",
")",
"{",
"var",
"mesh",
"=",
"subMesh",
".",
"getRenderingMesh",
"(",
")",
";",
"if",
"(",
"_this",
".",
"_meshExcluded",
"(",
"mesh",
")",
")",
"{",
"return",
";",
"}",
"var",
"scene",
"=",
"mesh",
".",
"getScene",
"(",
")",
";",
"var",
"engine",
"=",
"scene",
".",
"getEngine",
"(",
")",
";",
"// Culling",
"engine",
".",
"setState",
"(",
"subMesh",
".",
"getMaterial",
"(",
")",
".",
"backFaceCulling",
")",
";",
"// Managing instances",
"var",
"batch",
"=",
"mesh",
".",
"_getInstancesRenderList",
"(",
"subMesh",
".",
"_id",
")",
";",
"if",
"(",
"batch",
".",
"mustReturn",
")",
"{",
"return",
";",
"}",
"var",
"hardwareInstancedRendering",
"=",
"(",
"engine",
".",
"getCaps",
"(",
")",
".",
"instancedArrays",
")",
"&&",
"(",
"batch",
".",
"visibleInstances",
"[",
"subMesh",
".",
"_id",
"]",
"!==",
"null",
")",
";",
"if",
"(",
"_this",
".",
"isReady",
"(",
"subMesh",
",",
"hardwareInstancedRendering",
")",
")",
"{",
"var",
"effect",
"=",
"_this",
".",
"_volumetricLightScatteringPass",
";",
"if",
"(",
"mesh",
"===",
"_this",
".",
"mesh",
")",
"{",
"if",
"(",
"subMesh",
".",
"effect",
")",
"{",
"effect",
"=",
"subMesh",
".",
"effect",
";",
"}",
"else",
"{",
"effect",
"=",
"subMesh",
".",
"getMaterial",
"(",
")",
".",
"getEffect",
"(",
")",
";",
"}",
"}",
"engine",
".",
"enableEffect",
"(",
"effect",
")",
";",
"mesh",
".",
"_bind",
"(",
"subMesh",
",",
"effect",
",",
"BABYLON",
".",
"Material",
".",
"TriangleFillMode",
")",
";",
"if",
"(",
"mesh",
"===",
"_this",
".",
"mesh",
")",
"{",
"subMesh",
".",
"getMaterial",
"(",
")",
".",
"bind",
"(",
"mesh",
".",
"getWorldMatrix",
"(",
")",
",",
"mesh",
")",
";",
"}",
"else",
"{",
"var",
"material",
"=",
"subMesh",
".",
"getMaterial",
"(",
")",
";",
"_this",
".",
"_volumetricLightScatteringPass",
".",
"setMatrix",
"(",
"\"viewProjection\"",
",",
"scene",
".",
"getTransformMatrix",
"(",
")",
")",
";",
"// Alpha test",
"if",
"(",
"material",
"&&",
"material",
".",
"needAlphaTesting",
"(",
")",
")",
"{",
"var",
"alphaTexture",
"=",
"material",
".",
"getAlphaTestTexture",
"(",
")",
";",
"_this",
".",
"_volumetricLightScatteringPass",
".",
"setTexture",
"(",
"\"diffuseSampler\"",
",",
"alphaTexture",
")",
";",
"if",
"(",
"alphaTexture",
")",
"{",
"_this",
".",
"_volumetricLightScatteringPass",
".",
"setMatrix",
"(",
"\"diffuseMatrix\"",
",",
"alphaTexture",
".",
"getTextureMatrix",
"(",
")",
")",
";",
"}",
"}",
"// Bones",
"if",
"(",
"mesh",
".",
"useBones",
"&&",
"mesh",
".",
"computeBonesUsingShaders",
")",
"{",
"_this",
".",
"_volumetricLightScatteringPass",
".",
"setMatrices",
"(",
"\"mBones\"",
",",
"mesh",
".",
"skeleton",
".",
"getTransformMatrices",
"(",
"mesh",
")",
")",
";",
"}",
"}",
"// Draw",
"mesh",
".",
"_processRendering",
"(",
"subMesh",
",",
"_this",
".",
"_volumetricLightScatteringPass",
",",
"BABYLON",
".",
"Material",
".",
"TriangleFillMode",
",",
"batch",
",",
"hardwareInstancedRendering",
",",
"function",
"(",
"isInstance",
",",
"world",
")",
"{",
"return",
"effect",
".",
"setMatrix",
"(",
"\"world\"",
",",
"world",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Custom render function for submeshes
|
[
"Custom",
"render",
"function",
"for",
"submeshes"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L58169-L58218
|
|
9,633
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (v) {
if (this._idealKernel === v) {
return;
}
v = Math.max(v, 1);
this._idealKernel = v;
this._kernel = this._nearestBestKernel(v);
this._updateParameters();
}
|
javascript
|
function (v) {
if (this._idealKernel === v) {
return;
}
v = Math.max(v, 1);
this._idealKernel = v;
this._kernel = this._nearestBestKernel(v);
this._updateParameters();
}
|
[
"function",
"(",
"v",
")",
"{",
"if",
"(",
"this",
".",
"_idealKernel",
"===",
"v",
")",
"{",
"return",
";",
"}",
"v",
"=",
"Math",
".",
"max",
"(",
"v",
",",
"1",
")",
";",
"this",
".",
"_idealKernel",
"=",
"v",
";",
"this",
".",
"_kernel",
"=",
"this",
".",
"_nearestBestKernel",
"(",
"v",
")",
";",
"this",
".",
"_updateParameters",
"(",
")",
";",
"}"
] |
Sets the length in pixels of the blur sample region
|
[
"Sets",
"the",
"length",
"in",
"pixels",
"of",
"the",
"blur",
"sample",
"region"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L58884-L58892
|
|
9,634
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
HDRCubeTexture
|
function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
if (noMipmap === void 0) { noMipmap = false; }
if (generateHarmonics === void 0) { generateHarmonics = true; }
if (useInGammaSpace === void 0) { useInGammaSpace = false; }
if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
if (onLoad === void 0) { onLoad = null; }
if (onError === void 0) { onError = null; }
var _this = _super.call(this, scene) || this;
_this._useInGammaSpace = false;
_this._generateHarmonics = true;
_this._isBABYLONPreprocessed = false;
_this._onLoad = null;
_this._onError = null;
/**
* The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
*/
_this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
/**
* Specifies wether the texture has been generated through the PMREMGenerator tool.
* This is usefull at run time to apply the good shader.
*/
_this.isPMREM = false;
_this._isBlocking = true;
if (!url) {
return _this;
}
_this.name = url;
_this.url = url;
_this.hasAlpha = false;
_this.isCube = true;
_this._textureMatrix = BABYLON.Matrix.Identity();
_this._onLoad = onLoad;
_this._onError = onError;
_this.gammaSpace = false;
if (size) {
_this._isBABYLONPreprocessed = false;
_this._noMipmap = noMipmap;
_this._size = size;
_this._useInGammaSpace = useInGammaSpace;
_this._usePMREMGenerator = usePMREMGenerator &&
scene.getEngine().getCaps().textureLOD &&
_this.getScene().getEngine().getCaps().textureFloat &&
!_this._useInGammaSpace;
}
else {
_this._isBABYLONPreprocessed = true;
_this._noMipmap = false;
_this._useInGammaSpace = false;
_this._usePMREMGenerator = scene.getEngine().getCaps().textureLOD &&
_this.getScene().getEngine().getCaps().textureFloat &&
!_this._useInGammaSpace;
}
_this.isPMREM = _this._usePMREMGenerator;
_this._texture = _this._getFromCache(url, _this._noMipmap);
if (!_this._texture) {
if (!scene.useDelayedTextureLoading) {
_this.loadTexture();
}
else {
_this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
}
}
return _this;
}
|
javascript
|
function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
if (noMipmap === void 0) { noMipmap = false; }
if (generateHarmonics === void 0) { generateHarmonics = true; }
if (useInGammaSpace === void 0) { useInGammaSpace = false; }
if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
if (onLoad === void 0) { onLoad = null; }
if (onError === void 0) { onError = null; }
var _this = _super.call(this, scene) || this;
_this._useInGammaSpace = false;
_this._generateHarmonics = true;
_this._isBABYLONPreprocessed = false;
_this._onLoad = null;
_this._onError = null;
/**
* The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
*/
_this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
/**
* Specifies wether the texture has been generated through the PMREMGenerator tool.
* This is usefull at run time to apply the good shader.
*/
_this.isPMREM = false;
_this._isBlocking = true;
if (!url) {
return _this;
}
_this.name = url;
_this.url = url;
_this.hasAlpha = false;
_this.isCube = true;
_this._textureMatrix = BABYLON.Matrix.Identity();
_this._onLoad = onLoad;
_this._onError = onError;
_this.gammaSpace = false;
if (size) {
_this._isBABYLONPreprocessed = false;
_this._noMipmap = noMipmap;
_this._size = size;
_this._useInGammaSpace = useInGammaSpace;
_this._usePMREMGenerator = usePMREMGenerator &&
scene.getEngine().getCaps().textureLOD &&
_this.getScene().getEngine().getCaps().textureFloat &&
!_this._useInGammaSpace;
}
else {
_this._isBABYLONPreprocessed = true;
_this._noMipmap = false;
_this._useInGammaSpace = false;
_this._usePMREMGenerator = scene.getEngine().getCaps().textureLOD &&
_this.getScene().getEngine().getCaps().textureFloat &&
!_this._useInGammaSpace;
}
_this.isPMREM = _this._usePMREMGenerator;
_this._texture = _this._getFromCache(url, _this._noMipmap);
if (!_this._texture) {
if (!scene.useDelayedTextureLoading) {
_this.loadTexture();
}
else {
_this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
}
}
return _this;
}
|
[
"function",
"HDRCubeTexture",
"(",
"url",
",",
"scene",
",",
"size",
",",
"noMipmap",
",",
"generateHarmonics",
",",
"useInGammaSpace",
",",
"usePMREMGenerator",
",",
"onLoad",
",",
"onError",
")",
"{",
"if",
"(",
"noMipmap",
"===",
"void",
"0",
")",
"{",
"noMipmap",
"=",
"false",
";",
"}",
"if",
"(",
"generateHarmonics",
"===",
"void",
"0",
")",
"{",
"generateHarmonics",
"=",
"true",
";",
"}",
"if",
"(",
"useInGammaSpace",
"===",
"void",
"0",
")",
"{",
"useInGammaSpace",
"=",
"false",
";",
"}",
"if",
"(",
"usePMREMGenerator",
"===",
"void",
"0",
")",
"{",
"usePMREMGenerator",
"=",
"false",
";",
"}",
"if",
"(",
"onLoad",
"===",
"void",
"0",
")",
"{",
"onLoad",
"=",
"null",
";",
"}",
"if",
"(",
"onError",
"===",
"void",
"0",
")",
"{",
"onError",
"=",
"null",
";",
"}",
"var",
"_this",
"=",
"_super",
".",
"call",
"(",
"this",
",",
"scene",
")",
"||",
"this",
";",
"_this",
".",
"_useInGammaSpace",
"=",
"false",
";",
"_this",
".",
"_generateHarmonics",
"=",
"true",
";",
"_this",
".",
"_isBABYLONPreprocessed",
"=",
"false",
";",
"_this",
".",
"_onLoad",
"=",
"null",
";",
"_this",
".",
"_onError",
"=",
"null",
";",
"/**\n * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.\n */",
"_this",
".",
"coordinatesMode",
"=",
"BABYLON",
".",
"Texture",
".",
"CUBIC_MODE",
";",
"/**\n * Specifies wether the texture has been generated through the PMREMGenerator tool.\n * This is usefull at run time to apply the good shader.\n */",
"_this",
".",
"isPMREM",
"=",
"false",
";",
"_this",
".",
"_isBlocking",
"=",
"true",
";",
"if",
"(",
"!",
"url",
")",
"{",
"return",
"_this",
";",
"}",
"_this",
".",
"name",
"=",
"url",
";",
"_this",
".",
"url",
"=",
"url",
";",
"_this",
".",
"hasAlpha",
"=",
"false",
";",
"_this",
".",
"isCube",
"=",
"true",
";",
"_this",
".",
"_textureMatrix",
"=",
"BABYLON",
".",
"Matrix",
".",
"Identity",
"(",
")",
";",
"_this",
".",
"_onLoad",
"=",
"onLoad",
";",
"_this",
".",
"_onError",
"=",
"onError",
";",
"_this",
".",
"gammaSpace",
"=",
"false",
";",
"if",
"(",
"size",
")",
"{",
"_this",
".",
"_isBABYLONPreprocessed",
"=",
"false",
";",
"_this",
".",
"_noMipmap",
"=",
"noMipmap",
";",
"_this",
".",
"_size",
"=",
"size",
";",
"_this",
".",
"_useInGammaSpace",
"=",
"useInGammaSpace",
";",
"_this",
".",
"_usePMREMGenerator",
"=",
"usePMREMGenerator",
"&&",
"scene",
".",
"getEngine",
"(",
")",
".",
"getCaps",
"(",
")",
".",
"textureLOD",
"&&",
"_this",
".",
"getScene",
"(",
")",
".",
"getEngine",
"(",
")",
".",
"getCaps",
"(",
")",
".",
"textureFloat",
"&&",
"!",
"_this",
".",
"_useInGammaSpace",
";",
"}",
"else",
"{",
"_this",
".",
"_isBABYLONPreprocessed",
"=",
"true",
";",
"_this",
".",
"_noMipmap",
"=",
"false",
";",
"_this",
".",
"_useInGammaSpace",
"=",
"false",
";",
"_this",
".",
"_usePMREMGenerator",
"=",
"scene",
".",
"getEngine",
"(",
")",
".",
"getCaps",
"(",
")",
".",
"textureLOD",
"&&",
"_this",
".",
"getScene",
"(",
")",
".",
"getEngine",
"(",
")",
".",
"getCaps",
"(",
")",
".",
"textureFloat",
"&&",
"!",
"_this",
".",
"_useInGammaSpace",
";",
"}",
"_this",
".",
"isPMREM",
"=",
"_this",
".",
"_usePMREMGenerator",
";",
"_this",
".",
"_texture",
"=",
"_this",
".",
"_getFromCache",
"(",
"url",
",",
"_this",
".",
"_noMipmap",
")",
";",
"if",
"(",
"!",
"_this",
".",
"_texture",
")",
"{",
"if",
"(",
"!",
"scene",
".",
"useDelayedTextureLoading",
")",
"{",
"_this",
".",
"loadTexture",
"(",
")",
";",
"}",
"else",
"{",
"_this",
".",
"delayLoadState",
"=",
"BABYLON",
".",
"Engine",
".",
"DELAYLOADSTATE_NOTLOADED",
";",
"}",
"}",
"return",
"_this",
";",
"}"
] |
Instantiates an HDRTexture from the following parameters.
@param url The location of the HDR raw data (Panorama stored in RGBE format)
@param scene The scene the texture will be used in
@param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
@param noMipmap Forces to not generate the mipmap if true
@param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process
@param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
@param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
|
[
"Instantiates",
"an",
"HDRTexture",
"from",
"the",
"following",
"parameters",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L61623-L61686
|
9,635
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
zOrder
|
function zOrder(x, y, minX, minY, size) {
// coords are transformed into non-negative 15-bit integer range
x = 32767 * (x - minX) / size;
y = 32767 * (y - minY) / size;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
|
javascript
|
function zOrder(x, y, minX, minY, size) {
// coords are transformed into non-negative 15-bit integer range
x = 32767 * (x - minX) / size;
y = 32767 * (y - minY) / size;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
|
[
"function",
"zOrder",
"(",
"x",
",",
"y",
",",
"minX",
",",
"minY",
",",
"size",
")",
"{",
"// coords are transformed into non-negative 15-bit integer range",
"x",
"=",
"32767",
"*",
"(",
"x",
"-",
"minX",
")",
"/",
"size",
";",
"y",
"=",
"32767",
"*",
"(",
"y",
"-",
"minY",
")",
"/",
"size",
";",
"x",
"=",
"(",
"x",
"|",
"(",
"x",
"<<",
"8",
")",
")",
"&",
"0x00FF00FF",
";",
"x",
"=",
"(",
"x",
"|",
"(",
"x",
"<<",
"4",
")",
")",
"&",
"0x0F0F0F0F",
";",
"x",
"=",
"(",
"x",
"|",
"(",
"x",
"<<",
"2",
")",
")",
"&",
"0x33333333",
";",
"x",
"=",
"(",
"x",
"|",
"(",
"x",
"<<",
"1",
")",
")",
"&",
"0x55555555",
";",
"y",
"=",
"(",
"y",
"|",
"(",
"y",
"<<",
"8",
")",
")",
"&",
"0x00FF00FF",
";",
"y",
"=",
"(",
"y",
"|",
"(",
"y",
"<<",
"4",
")",
")",
"&",
"0x0F0F0F0F",
";",
"y",
"=",
"(",
"y",
"|",
"(",
"y",
"<<",
"2",
")",
")",
"&",
"0x33333333",
";",
"y",
"=",
"(",
"y",
"|",
"(",
"y",
"<<",
"1",
")",
")",
"&",
"0x55555555",
";",
"return",
"x",
"|",
"(",
"y",
"<<",
"1",
")",
";",
"}"
] |
z-order of a point given coords and size of the data bounding box
|
[
"z",
"-",
"order",
"of",
"a",
"point",
"given",
"coords",
"and",
"size",
"of",
"the",
"data",
"bounding",
"box"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L62408-L62421
|
9,636
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
DynamicFloatArray
|
function DynamicFloatArray(stride, initialElementCount) {
this.compareValueOffset = null;
this.sortingAscending = true;
this._stride = stride;
this.buffer = new Float32Array(stride * initialElementCount);
this._lastUsed = 0;
this._firstFree = 0;
this._allEntries = new Array(initialElementCount);
this._freeEntries = new Array(initialElementCount);
for (var i = 0; i < initialElementCount; i++) {
var element = new DynamicFloatArrayElementInfo();
element.offset = i * stride;
this._allEntries[i] = element;
this._freeEntries[initialElementCount - i - 1] = element;
}
}
|
javascript
|
function DynamicFloatArray(stride, initialElementCount) {
this.compareValueOffset = null;
this.sortingAscending = true;
this._stride = stride;
this.buffer = new Float32Array(stride * initialElementCount);
this._lastUsed = 0;
this._firstFree = 0;
this._allEntries = new Array(initialElementCount);
this._freeEntries = new Array(initialElementCount);
for (var i = 0; i < initialElementCount; i++) {
var element = new DynamicFloatArrayElementInfo();
element.offset = i * stride;
this._allEntries[i] = element;
this._freeEntries[initialElementCount - i - 1] = element;
}
}
|
[
"function",
"DynamicFloatArray",
"(",
"stride",
",",
"initialElementCount",
")",
"{",
"this",
".",
"compareValueOffset",
"=",
"null",
";",
"this",
".",
"sortingAscending",
"=",
"true",
";",
"this",
".",
"_stride",
"=",
"stride",
";",
"this",
".",
"buffer",
"=",
"new",
"Float32Array",
"(",
"stride",
"*",
"initialElementCount",
")",
";",
"this",
".",
"_lastUsed",
"=",
"0",
";",
"this",
".",
"_firstFree",
"=",
"0",
";",
"this",
".",
"_allEntries",
"=",
"new",
"Array",
"(",
"initialElementCount",
")",
";",
"this",
".",
"_freeEntries",
"=",
"new",
"Array",
"(",
"initialElementCount",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"initialElementCount",
";",
"i",
"++",
")",
"{",
"var",
"element",
"=",
"new",
"DynamicFloatArrayElementInfo",
"(",
")",
";",
"element",
".",
"offset",
"=",
"i",
"*",
"stride",
";",
"this",
".",
"_allEntries",
"[",
"i",
"]",
"=",
"element",
";",
"this",
".",
"_freeEntries",
"[",
"initialElementCount",
"-",
"i",
"-",
"1",
"]",
"=",
"element",
";",
"}",
"}"
] |
Construct an instance of the dynamic float array
@param stride size of one element in float (i.e. not bytes!)
@param initialElementCount the number of available entries at construction
|
[
"Construct",
"an",
"instance",
"of",
"the",
"dynamic",
"float",
"array"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L66150-L66165
|
9,637
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
EdgesRenderer
|
function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
if (epsilon === void 0) { epsilon = 0.95; }
if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
this.edgesWidthScalerForOrthographic = 1000.0;
this.edgesWidthScalerForPerspective = 50.0;
this._linesPositions = new Array();
this._linesNormals = new Array();
this._linesIndices = new Array();
this._buffers = {};
this._checkVerticesInsteadOfIndices = false;
this._source = source;
this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
this._epsilon = epsilon;
this._prepareRessources();
this._generateEdgesLines();
}
|
javascript
|
function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
if (epsilon === void 0) { epsilon = 0.95; }
if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
this.edgesWidthScalerForOrthographic = 1000.0;
this.edgesWidthScalerForPerspective = 50.0;
this._linesPositions = new Array();
this._linesNormals = new Array();
this._linesIndices = new Array();
this._buffers = {};
this._checkVerticesInsteadOfIndices = false;
this._source = source;
this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
this._epsilon = epsilon;
this._prepareRessources();
this._generateEdgesLines();
}
|
[
"function",
"EdgesRenderer",
"(",
"source",
",",
"epsilon",
",",
"checkVerticesInsteadOfIndices",
")",
"{",
"if",
"(",
"epsilon",
"===",
"void",
"0",
")",
"{",
"epsilon",
"=",
"0.95",
";",
"}",
"if",
"(",
"checkVerticesInsteadOfIndices",
"===",
"void",
"0",
")",
"{",
"checkVerticesInsteadOfIndices",
"=",
"false",
";",
"}",
"this",
".",
"edgesWidthScalerForOrthographic",
"=",
"1000.0",
";",
"this",
".",
"edgesWidthScalerForPerspective",
"=",
"50.0",
";",
"this",
".",
"_linesPositions",
"=",
"new",
"Array",
"(",
")",
";",
"this",
".",
"_linesNormals",
"=",
"new",
"Array",
"(",
")",
";",
"this",
".",
"_linesIndices",
"=",
"new",
"Array",
"(",
")",
";",
"this",
".",
"_buffers",
"=",
"{",
"}",
";",
"this",
".",
"_checkVerticesInsteadOfIndices",
"=",
"false",
";",
"this",
".",
"_source",
"=",
"source",
";",
"this",
".",
"_checkVerticesInsteadOfIndices",
"=",
"checkVerticesInsteadOfIndices",
";",
"this",
".",
"_epsilon",
"=",
"epsilon",
";",
"this",
".",
"_prepareRessources",
"(",
")",
";",
"this",
".",
"_generateEdgesLines",
"(",
")",
";",
"}"
] |
Beware when you use this class with complex objects as the adjacencies computation can be really long
|
[
"Beware",
"when",
"you",
"use",
"this",
"class",
"with",
"complex",
"objects",
"as",
"the",
"adjacencies",
"computation",
"can",
"be",
"really",
"long"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L70414-L70429
|
9,638
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
HighlightLayer
|
function HighlightLayer(name, scene, options) {
this.name = name;
this._vertexBuffers = {};
this._mainTextureDesiredSize = { width: 0, height: 0 };
this._meshes = {};
this._maxSize = 0;
this._shouldRender = false;
this._instanceGlowingMeshStencilReference = HighlightLayer.glowingMeshStencilReference++;
this._excludedMeshes = {};
/**
* Specifies whether or not the inner glow is ACTIVE in the layer.
*/
this.innerGlow = true;
/**
* Specifies whether or not the outer glow is ACTIVE in the layer.
*/
this.outerGlow = true;
/**
* Specifies wether the highlight layer is enabled or not.
*/
this.isEnabled = true;
/**
* An event triggered when the highlight layer has been disposed.
* @type {BABYLON.Observable}
*/
this.onDisposeObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer is about rendering the main texture with the glowy parts.
* @type {BABYLON.Observable}
*/
this.onBeforeRenderMainTextureObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer is being blurred.
* @type {BABYLON.Observable}
*/
this.onBeforeBlurObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer has been blurred.
* @type {BABYLON.Observable}
*/
this.onAfterBlurObservable = new BABYLON.Observable();
/**
* An event triggered when the glowing blurred texture is being merged in the scene.
* @type {BABYLON.Observable}
*/
this.onBeforeComposeObservable = new BABYLON.Observable();
/**
* An event triggered when the glowing blurred texture has been merged in the scene.
* @type {BABYLON.Observable}
*/
this.onAfterComposeObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer changes its size.
* @type {BABYLON.Observable}
*/
this.onSizeChangedObservable = new BABYLON.Observable();
this._scene = scene || BABYLON.Engine.LastCreatedScene;
var engine = scene.getEngine();
this._engine = engine;
this._maxSize = this._engine.getCaps().maxTextureSize;
this._scene.highlightLayers.push(this);
// Warn on stencil.
if (!this._engine.isStencilEnable) {
BABYLON.Tools.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new BABYLON.Engine(canvas, antialias, { stencil: true }");
}
// Adapt options
this._options = options || {
mainTextureRatio: 0.5,
blurTextureSizeRatio: 0.5,
blurHorizontalSize: 1.0,
blurVerticalSize: 1.0,
alphaBlendingMode: BABYLON.Engine.ALPHA_COMBINE
};
this._options.mainTextureRatio = this._options.mainTextureRatio || 0.5;
this._options.blurTextureSizeRatio = this._options.blurTextureSizeRatio || 1.0;
this._options.blurHorizontalSize = this._options.blurHorizontalSize || 1;
this._options.blurVerticalSize = this._options.blurVerticalSize || 1;
this._options.alphaBlendingMode = this._options.alphaBlendingMode || BABYLON.Engine.ALPHA_COMBINE;
// VBO
var vertices = [];
vertices.push(1, 1);
vertices.push(-1, 1);
vertices.push(-1, -1);
vertices.push(1, -1);
var vertexBuffer = new BABYLON.VertexBuffer(engine, vertices, BABYLON.VertexBuffer.PositionKind, false, false, 2);
this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = vertexBuffer;
this._createIndexBuffer();
// Effect
this._glowMapMergeEffect = engine.createEffect("glowMapMerge", [BABYLON.VertexBuffer.PositionKind], ["offset"], ["textureSampler"], "");
// Render target
this.setMainTextureSize();
// Create Textures and post processes
this.createTextureAndPostProcesses();
}
|
javascript
|
function HighlightLayer(name, scene, options) {
this.name = name;
this._vertexBuffers = {};
this._mainTextureDesiredSize = { width: 0, height: 0 };
this._meshes = {};
this._maxSize = 0;
this._shouldRender = false;
this._instanceGlowingMeshStencilReference = HighlightLayer.glowingMeshStencilReference++;
this._excludedMeshes = {};
/**
* Specifies whether or not the inner glow is ACTIVE in the layer.
*/
this.innerGlow = true;
/**
* Specifies whether or not the outer glow is ACTIVE in the layer.
*/
this.outerGlow = true;
/**
* Specifies wether the highlight layer is enabled or not.
*/
this.isEnabled = true;
/**
* An event triggered when the highlight layer has been disposed.
* @type {BABYLON.Observable}
*/
this.onDisposeObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer is about rendering the main texture with the glowy parts.
* @type {BABYLON.Observable}
*/
this.onBeforeRenderMainTextureObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer is being blurred.
* @type {BABYLON.Observable}
*/
this.onBeforeBlurObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer has been blurred.
* @type {BABYLON.Observable}
*/
this.onAfterBlurObservable = new BABYLON.Observable();
/**
* An event triggered when the glowing blurred texture is being merged in the scene.
* @type {BABYLON.Observable}
*/
this.onBeforeComposeObservable = new BABYLON.Observable();
/**
* An event triggered when the glowing blurred texture has been merged in the scene.
* @type {BABYLON.Observable}
*/
this.onAfterComposeObservable = new BABYLON.Observable();
/**
* An event triggered when the highlight layer changes its size.
* @type {BABYLON.Observable}
*/
this.onSizeChangedObservable = new BABYLON.Observable();
this._scene = scene || BABYLON.Engine.LastCreatedScene;
var engine = scene.getEngine();
this._engine = engine;
this._maxSize = this._engine.getCaps().maxTextureSize;
this._scene.highlightLayers.push(this);
// Warn on stencil.
if (!this._engine.isStencilEnable) {
BABYLON.Tools.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new BABYLON.Engine(canvas, antialias, { stencil: true }");
}
// Adapt options
this._options = options || {
mainTextureRatio: 0.5,
blurTextureSizeRatio: 0.5,
blurHorizontalSize: 1.0,
blurVerticalSize: 1.0,
alphaBlendingMode: BABYLON.Engine.ALPHA_COMBINE
};
this._options.mainTextureRatio = this._options.mainTextureRatio || 0.5;
this._options.blurTextureSizeRatio = this._options.blurTextureSizeRatio || 1.0;
this._options.blurHorizontalSize = this._options.blurHorizontalSize || 1;
this._options.blurVerticalSize = this._options.blurVerticalSize || 1;
this._options.alphaBlendingMode = this._options.alphaBlendingMode || BABYLON.Engine.ALPHA_COMBINE;
// VBO
var vertices = [];
vertices.push(1, 1);
vertices.push(-1, 1);
vertices.push(-1, -1);
vertices.push(1, -1);
var vertexBuffer = new BABYLON.VertexBuffer(engine, vertices, BABYLON.VertexBuffer.PositionKind, false, false, 2);
this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = vertexBuffer;
this._createIndexBuffer();
// Effect
this._glowMapMergeEffect = engine.createEffect("glowMapMerge", [BABYLON.VertexBuffer.PositionKind], ["offset"], ["textureSampler"], "");
// Render target
this.setMainTextureSize();
// Create Textures and post processes
this.createTextureAndPostProcesses();
}
|
[
"function",
"HighlightLayer",
"(",
"name",
",",
"scene",
",",
"options",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"_vertexBuffers",
"=",
"{",
"}",
";",
"this",
".",
"_mainTextureDesiredSize",
"=",
"{",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
";",
"this",
".",
"_meshes",
"=",
"{",
"}",
";",
"this",
".",
"_maxSize",
"=",
"0",
";",
"this",
".",
"_shouldRender",
"=",
"false",
";",
"this",
".",
"_instanceGlowingMeshStencilReference",
"=",
"HighlightLayer",
".",
"glowingMeshStencilReference",
"++",
";",
"this",
".",
"_excludedMeshes",
"=",
"{",
"}",
";",
"/**\n * Specifies whether or not the inner glow is ACTIVE in the layer.\n */",
"this",
".",
"innerGlow",
"=",
"true",
";",
"/**\n * Specifies whether or not the outer glow is ACTIVE in the layer.\n */",
"this",
".",
"outerGlow",
"=",
"true",
";",
"/**\n * Specifies wether the highlight layer is enabled or not.\n */",
"this",
".",
"isEnabled",
"=",
"true",
";",
"/**\n * An event triggered when the highlight layer has been disposed.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onDisposeObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the highlight layer is about rendering the main texture with the glowy parts.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onBeforeRenderMainTextureObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the highlight layer is being blurred.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onBeforeBlurObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the highlight layer has been blurred.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onAfterBlurObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the glowing blurred texture is being merged in the scene.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onBeforeComposeObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the glowing blurred texture has been merged in the scene.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onAfterComposeObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"/**\n * An event triggered when the highlight layer changes its size.\n * @type {BABYLON.Observable}\n */",
"this",
".",
"onSizeChangedObservable",
"=",
"new",
"BABYLON",
".",
"Observable",
"(",
")",
";",
"this",
".",
"_scene",
"=",
"scene",
"||",
"BABYLON",
".",
"Engine",
".",
"LastCreatedScene",
";",
"var",
"engine",
"=",
"scene",
".",
"getEngine",
"(",
")",
";",
"this",
".",
"_engine",
"=",
"engine",
";",
"this",
".",
"_maxSize",
"=",
"this",
".",
"_engine",
".",
"getCaps",
"(",
")",
".",
"maxTextureSize",
";",
"this",
".",
"_scene",
".",
"highlightLayers",
".",
"push",
"(",
"this",
")",
";",
"// Warn on stencil.",
"if",
"(",
"!",
"this",
".",
"_engine",
".",
"isStencilEnable",
")",
"{",
"BABYLON",
".",
"Tools",
".",
"Warn",
"(",
"\"Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new BABYLON.Engine(canvas, antialias, { stencil: true }\"",
")",
";",
"}",
"// Adapt options",
"this",
".",
"_options",
"=",
"options",
"||",
"{",
"mainTextureRatio",
":",
"0.5",
",",
"blurTextureSizeRatio",
":",
"0.5",
",",
"blurHorizontalSize",
":",
"1.0",
",",
"blurVerticalSize",
":",
"1.0",
",",
"alphaBlendingMode",
":",
"BABYLON",
".",
"Engine",
".",
"ALPHA_COMBINE",
"}",
";",
"this",
".",
"_options",
".",
"mainTextureRatio",
"=",
"this",
".",
"_options",
".",
"mainTextureRatio",
"||",
"0.5",
";",
"this",
".",
"_options",
".",
"blurTextureSizeRatio",
"=",
"this",
".",
"_options",
".",
"blurTextureSizeRatio",
"||",
"1.0",
";",
"this",
".",
"_options",
".",
"blurHorizontalSize",
"=",
"this",
".",
"_options",
".",
"blurHorizontalSize",
"||",
"1",
";",
"this",
".",
"_options",
".",
"blurVerticalSize",
"=",
"this",
".",
"_options",
".",
"blurVerticalSize",
"||",
"1",
";",
"this",
".",
"_options",
".",
"alphaBlendingMode",
"=",
"this",
".",
"_options",
".",
"alphaBlendingMode",
"||",
"BABYLON",
".",
"Engine",
".",
"ALPHA_COMBINE",
";",
"// VBO",
"var",
"vertices",
"=",
"[",
"]",
";",
"vertices",
".",
"push",
"(",
"1",
",",
"1",
")",
";",
"vertices",
".",
"push",
"(",
"-",
"1",
",",
"1",
")",
";",
"vertices",
".",
"push",
"(",
"-",
"1",
",",
"-",
"1",
")",
";",
"vertices",
".",
"push",
"(",
"1",
",",
"-",
"1",
")",
";",
"var",
"vertexBuffer",
"=",
"new",
"BABYLON",
".",
"VertexBuffer",
"(",
"engine",
",",
"vertices",
",",
"BABYLON",
".",
"VertexBuffer",
".",
"PositionKind",
",",
"false",
",",
"false",
",",
"2",
")",
";",
"this",
".",
"_vertexBuffers",
"[",
"BABYLON",
".",
"VertexBuffer",
".",
"PositionKind",
"]",
"=",
"vertexBuffer",
";",
"this",
".",
"_createIndexBuffer",
"(",
")",
";",
"// Effect",
"this",
".",
"_glowMapMergeEffect",
"=",
"engine",
".",
"createEffect",
"(",
"\"glowMapMerge\"",
",",
"[",
"BABYLON",
".",
"VertexBuffer",
".",
"PositionKind",
"]",
",",
"[",
"\"offset\"",
"]",
",",
"[",
"\"textureSampler\"",
"]",
",",
"\"\"",
")",
";",
"// Render target",
"this",
".",
"setMainTextureSize",
"(",
")",
";",
"// Create Textures and post processes",
"this",
".",
"createTextureAndPostProcesses",
"(",
")",
";",
"}"
] |
Instantiates a new highlight Layer and references it to the scene..
@param name The name of the layer
@param scene The scene to use the layer in
@param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
|
[
"Instantiates",
"a",
"new",
"highlight",
"Layer",
"and",
"references",
"it",
"to",
"the",
"scene",
".."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L70710-L70803
|
9,639
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
RectPackingMap
|
function RectPackingMap(size, margin) {
if (margin === void 0) { margin = 0; }
var _this = _super.call(this, null, null, BABYLON.Vector2.Zero(), size) || this;
_this._margin = margin;
_this._root = _this;
return _this;
}
|
javascript
|
function RectPackingMap(size, margin) {
if (margin === void 0) { margin = 0; }
var _this = _super.call(this, null, null, BABYLON.Vector2.Zero(), size) || this;
_this._margin = margin;
_this._root = _this;
return _this;
}
|
[
"function",
"RectPackingMap",
"(",
"size",
",",
"margin",
")",
"{",
"if",
"(",
"margin",
"===",
"void",
"0",
")",
"{",
"margin",
"=",
"0",
";",
"}",
"var",
"_this",
"=",
"_super",
".",
"call",
"(",
"this",
",",
"null",
",",
"null",
",",
"BABYLON",
".",
"Vector2",
".",
"Zero",
"(",
")",
",",
"size",
")",
"||",
"this",
";",
"_this",
".",
"_margin",
"=",
"margin",
";",
"_this",
".",
"_root",
"=",
"_this",
";",
"return",
"_this",
";",
"}"
] |
Create an instance of the object with a dimension using the given size
@param size The dimension of the rectangle that will contain all the sub ones.
@param margin The margin (empty space) created (in pixels) around the allocated Rectangles
|
[
"Create",
"an",
"instance",
"of",
"the",
"object",
"with",
"a",
"dimension",
"using",
"the",
"given",
"size"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L72021-L72027
|
9,640
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function () {
return this._attachedCamera.inertialAlphaOffset !== 0 ||
this._attachedCamera.inertialBetaOffset !== 0 ||
this._attachedCamera.inertialRadiusOffset !== 0 ||
this._attachedCamera.inertialPanningX !== 0 ||
this._attachedCamera.inertialPanningY !== 0 ||
this._isPointerDown;
}
|
javascript
|
function () {
return this._attachedCamera.inertialAlphaOffset !== 0 ||
this._attachedCamera.inertialBetaOffset !== 0 ||
this._attachedCamera.inertialRadiusOffset !== 0 ||
this._attachedCamera.inertialPanningX !== 0 ||
this._attachedCamera.inertialPanningY !== 0 ||
this._isPointerDown;
}
|
[
"function",
"(",
")",
"{",
"return",
"this",
".",
"_attachedCamera",
".",
"inertialAlphaOffset",
"!==",
"0",
"||",
"this",
".",
"_attachedCamera",
".",
"inertialBetaOffset",
"!==",
"0",
"||",
"this",
".",
"_attachedCamera",
".",
"inertialRadiusOffset",
"!==",
"0",
"||",
"this",
".",
"_attachedCamera",
".",
"inertialPanningX",
"!==",
"0",
"||",
"this",
".",
"_attachedCamera",
".",
"inertialPanningY",
"!==",
"0",
"||",
"this",
".",
"_isPointerDown",
";",
"}"
] |
Gets a value indicating if the user is moving the camera
|
[
"Gets",
"a",
"value",
"indicating",
"if",
"the",
"user",
"is",
"moving",
"the",
"camera"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L73044-L73051
|
|
9,641
|
BabylonJS/Spector.js
|
sample/assets/js/babylon.max.js
|
function (value) {
var _this = this;
if (this._autoTransitionRange === value) {
return;
}
this._autoTransitionRange = value;
var camera = this._attachedCamera;
if (value) {
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
if (!mesh) {
return;
}
mesh.computeWorldMatrix(true);
var diagonal = mesh.getBoundingInfo().diagonalLength;
_this.lowerRadiusTransitionRange = diagonal * 0.05;
_this.upperRadiusTransitionRange = diagonal * 0.05;
});
}
else if (this._onMeshTargetChangedObserver) {
camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
}
}
|
javascript
|
function (value) {
var _this = this;
if (this._autoTransitionRange === value) {
return;
}
this._autoTransitionRange = value;
var camera = this._attachedCamera;
if (value) {
this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
if (!mesh) {
return;
}
mesh.computeWorldMatrix(true);
var diagonal = mesh.getBoundingInfo().diagonalLength;
_this.lowerRadiusTransitionRange = diagonal * 0.05;
_this.upperRadiusTransitionRange = diagonal * 0.05;
});
}
else if (this._onMeshTargetChangedObserver) {
camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
}
}
|
[
"function",
"(",
"value",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"this",
".",
"_autoTransitionRange",
"===",
"value",
")",
"{",
"return",
";",
"}",
"this",
".",
"_autoTransitionRange",
"=",
"value",
";",
"var",
"camera",
"=",
"this",
".",
"_attachedCamera",
";",
"if",
"(",
"value",
")",
"{",
"this",
".",
"_onMeshTargetChangedObserver",
"=",
"camera",
".",
"onMeshTargetChangedObservable",
".",
"add",
"(",
"function",
"(",
"mesh",
")",
"{",
"if",
"(",
"!",
"mesh",
")",
"{",
"return",
";",
"}",
"mesh",
".",
"computeWorldMatrix",
"(",
"true",
")",
";",
"var",
"diagonal",
"=",
"mesh",
".",
"getBoundingInfo",
"(",
")",
".",
"diagonalLength",
";",
"_this",
".",
"lowerRadiusTransitionRange",
"=",
"diagonal",
"*",
"0.05",
";",
"_this",
".",
"upperRadiusTransitionRange",
"=",
"diagonal",
"*",
"0.05",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"_onMeshTargetChangedObserver",
")",
"{",
"camera",
".",
"onMeshTargetChangedObservable",
".",
"remove",
"(",
"this",
".",
"_onMeshTargetChangedObserver",
")",
";",
"}",
"}"
] |
Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
Transition ranges will be set to 5% of the bounding box diagonal in world space
|
[
"Sets",
"a",
"value",
"indicating",
"if",
"the",
"lowerRadiusTransitionRange",
"and",
"upperRadiusTransitionRange",
"are",
"defined",
"automatically",
"Transition",
"ranges",
"will",
"be",
"set",
"to",
"5%",
"of",
"the",
"bounding",
"box",
"diagonal",
"in",
"world",
"space"
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/assets/js/babylon.max.js#L73122-L73143
|
|
9,642
|
BabylonJS/Spector.js
|
sample/js/uniformArray.js
|
drawScene
|
function drawScene() {
// Clear the canvas before we start drawing on it.
gl.clearColor(0, 0, 0, 1);
gl.clearDepth(1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Establish the perspective with which we want to view the
// scene. Our field of view is 45 degrees, with a width/height
// ratio of 640:480, and we only want to see objects between 0.1 units
// and 100 units away from the camera.
perspectiveMatrix = makePerspective(45, 640.0/480.0, 0.1, 100.0);
// Set the drawing position to the "identity" point, which is
// the center of the scene.
loadIdentity();
// Now move the drawing position a bit to where we want to start
// drawing the cube.
mvTranslate([-0.0, 0.0, -6.0]);
// Save the current matrix, then rotate before we draw.
mvPushMatrix();
mvRotate(cubeRotation, [1, 0, 1]);
mvTranslate([cubeXOffset, cubeYOffset, cubeZOffset]);
// Draw the cube by binding the array buffer to the cube's vertices
// array, setting attributes, and pushing it to GL.
gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesBuffer);
gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);
// Draw the cube.
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
setMatrixUniforms();
var pUniform = gl.getUniformLocation(shaderProgram, "uniformArray");
gl.uniform2fv(pUniform, new Float32Array([1,0.2,0.4,1]));
gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);
// Restore the original matrix
mvPopMatrix();
// Update the rotation for the next draw, if it's time to do so.
var currentTime = (new Date).getTime();
if (lastCubeUpdateTime) {
var delta = currentTime - lastCubeUpdateTime;
cubeRotation += (30 * delta) / 1000.0;
cubeXOffset += xIncValue * ((30 * delta) / 1000.0);
cubeYOffset += yIncValue * ((30 * delta) / 1000.0);
cubeZOffset += zIncValue * ((30 * delta) / 1000.0);
if (Math.abs(cubeYOffset) > 2.5) {
xIncValue = -xIncValue;
yIncValue = -yIncValue;
zIncValue = -zIncValue;
}
}
lastCubeUpdateTime = currentTime;
window.requestAnimationFrame(function() {
drawScene();
});
}
|
javascript
|
function drawScene() {
// Clear the canvas before we start drawing on it.
gl.clearColor(0, 0, 0, 1);
gl.clearDepth(1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Establish the perspective with which we want to view the
// scene. Our field of view is 45 degrees, with a width/height
// ratio of 640:480, and we only want to see objects between 0.1 units
// and 100 units away from the camera.
perspectiveMatrix = makePerspective(45, 640.0/480.0, 0.1, 100.0);
// Set the drawing position to the "identity" point, which is
// the center of the scene.
loadIdentity();
// Now move the drawing position a bit to where we want to start
// drawing the cube.
mvTranslate([-0.0, 0.0, -6.0]);
// Save the current matrix, then rotate before we draw.
mvPushMatrix();
mvRotate(cubeRotation, [1, 0, 1]);
mvTranslate([cubeXOffset, cubeYOffset, cubeZOffset]);
// Draw the cube by binding the array buffer to the cube's vertices
// array, setting attributes, and pushing it to GL.
gl.bindBuffer(gl.ARRAY_BUFFER, cubeVerticesBuffer);
gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);
// Draw the cube.
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
setMatrixUniforms();
var pUniform = gl.getUniformLocation(shaderProgram, "uniformArray");
gl.uniform2fv(pUniform, new Float32Array([1,0.2,0.4,1]));
gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);
// Restore the original matrix
mvPopMatrix();
// Update the rotation for the next draw, if it's time to do so.
var currentTime = (new Date).getTime();
if (lastCubeUpdateTime) {
var delta = currentTime - lastCubeUpdateTime;
cubeRotation += (30 * delta) / 1000.0;
cubeXOffset += xIncValue * ((30 * delta) / 1000.0);
cubeYOffset += yIncValue * ((30 * delta) / 1000.0);
cubeZOffset += zIncValue * ((30 * delta) / 1000.0);
if (Math.abs(cubeYOffset) > 2.5) {
xIncValue = -xIncValue;
yIncValue = -yIncValue;
zIncValue = -zIncValue;
}
}
lastCubeUpdateTime = currentTime;
window.requestAnimationFrame(function() {
drawScene();
});
}
|
[
"function",
"drawScene",
"(",
")",
"{",
"// Clear the canvas before we start drawing on it.",
"gl",
".",
"clearColor",
"(",
"0",
",",
"0",
",",
"0",
",",
"1",
")",
";",
"gl",
".",
"clearDepth",
"(",
"1.0",
")",
";",
"gl",
".",
"clear",
"(",
"gl",
".",
"COLOR_BUFFER_BIT",
"|",
"gl",
".",
"DEPTH_BUFFER_BIT",
")",
";",
"// Establish the perspective with which we want to view the",
"// scene. Our field of view is 45 degrees, with a width/height",
"// ratio of 640:480, and we only want to see objects between 0.1 units",
"// and 100 units away from the camera.",
"perspectiveMatrix",
"=",
"makePerspective",
"(",
"45",
",",
"640.0",
"/",
"480.0",
",",
"0.1",
",",
"100.0",
")",
";",
"// Set the drawing position to the \"identity\" point, which is",
"// the center of the scene.",
"loadIdentity",
"(",
")",
";",
"// Now move the drawing position a bit to where we want to start",
"// drawing the cube.",
"mvTranslate",
"(",
"[",
"-",
"0.0",
",",
"0.0",
",",
"-",
"6.0",
"]",
")",
";",
"// Save the current matrix, then rotate before we draw.",
"mvPushMatrix",
"(",
")",
";",
"mvRotate",
"(",
"cubeRotation",
",",
"[",
"1",
",",
"0",
",",
"1",
"]",
")",
";",
"mvTranslate",
"(",
"[",
"cubeXOffset",
",",
"cubeYOffset",
",",
"cubeZOffset",
"]",
")",
";",
"// Draw the cube by binding the array buffer to the cube's vertices",
"// array, setting attributes, and pushing it to GL.",
"gl",
".",
"bindBuffer",
"(",
"gl",
".",
"ARRAY_BUFFER",
",",
"cubeVerticesBuffer",
")",
";",
"gl",
".",
"vertexAttribPointer",
"(",
"vertexPositionAttribute",
",",
"3",
",",
"gl",
".",
"FLOAT",
",",
"false",
",",
"0",
",",
"0",
")",
";",
"// Draw the cube.",
"gl",
".",
"bindBuffer",
"(",
"gl",
".",
"ELEMENT_ARRAY_BUFFER",
",",
"cubeVerticesIndexBuffer",
")",
";",
"setMatrixUniforms",
"(",
")",
";",
"var",
"pUniform",
"=",
"gl",
".",
"getUniformLocation",
"(",
"shaderProgram",
",",
"\"uniformArray\"",
")",
";",
"gl",
".",
"uniform2fv",
"(",
"pUniform",
",",
"new",
"Float32Array",
"(",
"[",
"1",
",",
"0.2",
",",
"0.4",
",",
"1",
"]",
")",
")",
";",
"gl",
".",
"drawElements",
"(",
"gl",
".",
"TRIANGLES",
",",
"36",
",",
"gl",
".",
"UNSIGNED_SHORT",
",",
"0",
")",
";",
"// Restore the original matrix",
"mvPopMatrix",
"(",
")",
";",
"// Update the rotation for the next draw, if it's time to do so.",
"var",
"currentTime",
"=",
"(",
"new",
"Date",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"lastCubeUpdateTime",
")",
"{",
"var",
"delta",
"=",
"currentTime",
"-",
"lastCubeUpdateTime",
";",
"cubeRotation",
"+=",
"(",
"30",
"*",
"delta",
")",
"/",
"1000.0",
";",
"cubeXOffset",
"+=",
"xIncValue",
"*",
"(",
"(",
"30",
"*",
"delta",
")",
"/",
"1000.0",
")",
";",
"cubeYOffset",
"+=",
"yIncValue",
"*",
"(",
"(",
"30",
"*",
"delta",
")",
"/",
"1000.0",
")",
";",
"cubeZOffset",
"+=",
"zIncValue",
"*",
"(",
"(",
"30",
"*",
"delta",
")",
"/",
"1000.0",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"cubeYOffset",
")",
">",
"2.5",
")",
"{",
"xIncValue",
"=",
"-",
"xIncValue",
";",
"yIncValue",
"=",
"-",
"yIncValue",
";",
"zIncValue",
"=",
"-",
"zIncValue",
";",
"}",
"}",
"lastCubeUpdateTime",
"=",
"currentTime",
";",
"window",
".",
"requestAnimationFrame",
"(",
"function",
"(",
")",
"{",
"drawScene",
"(",
")",
";",
"}",
")",
";",
"}"
] |
drawScene Draw the scene.
|
[
"drawScene",
"Draw",
"the",
"scene",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/uniformArray.js#L191-L263
|
9,643
|
BabylonJS/Spector.js
|
sample/js/uniformArray.js
|
initShaders
|
function initShaders() {
var fragmentShader = getShader(gl, fragmentShaderSource, false);
var vertexShader = getShader(gl, vertexShaderSource, true);
// Create the shader program
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.linkProgram(shaderProgram);
// If creating the shader program failed, alert
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
alert("Unable to initialize the shader program: " + gl.getProgramInfoLog(shader));
}
gl.useProgram(shaderProgram);
vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
gl.enableVertexAttribArray(vertexPositionAttribute);
}
|
javascript
|
function initShaders() {
var fragmentShader = getShader(gl, fragmentShaderSource, false);
var vertexShader = getShader(gl, vertexShaderSource, true);
// Create the shader program
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.linkProgram(shaderProgram);
// If creating the shader program failed, alert
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
alert("Unable to initialize the shader program: " + gl.getProgramInfoLog(shader));
}
gl.useProgram(shaderProgram);
vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
gl.enableVertexAttribArray(vertexPositionAttribute);
}
|
[
"function",
"initShaders",
"(",
")",
"{",
"var",
"fragmentShader",
"=",
"getShader",
"(",
"gl",
",",
"fragmentShaderSource",
",",
"false",
")",
";",
"var",
"vertexShader",
"=",
"getShader",
"(",
"gl",
",",
"vertexShaderSource",
",",
"true",
")",
";",
"// Create the shader program",
"shaderProgram",
"=",
"gl",
".",
"createProgram",
"(",
")",
";",
"gl",
".",
"attachShader",
"(",
"shaderProgram",
",",
"vertexShader",
")",
";",
"gl",
".",
"attachShader",
"(",
"shaderProgram",
",",
"fragmentShader",
")",
";",
"gl",
".",
"linkProgram",
"(",
"shaderProgram",
")",
";",
"// If creating the shader program failed, alert",
"if",
"(",
"!",
"gl",
".",
"getProgramParameter",
"(",
"shaderProgram",
",",
"gl",
".",
"LINK_STATUS",
")",
")",
"{",
"alert",
"(",
"\"Unable to initialize the shader program: \"",
"+",
"gl",
".",
"getProgramInfoLog",
"(",
"shader",
")",
")",
";",
"}",
"gl",
".",
"useProgram",
"(",
"shaderProgram",
")",
";",
"vertexPositionAttribute",
"=",
"gl",
".",
"getAttribLocation",
"(",
"shaderProgram",
",",
"\"aVertexPosition\"",
")",
";",
"gl",
".",
"enableVertexAttribArray",
"(",
"vertexPositionAttribute",
")",
";",
"}"
] |
initShaders Initialize the shaders, so WebGL knows how to light our scene.
|
[
"initShaders",
"Initialize",
"the",
"shaders",
"so",
"WebGL",
"knows",
"how",
"to",
"light",
"our",
"scene",
"."
] |
42602c83a0515b60338edad27c3330a7c0523bbe
|
https://github.com/BabylonJS/Spector.js/blob/42602c83a0515b60338edad27c3330a7c0523bbe/sample/js/uniformArray.js#L270-L291
|
9,644
|
googleapis/nodejs-tasks
|
samples/createHttpTaskWithToken.js
|
createHttpTaskWithToken
|
async function createHttpTaskWithToken(
project,
location,
queue,
url,
email,
payload,
inSeconds
) {
// [START cloud_tasks_create_http_task_with_token]
// Imports the Google Cloud Tasks library.
const {v2beta3} = require('@google-cloud/tasks');
// Instantiates a client.
const client = new v2beta3.CloudTasksClient();
// TODO(developer): Uncomment these lines and replace with your values.
// const project = 'my-project-id';
// const queue = 'my-appengine-queue';
// const location = 'us-central1';
// const url = 'https://<project-id>.appspot.com/log_payload'
// const email = 'client@<project-id>.iam.gserviceaccount.com'
// const options = {payload: 'hello'};
// Construct the fully qualified queue name.
const parent = client.queuePath(project, location, queue);
const task = {
httpRequest: {
httpMethod: 'POST',
url, //The full url path that the request will be sent to.
oidcToken: {
serviceAccountEmail: email,
},
},
};
if (payload) {
task.httpRequest.body = Buffer.from(payload).toString('base64');
}
if (inSeconds) {
task.scheduleTime = {
seconds: inSeconds + Date.now() / 1000,
};
}
const request = {
parent: parent,
task: task,
};
console.log('Sending task:');
console.log(task);
// Send create task request.
const [response] = await client.createTask(request);
const name = response.name;
console.log(`Created task ${name}`);
// [END cloud_tasks_create_http_task_with_token]
}
|
javascript
|
async function createHttpTaskWithToken(
project,
location,
queue,
url,
email,
payload,
inSeconds
) {
// [START cloud_tasks_create_http_task_with_token]
// Imports the Google Cloud Tasks library.
const {v2beta3} = require('@google-cloud/tasks');
// Instantiates a client.
const client = new v2beta3.CloudTasksClient();
// TODO(developer): Uncomment these lines and replace with your values.
// const project = 'my-project-id';
// const queue = 'my-appengine-queue';
// const location = 'us-central1';
// const url = 'https://<project-id>.appspot.com/log_payload'
// const email = 'client@<project-id>.iam.gserviceaccount.com'
// const options = {payload: 'hello'};
// Construct the fully qualified queue name.
const parent = client.queuePath(project, location, queue);
const task = {
httpRequest: {
httpMethod: 'POST',
url, //The full url path that the request will be sent to.
oidcToken: {
serviceAccountEmail: email,
},
},
};
if (payload) {
task.httpRequest.body = Buffer.from(payload).toString('base64');
}
if (inSeconds) {
task.scheduleTime = {
seconds: inSeconds + Date.now() / 1000,
};
}
const request = {
parent: parent,
task: task,
};
console.log('Sending task:');
console.log(task);
// Send create task request.
const [response] = await client.createTask(request);
const name = response.name;
console.log(`Created task ${name}`);
// [END cloud_tasks_create_http_task_with_token]
}
|
[
"async",
"function",
"createHttpTaskWithToken",
"(",
"project",
",",
"location",
",",
"queue",
",",
"url",
",",
"email",
",",
"payload",
",",
"inSeconds",
")",
"{",
"// [START cloud_tasks_create_http_task_with_token]",
"// Imports the Google Cloud Tasks library.",
"const",
"{",
"v2beta3",
"}",
"=",
"require",
"(",
"'@google-cloud/tasks'",
")",
";",
"// Instantiates a client.",
"const",
"client",
"=",
"new",
"v2beta3",
".",
"CloudTasksClient",
"(",
")",
";",
"// TODO(developer): Uncomment these lines and replace with your values.",
"// const project = 'my-project-id';",
"// const queue = 'my-appengine-queue';",
"// const location = 'us-central1';",
"// const url = 'https://<project-id>.appspot.com/log_payload'",
"// const email = 'client@<project-id>.iam.gserviceaccount.com'",
"// const options = {payload: 'hello'};",
"// Construct the fully qualified queue name.",
"const",
"parent",
"=",
"client",
".",
"queuePath",
"(",
"project",
",",
"location",
",",
"queue",
")",
";",
"const",
"task",
"=",
"{",
"httpRequest",
":",
"{",
"httpMethod",
":",
"'POST'",
",",
"url",
",",
"//The full url path that the request will be sent to.",
"oidcToken",
":",
"{",
"serviceAccountEmail",
":",
"email",
",",
"}",
",",
"}",
",",
"}",
";",
"if",
"(",
"payload",
")",
"{",
"task",
".",
"httpRequest",
".",
"body",
"=",
"Buffer",
".",
"from",
"(",
"payload",
")",
".",
"toString",
"(",
"'base64'",
")",
";",
"}",
"if",
"(",
"inSeconds",
")",
"{",
"task",
".",
"scheduleTime",
"=",
"{",
"seconds",
":",
"inSeconds",
"+",
"Date",
".",
"now",
"(",
")",
"/",
"1000",
",",
"}",
";",
"}",
"const",
"request",
"=",
"{",
"parent",
":",
"parent",
",",
"task",
":",
"task",
",",
"}",
";",
"console",
".",
"log",
"(",
"'Sending task:'",
")",
";",
"console",
".",
"log",
"(",
"task",
")",
";",
"// Send create task request.",
"const",
"[",
"response",
"]",
"=",
"await",
"client",
".",
"createTask",
"(",
"request",
")",
";",
"const",
"name",
"=",
"response",
".",
"name",
";",
"console",
".",
"log",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"// [END cloud_tasks_create_http_task_with_token]",
"}"
] |
Create a task with an HTTP target for a given queue with an arbitrary payload.
|
[
"Create",
"a",
"task",
"with",
"an",
"HTTP",
"target",
"for",
"a",
"given",
"queue",
"with",
"an",
"arbitrary",
"payload",
"."
] |
df5ee7359e140511f68d21e933fea6f987cf5077
|
https://github.com/googleapis/nodejs-tasks/blob/df5ee7359e140511f68d21e933fea6f987cf5077/samples/createHttpTaskWithToken.js#L21-L81
|
9,645
|
googleapis/nodejs-tasks
|
samples/createQueue.js
|
createQueue
|
async function createQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to create
location = 'us-central1' // The GCP region in which to create the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();
// Send create queue request.
const [response] = await client.createQueue({
// The fully qualified path to the location where the queue is created
parent: client.locationPath(project, location),
queue: {
// The fully qualified path to the queue
name: client.queuePath(project, location, queue),
appEngineHttpQueue: {
appEngineRoutingOverride: {
// The App Engine service that will receive the tasks.
service: 'default',
},
},
},
});
console.log(`Created queue ${response.name}`);
}
|
javascript
|
async function createQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to create
location = 'us-central1' // The GCP region in which to create the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();
// Send create queue request.
const [response] = await client.createQueue({
// The fully qualified path to the location where the queue is created
parent: client.locationPath(project, location),
queue: {
// The fully qualified path to the queue
name: client.queuePath(project, location, queue),
appEngineHttpQueue: {
appEngineRoutingOverride: {
// The App Engine service that will receive the tasks.
service: 'default',
},
},
},
});
console.log(`Created queue ${response.name}`);
}
|
[
"async",
"function",
"createQueue",
"(",
"project",
"=",
"'my-project-id'",
",",
"// Your GCP Project id",
"queue",
"=",
"'my-appengine-queue'",
",",
"// Name of the Queue to create",
"location",
"=",
"'us-central1'",
"// The GCP region in which to create the queue",
")",
"{",
"// Imports the Google Cloud Tasks library.",
"const",
"cloudTasks",
"=",
"require",
"(",
"'@google-cloud/tasks'",
")",
";",
"// Instantiates a client.",
"const",
"client",
"=",
"new",
"cloudTasks",
".",
"CloudTasksClient",
"(",
")",
";",
"// Send create queue request.",
"const",
"[",
"response",
"]",
"=",
"await",
"client",
".",
"createQueue",
"(",
"{",
"// The fully qualified path to the location where the queue is created",
"parent",
":",
"client",
".",
"locationPath",
"(",
"project",
",",
"location",
")",
",",
"queue",
":",
"{",
"// The fully qualified path to the queue",
"name",
":",
"client",
".",
"queuePath",
"(",
"project",
",",
"location",
",",
"queue",
")",
",",
"appEngineHttpQueue",
":",
"{",
"appEngineRoutingOverride",
":",
"{",
"// The App Engine service that will receive the tasks.",
"service",
":",
"'default'",
",",
"}",
",",
"}",
",",
"}",
",",
"}",
")",
";",
"console",
".",
"log",
"(",
"`",
"${",
"response",
".",
"name",
"}",
"`",
")",
";",
"}"
] |
Create a new Task Queue
|
[
"Create",
"a",
"new",
"Task",
"Queue"
] |
df5ee7359e140511f68d21e933fea6f987cf5077
|
https://github.com/googleapis/nodejs-tasks/blob/df5ee7359e140511f68d21e933fea6f987cf5077/samples/createQueue.js#L20-L47
|
9,646
|
googleapis/nodejs-tasks
|
samples/deleteQueue.js
|
deleteQueue
|
async function deleteQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to delete
location = 'us-central1' // The GCP region in which to delete the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();
// Get the fully qualified path to the queue
const name = client.queuePath(project, location, queue);
// Send delete queue request.
await client.deleteQueue({name});
console.log(`Deleted queue '${queue}'.`);
}
|
javascript
|
async function deleteQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to delete
location = 'us-central1' // The GCP region in which to delete the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();
// Get the fully qualified path to the queue
const name = client.queuePath(project, location, queue);
// Send delete queue request.
await client.deleteQueue({name});
console.log(`Deleted queue '${queue}'.`);
}
|
[
"async",
"function",
"deleteQueue",
"(",
"project",
"=",
"'my-project-id'",
",",
"// Your GCP Project id",
"queue",
"=",
"'my-appengine-queue'",
",",
"// Name of the Queue to delete",
"location",
"=",
"'us-central1'",
"// The GCP region in which to delete the queue",
")",
"{",
"// Imports the Google Cloud Tasks library.",
"const",
"cloudTasks",
"=",
"require",
"(",
"'@google-cloud/tasks'",
")",
";",
"// Instantiates a client.",
"const",
"client",
"=",
"new",
"cloudTasks",
".",
"CloudTasksClient",
"(",
")",
";",
"// Get the fully qualified path to the queue",
"const",
"name",
"=",
"client",
".",
"queuePath",
"(",
"project",
",",
"location",
",",
"queue",
")",
";",
"// Send delete queue request.",
"await",
"client",
".",
"deleteQueue",
"(",
"{",
"name",
"}",
")",
";",
"console",
".",
"log",
"(",
"`",
"${",
"queue",
"}",
"`",
")",
";",
"}"
] |
Delete a given Queue
|
[
"Delete",
"a",
"given",
"Queue"
] |
df5ee7359e140511f68d21e933fea6f987cf5077
|
https://github.com/googleapis/nodejs-tasks/blob/df5ee7359e140511f68d21e933fea6f987cf5077/samples/deleteQueue.js#L20-L37
|
9,647
|
uiwjs/uiw
|
packages/core/src/table/util.js
|
getColspanNum
|
function getColspanNum(data = [], num = 1) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (data[i].children) {
childs = childs.concat(data[i].children);
}
}
if (childs && childs.length > 0) {
num = getColspanNum(childs, num + 1);
}
return num;
}
|
javascript
|
function getColspanNum(data = [], num = 1) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (data[i].children) {
childs = childs.concat(data[i].children);
}
}
if (childs && childs.length > 0) {
num = getColspanNum(childs, num + 1);
}
return num;
}
|
[
"function",
"getColspanNum",
"(",
"data",
"=",
"[",
"]",
",",
"num",
"=",
"1",
")",
"{",
"let",
"childs",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"data",
"[",
"i",
"]",
".",
"children",
")",
"{",
"childs",
"=",
"childs",
".",
"concat",
"(",
"data",
"[",
"i",
"]",
".",
"children",
")",
";",
"}",
"}",
"if",
"(",
"childs",
"&&",
"childs",
".",
"length",
">",
"0",
")",
"{",
"num",
"=",
"getColspanNum",
"(",
"childs",
",",
"num",
"+",
"1",
")",
";",
"}",
"return",
"num",
";",
"}"
] |
Get colspan number
@param {Array} date
|
[
"Get",
"colspan",
"number"
] |
28d57c797c1b827681dc04c5885c6c310fb690b4
|
https://github.com/uiwjs/uiw/blob/28d57c797c1b827681dc04c5885c6c310fb690b4/packages/core/src/table/util.js#L7-L18
|
9,648
|
uiwjs/uiw
|
packages/core/src/table/util.js
|
getRowspanNum
|
function getRowspanNum(data = [], child = []) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (!data[i].children) {
childs.push(data[i]);
} else if (data[i].children && data[i].children.length > 0) {
childs = childs.concat(getRowspanNum(data[i].children, child));
}
}
return childs;
}
|
javascript
|
function getRowspanNum(data = [], child = []) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (!data[i].children) {
childs.push(data[i]);
} else if (data[i].children && data[i].children.length > 0) {
childs = childs.concat(getRowspanNum(data[i].children, child));
}
}
return childs;
}
|
[
"function",
"getRowspanNum",
"(",
"data",
"=",
"[",
"]",
",",
"child",
"=",
"[",
"]",
")",
"{",
"let",
"childs",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"!",
"data",
"[",
"i",
"]",
".",
"children",
")",
"{",
"childs",
".",
"push",
"(",
"data",
"[",
"i",
"]",
")",
";",
"}",
"else",
"if",
"(",
"data",
"[",
"i",
"]",
".",
"children",
"&&",
"data",
"[",
"i",
"]",
".",
"children",
".",
"length",
">",
"0",
")",
"{",
"childs",
"=",
"childs",
".",
"concat",
"(",
"getRowspanNum",
"(",
"data",
"[",
"i",
"]",
".",
"children",
",",
"child",
")",
")",
";",
"}",
"}",
"return",
"childs",
";",
"}"
] |
Get rowspan number
@param {Array} date
|
[
"Get",
"rowspan",
"number"
] |
28d57c797c1b827681dc04c5885c6c310fb690b4
|
https://github.com/uiwjs/uiw/blob/28d57c797c1b827681dc04c5885c6c310fb690b4/packages/core/src/table/util.js#L24-L34
|
9,649
|
newsuk/times-components
|
packages/article-skeleton/src/head.web.js
|
getSectionName
|
function getSectionName(article) {
const { tiles } = article;
if (!tiles) {
return null;
}
const slices = tiles.reduce((acc, tile) => {
acc.push(...tile.slices);
return acc;
}, []);
const sections = slices.reduce((acc, slice) => {
acc.push(...slice.sections);
return acc;
}, []);
const titles = sections.map(section => section.title);
if (titles.length === 0) {
return null;
}
const nonNews = titles.filter(title => title !== "News");
return nonNews.length ? nonNews[0] : "News";
}
|
javascript
|
function getSectionName(article) {
const { tiles } = article;
if (!tiles) {
return null;
}
const slices = tiles.reduce((acc, tile) => {
acc.push(...tile.slices);
return acc;
}, []);
const sections = slices.reduce((acc, slice) => {
acc.push(...slice.sections);
return acc;
}, []);
const titles = sections.map(section => section.title);
if (titles.length === 0) {
return null;
}
const nonNews = titles.filter(title => title !== "News");
return nonNews.length ? nonNews[0] : "News";
}
|
[
"function",
"getSectionName",
"(",
"article",
")",
"{",
"const",
"{",
"tiles",
"}",
"=",
"article",
";",
"if",
"(",
"!",
"tiles",
")",
"{",
"return",
"null",
";",
"}",
"const",
"slices",
"=",
"tiles",
".",
"reduce",
"(",
"(",
"acc",
",",
"tile",
")",
"=>",
"{",
"acc",
".",
"push",
"(",
"...",
"tile",
".",
"slices",
")",
";",
"return",
"acc",
";",
"}",
",",
"[",
"]",
")",
";",
"const",
"sections",
"=",
"slices",
".",
"reduce",
"(",
"(",
"acc",
",",
"slice",
")",
"=>",
"{",
"acc",
".",
"push",
"(",
"...",
"slice",
".",
"sections",
")",
";",
"return",
"acc",
";",
"}",
",",
"[",
"]",
")",
";",
"const",
"titles",
"=",
"sections",
".",
"map",
"(",
"section",
"=>",
"section",
".",
"title",
")",
";",
"if",
"(",
"titles",
".",
"length",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"const",
"nonNews",
"=",
"titles",
".",
"filter",
"(",
"title",
"=>",
"title",
"!==",
"\"News\"",
")",
";",
"return",
"nonNews",
".",
"length",
"?",
"nonNews",
"[",
"0",
"]",
":",
"\"News\"",
";",
"}"
] |
Get the section for an article, preferring it not to be News
|
[
"Get",
"the",
"section",
"for",
"an",
"article",
"preferring",
"it",
"not",
"to",
"be",
"News"
] |
06bdf1b6e42ee94101e50731c62fa51d55dadbef
|
https://github.com/newsuk/times-components/blob/06bdf1b6e42ee94101e50731c62fa51d55dadbef/packages/article-skeleton/src/head.web.js#L9-L33
|
9,650
|
keen/keen-tracking.js
|
lib/utils/serializeForm.js
|
str_serialize
|
function str_serialize(result, key, value) {
// encode newlines as \r\n cause the html spec says so
value = value.replace(/(\r)?\n/g, '\r\n');
value = encodeURIComponent(value);
// spaces should be '+' rather than '%20'.
value = value.replace(/%20/g, '+');
return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
}
|
javascript
|
function str_serialize(result, key, value) {
// encode newlines as \r\n cause the html spec says so
value = value.replace(/(\r)?\n/g, '\r\n');
value = encodeURIComponent(value);
// spaces should be '+' rather than '%20'.
value = value.replace(/%20/g, '+');
return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
}
|
[
"function",
"str_serialize",
"(",
"result",
",",
"key",
",",
"value",
")",
"{",
"// encode newlines as \\r\\n cause the html spec says so",
"value",
"=",
"value",
".",
"replace",
"(",
"/",
"(\\r)?\\n",
"/",
"g",
",",
"'\\r\\n'",
")",
";",
"value",
"=",
"encodeURIComponent",
"(",
"value",
")",
";",
"// spaces should be '+' rather than '%20'.",
"value",
"=",
"value",
".",
"replace",
"(",
"/",
"%20",
"/",
"g",
",",
"'+'",
")",
";",
"return",
"result",
"+",
"(",
"result",
"?",
"'&'",
":",
"''",
")",
"+",
"encodeURIComponent",
"(",
"key",
")",
"+",
"'='",
"+",
"value",
";",
"}"
] |
urlform encoding serializer
|
[
"urlform",
"encoding",
"serializer"
] |
9101cef8e105a80ea12354423d6f563a3853aa8c
|
https://github.com/keen/keen-tracking.js/blob/9101cef8e105a80ea12354423d6f563a3853aa8c/lib/utils/serializeForm.js#L253-L261
|
9,651
|
keen/keen-tracking.js
|
lib/record-events-browser.js
|
sendBeacon
|
function sendBeacon(url, callback){
var self = this,
img = document.createElement('img'),
loaded = false;
img.onload = function() {
loaded = true;
if ('naturalHeight' in this) {
if (this.naturalHeight + this.naturalWidth === 0) {
this.onerror();
return;
}
} else if (this.width + this.height === 0) {
this.onerror();
return;
}
if (callback) {
callback.call(self);
}
};
img.onerror = function() {
loaded = true;
if (callback) {
callback.call(self, 'An error occurred!', null);
}
};
img.src = url + '&c=clv1';
}
|
javascript
|
function sendBeacon(url, callback){
var self = this,
img = document.createElement('img'),
loaded = false;
img.onload = function() {
loaded = true;
if ('naturalHeight' in this) {
if (this.naturalHeight + this.naturalWidth === 0) {
this.onerror();
return;
}
} else if (this.width + this.height === 0) {
this.onerror();
return;
}
if (callback) {
callback.call(self);
}
};
img.onerror = function() {
loaded = true;
if (callback) {
callback.call(self, 'An error occurred!', null);
}
};
img.src = url + '&c=clv1';
}
|
[
"function",
"sendBeacon",
"(",
"url",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
",",
"img",
"=",
"document",
".",
"createElement",
"(",
"'img'",
")",
",",
"loaded",
"=",
"false",
";",
"img",
".",
"onload",
"=",
"function",
"(",
")",
"{",
"loaded",
"=",
"true",
";",
"if",
"(",
"'naturalHeight'",
"in",
"this",
")",
"{",
"if",
"(",
"this",
".",
"naturalHeight",
"+",
"this",
".",
"naturalWidth",
"===",
"0",
")",
"{",
"this",
".",
"onerror",
"(",
")",
";",
"return",
";",
"}",
"}",
"else",
"if",
"(",
"this",
".",
"width",
"+",
"this",
".",
"height",
"===",
"0",
")",
"{",
"this",
".",
"onerror",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"callback",
")",
"{",
"callback",
".",
"call",
"(",
"self",
")",
";",
"}",
"}",
";",
"img",
".",
"onerror",
"=",
"function",
"(",
")",
"{",
"loaded",
"=",
"true",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"'An error occurred!'",
",",
"null",
")",
";",
"}",
"}",
";",
"img",
".",
"src",
"=",
"url",
"+",
"'&c=clv1'",
";",
"}"
] |
Image Beacon Requests DEPRECATED
|
[
"Image",
"Beacon",
"Requests",
"DEPRECATED"
] |
9101cef8e105a80ea12354423d6f563a3853aa8c
|
https://github.com/keen/keen-tracking.js/blob/9101cef8e105a80ea12354423d6f563a3853aa8c/lib/record-events-browser.js#L327-L354
|
9,652
|
ballercat/walt
|
packages/walt-parser-tools/src/map-node.js
|
mapNode
|
function mapNode(visitor) {
const nodeMapper = node => {
if (node == null) {
return node;
}
const mappingFunction = (() => {
if ('*' in visitor && typeof visitor['*'] === 'function') {
return visitor['*'];
}
if (node.Type in visitor && typeof visitor[node.Type] === 'function') {
return visitor[node.Type];
}
return identity;
})();
if (mappingFunction.length === 2) {
return mappingFunction(node, nodeMapper);
}
const mappedNode = mappingFunction(node);
const params = mappedNode.params.map(nodeMapper);
return extend(mappedNode, { params });
};
return nodeMapper;
}
|
javascript
|
function mapNode(visitor) {
const nodeMapper = node => {
if (node == null) {
return node;
}
const mappingFunction = (() => {
if ('*' in visitor && typeof visitor['*'] === 'function') {
return visitor['*'];
}
if (node.Type in visitor && typeof visitor[node.Type] === 'function') {
return visitor[node.Type];
}
return identity;
})();
if (mappingFunction.length === 2) {
return mappingFunction(node, nodeMapper);
}
const mappedNode = mappingFunction(node);
const params = mappedNode.params.map(nodeMapper);
return extend(mappedNode, { params });
};
return nodeMapper;
}
|
[
"function",
"mapNode",
"(",
"visitor",
")",
"{",
"const",
"nodeMapper",
"=",
"node",
"=>",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"return",
"node",
";",
"}",
"const",
"mappingFunction",
"=",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"'*'",
"in",
"visitor",
"&&",
"typeof",
"visitor",
"[",
"'*'",
"]",
"===",
"'function'",
")",
"{",
"return",
"visitor",
"[",
"'*'",
"]",
";",
"}",
"if",
"(",
"node",
".",
"Type",
"in",
"visitor",
"&&",
"typeof",
"visitor",
"[",
"node",
".",
"Type",
"]",
"===",
"'function'",
")",
"{",
"return",
"visitor",
"[",
"node",
".",
"Type",
"]",
";",
"}",
"return",
"identity",
";",
"}",
")",
"(",
")",
";",
"if",
"(",
"mappingFunction",
".",
"length",
"===",
"2",
")",
"{",
"return",
"mappingFunction",
"(",
"node",
",",
"nodeMapper",
")",
";",
"}",
"const",
"mappedNode",
"=",
"mappingFunction",
"(",
"node",
")",
";",
"const",
"params",
"=",
"mappedNode",
".",
"params",
".",
"map",
"(",
"nodeMapper",
")",
";",
"return",
"extend",
"(",
"mappedNode",
",",
"{",
"params",
"}",
")",
";",
"}",
";",
"return",
"nodeMapper",
";",
"}"
] |
This should maybe be it's own module.
|
[
"This",
"should",
"maybe",
"be",
"it",
"s",
"own",
"module",
"."
] |
024533f483e0dc8f234638134948d686409187b4
|
https://github.com/ballercat/walt/blob/024533f483e0dc8f234638134948d686409187b4/packages/walt-parser-tools/src/map-node.js#L36-L64
|
9,653
|
ballercat/walt
|
packages/walt-compiler/src/parser/index.js
|
makeLexer
|
function makeLexer() {
const mooLexer = moo.compile(tokens);
return {
current: null,
lines: [],
get line() {
return mooLexer.line;
},
get col() {
return mooLexer.col;
},
save() {
return mooLexer.save();
},
reset(chunk, info) {
this.lines = chunk.split('\n');
return mooLexer.reset(chunk, info);
},
next() {
// It's a cruel and unusual punishment to implement comments with nearly
let token = mooLexer.next();
// Drop all comment tokens found
while (token && token.type === 'comment') {
token = mooLexer.next();
}
this.current = token;
return this.current;
},
formatError(token) {
return mooLexer.formatError(token);
},
has(name) {
return mooLexer.has(name);
},
};
}
|
javascript
|
function makeLexer() {
const mooLexer = moo.compile(tokens);
return {
current: null,
lines: [],
get line() {
return mooLexer.line;
},
get col() {
return mooLexer.col;
},
save() {
return mooLexer.save();
},
reset(chunk, info) {
this.lines = chunk.split('\n');
return mooLexer.reset(chunk, info);
},
next() {
// It's a cruel and unusual punishment to implement comments with nearly
let token = mooLexer.next();
// Drop all comment tokens found
while (token && token.type === 'comment') {
token = mooLexer.next();
}
this.current = token;
return this.current;
},
formatError(token) {
return mooLexer.formatError(token);
},
has(name) {
return mooLexer.has(name);
},
};
}
|
[
"function",
"makeLexer",
"(",
")",
"{",
"const",
"mooLexer",
"=",
"moo",
".",
"compile",
"(",
"tokens",
")",
";",
"return",
"{",
"current",
":",
"null",
",",
"lines",
":",
"[",
"]",
",",
"get",
"line",
"(",
")",
"{",
"return",
"mooLexer",
".",
"line",
";",
"}",
",",
"get",
"col",
"(",
")",
"{",
"return",
"mooLexer",
".",
"col",
";",
"}",
",",
"save",
"(",
")",
"{",
"return",
"mooLexer",
".",
"save",
"(",
")",
";",
"}",
",",
"reset",
"(",
"chunk",
",",
"info",
")",
"{",
"this",
".",
"lines",
"=",
"chunk",
".",
"split",
"(",
"'\\n'",
")",
";",
"return",
"mooLexer",
".",
"reset",
"(",
"chunk",
",",
"info",
")",
";",
"}",
",",
"next",
"(",
")",
"{",
"// It's a cruel and unusual punishment to implement comments with nearly",
"let",
"token",
"=",
"mooLexer",
".",
"next",
"(",
")",
";",
"// Drop all comment tokens found",
"while",
"(",
"token",
"&&",
"token",
".",
"type",
"===",
"'comment'",
")",
"{",
"token",
"=",
"mooLexer",
".",
"next",
"(",
")",
";",
"}",
"this",
".",
"current",
"=",
"token",
";",
"return",
"this",
".",
"current",
";",
"}",
",",
"formatError",
"(",
"token",
")",
"{",
"return",
"mooLexer",
".",
"formatError",
"(",
"token",
")",
";",
"}",
",",
"has",
"(",
"name",
")",
"{",
"return",
"mooLexer",
".",
"has",
"(",
"name",
")",
";",
"}",
",",
"}",
";",
"}"
] |
Returns a custom lexer. This wrapper API is necessary to ignore comments
in all of the subsequent compiler phases, unfortunately.
TODO: Maybe consider adding comment nodes back to the AST. IIRC this causes
lots of ambiguous grammar for whatever reason.
|
[
"Returns",
"a",
"custom",
"lexer",
".",
"This",
"wrapper",
"API",
"is",
"necessary",
"to",
"ignore",
"comments",
"in",
"all",
"of",
"the",
"subsequent",
"compiler",
"phases",
"unfortunately",
"."
] |
024533f483e0dc8f234638134948d686409187b4
|
https://github.com/ballercat/walt/blob/024533f483e0dc8f234638134948d686409187b4/packages/walt-compiler/src/parser/index.js#L35-L71
|
9,654
|
ballercat/walt
|
packages/walt-buildtools/src/index.js
|
parseImports
|
function parseImports(ast, compiler) {
const imports = {};
let hasMemory = false;
compiler.walkNode({
Import(node, _) {
// Import nodes consist of field and a string literal node
const [fields, module] = node.params;
if (imports[module.value] == null) {
imports[module.value] = [];
}
compiler.walkNode({
Pair(pair, __) {
// Import pairs consist of identifier and type
const [identifier, type] = pair.params;
imports[module.value] = Array.from(
new Set(imports[module.value].concat(identifier.value))
);
if (type.value === "Memory") {
hasMemory = true;
}
},
})(fields);
},
})(ast);
return [imports, hasMemory];
}
|
javascript
|
function parseImports(ast, compiler) {
const imports = {};
let hasMemory = false;
compiler.walkNode({
Import(node, _) {
// Import nodes consist of field and a string literal node
const [fields, module] = node.params;
if (imports[module.value] == null) {
imports[module.value] = [];
}
compiler.walkNode({
Pair(pair, __) {
// Import pairs consist of identifier and type
const [identifier, type] = pair.params;
imports[module.value] = Array.from(
new Set(imports[module.value].concat(identifier.value))
);
if (type.value === "Memory") {
hasMemory = true;
}
},
})(fields);
},
})(ast);
return [imports, hasMemory];
}
|
[
"function",
"parseImports",
"(",
"ast",
",",
"compiler",
")",
"{",
"const",
"imports",
"=",
"{",
"}",
";",
"let",
"hasMemory",
"=",
"false",
";",
"compiler",
".",
"walkNode",
"(",
"{",
"Import",
"(",
"node",
",",
"_",
")",
"{",
"// Import nodes consist of field and a string literal node",
"const",
"[",
"fields",
",",
"module",
"]",
"=",
"node",
".",
"params",
";",
"if",
"(",
"imports",
"[",
"module",
".",
"value",
"]",
"==",
"null",
")",
"{",
"imports",
"[",
"module",
".",
"value",
"]",
"=",
"[",
"]",
";",
"}",
"compiler",
".",
"walkNode",
"(",
"{",
"Pair",
"(",
"pair",
",",
"__",
")",
"{",
"// Import pairs consist of identifier and type",
"const",
"[",
"identifier",
",",
"type",
"]",
"=",
"pair",
".",
"params",
";",
"imports",
"[",
"module",
".",
"value",
"]",
"=",
"Array",
".",
"from",
"(",
"new",
"Set",
"(",
"imports",
"[",
"module",
".",
"value",
"]",
".",
"concat",
"(",
"identifier",
".",
"value",
")",
")",
")",
";",
"if",
"(",
"type",
".",
"value",
"===",
"\"Memory\"",
")",
"{",
"hasMemory",
"=",
"true",
";",
"}",
"}",
",",
"}",
")",
"(",
"fields",
")",
";",
"}",
",",
"}",
")",
"(",
"ast",
")",
";",
"return",
"[",
"imports",
",",
"hasMemory",
"]",
";",
"}"
] |
Parse imports out of an ast
|
[
"Parse",
"imports",
"out",
"of",
"an",
"ast"
] |
024533f483e0dc8f234638134948d686409187b4
|
https://github.com/ballercat/walt/blob/024533f483e0dc8f234638134948d686409187b4/packages/walt-buildtools/src/index.js#L26-L55
|
9,655
|
ballercat/walt
|
packages/walt-buildtools/src/index.js
|
buildTree
|
function buildTree(index, api) {
const modules = {};
const dependency = (module, parent) => {
const filepath = api.resolve(module, parent);
if (modules[filepath] != null) {
return modules[filepath];
}
const src = api.getFileContents(module, parent, "utf8");
const basic = api.parser(src);
const [nestedImports, hasMemory] = parseImports(basic, api);
const deps = {};
Object.keys(nestedImports).forEach(mod => {
if (mod.indexOf(".") === 0) {
const dep = dependency(mod, filepath);
deps[mod] = dep;
}
});
const patched = inferImportTypes(basic, deps, api);
const ast = api.semantics(patched);
api.validate(ast, {
lines: src.split("\n"),
filename: module.split("/").pop(),
});
const result = {
ast,
deps,
filepath,
hasMemory,
};
modules[filepath] = result;
return result;
};
const root = dependency(index, null);
return {
root,
modules,
};
}
|
javascript
|
function buildTree(index, api) {
const modules = {};
const dependency = (module, parent) => {
const filepath = api.resolve(module, parent);
if (modules[filepath] != null) {
return modules[filepath];
}
const src = api.getFileContents(module, parent, "utf8");
const basic = api.parser(src);
const [nestedImports, hasMemory] = parseImports(basic, api);
const deps = {};
Object.keys(nestedImports).forEach(mod => {
if (mod.indexOf(".") === 0) {
const dep = dependency(mod, filepath);
deps[mod] = dep;
}
});
const patched = inferImportTypes(basic, deps, api);
const ast = api.semantics(patched);
api.validate(ast, {
lines: src.split("\n"),
filename: module.split("/").pop(),
});
const result = {
ast,
deps,
filepath,
hasMemory,
};
modules[filepath] = result;
return result;
};
const root = dependency(index, null);
return {
root,
modules,
};
}
|
[
"function",
"buildTree",
"(",
"index",
",",
"api",
")",
"{",
"const",
"modules",
"=",
"{",
"}",
";",
"const",
"dependency",
"=",
"(",
"module",
",",
"parent",
")",
"=>",
"{",
"const",
"filepath",
"=",
"api",
".",
"resolve",
"(",
"module",
",",
"parent",
")",
";",
"if",
"(",
"modules",
"[",
"filepath",
"]",
"!=",
"null",
")",
"{",
"return",
"modules",
"[",
"filepath",
"]",
";",
"}",
"const",
"src",
"=",
"api",
".",
"getFileContents",
"(",
"module",
",",
"parent",
",",
"\"utf8\"",
")",
";",
"const",
"basic",
"=",
"api",
".",
"parser",
"(",
"src",
")",
";",
"const",
"[",
"nestedImports",
",",
"hasMemory",
"]",
"=",
"parseImports",
"(",
"basic",
",",
"api",
")",
";",
"const",
"deps",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"nestedImports",
")",
".",
"forEach",
"(",
"mod",
"=>",
"{",
"if",
"(",
"mod",
".",
"indexOf",
"(",
"\".\"",
")",
"===",
"0",
")",
"{",
"const",
"dep",
"=",
"dependency",
"(",
"mod",
",",
"filepath",
")",
";",
"deps",
"[",
"mod",
"]",
"=",
"dep",
";",
"}",
"}",
")",
";",
"const",
"patched",
"=",
"inferImportTypes",
"(",
"basic",
",",
"deps",
",",
"api",
")",
";",
"const",
"ast",
"=",
"api",
".",
"semantics",
"(",
"patched",
")",
";",
"api",
".",
"validate",
"(",
"ast",
",",
"{",
"lines",
":",
"src",
".",
"split",
"(",
"\"\\n\"",
")",
",",
"filename",
":",
"module",
".",
"split",
"(",
"\"/\"",
")",
".",
"pop",
"(",
")",
",",
"}",
")",
";",
"const",
"result",
"=",
"{",
"ast",
",",
"deps",
",",
"filepath",
",",
"hasMemory",
",",
"}",
";",
"modules",
"[",
"filepath",
"]",
"=",
"result",
";",
"return",
"result",
";",
"}",
";",
"const",
"root",
"=",
"dependency",
"(",
"index",
",",
"null",
")",
";",
"return",
"{",
"root",
",",
"modules",
",",
"}",
";",
"}"
] |
Build a dependency tree of ASTs given a root module
|
[
"Build",
"a",
"dependency",
"tree",
"of",
"ASTs",
"given",
"a",
"root",
"module"
] |
024533f483e0dc8f234638134948d686409187b4
|
https://github.com/ballercat/walt/blob/024533f483e0dc8f234638134948d686409187b4/packages/walt-buildtools/src/index.js#L58-L105
|
9,656
|
ballercat/walt
|
packages/walt-buildtools/src/index.js
|
build
|
function build(importsObj, tree) {
const modules = {};
const instantiate = filepath => {
if (modules[filepath] != null) {
return modules[filepath];
}
const mod = tree.modules[filepath];
const promise = Promise.all(
Object.entries(mod.deps).map(([key, dep]) => {
return instantiate(dep.filepath).then(result => [key, result]);
})
)
.then(importsMap => {
const imports = importsMap.reduce((acc, [key, module]) => {
acc[key] = module.instance.exports;
return acc;
}, {});
return WebAssembly.instantiate(
tree.opcodes[filepath],
Object.assign({}, imports, importsObj)
);
})
.catch(e => {
// TODO: do some logging here
throw e;
});
modules[filepath] = promise;
return promise;
};
modules[tree.root.filepath] = instantiate(tree.root.filepath);
return modules[tree.root.filepath];
}
|
javascript
|
function build(importsObj, tree) {
const modules = {};
const instantiate = filepath => {
if (modules[filepath] != null) {
return modules[filepath];
}
const mod = tree.modules[filepath];
const promise = Promise.all(
Object.entries(mod.deps).map(([key, dep]) => {
return instantiate(dep.filepath).then(result => [key, result]);
})
)
.then(importsMap => {
const imports = importsMap.reduce((acc, [key, module]) => {
acc[key] = module.instance.exports;
return acc;
}, {});
return WebAssembly.instantiate(
tree.opcodes[filepath],
Object.assign({}, imports, importsObj)
);
})
.catch(e => {
// TODO: do some logging here
throw e;
});
modules[filepath] = promise;
return promise;
};
modules[tree.root.filepath] = instantiate(tree.root.filepath);
return modules[tree.root.filepath];
}
|
[
"function",
"build",
"(",
"importsObj",
",",
"tree",
")",
"{",
"const",
"modules",
"=",
"{",
"}",
";",
"const",
"instantiate",
"=",
"filepath",
"=>",
"{",
"if",
"(",
"modules",
"[",
"filepath",
"]",
"!=",
"null",
")",
"{",
"return",
"modules",
"[",
"filepath",
"]",
";",
"}",
"const",
"mod",
"=",
"tree",
".",
"modules",
"[",
"filepath",
"]",
";",
"const",
"promise",
"=",
"Promise",
".",
"all",
"(",
"Object",
".",
"entries",
"(",
"mod",
".",
"deps",
")",
".",
"map",
"(",
"(",
"[",
"key",
",",
"dep",
"]",
")",
"=>",
"{",
"return",
"instantiate",
"(",
"dep",
".",
"filepath",
")",
".",
"then",
"(",
"result",
"=>",
"[",
"key",
",",
"result",
"]",
")",
";",
"}",
")",
")",
".",
"then",
"(",
"importsMap",
"=>",
"{",
"const",
"imports",
"=",
"importsMap",
".",
"reduce",
"(",
"(",
"acc",
",",
"[",
"key",
",",
"module",
"]",
")",
"=>",
"{",
"acc",
"[",
"key",
"]",
"=",
"module",
".",
"instance",
".",
"exports",
";",
"return",
"acc",
";",
"}",
",",
"{",
"}",
")",
";",
"return",
"WebAssembly",
".",
"instantiate",
"(",
"tree",
".",
"opcodes",
"[",
"filepath",
"]",
",",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"imports",
",",
"importsObj",
")",
")",
";",
"}",
")",
".",
"catch",
"(",
"e",
"=>",
"{",
"// TODO: do some logging here",
"throw",
"e",
";",
"}",
")",
";",
"modules",
"[",
"filepath",
"]",
"=",
"promise",
";",
"return",
"promise",
";",
"}",
";",
"modules",
"[",
"tree",
".",
"root",
".",
"filepath",
"]",
"=",
"instantiate",
"(",
"tree",
".",
"root",
".",
"filepath",
")",
";",
"return",
"modules",
"[",
"tree",
".",
"root",
".",
"filepath",
"]",
";",
"}"
] |
Build the final binary Module set
|
[
"Build",
"the",
"final",
"binary",
"Module",
"set"
] |
024533f483e0dc8f234638134948d686409187b4
|
https://github.com/ballercat/walt/blob/024533f483e0dc8f234638134948d686409187b4/packages/walt-buildtools/src/index.js#L157-L195
|
9,657
|
apache/couchdb-fauxton
|
tasks/fauxton.js
|
_getHost
|
function _getHost (fauxton_ip) {
if (fauxton_ip) {
return fauxton_ip;
}
//making some assumptions here
const interfaces = os.networkInterfaces();
const eth0 = interfaces[Object.keys(interfaces)[1]];
return eth0.find(function (item) {
return item.family === 'IPv4';
}).address;
}
|
javascript
|
function _getHost (fauxton_ip) {
if (fauxton_ip) {
return fauxton_ip;
}
//making some assumptions here
const interfaces = os.networkInterfaces();
const eth0 = interfaces[Object.keys(interfaces)[1]];
return eth0.find(function (item) {
return item.family === 'IPv4';
}).address;
}
|
[
"function",
"_getHost",
"(",
"fauxton_ip",
")",
"{",
"if",
"(",
"fauxton_ip",
")",
"{",
"return",
"fauxton_ip",
";",
"}",
"//making some assumptions here",
"const",
"interfaces",
"=",
"os",
".",
"networkInterfaces",
"(",
")",
";",
"const",
"eth0",
"=",
"interfaces",
"[",
"Object",
".",
"keys",
"(",
"interfaces",
")",
"[",
"1",
"]",
"]",
";",
"return",
"eth0",
".",
"find",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"family",
"===",
"'IPv4'",
";",
"}",
")",
".",
"address",
";",
"}"
] |
HELPERS if FAUXTON_HOST not set use ip address
|
[
"HELPERS",
"if",
"FAUXTON_HOST",
"not",
"set",
"use",
"ip",
"address"
] |
8773b054de9ec818c2a8555e342392abbd9dddec
|
https://github.com/apache/couchdb-fauxton/blob/8773b054de9ec818c2a8555e342392abbd9dddec/tasks/fauxton.js#L117-L127
|
9,658
|
apache/couchdb-fauxton
|
app/core/base.js
|
function (options) {
options = Object.assign({
msg: 'Notification Event Triggered!',
type: 'info',
escape: true,
clear: false
}, options);
if (FauxtonAPI.reduxDispatch) {
FauxtonAPI.reduxDispatch({
type: 'ADD_NOTIFICATION',
options: {
info: options
}
});
}
}
|
javascript
|
function (options) {
options = Object.assign({
msg: 'Notification Event Triggered!',
type: 'info',
escape: true,
clear: false
}, options);
if (FauxtonAPI.reduxDispatch) {
FauxtonAPI.reduxDispatch({
type: 'ADD_NOTIFICATION',
options: {
info: options
}
});
}
}
|
[
"function",
"(",
"options",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"msg",
":",
"'Notification Event Triggered!'",
",",
"type",
":",
"'info'",
",",
"escape",
":",
"true",
",",
"clear",
":",
"false",
"}",
",",
"options",
")",
";",
"if",
"(",
"FauxtonAPI",
".",
"reduxDispatch",
")",
"{",
"FauxtonAPI",
".",
"reduxDispatch",
"(",
"{",
"type",
":",
"'ADD_NOTIFICATION'",
",",
"options",
":",
"{",
"info",
":",
"options",
"}",
"}",
")",
";",
"}",
"}"
] |
Displays a notification message. The message is only displayed for a few seconds.
The option visibleTime can be provided to set for how long the message should be displayed.
@param {object} options Options are of the form
{
message: "string",
type: "success"|"error"|"info",
clear: true|false,
escape: true|false,
visibleTime: number
}
|
[
"Displays",
"a",
"notification",
"message",
".",
"The",
"message",
"is",
"only",
"displayed",
"for",
"a",
"few",
"seconds",
".",
"The",
"option",
"visibleTime",
"can",
"be",
"provided",
"to",
"set",
"for",
"how",
"long",
"the",
"message",
"should",
"be",
"displayed",
"."
] |
8773b054de9ec818c2a8555e342392abbd9dddec
|
https://github.com/apache/couchdb-fauxton/blob/8773b054de9ec818c2a8555e342392abbd9dddec/app/core/base.js#L58-L74
|
|
9,659
|
gijsroge/OwlCarousel2-Thumbs
|
dist/owl.carousel2.thumbs.js
|
function (carousel) {
/**
* Reference to the core.
* @protected
* @type {Owl}
*/
this.owl = carousel;
/**
* All DOM elements for thumbnails
* @protected
* @type {Object}
*/
this._thumbcontent = [];
/**
* Instance identiefier
* @type {number}
* @private
*/
this._identifier = 0;
/**
* Return current item regardless of clones
* @protected
* @type {Object}
*/
this.owl_currentitem = this.owl.options.startPosition;
/**
* The carousel element.
* @type {jQuery}
*/
this.$element = this.owl.$element;
/**
* All event handlers.
* @protected
* @type {Object}
*/
this._handlers = {
'prepared.owl.carousel': $.proxy(function (e) {
if (e.namespace && this.owl.options.thumbs && !this.owl.options.thumbImage && !this.owl.options.thumbsPrerendered && !this.owl.options.thumbImage) {
if ($(e.content).find('[data-thumb]').attr('data-thumb') !== undefined) {
this._thumbcontent.push($(e.content).find('[data-thumb]').attr('data-thumb'));
}
} else if (e.namespace && this.owl.options.thumbs && this.owl.options.thumbImage) {
var innerImage = $(e.content).find('img');
this._thumbcontent.push(innerImage);
}
}, this),
'initialized.owl.carousel': $.proxy(function (e) {
if (e.namespace && this.owl.options.thumbs) {
this.render();
this.listen();
this._identifier = this.owl.$element.data('slider-id');
this.setActive();
}
}, this),
'changed.owl.carousel': $.proxy(function (e) {
if (e.namespace && e.property.name === 'position' && this.owl.options.thumbs) {
this._identifier = this.owl.$element.data('slider-id');
this.setActive();
}
}, this)
};
// set default options
this.owl.options = $.extend({}, Thumbs.Defaults, this.owl.options);
// register the event handlers
this.owl.$element.on(this._handlers);
}
|
javascript
|
function (carousel) {
/**
* Reference to the core.
* @protected
* @type {Owl}
*/
this.owl = carousel;
/**
* All DOM elements for thumbnails
* @protected
* @type {Object}
*/
this._thumbcontent = [];
/**
* Instance identiefier
* @type {number}
* @private
*/
this._identifier = 0;
/**
* Return current item regardless of clones
* @protected
* @type {Object}
*/
this.owl_currentitem = this.owl.options.startPosition;
/**
* The carousel element.
* @type {jQuery}
*/
this.$element = this.owl.$element;
/**
* All event handlers.
* @protected
* @type {Object}
*/
this._handlers = {
'prepared.owl.carousel': $.proxy(function (e) {
if (e.namespace && this.owl.options.thumbs && !this.owl.options.thumbImage && !this.owl.options.thumbsPrerendered && !this.owl.options.thumbImage) {
if ($(e.content).find('[data-thumb]').attr('data-thumb') !== undefined) {
this._thumbcontent.push($(e.content).find('[data-thumb]').attr('data-thumb'));
}
} else if (e.namespace && this.owl.options.thumbs && this.owl.options.thumbImage) {
var innerImage = $(e.content).find('img');
this._thumbcontent.push(innerImage);
}
}, this),
'initialized.owl.carousel': $.proxy(function (e) {
if (e.namespace && this.owl.options.thumbs) {
this.render();
this.listen();
this._identifier = this.owl.$element.data('slider-id');
this.setActive();
}
}, this),
'changed.owl.carousel': $.proxy(function (e) {
if (e.namespace && e.property.name === 'position' && this.owl.options.thumbs) {
this._identifier = this.owl.$element.data('slider-id');
this.setActive();
}
}, this)
};
// set default options
this.owl.options = $.extend({}, Thumbs.Defaults, this.owl.options);
// register the event handlers
this.owl.$element.on(this._handlers);
}
|
[
"function",
"(",
"carousel",
")",
"{",
"/**\n * Reference to the core.\n * @protected\n * @type {Owl}\n */",
"this",
".",
"owl",
"=",
"carousel",
";",
"/**\n * All DOM elements for thumbnails\n * @protected\n * @type {Object}\n */",
"this",
".",
"_thumbcontent",
"=",
"[",
"]",
";",
"/**\n * Instance identiefier\n * @type {number}\n * @private\n */",
"this",
".",
"_identifier",
"=",
"0",
";",
"/**\n * Return current item regardless of clones\n * @protected\n * @type {Object}\n */",
"this",
".",
"owl_currentitem",
"=",
"this",
".",
"owl",
".",
"options",
".",
"startPosition",
";",
"/**\n * The carousel element.\n * @type {jQuery}\n */",
"this",
".",
"$element",
"=",
"this",
".",
"owl",
".",
"$element",
";",
"/**\n * All event handlers.\n * @protected\n * @type {Object}\n */",
"this",
".",
"_handlers",
"=",
"{",
"'prepared.owl.carousel'",
":",
"$",
".",
"proxy",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"namespace",
"&&",
"this",
".",
"owl",
".",
"options",
".",
"thumbs",
"&&",
"!",
"this",
".",
"owl",
".",
"options",
".",
"thumbImage",
"&&",
"!",
"this",
".",
"owl",
".",
"options",
".",
"thumbsPrerendered",
"&&",
"!",
"this",
".",
"owl",
".",
"options",
".",
"thumbImage",
")",
"{",
"if",
"(",
"$",
"(",
"e",
".",
"content",
")",
".",
"find",
"(",
"'[data-thumb]'",
")",
".",
"attr",
"(",
"'data-thumb'",
")",
"!==",
"undefined",
")",
"{",
"this",
".",
"_thumbcontent",
".",
"push",
"(",
"$",
"(",
"e",
".",
"content",
")",
".",
"find",
"(",
"'[data-thumb]'",
")",
".",
"attr",
"(",
"'data-thumb'",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"e",
".",
"namespace",
"&&",
"this",
".",
"owl",
".",
"options",
".",
"thumbs",
"&&",
"this",
".",
"owl",
".",
"options",
".",
"thumbImage",
")",
"{",
"var",
"innerImage",
"=",
"$",
"(",
"e",
".",
"content",
")",
".",
"find",
"(",
"'img'",
")",
";",
"this",
".",
"_thumbcontent",
".",
"push",
"(",
"innerImage",
")",
";",
"}",
"}",
",",
"this",
")",
",",
"'initialized.owl.carousel'",
":",
"$",
".",
"proxy",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"namespace",
"&&",
"this",
".",
"owl",
".",
"options",
".",
"thumbs",
")",
"{",
"this",
".",
"render",
"(",
")",
";",
"this",
".",
"listen",
"(",
")",
";",
"this",
".",
"_identifier",
"=",
"this",
".",
"owl",
".",
"$element",
".",
"data",
"(",
"'slider-id'",
")",
";",
"this",
".",
"setActive",
"(",
")",
";",
"}",
"}",
",",
"this",
")",
",",
"'changed.owl.carousel'",
":",
"$",
".",
"proxy",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"namespace",
"&&",
"e",
".",
"property",
".",
"name",
"===",
"'position'",
"&&",
"this",
".",
"owl",
".",
"options",
".",
"thumbs",
")",
"{",
"this",
".",
"_identifier",
"=",
"this",
".",
"owl",
".",
"$element",
".",
"data",
"(",
"'slider-id'",
")",
";",
"this",
".",
"setActive",
"(",
")",
";",
"}",
"}",
",",
"this",
")",
"}",
";",
"// set default options",
"this",
".",
"owl",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"Thumbs",
".",
"Defaults",
",",
"this",
".",
"owl",
".",
"options",
")",
";",
"// register the event handlers",
"this",
".",
"owl",
".",
"$element",
".",
"on",
"(",
"this",
".",
"_handlers",
")",
";",
"}"
] |
Creates the thumbs plugin.
@class The thumbs Plugin
@param {Owl} carousel - The Owl Carousel
|
[
"Creates",
"the",
"thumbs",
"plugin",
"."
] |
f4d2ca24dbdbf769f0915c721507809479492e74
|
https://github.com/gijsroge/OwlCarousel2-Thumbs/blob/f4d2ca24dbdbf769f0915c721507809479492e74/dist/owl.carousel2.thumbs.js#L16-L97
|
|
9,660
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
showWarning
|
function showWarning() {
var method = showWarning.caller.name;
if (!configurations.areTestsRunnning()) {
console.warn('This method (' + method + ') is deprecated and its going to be removed on next versions');
}
}
|
javascript
|
function showWarning() {
var method = showWarning.caller.name;
if (!configurations.areTestsRunnning()) {
console.warn('This method (' + method + ') is deprecated and its going to be removed on next versions');
}
}
|
[
"function",
"showWarning",
"(",
")",
"{",
"var",
"method",
"=",
"showWarning",
".",
"caller",
".",
"name",
";",
"if",
"(",
"!",
"configurations",
".",
"areTestsRunnning",
"(",
")",
")",
"{",
"console",
".",
"warn",
"(",
"'This method ('",
"+",
"method",
"+",
"') is deprecated and its going to be removed on next versions'",
")",
";",
"}",
"}"
] |
Show Warning for method deprecation
|
[
"Show",
"Warning",
"for",
"method",
"deprecation"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L15-L20
|
9,661
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
sandboxMode
|
function sandboxMode(enabled) {
showWarning();
configurations.sandbox = (enabled !== undefined) ? (enabled === true) : configurations.sandbox;
}
|
javascript
|
function sandboxMode(enabled) {
showWarning();
configurations.sandbox = (enabled !== undefined) ? (enabled === true) : configurations.sandbox;
}
|
[
"function",
"sandboxMode",
"(",
"enabled",
")",
"{",
"showWarning",
"(",
")",
";",
"configurations",
".",
"sandbox",
"=",
"(",
"enabled",
"!==",
"undefined",
")",
"?",
"(",
"enabled",
"===",
"true",
")",
":",
"configurations",
".",
"sandbox",
";",
"}"
] |
Enabled or disabled sandbox
@param enabled
|
[
"Enabled",
"or",
"disabled",
"sandbox"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L26-L29
|
9,662
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
getAccessToken
|
function getAccessToken() {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return requestManager.generateAccessToken(callback);
}
|
javascript
|
function getAccessToken() {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return requestManager.generateAccessToken(callback);
}
|
[
"function",
"getAccessToken",
"(",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"requestManager",
".",
"generateAccessToken",
"(",
"callback",
")",
";",
"}"
] |
Get access_token using the client_id and client_secret configure
@param callback
@returns {string}
|
[
"Get",
"access_token",
"using",
"the",
"client_id",
"and",
"client_secret",
"configure"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L36-L42
|
9,663
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
createPreference
|
function createPreference(preferences) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.create(preferences, callback);
}
|
javascript
|
function createPreference(preferences) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.create(preferences, callback);
}
|
[
"function",
"createPreference",
"(",
"preferences",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"preferencesModule",
".",
"create",
"(",
"preferences",
",",
"callback",
")",
";",
"}"
] |
Create a preference using preferenceModule
@param preferences
@param callback
@returns {preferences}
|
[
"Create",
"a",
"preference",
"using",
"preferenceModule"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L169-L175
|
9,664
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
getPreference
|
function getPreference(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.get(id, callback);
}
|
javascript
|
function getPreference(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.get(id, callback);
}
|
[
"function",
"getPreference",
"(",
"id",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"preferencesModule",
".",
"get",
"(",
"id",
",",
"callback",
")",
";",
"}"
] |
Get a preference using preferenceModule
@param id
@param callback
@returns {*}
|
[
"Get",
"a",
"preference",
"using",
"preferenceModule"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L201-L207
|
9,665
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
createPreapprovalPayment
|
function createPreapprovalPayment(preapproval) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.create(preapproval, callback);
}
|
javascript
|
function createPreapprovalPayment(preapproval) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.create(preapproval, callback);
}
|
[
"function",
"createPreapprovalPayment",
"(",
"preapproval",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"preapprovalModule",
".",
"create",
"(",
"preapproval",
",",
"callback",
")",
";",
"}"
] |
Create a preapproval payment using the preapprovalModule
@param preapproval
@param callback
@returns {preapproval}
|
[
"Create",
"a",
"preapproval",
"payment",
"using",
"the",
"preapprovalModule"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L215-L221
|
9,666
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
getPreapprovalPayment
|
function getPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.get(id, callback);
}
|
javascript
|
function getPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.get(id, callback);
}
|
[
"function",
"getPreapprovalPayment",
"(",
"id",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"preapprovalModule",
".",
"get",
"(",
"id",
",",
"callback",
")",
";",
"}"
] |
Get a preapproval payment using the preapprovalModule
@param id
@param callback
@returns {*}
|
[
"Get",
"a",
"preapproval",
"payment",
"using",
"the",
"preapprovalModule"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L247-L253
|
9,667
|
mercadopago/dx-nodejs
|
lib/mercadopago-support.js
|
cancelPreapprovalPayment
|
function cancelPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.update({
id: id,
status: 'cancelled'
}, callback);
}
|
javascript
|
function cancelPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.update({
id: id,
status: 'cancelled'
}, callback);
}
|
[
"function",
"cancelPreapprovalPayment",
"(",
"id",
")",
"{",
"var",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
")",
";",
"showWarning",
"(",
")",
";",
"return",
"preapprovalModule",
".",
"update",
"(",
"{",
"id",
":",
"id",
",",
"status",
":",
"'cancelled'",
"}",
",",
"callback",
")",
";",
"}"
] |
Canacel a preapproval payment using the preapprovalModule
@param id
@param callback
@returns {*}
|
[
"Canacel",
"a",
"preapproval",
"payment",
"using",
"the",
"preapprovalModule"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/mercadopago-support.js#L343-L352
|
9,668
|
mercadopago/dx-nodejs
|
lib/utils/mercadopagoError.js
|
function (resolve, reject, callback) {
callback = preConditions.getCallback(callback);
return requestManager.generateAccessToken().then(function () {
return requestManager.exec(execOptions);
}).then(function (response) {
resolve(response);
return callback.apply(null, [null, response]);
}).catch(function (err) {
reject(err);
return callback.apply(null, [err, null]);
});
}
|
javascript
|
function (resolve, reject, callback) {
callback = preConditions.getCallback(callback);
return requestManager.generateAccessToken().then(function () {
return requestManager.exec(execOptions);
}).then(function (response) {
resolve(response);
return callback.apply(null, [null, response]);
}).catch(function (err) {
reject(err);
return callback.apply(null, [err, null]);
});
}
|
[
"function",
"(",
"resolve",
",",
"reject",
",",
"callback",
")",
"{",
"callback",
"=",
"preConditions",
".",
"getCallback",
"(",
"callback",
")",
";",
"return",
"requestManager",
".",
"generateAccessToken",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"requestManager",
".",
"exec",
"(",
"execOptions",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"resolve",
"(",
"response",
")",
";",
"return",
"callback",
".",
"apply",
"(",
"null",
",",
"[",
"null",
",",
"response",
"]",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"return",
"callback",
".",
"apply",
"(",
"null",
",",
"[",
"err",
",",
"null",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Execute request using the requestManager and execOptions
@param resolve
@param reject
@param callback
@returns {*}
|
[
"Execute",
"request",
"using",
"the",
"requestManager",
"and",
"execOptions"
] |
6b0c1c4bf9ba363cd247358de62d01c3bb07820e
|
https://github.com/mercadopago/dx-nodejs/blob/6b0c1c4bf9ba363cd247358de62d01c3bb07820e/lib/utils/mercadopagoError.js#L28-L40
|
|
9,669
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
setCSS
|
function setCSS(el, properties) {
var key;
for (key in properties) {
if (properties.hasOwnProperty(key)) {
el.style[key] = properties[key];
}
}
}
|
javascript
|
function setCSS(el, properties) {
var key;
for (key in properties) {
if (properties.hasOwnProperty(key)) {
el.style[key] = properties[key];
}
}
}
|
[
"function",
"setCSS",
"(",
"el",
",",
"properties",
")",
"{",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"properties",
")",
"{",
"if",
"(",
"properties",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"el",
".",
"style",
"[",
"key",
"]",
"=",
"properties",
"[",
"key",
"]",
";",
"}",
"}",
"}"
] |
Update multiple css values on an object
|
[
"Update",
"multiple",
"css",
"values",
"on",
"an",
"object"
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L60-L67
|
9,670
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
bulkUpdateCSS
|
function bulkUpdateCSS(data, callback) {
executeNextFrame(function () {
var i, item;
for (i = 0; i < data.length; i++) {
item = data[i];
setCSS(item.el, item.css);
}
// Run optional callback
if (typeof callback === 'function') {
executeNextFrame(callback);
}
});
}
|
javascript
|
function bulkUpdateCSS(data, callback) {
executeNextFrame(function () {
var i, item;
for (i = 0; i < data.length; i++) {
item = data[i];
setCSS(item.el, item.css);
}
// Run optional callback
if (typeof callback === 'function') {
executeNextFrame(callback);
}
});
}
|
[
"function",
"bulkUpdateCSS",
"(",
"data",
",",
"callback",
")",
"{",
"executeNextFrame",
"(",
"function",
"(",
")",
"{",
"var",
"i",
",",
"item",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"data",
"[",
"i",
"]",
";",
"setCSS",
"(",
"item",
".",
"el",
",",
"item",
".",
"css",
")",
";",
"}",
"// Run optional callback",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"executeNextFrame",
"(",
"callback",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Update the css properties of multiple elements at the same time befor the browsers next animation frame. The parameter `data` has to be an array containing objects, each with the element and the desired css properties.
|
[
"Update",
"the",
"css",
"properties",
"of",
"multiple",
"elements",
"at",
"the",
"same",
"time",
"befor",
"the",
"browsers",
"next",
"animation",
"frame",
".",
"The",
"parameter",
"data",
"has",
"to",
"be",
"an",
"array",
"containing",
"objects",
"each",
"with",
"the",
"element",
"and",
"the",
"desired",
"css",
"properties",
"."
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L73-L85
|
9,671
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
getData
|
function getData(el, attr, isInt, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
var val = el.getAttribute('data-' + prefix + attr);
if (isInt === true) {
return parseInt(val, 10);
}
return val;
}
|
javascript
|
function getData(el, attr, isInt, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
var val = el.getAttribute('data-' + prefix + attr);
if (isInt === true) {
return parseInt(val, 10);
}
return val;
}
|
[
"function",
"getData",
"(",
"el",
",",
"attr",
",",
"isInt",
",",
"prefix",
")",
"{",
"if",
"(",
"prefix",
"===",
"undefined",
")",
"{",
"prefix",
"=",
"'wookmark-'",
";",
"}",
"var",
"val",
"=",
"el",
".",
"getAttribute",
"(",
"'data-'",
"+",
"prefix",
"+",
"attr",
")",
";",
"if",
"(",
"isInt",
"===",
"true",
")",
"{",
"return",
"parseInt",
"(",
"val",
",",
"10",
")",
";",
"}",
"return",
"val",
";",
"}"
] |
Get value of specified data attribute
|
[
"Get",
"value",
"of",
"specified",
"data",
"attribute"
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L160-L169
|
9,672
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
setData
|
function setData(el, attr, val, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
el.setAttribute('data-' + prefix + attr, val);
}
|
javascript
|
function setData(el, attr, val, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
el.setAttribute('data-' + prefix + attr, val);
}
|
[
"function",
"setData",
"(",
"el",
",",
"attr",
",",
"val",
",",
"prefix",
")",
"{",
"if",
"(",
"prefix",
"===",
"undefined",
")",
"{",
"prefix",
"=",
"'wookmark-'",
";",
"}",
"el",
".",
"setAttribute",
"(",
"'data-'",
"+",
"prefix",
"+",
"attr",
",",
"val",
")",
";",
"}"
] |
Set value of specified data attribute
|
[
"Set",
"value",
"of",
"specified",
"data",
"attribute"
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L172-L177
|
9,673
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
removeDuplicates
|
function removeDuplicates(items) {
var temp = {}, result = [], x, i = items.length;
while (i--) {
x = getData(items[i], 'id', true);
if (!temp.hasOwnProperty(x)) {
temp[x] = 1;
result.push(items[i]);
}
}
return result;
}
|
javascript
|
function removeDuplicates(items) {
var temp = {}, result = [], x, i = items.length;
while (i--) {
x = getData(items[i], 'id', true);
if (!temp.hasOwnProperty(x)) {
temp[x] = 1;
result.push(items[i]);
}
}
return result;
}
|
[
"function",
"removeDuplicates",
"(",
"items",
")",
"{",
"var",
"temp",
"=",
"{",
"}",
",",
"result",
"=",
"[",
"]",
",",
"x",
",",
"i",
"=",
"items",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"x",
"=",
"getData",
"(",
"items",
"[",
"i",
"]",
",",
"'id'",
",",
"true",
")",
";",
"if",
"(",
"!",
"temp",
".",
"hasOwnProperty",
"(",
"x",
")",
")",
"{",
"temp",
"[",
"x",
"]",
"=",
"1",
";",
"result",
".",
"push",
"(",
"items",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Remove duplicates from given array
|
[
"Remove",
"duplicates",
"from",
"given",
"array"
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L180-L190
|
9,674
|
germanysbestkeptsecret/Wookmark-jQuery
|
wookmark.js
|
indexOf
|
function indexOf(items, item) {
var len = items.length, i;
for (i = 0; i < len; i++) {
if (items[i] === item) {
return i;
}
}
return -1;
}
|
javascript
|
function indexOf(items, item) {
var len = items.length, i;
for (i = 0; i < len; i++) {
if (items[i] === item) {
return i;
}
}
return -1;
}
|
[
"function",
"indexOf",
"(",
"items",
",",
"item",
")",
"{",
"var",
"len",
"=",
"items",
".",
"length",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"items",
"[",
"i",
"]",
"===",
"item",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
IE 8 compatible indexOf
|
[
"IE",
"8",
"compatible",
"indexOf"
] |
ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47
|
https://github.com/germanysbestkeptsecret/Wookmark-jQuery/blob/ef96eb34ec653c4a0c1ec09fd3c7b6a615e6ab47/wookmark.js#L199-L207
|
9,675
|
SparkPost/heml
|
packages/heml/src/bin/commands/develop.js
|
renderCLI
|
function renderCLI ({ url, status, time, size }) {
return logUpdate(boxen(
`${chalk.bgBlue.black(' HEML ')}\n\n` +
`- ${chalk.bold('Preview:')} ${url}\n` +
`- ${chalk.bold('Status:')} ${status}\n` +
`- ${chalk.bold('Compile time:')} ${time}ms\n` +
`- ${chalk.bold('Total size:')} ${size}`,
{ padding: 1, margin: 1 }))
}
|
javascript
|
function renderCLI ({ url, status, time, size }) {
return logUpdate(boxen(
`${chalk.bgBlue.black(' HEML ')}\n\n` +
`- ${chalk.bold('Preview:')} ${url}\n` +
`- ${chalk.bold('Status:')} ${status}\n` +
`- ${chalk.bold('Compile time:')} ${time}ms\n` +
`- ${chalk.bold('Total size:')} ${size}`,
{ padding: 1, margin: 1 }))
}
|
[
"function",
"renderCLI",
"(",
"{",
"url",
",",
"status",
",",
"time",
",",
"size",
"}",
")",
"{",
"return",
"logUpdate",
"(",
"boxen",
"(",
"`",
"${",
"chalk",
".",
"bgBlue",
".",
"black",
"(",
"' HEML '",
")",
"}",
"\\n",
"\\n",
"`",
"+",
"`",
"${",
"chalk",
".",
"bold",
"(",
"'Preview:'",
")",
"}",
"${",
"url",
"}",
"\\n",
"`",
"+",
"`",
"${",
"chalk",
".",
"bold",
"(",
"'Status:'",
")",
"}",
"${",
"status",
"}",
"\\n",
"`",
"+",
"`",
"${",
"chalk",
".",
"bold",
"(",
"'Compile time:'",
")",
"}",
"${",
"time",
"}",
"\\n",
"`",
"+",
"`",
"${",
"chalk",
".",
"bold",
"(",
"'Total size:'",
")",
"}",
"${",
"size",
"}",
"`",
",",
"{",
"padding",
":",
"1",
",",
"margin",
":",
"1",
"}",
")",
")",
"}"
] |
update the cli UI
@param {String} params.url URL for preview server
@param {String} params.status the current status
@param {String} params.time time to compile the heml
@param {String} params.size size of the HTML in mb
|
[
"update",
"the",
"cli",
"UI"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml/src/bin/commands/develop.js#L69-L77
|
9,676
|
SparkPost/heml
|
packages/heml/src/bin/commands/develop.js
|
startDevServer
|
function startDevServer (directory, port = 3000) {
let url
const app = express()
const { reload } = reloadServer(app)
let preview = ''
app.get('/', (req, res) => res.send(preview))
app.use(express.static(directory))
function update ({ html, errors, metadata }) {
let status = errors.length ? chalk.red('failed') : chalk.green('success')
preview = errors.length
? buildErrorPage(errors)
: html.replace('</body>', '<script src="/reload/reload.js"></script></body>')
renderCLI({ url, status, time: metadata.time, size: metadata.size })
reload()
}
return new Promise((resolve, reject) => {
getPort({ port }).then((availablePort) => {
url = `http://localhost:${availablePort}`
app.listen(availablePort, () => resolve({ update, url, app }))
})
process.on('uncaughtException', reject)
})
}
|
javascript
|
function startDevServer (directory, port = 3000) {
let url
const app = express()
const { reload } = reloadServer(app)
let preview = ''
app.get('/', (req, res) => res.send(preview))
app.use(express.static(directory))
function update ({ html, errors, metadata }) {
let status = errors.length ? chalk.red('failed') : chalk.green('success')
preview = errors.length
? buildErrorPage(errors)
: html.replace('</body>', '<script src="/reload/reload.js"></script></body>')
renderCLI({ url, status, time: metadata.time, size: metadata.size })
reload()
}
return new Promise((resolve, reject) => {
getPort({ port }).then((availablePort) => {
url = `http://localhost:${availablePort}`
app.listen(availablePort, () => resolve({ update, url, app }))
})
process.on('uncaughtException', reject)
})
}
|
[
"function",
"startDevServer",
"(",
"directory",
",",
"port",
"=",
"3000",
")",
"{",
"let",
"url",
"const",
"app",
"=",
"express",
"(",
")",
"const",
"{",
"reload",
"}",
"=",
"reloadServer",
"(",
"app",
")",
"let",
"preview",
"=",
"''",
"app",
".",
"get",
"(",
"'/'",
",",
"(",
"req",
",",
"res",
")",
"=>",
"res",
".",
"send",
"(",
"preview",
")",
")",
"app",
".",
"use",
"(",
"express",
".",
"static",
"(",
"directory",
")",
")",
"function",
"update",
"(",
"{",
"html",
",",
"errors",
",",
"metadata",
"}",
")",
"{",
"let",
"status",
"=",
"errors",
".",
"length",
"?",
"chalk",
".",
"red",
"(",
"'failed'",
")",
":",
"chalk",
".",
"green",
"(",
"'success'",
")",
"preview",
"=",
"errors",
".",
"length",
"?",
"buildErrorPage",
"(",
"errors",
")",
":",
"html",
".",
"replace",
"(",
"'</body>'",
",",
"'<script src=\"/reload/reload.js\"></script></body>'",
")",
"renderCLI",
"(",
"{",
"url",
",",
"status",
",",
"time",
":",
"metadata",
".",
"time",
",",
"size",
":",
"metadata",
".",
"size",
"}",
")",
"reload",
"(",
")",
"}",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"getPort",
"(",
"{",
"port",
"}",
")",
".",
"then",
"(",
"(",
"availablePort",
")",
"=>",
"{",
"url",
"=",
"`",
"${",
"availablePort",
"}",
"`",
"app",
".",
"listen",
"(",
"availablePort",
",",
"(",
")",
"=>",
"resolve",
"(",
"{",
"update",
",",
"url",
",",
"app",
"}",
")",
")",
"}",
")",
"process",
".",
"on",
"(",
"'uncaughtException'",
",",
"reject",
")",
"}",
")",
"}"
] |
Launches a server that reloads when the update function is called
@param {String} defaultPreview the default content for when the sever loads
@return {Object} { server, port, update }
|
[
"Launches",
"a",
"server",
"that",
"reloads",
"when",
"the",
"update",
"function",
"is",
"called"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml/src/bin/commands/develop.js#L84-L112
|
9,677
|
SparkPost/heml
|
packages/heml/src/index.js
|
heml
|
async function heml (contents, options = {}) {
const results = {}
const {
beautify: beautifyOptions = {},
validate: validateOption = 'soft'
} = options
options.elements = flattenDeep(toArray(coreElements).concat(options.elements || []))
/** parse it ✂️ */
const $heml = parse(contents, options)
/** validate it 🕵 */
const errors = validate($heml, options)
if (validateOption.toLowerCase() === 'strict' && errors.length > 0) { throw errors[0] }
if (validateOption.toLowerCase() === 'soft') { results.errors = errors }
/** render it 🤖 */
const {
$: $html,
metadata
} = await render($heml, options)
/** inline it ✍️ */
inline($html, options)
/** beautify it 💅 */
results.html = condition.replace(beautify($html.html(), {
indent_size: 2,
indent_inner_html: true,
preserve_newlines: false,
extra_liners: [],
...beautifyOptions }))
/** final touches 👌 */
metadata.size = `${(byteLength(results.html) / 1024).toFixed(2)}kb`
results.metadata = metadata
/** send it back 🎉 */
return results
}
|
javascript
|
async function heml (contents, options = {}) {
const results = {}
const {
beautify: beautifyOptions = {},
validate: validateOption = 'soft'
} = options
options.elements = flattenDeep(toArray(coreElements).concat(options.elements || []))
/** parse it ✂️ */
const $heml = parse(contents, options)
/** validate it 🕵 */
const errors = validate($heml, options)
if (validateOption.toLowerCase() === 'strict' && errors.length > 0) { throw errors[0] }
if (validateOption.toLowerCase() === 'soft') { results.errors = errors }
/** render it 🤖 */
const {
$: $html,
metadata
} = await render($heml, options)
/** inline it ✍️ */
inline($html, options)
/** beautify it 💅 */
results.html = condition.replace(beautify($html.html(), {
indent_size: 2,
indent_inner_html: true,
preserve_newlines: false,
extra_liners: [],
...beautifyOptions }))
/** final touches 👌 */
metadata.size = `${(byteLength(results.html) / 1024).toFixed(2)}kb`
results.metadata = metadata
/** send it back 🎉 */
return results
}
|
[
"async",
"function",
"heml",
"(",
"contents",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"results",
"=",
"{",
"}",
"const",
"{",
"beautify",
":",
"beautifyOptions",
"=",
"{",
"}",
",",
"validate",
":",
"validateOption",
"=",
"'soft'",
"}",
"=",
"options",
"options",
".",
"elements",
"=",
"flattenDeep",
"(",
"toArray",
"(",
"coreElements",
")",
".",
"concat",
"(",
"options",
".",
"elements",
"||",
"[",
"]",
")",
")",
"/** parse it ✂️ */",
"const",
"$heml",
"=",
"parse",
"(",
"contents",
",",
"options",
")",
"/** validate it 🕵 */",
"const",
"errors",
"=",
"validate",
"(",
"$heml",
",",
"options",
")",
"if",
"(",
"validateOption",
".",
"toLowerCase",
"(",
")",
"===",
"'strict'",
"&&",
"errors",
".",
"length",
">",
"0",
")",
"{",
"throw",
"errors",
"[",
"0",
"]",
"}",
"if",
"(",
"validateOption",
".",
"toLowerCase",
"(",
")",
"===",
"'soft'",
")",
"{",
"results",
".",
"errors",
"=",
"errors",
"}",
"/** render it 🤖 */",
"const",
"{",
"$",
":",
"$html",
",",
"metadata",
"}",
"=",
"await",
"render",
"(",
"$heml",
",",
"options",
")",
"/** inline it ✍️ */",
"inline",
"(",
"$html",
",",
"options",
")",
"/** beautify it 💅 */",
"results",
".",
"html",
"=",
"condition",
".",
"replace",
"(",
"beautify",
"(",
"$html",
".",
"html",
"(",
")",
",",
"{",
"indent_size",
":",
"2",
",",
"indent_inner_html",
":",
"true",
",",
"preserve_newlines",
":",
"false",
",",
"extra_liners",
":",
"[",
"]",
",",
"...",
"beautifyOptions",
"}",
")",
")",
"/** final touches 👌 */",
"metadata",
".",
"size",
"=",
"`",
"${",
"(",
"byteLength",
"(",
"results",
".",
"html",
")",
"/",
"1024",
")",
".",
"toFixed",
"(",
"2",
")",
"}",
"`",
"results",
".",
"metadata",
"=",
"metadata",
"/** send it back 🎉 */",
"return",
"results",
"}"
] |
renders the given HEML string with the config provided
@param {String} HEML the heml to render
@param {Object} options the options
@return {Object} { metadata, html, errors }
|
[
"renders",
"the",
"given",
"HEML",
"string",
"with",
"the",
"config",
"provided"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml/src/index.js#L17-L57
|
9,678
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/expanders.js
|
replaceElementTagMentions
|
function replaceElementTagMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.walk((node) => {
if (node.value === element.tag && node.type === 'tag') { nodesToReplace.push(node) }
})
nodesToReplace.forEach((node) => node.replaceWith(element.pseudos.root))
})
return processor.process(selector).result
}
|
javascript
|
function replaceElementTagMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.walk((node) => {
if (node.value === element.tag && node.type === 'tag') { nodesToReplace.push(node) }
})
nodesToReplace.forEach((node) => node.replaceWith(element.pseudos.root))
})
return processor.process(selector).result
}
|
[
"function",
"replaceElementTagMentions",
"(",
"element",
",",
"selector",
")",
"{",
"const",
"processor",
"=",
"selectorParser",
"(",
"(",
"selectors",
")",
"=>",
"{",
"let",
"nodesToReplace",
"=",
"[",
"]",
"/**\n * looping breaks if we replace dynamically\n * so instead collect an array of nodes to swap and do it at the end\n */",
"selectors",
".",
"walk",
"(",
"(",
"node",
")",
"=>",
"{",
"if",
"(",
"node",
".",
"value",
"===",
"element",
".",
"tag",
"&&",
"node",
".",
"type",
"===",
"'tag'",
")",
"{",
"nodesToReplace",
".",
"push",
"(",
"node",
")",
"}",
"}",
")",
"nodesToReplace",
".",
"forEach",
"(",
"(",
"node",
")",
"=>",
"node",
".",
"replaceWith",
"(",
"element",
".",
"pseudos",
".",
"root",
")",
")",
"}",
")",
"return",
"processor",
".",
"process",
"(",
"selector",
")",
".",
"result",
"}"
] |
replace all custom element tag selectors
@param {Object} element the element definition
@param {String} selector the selector
@return {String} the replaced selector
|
[
"replace",
"all",
"custom",
"element",
"tag",
"selectors"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/expanders.js#L9-L25
|
9,679
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/expanders.js
|
replaceElementPseudoMentions
|
function replaceElementPseudoMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.each((selector) => {
let onElementTag = false
selector.each((node) => {
if (node.type === 'tag' && node.value === element.tag) {
onElementTag = true
} else if (node.type === 'combinator') {
onElementTag = false
} else if (node.type === 'pseudo' && onElementTag) {
const matchedPseudos = Object.entries(element.pseudos).filter(([ pseudo ]) => {
return node.value.replace(/::?/, '') === pseudo
})
if (matchedPseudos.length > 0) {
const [, value] = matchedPseudos[0]
nodesToReplace.push({ node, value })
}
}
})
})
nodesToReplace.forEach(({ node, value }) => node.replaceWith(` ${value}`))
})
return processor.process(selector).result
}
|
javascript
|
function replaceElementPseudoMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.each((selector) => {
let onElementTag = false
selector.each((node) => {
if (node.type === 'tag' && node.value === element.tag) {
onElementTag = true
} else if (node.type === 'combinator') {
onElementTag = false
} else if (node.type === 'pseudo' && onElementTag) {
const matchedPseudos = Object.entries(element.pseudos).filter(([ pseudo ]) => {
return node.value.replace(/::?/, '') === pseudo
})
if (matchedPseudos.length > 0) {
const [, value] = matchedPseudos[0]
nodesToReplace.push({ node, value })
}
}
})
})
nodesToReplace.forEach(({ node, value }) => node.replaceWith(` ${value}`))
})
return processor.process(selector).result
}
|
[
"function",
"replaceElementPseudoMentions",
"(",
"element",
",",
"selector",
")",
"{",
"const",
"processor",
"=",
"selectorParser",
"(",
"(",
"selectors",
")",
"=>",
"{",
"let",
"nodesToReplace",
"=",
"[",
"]",
"/**\n * looping breaks if we replace dynamically\n * so instead collect an array of nodes to swap and do it at the end\n */",
"selectors",
".",
"each",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"onElementTag",
"=",
"false",
"selector",
".",
"each",
"(",
"(",
"node",
")",
"=>",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'tag'",
"&&",
"node",
".",
"value",
"===",
"element",
".",
"tag",
")",
"{",
"onElementTag",
"=",
"true",
"}",
"else",
"if",
"(",
"node",
".",
"type",
"===",
"'combinator'",
")",
"{",
"onElementTag",
"=",
"false",
"}",
"else",
"if",
"(",
"node",
".",
"type",
"===",
"'pseudo'",
"&&",
"onElementTag",
")",
"{",
"const",
"matchedPseudos",
"=",
"Object",
".",
"entries",
"(",
"element",
".",
"pseudos",
")",
".",
"filter",
"(",
"(",
"[",
"pseudo",
"]",
")",
"=>",
"{",
"return",
"node",
".",
"value",
".",
"replace",
"(",
"/",
"::?",
"/",
",",
"''",
")",
"===",
"pseudo",
"}",
")",
"if",
"(",
"matchedPseudos",
".",
"length",
">",
"0",
")",
"{",
"const",
"[",
",",
"value",
"]",
"=",
"matchedPseudos",
"[",
"0",
"]",
"nodesToReplace",
".",
"push",
"(",
"{",
"node",
",",
"value",
"}",
")",
"}",
"}",
"}",
")",
"}",
")",
"nodesToReplace",
".",
"forEach",
"(",
"(",
"{",
"node",
",",
"value",
"}",
")",
"=>",
"node",
".",
"replaceWith",
"(",
"`",
"${",
"value",
"}",
"`",
")",
")",
"}",
")",
"return",
"processor",
".",
"process",
"(",
"selector",
")",
".",
"result",
"}"
] |
replace all custom element pseudo selectors
@param {Object} element the element definiton
@param {String} selector the selector
@return {String} the replaced selector
|
[
"replace",
"all",
"custom",
"element",
"pseudo",
"selectors"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/expanders.js#L33-L66
|
9,680
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/expanders.js
|
expandElementRule
|
function expandElementRule (element, selectors = [], originalRule) {
/** early return if we don't have any selectors */
if (selectors.length === 0) return []
let usedProps = []
let expandedRules = []
let defaultRules = []
/** create the base rule */
const baseRule = originalRule.clone()
baseRule.selectors = selectors
baseRule.selector = replaceElementTagMentions(element, baseRule.selector)
/** create postcss rules for each element rule */
for (const [ ruleSelector, ruleDecls ] of Object.entries(element.rules)) {
const isRoot = element.pseudos.root === ruleSelector
const isDefault = element.defaults.includes(ruleSelector)
const expandedRule = baseRule.clone()
/** gather all rules that get decls be default */
if (isDefault) { defaultRules.push(expandedRule) }
/** map all the selectors to target this rule selector */
if (!isRoot) { expandedRule.selectors = expandedRule.selectors.map((selector) => `${selector} ${ruleSelector}`) }
/** strip any non whitelisted props, run tranforms, gather used props */
expandedRule.walkDecls((decl) => {
const matchedRuleDecls = ruleDecls.filter(({ prop }) => prop.test(decl.prop))
if (matchedRuleDecls.length === 0) { return decl.remove() }
usedProps.push(decl.prop)
matchedRuleDecls.forEach(({ transform }) => transform(decl, originalRule))
})
expandedRules.push(expandedRule)
}
baseRule.walkDecls((decl) => {
if (!usedProps.includes(decl.prop)) {
defaultRules.forEach((defaultRule) => defaultRule.prepend(decl.clone()))
}
})
return expandedRules
}
|
javascript
|
function expandElementRule (element, selectors = [], originalRule) {
/** early return if we don't have any selectors */
if (selectors.length === 0) return []
let usedProps = []
let expandedRules = []
let defaultRules = []
/** create the base rule */
const baseRule = originalRule.clone()
baseRule.selectors = selectors
baseRule.selector = replaceElementTagMentions(element, baseRule.selector)
/** create postcss rules for each element rule */
for (const [ ruleSelector, ruleDecls ] of Object.entries(element.rules)) {
const isRoot = element.pseudos.root === ruleSelector
const isDefault = element.defaults.includes(ruleSelector)
const expandedRule = baseRule.clone()
/** gather all rules that get decls be default */
if (isDefault) { defaultRules.push(expandedRule) }
/** map all the selectors to target this rule selector */
if (!isRoot) { expandedRule.selectors = expandedRule.selectors.map((selector) => `${selector} ${ruleSelector}`) }
/** strip any non whitelisted props, run tranforms, gather used props */
expandedRule.walkDecls((decl) => {
const matchedRuleDecls = ruleDecls.filter(({ prop }) => prop.test(decl.prop))
if (matchedRuleDecls.length === 0) { return decl.remove() }
usedProps.push(decl.prop)
matchedRuleDecls.forEach(({ transform }) => transform(decl, originalRule))
})
expandedRules.push(expandedRule)
}
baseRule.walkDecls((decl) => {
if (!usedProps.includes(decl.prop)) {
defaultRules.forEach((defaultRule) => defaultRule.prepend(decl.clone()))
}
})
return expandedRules
}
|
[
"function",
"expandElementRule",
"(",
"element",
",",
"selectors",
"=",
"[",
"]",
",",
"originalRule",
")",
"{",
"/** early return if we don't have any selectors */",
"if",
"(",
"selectors",
".",
"length",
"===",
"0",
")",
"return",
"[",
"]",
"let",
"usedProps",
"=",
"[",
"]",
"let",
"expandedRules",
"=",
"[",
"]",
"let",
"defaultRules",
"=",
"[",
"]",
"/** create the base rule */",
"const",
"baseRule",
"=",
"originalRule",
".",
"clone",
"(",
")",
"baseRule",
".",
"selectors",
"=",
"selectors",
"baseRule",
".",
"selector",
"=",
"replaceElementTagMentions",
"(",
"element",
",",
"baseRule",
".",
"selector",
")",
"/** create postcss rules for each element rule */",
"for",
"(",
"const",
"[",
"ruleSelector",
",",
"ruleDecls",
"]",
"of",
"Object",
".",
"entries",
"(",
"element",
".",
"rules",
")",
")",
"{",
"const",
"isRoot",
"=",
"element",
".",
"pseudos",
".",
"root",
"===",
"ruleSelector",
"const",
"isDefault",
"=",
"element",
".",
"defaults",
".",
"includes",
"(",
"ruleSelector",
")",
"const",
"expandedRule",
"=",
"baseRule",
".",
"clone",
"(",
")",
"/** gather all rules that get decls be default */",
"if",
"(",
"isDefault",
")",
"{",
"defaultRules",
".",
"push",
"(",
"expandedRule",
")",
"}",
"/** map all the selectors to target this rule selector */",
"if",
"(",
"!",
"isRoot",
")",
"{",
"expandedRule",
".",
"selectors",
"=",
"expandedRule",
".",
"selectors",
".",
"map",
"(",
"(",
"selector",
")",
"=>",
"`",
"${",
"selector",
"}",
"${",
"ruleSelector",
"}",
"`",
")",
"}",
"/** strip any non whitelisted props, run tranforms, gather used props */",
"expandedRule",
".",
"walkDecls",
"(",
"(",
"decl",
")",
"=>",
"{",
"const",
"matchedRuleDecls",
"=",
"ruleDecls",
".",
"filter",
"(",
"(",
"{",
"prop",
"}",
")",
"=>",
"prop",
".",
"test",
"(",
"decl",
".",
"prop",
")",
")",
"if",
"(",
"matchedRuleDecls",
".",
"length",
"===",
"0",
")",
"{",
"return",
"decl",
".",
"remove",
"(",
")",
"}",
"usedProps",
".",
"push",
"(",
"decl",
".",
"prop",
")",
"matchedRuleDecls",
".",
"forEach",
"(",
"(",
"{",
"transform",
"}",
")",
"=>",
"transform",
"(",
"decl",
",",
"originalRule",
")",
")",
"}",
")",
"expandedRules",
".",
"push",
"(",
"expandedRule",
")",
"}",
"baseRule",
".",
"walkDecls",
"(",
"(",
"decl",
")",
"=>",
"{",
"if",
"(",
"!",
"usedProps",
".",
"includes",
"(",
"decl",
".",
"prop",
")",
")",
"{",
"defaultRules",
".",
"forEach",
"(",
"(",
"defaultRule",
")",
"=>",
"defaultRule",
".",
"prepend",
"(",
"decl",
".",
"clone",
"(",
")",
")",
")",
"}",
"}",
")",
"return",
"expandedRules",
"}"
] |
expand the given rule to correctly the style the element
@param {Object} element element The element definition
@param {Array} selectors the matched selectors to for
@return {Array[Rule]} an array of the expanded rules
|
[
"expand",
"the",
"given",
"rule",
"to",
"correctly",
"the",
"style",
"the",
"element"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/expanders.js#L74-L119
|
9,681
|
SparkPost/heml
|
packages/heml-render/src/index.js
|
preRenderElements
|
async function preRenderElements (elements, globals) {
for (let element of elements) {
await element.preRender(globals)
}
}
|
javascript
|
async function preRenderElements (elements, globals) {
for (let element of elements) {
await element.preRender(globals)
}
}
|
[
"async",
"function",
"preRenderElements",
"(",
"elements",
",",
"globals",
")",
"{",
"for",
"(",
"let",
"element",
"of",
"elements",
")",
"{",
"await",
"element",
".",
"preRender",
"(",
"globals",
")",
"}",
"}"
] |
Run the async preRender functions for each element
@param {Array} elements List of element definitons
@param {Object} globals
@return {Promise}
|
[
"Run",
"the",
"async",
"preRender",
"functions",
"for",
"each",
"element"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-render/src/index.js#L33-L37
|
9,682
|
SparkPost/heml
|
packages/heml-render/src/index.js
|
postRenderElements
|
async function postRenderElements (elements, globals) {
for (let element of elements) {
await element.postRender(globals)
}
}
|
javascript
|
async function postRenderElements (elements, globals) {
for (let element of elements) {
await element.postRender(globals)
}
}
|
[
"async",
"function",
"postRenderElements",
"(",
"elements",
",",
"globals",
")",
"{",
"for",
"(",
"let",
"element",
"of",
"elements",
")",
"{",
"await",
"element",
".",
"postRender",
"(",
"globals",
")",
"}",
"}"
] |
Run the async postRender functions for each element
@param {Array} elements List of element definitons
@param {Object} globals
@return {Promise}
|
[
"Run",
"the",
"async",
"postRender",
"functions",
"for",
"each",
"element"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-render/src/index.js#L45-L49
|
9,683
|
SparkPost/heml
|
packages/heml-render/src/index.js
|
renderElements
|
async function renderElements (elements, globals) {
const { $ } = globals
const elementMap = keyBy(elements, 'tagName')
const metaTagNames = filter(elements, { parent: [ 'head' ] }).map(({ tagName }) => tagName)
const nonMetaTagNames = difference(elements.map(({ tagName }) => tagName), metaTagNames)
const $nodes = [
...$.findNodes(metaTagNames), /** Render the meta elements first to last */
...$.findNodes(nonMetaTagNames).reverse() /** Render the elements last to first/outside to inside */
]
for (let $node of $nodes) {
const element = elementMap[$node.prop('tagName').toLowerCase()]
const contents = $node.html()
const attrs = $node[0].attribs
const renderedValue = await Promise.resolve(renderElement(element, attrs, contents))
$node.replaceWith(renderedValue.trim())
}
}
|
javascript
|
async function renderElements (elements, globals) {
const { $ } = globals
const elementMap = keyBy(elements, 'tagName')
const metaTagNames = filter(elements, { parent: [ 'head' ] }).map(({ tagName }) => tagName)
const nonMetaTagNames = difference(elements.map(({ tagName }) => tagName), metaTagNames)
const $nodes = [
...$.findNodes(metaTagNames), /** Render the meta elements first to last */
...$.findNodes(nonMetaTagNames).reverse() /** Render the elements last to first/outside to inside */
]
for (let $node of $nodes) {
const element = elementMap[$node.prop('tagName').toLowerCase()]
const contents = $node.html()
const attrs = $node[0].attribs
const renderedValue = await Promise.resolve(renderElement(element, attrs, contents))
$node.replaceWith(renderedValue.trim())
}
}
|
[
"async",
"function",
"renderElements",
"(",
"elements",
",",
"globals",
")",
"{",
"const",
"{",
"$",
"}",
"=",
"globals",
"const",
"elementMap",
"=",
"keyBy",
"(",
"elements",
",",
"'tagName'",
")",
"const",
"metaTagNames",
"=",
"filter",
"(",
"elements",
",",
"{",
"parent",
":",
"[",
"'head'",
"]",
"}",
")",
".",
"map",
"(",
"(",
"{",
"tagName",
"}",
")",
"=>",
"tagName",
")",
"const",
"nonMetaTagNames",
"=",
"difference",
"(",
"elements",
".",
"map",
"(",
"(",
"{",
"tagName",
"}",
")",
"=>",
"tagName",
")",
",",
"metaTagNames",
")",
"const",
"$nodes",
"=",
"[",
"...",
"$",
".",
"findNodes",
"(",
"metaTagNames",
")",
",",
"/** Render the meta elements first to last */",
"...",
"$",
".",
"findNodes",
"(",
"nonMetaTagNames",
")",
".",
"reverse",
"(",
")",
"/** Render the elements last to first/outside to inside */",
"]",
"for",
"(",
"let",
"$node",
"of",
"$nodes",
")",
"{",
"const",
"element",
"=",
"elementMap",
"[",
"$node",
".",
"prop",
"(",
"'tagName'",
")",
".",
"toLowerCase",
"(",
")",
"]",
"const",
"contents",
"=",
"$node",
".",
"html",
"(",
")",
"const",
"attrs",
"=",
"$node",
"[",
"0",
"]",
".",
"attribs",
"const",
"renderedValue",
"=",
"await",
"Promise",
".",
"resolve",
"(",
"renderElement",
"(",
"element",
",",
"attrs",
",",
"contents",
")",
")",
"$node",
".",
"replaceWith",
"(",
"renderedValue",
".",
"trim",
"(",
")",
")",
"}",
"}"
] |
Renders all HEML elements
@param {Array} elements List of element definitons
@param {Object} globals
@return {Promise}
|
[
"Renders",
"all",
"HEML",
"elements"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-render/src/index.js#L57-L77
|
9,684
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/coerceElements.js
|
findAtDecl
|
function findAtDecl (decls, prop) {
const foundDecls = decls.filter((decl) => {
return (isPlainObject(decl) &&
Object.keys(decl).length > 0 &&
Object.keys(decl)[0] === `@${prop}`) || decl === `@${prop}`
})
if (foundDecls.length === 0) { return }
const decl = foundDecls[0]
return isPlainObject(decl) ? Object.values(decl)[0] : true
}
|
javascript
|
function findAtDecl (decls, prop) {
const foundDecls = decls.filter((decl) => {
return (isPlainObject(decl) &&
Object.keys(decl).length > 0 &&
Object.keys(decl)[0] === `@${prop}`) || decl === `@${prop}`
})
if (foundDecls.length === 0) { return }
const decl = foundDecls[0]
return isPlainObject(decl) ? Object.values(decl)[0] : true
}
|
[
"function",
"findAtDecl",
"(",
"decls",
",",
"prop",
")",
"{",
"const",
"foundDecls",
"=",
"decls",
".",
"filter",
"(",
"(",
"decl",
")",
"=>",
"{",
"return",
"(",
"isPlainObject",
"(",
"decl",
")",
"&&",
"Object",
".",
"keys",
"(",
"decl",
")",
".",
"length",
">",
"0",
"&&",
"Object",
".",
"keys",
"(",
"decl",
")",
"[",
"0",
"]",
"===",
"`",
"${",
"prop",
"}",
"`",
")",
"||",
"decl",
"===",
"`",
"${",
"prop",
"}",
"`",
"}",
")",
"if",
"(",
"foundDecls",
".",
"length",
"===",
"0",
")",
"{",
"return",
"}",
"const",
"decl",
"=",
"foundDecls",
"[",
"0",
"]",
"return",
"isPlainObject",
"(",
"decl",
")",
"?",
"Object",
".",
"values",
"(",
"decl",
")",
"[",
"0",
"]",
":",
"true",
"}"
] |
finds the given at declaration value
@param {Array[Object]} decls the decls from an element
@param {String} the prop
@return {Any} the found value
|
[
"finds",
"the",
"given",
"at",
"declaration",
"value"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/coerceElements.js#L65-L77
|
9,685
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/coerceElements.js
|
toRegExp
|
function toRegExp (string) {
if (isString(string) && string.startsWith('/') && string.lastIndexOf('/') !== 0) {
const pattern = string.substr(1, string.lastIndexOf('/') - 1)
const opts = string.substr(string.lastIndexOf('/') + 1).toLowerCase()
return new RegExp(pattern, opts.includes('i') ? opts : `${opts}i`)
}
if (isString(string)) {
return new RegExp(`^${escapeRegExp(string)}$`, 'i')
}
return string
}
|
javascript
|
function toRegExp (string) {
if (isString(string) && string.startsWith('/') && string.lastIndexOf('/') !== 0) {
const pattern = string.substr(1, string.lastIndexOf('/') - 1)
const opts = string.substr(string.lastIndexOf('/') + 1).toLowerCase()
return new RegExp(pattern, opts.includes('i') ? opts : `${opts}i`)
}
if (isString(string)) {
return new RegExp(`^${escapeRegExp(string)}$`, 'i')
}
return string
}
|
[
"function",
"toRegExp",
"(",
"string",
")",
"{",
"if",
"(",
"isString",
"(",
"string",
")",
"&&",
"string",
".",
"startsWith",
"(",
"'/'",
")",
"&&",
"string",
".",
"lastIndexOf",
"(",
"'/'",
")",
"!==",
"0",
")",
"{",
"const",
"pattern",
"=",
"string",
".",
"substr",
"(",
"1",
",",
"string",
".",
"lastIndexOf",
"(",
"'/'",
")",
"-",
"1",
")",
"const",
"opts",
"=",
"string",
".",
"substr",
"(",
"string",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
".",
"toLowerCase",
"(",
")",
"return",
"new",
"RegExp",
"(",
"pattern",
",",
"opts",
".",
"includes",
"(",
"'i'",
")",
"?",
"opts",
":",
"`",
"${",
"opts",
"}",
"`",
")",
"}",
"if",
"(",
"isString",
"(",
"string",
")",
")",
"{",
"return",
"new",
"RegExp",
"(",
"`",
"${",
"escapeRegExp",
"(",
"string",
")",
"}",
"`",
",",
"'i'",
")",
"}",
"return",
"string",
"}"
] |
convert the given string to a regular expression
@param {String|RegExp} prop the string to convert
@return {RegExp} the regular expression
|
[
"convert",
"the",
"given",
"string",
"to",
"a",
"regular",
"expression"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/coerceElements.js#L84-L97
|
9,686
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js
|
targetsTag
|
function targetsTag (selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { break }
if (node.type === 'tag') { return true }
}
return false
}).length > 0
}
|
javascript
|
function targetsTag (selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { break }
if (node.type === 'tag') { return true }
}
return false
}).length > 0
}
|
[
"function",
"targetsTag",
"(",
"selector",
")",
"{",
"const",
"selectors",
"=",
"simpleSelectorParser",
".",
"process",
"(",
"selector",
")",
".",
"res",
"return",
"selectors",
".",
"filter",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"selectorNodes",
"=",
"selector",
".",
"nodes",
".",
"concat",
"(",
"[",
"]",
")",
".",
"reverse",
"(",
")",
"// clone the array",
"for",
"(",
"const",
"node",
"of",
"selectorNodes",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'cominator'",
")",
"{",
"break",
"}",
"if",
"(",
"node",
".",
"type",
"===",
"'tag'",
")",
"{",
"return",
"true",
"}",
"}",
"return",
"false",
"}",
")",
".",
"length",
">",
"0",
"}"
] |
checks if selector targets a tag
@param {String} selector the selector
@return {Boolean} if the selector targets a tag
|
[
"checks",
"if",
"selector",
"targets",
"a",
"tag"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js#L36-L50
|
9,687
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js
|
targetsElementPseudo
|
function targetsElementPseudo (element, selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { break }
if (node.type === 'pseudo' && node.value.replace(/::?/, '') in element.pseudos) {
return true
}
if (node.type === 'tag' && node.value === element.tag) { break }
}
return false
}).length > 0
}
|
javascript
|
function targetsElementPseudo (element, selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { break }
if (node.type === 'pseudo' && node.value.replace(/::?/, '') in element.pseudos) {
return true
}
if (node.type === 'tag' && node.value === element.tag) { break }
}
return false
}).length > 0
}
|
[
"function",
"targetsElementPseudo",
"(",
"element",
",",
"selector",
")",
"{",
"const",
"selectors",
"=",
"simpleSelectorParser",
".",
"process",
"(",
"selector",
")",
".",
"res",
"return",
"selectors",
".",
"filter",
"(",
"(",
"selector",
")",
"=>",
"{",
"let",
"selectorNodes",
"=",
"selector",
".",
"nodes",
".",
"concat",
"(",
"[",
"]",
")",
".",
"reverse",
"(",
")",
"// clone the array",
"for",
"(",
"const",
"node",
"of",
"selectorNodes",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'cominator'",
")",
"{",
"break",
"}",
"if",
"(",
"node",
".",
"type",
"===",
"'pseudo'",
"&&",
"node",
".",
"value",
".",
"replace",
"(",
"/",
"::?",
"/",
",",
"''",
")",
"in",
"element",
".",
"pseudos",
")",
"{",
"return",
"true",
"}",
"if",
"(",
"node",
".",
"type",
"===",
"'tag'",
"&&",
"node",
".",
"value",
"===",
"element",
".",
"tag",
")",
"{",
"break",
"}",
"}",
"return",
"false",
"}",
")",
".",
"length",
">",
"0",
"}"
] |
find all selectors that target the give element
@param {Object} element the element definition
@param {String} selector the selector
@return {Array} the matched selectors
|
[
"find",
"all",
"selectors",
"that",
"target",
"the",
"give",
"element"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js#L58-L76
|
9,688
|
SparkPost/heml
|
packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js
|
appendElementSelector
|
function appendElementSelector (element, selector) {
const processor = selectorParser((selectors) => {
let combinatorNode = null
/**
* looping breaks if we insert dynamically
*/
selectors.each((selector) => {
const elementNode = selectorParser.tag({ value: element.tag })
selector.walk((node) => {
if (node.type === 'combinator') { combinatorNode = node }
})
if (combinatorNode) {
selector.insertAfter(combinatorNode, elementNode)
} else {
selector.prepend(elementNode)
}
})
})
return processor.process(selector).result
}
|
javascript
|
function appendElementSelector (element, selector) {
const processor = selectorParser((selectors) => {
let combinatorNode = null
/**
* looping breaks if we insert dynamically
*/
selectors.each((selector) => {
const elementNode = selectorParser.tag({ value: element.tag })
selector.walk((node) => {
if (node.type === 'combinator') { combinatorNode = node }
})
if (combinatorNode) {
selector.insertAfter(combinatorNode, elementNode)
} else {
selector.prepend(elementNode)
}
})
})
return processor.process(selector).result
}
|
[
"function",
"appendElementSelector",
"(",
"element",
",",
"selector",
")",
"{",
"const",
"processor",
"=",
"selectorParser",
"(",
"(",
"selectors",
")",
"=>",
"{",
"let",
"combinatorNode",
"=",
"null",
"/**\n * looping breaks if we insert dynamically\n */",
"selectors",
".",
"each",
"(",
"(",
"selector",
")",
"=>",
"{",
"const",
"elementNode",
"=",
"selectorParser",
".",
"tag",
"(",
"{",
"value",
":",
"element",
".",
"tag",
"}",
")",
"selector",
".",
"walk",
"(",
"(",
"node",
")",
"=>",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'combinator'",
")",
"{",
"combinatorNode",
"=",
"node",
"}",
"}",
")",
"if",
"(",
"combinatorNode",
")",
"{",
"selector",
".",
"insertAfter",
"(",
"combinatorNode",
",",
"elementNode",
")",
"}",
"else",
"{",
"selector",
".",
"prepend",
"(",
"elementNode",
")",
"}",
"}",
")",
"}",
")",
"return",
"processor",
".",
"process",
"(",
"selector",
")",
".",
"result",
"}"
] |
Add the element tag to the end of the selector
@param {Object} element element definition
@param {String} selector the selector
@return {String} the modified selector
|
[
"Add",
"the",
"element",
"tag",
"to",
"the",
"end",
"of",
"the",
"selector"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-styles/src/plugins/postcss-element-expander/tagAliasSelectors.js#L84-L106
|
9,689
|
SparkPost/heml
|
packages/heml-inline/src/inlineMargins.js
|
inlineMargins
|
function inlineMargins ($) {
$('table[style*=margin]').toNodes().forEach(($el) => {
const { left, right } = getSideMargins($el.attr('style'))
if (left === 'auto' && right === 'auto') {
$el.attr('align', 'center')
} else if (left === 'auto' && right !== 'auto') {
$el.attr('align', 'right')
} else if (left !== 'auto') {
$el.attr('align', 'left')
}
})
}
|
javascript
|
function inlineMargins ($) {
$('table[style*=margin]').toNodes().forEach(($el) => {
const { left, right } = getSideMargins($el.attr('style'))
if (left === 'auto' && right === 'auto') {
$el.attr('align', 'center')
} else if (left === 'auto' && right !== 'auto') {
$el.attr('align', 'right')
} else if (left !== 'auto') {
$el.attr('align', 'left')
}
})
}
|
[
"function",
"inlineMargins",
"(",
"$",
")",
"{",
"$",
"(",
"'table[style*=margin]'",
")",
".",
"toNodes",
"(",
")",
".",
"forEach",
"(",
"(",
"$el",
")",
"=>",
"{",
"const",
"{",
"left",
",",
"right",
"}",
"=",
"getSideMargins",
"(",
"$el",
".",
"attr",
"(",
"'style'",
")",
")",
"if",
"(",
"left",
"===",
"'auto'",
"&&",
"right",
"===",
"'auto'",
")",
"{",
"$el",
".",
"attr",
"(",
"'align'",
",",
"'center'",
")",
"}",
"else",
"if",
"(",
"left",
"===",
"'auto'",
"&&",
"right",
"!==",
"'auto'",
")",
"{",
"$el",
".",
"attr",
"(",
"'align'",
",",
"'right'",
")",
"}",
"else",
"if",
"(",
"left",
"!==",
"'auto'",
")",
"{",
"$el",
".",
"attr",
"(",
"'align'",
",",
"'left'",
")",
"}",
"}",
")",
"}"
] |
finds all the tables that are centered with margins
and centers them with the align attribute
@param {Cheerio} $
|
[
"finds",
"all",
"the",
"tables",
"that",
"are",
"centered",
"with",
"margins",
"and",
"centers",
"them",
"with",
"the",
"align",
"attribute"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-inline/src/inlineMargins.js#L8-L20
|
9,690
|
SparkPost/heml
|
packages/heml-inline/src/inlineMargins.js
|
getSideMargins
|
function getSideMargins (style) {
const margins = compact(style.split(';')).map((decl) => {
const split = decl.split(':')
return {
prop: first(split).trim().toLowerCase(),
value: last(split).trim().toLowerCase()
}
}).filter(({ prop, value }) => prop.indexOf('margin') === 0)
let left = 0
let right = 0
margins.forEach(({ prop, value }) => {
if (prop === 'margin-left') {
left = value
return
}
if (prop === 'margin-right') {
right = value
return
}
if (prop === 'margin') {
const values = value.split(' ').map((i) => i.trim())
switch (values.length) {
case 1:
right = first(values)
left = first(values)
break
case 2:
right = last(values)
left = last(values)
break
case 3:
right = nth(values, 1)
left = nth(values, 1)
break
default:
right = nth(values, 1)
left = nth(values, 3)
break
}
}
})
return { left, right }
}
|
javascript
|
function getSideMargins (style) {
const margins = compact(style.split(';')).map((decl) => {
const split = decl.split(':')
return {
prop: first(split).trim().toLowerCase(),
value: last(split).trim().toLowerCase()
}
}).filter(({ prop, value }) => prop.indexOf('margin') === 0)
let left = 0
let right = 0
margins.forEach(({ prop, value }) => {
if (prop === 'margin-left') {
left = value
return
}
if (prop === 'margin-right') {
right = value
return
}
if (prop === 'margin') {
const values = value.split(' ').map((i) => i.trim())
switch (values.length) {
case 1:
right = first(values)
left = first(values)
break
case 2:
right = last(values)
left = last(values)
break
case 3:
right = nth(values, 1)
left = nth(values, 1)
break
default:
right = nth(values, 1)
left = nth(values, 3)
break
}
}
})
return { left, right }
}
|
[
"function",
"getSideMargins",
"(",
"style",
")",
"{",
"const",
"margins",
"=",
"compact",
"(",
"style",
".",
"split",
"(",
"';'",
")",
")",
".",
"map",
"(",
"(",
"decl",
")",
"=>",
"{",
"const",
"split",
"=",
"decl",
".",
"split",
"(",
"':'",
")",
"return",
"{",
"prop",
":",
"first",
"(",
"split",
")",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"value",
":",
"last",
"(",
"split",
")",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
"}",
"}",
")",
".",
"filter",
"(",
"(",
"{",
"prop",
",",
"value",
"}",
")",
"=>",
"prop",
".",
"indexOf",
"(",
"'margin'",
")",
"===",
"0",
")",
"let",
"left",
"=",
"0",
"let",
"right",
"=",
"0",
"margins",
".",
"forEach",
"(",
"(",
"{",
"prop",
",",
"value",
"}",
")",
"=>",
"{",
"if",
"(",
"prop",
"===",
"'margin-left'",
")",
"{",
"left",
"=",
"value",
"return",
"}",
"if",
"(",
"prop",
"===",
"'margin-right'",
")",
"{",
"right",
"=",
"value",
"return",
"}",
"if",
"(",
"prop",
"===",
"'margin'",
")",
"{",
"const",
"values",
"=",
"value",
".",
"split",
"(",
"' '",
")",
".",
"map",
"(",
"(",
"i",
")",
"=>",
"i",
".",
"trim",
"(",
")",
")",
"switch",
"(",
"values",
".",
"length",
")",
"{",
"case",
"1",
":",
"right",
"=",
"first",
"(",
"values",
")",
"left",
"=",
"first",
"(",
"values",
")",
"break",
"case",
"2",
":",
"right",
"=",
"last",
"(",
"values",
")",
"left",
"=",
"last",
"(",
"values",
")",
"break",
"case",
"3",
":",
"right",
"=",
"nth",
"(",
"values",
",",
"1",
")",
"left",
"=",
"nth",
"(",
"values",
",",
"1",
")",
"break",
"default",
":",
"right",
"=",
"nth",
"(",
"values",
",",
"1",
")",
"left",
"=",
"nth",
"(",
"values",
",",
"3",
")",
"break",
"}",
"}",
"}",
")",
"return",
"{",
"left",
",",
"right",
"}",
"}"
] |
pulls the left and right margins from the given inline styles
@param {String} style the inline styles
@return {Object} object with left and right margins
|
[
"pulls",
"the",
"left",
"and",
"right",
"margins",
"from",
"the",
"given",
"inline",
"styles"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-inline/src/inlineMargins.js#L27-L78
|
9,691
|
SparkPost/heml
|
packages/heml-elements/src/Typography.js
|
createTextElement
|
function createTextElement (name, element = {}) {
let classToAdd = ''
const Tag = name
if (/^h\d$/i.test(name)) {
classToAdd = 'header'
} else {
classToAdd = 'text'
}
return createElement(name, merge({
attrs: true,
rules: {
[`.${name}.${classToAdd}`]: [ { '@pseudo': 'root' }, '@default', { display: transforms.trueHide() }, margin, background, border, borderRadius, text, font ]
},
render (attrs, contents) {
attrs.class += ` ${classToAdd} ${name}`
return <Tag {...attrs}>{contents}</Tag>
}
}, element))
}
|
javascript
|
function createTextElement (name, element = {}) {
let classToAdd = ''
const Tag = name
if (/^h\d$/i.test(name)) {
classToAdd = 'header'
} else {
classToAdd = 'text'
}
return createElement(name, merge({
attrs: true,
rules: {
[`.${name}.${classToAdd}`]: [ { '@pseudo': 'root' }, '@default', { display: transforms.trueHide() }, margin, background, border, borderRadius, text, font ]
},
render (attrs, contents) {
attrs.class += ` ${classToAdd} ${name}`
return <Tag {...attrs}>{contents}</Tag>
}
}, element))
}
|
[
"function",
"createTextElement",
"(",
"name",
",",
"element",
"=",
"{",
"}",
")",
"{",
"let",
"classToAdd",
"=",
"''",
"const",
"Tag",
"=",
"name",
"if",
"(",
"/",
"^h\\d$",
"/",
"i",
".",
"test",
"(",
"name",
")",
")",
"{",
"classToAdd",
"=",
"'header'",
"}",
"else",
"{",
"classToAdd",
"=",
"'text'",
"}",
"return",
"createElement",
"(",
"name",
",",
"merge",
"(",
"{",
"attrs",
":",
"true",
",",
"rules",
":",
"{",
"[",
"`",
"${",
"name",
"}",
"${",
"classToAdd",
"}",
"`",
"]",
":",
"[",
"{",
"'@pseudo'",
":",
"'root'",
"}",
",",
"'@default'",
",",
"{",
"display",
":",
"transforms",
".",
"trueHide",
"(",
")",
"}",
",",
"margin",
",",
"background",
",",
"border",
",",
"borderRadius",
",",
"text",
",",
"font",
"]",
"}",
",",
"render",
"(",
"attrs",
",",
"contents",
")",
"{",
"attrs",
".",
"class",
"+=",
"`",
"${",
"classToAdd",
"}",
"${",
"name",
"}",
"`",
"return",
"<",
"Tag",
"{",
"...",
"attrs",
"}",
">",
"{",
"contents",
"}",
"<",
"/",
"Tag",
">",
"}",
"}",
",",
"element",
")",
")",
"}"
] |
create mergable text element
@param {String} name
@param {Object} element
@return {Object}
|
[
"create",
"mergable",
"text",
"element"
] |
9c600cb97b4d5f46a97a0c8af75851c15d5c681c
|
https://github.com/SparkPost/heml/blob/9c600cb97b4d5f46a97a0c8af75851c15d5c681c/packages/heml-elements/src/Typography.js#L14-L35
|
9,692
|
mhart/kinesalite
|
db/index.js
|
sumShards
|
function sumShards(store, cb) {
exports.lazy(store.metaDb.createValueStream(), cb)
.map(function(stream) {
return stream.Shards.filter(function(shard) {
return shard.SequenceNumberRange.EndingSequenceNumber == null
}).length
})
.sum(function(sum) { return cb(null, sum) })
}
|
javascript
|
function sumShards(store, cb) {
exports.lazy(store.metaDb.createValueStream(), cb)
.map(function(stream) {
return stream.Shards.filter(function(shard) {
return shard.SequenceNumberRange.EndingSequenceNumber == null
}).length
})
.sum(function(sum) { return cb(null, sum) })
}
|
[
"function",
"sumShards",
"(",
"store",
",",
"cb",
")",
"{",
"exports",
".",
"lazy",
"(",
"store",
".",
"metaDb",
".",
"createValueStream",
"(",
")",
",",
"cb",
")",
".",
"map",
"(",
"function",
"(",
"stream",
")",
"{",
"return",
"stream",
".",
"Shards",
".",
"filter",
"(",
"function",
"(",
"shard",
")",
"{",
"return",
"shard",
".",
"SequenceNumberRange",
".",
"EndingSequenceNumber",
"==",
"null",
"}",
")",
".",
"length",
"}",
")",
".",
"sum",
"(",
"function",
"(",
"sum",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"sum",
")",
"}",
")",
"}"
] |
Sum shards that haven't closed yet
|
[
"Sum",
"shards",
"that",
"haven",
"t",
"closed",
"yet"
] |
d2cea0a7890c305d4bdf312ce5c67c24c84d0c03
|
https://github.com/mhart/kinesalite/blob/d2cea0a7890c305d4bdf312ce5c67c24c84d0c03/db/index.js#L266-L274
|
9,693
|
hemerajs/hemera
|
packages/hemera/lib/extensions.js
|
onActFinished
|
function onActFinished(context, next) {
const msg = context.response.payload
// pass to act context
if (msg) {
context.request$ = msg.request || {}
context.trace$ = msg.trace || {}
context.meta$ = msg.meta || {}
}
// calculate request duration
const now = Util.nowHrTime()
const diff = now - context.trace$.timestamp
context.trace$.duration = diff
if (context._config.traceLog) {
context.log = context.log.child({
tag: context._config.tag,
requestId: context.request$.id,
parentSpanId: context.trace$.parentSpanId,
traceId: context.trace$.traceId,
spanId: context.trace$.spanId
})
context.log.info(
{
pattern: context.trace$.method,
responseTime: context.trace$.duration
},
'Request completed'
)
} else {
context.log.info(
{
requestId: context.request$.id,
pattern: context.trace$.method,
responseTime: context.trace$.duration
},
'Request completed'
)
}
next()
}
|
javascript
|
function onActFinished(context, next) {
const msg = context.response.payload
// pass to act context
if (msg) {
context.request$ = msg.request || {}
context.trace$ = msg.trace || {}
context.meta$ = msg.meta || {}
}
// calculate request duration
const now = Util.nowHrTime()
const diff = now - context.trace$.timestamp
context.trace$.duration = diff
if (context._config.traceLog) {
context.log = context.log.child({
tag: context._config.tag,
requestId: context.request$.id,
parentSpanId: context.trace$.parentSpanId,
traceId: context.trace$.traceId,
spanId: context.trace$.spanId
})
context.log.info(
{
pattern: context.trace$.method,
responseTime: context.trace$.duration
},
'Request completed'
)
} else {
context.log.info(
{
requestId: context.request$.id,
pattern: context.trace$.method,
responseTime: context.trace$.duration
},
'Request completed'
)
}
next()
}
|
[
"function",
"onActFinished",
"(",
"context",
",",
"next",
")",
"{",
"const",
"msg",
"=",
"context",
".",
"response",
".",
"payload",
"// pass to act context",
"if",
"(",
"msg",
")",
"{",
"context",
".",
"request$",
"=",
"msg",
".",
"request",
"||",
"{",
"}",
"context",
".",
"trace$",
"=",
"msg",
".",
"trace",
"||",
"{",
"}",
"context",
".",
"meta$",
"=",
"msg",
".",
"meta",
"||",
"{",
"}",
"}",
"// calculate request duration",
"const",
"now",
"=",
"Util",
".",
"nowHrTime",
"(",
")",
"const",
"diff",
"=",
"now",
"-",
"context",
".",
"trace$",
".",
"timestamp",
"context",
".",
"trace$",
".",
"duration",
"=",
"diff",
"if",
"(",
"context",
".",
"_config",
".",
"traceLog",
")",
"{",
"context",
".",
"log",
"=",
"context",
".",
"log",
".",
"child",
"(",
"{",
"tag",
":",
"context",
".",
"_config",
".",
"tag",
",",
"requestId",
":",
"context",
".",
"request$",
".",
"id",
",",
"parentSpanId",
":",
"context",
".",
"trace$",
".",
"parentSpanId",
",",
"traceId",
":",
"context",
".",
"trace$",
".",
"traceId",
",",
"spanId",
":",
"context",
".",
"trace$",
".",
"spanId",
"}",
")",
"context",
".",
"log",
".",
"info",
"(",
"{",
"pattern",
":",
"context",
".",
"trace$",
".",
"method",
",",
"responseTime",
":",
"context",
".",
"trace$",
".",
"duration",
"}",
",",
"'Request completed'",
")",
"}",
"else",
"{",
"context",
".",
"log",
".",
"info",
"(",
"{",
"requestId",
":",
"context",
".",
"request$",
".",
"id",
",",
"pattern",
":",
"context",
".",
"trace$",
".",
"method",
",",
"responseTime",
":",
"context",
".",
"trace$",
".",
"duration",
"}",
",",
"'Request completed'",
")",
"}",
"next",
"(",
")",
"}"
] |
- Restore context
- Measure request duration
@param {*} context
@param {*} next
|
[
"-",
"Restore",
"context",
"-",
"Measure",
"request",
"duration"
] |
f429eead7a3e479a55008ee1d35e8f92d55f213e
|
https://github.com/hemerajs/hemera/blob/f429eead7a3e479a55008ee1d35e8f92d55f213e/packages/hemera/lib/extensions.js#L133-L175
|
9,694
|
qlik-oss/enigma.js
|
examples/basics/parameters/parameter-passing.js
|
print
|
function print(tableContent) {
for (let i = 0; i < tableContent.length; i += 1) {
console.log(`dim: ${tableContent[i].qValue[0].qText} val: ${tableContent[i].qValue[1].qText}`);
}
}
|
javascript
|
function print(tableContent) {
for (let i = 0; i < tableContent.length; i += 1) {
console.log(`dim: ${tableContent[i].qValue[0].qText} val: ${tableContent[i].qValue[1].qText}`);
}
}
|
[
"function",
"print",
"(",
"tableContent",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"tableContent",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"tableContent",
"[",
"i",
"]",
".",
"qValue",
"[",
"0",
"]",
".",
"qText",
"}",
"${",
"tableContent",
"[",
"i",
"]",
".",
"qValue",
"[",
"1",
"]",
".",
"qText",
"}",
"`",
")",
";",
"}",
"}"
] |
Write the tabelContent to console.
@param {*} tabelContent
|
[
"Write",
"the",
"tabelContent",
"to",
"console",
"."
] |
d47661846ba23b7705a54ae1d663b6a71d772b19
|
https://github.com/qlik-oss/enigma.js/blob/d47661846ba23b7705a54ae1d663b6a71d772b19/examples/basics/parameters/parameter-passing.js#L21-L25
|
9,695
|
qlik-oss/enigma.js
|
src/json-patch.js
|
emptyObject
|
function emptyObject(obj) {
Object.keys(obj).forEach((key) => {
const config = Object.getOwnPropertyDescriptor(obj, key);
if (config.configurable && !isSpecialProperty(obj, key)) {
delete obj[key];
}
});
}
|
javascript
|
function emptyObject(obj) {
Object.keys(obj).forEach((key) => {
const config = Object.getOwnPropertyDescriptor(obj, key);
if (config.configurable && !isSpecialProperty(obj, key)) {
delete obj[key];
}
});
}
|
[
"function",
"emptyObject",
"(",
"obj",
")",
"{",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"const",
"config",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"obj",
",",
"key",
")",
";",
"if",
"(",
"config",
".",
"configurable",
"&&",
"!",
"isSpecialProperty",
"(",
"obj",
",",
"key",
")",
")",
"{",
"delete",
"obj",
"[",
"key",
"]",
";",
"}",
"}",
")",
";",
"}"
] |
Cleans an object of all its properties, unless they're deemed special or
cannot be removed by configuration.
@private
@param {Object} obj The object to clean
|
[
"Cleans",
"an",
"object",
"of",
"all",
"its",
"properties",
"unless",
"they",
"re",
"deemed",
"special",
"or",
"cannot",
"be",
"removed",
"by",
"configuration",
"."
] |
d47661846ba23b7705a54ae1d663b6a71d772b19
|
https://github.com/qlik-oss/enigma.js/blob/d47661846ba23b7705a54ae1d663b6a71d772b19/src/json-patch.js#L75-L83
|
9,696
|
qlik-oss/enigma.js
|
src/json-patch.js
|
compare
|
function compare(a, b) {
let isIdentical = true;
if (isObject(a) && isObject(b)) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
Object.keys(a).forEach((key) => {
if (!compare(a[key], b[key])) {
isIdentical = false;
}
});
return isIdentical;
} if (isArray(a) && isArray(b)) {
if (a.length !== b.length) {
return false;
}
for (let i = 0, l = a.length; i < l; i += 1) {
if (!compare(a[i], b[i])) {
return false;
}
}
return true;
}
return a === b;
}
|
javascript
|
function compare(a, b) {
let isIdentical = true;
if (isObject(a) && isObject(b)) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
Object.keys(a).forEach((key) => {
if (!compare(a[key], b[key])) {
isIdentical = false;
}
});
return isIdentical;
} if (isArray(a) && isArray(b)) {
if (a.length !== b.length) {
return false;
}
for (let i = 0, l = a.length; i < l; i += 1) {
if (!compare(a[i], b[i])) {
return false;
}
}
return true;
}
return a === b;
}
|
[
"function",
"compare",
"(",
"a",
",",
"b",
")",
"{",
"let",
"isIdentical",
"=",
"true",
";",
"if",
"(",
"isObject",
"(",
"a",
")",
"&&",
"isObject",
"(",
"b",
")",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"a",
")",
".",
"length",
"!==",
"Object",
".",
"keys",
"(",
"b",
")",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"Object",
".",
"keys",
"(",
"a",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"if",
"(",
"!",
"compare",
"(",
"a",
"[",
"key",
"]",
",",
"b",
"[",
"key",
"]",
")",
")",
"{",
"isIdentical",
"=",
"false",
";",
"}",
"}",
")",
";",
"return",
"isIdentical",
";",
"}",
"if",
"(",
"isArray",
"(",
"a",
")",
"&&",
"isArray",
"(",
"b",
")",
")",
"{",
"if",
"(",
"a",
".",
"length",
"!==",
"b",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"!",
"compare",
"(",
"a",
"[",
"i",
"]",
",",
"b",
"[",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"a",
"===",
"b",
";",
"}"
] |
Compare an object with another, could be object, array, number, string, bool.
@private
@param {Object} a The first object to compare
@param {Object} a The second object to compare
@returns {Boolean} Whether the objects are identical
|
[
"Compare",
"an",
"object",
"with",
"another",
"could",
"be",
"object",
"array",
"number",
"string",
"bool",
"."
] |
d47661846ba23b7705a54ae1d663b6a71d772b19
|
https://github.com/qlik-oss/enigma.js/blob/d47661846ba23b7705a54ae1d663b6a71d772b19/src/json-patch.js#L92-L117
|
9,697
|
qlik-oss/enigma.js
|
src/json-patch.js
|
patchArray
|
function patchArray(original, newA, basePath) {
let patches = [];
const oldA = original.slice();
let tmpIdx = -1;
function findIndex(a, id, idx) {
if (a[idx] && isUndef(a[idx].qInfo)) {
return null;
} if (a[idx] && a[idx].qInfo.qId === id) {
// shortcut if identical
return idx;
}
for (let ii = 0, ll = a.length; ii < ll; ii += 1) {
if (a[ii] && a[ii].qInfo.qId === id) {
return ii;
}
}
return -1;
}
if (compare(newA, oldA)) {
// array is unchanged
return patches;
}
if (!isUndef(newA[0]) && isUndef(newA[0].qInfo)) {
// we cannot create patches without unique identifiers, replace array...
patches.push({
op: 'replace',
path: basePath,
value: newA,
});
return patches;
}
for (let i = oldA.length - 1; i >= 0; i -= 1) {
tmpIdx = findIndex(newA, oldA[i].qInfo && oldA[i].qInfo.qId, i);
if (tmpIdx === -1) {
patches.push({
op: 'remove',
path: `${basePath}/${i}`,
});
oldA.splice(i, 1);
} else {
patches = patches.concat(JSONPatch.generate(oldA[i], newA[tmpIdx], `${basePath}/${i}`));
}
}
for (let i = 0, l = newA.length; i < l; i += 1) {
tmpIdx = findIndex(oldA, newA[i].qInfo && newA[i].qInfo.qId);
if (tmpIdx === -1) {
patches.push({
op: 'add',
path: `${basePath}/${i}`,
value: newA[i],
});
oldA.splice(i, 0, newA[i]);
} else if (tmpIdx !== i) {
patches.push({
op: 'move',
path: `${basePath}/${i}`,
from: `${basePath}/${tmpIdx}`,
});
oldA.splice(i, 0, oldA.splice(tmpIdx, 1)[0]);
}
}
return patches;
}
|
javascript
|
function patchArray(original, newA, basePath) {
let patches = [];
const oldA = original.slice();
let tmpIdx = -1;
function findIndex(a, id, idx) {
if (a[idx] && isUndef(a[idx].qInfo)) {
return null;
} if (a[idx] && a[idx].qInfo.qId === id) {
// shortcut if identical
return idx;
}
for (let ii = 0, ll = a.length; ii < ll; ii += 1) {
if (a[ii] && a[ii].qInfo.qId === id) {
return ii;
}
}
return -1;
}
if (compare(newA, oldA)) {
// array is unchanged
return patches;
}
if (!isUndef(newA[0]) && isUndef(newA[0].qInfo)) {
// we cannot create patches without unique identifiers, replace array...
patches.push({
op: 'replace',
path: basePath,
value: newA,
});
return patches;
}
for (let i = oldA.length - 1; i >= 0; i -= 1) {
tmpIdx = findIndex(newA, oldA[i].qInfo && oldA[i].qInfo.qId, i);
if (tmpIdx === -1) {
patches.push({
op: 'remove',
path: `${basePath}/${i}`,
});
oldA.splice(i, 1);
} else {
patches = patches.concat(JSONPatch.generate(oldA[i], newA[tmpIdx], `${basePath}/${i}`));
}
}
for (let i = 0, l = newA.length; i < l; i += 1) {
tmpIdx = findIndex(oldA, newA[i].qInfo && newA[i].qInfo.qId);
if (tmpIdx === -1) {
patches.push({
op: 'add',
path: `${basePath}/${i}`,
value: newA[i],
});
oldA.splice(i, 0, newA[i]);
} else if (tmpIdx !== i) {
patches.push({
op: 'move',
path: `${basePath}/${i}`,
from: `${basePath}/${tmpIdx}`,
});
oldA.splice(i, 0, oldA.splice(tmpIdx, 1)[0]);
}
}
return patches;
}
|
[
"function",
"patchArray",
"(",
"original",
",",
"newA",
",",
"basePath",
")",
"{",
"let",
"patches",
"=",
"[",
"]",
";",
"const",
"oldA",
"=",
"original",
".",
"slice",
"(",
")",
";",
"let",
"tmpIdx",
"=",
"-",
"1",
";",
"function",
"findIndex",
"(",
"a",
",",
"id",
",",
"idx",
")",
"{",
"if",
"(",
"a",
"[",
"idx",
"]",
"&&",
"isUndef",
"(",
"a",
"[",
"idx",
"]",
".",
"qInfo",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"a",
"[",
"idx",
"]",
"&&",
"a",
"[",
"idx",
"]",
".",
"qInfo",
".",
"qId",
"===",
"id",
")",
"{",
"// shortcut if identical",
"return",
"idx",
";",
"}",
"for",
"(",
"let",
"ii",
"=",
"0",
",",
"ll",
"=",
"a",
".",
"length",
";",
"ii",
"<",
"ll",
";",
"ii",
"+=",
"1",
")",
"{",
"if",
"(",
"a",
"[",
"ii",
"]",
"&&",
"a",
"[",
"ii",
"]",
".",
"qInfo",
".",
"qId",
"===",
"id",
")",
"{",
"return",
"ii",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"compare",
"(",
"newA",
",",
"oldA",
")",
")",
"{",
"// array is unchanged",
"return",
"patches",
";",
"}",
"if",
"(",
"!",
"isUndef",
"(",
"newA",
"[",
"0",
"]",
")",
"&&",
"isUndef",
"(",
"newA",
"[",
"0",
"]",
".",
"qInfo",
")",
")",
"{",
"// we cannot create patches without unique identifiers, replace array...",
"patches",
".",
"push",
"(",
"{",
"op",
":",
"'replace'",
",",
"path",
":",
"basePath",
",",
"value",
":",
"newA",
",",
"}",
")",
";",
"return",
"patches",
";",
"}",
"for",
"(",
"let",
"i",
"=",
"oldA",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"-=",
"1",
")",
"{",
"tmpIdx",
"=",
"findIndex",
"(",
"newA",
",",
"oldA",
"[",
"i",
"]",
".",
"qInfo",
"&&",
"oldA",
"[",
"i",
"]",
".",
"qInfo",
".",
"qId",
",",
"i",
")",
";",
"if",
"(",
"tmpIdx",
"===",
"-",
"1",
")",
"{",
"patches",
".",
"push",
"(",
"{",
"op",
":",
"'remove'",
",",
"path",
":",
"`",
"${",
"basePath",
"}",
"${",
"i",
"}",
"`",
",",
"}",
")",
";",
"oldA",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"else",
"{",
"patches",
"=",
"patches",
".",
"concat",
"(",
"JSONPatch",
".",
"generate",
"(",
"oldA",
"[",
"i",
"]",
",",
"newA",
"[",
"tmpIdx",
"]",
",",
"`",
"${",
"basePath",
"}",
"${",
"i",
"}",
"`",
")",
")",
";",
"}",
"}",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"newA",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"+=",
"1",
")",
"{",
"tmpIdx",
"=",
"findIndex",
"(",
"oldA",
",",
"newA",
"[",
"i",
"]",
".",
"qInfo",
"&&",
"newA",
"[",
"i",
"]",
".",
"qInfo",
".",
"qId",
")",
";",
"if",
"(",
"tmpIdx",
"===",
"-",
"1",
")",
"{",
"patches",
".",
"push",
"(",
"{",
"op",
":",
"'add'",
",",
"path",
":",
"`",
"${",
"basePath",
"}",
"${",
"i",
"}",
"`",
",",
"value",
":",
"newA",
"[",
"i",
"]",
",",
"}",
")",
";",
"oldA",
".",
"splice",
"(",
"i",
",",
"0",
",",
"newA",
"[",
"i",
"]",
")",
";",
"}",
"else",
"if",
"(",
"tmpIdx",
"!==",
"i",
")",
"{",
"patches",
".",
"push",
"(",
"{",
"op",
":",
"'move'",
",",
"path",
":",
"`",
"${",
"basePath",
"}",
"${",
"i",
"}",
"`",
",",
"from",
":",
"`",
"${",
"basePath",
"}",
"${",
"tmpIdx",
"}",
"`",
",",
"}",
")",
";",
"oldA",
".",
"splice",
"(",
"i",
",",
"0",
",",
"oldA",
".",
"splice",
"(",
"tmpIdx",
",",
"1",
")",
"[",
"0",
"]",
")",
";",
"}",
"}",
"return",
"patches",
";",
"}"
] |
Generates patches by comparing two arrays.
@private
@param {Array} oldA The old (original) array, which will be patched
@param {Array} newA The new array, which will be used to compare against
@returns {Array} An array of patches (if any)
|
[
"Generates",
"patches",
"by",
"comparing",
"two",
"arrays",
"."
] |
d47661846ba23b7705a54ae1d663b6a71d772b19
|
https://github.com/qlik-oss/enigma.js/blob/d47661846ba23b7705a54ae1d663b6a71d772b19/src/json-patch.js#L127-L194
|
9,698
|
ethjs/ethjs
|
src/index.js
|
Eth
|
function Eth(cprovider, options) {
if (!(this instanceof Eth)) { throw new Error('[ethjs] the Eth object requires you construct it with the "new" flag (i.e. `const eth = new Eth(...);`).'); }
const self = this;
self.options = options || {};
const query = new EthQuery(cprovider, self.options.query);
Object.keys(Object.getPrototypeOf(query)).forEach((methodName) => {
self[methodName] = (...args) => query[methodName].apply(query, args);
});
self.filter = new EthFilter(query, self.options.query);
self.contract = new EthContract(query, self.options.query);
self.currentProvider = query.rpc.currentProvider;
self.setProvider = query.setProvider;
self.getTransactionSuccess = getTransactionSuccess(self);
}
|
javascript
|
function Eth(cprovider, options) {
if (!(this instanceof Eth)) { throw new Error('[ethjs] the Eth object requires you construct it with the "new" flag (i.e. `const eth = new Eth(...);`).'); }
const self = this;
self.options = options || {};
const query = new EthQuery(cprovider, self.options.query);
Object.keys(Object.getPrototypeOf(query)).forEach((methodName) => {
self[methodName] = (...args) => query[methodName].apply(query, args);
});
self.filter = new EthFilter(query, self.options.query);
self.contract = new EthContract(query, self.options.query);
self.currentProvider = query.rpc.currentProvider;
self.setProvider = query.setProvider;
self.getTransactionSuccess = getTransactionSuccess(self);
}
|
[
"function",
"Eth",
"(",
"cprovider",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Eth",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[ethjs] the Eth object requires you construct it with the \"new\" flag (i.e. `const eth = new Eth(...);`).'",
")",
";",
"}",
"const",
"self",
"=",
"this",
";",
"self",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"const",
"query",
"=",
"new",
"EthQuery",
"(",
"cprovider",
",",
"self",
".",
"options",
".",
"query",
")",
";",
"Object",
".",
"keys",
"(",
"Object",
".",
"getPrototypeOf",
"(",
"query",
")",
")",
".",
"forEach",
"(",
"(",
"methodName",
")",
"=>",
"{",
"self",
"[",
"methodName",
"]",
"=",
"(",
"...",
"args",
")",
"=>",
"query",
"[",
"methodName",
"]",
".",
"apply",
"(",
"query",
",",
"args",
")",
";",
"}",
")",
";",
"self",
".",
"filter",
"=",
"new",
"EthFilter",
"(",
"query",
",",
"self",
".",
"options",
".",
"query",
")",
";",
"self",
".",
"contract",
"=",
"new",
"EthContract",
"(",
"query",
",",
"self",
".",
"options",
".",
"query",
")",
";",
"self",
".",
"currentProvider",
"=",
"query",
".",
"rpc",
".",
"currentProvider",
";",
"self",
".",
"setProvider",
"=",
"query",
".",
"setProvider",
";",
"self",
".",
"getTransactionSuccess",
"=",
"getTransactionSuccess",
"(",
"self",
")",
";",
"}"
] |
Returns the ethjs Eth instance.
@method Eth
@param {Object} cprovider the web3 standard provider object
@param {Object} options the Eth options object
@returns {Object} eth Eth object instance
@throws if the new flag is not used in construction
|
[
"Returns",
"the",
"ethjs",
"Eth",
"instance",
"."
] |
68229b93e72bfba0c9a37ea1d979347e8f7395e4
|
https://github.com/ethjs/ethjs/blob/68229b93e72bfba0c9a37ea1d979347e8f7395e4/src/index.js#L26-L39
|
9,699
|
SAP/ui5-builder
|
lib/processors/jsdoc/jsdocGenerator.js
|
generateJsdocConfig
|
async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName, version, variants}) {
// Backlash needs to be escaped as double-backslash
// This is not only relevant for win32 paths but also for
// Unix directory names that contain a backslash in their name
const backslashRegex = /\\/g;
// Resolve path to this script to get the path to the JSDoc extensions folder
const jsdocPath = path.normalize(__dirname);
const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.js").replace(backslashRegex, "\\\\");
const templatePath = path.join(jsdocPath, "lib", "ui5", "template").replace(backslashRegex, "\\\\");
const destinationPath = path.normalize(tmpPath).replace(backslashRegex, "\\\\");
const jsapiFilePath = path.join(targetPath, "libraries", projectName + ".js").replace(backslashRegex, "\\\\");
const apiJsonFolderPath = path.join(tmpPath, "dependency-apis").replace(backslashRegex, "\\\\");
const apiJsonFilePath =
path.join(targetPath, "test-resources", path.normalize(namespace), "designtime", "api.json")
.replace(backslashRegex, "\\\\");
const config = `{
"plugins": ["${pluginPath}"],
"opts": {
"recurse": true,
"lenient": true,
"template": "${templatePath}",
"ui5": {
"saveSymbols": true
},
"destination": "${destinationPath}"
},
"templates": {
"ui5": {
"variants": ${JSON.stringify(variants)},
"version": "${version}",
"jsapiFile": "${jsapiFilePath}",
"apiJsonFolder": "${apiJsonFolderPath}",
"apiJsonFile": "${apiJsonFilePath}"
}
}
}`;
return config;
}
|
javascript
|
async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName, version, variants}) {
// Backlash needs to be escaped as double-backslash
// This is not only relevant for win32 paths but also for
// Unix directory names that contain a backslash in their name
const backslashRegex = /\\/g;
// Resolve path to this script to get the path to the JSDoc extensions folder
const jsdocPath = path.normalize(__dirname);
const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.js").replace(backslashRegex, "\\\\");
const templatePath = path.join(jsdocPath, "lib", "ui5", "template").replace(backslashRegex, "\\\\");
const destinationPath = path.normalize(tmpPath).replace(backslashRegex, "\\\\");
const jsapiFilePath = path.join(targetPath, "libraries", projectName + ".js").replace(backslashRegex, "\\\\");
const apiJsonFolderPath = path.join(tmpPath, "dependency-apis").replace(backslashRegex, "\\\\");
const apiJsonFilePath =
path.join(targetPath, "test-resources", path.normalize(namespace), "designtime", "api.json")
.replace(backslashRegex, "\\\\");
const config = `{
"plugins": ["${pluginPath}"],
"opts": {
"recurse": true,
"lenient": true,
"template": "${templatePath}",
"ui5": {
"saveSymbols": true
},
"destination": "${destinationPath}"
},
"templates": {
"ui5": {
"variants": ${JSON.stringify(variants)},
"version": "${version}",
"jsapiFile": "${jsapiFilePath}",
"apiJsonFolder": "${apiJsonFolderPath}",
"apiJsonFile": "${apiJsonFilePath}"
}
}
}`;
return config;
}
|
[
"async",
"function",
"generateJsdocConfig",
"(",
"{",
"targetPath",
",",
"tmpPath",
",",
"namespace",
",",
"projectName",
",",
"version",
",",
"variants",
"}",
")",
"{",
"// Backlash needs to be escaped as double-backslash",
"// This is not only relevant for win32 paths but also for",
"//\tUnix directory names that contain a backslash in their name",
"const",
"backslashRegex",
"=",
"/",
"\\\\",
"/",
"g",
";",
"// Resolve path to this script to get the path to the JSDoc extensions folder",
"const",
"jsdocPath",
"=",
"path",
".",
"normalize",
"(",
"__dirname",
")",
";",
"const",
"pluginPath",
"=",
"path",
".",
"join",
"(",
"jsdocPath",
",",
"\"lib\"",
",",
"\"ui5\"",
",",
"\"plugin.js\"",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"templatePath",
"=",
"path",
".",
"join",
"(",
"jsdocPath",
",",
"\"lib\"",
",",
"\"ui5\"",
",",
"\"template\"",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"destinationPath",
"=",
"path",
".",
"normalize",
"(",
"tmpPath",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"jsapiFilePath",
"=",
"path",
".",
"join",
"(",
"targetPath",
",",
"\"libraries\"",
",",
"projectName",
"+",
"\".js\"",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"apiJsonFolderPath",
"=",
"path",
".",
"join",
"(",
"tmpPath",
",",
"\"dependency-apis\"",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"apiJsonFilePath",
"=",
"path",
".",
"join",
"(",
"targetPath",
",",
"\"test-resources\"",
",",
"path",
".",
"normalize",
"(",
"namespace",
")",
",",
"\"designtime\"",
",",
"\"api.json\"",
")",
".",
"replace",
"(",
"backslashRegex",
",",
"\"\\\\\\\\\"",
")",
";",
"const",
"config",
"=",
"`",
"${",
"pluginPath",
"}",
"${",
"templatePath",
"}",
"${",
"destinationPath",
"}",
"${",
"JSON",
".",
"stringify",
"(",
"variants",
")",
"}",
"${",
"version",
"}",
"${",
"jsapiFilePath",
"}",
"${",
"apiJsonFolderPath",
"}",
"${",
"apiJsonFilePath",
"}",
"`",
";",
"return",
"config",
";",
"}"
] |
Generate jsdoc-config.json content
@private
@param {Object} parameters Parameters
@param {string} parameters.targetPath Path to write any output files
@param {string} parameters.tmpPath Path to write temporary and debug files
@param {string} parameters.projectName Project name
@param {string} parameters.version Project version
@param {Array} parameters.variants JSDoc variants to be built
@returns {string} jsdoc-config.json content string
|
[
"Generate",
"jsdoc",
"-",
"config",
".",
"json",
"content"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/processors/jsdoc/jsdocGenerator.js#L74-L113
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.