repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
marmelab/gremlins.js | src/species/toucher.js | doubletap | function doubletap(position, element, done) {
touchTypes.tap(position, element, function() {
setTimeout(function() {
touchTypes.tap(position, element, done);
}, 30);
});
} | javascript | function doubletap(position, element, done) {
touchTypes.tap(position, element, function() {
setTimeout(function() {
touchTypes.tap(position, element, done);
}, 30);
});
} | [
"function",
"doubletap",
"(",
"position",
",",
"element",
",",
"done",
")",
"{",
"touchTypes",
".",
"tap",
"(",
"position",
",",
"element",
",",
"function",
"(",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"touchTypes",
".",
"tap",
"(",
"po... | doubletap, like a dblclick event, only 1 touch could also be a slow doubletap, that could turn out to be a hold | [
"doubletap",
"like",
"a",
"dblclick",
"event",
"only",
"1",
"touch",
"could",
"also",
"be",
"a",
"slow",
"doubletap",
"that",
"could",
"turn",
"out",
"to",
"be",
"a",
"hold"
] | 2735fa5253cbefcb8848ea40825a6426fc04c398 | https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/species/toucher.js#L243-L249 | train |
marmelab/gremlins.js | src/species/toucher.js | gesture | function gesture(position, element, done) {
var gesture = {
distanceX: config.randomizer.integer({ min: -100, max: 200 }),
distanceY: config.randomizer.integer({ min: -100, max: 200 }),
duration: config.randomizer.integer({ min: 20, max: 500 }... | javascript | function gesture(position, element, done) {
var gesture = {
distanceX: config.randomizer.integer({ min: -100, max: 200 }),
distanceY: config.randomizer.integer({ min: -100, max: 200 }),
duration: config.randomizer.integer({ min: 20, max: 500 }... | [
"function",
"gesture",
"(",
"position",
",",
"element",
",",
"done",
")",
"{",
"var",
"gesture",
"=",
"{",
"distanceX",
":",
"config",
".",
"randomizer",
".",
"integer",
"(",
"{",
"min",
":",
"-",
"100",
",",
"max",
":",
"200",
"}",
")",
",",
"dist... | single touch gesture, could be a drag and swipe, with 1 points | [
"single",
"touch",
"gesture",
"could",
"be",
"a",
"drag",
"and",
"swipe",
"with",
"1",
"points"
] | 2735fa5253cbefcb8848ea40825a6426fc04c398 | https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/species/toucher.js#L252-L263 | train |
marmelab/gremlins.js | src/species/toucher.js | multitouch | function multitouch(position, element, done) {
var points = config.randomizer.integer({ min: 2, max: config.maxTouches});
var gesture = {
scale: config.randomizer.floating({ min: 0, max: 2 }),
rotation: config.randomizer.natural({ min: -100, m... | javascript | function multitouch(position, element, done) {
var points = config.randomizer.integer({ min: 2, max: config.maxTouches});
var gesture = {
scale: config.randomizer.floating({ min: 0, max: 2 }),
rotation: config.randomizer.natural({ min: -100, m... | [
"function",
"multitouch",
"(",
"position",
",",
"element",
",",
"done",
")",
"{",
"var",
"points",
"=",
"config",
".",
"randomizer",
".",
"integer",
"(",
"{",
"min",
":",
"2",
",",
"max",
":",
"config",
".",
"maxTouches",
"}",
")",
";",
"var",
"gestu... | multitouch gesture, could be a drag, swipe, pinch and rotate, with 2 or more points | [
"multitouch",
"gesture",
"could",
"be",
"a",
"drag",
"swipe",
"pinch",
"and",
"rotate",
"with",
"2",
"or",
"more",
"points"
] | 2735fa5253cbefcb8848ea40825a6426fc04c398 | https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/species/toucher.js#L266-L281 | train |
hoodiehq/hoodie | cli/parse-options.js | parseOptions | function parseOptions (options) {
var dbOptions = {}
var config = {
name: options.name,
loglevel: options.loglevel,
paths: {
data: options.data,
public: options.public
},
plugins: options.plugins,
app: options.app,
inMemory: Boolean(options.inMemory),
client: options.cli... | javascript | function parseOptions (options) {
var dbOptions = {}
var config = {
name: options.name,
loglevel: options.loglevel,
paths: {
data: options.data,
public: options.public
},
plugins: options.plugins,
app: options.app,
inMemory: Boolean(options.inMemory),
client: options.cli... | [
"function",
"parseOptions",
"(",
"options",
")",
"{",
"var",
"dbOptions",
"=",
"{",
"}",
"var",
"config",
"=",
"{",
"name",
":",
"options",
".",
"name",
",",
"loglevel",
":",
"options",
".",
"loglevel",
",",
"paths",
":",
"{",
"data",
":",
"options",
... | Parse options into internal config structure.
Options are all the things that users can pass in to Hoodie as described at
https://github.com/hoodiehq/hoodie#usage. All these options are flat, while
internally we group theem into db, connection and path options.
`appOptions` are app-specific default options configured... | [
"Parse",
"options",
"into",
"internal",
"config",
"structure",
"."
] | f1c0e2f5c94ec4041bdb078ed5af21e6ad188156 | https://github.com/hoodiehq/hoodie/blob/f1c0e2f5c94ec4041bdb078ed5af21e6ad188156/cli/parse-options.js#L29-L75 | train |
danielcaldas/react-d3-graph | src/components/marker/marker.helper.js | _getMarkerSize | function _getMarkerSize(transform, mMax, lMax) {
if (transform < mMax) {
return SIZES.S;
} else if (transform >= mMax && transform < lMax) {
return SIZES.M;
} else {
return SIZES.L;
}
} | javascript | function _getMarkerSize(transform, mMax, lMax) {
if (transform < mMax) {
return SIZES.S;
} else if (transform >= mMax && transform < lMax) {
return SIZES.M;
} else {
return SIZES.L;
}
} | [
"function",
"_getMarkerSize",
"(",
"transform",
",",
"mMax",
",",
"lMax",
")",
"{",
"if",
"(",
"transform",
"<",
"mMax",
")",
"{",
"return",
"SIZES",
".",
"S",
";",
"}",
"else",
"if",
"(",
"transform",
">=",
"mMax",
"&&",
"transform",
"<",
"lMax",
")... | This functions returns the proper marker size given the inputs that describe the scenario
where the marker is to be applied.
@param {number} transform - the delta zoom value to calculate resize transformations.
@param {number} mMax - a derived value from the max zoom config.
@param {number} lMax - a derived value from ... | [
"This",
"functions",
"returns",
"the",
"proper",
"marker",
"size",
"given",
"the",
"inputs",
"that",
"describe",
"the",
"scenario",
"where",
"the",
"marker",
"is",
"to",
"be",
"applied",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/marker/marker.helper.js#L29-L37 | train |
danielcaldas/react-d3-graph | src/components/marker/marker.helper.js | _computeMarkerId | function _computeMarkerId(highlight, transform, { maxZoom }) {
const mMax = maxZoom / 4;
const lMax = maxZoom / 2;
const size = _getMarkerSize(transform, mMax, lMax);
const highlighted = highlight ? HIGHLIGHTED : "";
const markerKey = _markerKeyBuilder(size, highlighted);
return MARKERS[markerK... | javascript | function _computeMarkerId(highlight, transform, { maxZoom }) {
const mMax = maxZoom / 4;
const lMax = maxZoom / 2;
const size = _getMarkerSize(transform, mMax, lMax);
const highlighted = highlight ? HIGHLIGHTED : "";
const markerKey = _markerKeyBuilder(size, highlighted);
return MARKERS[markerK... | [
"function",
"_computeMarkerId",
"(",
"highlight",
",",
"transform",
",",
"{",
"maxZoom",
"}",
")",
"{",
"const",
"mMax",
"=",
"maxZoom",
"/",
"4",
";",
"const",
"lMax",
"=",
"maxZoom",
"/",
"2",
";",
"const",
"size",
"=",
"_getMarkerSize",
"(",
"transfor... | This function holds logic to retrieve the appropriate marker id that reflects the input
parameters, markers can vary with highlight and transform value.
@param {boolean} highlight - tells us whether or not some element (link or node) is highlighted.
@param {number} transform - the delta zoom value to calculate resize t... | [
"This",
"function",
"holds",
"logic",
"to",
"retrieve",
"the",
"appropriate",
"marker",
"id",
"that",
"reflects",
"the",
"input",
"parameters",
"markers",
"can",
"vary",
"with",
"highlight",
"and",
"transform",
"value",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/marker/marker.helper.js#L48-L56 | train |
danielcaldas/react-d3-graph | src/components/marker/marker.helper.js | _memoizedComputeMarkerId | function _memoizedComputeMarkerId() {
let cache = {};
return (highlight, transform, { maxZoom }) => {
const cacheKey = `${highlight};${transform};${maxZoom}`;
if (cache[cacheKey]) {
return cache[cacheKey];
}
const markerId = _computeMarkerId(highlight, transform, {... | javascript | function _memoizedComputeMarkerId() {
let cache = {};
return (highlight, transform, { maxZoom }) => {
const cacheKey = `${highlight};${transform};${maxZoom}`;
if (cache[cacheKey]) {
return cache[cacheKey];
}
const markerId = _computeMarkerId(highlight, transform, {... | [
"function",
"_memoizedComputeMarkerId",
"(",
")",
"{",
"let",
"cache",
"=",
"{",
"}",
";",
"return",
"(",
"highlight",
",",
"transform",
",",
"{",
"maxZoom",
"}",
")",
"=>",
"{",
"const",
"cacheKey",
"=",
"`",
"${",
"highlight",
"}",
"${",
"transform",
... | This function memoize results for _computeMarkerId
since many of the times user will be playing around with the same zoom
factor, we can take advantage of this and cache the results for a
given combination of highlight state, zoom transform value and maxZoom config.
@returns{Function} memoize wrapper to the _computeMar... | [
"This",
"function",
"memoize",
"results",
"for",
"_computeMarkerId",
"since",
"many",
"of",
"the",
"times",
"user",
"will",
"be",
"playing",
"around",
"with",
"the",
"same",
"zoom",
"factor",
"we",
"can",
"take",
"advantage",
"of",
"this",
"and",
"cache",
"t... | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/marker/marker.helper.js#L66-L82 | train |
danielcaldas/react-d3-graph | src/components/link/link.helper.js | smoothCurveRadius | function smoothCurveRadius(x1, y1, x2, y2) {
const dx = x2 - x1;
const dy = y2 - y1;
return Math.sqrt(dx * dx + dy * dy);
} | javascript | function smoothCurveRadius(x1, y1, x2, y2) {
const dx = x2 - x1;
const dy = y2 - y1;
return Math.sqrt(dx * dx + dy * dy);
} | [
"function",
"smoothCurveRadius",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"{",
"const",
"dx",
"=",
"x2",
"-",
"x1",
";",
"const",
"dy",
"=",
"y2",
"-",
"y1",
";",
"return",
"Math",
".",
"sqrt",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"d... | Computes radius for a smooth curve effect.
@param {number} x1 - x value for point 1
@param {number} y1 - y value for point 1
@param {number} x2 - y value for point 2
@param {number} y2 - y value for point 2
@returns{number} value of radius.
@memberof Link/helper | [
"Computes",
"radius",
"for",
"a",
"smooth",
"curve",
"effect",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/link/link.helper.js#L26-L31 | train |
danielcaldas/react-d3-graph | cypress/page-objects/node.po.js | NodePO | function NodePO(id) {
this.id = id;
this.g = `#${this.id}`;
this.path = `#${this.id} > path`;
this.text = `#${this.id} > text`;
this.image = `#${this.id} > image`;
this.getPath = () => cy.get(this.path);
this.getLabel = () => cy.get(this.text);
this.getColor = () => cy.get(this.path).in... | javascript | function NodePO(id) {
this.id = id;
this.g = `#${this.id}`;
this.path = `#${this.id} > path`;
this.text = `#${this.id} > text`;
this.image = `#${this.id} > image`;
this.getPath = () => cy.get(this.path);
this.getLabel = () => cy.get(this.text);
this.getColor = () => cy.get(this.path).in... | [
"function",
"NodePO",
"(",
"id",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"g",
"=",
"`",
"${",
"this",
".",
"id",
"}",
"`",
";",
"this",
".",
"path",
"=",
"`",
"${",
"this",
".",
"id",
"}",
"`",
";",
"this",
".",
"text",
... | Page Object for interacting with Node component.
@param {string} id the id of the node.
@returns {undefined} | [
"Page",
"Object",
"for",
"interacting",
"with",
"Node",
"component",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/cypress/page-objects/node.po.js#L6-L23 | train |
danielcaldas/react-d3-graph | src/components/node/node.helper.js | buildSvgSymbol | function buildSvgSymbol(size = CONST.DEFAULT_NODE_SIZE, symbolTypeDesc = CONST.SYMBOLS.CIRCLE) {
return d3Symbol()
.size(() => size)
.type(() => _convertTypeToD3Symbol(symbolTypeDesc))();
} | javascript | function buildSvgSymbol(size = CONST.DEFAULT_NODE_SIZE, symbolTypeDesc = CONST.SYMBOLS.CIRCLE) {
return d3Symbol()
.size(() => size)
.type(() => _convertTypeToD3Symbol(symbolTypeDesc))();
} | [
"function",
"buildSvgSymbol",
"(",
"size",
"=",
"CONST",
".",
"DEFAULT_NODE_SIZE",
",",
"symbolTypeDesc",
"=",
"CONST",
".",
"SYMBOLS",
".",
"CIRCLE",
")",
"{",
"return",
"d3Symbol",
"(",
")",
".",
"size",
"(",
"(",
")",
"=>",
"size",
")",
".",
"type",
... | Build a d3 svg symbol based on passed symbol and symbol type.
@param {number} [size=80] - the size of the symbol.
@param {string} [symbolTypeDesc='circle'] - the string containing the type of symbol that we want to build
(should be one of {@link #node-symbol-type|node.symbolType}).
@returns {Object} concrete instance... | [
"Build",
"a",
"d3",
"svg",
"symbol",
"based",
"on",
"passed",
"symbol",
"and",
"symbol",
"type",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/node/node.helper.js#L56-L60 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.builder.js | _getNodeOpacity | function _getNodeOpacity(node, highlightedNode, highlightedLink, config) {
const highlight =
node.highlighted ||
node.id === (highlightedLink && highlightedLink.source) ||
node.id === (highlightedLink && highlightedLink.target);
const someNodeHighlighted = !!(
highlightedNode ||
... | javascript | function _getNodeOpacity(node, highlightedNode, highlightedLink, config) {
const highlight =
node.highlighted ||
node.id === (highlightedLink && highlightedLink.source) ||
node.id === (highlightedLink && highlightedLink.target);
const someNodeHighlighted = !!(
highlightedNode ||
... | [
"function",
"_getNodeOpacity",
"(",
"node",
",",
"highlightedNode",
",",
"highlightedLink",
",",
"config",
")",
"{",
"const",
"highlight",
"=",
"node",
".",
"highlighted",
"||",
"node",
".",
"id",
"===",
"(",
"highlightedLink",
"&&",
"highlightedLink",
".",
"s... | Get the correct node opacity in order to properly make decisions based on context such as currently highlighted node.
@param {Object} node - the node object for whom we will generate properties.
@param {string} highlightedNode - same as {@link #graphrenderer|highlightedNode in renderGraph}.
@param {Object} highlight... | [
"Get",
"the",
"correct",
"node",
"opacity",
"in",
"order",
"to",
"properly",
"make",
"decisions",
"based",
"on",
"context",
"such",
"as",
"currently",
"highlighted",
"node",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.builder.js#L20-L40 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.builder.js | buildNodeProps | function buildNodeProps(node, config, nodeCallbacks = {}, highlightedNode, highlightedLink, transform) {
const highlight =
node.highlighted ||
(node.id === (highlightedLink && highlightedLink.source) ||
node.id === (highlightedLink && highlightedLink.target));
const opacity = _getNod... | javascript | function buildNodeProps(node, config, nodeCallbacks = {}, highlightedNode, highlightedLink, transform) {
const highlight =
node.highlighted ||
(node.id === (highlightedLink && highlightedLink.source) ||
node.id === (highlightedLink && highlightedLink.target));
const opacity = _getNod... | [
"function",
"buildNodeProps",
"(",
"node",
",",
"config",
",",
"nodeCallbacks",
"=",
"{",
"}",
",",
"highlightedNode",
",",
"highlightedLink",
",",
"transform",
")",
"{",
"const",
"highlight",
"=",
"node",
".",
"highlighted",
"||",
"(",
"node",
".",
"id",
... | Build some Node properties based on given parameters.
@param {Object} node - the node object for whom we will generate properties.
@param {Object} config - same as {@link #graphrenderer|config in renderGraph}.
@param {Function[]} nodeCallbacks - same as {@link #graphrenderer|nodeCallbacks in renderGraph}.
@param {s... | [
"Build",
"some",
"Node",
"properties",
"based",
"on",
"given",
"parameters",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.builder.js#L152-L217 | train |
danielcaldas/react-d3-graph | sandbox/utils.js | formMap | function formMap(k, v) {
// customized props
switch (k) {
case "link.type": {
return {
type: "array",
title: "link.type",
items: {
enum: Object.keys(LINE_TYPES),
},
uniqueItems: true,
... | javascript | function formMap(k, v) {
// customized props
switch (k) {
case "link.type": {
return {
type: "array",
title: "link.type",
items: {
enum: Object.keys(LINE_TYPES),
},
uniqueItems: true,
... | [
"function",
"formMap",
"(",
"k",
",",
"v",
")",
"{",
"// customized props",
"switch",
"(",
"k",
")",
"{",
"case",
"\"link.type\"",
":",
"{",
"return",
"{",
"type",
":",
"\"array\"",
",",
"title",
":",
"\"link.type\"",
",",
"items",
":",
"{",
"enum",
":... | This two functions generate the react-jsonschema-form
schema from some passed graph configuration. | [
"This",
"two",
"functions",
"generate",
"the",
"react",
"-",
"jsonschema",
"-",
"form",
"schema",
"from",
"some",
"passed",
"graph",
"configuration",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/sandbox/utils.js#L11-L31 | train |
danielcaldas/react-d3-graph | cypress/page-objects/sandbox.po.js | SandboxPO | function SandboxPO() {
// whitelist checkbox inputs
this.checkboxes = ["link.renderLabel", "node.renderLabel", "staticGraph", "collapsible", "directed"];
// actions
this.fullScreenMode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(1)");
this.playGraph = () => cy.get(".container__gr... | javascript | function SandboxPO() {
// whitelist checkbox inputs
this.checkboxes = ["link.renderLabel", "node.renderLabel", "staticGraph", "collapsible", "directed"];
// actions
this.fullScreenMode = () => cy.get(".container__graph > :nth-child(1) > :nth-child(1)");
this.playGraph = () => cy.get(".container__gr... | [
"function",
"SandboxPO",
"(",
")",
"{",
"// whitelist checkbox inputs",
"this",
".",
"checkboxes",
"=",
"[",
"\"link.renderLabel\"",
",",
"\"node.renderLabel\"",
",",
"\"staticGraph\"",
",",
"\"collapsible\"",
",",
"\"directed\"",
"]",
";",
"// actions",
"this",
".",
... | Page Object for interacting with sandbox interface.
@returns {undefined} | [
"Page",
"Object",
"for",
"interacting",
"with",
"sandbox",
"interface",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/cypress/page-objects/sandbox.po.js#L5-L41 | train |
danielcaldas/react-d3-graph | cypress/page-objects/link.po.js | LinkPO | function LinkPO(index) {
this.index = index;
this.getLine = () => cy.get('path[class="link"]').then(lines => lines[this.index]);
this.getStyle = () => this.getLine().invoke("attr", "style");
this.shouldHaveColor = color => this.getStyle().should("contain", `stroke: ${color};`);
this.shouldHaveOpaci... | javascript | function LinkPO(index) {
this.index = index;
this.getLine = () => cy.get('path[class="link"]').then(lines => lines[this.index]);
this.getStyle = () => this.getLine().invoke("attr", "style");
this.shouldHaveColor = color => this.getStyle().should("contain", `stroke: ${color};`);
this.shouldHaveOpaci... | [
"function",
"LinkPO",
"(",
"index",
")",
"{",
"this",
".",
"index",
"=",
"index",
";",
"this",
".",
"getLine",
"=",
"(",
")",
"=>",
"cy",
".",
"get",
"(",
"'path[class=\"link\"]'",
")",
".",
"then",
"(",
"lines",
"=>",
"lines",
"[",
"this",
".",
"i... | Page Object for interacting with Link component.
@param {number} index - the index of the link.
@returns {undefined} | [
"Page",
"Object",
"for",
"interacting",
"with",
"Link",
"component",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/cypress/page-objects/link.po.js#L6-L18 | train |
danielcaldas/react-d3-graph | src/utils.js | _isPropertyNestedObject | function _isPropertyNestedObject(o, k) {
return !!o && o.hasOwnProperty(k) && typeof o[k] === "object" && o[k] !== null && !isEmptyObject(o[k]);
} | javascript | function _isPropertyNestedObject(o, k) {
return !!o && o.hasOwnProperty(k) && typeof o[k] === "object" && o[k] !== null && !isEmptyObject(o[k]);
} | [
"function",
"_isPropertyNestedObject",
"(",
"o",
",",
"k",
")",
"{",
"return",
"!",
"!",
"o",
"&&",
"o",
".",
"hasOwnProperty",
"(",
"k",
")",
"&&",
"typeof",
"o",
"[",
"k",
"]",
"===",
"\"object\"",
"&&",
"o",
"[",
"k",
"]",
"!==",
"null",
"&&",
... | Checks whether a certain object property is from object type and is a non empty object.
@param {Object} o - the object.
@param {string} k - the object property.
@returns {boolean} returns true if o[k] is an non empty object.
@memberof utils | [
"Checks",
"whether",
"a",
"certain",
"object",
"property",
"is",
"from",
"object",
"type",
"and",
"is",
"a",
"non",
"empty",
"object",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L19-L21 | train |
danielcaldas/react-d3-graph | src/utils.js | isDeepEqual | function isDeepEqual(o1, o2, _depth = 0) {
let diffs = [];
if (_depth === 0 && o1 === o2) {
return true;
}
if ((isEmptyObject(o1) && !isEmptyObject(o2)) || (!isEmptyObject(o1) && isEmptyObject(o2))) {
return false;
}
const o1Keys = Object.keys(o1);
const o2Keys = Object.ke... | javascript | function isDeepEqual(o1, o2, _depth = 0) {
let diffs = [];
if (_depth === 0 && o1 === o2) {
return true;
}
if ((isEmptyObject(o1) && !isEmptyObject(o2)) || (!isEmptyObject(o1) && isEmptyObject(o2))) {
return false;
}
const o1Keys = Object.keys(o1);
const o2Keys = Object.ke... | [
"function",
"isDeepEqual",
"(",
"o1",
",",
"o2",
",",
"_depth",
"=",
"0",
")",
"{",
"let",
"diffs",
"=",
"[",
"]",
";",
"if",
"(",
"_depth",
"===",
"0",
"&&",
"o1",
"===",
"o2",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"(",
"isEmptyObje... | Generic deep comparison between javascript simple or complex objects.
@param {Object} o1 - one of the objects to be compared.
@param {Object} o2 - second object to compare with first.
@param {number} [_depth=0] - this parameter serves only for internal usage.
@returns {boolean} returns true if o1 and o2 have exactly... | [
"Generic",
"deep",
"comparison",
"between",
"javascript",
"simple",
"or",
"complex",
"objects",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L31-L66 | train |
danielcaldas/react-d3-graph | src/utils.js | deepClone | function deepClone(o, _clone = {}, _depth = 0) {
// TODO: Handle invalid input o is null, undefined, empty object
const oKeys = Object.keys(o);
// TODO: handle arrays
for (let k of oKeys) {
const nested = _isPropertyNestedObject(o, k);
_clone[k] = nested && _depth < MAX_DEPTH ? deepClo... | javascript | function deepClone(o, _clone = {}, _depth = 0) {
// TODO: Handle invalid input o is null, undefined, empty object
const oKeys = Object.keys(o);
// TODO: handle arrays
for (let k of oKeys) {
const nested = _isPropertyNestedObject(o, k);
_clone[k] = nested && _depth < MAX_DEPTH ? deepClo... | [
"function",
"deepClone",
"(",
"o",
",",
"_clone",
"=",
"{",
"}",
",",
"_depth",
"=",
"0",
")",
"{",
"// TODO: Handle invalid input o is null, undefined, empty object",
"const",
"oKeys",
"=",
"Object",
".",
"keys",
"(",
"o",
")",
";",
"// TODO: handle arrays",
"f... | Function to deep clone plain javascript objects.
@param {Object} o - the object to clone.
@param {Object} _clone - carries the cloned output throughout the
recursive calls. Parameter serves only for internal usage.
@param {number} _depth - this parameter serves only for internal usage.
@returns {Object} - the cloned ob... | [
"Function",
"to",
"deep",
"clone",
"plain",
"javascript",
"objects",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L88-L100 | train |
danielcaldas/react-d3-graph | src/utils.js | merge | function merge(o1 = {}, o2 = {}, _depth = 0) {
let o = {};
if (Object.keys(o1 || {}).length === 0) {
return o2 && !isEmptyObject(o2) ? o2 : {};
}
for (let k of Object.keys(o1)) {
const nestedO = !!(o2[k] && typeof o2[k] === "object" && typeof o1[k] === "object" && _depth < MAX_DEPTH);
... | javascript | function merge(o1 = {}, o2 = {}, _depth = 0) {
let o = {};
if (Object.keys(o1 || {}).length === 0) {
return o2 && !isEmptyObject(o2) ? o2 : {};
}
for (let k of Object.keys(o1)) {
const nestedO = !!(o2[k] && typeof o2[k] === "object" && typeof o1[k] === "object" && _depth < MAX_DEPTH);
... | [
"function",
"merge",
"(",
"o1",
"=",
"{",
"}",
",",
"o2",
"=",
"{",
"}",
",",
"_depth",
"=",
"0",
")",
"{",
"let",
"o",
"=",
"{",
"}",
";",
"if",
"(",
"Object",
".",
"keys",
"(",
"o1",
"||",
"{",
"}",
")",
".",
"length",
"===",
"0",
")",
... | This function merges two objects o1 and o2, where o2 properties override existent o1 properties, and
if o2 doesn't posses some o1 property the fallback will be the o1 property.
@param {Object} o1 - object.
@param {Object} o2 - object that will override o1 properties.
@param {int} [_depth=0] - the depth at which we a... | [
"This",
"function",
"merges",
"two",
"objects",
"o1",
"and",
"o2",
"where",
"o2",
"properties",
"override",
"existent",
"o1",
"properties",
"and",
"if",
"o2",
"doesn",
"t",
"posses",
"some",
"o1",
"property",
"the",
"fallback",
"will",
"be",
"the",
"o1",
"... | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L112-L133 | train |
danielcaldas/react-d3-graph | src/utils.js | pick | function pick(o, props = []) {
return props.reduce((acc, k) => {
if (o.hasOwnProperty(k)) {
acc[k] = o[k];
}
return acc;
}, {});
} | javascript | function pick(o, props = []) {
return props.reduce((acc, k) => {
if (o.hasOwnProperty(k)) {
acc[k] = o[k];
}
return acc;
}, {});
} | [
"function",
"pick",
"(",
"o",
",",
"props",
"=",
"[",
"]",
")",
"{",
"return",
"props",
".",
"reduce",
"(",
"(",
"acc",
",",
"k",
")",
"=>",
"{",
"if",
"(",
"o",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"acc",
"[",
"k",
"]",
"=",
"o"... | Create new object from the inputted one only with the props passed
in the props list.
@param {Object} o - the object to pick props from.
@param {Array.<string>} props - list of props that we want to pick from o.
@returns {Object} the object resultant from the picking operation.
@memberof utils | [
"Create",
"new",
"object",
"from",
"the",
"inputted",
"one",
"only",
"with",
"the",
"props",
"passed",
"in",
"the",
"props",
"list",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L143-L151 | train |
danielcaldas/react-d3-graph | src/utils.js | antiPick | function antiPick(o, props = []) {
const wanted = Object.keys(o).filter(k => !props.includes(k));
return pick(o, wanted);
} | javascript | function antiPick(o, props = []) {
const wanted = Object.keys(o).filter(k => !props.includes(k));
return pick(o, wanted);
} | [
"function",
"antiPick",
"(",
"o",
",",
"props",
"=",
"[",
"]",
")",
"{",
"const",
"wanted",
"=",
"Object",
".",
"keys",
"(",
"o",
")",
".",
"filter",
"(",
"k",
"=>",
"!",
"props",
".",
"includes",
"(",
"k",
")",
")",
";",
"return",
"pick",
"(",... | Picks all props except the ones passed in the props array.
@param {Object} o - the object to pick props from.
@param {Array.<string>} props - list of props that we DON'T want to pick from o.
@returns {Object} the object resultant from the anti picking operation.
@memberof utils | [
"Picks",
"all",
"props",
"except",
"the",
"ones",
"passed",
"in",
"the",
"props",
"array",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/utils.js#L160-L164 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | _initializeNodes | function _initializeNodes(graphNodes) {
let nodes = {};
const n = graphNodes.length;
for (let i = 0; i < n; i++) {
const node = graphNodes[i];
node.highlighted = false;
if (!node.hasOwnProperty("x")) {
node.x = 0;
}
if (!node.hasOwnProperty("y")) {
... | javascript | function _initializeNodes(graphNodes) {
let nodes = {};
const n = graphNodes.length;
for (let i = 0; i < n; i++) {
const node = graphNodes[i];
node.highlighted = false;
if (!node.hasOwnProperty("x")) {
node.x = 0;
}
if (!node.hasOwnProperty("y")) {
... | [
"function",
"_initializeNodes",
"(",
"graphNodes",
")",
"{",
"let",
"nodes",
"=",
"{",
"}",
";",
"const",
"n",
"=",
"graphNodes",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"const",
"node",... | Method that initialize graph nodes provided by rd3g consumer and adds additional default mandatory properties
that are optional for the user. Also it generates an index mapping, this maps nodes ids the their index in the array
of nodes. This is needed because d3 callbacks such as node click and link click return the in... | [
"Method",
"that",
"initialize",
"graph",
"nodes",
"provided",
"by",
"rd3g",
"consumer",
"and",
"adds",
"additional",
"default",
"mandatory",
"properties",
"that",
"are",
"optional",
"for",
"the",
"user",
".",
"Also",
"it",
"generates",
"an",
"index",
"mapping",
... | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L105-L125 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | _tagOrphanNodes | function _tagOrphanNodes(nodes, linksMatrix) {
return Object.keys(nodes).reduce((acc, nodeId) => {
const { inDegree, outDegree } = computeNodeDegree(nodeId, linksMatrix);
const node = nodes[nodeId];
const taggedNode = inDegree === 0 && outDegree === 0 ? { ...node, _orphan: true } : node;
... | javascript | function _tagOrphanNodes(nodes, linksMatrix) {
return Object.keys(nodes).reduce((acc, nodeId) => {
const { inDegree, outDegree } = computeNodeDegree(nodeId, linksMatrix);
const node = nodes[nodeId];
const taggedNode = inDegree === 0 && outDegree === 0 ? { ...node, _orphan: true } : node;
... | [
"function",
"_tagOrphanNodes",
"(",
"nodes",
",",
"linksMatrix",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"nodes",
")",
".",
"reduce",
"(",
"(",
"acc",
",",
"nodeId",
")",
"=>",
"{",
"const",
"{",
"inDegree",
",",
"outDegree",
"}",
"=",
"compute... | Tags orphan nodes with a `_orphan` flag.
@param {Object.<string, Object>} nodes - nodes mapped by their id.
@param {Object.<string, Object>} linksMatrix - an object containing a matrix of connections of the graph, for each nodeId,
there is an object that maps adjacent nodes ids (string) and their values (number).
@retu... | [
"Tags",
"orphan",
"nodes",
"with",
"a",
"_orphan",
"flag",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L187-L197 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | _validateGraphData | function _validateGraphData(data) {
if (!data.nodes || !data.nodes.length) {
utils.throwErr("Graph", ERRORS.INSUFFICIENT_DATA);
}
const n = data.links.length;
for (let i = 0; i < n; i++) {
const l = data.links[i];
if (!data.nodes.find(n => n.id === l.source)) {
uti... | javascript | function _validateGraphData(data) {
if (!data.nodes || !data.nodes.length) {
utils.throwErr("Graph", ERRORS.INSUFFICIENT_DATA);
}
const n = data.links.length;
for (let i = 0; i < n; i++) {
const l = data.links[i];
if (!data.nodes.find(n => n.id === l.source)) {
uti... | [
"function",
"_validateGraphData",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
".",
"nodes",
"||",
"!",
"data",
".",
"nodes",
".",
"length",
")",
"{",
"utils",
".",
"throwErr",
"(",
"\"Graph\"",
",",
"ERRORS",
".",
"INSUFFICIENT_DATA",
")",
";",
"}",... | Some integrity validations on links and nodes structure. If some validation fails the function will
throw an error.
@param {Object} data - Same as {@link #initializeGraphState|data in initializeGraphState}.
@throws can throw the following error msg:
INSUFFICIENT_DATA - msg if no nodes are provided
INVALID_LINKS - if l... | [
"Some",
"integrity",
"validations",
"on",
"links",
"and",
"nodes",
"structure",
".",
"If",
"some",
"validation",
"fails",
"the",
"function",
"will",
"throw",
"an",
"error",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L209-L234 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | checkForGraphConfigChanges | function checkForGraphConfigChanges(nextProps, currentState) {
const newConfig = nextProps.config || {};
const configUpdated =
newConfig && !utils.isEmptyObject(newConfig) && !utils.isDeepEqual(newConfig, currentState.config);
const d3ConfigUpdated = newConfig && newConfig.d3 && !utils.isDeepEqual(n... | javascript | function checkForGraphConfigChanges(nextProps, currentState) {
const newConfig = nextProps.config || {};
const configUpdated =
newConfig && !utils.isEmptyObject(newConfig) && !utils.isDeepEqual(newConfig, currentState.config);
const d3ConfigUpdated = newConfig && newConfig.d3 && !utils.isDeepEqual(n... | [
"function",
"checkForGraphConfigChanges",
"(",
"nextProps",
",",
"currentState",
")",
"{",
"const",
"newConfig",
"=",
"nextProps",
".",
"config",
"||",
"{",
"}",
";",
"const",
"configUpdated",
"=",
"newConfig",
"&&",
"!",
"utils",
".",
"isEmptyObject",
"(",
"n... | Logic to check for changes in graph config.
@param {Object} nextProps - nextProps that graph will receive.
@param {Object} currentState - the current state of the graph.
@returns {Object.<string, boolean>} returns object containing update check flags:
- configUpdated - global flag that indicates if any property was upd... | [
"Logic",
"to",
"check",
"for",
"changes",
"in",
"graph",
"config",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L282-L289 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | getCenterAndZoomTransformation | function getCenterAndZoomTransformation(d3Node, config) {
if (!d3Node) {
return;
}
const { width, height, focusZoom } = config;
return `
translate(${width / 2}, ${height / 2})
scale(${focusZoom})
translate(${-d3Node.x}, ${-d3Node.y})
`;
} | javascript | function getCenterAndZoomTransformation(d3Node, config) {
if (!d3Node) {
return;
}
const { width, height, focusZoom } = config;
return `
translate(${width / 2}, ${height / 2})
scale(${focusZoom})
translate(${-d3Node.x}, ${-d3Node.y})
`;
} | [
"function",
"getCenterAndZoomTransformation",
"(",
"d3Node",
",",
"config",
")",
"{",
"if",
"(",
"!",
"d3Node",
")",
"{",
"return",
";",
"}",
"const",
"{",
"width",
",",
"height",
",",
"focusZoom",
"}",
"=",
"config",
";",
"return",
"`",
"${",
"width",
... | Returns the transformation to apply in order to center the graph on the
selected node.
@param {Object} d3Node - node to focus the graph view on.
@param {Object} config - same as {@link #graphrenderer|config in renderGraph}.
@returns {string} transform rule to apply.
@memberof Graph/helper | [
"Returns",
"the",
"transformation",
"to",
"apply",
"in",
"order",
"to",
"center",
"the",
"graph",
"on",
"the",
"selected",
"node",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L299-L311 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | initializeGraphState | function initializeGraphState({ data, id, config }, state) {
_validateGraphData(data);
let graph;
if (state && state.nodes) {
graph = {
nodes: data.nodes.map(n =>
state.nodes[n.id]
? Object.assign({}, n, utils.pick(state.nodes[n.id], NODE_PROPS_WHITE... | javascript | function initializeGraphState({ data, id, config }, state) {
_validateGraphData(data);
let graph;
if (state && state.nodes) {
graph = {
nodes: data.nodes.map(n =>
state.nodes[n.id]
? Object.assign({}, n, utils.pick(state.nodes[n.id], NODE_PROPS_WHITE... | [
"function",
"initializeGraphState",
"(",
"{",
"data",
",",
"id",
",",
"config",
"}",
",",
"state",
")",
"{",
"_validateGraphData",
"(",
"data",
")",
";",
"let",
"graph",
";",
"if",
"(",
"state",
"&&",
"state",
".",
"nodes",
")",
"{",
"graph",
"=",
"{... | Encapsulates common procedures to initialize graph.
@param {Object} props - Graph component props, object that holds data, id and config.
@param {Object} props.data - Data object holds links (array of **Link**) and nodes (array of **Node**).
@param {string} props.id - the graph id.
@param {Object} props.config - same a... | [
"Encapsulates",
"common",
"procedures",
"to",
"initialize",
"graph",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L323-L372 | train |
danielcaldas/react-d3-graph | src/components/graph/graph.helper.js | updateNodeHighlightedValue | function updateNodeHighlightedValue(nodes, links, config, id, value = false) {
const highlightedNode = value ? id : "";
const node = Object.assign({}, nodes[id], { highlighted: value });
let updatedNodes = Object.assign({}, nodes, { [id]: node });
// when highlightDegree is 0 we want only to highlight ... | javascript | function updateNodeHighlightedValue(nodes, links, config, id, value = false) {
const highlightedNode = value ? id : "";
const node = Object.assign({}, nodes[id], { highlighted: value });
let updatedNodes = Object.assign({}, nodes, { [id]: node });
// when highlightDegree is 0 we want only to highlight ... | [
"function",
"updateNodeHighlightedValue",
"(",
"nodes",
",",
"links",
",",
"config",
",",
"id",
",",
"value",
"=",
"false",
")",
"{",
"const",
"highlightedNode",
"=",
"value",
"?",
"id",
":",
"\"\"",
";",
"const",
"node",
"=",
"Object",
".",
"assign",
"(... | This function updates the highlighted value for a given node and also updates highlight props.
@param {Object.<string, Object>} nodes - an object containing all nodes mapped by their id.
@param {Object.<string, Object>} links - an object containing a matrix of connections of the graph.
@param {Object} config - an objec... | [
"This",
"function",
"updates",
"the",
"highlighted",
"value",
"for",
"a",
"given",
"node",
"and",
"also",
"updates",
"highlight",
"props",
"."
] | d7911aef4eb79a5c2fd0368b39640b654dabfea4 | https://github.com/danielcaldas/react-d3-graph/blob/d7911aef4eb79a5c2fd0368b39640b654dabfea4/src/components/graph/graph.helper.js#L385-L403 | train |
blockchain/service-my-wallet-v3 | src/create.js | function (uuids) {
var guid = uuids[0]
var sharedKey = uuids[1]
if (!guid || !sharedKey || guid.length !== 36 || sharedKey.length !== 36) {
throw 'Error generating wallet identifier'
}
return { guid: guid, sharedKey: sharedKey }
} | javascript | function (uuids) {
var guid = uuids[0]
var sharedKey = uuids[1]
if (!guid || !sharedKey || guid.length !== 36 || sharedKey.length !== 36) {
throw 'Error generating wallet identifier'
}
return { guid: guid, sharedKey: sharedKey }
} | [
"function",
"(",
"uuids",
")",
"{",
"var",
"guid",
"=",
"uuids",
"[",
"0",
"]",
"var",
"sharedKey",
"=",
"uuids",
"[",
"1",
"]",
"if",
"(",
"!",
"guid",
"||",
"!",
"sharedKey",
"||",
"guid",
".",
"length",
"!==",
"36",
"||",
"sharedKey",
".",
"le... | Handle response from WalletNetwork | [
"Handle",
"response",
"from",
"WalletNetwork"
] | 5af1ca6195a883cb6736e0f55f257d04147b0312 | https://github.com/blockchain/service-my-wallet-v3/blob/5af1ca6195a883cb6736e0f55f257d04147b0312/src/create.js#L44-L53 | train | |
blockchain/service-my-wallet-v3 | src/create.js | function (uuids) {
var walletJSON = {
guid: uuids.guid,
sharedKey: uuids.sharedKey,
double_encryption: false,
options: {
pbkdf2_iterations: 5000,
html5_notifications: false,
fee_per_kb: 10000,
logout_time: 600000
}
}
var createHdWallet = functio... | javascript | function (uuids) {
var walletJSON = {
guid: uuids.guid,
sharedKey: uuids.sharedKey,
double_encryption: false,
options: {
pbkdf2_iterations: 5000,
html5_notifications: false,
fee_per_kb: 10000,
logout_time: 600000
}
}
var createHdWallet = functio... | [
"function",
"(",
"uuids",
")",
"{",
"var",
"walletJSON",
"=",
"{",
"guid",
":",
"uuids",
".",
"guid",
",",
"sharedKey",
":",
"uuids",
".",
"sharedKey",
",",
"double_encryption",
":",
"false",
",",
"options",
":",
"{",
"pbkdf2_iterations",
":",
"5000",
",... | Generate new Wallet JSON, add first key | [
"Generate",
"new",
"Wallet",
"JSON",
"add",
"first",
"key"
] | 5af1ca6195a883cb6736e0f55f257d04147b0312 | https://github.com/blockchain/service-my-wallet-v3/blob/5af1ca6195a883cb6736e0f55f257d04147b0312/src/create.js#L56-L96 | train | |
blockchain/service-my-wallet-v3 | src/create.js | function (wallet) {
var data = JSON.stringify(wallet, null, 2)
var enc = Blockchain.WalletCrypto.encryptWallet(data, password, wallet.options.pbkdf2_iterations, 2.0)
var check = sha256(enc).toString('hex')
// Throws if there is an encryption error
Blockchain.WalletCrypto.decryptWallet(enc, password... | javascript | function (wallet) {
var data = JSON.stringify(wallet, null, 2)
var enc = Blockchain.WalletCrypto.encryptWallet(data, password, wallet.options.pbkdf2_iterations, 2.0)
var check = sha256(enc).toString('hex')
// Throws if there is an encryption error
Blockchain.WalletCrypto.decryptWallet(enc, password... | [
"function",
"(",
"wallet",
")",
"{",
"var",
"data",
"=",
"JSON",
".",
"stringify",
"(",
"wallet",
",",
"null",
",",
"2",
")",
"var",
"enc",
"=",
"Blockchain",
".",
"WalletCrypto",
".",
"encryptWallet",
"(",
"data",
",",
"password",
",",
"wallet",
".",
... | Encrypt and push new wallet to server | [
"Encrypt",
"and",
"push",
"new",
"wallet",
"to",
"server"
] | 5af1ca6195a883cb6736e0f55f257d04147b0312 | https://github.com/blockchain/service-my-wallet-v3/blob/5af1ca6195a883cb6736e0f55f257d04147b0312/src/create.js#L99-L130 | train | |
google/traceur-compiler | demo/generators.js | fib | function fib(max) {
var a = 0, b = 1;
var results = [];
while (b < max) {
results.push(b);
[a, b] = [b, a + b];
}
return results;
} | javascript | function fib(max) {
var a = 0, b = 1;
var results = [];
while (b < max) {
results.push(b);
[a, b] = [b, a + b];
}
return results;
} | [
"function",
"fib",
"(",
"max",
")",
"{",
"var",
"a",
"=",
"0",
",",
"b",
"=",
"1",
";",
"var",
"results",
"=",
"[",
"]",
";",
"while",
"(",
"b",
"<",
"max",
")",
"{",
"results",
".",
"push",
"(",
"b",
")",
";",
"[",
"a",
",",
"b",
"]",
... | Example 2. Fibonacci precomputes a fixed set | [
"Example",
"2",
".",
"Fibonacci",
"precomputes",
"a",
"fixed",
"set"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/demo/generators.js#L26-L34 | train |
google/traceur-compiler | demo/generators.js | tree | function tree(list) {
var n = list.length;
if (n == 0) {
return null;
}
var i = Math.floor(n / 2);
return new Tree(list[i], tree(list.slice(0, i)), tree(list.slice(i + 1)));
} | javascript | function tree(list) {
var n = list.length;
if (n == 0) {
return null;
}
var i = Math.floor(n / 2);
return new Tree(list[i], tree(list.slice(0, i)), tree(list.slice(i + 1)));
} | [
"function",
"tree",
"(",
"list",
")",
"{",
"var",
"n",
"=",
"list",
".",
"length",
";",
"if",
"(",
"n",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"var",
"i",
"=",
"Math",
".",
"floor",
"(",
"n",
"/",
"2",
")",
";",
"return",
"new",
"... | Create a Tree from a list. | [
"Create",
"a",
"Tree",
"from",
"a",
"list",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/demo/generators.js#L56-L63 | train |
google/traceur-compiler | src/runtime/polyfills/ArrayIterator.js | createArrayIterator | function createArrayIterator(array, kind) {
var object = toObject(array);
var iterator = new ArrayIterator;
iterator.iteratorObject_ = object;
iterator.arrayIteratorNextIndex_ = 0;
iterator.arrayIterationKind_ = kind;
return iterator;
} | javascript | function createArrayIterator(array, kind) {
var object = toObject(array);
var iterator = new ArrayIterator;
iterator.iteratorObject_ = object;
iterator.arrayIteratorNextIndex_ = 0;
iterator.arrayIterationKind_ = kind;
return iterator;
} | [
"function",
"createArrayIterator",
"(",
"array",
",",
"kind",
")",
"{",
"var",
"object",
"=",
"toObject",
"(",
"array",
")",
";",
"var",
"iterator",
"=",
"new",
"ArrayIterator",
";",
"iterator",
".",
"iteratorObject_",
"=",
"object",
";",
"iterator",
".",
... | 15.4.5.1 CreateArrayIterator Abstract Operation | [
"15",
".",
"4",
".",
"5",
".",
"1",
"CreateArrayIterator",
"Abstract",
"Operation"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/runtime/polyfills/ArrayIterator.js#L66-L73 | train |
google/traceur-compiler | third_party/es6-module-loader/system.js | traverse | function traverse(object, iterator, parent, parentProperty) {
var key, child;
if (iterator(object, parent, parentProperty) === false)
return;
for (key in object) {
if (!object.hasOwnProperty(key))
continue;
if (key == 'location' || key == 'type')
... | javascript | function traverse(object, iterator, parent, parentProperty) {
var key, child;
if (iterator(object, parent, parentProperty) === false)
return;
for (key in object) {
if (!object.hasOwnProperty(key))
continue;
if (key == 'location' || key == 'type')
... | [
"function",
"traverse",
"(",
"object",
",",
"iterator",
",",
"parent",
",",
"parentProperty",
")",
"{",
"var",
"key",
",",
"child",
";",
"if",
"(",
"iterator",
"(",
"object",
",",
"parent",
",",
"parentProperty",
")",
"===",
"false",
")",
"return",
";",
... | tree traversal, NB should use visitor pattern here | [
"tree",
"traversal",
"NB",
"should",
"use",
"visitor",
"pattern",
"here"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/system.js#L136-L149 | train |
google/traceur-compiler | third_party/es6-module-loader/system.js | __eval | function __eval(__source, __global, load) {
// Hijack System.register to set declare function
System.__curRegister = System.register;
System.register = function(name, deps, declare) {
// store the registered declaration as load.declare
load.declare = typeof name == 'string' ? declare : deps;
... | javascript | function __eval(__source, __global, load) {
// Hijack System.register to set declare function
System.__curRegister = System.register;
System.register = function(name, deps, declare) {
// store the registered declaration as load.declare
load.declare = typeof name == 'string' ? declare : deps;
... | [
"function",
"__eval",
"(",
"__source",
",",
"__global",
",",
"load",
")",
"{",
"// Hijack System.register to set declare function",
"System",
".",
"__curRegister",
"=",
"System",
".",
"register",
";",
"System",
".",
"register",
"=",
"function",
"(",
"name",
",",
... | Define our eval outside of the scope of any other reference defined in this file to avoid adding those references to the evaluation scope. | [
"Define",
"our",
"eval",
"outside",
"of",
"the",
"scope",
"of",
"any",
"other",
"reference",
"defined",
"in",
"this",
"file",
"to",
"avoid",
"adding",
"those",
"references",
"to",
"the",
"evaluation",
"scope",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/system.js#L367-L378 | train |
google/traceur-compiler | src/node/deferred.js | wrapModule | function wrapModule(module, functions) {
if (typeof module === 'string')
module = require(module);
if (!functions) {
for (var k in module) {
// HACK: wrap all functions with a fnSync variant.
if (typeof module[k] === 'function' &&
typeof module[k + 'Sync'] === 'function')
modu... | javascript | function wrapModule(module, functions) {
if (typeof module === 'string')
module = require(module);
if (!functions) {
for (var k in module) {
// HACK: wrap all functions with a fnSync variant.
if (typeof module[k] === 'function' &&
typeof module[k + 'Sync'] === 'function')
modu... | [
"function",
"wrapModule",
"(",
"module",
",",
"functions",
")",
"{",
"if",
"(",
"typeof",
"module",
"===",
"'string'",
")",
"module",
"=",
"require",
"(",
"module",
")",
";",
"if",
"(",
"!",
"functions",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"modul... | Wrap async functions in a module to enable the use of await.
If no function name array is provided, every function with a fnSync
variant will be wrapped.
@param {string|Object} module The exports of the module or a string that
will be passed to require to get the module.
@param {Array.<string>} functions Function name... | [
"Wrap",
"async",
"functions",
"in",
"a",
"module",
"to",
"enable",
"the",
"use",
"of",
"await",
".",
"If",
"no",
"function",
"name",
"array",
"is",
"provided",
"every",
"function",
"with",
"a",
"fnSync",
"variant",
"will",
"be",
"wrapped",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/node/deferred.js#L76-L95 | train |
google/traceur-compiler | build/minifier.js | printCompilerMsg | function printCompilerMsg(msg, file) {
console.error('%s:%d:%d %s - %s',
file || msg.file, msg.lineno + 1,
msg.charno + 1, msg.type, msg.error);
console.error('%s\n%s^',
msg.line, Array(msg.charno + 1).join(' '));
} | javascript | function printCompilerMsg(msg, file) {
console.error('%s:%d:%d %s - %s',
file || msg.file, msg.lineno + 1,
msg.charno + 1, msg.type, msg.error);
console.error('%s\n%s^',
msg.line, Array(msg.charno + 1).join(' '));
} | [
"function",
"printCompilerMsg",
"(",
"msg",
",",
"file",
")",
"{",
"console",
".",
"error",
"(",
"'%s:%d:%d %s - %s'",
",",
"file",
"||",
"msg",
".",
"file",
",",
"msg",
".",
"lineno",
"+",
"1",
",",
"msg",
".",
"charno",
"+",
"1",
",",
"msg",
".",
... | Prints a formatted error or warning message.
@param {CompilerMsg} msg An error or warning message as returned by the
Closure Compiler Service's JSON output format.
@param {string|null} file The filename to refer to in error messages. If
null, then msg.file is used instead. | [
"Prints",
"a",
"formatted",
"error",
"or",
"warning",
"message",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/build/minifier.js#L29-L35 | train |
google/traceur-compiler | build/minifier.js | mergedCompilerMsgLists | function mergedCompilerMsgLists(list1, list2) {
var list = [];
list1 = list1 || [];
list2 = list2 || [];
function lessThan(e1, e2) {
if (e1.lineno < e2.lineno)
return true;
return e1.lineno === e2.lineno && e1.charno < e2.charno;
}
var i1 = 0, i2 = 0;
while (true) {
if (i1 >= list1.le... | javascript | function mergedCompilerMsgLists(list1, list2) {
var list = [];
list1 = list1 || [];
list2 = list2 || [];
function lessThan(e1, e2) {
if (e1.lineno < e2.lineno)
return true;
return e1.lineno === e2.lineno && e1.charno < e2.charno;
}
var i1 = 0, i2 = 0;
while (true) {
if (i1 >= list1.le... | [
"function",
"mergedCompilerMsgLists",
"(",
"list1",
",",
"list2",
")",
"{",
"var",
"list",
"=",
"[",
"]",
";",
"list1",
"=",
"list1",
"||",
"[",
"]",
";",
"list2",
"=",
"list2",
"||",
"[",
"]",
";",
"function",
"lessThan",
"(",
"e1",
",",
"e2",
")"... | Used to merge the warning and error lists so that everything can be printed
in lineno and charno order. If lineno and charno match, then list2 is chosen
first.
@param {Array.<CompilerMsg>} list1
@param {Array.<CompilerMsg>} list2 | [
"Used",
"to",
"merge",
"the",
"warning",
"and",
"error",
"lists",
"so",
"that",
"everything",
"can",
"be",
"printed",
"in",
"lineno",
"and",
"charno",
"order",
".",
"If",
"lineno",
"and",
"charno",
"match",
"then",
"list2",
"is",
"chosen",
"first",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/build/minifier.js#L44-L67 | train |
google/traceur-compiler | src/node/file-util.js | mkdirRecursive | function mkdirRecursive(dir) {
var parts = path.normalize(dir).split(path.sep);
dir = '';
for (var i = 0; i < parts.length; i++) {
dir += parts[i] + path.sep;
if (!existsSync(dir)) {
fs.mkdirSync(dir, 0x1FD); // 0775 permissions
}
}
} | javascript | function mkdirRecursive(dir) {
var parts = path.normalize(dir).split(path.sep);
dir = '';
for (var i = 0; i < parts.length; i++) {
dir += parts[i] + path.sep;
if (!existsSync(dir)) {
fs.mkdirSync(dir, 0x1FD); // 0775 permissions
}
}
} | [
"function",
"mkdirRecursive",
"(",
"dir",
")",
"{",
"var",
"parts",
"=",
"path",
".",
"normalize",
"(",
"dir",
")",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
"dir",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"parts"... | Recursively makes all directoires, similar to mkdir -p
@param {string} dir | [
"Recursively",
"makes",
"all",
"directoires",
"similar",
"to",
"mkdir",
"-",
"p"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/node/file-util.js#L26-L35 | train |
google/traceur-compiler | src/node/file-util.js | removeCommonPrefix | function removeCommonPrefix(basedir, filedir) {
var baseparts = basedir.split(path.sep);
var fileparts = filedir.split(path.sep);
var i = 0;
while (i < fileparts.length && fileparts[i] === baseparts[i]) {
i++;
}
return fileparts.slice(i).join(path.sep);
} | javascript | function removeCommonPrefix(basedir, filedir) {
var baseparts = basedir.split(path.sep);
var fileparts = filedir.split(path.sep);
var i = 0;
while (i < fileparts.length && fileparts[i] === baseparts[i]) {
i++;
}
return fileparts.slice(i).join(path.sep);
} | [
"function",
"removeCommonPrefix",
"(",
"basedir",
",",
"filedir",
")",
"{",
"var",
"baseparts",
"=",
"basedir",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
"var",
"fileparts",
"=",
"filedir",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
"var",... | Removes the common prefix of basedir and filedir from filedir
@param {string} basedir
@param {string} filedir | [
"Removes",
"the",
"common",
"prefix",
"of",
"basedir",
"and",
"filedir",
"from",
"filedir"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/node/file-util.js#L42-L51 | train |
google/traceur-compiler | src/syntax/Scanner.js | scanTemplateStart | function scanTemplateStart(beginIndex) {
if (isAtEnd()) {
reportError('Unterminated template literal', beginIndex, index);
return lastToken = createToken(END_OF_FILE, beginIndex);
}
return nextTemplateLiteralTokenShared(NO_SUBSTITUTION_TEMPLATE,
TEMPLATE_HEAD);
} | javascript | function scanTemplateStart(beginIndex) {
if (isAtEnd()) {
reportError('Unterminated template literal', beginIndex, index);
return lastToken = createToken(END_OF_FILE, beginIndex);
}
return nextTemplateLiteralTokenShared(NO_SUBSTITUTION_TEMPLATE,
TEMPLATE_HEAD);
} | [
"function",
"scanTemplateStart",
"(",
"beginIndex",
")",
"{",
"if",
"(",
"isAtEnd",
"(",
")",
")",
"{",
"reportError",
"(",
"'Unterminated template literal'",
",",
"beginIndex",
",",
"index",
")",
";",
"return",
"lastToken",
"=",
"createToken",
"(",
"END_OF_FILE... | Either returns a NO_SUBSTITUTION_TEMPLATE or TEMPLATE_HEAD token. | [
"Either",
"returns",
"a",
"NO_SUBSTITUTION_TEMPLATE",
"or",
"TEMPLATE_HEAD",
"token",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/syntax/Scanner.js#L444-L452 | train |
google/traceur-compiler | src/syntax/Scanner.js | scanJsxToken | function scanJsxToken() {
skipComments();
let beginIndex = index;
switch (currentCharCode) {
case 34: // "
case 39: // '
return scanJsxStringLiteral(beginIndex, currentCharCode);
case 62: // >
next();
return createToken(CLOSE_ANGLE, beginIndex);
// case 123: // {
// case ... | javascript | function scanJsxToken() {
skipComments();
let beginIndex = index;
switch (currentCharCode) {
case 34: // "
case 39: // '
return scanJsxStringLiteral(beginIndex, currentCharCode);
case 62: // >
next();
return createToken(CLOSE_ANGLE, beginIndex);
// case 123: // {
// case ... | [
"function",
"scanJsxToken",
"(",
")",
"{",
"skipComments",
"(",
")",
";",
"let",
"beginIndex",
"=",
"index",
";",
"switch",
"(",
"currentCharCode",
")",
"{",
"case",
"34",
":",
"// \"",
"case",
"39",
":",
"// '",
"return",
"scanJsxStringLiteral",
"(",
"beg... | Used to scan for a JSXIdentifier. | [
"Used",
"to",
"scan",
"for",
"a",
"JSXIdentifier",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/syntax/Scanner.js#L520-L543 | train |
google/traceur-compiler | src/codegeneration/BlockBindingTransformer.js | varNeedsInitializer | function varNeedsInitializer(tree, loopTree) {
if (loopTree === null) return false;
// Loop initializers for for-in/for-of must not have an initializer RHS.
let type = loopTree.type;
if (type !== FOR_IN_STATEMENT && type !== FOR_OF_STATEMENT) return true;
return loopTree.initializer.declarations[0] !== tree;... | javascript | function varNeedsInitializer(tree, loopTree) {
if (loopTree === null) return false;
// Loop initializers for for-in/for-of must not have an initializer RHS.
let type = loopTree.type;
if (type !== FOR_IN_STATEMENT && type !== FOR_OF_STATEMENT) return true;
return loopTree.initializer.declarations[0] !== tree;... | [
"function",
"varNeedsInitializer",
"(",
"tree",
",",
"loopTree",
")",
"{",
"if",
"(",
"loopTree",
"===",
"null",
")",
"return",
"false",
";",
"// Loop initializers for for-in/for-of must not have an initializer RHS.",
"let",
"type",
"=",
"loopTree",
".",
"type",
";",
... | Transforms the block bindings from traceur to js.
In most cases, let can be transformed to var straight away and renamed to
avoid name collisions.
Making a
if (true) { let t = 5; }
Become a
if (true) { var t$__0 = 5; }
The only special case is in Iterable statements. For those, we only use a
different strategy if... | [
"Transforms",
"the",
"block",
"bindings",
"from",
"traceur",
"to",
"js",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/codegeneration/BlockBindingTransformer.js#L152-L159 | train |
google/traceur-compiler | src/node/recursiveModuleCompile.js | recursiveModuleCompile | function recursiveModuleCompile(fileNamesAndTypes, options) {
var referrerName = options && options.referrer;
var basePath = path.resolve('./') + '/';
basePath = basePath.replace(/\\/g, '/');
var elements = [];
var loaderCompiler = new InlineLoaderCompiler(elements);
var loader = new TraceurLoader(nodeLo... | javascript | function recursiveModuleCompile(fileNamesAndTypes, options) {
var referrerName = options && options.referrer;
var basePath = path.resolve('./') + '/';
basePath = basePath.replace(/\\/g, '/');
var elements = [];
var loaderCompiler = new InlineLoaderCompiler(elements);
var loader = new TraceurLoader(nodeLo... | [
"function",
"recursiveModuleCompile",
"(",
"fileNamesAndTypes",
",",
"options",
")",
"{",
"var",
"referrerName",
"=",
"options",
"&&",
"options",
".",
"referrer",
";",
"var",
"basePath",
"=",
"path",
".",
"resolve",
"(",
"'./'",
")",
"+",
"'/'",
";",
"basePa... | Compiles the files in "fileNamesAndTypes" along with any associated modules,
into a single js file, in module dependency order.
@param {Array<Object>} fileNamesAndTypes The list of {name, type}
to compile and concat; type is 'module' or 'script'
@param {Object} options A container for misc options. 'referrer' is the
o... | [
"Compiles",
"the",
"files",
"in",
"fileNamesAndTypes",
"along",
"with",
"any",
"associated",
"modules",
"into",
"a",
"single",
"js",
"file",
"in",
"module",
"dependency",
"order",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/node/recursiveModuleCompile.js#L111-L162 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | proceedToLocate | function proceedToLocate(loader, load) {
proceedToFetch(loader, load,
Promise.resolve()
// 15.2.4.3.1 CallLocate
.then(function() {
return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
})
);
} | javascript | function proceedToLocate(loader, load) {
proceedToFetch(loader, load,
Promise.resolve()
// 15.2.4.3.1 CallLocate
.then(function() {
return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
})
);
} | [
"function",
"proceedToLocate",
"(",
"loader",
",",
"load",
")",
"{",
"proceedToFetch",
"(",
"loader",
",",
"load",
",",
"Promise",
".",
"resolve",
"(",
")",
"// 15.2.4.3.1 CallLocate",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"loader",
".",
"... | 15.2.4.3 | [
"15",
".",
"2",
".",
"4",
".",
"3"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L214-L222 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | proceedToFetch | function proceedToFetch(loader, load, p) {
proceedToTranslate(loader, load,
p
// 15.2.4.4.1 CallFetch
.then(function(address) {
// adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
if (load.status != 'loading')
return;
load.address = a... | javascript | function proceedToFetch(loader, load, p) {
proceedToTranslate(loader, load,
p
// 15.2.4.4.1 CallFetch
.then(function(address) {
// adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
if (load.status != 'loading')
return;
load.address = a... | [
"function",
"proceedToFetch",
"(",
"loader",
",",
"load",
",",
"p",
")",
"{",
"proceedToTranslate",
"(",
"loader",
",",
"load",
",",
"p",
"// 15.2.4.4.1 CallFetch",
".",
"then",
"(",
"function",
"(",
"address",
")",
"{",
"// adjusted, see https://bugs.ecmascript.o... | 15.2.4.4 | [
"15",
".",
"2",
".",
"4",
".",
"4"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L225-L238 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | addLoadToLinkSet | function addLoadToLinkSet(linkSet, load) {
console.assert(load.status == 'loading' || load.status == 'loaded', 'loading or loaded on link set');
for (var i = 0, l = linkSet.loads.length; i < l; i++)
if (linkSet.loads[i] == load)
return;
linkSet.loads.push(load);
load.linkSets... | javascript | function addLoadToLinkSet(linkSet, load) {
console.assert(load.status == 'loading' || load.status == 'loaded', 'loading or loaded on link set');
for (var i = 0, l = linkSet.loads.length; i < l; i++)
if (linkSet.loads[i] == load)
return;
linkSet.loads.push(load);
load.linkSets... | [
"function",
"addLoadToLinkSet",
"(",
"linkSet",
",",
"load",
")",
"{",
"console",
".",
"assert",
"(",
"load",
".",
"status",
"==",
"'loading'",
"||",
"load",
".",
"status",
"==",
"'loaded'",
",",
"'loading or loaded on link set'",
")",
";",
"for",
"(",
"var"... | 15.2.5.2.2 | [
"15",
".",
"2",
".",
"5",
".",
"2",
".",
"2"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L409-L442 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | updateLinkSetOnLoad | function updateLinkSetOnLoad(linkSet, load) {
// console.log('update linkset on load ' + load.name);
// snapshot(linkSet.loader);
console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
linkSet.loadingCount--;
if (linkSet.loadingCount > 0)
return;... | javascript | function updateLinkSetOnLoad(linkSet, load) {
// console.log('update linkset on load ' + load.name);
// snapshot(linkSet.loader);
console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
linkSet.loadingCount--;
if (linkSet.loadingCount > 0)
return;... | [
"function",
"updateLinkSetOnLoad",
"(",
"linkSet",
",",
"load",
")",
"{",
"// console.log('update linkset on load ' + load.name);",
"// snapshot(linkSet.loader);",
"console",
".",
"assert",
"(",
"load",
".",
"status",
"==",
"'loaded'",
"||",
"load",
".",
"status",
"==",... | 15.2.5.2.3 | [
"15",
".",
"2",
".",
"5",
".",
"2",
".",
"3"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L455-L498 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | finishLoad | function finishLoad(loader, load) {
// add to global trace if tracing
if (loader.loaderObj.trace) {
if (!loader.loaderObj.loads)
loader.loaderObj.loads = {};
var depMap = {};
load.dependencies.forEach(function(dep) {
depMap[dep.key] = dep.value;
});
... | javascript | function finishLoad(loader, load) {
// add to global trace if tracing
if (loader.loaderObj.trace) {
if (!loader.loaderObj.loads)
loader.loaderObj.loads = {};
var depMap = {};
load.dependencies.forEach(function(dep) {
depMap[dep.key] = dep.value;
});
... | [
"function",
"finishLoad",
"(",
"loader",
",",
"load",
")",
"{",
"// add to global trace if tracing",
"if",
"(",
"loader",
".",
"loaderObj",
".",
"trace",
")",
"{",
"if",
"(",
"!",
"loader",
".",
"loaderObj",
".",
"loads",
")",
"loader",
".",
"loaderObj",
"... | 15.2.5.2.5 | [
"15",
".",
"2",
".",
"5",
".",
"2",
".",
"5"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L525-L558 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | linkDeclarativeModule | function linkDeclarativeModule(load, loads, loader) {
if (load.module)
return;
var module = load.module = getOrCreateModuleRecord(load.name);
var moduleObj = load.module.module;
var registryEntry = load.declare.call(__global, function(name, value) {
// NB This should be an Obje... | javascript | function linkDeclarativeModule(load, loads, loader) {
if (load.module)
return;
var module = load.module = getOrCreateModuleRecord(load.name);
var moduleObj = load.module.module;
var registryEntry = load.declare.call(__global, function(name, value) {
// NB This should be an Obje... | [
"function",
"linkDeclarativeModule",
"(",
"load",
",",
"loads",
",",
"loader",
")",
"{",
"if",
"(",
"load",
".",
"module",
")",
"return",
";",
"var",
"module",
"=",
"load",
".",
"module",
"=",
"getOrCreateModuleRecord",
"(",
"load",
".",
"name",
")",
";"... | custom declarative linking function | [
"custom",
"declarative",
"linking",
"function"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L679-L750 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | evaluateLoadedModule | function evaluateLoadedModule(loader, load) {
console.assert(load.status == 'linked', 'is linked ' + load.name);
doEnsureEvaluated(load.module, [], loader);
return load.module.module;
} | javascript | function evaluateLoadedModule(loader, load) {
console.assert(load.status == 'linked', 'is linked ' + load.name);
doEnsureEvaluated(load.module, [], loader);
return load.module.module;
} | [
"function",
"evaluateLoadedModule",
"(",
"loader",
",",
"load",
")",
"{",
"console",
".",
"assert",
"(",
"load",
".",
"status",
"==",
"'linked'",
",",
"'is linked '",
"+",
"load",
".",
"name",
")",
";",
"doEnsureEvaluated",
"(",
"load",
".",
"module",
",",... | 15.2.5.5.1 LinkImports not implemented 15.2.5.7 ResolveExportEntries not implemented 15.2.5.8 ResolveExports not implemented 15.2.5.9 ResolveExport not implemented 15.2.5.10 ResolveImportEntries not implemented 15.2.6.1 | [
"15",
".",
"2",
".",
"5",
".",
"5",
".",
"1",
"LinkImports",
"not",
"implemented",
"15",
".",
"2",
".",
"5",
".",
"7",
"ResolveExportEntries",
"not",
"implemented",
"15",
".",
"2",
".",
"5",
".",
"8",
"ResolveExports",
"not",
"implemented",
"15",
"."... | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L761-L766 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | ensureEvaluated | function ensureEvaluated(module, seen, loader) {
if (module.evaluated || !module.dependencies)
return;
seen.push(module);
var deps = module.dependencies;
var err;
for (var i = 0, l = deps.length; i < l; i++) {
var dep = deps[i];
if (indexOf.call(seen, dep) == -1)... | javascript | function ensureEvaluated(module, seen, loader) {
if (module.evaluated || !module.dependencies)
return;
seen.push(module);
var deps = module.dependencies;
var err;
for (var i = 0, l = deps.length; i < l; i++) {
var dep = deps[i];
if (indexOf.call(seen, dep) == -1)... | [
"function",
"ensureEvaluated",
"(",
"module",
",",
"seen",
",",
"loader",
")",
"{",
"if",
"(",
"module",
".",
"evaluated",
"||",
"!",
"module",
".",
"dependencies",
")",
"return",
";",
"seen",
".",
"push",
"(",
"module",
")",
";",
"var",
"deps",
"=",
... | 15.2.6.2 EnsureEvaluated adjusted | [
"15",
".",
"2",
".",
"6",
".",
"2",
"EnsureEvaluated",
"adjusted"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L794-L832 | train |
google/traceur-compiler | third_party/es6-module-loader/loader.js | function(key) {
if (!this._loader.modules[key])
return;
doEnsureEvaluated(this._loader.modules[key], [], this);
return this._loader.modules[key].module;
} | javascript | function(key) {
if (!this._loader.modules[key])
return;
doEnsureEvaluated(this._loader.modules[key], [], this);
return this._loader.modules[key].module;
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_loader",
".",
"modules",
"[",
"key",
"]",
")",
"return",
";",
"doEnsureEvaluated",
"(",
"this",
".",
"_loader",
".",
"modules",
"[",
"key",
"]",
",",
"[",
"]",
",",
"this",
")",
";"... | 26.3.3.4 entries not implemented 26.3.3.5 | [
"26",
".",
"3",
".",
"3",
".",
"4",
"entries",
"not",
"implemented",
"26",
".",
"3",
".",
"3",
".",
"5"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L906-L911 | train | |
google/traceur-compiler | third_party/es6-module-loader/loader.js | function(name, module) {
if (!(module instanceof Module))
throw new TypeError('Set must be a module');
this._loader.modules[name] = {
module: module
};
} | javascript | function(name, module) {
if (!(module instanceof Module))
throw new TypeError('Set must be a module');
this._loader.modules[name] = {
module: module
};
} | [
"function",
"(",
"name",
",",
"module",
")",
"{",
"if",
"(",
"!",
"(",
"module",
"instanceof",
"Module",
")",
")",
"throw",
"new",
"TypeError",
"(",
"'Set must be a module'",
")",
";",
"this",
".",
"_loader",
".",
"modules",
"[",
"name",
"]",
"=",
"{",... | 26.3.3.14 | [
"26",
".",
"3",
".",
"3",
".",
"14"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/third_party/es6-module-loader/loader.js#L988-L994 | train | |
google/traceur-compiler | src/codegeneration/TemplateLiteralTransformer.js | createGetTemplateObject | function createGetTemplateObject(elements, getTemplateObject) {
let cooked = [];
let raw = [];
let same = true;
for (let i = 0; i < elements.length; i += 2) {
let loc = elements[i].location;
let str = elements[i].value.value;
let cookedStr = toCookedString(str);
let rawStr = toRawString(str);
... | javascript | function createGetTemplateObject(elements, getTemplateObject) {
let cooked = [];
let raw = [];
let same = true;
for (let i = 0; i < elements.length; i += 2) {
let loc = elements[i].location;
let str = elements[i].value.value;
let cookedStr = toCookedString(str);
let rawStr = toRawString(str);
... | [
"function",
"createGetTemplateObject",
"(",
"elements",
",",
"getTemplateObject",
")",
"{",
"let",
"cooked",
"=",
"[",
"]",
";",
"let",
"raw",
"=",
"[",
"]",
";",
"let",
"same",
"=",
"true",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"el... | Generetes the runtime call to create the template object.
The tagged template literal
f `a${42}\n`
gets compiled into:
f($traceurRuntime.getTemplateObject(['a', '\\n], ['a', '\n']), 42)
Note that if the cooked and the raw strings are identical the runtime call
only pass one array.
@param {Array<ParseTree>} element... | [
"Generetes",
"the",
"runtime",
"call",
"to",
"create",
"the",
"template",
"object",
".",
"The",
"tagged",
"template",
"literal"
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/codegeneration/TemplateLiteralTransformer.js#L67-L99 | train |
google/traceur-compiler | src/codegeneration/TemplateLiteralTransformer.js | maybeAddEmptyStringAtEnd | function maybeAddEmptyStringAtEnd(elements, items) {
let length = elements.length;
if (!length || elements[length - 1].type !== TEMPLATE_LITERAL_PORTION) {
items.push(createStringLiteralExpression(null, '""'));
}
} | javascript | function maybeAddEmptyStringAtEnd(elements, items) {
let length = elements.length;
if (!length || elements[length - 1].type !== TEMPLATE_LITERAL_PORTION) {
items.push(createStringLiteralExpression(null, '""'));
}
} | [
"function",
"maybeAddEmptyStringAtEnd",
"(",
"elements",
",",
"items",
")",
"{",
"let",
"length",
"=",
"elements",
".",
"length",
";",
"if",
"(",
"!",
"length",
"||",
"elements",
"[",
"length",
"-",
"1",
"]",
".",
"type",
"!==",
"TEMPLATE_LITERAL_PORTION",
... | Adds an empty string at the end if needed. This is needed in case the
template literal does not end with a literal portion.
@param {Array<ParseTree>} elements
@param {Array<ParseTree>} items This is the array that gets mutated. | [
"Adds",
"an",
"empty",
"string",
"at",
"the",
"end",
"if",
"needed",
".",
"This",
"is",
"needed",
"in",
"case",
"the",
"template",
"literal",
"does",
"not",
"end",
"with",
"a",
"literal",
"portion",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/codegeneration/TemplateLiteralTransformer.js#L107-L112 | train |
google/traceur-compiler | src/codegeneration/TemplateLiteralTransformer.js | toCookedString | function toCookedString(s) {
let sb = ['"'];
let i = 0, k = 1, c, c2;
while (i < s.length) {
c = s[i++];
switch (c) {
case '\\':
c2 = s[i++];
switch (c2) {
// Strip line continuation.
case '\n':
case '\u2028':
case '\u2029':
break;
... | javascript | function toCookedString(s) {
let sb = ['"'];
let i = 0, k = 1, c, c2;
while (i < s.length) {
c = s[i++];
switch (c) {
case '\\':
c2 = s[i++];
switch (c2) {
// Strip line continuation.
case '\n':
case '\u2028':
case '\u2029':
break;
... | [
"function",
"toCookedString",
"(",
"s",
")",
"{",
"let",
"sb",
"=",
"[",
"'\"'",
"]",
";",
"let",
"i",
"=",
"0",
",",
"k",
"=",
"1",
",",
"c",
",",
"c2",
";",
"while",
"(",
"i",
"<",
"s",
".",
"length",
")",
"{",
"c",
"=",
"s",
"[",
"i",
... | Takes a raw string and returns a string that is suitable for the cooked
value. This involves removing line continuations, escaping double quotes
and escaping whitespace.
@param {string} s
@return {string} | [
"Takes",
"a",
"raw",
"string",
"and",
"returns",
"a",
"string",
"that",
"is",
"suitable",
"for",
"the",
"cooked",
"value",
".",
"This",
"involves",
"removing",
"line",
"continuations",
"escaping",
"double",
"quotes",
"and",
"escaping",
"whitespace",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/src/codegeneration/TemplateLiteralTransformer.js#L138-L204 | train |
google/traceur-compiler | demo/repl.js | setDebugLevel | function setDebugLevel(level, printf) {
var outLevel = 0;
debug = debug2 = debug3 = debugTree = function() {};
switch (String(level)) {
case '3':
debug3 = printf;
outLevel++;
// fall through
case '2':
debugTree = function (fmt, tree) {
printf(fmt, util.inspect(tree.toJSON... | javascript | function setDebugLevel(level, printf) {
var outLevel = 0;
debug = debug2 = debug3 = debugTree = function() {};
switch (String(level)) {
case '3':
debug3 = printf;
outLevel++;
// fall through
case '2':
debugTree = function (fmt, tree) {
printf(fmt, util.inspect(tree.toJSON... | [
"function",
"setDebugLevel",
"(",
"level",
",",
"printf",
")",
"{",
"var",
"outLevel",
"=",
"0",
";",
"debug",
"=",
"debug2",
"=",
"debug3",
"=",
"debugTree",
"=",
"function",
"(",
")",
"{",
"}",
";",
"switch",
"(",
"String",
"(",
"level",
")",
")",
... | Selectively enables and disables the debug functions.
@param {number|string} level The debug level to set (0-3).
@param {function} printf The printf-style function to use.
@return {number} The level that was set. | [
"Selectively",
"enables",
"and",
"disables",
"the",
"debug",
"functions",
"."
] | caa7b751d5150622e13cdd18865e09681d8c6691 | https://github.com/google/traceur-compiler/blob/caa7b751d5150622e13cdd18865e09681d8c6691/demo/repl.js#L32-L56 | train |
jaames/iro.js | dist/iro.es.js | usePlugins | function usePlugins(core) {
var installedPlugins = [];
/**
* @desc Register iro.js plugin
* @param {Function} plugin = plugin constructor
* @param {Object} pluginOptions = plugin options passed to constructor
*/
core.use = function(plugin, pluginOptions) {
if ( pluginOptions === void 0 ) plugin... | javascript | function usePlugins(core) {
var installedPlugins = [];
/**
* @desc Register iro.js plugin
* @param {Function} plugin = plugin constructor
* @param {Object} pluginOptions = plugin options passed to constructor
*/
core.use = function(plugin, pluginOptions) {
if ( pluginOptions === void 0 ) plugin... | [
"function",
"usePlugins",
"(",
"core",
")",
"{",
"var",
"installedPlugins",
"=",
"[",
"]",
";",
"/**\n * @desc Register iro.js plugin\n * @param {Function} plugin = plugin constructor\n * @param {Object} pluginOptions = plugin options passed to constructor\n */",
"core",
".",
"... | iro.js plugins API
This provides the iro.use method, which can be used to register plugins which extend the iro.js core | [
"iro",
".",
"js",
"plugins",
"API",
"This",
"provides",
"the",
"iro",
".",
"use",
"method",
"which",
"can",
"be",
"used",
"to",
"register",
"plugins",
"which",
"extend",
"the",
"iro",
".",
"js",
"core"
] | 6d193f0e68fbf9cac6b850ddbc87abfac28bdd7a | https://github.com/jaames/iro.js/blob/6d193f0e68fbf9cac6b850ddbc87abfac28bdd7a/dist/iro.es.js#L1778-L1802 | train |
vpulim/node-soap | soap-stub.js | createClient | function createClient(wsdlUrl, options, cb) {
if (!cb) {
cb = options;
options = {};
}
if (this.errOnCreateClient) {
return setTimeout(cb.bind(null, new Error('forced error on createClient')));
}
var client = getStub(wsdlUrl);
if (client) {
resetStubbedMethods(client);
setTimeout(cb.b... | javascript | function createClient(wsdlUrl, options, cb) {
if (!cb) {
cb = options;
options = {};
}
if (this.errOnCreateClient) {
return setTimeout(cb.bind(null, new Error('forced error on createClient')));
}
var client = getStub(wsdlUrl);
if (client) {
resetStubbedMethods(client);
setTimeout(cb.b... | [
"function",
"createClient",
"(",
"wsdlUrl",
",",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"this",
".",
"errOnCreateClient",
")",
"{",
"return",
"setTim... | Return a stubbed client based on the value of wsdlUrl.
@throws if wsdlUrl is unknown.
@param {String} wsdlUrl
@param {Object} options
@param {Function} cb
@return {Object} | [
"Return",
"a",
"stubbed",
"client",
"based",
"on",
"the",
"value",
"of",
"wsdlUrl",
"."
] | b0891343da75ab1b31d539812d5f3fb3a89ea15c | https://github.com/vpulim/node-soap/blob/b0891343da75ab1b31d539812d5f3fb3a89ea15c/soap-stub.js#L42-L60 | train |
vpulim/node-soap | soap-stub.js | createErroringStub | function createErroringStub(err) {
return function() {
this.args.forEach(function(argSet) {
setTimeout(argSet[1].bind(null, err));
});
this.yields(err);
};
} | javascript | function createErroringStub(err) {
return function() {
this.args.forEach(function(argSet) {
setTimeout(argSet[1].bind(null, err));
});
this.yields(err);
};
} | [
"function",
"createErroringStub",
"(",
"err",
")",
"{",
"return",
"function",
"(",
")",
"{",
"this",
".",
"args",
".",
"forEach",
"(",
"function",
"(",
"argSet",
")",
"{",
"setTimeout",
"(",
"argSet",
"[",
"1",
"]",
".",
"bind",
"(",
"null",
",",
"er... | Returns a method that calls all callbacks given to the method it is attached
to with the given error.
<pre>
myClientStub.someMethod.errorOnCall = createErroringStub(error);
// elsewhere
myClientStub.someMethod.errorOnCall();
</pre>
@param {?} object anything
@return {Function} | [
"Returns",
"a",
"method",
"that",
"calls",
"all",
"callbacks",
"given",
"to",
"the",
"method",
"it",
"is",
"attached",
"to",
"with",
"the",
"given",
"error",
"."
] | b0891343da75ab1b31d539812d5f3fb3a89ea15c | https://github.com/vpulim/node-soap/blob/b0891343da75ab1b31d539812d5f3fb3a89ea15c/soap-stub.js#L77-L84 | train |
vpulim/node-soap | soap-stub.js | createRespondingStub | function createRespondingStub(object, body) {
return function() {
this.args.forEach(function(argSet) {
setTimeout(argSet[1].bind(null, null, object));
});
this.yields(null, object, body);
};
} | javascript | function createRespondingStub(object, body) {
return function() {
this.args.forEach(function(argSet) {
setTimeout(argSet[1].bind(null, null, object));
});
this.yields(null, object, body);
};
} | [
"function",
"createRespondingStub",
"(",
"object",
",",
"body",
")",
"{",
"return",
"function",
"(",
")",
"{",
"this",
".",
"args",
".",
"forEach",
"(",
"function",
"(",
"argSet",
")",
"{",
"setTimeout",
"(",
"argSet",
"[",
"1",
"]",
".",
"bind",
"(",
... | Returns a method that calls all callbacks given to the method it is attached
to with the given response.
<pre>
myClientStub.someMethod.respondWithError = createRespondingStub(errorResponse);
// elsewhere
myClientStub.someMethod.respondWithError();
</pre>
@param {?} object anything
@return {Function} | [
"Returns",
"a",
"method",
"that",
"calls",
"all",
"callbacks",
"given",
"to",
"the",
"method",
"it",
"is",
"attached",
"to",
"with",
"the",
"given",
"response",
"."
] | b0891343da75ab1b31d539812d5f3fb3a89ea15c | https://github.com/vpulim/node-soap/blob/b0891343da75ab1b31d539812d5f3fb3a89ea15c/soap-stub.js#L101-L108 | train |
vpulim/node-soap | soap-stub.js | registerClient | function registerClient(alias, urlToWsdl, clientStub) {
aliasedClientStubs[alias] = clientStub;
clientStubs[urlToWsdl] = clientStub;
} | javascript | function registerClient(alias, urlToWsdl, clientStub) {
aliasedClientStubs[alias] = clientStub;
clientStubs[urlToWsdl] = clientStub;
} | [
"function",
"registerClient",
"(",
"alias",
",",
"urlToWsdl",
",",
"clientStub",
")",
"{",
"aliasedClientStubs",
"[",
"alias",
"]",
"=",
"clientStub",
";",
"clientStubs",
"[",
"urlToWsdl",
"]",
"=",
"clientStub",
";",
"}"
] | Registers a stubbed client with soap-stub. urlToWsdl is the path you will use
in your app.
@param {String} alias A simple name to refer to the clientStub as.
@param {String} urlToWsdl May be file system URL or http URL.
@param {Object} clientStub A client with stubbed methods. | [
"Registers",
"a",
"stubbed",
"client",
"with",
"soap",
"-",
"stub",
".",
"urlToWsdl",
"is",
"the",
"path",
"you",
"will",
"use",
"in",
"your",
"app",
"."
] | b0891343da75ab1b31d539812d5f3fb3a89ea15c | https://github.com/vpulim/node-soap/blob/b0891343da75ab1b31d539812d5f3fb3a89ea15c/soap-stub.js#L118-L121 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | loadMode | function loadMode(cm) {
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
cm.doc.iter(function(line) {
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
});
cm.doc.frontier = cm.doc.first;
startWorker(cm, 100);
cm.state.modeGen++;
if... | javascript | function loadMode(cm) {
cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
cm.doc.iter(function(line) {
if (line.stateAfter) line.stateAfter = null;
if (line.styles) line.styles = null;
});
cm.doc.frontier = cm.doc.first;
startWorker(cm, 100);
cm.state.modeGen++;
if... | [
"function",
"loadMode",
"(",
"cm",
")",
"{",
"cm",
".",
"doc",
".",
"mode",
"=",
"CodeMirror",
".",
"getMode",
"(",
"cm",
".",
"options",
",",
"cm",
".",
"doc",
".",
"modeOption",
")",
";",
"cm",
".",
"doc",
".",
"iter",
"(",
"function",
"(",
"li... | STATE UPDATES Used to get the editor into a consistent state again when options change. | [
"STATE",
"UPDATES",
"Used",
"to",
"get",
"the",
"editor",
"into",
"a",
"consistent",
"state",
"again",
"when",
"options",
"change",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L195-L205 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | setGuttersForLineNumbers | function setGuttersForLineNumbers(options) {
var found = false;
for (var i = 0; i < options.gutters.length; ++i) {
if (options.gutters[i] == "CodeMirror-linenumbers") {
if (options.lineNumbers) found = true;
else options.gutters.splice(i--, 1);
}
}
if (!found && options.lineN... | javascript | function setGuttersForLineNumbers(options) {
var found = false;
for (var i = 0; i < options.gutters.length; ++i) {
if (options.gutters[i] == "CodeMirror-linenumbers") {
if (options.lineNumbers) found = true;
else options.gutters.splice(i--, 1);
}
}
if (!found && options.lineN... | [
"function",
"setGuttersForLineNumbers",
"(",
"options",
")",
"{",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"gutters",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"options",
".",
"gu... | Make sure the gutters options contains the element "CodeMirror-linenumbers" when the lineNumbers option is true. | [
"Make",
"sure",
"the",
"gutters",
"options",
"contains",
"the",
"element",
"CodeMirror",
"-",
"linenumbers",
"when",
"the",
"lineNumbers",
"option",
"is",
"true",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L309-L319 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | updateScrollbars | function updateScrollbars(cm) {
var d = cm.display, docHeight = cm.doc.height;
var totalHeight = docHeight + paddingVert(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
var s... | javascript | function updateScrollbars(cm) {
var d = cm.display, docHeight = cm.doc.height;
var totalHeight = docHeight + paddingVert(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px";
var s... | [
"function",
"updateScrollbars",
"(",
"cm",
")",
"{",
"var",
"d",
"=",
"cm",
".",
"display",
",",
"docHeight",
"=",
"cm",
".",
"doc",
".",
"height",
";",
"var",
"totalHeight",
"=",
"docHeight",
"+",
"paddingVert",
"(",
"d",
")",
";",
"d",
".",
"sizer"... | Re-synchronize the fake scrollbars with the actual size of the content. Optionally force a scrollTop. | [
"Re",
"-",
"synchronize",
"the",
"fake",
"scrollbars",
"with",
"the",
"actual",
"size",
"of",
"the",
"content",
".",
"Optionally",
"force",
"a",
"scrollTop",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L325-L357 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | updateSelectionCursor | function updateSelectionCursor(cm) {
var display = cm.display, pos = cursorCoords(cm, cm.doc.sel.head, "div");
display.cursor.style.left = pos.left + "px";
display.cursor.style.top = pos.top + "px";
display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
dis... | javascript | function updateSelectionCursor(cm) {
var display = cm.display, pos = cursorCoords(cm, cm.doc.sel.head, "div");
display.cursor.style.left = pos.left + "px";
display.cursor.style.top = pos.top + "px";
display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
dis... | [
"function",
"updateSelectionCursor",
"(",
"cm",
")",
"{",
"var",
"display",
"=",
"cm",
".",
"display",
",",
"pos",
"=",
"cursorCoords",
"(",
"cm",
",",
"cm",
".",
"doc",
".",
"sel",
".",
"head",
",",
"\"div\"",
")",
";",
"display",
".",
"cursor",
"."... | No selection, plain cursor | [
"No",
"selection",
"plain",
"cursor"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L783-L796 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | operation | function operation(cm1, f) {
return function() {
var cm = cm1 || this, withOp = !cm.curOp;
if (withOp) startOperation(cm);
try { var result = f.apply(cm, arguments); }
finally { if (withOp) endOperation(cm); }
return result;
};
} | javascript | function operation(cm1, f) {
return function() {
var cm = cm1 || this, withOp = !cm.curOp;
if (withOp) startOperation(cm);
try { var result = f.apply(cm, arguments); }
finally { if (withOp) endOperation(cm); }
return result;
};
} | [
"function",
"operation",
"(",
"cm1",
",",
"f",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"cm",
"=",
"cm1",
"||",
"this",
",",
"withOp",
"=",
"!",
"cm",
".",
"curOp",
";",
"if",
"(",
"withOp",
")",
"startOperation",
"(",
"cm",
")",
";"... | Wraps a function in an operation. Returns the wrapped function. | [
"Wraps",
"a",
"function",
"in",
"an",
"operation",
".",
"Returns",
"the",
"wrapped",
"function",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L1387-L1395 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | unregister | function unregister() {
for (var p = d.wrapper.parentNode; p && p != document.body; p = p.parentNode) {}
if (p) setTimeout(unregister, 5000);
else off(window, "resize", onResize);
} | javascript | function unregister() {
for (var p = d.wrapper.parentNode; p && p != document.body; p = p.parentNode) {}
if (p) setTimeout(unregister, 5000);
else off(window, "resize", onResize);
} | [
"function",
"unregister",
"(",
")",
"{",
"for",
"(",
"var",
"p",
"=",
"d",
".",
"wrapper",
".",
"parentNode",
";",
"p",
"&&",
"p",
"!=",
"document",
".",
"body",
";",
"p",
"=",
"p",
".",
"parentNode",
")",
"{",
"}",
"if",
"(",
"p",
")",
"setTim... | Above handler holds on to the editor and its data structures. Here we poll to unregister it when the editor is no longer in the document, so that it can be garbage-collected. | [
"Above",
"handler",
"holds",
"on",
"to",
"the",
"editor",
"and",
"its",
"data",
"structures",
".",
"Here",
"we",
"poll",
"to",
"unregister",
"it",
"when",
"the",
"editor",
"is",
"no",
"longer",
"in",
"the",
"document",
"so",
"that",
"it",
"can",
"be",
... | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L1567-L1571 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | clipPostChange | function clipPostChange(doc, change, pos) {
if (!posLess(change.from, pos)) return clipPos(doc, pos);
var diff = (change.text.length - 1) - (change.to.line - change.from.line);
if (pos.line > change.to.line + diff) {
var preLine = pos.line - diff, lastLine = doc.first + doc.size - 1;
if (preLine... | javascript | function clipPostChange(doc, change, pos) {
if (!posLess(change.from, pos)) return clipPos(doc, pos);
var diff = (change.text.length - 1) - (change.to.line - change.from.line);
if (pos.line > change.to.line + diff) {
var preLine = pos.line - diff, lastLine = doc.first + doc.size - 1;
if (preLine... | [
"function",
"clipPostChange",
"(",
"doc",
",",
"change",
",",
"pos",
")",
"{",
"if",
"(",
"!",
"posLess",
"(",
"change",
".",
"from",
",",
"pos",
")",
")",
"return",
"clipPos",
"(",
"doc",
",",
"pos",
")",
";",
"var",
"diff",
"=",
"(",
"change",
... | Make sure a position will be valid after the given change. | [
"Make",
"sure",
"a",
"position",
"will",
"be",
"valid",
"after",
"the",
"given",
"change",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L2189-L2202 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | function(pos) {
if (posLess(pos, change.from)) return pos;
if (!posLess(change.to, pos)) return end;
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
if (pos.line == change.to.line) ch += end.ch - change.to.ch;
return Pos(line, ch);
} | javascript | function(pos) {
if (posLess(pos, change.from)) return pos;
if (!posLess(change.to, pos)) return end;
var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
if (pos.line == change.to.line) ch += end.ch - change.to.ch;
return Pos(line, ch);
} | [
"function",
"(",
"pos",
")",
"{",
"if",
"(",
"posLess",
"(",
"pos",
",",
"change",
".",
"from",
")",
")",
"return",
"pos",
";",
"if",
"(",
"!",
"posLess",
"(",
"change",
".",
"to",
",",
"pos",
")",
")",
"return",
"end",
";",
"var",
"line",
"=",... | hint is null, leave the selection alone as much as possible | [
"hint",
"is",
"null",
"leave",
"the",
"selection",
"alone",
"as",
"much",
"as",
"possible"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L2217-L2224 | train | |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | extendSelection | function extendSelection(doc, pos, other, bias) {
if (doc.sel.shift || doc.sel.extend) {
var anchor = doc.sel.anchor;
if (other) {
var posBefore = posLess(pos, anchor);
if (posBefore != posLess(other, anchor)) {
anchor = pos;
pos = other;
} else if (posBefore ... | javascript | function extendSelection(doc, pos, other, bias) {
if (doc.sel.shift || doc.sel.extend) {
var anchor = doc.sel.anchor;
if (other) {
var posBefore = posLess(pos, anchor);
if (posBefore != posLess(other, anchor)) {
anchor = pos;
pos = other;
} else if (posBefore ... | [
"function",
"extendSelection",
"(",
"doc",
",",
"pos",
",",
"other",
",",
"bias",
")",
"{",
"if",
"(",
"doc",
".",
"sel",
".",
"shift",
"||",
"doc",
".",
"sel",
".",
"extend",
")",
"{",
"var",
"anchor",
"=",
"doc",
".",
"sel",
".",
"anchor",
";",... | If shift is held, this will move the selection anchor. Otherwise, it'll set the whole selection. | [
"If",
"shift",
"is",
"held",
"this",
"will",
"move",
"the",
"selection",
"anchor",
".",
"Otherwise",
"it",
"ll",
"set",
"the",
"whole",
"selection",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L2460-L2477 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | setSelection | function setSelection(doc, anchor, head, bias, checkAtomic) {
if (!checkAtomic && hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) {
var filtered = filterSelectionChange(doc, anchor, head);
head = filtered.head;
anchor = filtered.anchor;
}
... | javascript | function setSelection(doc, anchor, head, bias, checkAtomic) {
if (!checkAtomic && hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) {
var filtered = filterSelectionChange(doc, anchor, head);
head = filtered.head;
anchor = filtered.anchor;
}
... | [
"function",
"setSelection",
"(",
"doc",
",",
"anchor",
",",
"head",
",",
"bias",
",",
"checkAtomic",
")",
"{",
"if",
"(",
"!",
"checkAtomic",
"&&",
"hasHandler",
"(",
"doc",
",",
"\"beforeSelectionChange\"",
")",
"||",
"doc",
".",
"cm",
"&&",
"hasHandler",... | Update the selection. Last two args are only used by updateDoc, since they have to be expressed in the line numbers before the update. | [
"Update",
"the",
"selection",
".",
"Last",
"two",
"args",
"are",
"only",
"used",
"by",
"updateDoc",
"since",
"they",
"have",
"to",
"be",
"expressed",
"in",
"the",
"line",
"numbers",
"before",
"the",
"update",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L2490-L2517 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | StringStream | function StringStream(string, tabSize) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
} | javascript | function StringStream(string, tabSize) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
} | [
"function",
"StringStream",
"(",
"string",
",",
"tabSize",
")",
"{",
"this",
".",
"pos",
"=",
"this",
".",
"start",
"=",
"0",
";",
"this",
".",
"string",
"=",
"string",
";",
"this",
".",
"tabSize",
"=",
"tabSize",
"||",
"8",
";",
"this",
".",
"last... | Fed to the mode parsers, provides helper functions to make parsers more succinct. The character stream used by a mode's parser. | [
"Fed",
"to",
"the",
"mode",
"parsers",
"provides",
"helper",
"functions",
"to",
"make",
"parsers",
"more",
"succinct",
".",
"The",
"character",
"stream",
"used",
"by",
"a",
"mode",
"s",
"parser",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L3605-L3610 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | copyHistoryArray | function copyHistoryArray(events, newGroup) {
for (var i = 0, copy = []; i < events.length; ++i) {
var event = events[i], changes = event.changes, newChanges = [];
copy.push({changes: newChanges, anchorBefore: event.anchorBefore, headBefore: event.headBefore,
anchorAfter: event.anchorAf... | javascript | function copyHistoryArray(events, newGroup) {
for (var i = 0, copy = []; i < events.length; ++i) {
var event = events[i], changes = event.changes, newChanges = [];
copy.push({changes: newChanges, anchorBefore: event.anchorBefore, headBefore: event.headBefore,
anchorAfter: event.anchorAf... | [
"function",
"copyHistoryArray",
"(",
"events",
",",
"newGroup",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"copy",
"=",
"[",
"]",
";",
"i",
"<",
"events",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"event",
"=",
"events",
"[",
"i",
"... | Used both to provide a JSON-safe object in .getHistory, and, when detaching a document, to split the history in two | [
"Used",
"both",
"to",
"provide",
"a",
"JSON",
"-",
"safe",
"object",
"in",
".",
"getHistory",
"and",
"when",
"detaching",
"a",
"document",
"to",
"split",
"the",
"history",
"in",
"two"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L5102-L5119 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | countColumn | function countColumn(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) end = string.length;
}
for (var i = startIndex || 0, n = startValue || 0; i < end; ++i) {
if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
... | javascript | function countColumn(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) end = string.length;
}
for (var i = startIndex || 0, n = startValue || 0; i < end; ++i) {
if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
... | [
"function",
"countColumn",
"(",
"string",
",",
"end",
",",
"tabSize",
",",
"startIndex",
",",
"startValue",
")",
"{",
"if",
"(",
"end",
"==",
"null",
")",
"{",
"end",
"=",
"string",
".",
"search",
"(",
"/",
"[^\\s\\u00a0]",
"/",
")",
";",
"if",
"(",
... | Counts the column offset in a string, taking tabs into account. Used mostly to find indentation. | [
"Counts",
"the",
"column",
"offset",
"in",
"a",
"string",
"taking",
"tabs",
"into",
"account",
".",
"Used",
"mostly",
"to",
"find",
"indentation",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L5298-L5308 | train |
gilbitron/Raneto | themes/default/public/scripts/ghostdown.js | updateWordCount | function updateWordCount() {
var wordCount = document.getElementsByClassName('entry-word-count')[0],
editorValue = editor.getValue();
if (editorValue.length) {
wordCount.innerHTML = editorValue.match(/\S+/g).length + ' words';
}
} | javascript | function updateWordCount() {
var wordCount = document.getElementsByClassName('entry-word-count')[0],
editorValue = editor.getValue();
if (editorValue.length) {
wordCount.innerHTML = editorValue.match(/\S+/g).length + ' words';
}
} | [
"function",
"updateWordCount",
"(",
")",
"{",
"var",
"wordCount",
"=",
"document",
".",
"getElementsByClassName",
"(",
"'entry-word-count'",
")",
"[",
"0",
"]",
",",
"editorValue",
"=",
"editor",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"editorValue",
".",... | Really not the best way to do things as it includes Markdown formatting along with words | [
"Really",
"not",
"the",
"best",
"way",
"to",
"do",
"things",
"as",
"it",
"includes",
"Markdown",
"formatting",
"along",
"with",
"words"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/themes/default/public/scripts/ghostdown.js#L6356-L6363 | train |
gilbitron/Raneto | app/middleware/oauth2.js | function (req, res, next) {
if (req.query.return) {
req.session.oauth2return = req.query.return;
}
next();
} | javascript | function (req, res, next) {
if (req.query.return) {
req.session.oauth2return = req.query.return;
}
next();
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"req",
".",
"query",
".",
"return",
")",
"{",
"req",
".",
"session",
".",
"oauth2return",
"=",
"req",
".",
"query",
".",
"return",
";",
"}",
"next",
"(",
")",
";",
"}"
] | Save the url of the user's current page so the app can redirect back to it after authorization | [
"Save",
"the",
"url",
"of",
"the",
"user",
"s",
"current",
"page",
"so",
"the",
"app",
"can",
"redirect",
"back",
"to",
"it",
"after",
"authorization"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/middleware/oauth2.js#L108-L113 | train | |
gilbitron/Raneto | app/middleware/oauth2.js | function (req, res) {
req.session.loggedIn = true;
if (config.oauth2.validateHostedDomain) {
req.session.allowedDomain = config.oauth2.hostedDomain;
}
var redirect = req.session.oauth2return || '/';
delete req.session.oauth2return;
res.redirect(redirect);
} | javascript | function (req, res) {
req.session.loggedIn = true;
if (config.oauth2.validateHostedDomain) {
req.session.allowedDomain = config.oauth2.hostedDomain;
}
var redirect = req.session.oauth2return || '/';
delete req.session.oauth2return;
res.redirect(redirect);
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"session",
".",
"loggedIn",
"=",
"true",
";",
"if",
"(",
"config",
".",
"oauth2",
".",
"validateHostedDomain",
")",
"{",
"req",
".",
"session",
".",
"allowedDomain",
"=",
"config",
".",
"oauth2"... | Redirect back to the original page, if any | [
"Redirect",
"back",
"to",
"the",
"original",
"page",
"if",
"any"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/middleware/oauth2.js#L130-L138 | train | |
gilbitron/Raneto | app/functions/contentProcessors.js | cleanObjectStrings | function cleanObjectStrings (obj) {
let cleanObj = {};
for (let field in obj) {
if (obj.hasOwnProperty(field)) {
cleanObj[cleanString(field, true)] = ('' + obj[field]).trim();
}
}
return cleanObj;
} | javascript | function cleanObjectStrings (obj) {
let cleanObj = {};
for (let field in obj) {
if (obj.hasOwnProperty(field)) {
cleanObj[cleanString(field, true)] = ('' + obj[field]).trim();
}
}
return cleanObj;
} | [
"function",
"cleanObjectStrings",
"(",
"obj",
")",
"{",
"let",
"cleanObj",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"field",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"field",
")",
")",
"{",
"cleanObj",
"[",
"cleanString",
"(... | Clean object strings. | [
"Clean",
"object",
"strings",
"."
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/contentProcessors.js#L32-L40 | train |
gilbitron/Raneto | app/functions/contentProcessors.js | slugToTitle | function slugToTitle (slug) {
slug = slug.replace('.md', '').trim();
return _s.titleize(_s.humanize(path.basename(slug)));
} | javascript | function slugToTitle (slug) {
slug = slug.replace('.md', '').trim();
return _s.titleize(_s.humanize(path.basename(slug)));
} | [
"function",
"slugToTitle",
"(",
"slug",
")",
"{",
"slug",
"=",
"slug",
".",
"replace",
"(",
"'.md'",
",",
"''",
")",
".",
"trim",
"(",
")",
";",
"return",
"_s",
".",
"titleize",
"(",
"_s",
".",
"humanize",
"(",
"path",
".",
"basename",
"(",
"slug",... | Convert a slug to a title | [
"Convert",
"a",
"slug",
"to",
"a",
"title"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/contentProcessors.js#L43-L46 | train |
gilbitron/Raneto | app/functions/contentProcessors.js | stripMeta | function stripMeta (markdownContent) {
switch (true) {
case _metaRegex.test(markdownContent):
return markdownContent.replace(_metaRegex, '').trim();
case _metaRegexYaml.test(markdownContent):
return markdownContent.replace(_metaRegexYaml, '').trim();
default:
return markdownContent.trim(... | javascript | function stripMeta (markdownContent) {
switch (true) {
case _metaRegex.test(markdownContent):
return markdownContent.replace(_metaRegex, '').trim();
case _metaRegexYaml.test(markdownContent):
return markdownContent.replace(_metaRegexYaml, '').trim();
default:
return markdownContent.trim(... | [
"function",
"stripMeta",
"(",
"markdownContent",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"_metaRegex",
".",
"test",
"(",
"markdownContent",
")",
":",
"return",
"markdownContent",
".",
"replace",
"(",
"_metaRegex",
",",
"''",
")",
".",
"trim",
"(... | Strip meta from Markdown content | [
"Strip",
"meta",
"from",
"Markdown",
"content"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/contentProcessors.js#L49-L58 | train |
gilbitron/Raneto | app/functions/contentProcessors.js | processMeta | function processMeta (markdownContent) {
let meta = {};
let metaArr;
let metaString;
let metas;
let yamlObject;
switch (true) {
case _metaRegex.test(markdownContent):
metaArr = markdownContent.match(_metaRegex);
metaString = metaArr ? metaArr[1].trim() : '';
if (metaString) {
... | javascript | function processMeta (markdownContent) {
let meta = {};
let metaArr;
let metaString;
let metas;
let yamlObject;
switch (true) {
case _metaRegex.test(markdownContent):
metaArr = markdownContent.match(_metaRegex);
metaString = metaArr ? metaArr[1].trim() : '';
if (metaString) {
... | [
"function",
"processMeta",
"(",
"markdownContent",
")",
"{",
"let",
"meta",
"=",
"{",
"}",
";",
"let",
"metaArr",
";",
"let",
"metaString",
";",
"let",
"metas",
";",
"let",
"yamlObject",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"_metaRegex",
".",
... | Get meta information from Markdown content | [
"Get",
"meta",
"information",
"from",
"Markdown",
"content"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/contentProcessors.js#L61-L97 | train |
gilbitron/Raneto | app/functions/contentProcessors.js | processVars | function processVars (markdownContent, config) {
if (config.variables && Array.isArray(config.variables)) {
config.variables.forEach((v) => {
markdownContent = markdownContent.replace(new RegExp('%' + v.name + '%', 'g'), v.content);
});
}
if (config.base_url) {
markdownContent = markdownContent.... | javascript | function processVars (markdownContent, config) {
if (config.variables && Array.isArray(config.variables)) {
config.variables.forEach((v) => {
markdownContent = markdownContent.replace(new RegExp('%' + v.name + '%', 'g'), v.content);
});
}
if (config.base_url) {
markdownContent = markdownContent.... | [
"function",
"processVars",
"(",
"markdownContent",
",",
"config",
")",
"{",
"if",
"(",
"config",
".",
"variables",
"&&",
"Array",
".",
"isArray",
"(",
"config",
".",
"variables",
")",
")",
"{",
"config",
".",
"variables",
".",
"forEach",
"(",
"(",
"v",
... | Replace content variables in Markdown content | [
"Replace",
"content",
"variables",
"in",
"Markdown",
"content"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/contentProcessors.js#L100-L113 | train |
gilbitron/Raneto | app/functions/create_meta_info.js | create_meta_info | function create_meta_info (meta_title, meta_description, meta_sort) {
var yamlDocument = {};
var meta_info_is_present = meta_title || meta_description || meta_sort;
if (meta_info_is_present) {
if (meta_title) { yamlDocument.Title = meta_title; }
if (meta_description) { yamlDocum... | javascript | function create_meta_info (meta_title, meta_description, meta_sort) {
var yamlDocument = {};
var meta_info_is_present = meta_title || meta_description || meta_sort;
if (meta_info_is_present) {
if (meta_title) { yamlDocument.Title = meta_title; }
if (meta_description) { yamlDocum... | [
"function",
"create_meta_info",
"(",
"meta_title",
",",
"meta_description",
",",
"meta_sort",
")",
"{",
"var",
"yamlDocument",
"=",
"{",
"}",
";",
"var",
"meta_info_is_present",
"=",
"meta_title",
"||",
"meta_description",
"||",
"meta_sort",
";",
"if",
"(",
"met... | Returns an empty string if all input strings are empty | [
"Returns",
"an",
"empty",
"string",
"if",
"all",
"input",
"strings",
"are",
"empty"
] | b142a33948bb0e29c77f49bebac6b58f40a4255f | https://github.com/gilbitron/Raneto/blob/b142a33948bb0e29c77f49bebac6b58f40a4255f/app/functions/create_meta_info.js#L8-L23 | train |
jnordberg/gif.js | src/LZWEncoder.js | cl_block | function cl_block(outs) {
cl_hash(HSIZE);
free_ent = ClearCode + 2;
clear_flg = true;
output(ClearCode, outs);
} | javascript | function cl_block(outs) {
cl_hash(HSIZE);
free_ent = ClearCode + 2;
clear_flg = true;
output(ClearCode, outs);
} | [
"function",
"cl_block",
"(",
"outs",
")",
"{",
"cl_hash",
"(",
"HSIZE",
")",
";",
"free_ent",
"=",
"ClearCode",
"+",
"2",
";",
"clear_flg",
"=",
"true",
";",
"output",
"(",
"ClearCode",
",",
"outs",
")",
";",
"}"
] | Clear out the hash table table clear for block compress | [
"Clear",
"out",
"the",
"hash",
"table",
"table",
"clear",
"for",
"block",
"compress"
] | a2201f123ed9e5582e57c3d15f5df00c0b8367bd | https://github.com/jnordberg/gif.js/blob/a2201f123ed9e5582e57c3d15f5df00c0b8367bd/src/LZWEncoder.js#L68-L73 | train |
jnordberg/gif.js | src/LZWEncoder.js | flush_char | function flush_char(outs) {
if (a_count > 0) {
outs.writeByte(a_count);
outs.writeBytes(accum, 0, a_count);
a_count = 0;
}
} | javascript | function flush_char(outs) {
if (a_count > 0) {
outs.writeByte(a_count);
outs.writeBytes(accum, 0, a_count);
a_count = 0;
}
} | [
"function",
"flush_char",
"(",
"outs",
")",
"{",
"if",
"(",
"a_count",
">",
"0",
")",
"{",
"outs",
".",
"writeByte",
"(",
"a_count",
")",
";",
"outs",
".",
"writeBytes",
"(",
"accum",
",",
"0",
",",
"a_count",
")",
";",
"a_count",
"=",
"0",
";",
... | Flush the packet to disk, and reset the accumulator | [
"Flush",
"the",
"packet",
"to",
"disk",
"and",
"reset",
"the",
"accumulator"
] | a2201f123ed9e5582e57c3d15f5df00c0b8367bd | https://github.com/jnordberg/gif.js/blob/a2201f123ed9e5582e57c3d15f5df00c0b8367bd/src/LZWEncoder.js#L148-L154 | train |
okonet/lint-staged | src/getConfig.js | isSimple | function isSimple(config) {
return (
isObject(config) &&
!config.hasOwnProperty('linters') &&
intersection(Object.keys(defaultConfig), Object.keys(config)).length === 0
)
} | javascript | function isSimple(config) {
return (
isObject(config) &&
!config.hasOwnProperty('linters') &&
intersection(Object.keys(defaultConfig), Object.keys(config)).length === 0
)
} | [
"function",
"isSimple",
"(",
"config",
")",
"{",
"return",
"(",
"isObject",
"(",
"config",
")",
"&&",
"!",
"config",
".",
"hasOwnProperty",
"(",
"'linters'",
")",
"&&",
"intersection",
"(",
"Object",
".",
"keys",
"(",
"defaultConfig",
")",
",",
"Object",
... | Check if the config is "simple" i.e. doesn't contains any of full config keys
@param config
@returns {boolean} | [
"Check",
"if",
"the",
"config",
"is",
"simple",
"i",
".",
"e",
".",
"doesn",
"t",
"contains",
"any",
"of",
"full",
"config",
"keys"
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/getConfig.js#L73-L79 | train |
okonet/lint-staged | src/getConfig.js | unknownValidationReporter | function unknownValidationReporter(config, option) {
/**
* If the unkonwn property is a glob this is probably
* a typical mistake of mixing simple and advanced configs
*/
if (isGlob(option)) {
// prettier-ignore
const message = `You are probably trying to mix simple and advanced config formats. Add... | javascript | function unknownValidationReporter(config, option) {
/**
* If the unkonwn property is a glob this is probably
* a typical mistake of mixing simple and advanced configs
*/
if (isGlob(option)) {
// prettier-ignore
const message = `You are probably trying to mix simple and advanced config formats. Add... | [
"function",
"unknownValidationReporter",
"(",
"config",
",",
"option",
")",
"{",
"/**\n * If the unkonwn property is a glob this is probably\n * a typical mistake of mixing simple and advanced configs\n */",
"if",
"(",
"isGlob",
"(",
"option",
")",
")",
"{",
"// prettier-igno... | Reporter for unknown options
@param config
@param option
@returns {void} | [
"Reporter",
"for",
"unknown",
"options"
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/getConfig.js#L124-L144 | train |
okonet/lint-staged | src/getConfig.js | getConfig | function getConfig(sourceConfig, debugMode) {
debug('Normalizing config')
const config = defaultsDeep(
{}, // Do not mutate sourceConfig!!!
isSimple(sourceConfig) ? { linters: sourceConfig } : sourceConfig,
defaultConfig
)
// Check if renderer is set in sourceConfig and if not, set accordingly to v... | javascript | function getConfig(sourceConfig, debugMode) {
debug('Normalizing config')
const config = defaultsDeep(
{}, // Do not mutate sourceConfig!!!
isSimple(sourceConfig) ? { linters: sourceConfig } : sourceConfig,
defaultConfig
)
// Check if renderer is set in sourceConfig and if not, set accordingly to v... | [
"function",
"getConfig",
"(",
"sourceConfig",
",",
"debugMode",
")",
"{",
"debug",
"(",
"'Normalizing config'",
")",
"const",
"config",
"=",
"defaultsDeep",
"(",
"{",
"}",
",",
"// Do not mutate sourceConfig!!!",
"isSimple",
"(",
"sourceConfig",
")",
"?",
"{",
"... | For a given configuration object that we retrive from .lintstagedrc or package.json
construct a full configuration with all options set.
This is a bit tricky since we support 2 different syntxes: simple and full
For simple config, only the `linters` configuration is provided.
@param {Object} sourceConfig
@returns {{
... | [
"For",
"a",
"given",
"configuration",
"object",
"that",
"we",
"retrive",
"from",
".",
"lintstagedrc",
"or",
"package",
".",
"json",
"construct",
"a",
"full",
"configuration",
"with",
"all",
"options",
"set",
"."
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/getConfig.js#L158-L172 | train |
okonet/lint-staged | src/getConfig.js | validateConfig | function validateConfig(config) {
debug('Validating config')
const deprecatedConfig = {
gitDir: "lint-staged now automatically resolves '.git' directory.",
verbose: `Use the command line flag ${chalk.bold('--debug')} instead.`
}
const errors = []
try {
schema.validateSync(config, { abortEarly: ... | javascript | function validateConfig(config) {
debug('Validating config')
const deprecatedConfig = {
gitDir: "lint-staged now automatically resolves '.git' directory.",
verbose: `Use the command line flag ${chalk.bold('--debug')} instead.`
}
const errors = []
try {
schema.validateSync(config, { abortEarly: ... | [
"function",
"validateConfig",
"(",
"config",
")",
"{",
"debug",
"(",
"'Validating config'",
")",
"const",
"deprecatedConfig",
"=",
"{",
"gitDir",
":",
"\"lint-staged now automatically resolves '.git' directory.\"",
",",
"verbose",
":",
"`",
"${",
"chalk",
".",
"bold",... | Runs config validation. Throws error if the config is not valid.
@param config {Object}
@returns config {Object} | [
"Runs",
"config",
"validation",
".",
"Throws",
"error",
"if",
"the",
"config",
"is",
"not",
"valid",
"."
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/getConfig.js#L179-L224 | train |
okonet/lint-staged | src/resolveTaskFn.js | execLinter | function execLinter(bin, args, execaOptions, pathsToLint) {
const binArgs = args.concat(pathsToLint)
debug('bin:', bin)
debug('args: %O', binArgs)
debug('opts: %o', execaOptions)
return execa(bin, binArgs, { ...execaOptions })
} | javascript | function execLinter(bin, args, execaOptions, pathsToLint) {
const binArgs = args.concat(pathsToLint)
debug('bin:', bin)
debug('args: %O', binArgs)
debug('opts: %o', execaOptions)
return execa(bin, binArgs, { ...execaOptions })
} | [
"function",
"execLinter",
"(",
"bin",
",",
"args",
",",
"execaOptions",
",",
"pathsToLint",
")",
"{",
"const",
"binArgs",
"=",
"args",
".",
"concat",
"(",
"pathsToLint",
")",
"debug",
"(",
"'bin:'",
",",
"bin",
")",
"debug",
"(",
"'args: %O'",
",",
"binA... | Execute the given linter binary with arguments and file paths using execa and
return the promise.
@param {string} bin
@param {Array<string>} args
@param {Object} execaOptions
@param {Array<string>} pathsToLint
@return {Promise} child_process | [
"Execute",
"the",
"given",
"linter",
"binary",
"with",
"arguments",
"and",
"file",
"paths",
"using",
"execa",
"and",
"return",
"the",
"promise",
"."
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/resolveTaskFn.js#L25-L33 | train |
okonet/lint-staged | src/resolveTaskFn.js | makeErr | function makeErr(linter, result, context = {}) {
// Indicate that some linter will fail so we don't update the index with formatting changes
context.hasErrors = true // eslint-disable-line no-param-reassign
const { stdout, stderr, killed, signal } = result
if (killed || (signal && signal !== '')) {
return t... | javascript | function makeErr(linter, result, context = {}) {
// Indicate that some linter will fail so we don't update the index with formatting changes
context.hasErrors = true // eslint-disable-line no-param-reassign
const { stdout, stderr, killed, signal } = result
if (killed || (signal && signal !== '')) {
return t... | [
"function",
"makeErr",
"(",
"linter",
",",
"result",
",",
"context",
"=",
"{",
"}",
")",
"{",
"// Indicate that some linter will fail so we don't update the index with formatting changes",
"context",
".",
"hasErrors",
"=",
"true",
"// eslint-disable-line no-param-reassign",
"... | Create a failure message dependding on process result.
@param {string} linter
@param {Object} result
@param {string} result.stdout
@param {string} result.stderr
@param {boolean} result.failed
@param {boolean} result.killed
@param {string} result.signal
@param {Object} context (see https://github.com/SamVerschueren/lis... | [
"Create",
"a",
"failure",
"message",
"dependding",
"on",
"process",
"result",
"."
] | 098452423fd3cdc4d80f861d330d64bc82f7bbaf | https://github.com/okonet/lint-staged/blob/098452423fd3cdc4d80f861d330d64bc82f7bbaf/src/resolveTaskFn.js#L65-L80 | train |
oliviertassinari/react-swipeable-views | packages/react-swipeable-views-core/src/mod.js | mod | function mod(n, m) {
const q = n % m;
return q < 0 ? q + m : q;
} | javascript | function mod(n, m) {
const q = n % m;
return q < 0 ? q + m : q;
} | [
"function",
"mod",
"(",
"n",
",",
"m",
")",
"{",
"const",
"q",
"=",
"n",
"%",
"m",
";",
"return",
"q",
"<",
"0",
"?",
"q",
"+",
"m",
":",
"q",
";",
"}"
] | Extended version of % with negative integer support. | [
"Extended",
"version",
"of",
"%",
"with",
"negative",
"integer",
"support",
"."
] | 400a004ef2a1c3f7804091a9f47f48c94d2125bf | https://github.com/oliviertassinari/react-swipeable-views/blob/400a004ef2a1c3f7804091a9f47f48c94d2125bf/packages/react-swipeable-views-core/src/mod.js#L2-L5 | train |
oliviertassinari/react-swipeable-views | packages/react-swipeable-views/src/SwipeableViews.js | applyRotationMatrix | function applyRotationMatrix(touch, axis) {
const rotationMatrix = axisProperties.rotationMatrix[axis];
return {
pageX: rotationMatrix.x[0] * touch.pageX + rotationMatrix.x[1] * touch.pageY,
pageY: rotationMatrix.y[0] * touch.pageX + rotationMatrix.y[1] * touch.pageY,
};
} | javascript | function applyRotationMatrix(touch, axis) {
const rotationMatrix = axisProperties.rotationMatrix[axis];
return {
pageX: rotationMatrix.x[0] * touch.pageX + rotationMatrix.x[1] * touch.pageY,
pageY: rotationMatrix.y[0] * touch.pageX + rotationMatrix.y[1] * touch.pageY,
};
} | [
"function",
"applyRotationMatrix",
"(",
"touch",
",",
"axis",
")",
"{",
"const",
"rotationMatrix",
"=",
"axisProperties",
".",
"rotationMatrix",
"[",
"axis",
"]",
";",
"return",
"{",
"pageX",
":",
"rotationMatrix",
".",
"x",
"[",
"0",
"]",
"*",
"touch",
".... | We are using a 2x2 rotation matrix. | [
"We",
"are",
"using",
"a",
"2x2",
"rotation",
"matrix",
"."
] | 400a004ef2a1c3f7804091a9f47f48c94d2125bf | https://github.com/oliviertassinari/react-swipeable-views/blob/400a004ef2a1c3f7804091a9f47f48c94d2125bf/packages/react-swipeable-views/src/SwipeableViews.js#L115-L122 | train |
jhildenbiddle/css-vars-ponyfill | src/transform-css.js | resolveFunc | function resolveFunc(value) {
const name = value.split(',')[0].replace(/[\s\n\t]/g, '');
const fallback = (value.match(/(?:\s*,\s*){1}(.*)?/) || [])[1];
const match = settings.variables.hasOwnProperty(name) ? String(settings.variables[name]) : undefined;
... | javascript | function resolveFunc(value) {
const name = value.split(',')[0].replace(/[\s\n\t]/g, '');
const fallback = (value.match(/(?:\s*,\s*){1}(.*)?/) || [])[1];
const match = settings.variables.hasOwnProperty(name) ? String(settings.variables[name]) : undefined;
... | [
"function",
"resolveFunc",
"(",
"value",
")",
"{",
"const",
"name",
"=",
"value",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"[\\s\\n\\t]",
"/",
"g",
",",
"''",
")",
";",
"const",
"fallback",
"=",
"(",
"value",
".",
"... | Resolves contents of CSS custom property function
@param {string} value String containing contents of CSS var() function
@returns {string}
@example
resolveFunc('--x, var(--y, green)')
// => obj['--x'] or obj['--y'] or 'green'
resolveFunc('--fail')
// => 'var(--fail)' when obj['--fail'] does not exist | [
"Resolves",
"contents",
"of",
"CSS",
"custom",
"property",
"function"
] | e22453fba24bdf0d593b0dbca17b05a947c7ed32 | https://github.com/jhildenbiddle/css-vars-ponyfill/blob/e22453fba24bdf0d593b0dbca17b05a947c7ed32/src/transform-css.js#L170-L187 | train |
jhildenbiddle/css-vars-ponyfill | src/index.js | getTimeStamp | function getTimeStamp() {
return isBrowser && (window.performance || {}).now ? window.performance.now() : new Date().getTime();
} | javascript | function getTimeStamp() {
return isBrowser && (window.performance || {}).now ? window.performance.now() : new Date().getTime();
} | [
"function",
"getTimeStamp",
"(",
")",
"{",
"return",
"isBrowser",
"&&",
"(",
"window",
".",
"performance",
"||",
"{",
"}",
")",
".",
"now",
"?",
"window",
".",
"performance",
".",
"now",
"(",
")",
":",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
... | Returns a time stamp in milliseconds
@returns {number} | [
"Returns",
"a",
"time",
"stamp",
"in",
"milliseconds"
] | e22453fba24bdf0d593b0dbca17b05a947c7ed32 | https://github.com/jhildenbiddle/css-vars-ponyfill/blob/e22453fba24bdf0d593b0dbca17b05a947c7ed32/src/index.js#L797-L799 | train |
iamdustan/smoothscroll | src/smoothscroll.js | shouldBailOut | function shouldBailOut(firstArg) {
if (
firstArg === null ||
typeof firstArg !== 'object' ||
firstArg.behavior === undefined ||
firstArg.behavior === 'auto' ||
firstArg.behavior === 'instant'
) {
// first argument is not an object/null
// or behavior is auto, instant or... | javascript | function shouldBailOut(firstArg) {
if (
firstArg === null ||
typeof firstArg !== 'object' ||
firstArg.behavior === undefined ||
firstArg.behavior === 'auto' ||
firstArg.behavior === 'instant'
) {
// first argument is not an object/null
// or behavior is auto, instant or... | [
"function",
"shouldBailOut",
"(",
"firstArg",
")",
"{",
"if",
"(",
"firstArg",
"===",
"null",
"||",
"typeof",
"firstArg",
"!==",
"'object'",
"||",
"firstArg",
".",
"behavior",
"===",
"undefined",
"||",
"firstArg",
".",
"behavior",
"===",
"'auto'",
"||",
"fir... | indicates if a smooth behavior should be applied
@method shouldBailOut
@param {Number|Object} firstArg
@returns {Boolean} | [
"indicates",
"if",
"a",
"smooth",
"behavior",
"should",
"be",
"applied"
] | 46ce13e65eee17640dacbbd50f7c64f4a393b3ef | https://github.com/iamdustan/smoothscroll/blob/46ce13e65eee17640dacbbd50f7c64f4a393b3ef/src/smoothscroll.js#L82-L106 | train |
iamdustan/smoothscroll | src/smoothscroll.js | hasScrollableSpace | function hasScrollableSpace(el, axis) {
if (axis === 'Y') {
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
}
if (axis === 'X') {
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
}
} | javascript | function hasScrollableSpace(el, axis) {
if (axis === 'Y') {
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
}
if (axis === 'X') {
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
}
} | [
"function",
"hasScrollableSpace",
"(",
"el",
",",
"axis",
")",
"{",
"if",
"(",
"axis",
"===",
"'Y'",
")",
"{",
"return",
"el",
".",
"clientHeight",
"+",
"ROUNDING_TOLERANCE",
"<",
"el",
".",
"scrollHeight",
";",
"}",
"if",
"(",
"axis",
"===",
"'X'",
")... | indicates if an element has scrollable space in the provided axis
@method hasScrollableSpace
@param {Node} el
@param {String} axis
@returns {Boolean} | [
"indicates",
"if",
"an",
"element",
"has",
"scrollable",
"space",
"in",
"the",
"provided",
"axis"
] | 46ce13e65eee17640dacbbd50f7c64f4a393b3ef | https://github.com/iamdustan/smoothscroll/blob/46ce13e65eee17640dacbbd50f7c64f4a393b3ef/src/smoothscroll.js#L115-L123 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.