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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
simplecrawler/simplecrawler | lib/crawler.js | processReceivedData | function processReceivedData() {
if (dataReceived || queueItem.fetched) {
return;
}
responseBuffer = responseBuffer.slice(0, responseLengthReceived);
dataReceived = true;
timeDataReceived = Date.now();
crawler.queue.update(queueIt... | javascript | function processReceivedData() {
if (dataReceived || queueItem.fetched) {
return;
}
responseBuffer = responseBuffer.slice(0, responseLengthReceived);
dataReceived = true;
timeDataReceived = Date.now();
crawler.queue.update(queueIt... | [
"function",
"processReceivedData",
"(",
")",
"{",
"if",
"(",
"dataReceived",
"||",
"queueItem",
".",
"fetched",
")",
"{",
"return",
";",
"}",
"responseBuffer",
"=",
"responseBuffer",
".",
"slice",
"(",
"0",
",",
"responseLengthReceived",
")",
";",
"dataReceive... | Function for dealing with 200 responses | [
"Function",
"for",
"dealing",
"with",
"200",
"responses"
] | 2698d15b1ea9cd69285ce3f8b3825975f80f858c | https://github.com/simplecrawler/simplecrawler/blob/2698d15b1ea9cd69285ce3f8b3825975f80f858c/lib/crawler.js#L1623-L1678 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | addPathHandle | function addPathHandle($canvas, parent, xProp, yProp) {
var handle = $.extend({
cursors: {
mouseover: 'grab',
mousedown: 'grabbing',
mouseup: 'grab'
}
}, parent.handle, {
// Define constant properties for handle
layer: true,
draggable: true,
x: parent[xProp],
y: parent[yProp],
_parent: paren... | javascript | function addPathHandle($canvas, parent, xProp, yProp) {
var handle = $.extend({
cursors: {
mouseover: 'grab',
mousedown: 'grabbing',
mouseup: 'grab'
}
}, parent.handle, {
// Define constant properties for handle
layer: true,
draggable: true,
x: parent[xProp],
y: parent[yProp],
_parent: paren... | [
"function",
"addPathHandle",
"(",
"$canvas",
",",
"parent",
",",
"xProp",
",",
"yProp",
")",
"{",
"var",
"handle",
"=",
"$",
".",
"extend",
"(",
"{",
"cursors",
":",
"{",
"mouseover",
":",
"'grab'",
",",
"mousedown",
":",
"'grabbing'",
",",
"mouseup",
... | Add a single handle to line path | [
"Add",
"a",
"single",
"handle",
"to",
"line",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L35-L74 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | function (layer) {
var parent = layer._parent;
if (parent.width + (layer.dx * layer._px) < parent.minWidth) {
parent.width = parent.minWidth;
layer.dx = 0;
}
if (parent.height + (layer.dy * layer._py) < parent.minHeight) {
parent.height = parent.minHeight;
layer.dy = 0;
}
if (!parent... | javascript | function (layer) {
var parent = layer._parent;
if (parent.width + (layer.dx * layer._px) < parent.minWidth) {
parent.width = parent.minWidth;
layer.dx = 0;
}
if (parent.height + (layer.dy * layer._py) < parent.minHeight) {
parent.height = parent.minHeight;
layer.dy = 0;
}
if (!parent... | [
"function",
"(",
"layer",
")",
"{",
"var",
"parent",
"=",
"layer",
".",
"_parent",
";",
"if",
"(",
"parent",
".",
"width",
"+",
"(",
"layer",
".",
"dx",
"*",
"layer",
".",
"_px",
")",
"<",
"parent",
".",
"minWidth",
")",
"{",
"parent",
".",
"widt... | Resize rectangle when dragging a handle | [
"Resize",
"rectangle",
"when",
"dragging",
"a",
"handle"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L110-L175 | train | |
caleb531/jcanvas | dist/jcanvas-handles.js | addRectHandles | function addRectHandles($canvas, parent) {
var handlePlacement = parent.handlePlacement;
// Store current width-to-height ratio
if (parent.aspectRatio === null && parent.height !== 0) {
parent.aspectRatio = parent.width / parent.height;
}
// Optionally add handles to corners
if (handlePlacement === 'corners' ||... | javascript | function addRectHandles($canvas, parent) {
var handlePlacement = parent.handlePlacement;
// Store current width-to-height ratio
if (parent.aspectRatio === null && parent.height !== 0) {
parent.aspectRatio = parent.width / parent.height;
}
// Optionally add handles to corners
if (handlePlacement === 'corners' ||... | [
"function",
"addRectHandles",
"(",
"$canvas",
",",
"parent",
")",
"{",
"var",
"handlePlacement",
"=",
"parent",
".",
"handlePlacement",
";",
"// Store current width-to-height ratio",
"if",
"(",
"parent",
".",
"aspectRatio",
"===",
"null",
"&&",
"parent",
".",
"hei... | Add all handles to rectangle | [
"Add",
"all",
"handles",
"to",
"rectangle"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L191-L215 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | updateRectGuides | function updateRectGuides(parent) {
var guide = parent._guide;
if (guide) {
guide.x = parent.x;
guide.y = parent.y;
guide.width = parent.width;
guide.height = parent.height;
guide.fromCenter = parent.fromCenter;
}
} | javascript | function updateRectGuides(parent) {
var guide = parent._guide;
if (guide) {
guide.x = parent.x;
guide.y = parent.y;
guide.width = parent.width;
guide.height = parent.height;
guide.fromCenter = parent.fromCenter;
}
} | [
"function",
"updateRectGuides",
"(",
"parent",
")",
"{",
"var",
"guide",
"=",
"parent",
".",
"_guide",
";",
"if",
"(",
"guide",
")",
"{",
"guide",
".",
"x",
"=",
"parent",
".",
"x",
";",
"guide",
".",
"y",
"=",
"parent",
".",
"y",
";",
"guide",
"... | Update handle guides for rectangular layer | [
"Update",
"handle",
"guides",
"for",
"rectangular",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L218-L227 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | addRectGuides | function addRectGuides($canvas, parent) {
var guideProps, guide;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'rectangle',
handle: null
});
$canvas.addLayer(guideProps);
guide = $canvas.getLayer(-1);
parent._guide = guide;
$canvas.moveLayer(guide, -parent._handles.length... | javascript | function addRectGuides($canvas, parent) {
var guideProps, guide;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'rectangle',
handle: null
});
$canvas.addLayer(guideProps);
guide = $canvas.getLayer(-1);
parent._guide = guide;
$canvas.moveLayer(guide, -parent._handles.length... | [
"function",
"addRectGuides",
"(",
"$canvas",
",",
"parent",
")",
"{",
"var",
"guideProps",
",",
"guide",
";",
"guideProps",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"parent",
".",
"guide",
",",
"{",
"layer",
":",
"true",
",",
"draggable",
":",
"f... | Add handle guides to rectangular layer | [
"Add",
"handle",
"guides",
"to",
"rectangular",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L230-L243 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | addPathHandles | function addPathHandles($canvas, parent) {
var key, xProp, yProp;
for (key in parent) {
if (Object.prototype.hasOwnProperty.call(parent, key)) {
// If property is a control point
if (key.match(/c?x(\d+)/gi) !== null) {
// Get the x and y coordinates for that control point
xProp = key;
yProp = key.... | javascript | function addPathHandles($canvas, parent) {
var key, xProp, yProp;
for (key in parent) {
if (Object.prototype.hasOwnProperty.call(parent, key)) {
// If property is a control point
if (key.match(/c?x(\d+)/gi) !== null) {
// Get the x and y coordinates for that control point
xProp = key;
yProp = key.... | [
"function",
"addPathHandles",
"(",
"$canvas",
",",
"parent",
")",
"{",
"var",
"key",
",",
"xProp",
",",
"yProp",
";",
"for",
"(",
"key",
"in",
"parent",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"parent",... | Add handles to line path | [
"Add",
"handles",
"to",
"line",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L246-L264 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | updatePathGuides | function updatePathGuides(parent) {
var handles = parent._handles,
guides = parent._guides,
handle, h,
guide, g;
if (parent._method === $.fn.drawQuadratic) {
if (handles) {
guide = parent._guide;
if (guide) {
for (h = 0; h < handles.length; h += 1) {
handle = parent._handles[h];
guide['x' ... | javascript | function updatePathGuides(parent) {
var handles = parent._handles,
guides = parent._guides,
handle, h,
guide, g;
if (parent._method === $.fn.drawQuadratic) {
if (handles) {
guide = parent._guide;
if (guide) {
for (h = 0; h < handles.length; h += 1) {
handle = parent._handles[h];
guide['x' ... | [
"function",
"updatePathGuides",
"(",
"parent",
")",
"{",
"var",
"handles",
"=",
"parent",
".",
"_handles",
",",
"guides",
"=",
"parent",
".",
"_guides",
",",
"handle",
",",
"h",
",",
"guide",
",",
"g",
";",
"if",
"(",
"parent",
".",
"_method",
"===",
... | Update handle guides for line path | [
"Update",
"handle",
"guides",
"for",
"line",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L267-L298 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | addPathGuides | function addPathGuides($canvas, parent) {
var handles = parent._handles,
prevHandle, nextHandle, otherHandle,
handle, h,
guide, guideProps;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'line'
});
if (parent._method === $.fn.drawQuadratic) {
$canvas.addLayer(guideProps... | javascript | function addPathGuides($canvas, parent) {
var handles = parent._handles,
prevHandle, nextHandle, otherHandle,
handle, h,
guide, guideProps;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'line'
});
if (parent._method === $.fn.drawQuadratic) {
$canvas.addLayer(guideProps... | [
"function",
"addPathGuides",
"(",
"$canvas",
",",
"parent",
")",
"{",
"var",
"handles",
"=",
"parent",
".",
"_handles",
",",
"prevHandle",
",",
"nextHandle",
",",
"otherHandle",
",",
"handle",
",",
"h",
",",
"guide",
",",
"guideProps",
";",
"guideProps",
"... | Add guides to path layer | [
"Add",
"guides",
"to",
"path",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L301-L342 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | updateRectHandles | function updateRectHandles(parent) {
var handle, h;
if (parent._handles) {
// Move handles when dragging
for (h = 0; h < parent._handles.length; h += 1) {
handle = parent._handles[h];
handle.x = parent.x + ((parent.width / 2 * handle._px) + ((parent.fromCenter) ? 0 : parent.width / 2));
handle.y = parent... | javascript | function updateRectHandles(parent) {
var handle, h;
if (parent._handles) {
// Move handles when dragging
for (h = 0; h < parent._handles.length; h += 1) {
handle = parent._handles[h];
handle.x = parent.x + ((parent.width / 2 * handle._px) + ((parent.fromCenter) ? 0 : parent.width / 2));
handle.y = parent... | [
"function",
"updateRectHandles",
"(",
"parent",
")",
"{",
"var",
"handle",
",",
"h",
";",
"if",
"(",
"parent",
".",
"_handles",
")",
"{",
"// Move handles when dragging",
"for",
"(",
"h",
"=",
"0",
";",
"h",
"<",
"parent",
".",
"_handles",
".",
"length",... | Update position of handles according to size and dimensions of rectangular layer | [
"Update",
"position",
"of",
"handles",
"according",
"to",
"size",
"and",
"dimensions",
"of",
"rectangular",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L346-L357 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | updatePathHandles | function updatePathHandles(parent) {
var handles = parent._handles,
handle, h;
if (handles) {
// Move handles when dragging
for (h = 0; h < handles.length; h += 1) {
handle = handles[h];
handle.x = parent[handle._xProp] + parent.x;
handle.y = parent[handle._yProp] + parent.y;
}
}
updatePathGuides(p... | javascript | function updatePathHandles(parent) {
var handles = parent._handles,
handle, h;
if (handles) {
// Move handles when dragging
for (h = 0; h < handles.length; h += 1) {
handle = handles[h];
handle.x = parent[handle._xProp] + parent.x;
handle.y = parent[handle._yProp] + parent.y;
}
}
updatePathGuides(p... | [
"function",
"updatePathHandles",
"(",
"parent",
")",
"{",
"var",
"handles",
"=",
"parent",
".",
"_handles",
",",
"handle",
",",
"h",
";",
"if",
"(",
"handles",
")",
"{",
"// Move handles when dragging",
"for",
"(",
"h",
"=",
"0",
";",
"h",
"<",
"handles"... | Update position of handles according to coordinates and dimensions of path layer | [
"Update",
"position",
"of",
"handles",
"according",
"to",
"coordinates",
"and",
"dimensions",
"of",
"path",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L361-L373 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | addHandles | function addHandles(parent) {
var $canvas = $(parent.canvas);
// If parent's list of handles doesn't exist
if (parent._handles === undefined) {
// Create list to store handles
parent._handles = [];
}
if (isRectLayer(parent)) {
// Add four handles to corners of a rectangle/ellipse/image
addRectHandles($ca... | javascript | function addHandles(parent) {
var $canvas = $(parent.canvas);
// If parent's list of handles doesn't exist
if (parent._handles === undefined) {
// Create list to store handles
parent._handles = [];
}
if (isRectLayer(parent)) {
// Add four handles to corners of a rectangle/ellipse/image
addRectHandles($ca... | [
"function",
"addHandles",
"(",
"parent",
")",
"{",
"var",
"$canvas",
"=",
"$",
"(",
"parent",
".",
"canvas",
")",
";",
"// If parent's list of handles doesn't exist",
"if",
"(",
"parent",
".",
"_handles",
"===",
"undefined",
")",
"{",
"// Create list to store hand... | Add drag handles to all four corners of rectangle layer | [
"Add",
"drag",
"handles",
"to",
"all",
"four",
"corners",
"of",
"rectangle",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L377-L393 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | removeHandles | function removeHandles(layer) {
var $canvas = $(layer.canvas), handle, h;
if (layer._handles) {
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | javascript | function removeHandles(layer) {
var $canvas = $(layer.canvas), handle, h;
if (layer._handles) {
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | [
"function",
"removeHandles",
"(",
"layer",
")",
"{",
"var",
"$canvas",
"=",
"$",
"(",
"layer",
".",
"canvas",
")",
",",
"handle",
",",
"h",
";",
"if",
"(",
"layer",
".",
"_handles",
")",
"{",
"// Remove handles from layer",
"for",
"(",
"h",
"=",
"0",
... | Remove handles if handle property was removed | [
"Remove",
"handles",
"if",
"handle",
"property",
"was",
"removed"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L396-L406 | train |
caleb531/jcanvas | dist/jcanvas-handles.js | function (layer) {
var $canvas, handle, h;
if (layer._handles) {
$canvas = $(this);
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | javascript | function (layer) {
var $canvas, handle, h;
if (layer._handles) {
$canvas = $(this);
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | [
"function",
"(",
"layer",
")",
"{",
"var",
"$canvas",
",",
"handle",
",",
"h",
";",
"if",
"(",
"layer",
".",
"_handles",
")",
"{",
"$canvas",
"=",
"$",
"(",
"this",
")",
";",
"// Remove handles from layer",
"for",
"(",
"h",
"=",
"0",
";",
"h",
"<",... | Remove handles of layer is removed | [
"Remove",
"handles",
"of",
"layer",
"is",
"removed"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L426-L437 | train | |
caleb531/jcanvas | dist/jcanvas-handles.js | function (layer, props) {
if (props.handle || objectContainsPathCoords(props)) {
// Add handles if handle property was added
removeHandles(layer);
addHandles(layer);
} else if (props.handle === null) {
removeHandles(layer);
}
if (isRectLayer(layer)) {
// If width/height was changed
if (props.w... | javascript | function (layer, props) {
if (props.handle || objectContainsPathCoords(props)) {
// Add handles if handle property was added
removeHandles(layer);
addHandles(layer);
} else if (props.handle === null) {
removeHandles(layer);
}
if (isRectLayer(layer)) {
// If width/height was changed
if (props.w... | [
"function",
"(",
"layer",
",",
"props",
")",
"{",
"if",
"(",
"props",
".",
"handle",
"||",
"objectContainsPathCoords",
"(",
"props",
")",
")",
"{",
"// Add handles if handle property was added",
"removeHandles",
"(",
"layer",
")",
";",
"addHandles",
"(",
"layer"... | Update handle positions when changing parent layer's dimensions | [
"Update",
"handle",
"positions",
"when",
"changing",
"parent",
"layer",
"s",
"dimensions"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L439-L457 | train | |
caleb531/jcanvas | dist/jcanvas-handles.js | function (layer, fx) {
// If layer is a rectangle or ellipse layer
if (isRectLayer(layer)) {
// If width or height are animated
if (fx.prop === 'width' || fx.prop === 'height' || fx.prop === 'x' || fx.prop === 'y') {
// Update rectangular handles
updateRectHandles(layer);
}
} else if (isPathLayer... | javascript | function (layer, fx) {
// If layer is a rectangle or ellipse layer
if (isRectLayer(layer)) {
// If width or height are animated
if (fx.prop === 'width' || fx.prop === 'height' || fx.prop === 'x' || fx.prop === 'y') {
// Update rectangular handles
updateRectHandles(layer);
}
} else if (isPathLayer... | [
"function",
"(",
"layer",
",",
"fx",
")",
"{",
"// If layer is a rectangle or ellipse layer",
"if",
"(",
"isRectLayer",
"(",
"layer",
")",
")",
"{",
"// If width or height are animated",
"if",
"(",
"fx",
".",
"prop",
"===",
"'width'",
"||",
"fx",
".",
"prop",
... | Update handle positions when animating parent layer | [
"Update",
"handle",
"positions",
"when",
"animating",
"parent",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-handles.js#L459-L474 | train | |
caleb531/jcanvas | dist/jcanvas.js | jCanvasObject | function jCanvasObject(args) {
var params = this,
propName;
// Copy the given parameters into new object
for (propName in args) {
// Do not merge defaults into parameters
if (Object.prototype.hasOwnProperty.call(args, propName)) {
params[propName] = args[propName];
}
}
return params;
} | javascript | function jCanvasObject(args) {
var params = this,
propName;
// Copy the given parameters into new object
for (propName in args) {
// Do not merge defaults into parameters
if (Object.prototype.hasOwnProperty.call(args, propName)) {
params[propName] = args[propName];
}
}
return params;
} | [
"function",
"jCanvasObject",
"(",
"args",
")",
"{",
"var",
"params",
"=",
"this",
",",
"propName",
";",
"// Copy the given parameters into new object",
"for",
"(",
"propName",
"in",
"args",
")",
"{",
"// Do not merge defaults into parameters",
"if",
"(",
"Object",
"... | Constructor for creating objects that inherit from jCanvas preferences and defaults | [
"Constructor",
"for",
"creating",
"objects",
"that",
"inherit",
"from",
"jCanvas",
"preferences",
"and",
"defaults"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L82-L93 | train |
caleb531/jcanvas | dist/jcanvas.js | _coerceNumericProps | function _coerceNumericProps(props) {
var propName, propType, propValue;
// Loop through all properties in given property map
for (propName in props) {
if (Object.prototype.hasOwnProperty.call(props, propName)) {
propValue = props[propName];
propType = typeOf(propValue);
// If property is non-empty string... | javascript | function _coerceNumericProps(props) {
var propName, propType, propValue;
// Loop through all properties in given property map
for (propName in props) {
if (Object.prototype.hasOwnProperty.call(props, propName)) {
propValue = props[propName];
propType = typeOf(propValue);
// If property is non-empty string... | [
"function",
"_coerceNumericProps",
"(",
"props",
")",
"{",
"var",
"propName",
",",
"propType",
",",
"propValue",
";",
"// Loop through all properties in given property map",
"for",
"(",
"propName",
"in",
"props",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".... | Coerce designated number properties from strings to numbers | [
"Coerce",
"designated",
"number",
"properties",
"from",
"strings",
"to",
"numbers"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L219-L237 | train |
caleb531/jcanvas | dist/jcanvas.js | _cloneTransforms | function _cloneTransforms(transforms) {
// Clone the object itself
transforms = extendObject({}, transforms);
// Clone the object's masks array
transforms.masks = transforms.masks.slice(0);
return transforms;
} | javascript | function _cloneTransforms(transforms) {
// Clone the object itself
transforms = extendObject({}, transforms);
// Clone the object's masks array
transforms.masks = transforms.masks.slice(0);
return transforms;
} | [
"function",
"_cloneTransforms",
"(",
"transforms",
")",
"{",
"// Clone the object itself",
"transforms",
"=",
"extendObject",
"(",
"{",
"}",
",",
"transforms",
")",
";",
"// Clone the object's masks array",
"transforms",
".",
"masks",
"=",
"transforms",
".",
"masks",
... | Clone the given transformations object | [
"Clone",
"the",
"given",
"transformations",
"object"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L240-L246 | train |
caleb531/jcanvas | dist/jcanvas.js | _saveCanvas | function _saveCanvas(ctx, data) {
var transforms;
ctx.save();
transforms = _cloneTransforms(data.transforms);
data.savedTransforms.push(transforms);
} | javascript | function _saveCanvas(ctx, data) {
var transforms;
ctx.save();
transforms = _cloneTransforms(data.transforms);
data.savedTransforms.push(transforms);
} | [
"function",
"_saveCanvas",
"(",
"ctx",
",",
"data",
")",
"{",
"var",
"transforms",
";",
"ctx",
".",
"save",
"(",
")",
";",
"transforms",
"=",
"_cloneTransforms",
"(",
"data",
".",
"transforms",
")",
";",
"data",
".",
"savedTransforms",
".",
"push",
"(",
... | Save canvas context and update transformation stack | [
"Save",
"canvas",
"context",
"and",
"update",
"transformation",
"stack"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L249-L254 | train |
caleb531/jcanvas | dist/jcanvas.js | _restoreCanvas | function _restoreCanvas(ctx, data) {
if (data.savedTransforms.length === 0) {
// Reset transformation state if it can't be restored any more
data.transforms = _cloneTransforms(baseTransforms);
} else {
// Restore canvas context
ctx.restore();
// Restore current transform state to the last saved state
data... | javascript | function _restoreCanvas(ctx, data) {
if (data.savedTransforms.length === 0) {
// Reset transformation state if it can't be restored any more
data.transforms = _cloneTransforms(baseTransforms);
} else {
// Restore canvas context
ctx.restore();
// Restore current transform state to the last saved state
data... | [
"function",
"_restoreCanvas",
"(",
"ctx",
",",
"data",
")",
"{",
"if",
"(",
"data",
".",
"savedTransforms",
".",
"length",
"===",
"0",
")",
"{",
"// Reset transformation state if it can't be restored any more",
"data",
".",
"transforms",
"=",
"_cloneTransforms",
"("... | Restore canvas context update transformation stack | [
"Restore",
"canvas",
"context",
"update",
"transformation",
"stack"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L257-L267 | train |
caleb531/jcanvas | dist/jcanvas.js | _setStyle | function _setStyle(canvas, ctx, params, styleName) {
if (params[styleName]) {
if (isFunction(params[styleName])) {
// Handle functions
ctx[styleName] = params[styleName].call(canvas, params);
} else {
// Handle string values
ctx[styleName] = params[styleName];
}
}
} | javascript | function _setStyle(canvas, ctx, params, styleName) {
if (params[styleName]) {
if (isFunction(params[styleName])) {
// Handle functions
ctx[styleName] = params[styleName].call(canvas, params);
} else {
// Handle string values
ctx[styleName] = params[styleName];
}
}
} | [
"function",
"_setStyle",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"styleName",
")",
"{",
"if",
"(",
"params",
"[",
"styleName",
"]",
")",
"{",
"if",
"(",
"isFunction",
"(",
"params",
"[",
"styleName",
"]",
")",
")",
"{",
"// Handle functions",
"c... | Set the style with the given name | [
"Set",
"the",
"style",
"with",
"the",
"given",
"name"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L270-L280 | train |
caleb531/jcanvas | dist/jcanvas.js | _setGlobalProps | function _setGlobalProps(canvas, ctx, params) {
_setStyle(canvas, ctx, params, 'fillStyle');
_setStyle(canvas, ctx, params, 'strokeStyle');
ctx.lineWidth = params.strokeWidth;
// Optionally round corners for paths
if (params.rounded) {
ctx.lineCap = ctx.lineJoin = 'round';
} else {
ctx.lineCap = params.stroke... | javascript | function _setGlobalProps(canvas, ctx, params) {
_setStyle(canvas, ctx, params, 'fillStyle');
_setStyle(canvas, ctx, params, 'strokeStyle');
ctx.lineWidth = params.strokeWidth;
// Optionally round corners for paths
if (params.rounded) {
ctx.lineCap = ctx.lineJoin = 'round';
} else {
ctx.lineCap = params.stroke... | [
"function",
"_setGlobalProps",
"(",
"canvas",
",",
"ctx",
",",
"params",
")",
"{",
"_setStyle",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"'fillStyle'",
")",
";",
"_setStyle",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"'strokeStyle'",
")",
";",... | Set canvas context properties | [
"Set",
"canvas",
"context",
"properties"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L283-L317 | train |
caleb531/jcanvas | dist/jcanvas.js | _enableMasking | function _enableMasking(ctx, data, params) {
if (params.mask) {
// If jCanvas autosave is enabled
if (params.autosave) {
// Automatically save transformation state by default
_saveCanvas(ctx, data);
}
// Clip the current path
ctx.clip();
// Keep track of current masks
data.transforms.masks.push(par... | javascript | function _enableMasking(ctx, data, params) {
if (params.mask) {
// If jCanvas autosave is enabled
if (params.autosave) {
// Automatically save transformation state by default
_saveCanvas(ctx, data);
}
// Clip the current path
ctx.clip();
// Keep track of current masks
data.transforms.masks.push(par... | [
"function",
"_enableMasking",
"(",
"ctx",
",",
"data",
",",
"params",
")",
"{",
"if",
"(",
"params",
".",
"mask",
")",
"{",
"// If jCanvas autosave is enabled",
"if",
"(",
"params",
".",
"autosave",
")",
"{",
"// Automatically save transformation state by default",
... | Optionally enable masking support for this path | [
"Optionally",
"enable",
"masking",
"support",
"for",
"this",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L320-L332 | train |
caleb531/jcanvas | dist/jcanvas.js | _closePath | function _closePath(canvas, ctx, params) {
var data;
// Optionally close path
if (params.closed) {
ctx.closePath();
}
if (params.shadowStroke && params.strokeWidth !== 0) {
// Extend the shadow to include the stroke of a drawing
// Add a stroke shadow by stroking before filling
ctx.stroke();
ctx.fill(... | javascript | function _closePath(canvas, ctx, params) {
var data;
// Optionally close path
if (params.closed) {
ctx.closePath();
}
if (params.shadowStroke && params.strokeWidth !== 0) {
// Extend the shadow to include the stroke of a drawing
// Add a stroke shadow by stroking before filling
ctx.stroke();
ctx.fill(... | [
"function",
"_closePath",
"(",
"canvas",
",",
"ctx",
",",
"params",
")",
"{",
"var",
"data",
";",
"// Optionally close path",
"if",
"(",
"params",
".",
"closed",
")",
"{",
"ctx",
".",
"closePath",
"(",
")",
";",
"}",
"if",
"(",
"params",
".",
"shadowSt... | Close current canvas path | [
"Close",
"current",
"canvas",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L344-L394 | train |
caleb531/jcanvas | dist/jcanvas.js | _addLayerEvents | function _addLayerEvents($canvas, data, layer) {
var eventName;
// Determine which jCanvas events need to be bound to this layer
for (eventName in jCanvas.events) {
if (Object.prototype.hasOwnProperty.call(jCanvas.events, eventName)) {
// If layer has callback function to complement it
if (layer[eventName] |... | javascript | function _addLayerEvents($canvas, data, layer) {
var eventName;
// Determine which jCanvas events need to be bound to this layer
for (eventName in jCanvas.events) {
if (Object.prototype.hasOwnProperty.call(jCanvas.events, eventName)) {
// If layer has callback function to complement it
if (layer[eventName] |... | [
"function",
"_addLayerEvents",
"(",
"$canvas",
",",
"data",
",",
"layer",
")",
"{",
"var",
"eventName",
";",
"// Determine which jCanvas events need to be bound to this layer",
"for",
"(",
"eventName",
"in",
"jCanvas",
".",
"events",
")",
"{",
"if",
"(",
"Object",
... | Initialize all of a layer's associated jCanvas events | [
"Initialize",
"all",
"of",
"a",
"layer",
"s",
"associated",
"jCanvas",
"events"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L543-L580 | train |
caleb531/jcanvas | dist/jcanvas.js | _addLayerEvent | function _addLayerEvent($canvas, data, layer, eventName) {
// Use touch events if appropriate
// eventName = _getMouseEventName(eventName);
// Bind event to layer
jCanvas.events[eventName]($canvas, data);
layer._event = true;
} | javascript | function _addLayerEvent($canvas, data, layer, eventName) {
// Use touch events if appropriate
// eventName = _getMouseEventName(eventName);
// Bind event to layer
jCanvas.events[eventName]($canvas, data);
layer._event = true;
} | [
"function",
"_addLayerEvent",
"(",
"$canvas",
",",
"data",
",",
"layer",
",",
"eventName",
")",
"{",
"// Use touch events if appropriate",
"// eventName = _getMouseEventName(eventName);",
"// Bind event to layer",
"jCanvas",
".",
"events",
"[",
"eventName",
"]",
"(",
"$ca... | Initialize the given event on the given layer | [
"Initialize",
"the",
"given",
"event",
"on",
"the",
"given",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L583-L589 | train |
caleb531/jcanvas | dist/jcanvas.js | _enableDrag | function _enableDrag($canvas, data, layer) {
var dragHelperEvents, eventName, i;
// Only make layer draggable if necessary
if (layer.draggable || layer.cursors) {
// Organize helper events which enable drag support
dragHelperEvents = ['mousedown', 'mousemove', 'mouseup'];
// Bind each helper event to the can... | javascript | function _enableDrag($canvas, data, layer) {
var dragHelperEvents, eventName, i;
// Only make layer draggable if necessary
if (layer.draggable || layer.cursors) {
// Organize helper events which enable drag support
dragHelperEvents = ['mousedown', 'mousemove', 'mouseup'];
// Bind each helper event to the can... | [
"function",
"_enableDrag",
"(",
"$canvas",
",",
"data",
",",
"layer",
")",
"{",
"var",
"dragHelperEvents",
",",
"eventName",
",",
"i",
";",
"// Only make layer draggable if necessary",
"if",
"(",
"layer",
".",
"draggable",
"||",
"layer",
".",
"cursors",
")",
"... | Enable drag support for this layer | [
"Enable",
"drag",
"support",
"for",
"this",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L602-L621 | train |
caleb531/jcanvas | dist/jcanvas.js | _updateLayerName | function _updateLayerName($canvas, data, layer, props) {
var nameMap = data.layer.names;
// If layer name is being added, not changed
if (!props) {
props = layer;
} else {
// Remove old layer name entry because layer name has changed
if (props.name !== undefined && isString(layer.name) && layer.name !== p... | javascript | function _updateLayerName($canvas, data, layer, props) {
var nameMap = data.layer.names;
// If layer name is being added, not changed
if (!props) {
props = layer;
} else {
// Remove old layer name entry because layer name has changed
if (props.name !== undefined && isString(layer.name) && layer.name !== p... | [
"function",
"_updateLayerName",
"(",
"$canvas",
",",
"data",
",",
"layer",
",",
"props",
")",
"{",
"var",
"nameMap",
"=",
"data",
".",
"layer",
".",
"names",
";",
"// If layer name is being added, not changed",
"if",
"(",
"!",
"props",
")",
"{",
"props",
"="... | Update a layer property map if property is changed | [
"Update",
"a",
"layer",
"property",
"map",
"if",
"property",
"is",
"changed"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L624-L645 | train |
caleb531/jcanvas | dist/jcanvas.js | _updateLayerGroups | function _updateLayerGroups($canvas, data, layer, props) {
var groupMap = data.layer.groups,
group, groupName, g,
index, l;
// If group name is not changing
if (!props) {
props = layer;
} else {
// Remove layer from all of its associated groups
if (props.groups !== undefined && layer.groups !== null) ... | javascript | function _updateLayerGroups($canvas, data, layer, props) {
var groupMap = data.layer.groups,
group, groupName, g,
index, l;
// If group name is not changing
if (!props) {
props = layer;
} else {
// Remove layer from all of its associated groups
if (props.groups !== undefined && layer.groups !== null) ... | [
"function",
"_updateLayerGroups",
"(",
"$canvas",
",",
"data",
",",
"layer",
",",
"props",
")",
"{",
"var",
"groupMap",
"=",
"data",
".",
"layer",
".",
"groups",
",",
"group",
",",
"groupName",
",",
"g",
",",
"index",
",",
"l",
";",
"// If group name is ... | Create or update the data map for the given layer and group type | [
"Create",
"or",
"update",
"the",
"data",
"map",
"for",
"the",
"given",
"layer",
"and",
"group",
"type"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L648-L709 | train |
caleb531/jcanvas | dist/jcanvas.js | _getIntersectingLayer | function _getIntersectingLayer(data) {
var layer, i,
mask, m;
// Store the topmost layer
layer = null;
// Get the topmost layer whose visible area intersects event coordinates
for (i = data.intersecting.length - 1; i >= 0; i -= 1) {
// Get current layer
layer = data.intersecting[i];
// If layer has pre... | javascript | function _getIntersectingLayer(data) {
var layer, i,
mask, m;
// Store the topmost layer
layer = null;
// Get the topmost layer whose visible area intersects event coordinates
for (i = data.intersecting.length - 1; i >= 0; i -= 1) {
// Get current layer
layer = data.intersecting[i];
// If layer has pre... | [
"function",
"_getIntersectingLayer",
"(",
"data",
")",
"{",
"var",
"layer",
",",
"i",
",",
"mask",
",",
"m",
";",
"// Store the topmost layer",
"layer",
"=",
"null",
";",
"// Get the topmost layer whose visible area intersects event coordinates",
"for",
"(",
"i",
"=",... | Get topmost layer that intersects with event coordinates | [
"Get",
"topmost",
"layer",
"that",
"intersects",
"with",
"event",
"coordinates"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1166-L1213 | train |
caleb531/jcanvas | dist/jcanvas.js | _setCursor | function _setCursor($canvas, layer, eventType) {
var cursor;
if (layer.cursors) {
// Retrieve cursor from cursors object if it exists
cursor = layer.cursors[eventType];
}
// Prefix any CSS3 cursor
if ($.inArray(cursor, css.cursors) !== -1) {
cursor = css.prefix + cursor;
}
// If cursor is defined
if (curs... | javascript | function _setCursor($canvas, layer, eventType) {
var cursor;
if (layer.cursors) {
// Retrieve cursor from cursors object if it exists
cursor = layer.cursors[eventType];
}
// Prefix any CSS3 cursor
if ($.inArray(cursor, css.cursors) !== -1) {
cursor = css.prefix + cursor;
}
// If cursor is defined
if (curs... | [
"function",
"_setCursor",
"(",
"$canvas",
",",
"layer",
",",
"eventType",
")",
"{",
"var",
"cursor",
";",
"if",
"(",
"layer",
".",
"cursors",
")",
"{",
"// Retrieve cursor from cursors object if it exists",
"cursor",
"=",
"layer",
".",
"cursors",
"[",
"eventType... | Set cursor on canvas | [
"Set",
"cursor",
"on",
"canvas"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1354-L1371 | train |
caleb531/jcanvas | dist/jcanvas.js | _runEventCallback | function _runEventCallback($canvas, layer, eventType, callbacks, arg) {
// Prevent callback from firing recursively
if (callbacks[eventType] && layer._running && !layer._running[eventType]) {
// Signify the start of callback execution for this event
layer._running[eventType] = true;
// Run event callback with t... | javascript | function _runEventCallback($canvas, layer, eventType, callbacks, arg) {
// Prevent callback from firing recursively
if (callbacks[eventType] && layer._running && !layer._running[eventType]) {
// Signify the start of callback execution for this event
layer._running[eventType] = true;
// Run event callback with t... | [
"function",
"_runEventCallback",
"(",
"$canvas",
",",
"layer",
",",
"eventType",
",",
"callbacks",
",",
"arg",
")",
"{",
"// Prevent callback from firing recursively",
"if",
"(",
"callbacks",
"[",
"eventType",
"]",
"&&",
"layer",
".",
"_running",
"&&",
"!",
"lay... | Run the given event callback with the given arguments | [
"Run",
"the",
"given",
"event",
"callback",
"with",
"the",
"given",
"arguments"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1381-L1391 | train |
caleb531/jcanvas | dist/jcanvas.js | _layerCanFireEvent | function _layerCanFireEvent(layer, eventType) {
// If events are disable and if
// layer is tangible or event is not tangible
return (!layer.disableEvents &&
(!layer.intangible || $.inArray(eventType, tangibleEvents) === -1));
} | javascript | function _layerCanFireEvent(layer, eventType) {
// If events are disable and if
// layer is tangible or event is not tangible
return (!layer.disableEvents &&
(!layer.intangible || $.inArray(eventType, tangibleEvents) === -1));
} | [
"function",
"_layerCanFireEvent",
"(",
"layer",
",",
"eventType",
")",
"{",
"// If events are disable and if",
"// layer is tangible or event is not tangible",
"return",
"(",
"!",
"layer",
".",
"disableEvents",
"&&",
"(",
"!",
"layer",
".",
"intangible",
"||",
"$",
".... | Determine if the given layer can "legally" fire the given event | [
"Determine",
"if",
"the",
"given",
"layer",
"can",
"legally",
"fire",
"the",
"given",
"event"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1394-L1399 | train |
caleb531/jcanvas | dist/jcanvas.js | _triggerLayerEvent | function _triggerLayerEvent($canvas, data, layer, eventType, arg) {
// If layer can legally fire this event type
if (_layerCanFireEvent(layer, eventType)) {
// Do not set a custom cursor on layer mouseout
if (eventType !== 'mouseout') {
// Update cursor if one is defined for this event
_setCursor($canvas, ... | javascript | function _triggerLayerEvent($canvas, data, layer, eventType, arg) {
// If layer can legally fire this event type
if (_layerCanFireEvent(layer, eventType)) {
// Do not set a custom cursor on layer mouseout
if (eventType !== 'mouseout') {
// Update cursor if one is defined for this event
_setCursor($canvas, ... | [
"function",
"_triggerLayerEvent",
"(",
"$canvas",
",",
"data",
",",
"layer",
",",
"eventType",
",",
"arg",
")",
"{",
"// If layer can legally fire this event type",
"if",
"(",
"_layerCanFireEvent",
"(",
"layer",
",",
"eventType",
")",
")",
"{",
"// Do not set a cust... | Trigger the given event on the given layer | [
"Trigger",
"the",
"given",
"event",
"on",
"the",
"given",
"layer"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1402-L1420 | train |
caleb531/jcanvas | dist/jcanvas.js | _parseEndValues | function _parseEndValues(canvas, layer, endValues) {
var propName, propValue,
subPropName, subPropValue;
// Loop through all properties in map of end values
for (propName in endValues) {
if (Object.prototype.hasOwnProperty.call(endValues, propName)) {
propValue = endValues[propName];
// If end value is fun... | javascript | function _parseEndValues(canvas, layer, endValues) {
var propName, propValue,
subPropName, subPropValue;
// Loop through all properties in map of end values
for (propName in endValues) {
if (Object.prototype.hasOwnProperty.call(endValues, propName)) {
propValue = endValues[propName];
// If end value is fun... | [
"function",
"_parseEndValues",
"(",
"canvas",
",",
"layer",
",",
"endValues",
")",
"{",
"var",
"propName",
",",
"propValue",
",",
"subPropName",
",",
"subPropValue",
";",
"// Loop through all properties in map of end values",
"for",
"(",
"propName",
"in",
"endValues",... | Evaluate property values that are functions | [
"Evaluate",
"property",
"values",
"that",
"are",
"functions"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1785-L1817 | train |
caleb531/jcanvas | dist/jcanvas.js | _removeSubPropAliases | function _removeSubPropAliases(layer) {
var propName;
for (propName in layer) {
if (Object.prototype.hasOwnProperty.call(layer, propName)) {
if (propName.indexOf('.') !== -1) {
delete layer[propName];
}
}
}
} | javascript | function _removeSubPropAliases(layer) {
var propName;
for (propName in layer) {
if (Object.prototype.hasOwnProperty.call(layer, propName)) {
if (propName.indexOf('.') !== -1) {
delete layer[propName];
}
}
}
} | [
"function",
"_removeSubPropAliases",
"(",
"layer",
")",
"{",
"var",
"propName",
";",
"for",
"(",
"propName",
"in",
"layer",
")",
"{",
"if",
"(",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"layer",
",",
"propName",
")",
")",
"{",... | Remove sub-property aliases from layer object | [
"Remove",
"sub",
"-",
"property",
"aliases",
"from",
"layer",
"object"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1820-L1829 | train |
caleb531/jcanvas | dist/jcanvas.js | _colorToRgbArray | function _colorToRgbArray(color) {
var originalColor, elem,
rgb = [],
multiple = 1;
// Deal with complete transparency
if (color === 'transparent') {
color = 'rgba(0, 0, 0, 0)';
} else if (color.match(/^([a-z]+|#[0-9a-f]+)$/gi)) {
// Deal with hexadecimal colors and color names
elem = document.head;
or... | javascript | function _colorToRgbArray(color) {
var originalColor, elem,
rgb = [],
multiple = 1;
// Deal with complete transparency
if (color === 'transparent') {
color = 'rgba(0, 0, 0, 0)';
} else if (color.match(/^([a-z]+|#[0-9a-f]+)$/gi)) {
// Deal with hexadecimal colors and color names
elem = document.head;
or... | [
"function",
"_colorToRgbArray",
"(",
"color",
")",
"{",
"var",
"originalColor",
",",
"elem",
",",
"rgb",
"=",
"[",
"]",
",",
"multiple",
"=",
"1",
";",
"// Deal with complete transparency",
"if",
"(",
"color",
"===",
"'transparent'",
")",
"{",
"color",
"=",
... | Convert a color value to an array of RGB values | [
"Convert",
"a",
"color",
"value",
"to",
"an",
"array",
"of",
"RGB",
"values"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1832-L1866 | train |
caleb531/jcanvas | dist/jcanvas.js | _animateColor | function _animateColor(fx) {
var n = 3,
i;
// Only parse start and end colors once
if (typeOf(fx.start) !== 'array') {
fx.start = _colorToRgbArray(fx.start);
fx.end = _colorToRgbArray(fx.end);
}
fx.now = [];
// If colors are RGBA, animate transparency
if (fx.start[3] !== 1 || fx.end[3] !== 1) {
n = 4;
... | javascript | function _animateColor(fx) {
var n = 3,
i;
// Only parse start and end colors once
if (typeOf(fx.start) !== 'array') {
fx.start = _colorToRgbArray(fx.start);
fx.end = _colorToRgbArray(fx.end);
}
fx.now = [];
// If colors are RGBA, animate transparency
if (fx.start[3] !== 1 || fx.end[3] !== 1) {
n = 4;
... | [
"function",
"_animateColor",
"(",
"fx",
")",
"{",
"var",
"n",
"=",
"3",
",",
"i",
";",
"// Only parse start and end colors once",
"if",
"(",
"typeOf",
"(",
"fx",
".",
"start",
")",
"!==",
"'array'",
")",
"{",
"fx",
".",
"start",
"=",
"_colorToRgbArray",
... | Animate a hex or RGB color | [
"Animate",
"a",
"hex",
"or",
"RGB",
"color"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1869-L1906 | train |
caleb531/jcanvas | dist/jcanvas.js | complete | function complete($canvas, data, layer) {
return function () {
_showProps(layer);
_removeSubPropAliases(layer);
// Prevent multiple redraw loops
if (!data.animating || data.animated === layer) {
// Redraw layers on last frame
$canvas.drawLayers();
}
// Signify the end of an animation loo... | javascript | function complete($canvas, data, layer) {
return function () {
_showProps(layer);
_removeSubPropAliases(layer);
// Prevent multiple redraw loops
if (!data.animating || data.animated === layer) {
// Redraw layers on last frame
$canvas.drawLayers();
}
// Signify the end of an animation loo... | [
"function",
"complete",
"(",
"$canvas",
",",
"data",
",",
"layer",
")",
"{",
"return",
"function",
"(",
")",
"{",
"_showProps",
"(",
"layer",
")",
";",
"_removeSubPropAliases",
"(",
"layer",
")",
";",
"// Prevent multiple redraw loops",
"if",
"(",
"!",
"data... | Run callback function when animation completes | [
"Run",
"callback",
"function",
"when",
"animation",
"completes"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L1956-L1984 | train |
caleb531/jcanvas | dist/jcanvas.js | _supportColorProps | function _supportColorProps(props) {
var p;
for (p = 0; p < props.length; p += 1) {
$.fx.step[props[p]] = _animateColor;
}
} | javascript | function _supportColorProps(props) {
var p;
for (p = 0; p < props.length; p += 1) {
$.fx.step[props[p]] = _animateColor;
}
} | [
"function",
"_supportColorProps",
"(",
"props",
")",
"{",
"var",
"p",
";",
"for",
"(",
"p",
"=",
"0",
";",
"p",
"<",
"props",
".",
"length",
";",
"p",
"+=",
"1",
")",
"{",
"$",
".",
"fx",
".",
"step",
"[",
"props",
"[",
"p",
"]",
"]",
"=",
... | Enable animation for color properties | [
"Enable",
"animation",
"for",
"color",
"properties"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L2202-L2207 | train |
caleb531/jcanvas | dist/jcanvas.js | _getMouseEventName | function _getMouseEventName(eventName) {
if (maps.mouseEvents[eventName]) {
eventName = maps.mouseEvents[eventName];
}
return eventName;
} | javascript | function _getMouseEventName(eventName) {
if (maps.mouseEvents[eventName]) {
eventName = maps.mouseEvents[eventName];
}
return eventName;
} | [
"function",
"_getMouseEventName",
"(",
"eventName",
")",
"{",
"if",
"(",
"maps",
".",
"mouseEvents",
"[",
"eventName",
"]",
")",
"{",
"eventName",
"=",
"maps",
".",
"mouseEvents",
"[",
"eventName",
"]",
";",
"}",
"return",
"eventName",
";",
"}"
] | Convert touch event name to a corresponding mouse event name | [
"Convert",
"touch",
"event",
"name",
"to",
"a",
"corresponding",
"mouse",
"event",
"name"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L2248-L2253 | train |
caleb531/jcanvas | dist/jcanvas.js | _createEvent | function _createEvent(eventName) {
jCanvas.events[eventName] = function ($canvas, data) {
var helperEventName, touchEventName, eventCache;
// Retrieve canvas's event cache
eventCache = data.event;
// Both mouseover/mouseout events will be managed by a single mousemove event
helperEventName = (eventName ==... | javascript | function _createEvent(eventName) {
jCanvas.events[eventName] = function ($canvas, data) {
var helperEventName, touchEventName, eventCache;
// Retrieve canvas's event cache
eventCache = data.event;
// Both mouseover/mouseout events will be managed by a single mousemove event
helperEventName = (eventName ==... | [
"function",
"_createEvent",
"(",
"eventName",
")",
"{",
"jCanvas",
".",
"events",
"[",
"eventName",
"]",
"=",
"function",
"(",
"$canvas",
",",
"data",
")",
"{",
"var",
"helperEventName",
",",
"touchEventName",
",",
"eventCache",
";",
"// Retrieve canvas's event ... | Bind event to jCanvas layer using standard jQuery events | [
"Bind",
"event",
"to",
"jCanvas",
"layer",
"using",
"standard",
"jQuery",
"events"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L2256-L2298 | train |
caleb531/jcanvas | dist/jcanvas.js | _detectEvents | function _detectEvents(canvas, ctx, params) {
var layer, data, eventCache, intersects,
transforms, x, y, angle;
// Use the layer object stored by the given parameters object
layer = params._args;
// Canvas must have event bindings
if (layer) {
data = _getCanvasData(canvas);
eventCache = data.event;
if (e... | javascript | function _detectEvents(canvas, ctx, params) {
var layer, data, eventCache, intersects,
transforms, x, y, angle;
// Use the layer object stored by the given parameters object
layer = params._args;
// Canvas must have event bindings
if (layer) {
data = _getCanvasData(canvas);
eventCache = data.event;
if (e... | [
"function",
"_detectEvents",
"(",
"canvas",
",",
"ctx",
",",
"params",
")",
"{",
"var",
"layer",
",",
"data",
",",
"eventCache",
",",
"intersects",
",",
"transforms",
",",
"x",
",",
"y",
",",
"angle",
";",
"// Use the layer object stored by the given parameters ... | Check if event fires when a drawing is drawn | [
"Check",
"if",
"event",
"fires",
"when",
"a",
"drawing",
"is",
"drawn"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L2324-L2377 | train |
caleb531/jcanvas | dist/jcanvas.js | _addStartArrow | function _addStartArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.startArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | javascript | function _addStartArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.startArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | [
"function",
"_addStartArrow",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"path",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"{",
"if",
"(",
"!",
"path",
".",
"_arrowAngleConverted",
")",
"{",
"path",
".",
"arrowAngle",
"*=",
"params",
".",
... | Optionally adds arrow to start of path | [
"Optionally",
"adds",
"arrow",
"to",
"start",
"of",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3102-L3110 | train |
caleb531/jcanvas | dist/jcanvas.js | _addEndArrow | function _addEndArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.endArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | javascript | function _addEndArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.endArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | [
"function",
"_addEndArrow",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"path",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
"{",
"if",
"(",
"!",
"path",
".",
"_arrowAngleConverted",
")",
"{",
"path",
".",
"arrowAngle",
"*=",
"params",
".",
... | Optionally adds arrow to end of path | [
"Optionally",
"adds",
"arrow",
"to",
"end",
"of",
"path"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3113-L3121 | train |
caleb531/jcanvas | dist/jcanvas.js | _getVectorX | function _getVectorX(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * cos(angle));
} | javascript | function _getVectorX(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * cos(angle));
} | [
"function",
"_getVectorX",
"(",
"params",
",",
"angle",
",",
"length",
")",
"{",
"angle",
"*=",
"params",
".",
"_toRad",
";",
"angle",
"-=",
"(",
"PI",
"/",
"2",
")",
";",
"return",
"(",
"length",
"*",
"cos",
"(",
"angle",
")",
")",
";",
"}"
] | Retrieves the x-coordinate for the given vector angle and length | [
"Retrieves",
"the",
"x",
"-",
"coordinate",
"for",
"the",
"given",
"vector",
"angle",
"and",
"length"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3366-L3370 | train |
caleb531/jcanvas | dist/jcanvas.js | _getVectorY | function _getVectorY(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * sin(angle));
} | javascript | function _getVectorY(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * sin(angle));
} | [
"function",
"_getVectorY",
"(",
"params",
",",
"angle",
",",
"length",
")",
"{",
"angle",
"*=",
"params",
".",
"_toRad",
";",
"angle",
"-=",
"(",
"PI",
"/",
"2",
")",
";",
"return",
"(",
"length",
"*",
"sin",
"(",
"angle",
")",
")",
";",
"}"
] | Retrieves the y-coordinate for the given vector angle and length | [
"Retrieves",
"the",
"y",
"-",
"coordinate",
"for",
"the",
"given",
"vector",
"angle",
"and",
"length"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3372-L3376 | train |
caleb531/jcanvas | dist/jcanvas.js | _measureText | function _measureText(canvas, ctx, params, lines) {
var originalSize, curWidth, l,
propCache = caches.propCache;
// Used cached width/height if possible
if (propCache.text === params.text && propCache.fontStyle === params.fontStyle && propCache.fontSize === params.fontSize && propCache.fontFamily === params.fontF... | javascript | function _measureText(canvas, ctx, params, lines) {
var originalSize, curWidth, l,
propCache = caches.propCache;
// Used cached width/height if possible
if (propCache.text === params.text && propCache.fontStyle === params.fontStyle && propCache.fontSize === params.fontSize && propCache.fontFamily === params.fontF... | [
"function",
"_measureText",
"(",
"canvas",
",",
"ctx",
",",
"params",
",",
"lines",
")",
"{",
"var",
"originalSize",
",",
"curWidth",
",",
"l",
",",
"propCache",
"=",
"caches",
".",
"propCache",
";",
"// Used cached width/height if possible",
"if",
"(",
"propC... | Measures canvas text | [
"Measures",
"canvas",
"text"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3537-L3573 | train |
caleb531/jcanvas | dist/jcanvas.js | _wrapText | function _wrapText(ctx, params) {
var allText = String(params.text),
// Maximum line width (optional)
maxWidth = params.maxWidth,
// Lines created by manual line breaks (\n)
manualLines = allText.split('\n'),
// All lines created manually and by wrapping
allLines = [],
// Other variables
lines, line, l... | javascript | function _wrapText(ctx, params) {
var allText = String(params.text),
// Maximum line width (optional)
maxWidth = params.maxWidth,
// Lines created by manual line breaks (\n)
manualLines = allText.split('\n'),
// All lines created manually and by wrapping
allLines = [],
// Other variables
lines, line, l... | [
"function",
"_wrapText",
"(",
"ctx",
",",
"params",
")",
"{",
"var",
"allText",
"=",
"String",
"(",
"params",
".",
"text",
")",
",",
"// Maximum line width (optional)",
"maxWidth",
"=",
"params",
".",
"maxWidth",
",",
"// Lines created by manual line breaks (\\n)",
... | Wraps a string of text within a defined width | [
"Wraps",
"a",
"string",
"of",
"text",
"within",
"a",
"defined",
"width"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas.js#L3576-L3640 | train |
caleb531/jcanvas | dist/jcanvas-crescents.js | getIntersection | function getIntersection(x0, y0, r0, x1, y1, r1) {
var dx = x1 - x0,
dy = y1 - y0,
d = sqrt(pow(dx, 2) + pow(dy, 2)),
a = (pow(d, 2) + pow(r0, 2) - pow(r1, 2)) / (2 * d),
x2 = x0 + (dx * a / d),
y2 = y0 + (dy * a / d),
h = sqrt(pow(r0, 2) - pow(a, 2)),
rx = -dy * (h / d),
ry = dx * (h / d),
xi = x2 +... | javascript | function getIntersection(x0, y0, r0, x1, y1, r1) {
var dx = x1 - x0,
dy = y1 - y0,
d = sqrt(pow(dx, 2) + pow(dy, 2)),
a = (pow(d, 2) + pow(r0, 2) - pow(r1, 2)) / (2 * d),
x2 = x0 + (dx * a / d),
y2 = y0 + (dy * a / d),
h = sqrt(pow(r0, 2) - pow(a, 2)),
rx = -dy * (h / d),
ry = dx * (h / d),
xi = x2 +... | [
"function",
"getIntersection",
"(",
"x0",
",",
"y0",
",",
"r0",
",",
"x1",
",",
"y1",
",",
"r1",
")",
"{",
"var",
"dx",
"=",
"x1",
"-",
"x0",
",",
"dy",
"=",
"y1",
"-",
"y0",
",",
"d",
"=",
"sqrt",
"(",
"pow",
"(",
"dx",
",",
"2",
")",
"+... | Get the topmost intersection point of two circles | [
"Get",
"the",
"topmost",
"intersection",
"point",
"of",
"two",
"circles"
] | d156506c4c0890419414af7de8dea1740c91884a | https://github.com/caleb531/jcanvas/blob/d156506c4c0890419414af7de8dea1740c91884a/dist/jcanvas-crescents.js#L15-L33 | train |
choojs/nanohtml | lib/babel.js | getElementName | function getElementName (props, tag) {
if (typeof props.id === 'string' && !placeholderRe.test(props.id)) {
return camelCase(props.id)
}
if (typeof props.className === 'string' && !placeholderRe.test(props.className)) {
return camelCase(props.className.split(' ')[0])
}
return tag || 'nanohtml'
} | javascript | function getElementName (props, tag) {
if (typeof props.id === 'string' && !placeholderRe.test(props.id)) {
return camelCase(props.id)
}
if (typeof props.className === 'string' && !placeholderRe.test(props.className)) {
return camelCase(props.className.split(' ')[0])
}
return tag || 'nanohtml'
} | [
"function",
"getElementName",
"(",
"props",
",",
"tag",
")",
"{",
"if",
"(",
"typeof",
"props",
".",
"id",
"===",
"'string'",
"&&",
"!",
"placeholderRe",
".",
"test",
"(",
"props",
".",
"id",
")",
")",
"{",
"return",
"camelCase",
"(",
"props",
".",
"... | Try to return a nice variable name for an element based on its HTML id,
classname, or tagname. | [
"Try",
"to",
"return",
"a",
"nice",
"variable",
"name",
"for",
"an",
"element",
"based",
"on",
"its",
"HTML",
"id",
"classname",
"or",
"tagname",
"."
] | 535063575a2ff3ff0fbd8eb2d118d8f4279760c3 | https://github.com/choojs/nanohtml/blob/535063575a2ff3ff0fbd8eb2d118d8f4279760c3/lib/babel.js#L17-L25 | train |
choojs/nanohtml | lib/babel.js | convertPlaceholders | function convertPlaceholders (value) {
// Probably AST nodes.
if (typeof value !== 'string') {
return [value]
}
const items = value.split(placeholderRe)
let placeholder = true
return items.map((item) => {
placeholder = !placeholder
return placeholder ? expres... | javascript | function convertPlaceholders (value) {
// Probably AST nodes.
if (typeof value !== 'string') {
return [value]
}
const items = value.split(placeholderRe)
let placeholder = true
return items.map((item) => {
placeholder = !placeholder
return placeholder ? expres... | [
"function",
"convertPlaceholders",
"(",
"value",
")",
"{",
"// Probably AST nodes.",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"[",
"value",
"]",
"}",
"const",
"items",
"=",
"value",
".",
"split",
"(",
"placeholderRe",
")",
"let",
... | Convert placeholders used in the template string back to the AST nodes
they reference. | [
"Convert",
"placeholders",
"used",
"in",
"the",
"template",
"string",
"back",
"to",
"the",
"AST",
"nodes",
"they",
"reference",
"."
] | 535063575a2ff3ff0fbd8eb2d118d8f4279760c3 | https://github.com/choojs/nanohtml/blob/535063575a2ff3ff0fbd8eb2d118d8f4279760c3/lib/babel.js#L206-L218 | train |
ekalinin/sitemap.js | lib/sitemap.js | buildSitemapIndex | function buildSitemapIndex (conf) {
var xml = [];
var lastmod;
xml.push('<?xml version="1.0" encoding="UTF-8"?>');
if (conf.xslUrl) {
xml.push('<?xml-stylesheet type="text/xsl" href="' + conf.xslUrl + '"?>');
}
if (!conf.xmlNs) {
xml.push('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitema... | javascript | function buildSitemapIndex (conf) {
var xml = [];
var lastmod;
xml.push('<?xml version="1.0" encoding="UTF-8"?>');
if (conf.xslUrl) {
xml.push('<?xml-stylesheet type="text/xsl" href="' + conf.xslUrl + '"?>');
}
if (!conf.xmlNs) {
xml.push('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitema... | [
"function",
"buildSitemapIndex",
"(",
"conf",
")",
"{",
"var",
"xml",
"=",
"[",
"]",
";",
"var",
"lastmod",
";",
"xml",
".",
"push",
"(",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
")",
";",
"if",
"(",
"conf",
".",
"xslUrl",
")",
"{",
"xml",
".",
"p... | Builds a sitemap index from urls
@param {Object} conf
@param {Array} conf.urls
@param {String} conf.xslUrl
@param {String} conf.xmlNs
@return {String} XML String of SitemapIndex | [
"Builds",
"a",
"sitemap",
"index",
"from",
"urls"
] | 682e9fc731b476e0c0263fe683fbd0e392b7b49b | https://github.com/ekalinin/sitemap.js/blob/682e9fc731b476e0c0263fe683fbd0e392b7b49b/lib/sitemap.js#L272-L315 | train |
cerebral/cerebral | packages/website/builder/pages/docs/nav.js | Headings | function Headings({ toc, path }) {
if (!toc.length) {
return null
}
return (
<ul>
{toc.map(function(item, index) {
const href = `${path}#${item.id}`
return (
<li key={index}>
{item.children.length > 0 && (
<input
... | javascript | function Headings({ toc, path }) {
if (!toc.length) {
return null
}
return (
<ul>
{toc.map(function(item, index) {
const href = `${path}#${item.id}`
return (
<li key={index}>
{item.children.length > 0 && (
<input
... | [
"function",
"Headings",
"(",
"{",
"toc",
",",
"path",
"}",
")",
"{",
"if",
"(",
"!",
"toc",
".",
"length",
")",
"{",
"return",
"null",
"}",
"return",
"(",
"<",
"ul",
">",
"\n ",
"{",
"toc",
".",
"map",
"(",
"function",
"(",
"item",
",",
... | To understand how navigation is composed, start from the bottom | [
"To",
"understand",
"how",
"navigation",
"is",
"composed",
"start",
"from",
"the",
"bottom"
] | a5f1f5e584cbf570ace94347254e5e42b336156b | https://github.com/cerebral/cerebral/blob/a5f1f5e584cbf570ace94347254e5e42b336156b/packages/website/builder/pages/docs/nav.js#L6-L38 | train |
feross/spoof | index.js | findInterfaces | function findInterfaces (targets) {
if (!targets) targets = []
targets = targets.map(target => target.toLowerCase())
if (process.platform === 'darwin') {
return findInterfacesDarwin(targets)
} else if (process.platform === 'linux') {
return findInterfacesLinux(targets)
} else if (process.platform ==... | javascript | function findInterfaces (targets) {
if (!targets) targets = []
targets = targets.map(target => target.toLowerCase())
if (process.platform === 'darwin') {
return findInterfacesDarwin(targets)
} else if (process.platform === 'linux') {
return findInterfacesLinux(targets)
} else if (process.platform ==... | [
"function",
"findInterfaces",
"(",
"targets",
")",
"{",
"if",
"(",
"!",
"targets",
")",
"targets",
"=",
"[",
"]",
"targets",
"=",
"targets",
".",
"map",
"(",
"target",
"=>",
"target",
".",
"toLowerCase",
"(",
")",
")",
"if",
"(",
"process",
".",
"pla... | Returns the list of interfaces found on this machine as reported by the
`networksetup` command.
@param {Array.<string>|null} targets
@return {Array.<Object>)} | [
"Returns",
"the",
"list",
"of",
"interfaces",
"found",
"on",
"this",
"machine",
"as",
"reported",
"by",
"the",
"networksetup",
"command",
"."
] | 4ccb8f916b348ed761bc69777902e5c8957ff1fe | https://github.com/feross/spoof/blob/4ccb8f916b348ed761bc69777902e5c8957ff1fe/index.js#L34-L46 | train |
feross/spoof | index.js | getInterfaceMAC | function getInterfaceMAC (device) {
if (process.platform === 'darwin' || process.platform === 'linux') {
let output
try {
output = cp.execSync(quote(['ifconfig', device]), { stdio: 'pipe' }).toString()
} catch (err) {
return null
}
const address = MAC_ADDRESS_RE.exec(output)
retur... | javascript | function getInterfaceMAC (device) {
if (process.platform === 'darwin' || process.platform === 'linux') {
let output
try {
output = cp.execSync(quote(['ifconfig', device]), { stdio: 'pipe' }).toString()
} catch (err) {
return null
}
const address = MAC_ADDRESS_RE.exec(output)
retur... | [
"function",
"getInterfaceMAC",
"(",
"device",
")",
"{",
"if",
"(",
"process",
".",
"platform",
"===",
"'darwin'",
"||",
"process",
".",
"platform",
"===",
"'linux'",
")",
"{",
"let",
"output",
"try",
"{",
"output",
"=",
"cp",
".",
"execSync",
"(",
"quote... | Returns currently-set MAC address of given interface. This is distinct from the
interface's hardware MAC address.
@return {string} | [
"Returns",
"currently",
"-",
"set",
"MAC",
"address",
"of",
"given",
"interface",
".",
"This",
"is",
"distinct",
"from",
"the",
"interface",
"s",
"hardware",
"MAC",
"address",
"."
] | 4ccb8f916b348ed761bc69777902e5c8957ff1fe | https://github.com/feross/spoof/blob/4ccb8f916b348ed761bc69777902e5c8957ff1fe/index.js#L253-L267 | train |
feross/spoof | index.js | setInterfaceMAC | function setInterfaceMAC (device, mac, port) {
if (!MAC_ADDRESS_RE.exec(mac)) {
throw new Error(mac + ' is not a valid MAC address')
}
const isWirelessPort = port && port.toLowerCase() === 'wi-fi'
if (process.platform === 'darwin') {
if (isWirelessPort) {
// Turn on the device, assuming it's an ... | javascript | function setInterfaceMAC (device, mac, port) {
if (!MAC_ADDRESS_RE.exec(mac)) {
throw new Error(mac + ' is not a valid MAC address')
}
const isWirelessPort = port && port.toLowerCase() === 'wi-fi'
if (process.platform === 'darwin') {
if (isWirelessPort) {
// Turn on the device, assuming it's an ... | [
"function",
"setInterfaceMAC",
"(",
"device",
",",
"mac",
",",
"port",
")",
"{",
"if",
"(",
"!",
"MAC_ADDRESS_RE",
".",
"exec",
"(",
"mac",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"mac",
"+",
"' is not a valid MAC address'",
")",
"}",
"const",
"isWi... | Sets the mac address for given `device` to `mac`.
Device varies by platform:
OS X, Linux: this is the interface name in ifconfig
Windows: this is the network adapter name in ipconfig
@param {string} device
@param {string} mac
@param {string=} port | [
"Sets",
"the",
"mac",
"address",
"for",
"given",
"device",
"to",
"mac",
"."
] | 4ccb8f916b348ed761bc69777902e5c8957ff1fe | https://github.com/feross/spoof/blob/4ccb8f916b348ed761bc69777902e5c8957ff1fe/index.js#L280-L347 | train |
feross/spoof | index.js | tryWindowsKey | function tryWindowsKey (key, device, mac) {
// Skip the Properties key to avoid problems with permissions
if (key.indexOf('Properties') > -1) {
return false
}
const networkAdapterKeyPath = new Winreg({
hive: Winreg.HKLM,
key: key
})
// we need to format the MAC a bit for Windows
mac = mac.re... | javascript | function tryWindowsKey (key, device, mac) {
// Skip the Properties key to avoid problems with permissions
if (key.indexOf('Properties') > -1) {
return false
}
const networkAdapterKeyPath = new Winreg({
hive: Winreg.HKLM,
key: key
})
// we need to format the MAC a bit for Windows
mac = mac.re... | [
"function",
"tryWindowsKey",
"(",
"key",
",",
"device",
",",
"mac",
")",
"{",
"// Skip the Properties key to avoid problems with permissions",
"if",
"(",
"key",
".",
"indexOf",
"(",
"'Properties'",
")",
">",
"-",
"1",
")",
"{",
"return",
"false",
"}",
"const",
... | Tries to set the "NetworkAddress" value on the specified registry key for given
`device` to `mac`.
@param {string} key
@param {string} device
@param {string} mac | [
"Tries",
"to",
"set",
"the",
"NetworkAddress",
"value",
"on",
"the",
"specified",
"registry",
"key",
"for",
"given",
"device",
"to",
"mac",
"."
] | 4ccb8f916b348ed761bc69777902e5c8957ff1fe | https://github.com/feross/spoof/blob/4ccb8f916b348ed761bc69777902e5c8957ff1fe/index.js#L357-L395 | train |
feross/spoof | index.js | randomize | function randomize (localAdmin) {
// Randomly assign a VM vendor's MAC address prefix, which should
// decrease chance of colliding with existing device's addresses.
const vendors = [
[ 0x00, 0x05, 0x69 ], // VMware
[ 0x00, 0x50, 0x56 ], // VMware
[ 0x00, 0x0C, 0x29 ], // VMware
[ 0x00, 0x16, 0x3... | javascript | function randomize (localAdmin) {
// Randomly assign a VM vendor's MAC address prefix, which should
// decrease chance of colliding with existing device's addresses.
const vendors = [
[ 0x00, 0x05, 0x69 ], // VMware
[ 0x00, 0x50, 0x56 ], // VMware
[ 0x00, 0x0C, 0x29 ], // VMware
[ 0x00, 0x16, 0x3... | [
"function",
"randomize",
"(",
"localAdmin",
")",
"{",
"// Randomly assign a VM vendor's MAC address prefix, which should",
"// decrease chance of colliding with existing device's addresses.",
"const",
"vendors",
"=",
"[",
"[",
"0x00",
",",
"0x05",
",",
"0x69",
"]",
",",
"// V... | Generates and returns a random MAC address.
@param {boolean} localAdmin locally administered address
@return {string} | [
"Generates",
"and",
"returns",
"a",
"random",
"MAC",
"address",
"."
] | 4ccb8f916b348ed761bc69777902e5c8957ff1fe | https://github.com/feross/spoof/blob/4ccb8f916b348ed761bc69777902e5c8957ff1fe/index.js#L402-L457 | train |
Workshape/icon-font-generator | lib/utils.js | logOutput | function logOutput(options, parts) {
const msg = `${ 'Generated '.blue }${ path.resolve.apply(path, parts).cyan }`
log(options, msg)
} | javascript | function logOutput(options, parts) {
const msg = `${ 'Generated '.blue }${ path.resolve.apply(path, parts).cyan }`
log(options, msg)
} | [
"function",
"logOutput",
"(",
"options",
",",
"parts",
")",
"{",
"const",
"msg",
"=",
"`",
"${",
"'Generated '",
".",
"blue",
"}",
"${",
"path",
".",
"resolve",
".",
"apply",
"(",
"path",
",",
"parts",
")",
".",
"cyan",
"}",
"`",
"log",
"(",
"optio... | Log output file generation
@param {Object} options
@param {[String]} parts
@return {void} | [
"Log",
"output",
"file",
"generation"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/utils.js#L26-L29 | train |
Workshape/icon-font-generator | lib/index.js | generate | async function generate(options = {}) {
options = Object.assign(DEFAULT_OPTIONS, options)
// Log start
let msg = `Generating font kit from ${ options.paths.length } SVG icons`.yellow
log(options, msg)
// Run validation over options
await validateOptions(options)
if (options.codepoints) {
options.co... | javascript | async function generate(options = {}) {
options = Object.assign(DEFAULT_OPTIONS, options)
// Log start
let msg = `Generating font kit from ${ options.paths.length } SVG icons`.yellow
log(options, msg)
// Run validation over options
await validateOptions(options)
if (options.codepoints) {
options.co... | [
"async",
"function",
"generate",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"options",
"=",
"Object",
".",
"assign",
"(",
"DEFAULT_OPTIONS",
",",
"options",
")",
"// Log start",
"let",
"msg",
"=",
"`",
"${",
"options",
".",
"paths",
".",
"length",
"}",
"... | Generate icon font set asynchronously
@param {Object} options
@param {Function} callback
@return {void} | [
"Generate",
"icon",
"font",
"set",
"asynchronously"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L29-L57 | train |
Workshape/icon-font-generator | lib/index.js | getGeneratorConfig | function getGeneratorConfig(options) {
const { tag, classNames } = parseSelector(options.baseSelector)
const config = {
files : options.paths,
dest : options.outputDir,
types : options.types,
codepoints : options.codepointsMap,
startCodepoint : options.startC... | javascript | function getGeneratorConfig(options) {
const { tag, classNames } = parseSelector(options.baseSelector)
const config = {
files : options.paths,
dest : options.outputDir,
types : options.types,
codepoints : options.codepointsMap,
startCodepoint : options.startC... | [
"function",
"getGeneratorConfig",
"(",
"options",
")",
"{",
"const",
"{",
"tag",
",",
"classNames",
"}",
"=",
"parseSelector",
"(",
"options",
".",
"baseSelector",
")",
"const",
"config",
"=",
"{",
"files",
":",
"options",
".",
"paths",
",",
"dest",
":",
... | Transform options Object in a configuration accepted by the generator
@param {Object} options
@return {void} | [
"Transform",
"options",
"Object",
"in",
"a",
"configuration",
"accepted",
"by",
"the",
"generator"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L65-L103 | train |
Workshape/icon-font-generator | lib/index.js | parseSelector | function parseSelector(selector = '') {
const tagMatch = selector.match(/^[a-zA-Z0-9='"[\]_-]*/g)
const classNamesMatch = selector.match(/\.[a-zA-Z0-1_-]*/g)
return {
tag: tagMatch ? tagMatch[0] : undefined,
classNames: classNamesMatch ? classNamesMatch.map(cname => cname.substr(1)) : []
}
} | javascript | function parseSelector(selector = '') {
const tagMatch = selector.match(/^[a-zA-Z0-9='"[\]_-]*/g)
const classNamesMatch = selector.match(/\.[a-zA-Z0-1_-]*/g)
return {
tag: tagMatch ? tagMatch[0] : undefined,
classNames: classNamesMatch ? classNamesMatch.map(cname => cname.substr(1)) : []
}
} | [
"function",
"parseSelector",
"(",
"selector",
"=",
"''",
")",
"{",
"const",
"tagMatch",
"=",
"selector",
".",
"match",
"(",
"/",
"^[a-zA-Z0-9='\"[\\]_-]*",
"/",
"g",
")",
"const",
"classNamesMatch",
"=",
"selector",
".",
"match",
"(",
"/",
"\\.[a-zA-Z0-1_-]*",... | Parse tag and classNames from given selector, if any are specified
@param {?String} selector
@return {Object} | [
"Parse",
"tag",
"and",
"classNames",
"from",
"given",
"selector",
"if",
"any",
"are",
"specified"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L111-L119 | train |
Workshape/icon-font-generator | lib/index.js | getCssFontsUrl | function getCssFontsUrl(options) {
if (options.cssFontsUrl) {
return options.cssFontsUrl
} if (options.cssPath) {
return path.relative(path.dirname(options.cssPath), options.outputDir)
}
return './'
} | javascript | function getCssFontsUrl(options) {
if (options.cssFontsUrl) {
return options.cssFontsUrl
} if (options.cssPath) {
return path.relative(path.dirname(options.cssPath), options.outputDir)
}
return './'
} | [
"function",
"getCssFontsUrl",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"cssFontsUrl",
")",
"{",
"return",
"options",
".",
"cssFontsUrl",
"}",
"if",
"(",
"options",
".",
"cssPath",
")",
"{",
"return",
"path",
".",
"relative",
"(",
"path",
".",... | Based on given options, compute value that should be used as a base URL for font files from the generated CSS
If a `cssFontsUrl` option is explicitally provided, it overrides default behaviour
Else if the CSS was output at a custom filepath, compute a relative path from there
Just return './' otherwise
@param {Obj... | [
"Based",
"on",
"given",
"options",
"compute",
"value",
"that",
"should",
"be",
"used",
"as",
"a",
"base",
"URL",
"for",
"font",
"files",
"from",
"the",
"generated",
"CSS"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L133-L141 | train |
Workshape/icon-font-generator | lib/index.js | getCodepointsMap | async function getCodepointsMap(filepath) {
const content = await fsAsync.readFile(filepath)
let codepointsMap
try {
codepointsMap = JSON.parse(content)
} catch (e) {
throw new ValidationError('Codepoints map is invalid JSON')
}
for (let propName in codepointsMap) {
codepointsMap[propName] = N... | javascript | async function getCodepointsMap(filepath) {
const content = await fsAsync.readFile(filepath)
let codepointsMap
try {
codepointsMap = JSON.parse(content)
} catch (e) {
throw new ValidationError('Codepoints map is invalid JSON')
}
for (let propName in codepointsMap) {
codepointsMap[propName] = N... | [
"async",
"function",
"getCodepointsMap",
"(",
"filepath",
")",
"{",
"const",
"content",
"=",
"await",
"fsAsync",
".",
"readFile",
"(",
"filepath",
")",
"let",
"codepointsMap",
"try",
"{",
"codepointsMap",
"=",
"JSON",
".",
"parse",
"(",
"content",
")",
"}",
... | Correctly parse codepoints map
@param {Object} options
@return {void} | [
"Correctly",
"parse",
"codepoints",
"map"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L149-L164 | train |
Workshape/icon-font-generator | lib/index.js | getResolvedPath | function getResolvedPath(options, type = 'html') {
const explicitPathKey = `${ type }Path`
if (options[explicitPathKey]) {
return path.resolve(options[explicitPathKey])
}
return path.resolve(options.outputDir, `${ options.fontName }.${ type }`)
} | javascript | function getResolvedPath(options, type = 'html') {
const explicitPathKey = `${ type }Path`
if (options[explicitPathKey]) {
return path.resolve(options[explicitPathKey])
}
return path.resolve(options.outputDir, `${ options.fontName }.${ type }`)
} | [
"function",
"getResolvedPath",
"(",
"options",
",",
"type",
"=",
"'html'",
")",
"{",
"const",
"explicitPathKey",
"=",
"`",
"${",
"type",
"}",
"`",
"if",
"(",
"options",
"[",
"explicitPathKey",
"]",
")",
"{",
"return",
"path",
".",
"resolve",
"(",
"option... | Assume the absolute path at which the file of given type should be written
@param {Object} options
@param {?String} type
@return {void} | [
"Assume",
"the",
"absolute",
"path",
"at",
"which",
"the",
"file",
"of",
"given",
"type",
"should",
"be",
"written"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L173-L181 | train |
Workshape/icon-font-generator | lib/index.js | logReport | function logReport(options) {
const { outputDir, fontName } = options
// Log font files output
for (let ext of options.types) { logOutput(options, [ outputDir, `${ fontName }.${ ext }` ]) }
// Log HTML file output
if (options.html) {
logOutput(options, [ getResolvedPath(options, 'html') ])
}
// Log... | javascript | function logReport(options) {
const { outputDir, fontName } = options
// Log font files output
for (let ext of options.types) { logOutput(options, [ outputDir, `${ fontName }.${ ext }` ]) }
// Log HTML file output
if (options.html) {
logOutput(options, [ getResolvedPath(options, 'html') ])
}
// Log... | [
"function",
"logReport",
"(",
"options",
")",
"{",
"const",
"{",
"outputDir",
",",
"fontName",
"}",
"=",
"options",
"// Log font files output",
"for",
"(",
"let",
"ext",
"of",
"options",
".",
"types",
")",
"{",
"logOutput",
"(",
"options",
",",
"[",
"outpu... | Log report with all generated files and completion message
@param {Object} options
@return {void} | [
"Log",
"report",
"with",
"all",
"generated",
"files",
"and",
"completion",
"message"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L189-L212 | train |
Workshape/icon-font-generator | lib/index.js | generateJson | async function generateJson(options, generatorResult) {
const jsonPath = (
options.jsonPath ||
`${ path.join(options.outputDir, '/' + options.fontName) }.json`
)
const css = generatorResult.generateCss()
let map = {}
css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)
await fsAs... | javascript | async function generateJson(options, generatorResult) {
const jsonPath = (
options.jsonPath ||
`${ path.join(options.outputDir, '/' + options.fontName) }.json`
)
const css = generatorResult.generateCss()
let map = {}
css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)
await fsAs... | [
"async",
"function",
"generateJson",
"(",
"options",
",",
"generatorResult",
")",
"{",
"const",
"jsonPath",
"=",
"(",
"options",
".",
"jsonPath",
"||",
"`",
"${",
"path",
".",
"join",
"(",
"options",
".",
"outputDir",
",",
"'/'",
"+",
"options",
".",
"fo... | Generate JSON icons map by parsing the generated CSS
@param {Object} options
@return {void} | [
"Generate",
"JSON",
"icons",
"map",
"by",
"parsing",
"the",
"generated",
"CSS"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L220-L232 | train |
Workshape/icon-font-generator | lib/index.js | deleteUnspecifiedTypes | async function deleteUnspecifiedTypes(options) {
const { outputDir, fontName, types } = options
for (let ext of FONT_TYPES) {
if (types.indexOf(ext) !== -1) { continue }
let filepath = path.resolve(outputDir, `${ fontName }.${ ext }`)
if (await fsAsync.exists(filepath)) {
await fsAsync.unlink(f... | javascript | async function deleteUnspecifiedTypes(options) {
const { outputDir, fontName, types } = options
for (let ext of FONT_TYPES) {
if (types.indexOf(ext) !== -1) { continue }
let filepath = path.resolve(outputDir, `${ fontName }.${ ext }`)
if (await fsAsync.exists(filepath)) {
await fsAsync.unlink(f... | [
"async",
"function",
"deleteUnspecifiedTypes",
"(",
"options",
")",
"{",
"const",
"{",
"outputDir",
",",
"fontName",
",",
"types",
"}",
"=",
"options",
"for",
"(",
"let",
"ext",
"of",
"FONT_TYPES",
")",
"{",
"if",
"(",
"types",
".",
"indexOf",
"(",
"ext"... | Delete generated fonts with extensions that weren't specified
@param {Object} options
@return {void} | [
"Delete",
"generated",
"fonts",
"with",
"extensions",
"that",
"weren",
"t",
"specified"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L240-L252 | train |
Workshape/icon-font-generator | lib/index.js | validateOptions | async function validateOptions(options) {
// Check that input glob was passed
if (!options.paths.length) {
throw new ValidationError('No paths specified')
}
// Check that output path was passed
if (!options.outputDir) {
throw new ValidationError('Please specify an output directory with -o or --output... | javascript | async function validateOptions(options) {
// Check that input glob was passed
if (!options.paths.length) {
throw new ValidationError('No paths specified')
}
// Check that output path was passed
if (!options.outputDir) {
throw new ValidationError('Please specify an output directory with -o or --output... | [
"async",
"function",
"validateOptions",
"(",
"options",
")",
"{",
"// Check that input glob was passed",
"if",
"(",
"!",
"options",
".",
"paths",
".",
"length",
")",
"{",
"throw",
"new",
"ValidationError",
"(",
"'No paths specified'",
")",
"}",
"// Check that output... | Asynchronously validate generation options, check existance of given files
and directories
@throws
@param {Object} options
@return {void} | [
"Asynchronously",
"validate",
"generation",
"options",
"check",
"existance",
"of",
"given",
"files",
"and",
"directories"
] | a9ac3b34c7343ee6157176a6a2af00e29939b41c | https://github.com/Workshape/icon-font-generator/blob/a9ac3b34c7343ee6157176a6a2af00e29939b41c/lib/index.js#L262-L308 | train |
socketstream/socketstream | lib/http/index.js | sessionMiddleware | function sessionMiddleware(req,res,next) {
return ss.session.strategy.sessionMiddleware? ss.session.strategy.sessionMiddleware(req,res,next) : next();
} | javascript | function sessionMiddleware(req,res,next) {
return ss.session.strategy.sessionMiddleware? ss.session.strategy.sessionMiddleware(req,res,next) : next();
} | [
"function",
"sessionMiddleware",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"return",
"ss",
".",
"session",
".",
"strategy",
".",
"sessionMiddleware",
"?",
"ss",
".",
"session",
".",
"strategy",
".",
"sessionMiddleware",
"(",
"req",
",",
"res",
",",
... | wrapped to allow using the middleware before the strategy is set | [
"wrapped",
"to",
"allow",
"using",
"the",
"middleware",
"before",
"the",
"strategy",
"is",
"set"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/http/index.js#L132-L134 | train |
socketstream/socketstream | lib/client/bundler/index.js | loadFile | function loadFile(entry, opts, formatter, cb, errCb) {
var type = entry.assetType || entry.bundle;
formatter = formatter || ss.client.formatters[entry.ext || type];
if (!formatter) {
throw new Error('Unsupported file extension \'.' + entry.ext + '\' when we were expecting some type of ' +
... | javascript | function loadFile(entry, opts, formatter, cb, errCb) {
var type = entry.assetType || entry.bundle;
formatter = formatter || ss.client.formatters[entry.ext || type];
if (!formatter) {
throw new Error('Unsupported file extension \'.' + entry.ext + '\' when we were expecting some type of ' +
... | [
"function",
"loadFile",
"(",
"entry",
",",
"opts",
",",
"formatter",
",",
"cb",
",",
"errCb",
")",
"{",
"var",
"type",
"=",
"entry",
".",
"assetType",
"||",
"entry",
".",
"bundle",
";",
"formatter",
"=",
"formatter",
"||",
"ss",
".",
"client",
".",
"... | API for implementing bundlers | [
"API",
"for",
"implementing",
"bundlers"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/bundler/index.js#L220-L238 | train |
socketstream/socketstream | lib/client/bundler/index.js | function(paths) {
function relativePath(p, dirType) {
var relativeStart = p.indexOf('./') === 0 || p.indexOf('../') === 0;
return relativeStart? prefixPath(options.dirs.client,p) : prefixPath(options.dirs[dirType], p);
}
function prefixPath(base,p) {
base = base.replace... | javascript | function(paths) {
function relativePath(p, dirType) {
var relativeStart = p.indexOf('./') === 0 || p.indexOf('../') === 0;
return relativeStart? prefixPath(options.dirs.client,p) : prefixPath(options.dirs[dirType], p);
}
function prefixPath(base,p) {
base = base.replace... | [
"function",
"(",
"paths",
")",
"{",
"function",
"relativePath",
"(",
"p",
",",
"dirType",
")",
"{",
"var",
"relativeStart",
"=",
"p",
".",
"indexOf",
"(",
"'./'",
")",
"===",
"0",
"||",
"p",
".",
"indexOf",
"(",
"'../'",
")",
"===",
"0",
";",
"retu... | input is decorated and returned | [
"input",
"is",
"decorated",
"and",
"returned"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/bundler/index.js#L274-L310 | train | |
socketstream/socketstream | lib/session/memory.js | getSession | function getSession(sessions, sessionId) {
var sess = sessions[sessionId]
if (!sess) {
debug('no session in MemoryStore for %s',sessionId);
return;
}
// parse
sess = JSON.parse(sess)
var expires = typeof sess.cookie.expires === 'string' ?
new Date(sess.cookie.expires) :
sess.cookie.expire... | javascript | function getSession(sessions, sessionId) {
var sess = sessions[sessionId]
if (!sess) {
debug('no session in MemoryStore for %s',sessionId);
return;
}
// parse
sess = JSON.parse(sess)
var expires = typeof sess.cookie.expires === 'string' ?
new Date(sess.cookie.expires) :
sess.cookie.expire... | [
"function",
"getSession",
"(",
"sessions",
",",
"sessionId",
")",
"{",
"var",
"sess",
"=",
"sessions",
"[",
"sessionId",
"]",
"if",
"(",
"!",
"sess",
")",
"{",
"debug",
"(",
"'no session in MemoryStore for %s'",
",",
"sessionId",
")",
";",
"return",
";",
"... | Get session from the store.
@private | [
"Get",
"session",
"from",
"the",
"store",
"."
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/session/memory.js#L172-L195 | train |
socketstream/socketstream | lib/http/cached.js | set | function set(url, content, mimeType) {
if (url.charAt(0) !== '/') { url = '/'+url; }
var point = getPoint(url) || new KnownPoint(url);
// console.info('new url:',url, mimeType);
point.content = content;
point.mimeType = mimeType;
} | javascript | function set(url, content, mimeType) {
if (url.charAt(0) !== '/') { url = '/'+url; }
var point = getPoint(url) || new KnownPoint(url);
// console.info('new url:',url, mimeType);
point.content = content;
point.mimeType = mimeType;
} | [
"function",
"set",
"(",
"url",
",",
"content",
",",
"mimeType",
")",
"{",
"if",
"(",
"url",
".",
"charAt",
"(",
"0",
")",
"!==",
"'/'",
")",
"{",
"url",
"=",
"'/'",
"+",
"url",
";",
"}",
"var",
"point",
"=",
"getPoint",
"(",
"url",
")",
"||",
... | assumed to be dev time frame, if this is to be used for production it should be enhanced | [
"assumed",
"to",
"be",
"dev",
"time",
"frame",
"if",
"this",
"is",
"to",
"be",
"used",
"for",
"production",
"it",
"should",
"be",
"enhanced"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/http/cached.js#L146-L152 | train |
socketstream/socketstream | lib/session/channels.js | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
if (session.channels.indexOf(name) === -1) { // clients can only join a channel once
session.channels.push(n... | javascript | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
if (session.channels.indexOf(name) === -1) { // clients can only join a channel once
session.channels.push(n... | [
"function",
"(",
"names",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
")",
"{",
"cb",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"session",
".",
"channels",
")",
"{",
"session",
".",
"channels",
"=",
"[",
"]",
";",
"}",
"... | Subscribes the client to one or more channels | [
"Subscribes",
"the",
"client",
"to",
"one",
"or",
"more",
"channels"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/session/channels.js#L20-L35 | train | |
socketstream/socketstream | lib/session/channels.js | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
var i;
if ((i = session.channels.indexOf(name)) >= 0) {
session.channels.splice(i, 1);
sub... | javascript | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
var i;
if ((i = session.channels.indexOf(name)) >= 0) {
session.channels.splice(i, 1);
sub... | [
"function",
"(",
"names",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
")",
"{",
"cb",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"session",
".",
"channels",
")",
"{",
"session",
".",
"channels",
"=",
"[",
"]",
";",
"}",
"... | Unsubscribes the client from one or more channels | [
"Unsubscribes",
"the",
"client",
"from",
"one",
"or",
"more",
"channels"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/session/channels.js#L38-L54 | train | |
socketstream/socketstream | lib/utils/file.js | isDir | function isDir(abspath, found) {
var stat = fs.statSync(abspath),
abspathAry = abspath.split('/'),
data,
file_name;
if (!found) {
found = {dirs: [], files: [] }
}
if (stat.isDirectory() && !isHidden(abspathAry[abspathAry.length - 1])) {
found.dirs.push(abs... | javascript | function isDir(abspath, found) {
var stat = fs.statSync(abspath),
abspathAry = abspath.split('/'),
data,
file_name;
if (!found) {
found = {dirs: [], files: [] }
}
if (stat.isDirectory() && !isHidden(abspathAry[abspathAry.length - 1])) {
found.dirs.push(abs... | [
"function",
"isDir",
"(",
"abspath",
",",
"found",
")",
"{",
"var",
"stat",
"=",
"fs",
".",
"statSync",
"(",
"abspath",
")",
",",
"abspathAry",
"=",
"abspath",
".",
"split",
"(",
"'/'",
")",
",",
"data",
",",
"file_name",
";",
"if",
"(",
"!",
"foun... | Identifies if the path is directory
@param {String} abspath Absolute path, should be already have replaced '\' with '/' to support Windows
@param {Object} found Object: {dirs: [], files: [] }, contains information about directory's files and subdirectories
@return {Object} Updated 'found' object | [
"Identifies",
"if",
"the",
"path",
"is",
"directory"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/utils/file.js#L41-L69 | train |
socketstream/socketstream | lib/utils/require.js | projectOrHereRequire | function projectOrHereRequire(id,root) {
try {
return resolve.sync(id, {
package: path.join(root,'package.json'),
paths: [root],
basedir:root
});
} catch(ex) {
// console.error(ex);
}
var here = path.join(__dirname,'..','..');
try {
var p = resolve.sync(id, {
package: path.join(here,'package.j... | javascript | function projectOrHereRequire(id,root) {
try {
return resolve.sync(id, {
package: path.join(root,'package.json'),
paths: [root],
basedir:root
});
} catch(ex) {
// console.error(ex);
}
var here = path.join(__dirname,'..','..');
try {
var p = resolve.sync(id, {
package: path.join(here,'package.j... | [
"function",
"projectOrHereRequire",
"(",
"id",
",",
"root",
")",
"{",
"try",
"{",
"return",
"resolve",
".",
"sync",
"(",
"id",
",",
"{",
"package",
":",
"path",
".",
"join",
"(",
"root",
",",
"'package.json'",
")",
",",
"paths",
":",
"[",
"root",
"]"... | return path to found, project first | [
"return",
"path",
"to",
"found",
"project",
"first"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/utils/require.js#L138-L160 | train |
socketstream/socketstream | lib/client/bundler/proto.js | resolveAssetLink | function resolveAssetLink(client, type) {
var defaultPath = '/assets/' + client.name + '/' + client.id + '.' + type,
pack = options.packedAssets,
link = pack !== undefined ? (pack.cdn !== undefined ? pack.cdn[type] : void 0) : void 0;
if (link) {
if (typeof link === 'function') {
var f... | javascript | function resolveAssetLink(client, type) {
var defaultPath = '/assets/' + client.name + '/' + client.id + '.' + type,
pack = options.packedAssets,
link = pack !== undefined ? (pack.cdn !== undefined ? pack.cdn[type] : void 0) : void 0;
if (link) {
if (typeof link === 'function') {
var f... | [
"function",
"resolveAssetLink",
"(",
"client",
",",
"type",
")",
"{",
"var",
"defaultPath",
"=",
"'/assets/'",
"+",
"client",
".",
"name",
"+",
"'/'",
"+",
"client",
".",
"id",
"+",
"'.'",
"+",
"type",
",",
"pack",
"=",
"options",
".",
"packedAssets",
... | When packing assets the default path to the CSS or JS file can be overridden either with a string or a function, typically pointing to an resource on a CDN | [
"When",
"packing",
"assets",
"the",
"default",
"path",
"to",
"the",
"CSS",
"or",
"JS",
"file",
"can",
"be",
"overridden",
"either",
"with",
"a",
"string",
"or",
"a",
"function",
"typically",
"pointing",
"to",
"an",
"resource",
"on",
"a",
"CDN"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/bundler/proto.js#L126-L147 | train |
socketstream/socketstream | lib/websocket/event_dispatcher.js | sendToMultiple | function sendToMultiple(send, msg, destinations, type) {
destinations = destinations instanceof Array && destinations || [destinations];
destinations.forEach(function(destination) {
var set, socketIds;
set = subscriptions[type];
if ((socketIds = set.members(destination))) {
return socketIds.slice(... | javascript | function sendToMultiple(send, msg, destinations, type) {
destinations = destinations instanceof Array && destinations || [destinations];
destinations.forEach(function(destination) {
var set, socketIds;
set = subscriptions[type];
if ((socketIds = set.members(destination))) {
return socketIds.slice(... | [
"function",
"sendToMultiple",
"(",
"send",
",",
"msg",
",",
"destinations",
",",
"type",
")",
"{",
"destinations",
"=",
"destinations",
"instanceof",
"Array",
"&&",
"destinations",
"||",
"[",
"destinations",
"]",
";",
"destinations",
".",
"forEach",
"(",
"func... | Private Attempt to send the event to the socket. If socket no longer exists, remove it from set | [
"Private",
"Attempt",
"to",
"send",
"the",
"event",
"to",
"the",
"socket",
".",
"If",
"socket",
"no",
"longer",
"exists",
"remove",
"it",
"from",
"set"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/websocket/event_dispatcher.js#L42-L56 | train |
socketstream/socketstream | lib/tasks/index.js | function(all) {
var tasks = all? ['load-api']:['pack-prepare','load-api'];
ss.bundler.forEach(function(bundler){
if (all) {
tasks.push(bundler.client.name + ':pack');
} else if (bundler.packNeeded) {
tasks.push(bundler.client.name + ':pack-needed');
tasks.push(b... | javascript | function(all) {
var tasks = all? ['load-api']:['pack-prepare','load-api'];
ss.bundler.forEach(function(bundler){
if (all) {
tasks.push(bundler.client.name + ':pack');
} else if (bundler.packNeeded) {
tasks.push(bundler.client.name + ':pack-needed');
tasks.push(b... | [
"function",
"(",
"all",
")",
"{",
"var",
"tasks",
"=",
"all",
"?",
"[",
"'load-api'",
"]",
":",
"[",
"'pack-prepare'",
",",
"'load-api'",
"]",
";",
"ss",
".",
"bundler",
".",
"forEach",
"(",
"function",
"(",
"bundler",
")",
"{",
"if",
"(",
"all",
"... | this is mostly for testing | [
"this",
"is",
"mostly",
"for",
"testing"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/tasks/index.js#L52-L65 | train | |
socketstream/socketstream | lib/client/template_engine.js | suggestedId | function suggestedId(pth, templatesPath) {
if (pth.indexOf(templatesPath) === 0) {
pth = pth.substring(templatesPath.length + 1);
}
var sp;
sp = pth.split('.');
if (pth.indexOf('.') > 0) {
sp.pop();
}
return sp.join('.').replace(/\//g, '-');
} | javascript | function suggestedId(pth, templatesPath) {
if (pth.indexOf(templatesPath) === 0) {
pth = pth.substring(templatesPath.length + 1);
}
var sp;
sp = pth.split('.');
if (pth.indexOf('.') > 0) {
sp.pop();
}
return sp.join('.').replace(/\//g, '-');
} | [
"function",
"suggestedId",
"(",
"pth",
",",
"templatesPath",
")",
"{",
"if",
"(",
"pth",
".",
"indexOf",
"(",
"templatesPath",
")",
"===",
"0",
")",
"{",
"pth",
"=",
"pth",
".",
"substring",
"(",
"templatesPath",
".",
"length",
"+",
"1",
")",
";",
"}... | This should be on the bundler entries, so it can be tweaked by bundler before being used by the engine Suggest an ID for this template based upon its path 3rd party Template Engine modules are free to use their own naming conventions but we recommend using this where possible | [
"This",
"should",
"be",
"on",
"the",
"bundler",
"entries",
"so",
"it",
"can",
"be",
"tweaked",
"by",
"bundler",
"before",
"being",
"used",
"by",
"the",
"engine",
"Suggest",
"an",
"ID",
"for",
"this",
"template",
"based",
"upon",
"its",
"path",
"3rd",
"pa... | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/template_engine.js#L203-L213 | train |
socketstream/socketstream | lib/client/index.js | onChange | function onChange(changedPath, event) {
var _ref = path.extname(changedPath),
action = cssExtensions.indexOf(_ref) >= 0 ? 'updateCSS' : 'reload';
//first change is with delayTime delay , thereafter only once there has been no further changes for guardTime seconds
//validate the change
... | javascript | function onChange(changedPath, event) {
var _ref = path.extname(changedPath),
action = cssExtensions.indexOf(_ref) >= 0 ? 'updateCSS' : 'reload';
//first change is with delayTime delay , thereafter only once there has been no further changes for guardTime seconds
//validate the change
... | [
"function",
"onChange",
"(",
"changedPath",
",",
"event",
")",
"{",
"var",
"_ref",
"=",
"path",
".",
"extname",
"(",
"changedPath",
")",
",",
"action",
"=",
"cssExtensions",
".",
"indexOf",
"(",
"_ref",
")",
">=",
"0",
"?",
"'updateCSS'",
":",
"'reload'"... | reload the browser | [
"reload",
"the",
"browser"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/index.js#L108-L131 | train |
socketstream/socketstream | lib/client/index.js | function(newOption) {
var k, v, y, _results;
if (typeof newOption !== 'object') {
throw new Error('ss.client.set() takes an object e.g. {liveReload: false}');
}
_results = [];
for (k in newOption) {
if (newOption.hasOwnProperty(k)) {
v = newOption[k];
if... | javascript | function(newOption) {
var k, v, y, _results;
if (typeof newOption !== 'object') {
throw new Error('ss.client.set() takes an object e.g. {liveReload: false}');
}
_results = [];
for (k in newOption) {
if (newOption.hasOwnProperty(k)) {
v = newOption[k];
if... | [
"function",
"(",
"newOption",
")",
"{",
"var",
"k",
",",
"v",
",",
"y",
",",
"_results",
";",
"if",
"(",
"typeof",
"newOption",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'ss.client.set() takes an object e.g. {liveReload: false}'",
")",
";",
... | Merge optional options | [
"Merge",
"optional",
"options"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/index.js#L206-L239 | train | |
socketstream/socketstream | lib/client/index.js | function(opts) {
if (opts && typeof opts !== 'object') {
throw new Error('Options passed to ss.client.packAssets() must be an object');
}
options.packedAssets = opts || true;
options.servePacked = opts || true;
options.liveReload = false;
// As it's safe to assume we're runn... | javascript | function(opts) {
if (opts && typeof opts !== 'object') {
throw new Error('Options passed to ss.client.packAssets() must be an object');
}
options.packedAssets = opts || true;
options.servePacked = opts || true;
options.liveReload = false;
// As it's safe to assume we're runn... | [
"function",
"(",
"opts",
")",
"{",
"if",
"(",
"opts",
"&&",
"typeof",
"opts",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Options passed to ss.client.packAssets() must be an object'",
")",
";",
"}",
"options",
".",
"packedAssets",
"=",
"opts",
... | Tell the asset manager to pack and minimise all assets | [
"Tell",
"the",
"asset",
"manager",
"to",
"pack",
"and",
"minimise",
"all",
"assets"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/index.js#L250-L266 | train | |
socketstream/socketstream | lib/client/index.js | function() {
ss.http.cached.loadStatic();
ss.http.cached.loadAssets();
ss.bundler.updateCachedOndemandAssets();
ss.bundler.forEach(function(bundler) {
bundler.updateCachedDevAssets();
});
} | javascript | function() {
ss.http.cached.loadStatic();
ss.http.cached.loadAssets();
ss.bundler.updateCachedOndemandAssets();
ss.bundler.forEach(function(bundler) {
bundler.updateCachedDevAssets();
});
} | [
"function",
"(",
")",
"{",
"ss",
".",
"http",
".",
"cached",
".",
"loadStatic",
"(",
")",
";",
"ss",
".",
"http",
".",
"cached",
".",
"loadAssets",
"(",
")",
";",
"ss",
".",
"bundler",
".",
"updateCachedOndemandAssets",
"(",
")",
";",
"ss",
".",
"b... | experimental interface to reload cache of contents for all clients | [
"experimental",
"interface",
"to",
"reload",
"cache",
"of",
"contents",
"for",
"all",
"clients"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/index.js#L333-L341 | train | |
socketstream/socketstream | lib/client/index.js | function() {
if (options.servePacked) {
ss.bundler.forEach(function(bundler) {
bundler.useLatestsPackedId();
});
}
ss.bundler.load();
//TODO convert options.dirs to relative paths stripping the lead '/' if present
// Cache instances of code formatters and templat... | javascript | function() {
if (options.servePacked) {
ss.bundler.forEach(function(bundler) {
bundler.useLatestsPackedId();
});
}
ss.bundler.load();
//TODO convert options.dirs to relative paths stripping the lead '/' if present
// Cache instances of code formatters and templat... | [
"function",
"(",
")",
"{",
"if",
"(",
"options",
".",
"servePacked",
")",
"{",
"ss",
".",
"bundler",
".",
"forEach",
"(",
"function",
"(",
"bundler",
")",
"{",
"bundler",
".",
"useLatestsPackedId",
"(",
")",
";",
"}",
")",
";",
"}",
"ss",
".",
"bun... | Listen and serve incoming asset requests | [
"Listen",
"and",
"serve",
"incoming",
"asset",
"requests"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/client/index.js#L359-L374 | train | |
socketstream/socketstream | lib/websocket/transports/engineio/index.js | function(msg) {
for (var id in openSocketsById) {
if (openSocketsById.hasOwnProperty(id)) {
openSocketsById[id].send('0|' + msg + '|null');
}
}
} | javascript | function(msg) {
for (var id in openSocketsById) {
if (openSocketsById.hasOwnProperty(id)) {
openSocketsById[id].send('0|' + msg + '|null');
}
}
} | [
"function",
"(",
"msg",
")",
"{",
"for",
"(",
"var",
"id",
"in",
"openSocketsById",
")",
"{",
"if",
"(",
"openSocketsById",
".",
"hasOwnProperty",
"(",
"id",
")",
")",
"{",
"openSocketsById",
"[",
"id",
"]",
".",
"send",
"(",
"'0|'",
"+",
"msg",
"+",... | Send the same message to every open socket | [
"Send",
"the",
"same",
"message",
"to",
"every",
"open",
"socket"
] | bc783da043de558ee3ff9032ea15b9b8113a8659 | https://github.com/socketstream/socketstream/blob/bc783da043de558ee3ff9032ea15b9b8113a8659/lib/websocket/transports/engineio/index.js#L136-L142 | train | |
kazupon/vue-validator | dist/vue-validator.common.js | pattern | function pattern (val, pat) {
if (typeof pat !== 'string') { return false }
var match = pat.match(new RegExp('^/(.*?)/([gimy]*)$'));
if (!match) { return false }
return new RegExp(match[1], match[2]).test(val)
} | javascript | function pattern (val, pat) {
if (typeof pat !== 'string') { return false }
var match = pat.match(new RegExp('^/(.*?)/([gimy]*)$'));
if (!match) { return false }
return new RegExp(match[1], match[2]).test(val)
} | [
"function",
"pattern",
"(",
"val",
",",
"pat",
")",
"{",
"if",
"(",
"typeof",
"pat",
"!==",
"'string'",
")",
"{",
"return",
"false",
"}",
"var",
"match",
"=",
"pat",
".",
"match",
"(",
"new",
"RegExp",
"(",
"'^/(.*?)/([gimy]*)$'",
")",
")",
";",
"if"... | pattern
This function validate whether the value matches the regex pattern | [
"pattern",
"This",
"function",
"validate",
"whether",
"the",
"value",
"matches",
"the",
"regex",
"pattern"
] | a88304a5c71cb3273341678ae48b030dc71c5956 | https://github.com/kazupon/vue-validator/blob/a88304a5c71cb3273341678ae48b030dc71c5956/dist/vue-validator.common.js#L80-L87 | train |
kazupon/vue-validator | dist/vue-validator.common.js | minlength | function minlength (val, min) {
if (typeof val === 'string') {
return isInteger(min, 10) && val.length >= parseInt(min, 10)
} else if (Array.isArray(val)) {
return val.length >= parseInt(min, 10)
} else {
return false
}
} | javascript | function minlength (val, min) {
if (typeof val === 'string') {
return isInteger(min, 10) && val.length >= parseInt(min, 10)
} else if (Array.isArray(val)) {
return val.length >= parseInt(min, 10)
} else {
return false
}
} | [
"function",
"minlength",
"(",
"val",
",",
"min",
")",
"{",
"if",
"(",
"typeof",
"val",
"===",
"'string'",
")",
"{",
"return",
"isInteger",
"(",
"min",
",",
"10",
")",
"&&",
"val",
".",
"length",
">=",
"parseInt",
"(",
"min",
",",
"10",
")",
"}",
... | minlength
This function validate whether the minimum length. | [
"minlength",
"This",
"function",
"validate",
"whether",
"the",
"minimum",
"length",
"."
] | a88304a5c71cb3273341678ae48b030dc71c5956 | https://github.com/kazupon/vue-validator/blob/a88304a5c71cb3273341678ae48b030dc71c5956/dist/vue-validator.common.js#L93-L101 | train |
kazupon/vue-validator | dist/vue-validator.common.js | maxlength | function maxlength (val, max) {
if (typeof val === 'string') {
return isInteger(max, 10) && val.length <= parseInt(max, 10)
} else if (Array.isArray(val)) {
return val.length <= parseInt(max, 10)
} else {
return false
}
} | javascript | function maxlength (val, max) {
if (typeof val === 'string') {
return isInteger(max, 10) && val.length <= parseInt(max, 10)
} else if (Array.isArray(val)) {
return val.length <= parseInt(max, 10)
} else {
return false
}
} | [
"function",
"maxlength",
"(",
"val",
",",
"max",
")",
"{",
"if",
"(",
"typeof",
"val",
"===",
"'string'",
")",
"{",
"return",
"isInteger",
"(",
"max",
",",
"10",
")",
"&&",
"val",
".",
"length",
"<=",
"parseInt",
"(",
"max",
",",
"10",
")",
"}",
... | maxlength
This function validate whether the maximum length. | [
"maxlength",
"This",
"function",
"validate",
"whether",
"the",
"maximum",
"length",
"."
] | a88304a5c71cb3273341678ae48b030dc71c5956 | https://github.com/kazupon/vue-validator/blob/a88304a5c71cb3273341678ae48b030dc71c5956/dist/vue-validator.common.js#L107-L115 | train |
kazupon/vue-validator | dist/vue-validator.common.js | validator | function validator (
id,
def
) {
if (def === undefined) {
return Vue.options['validators'][id]
} else {
Vue.options['validators'][id] = def;
if (def === null) {
delete Vue.options['validators']['id'];
}
}
} | javascript | function validator (
id,
def
) {
if (def === undefined) {
return Vue.options['validators'][id]
} else {
Vue.options['validators'][id] = def;
if (def === null) {
delete Vue.options['validators']['id'];
}
}
} | [
"function",
"validator",
"(",
"id",
",",
"def",
")",
"{",
"if",
"(",
"def",
"===",
"undefined",
")",
"{",
"return",
"Vue",
".",
"options",
"[",
"'validators'",
"]",
"[",
"id",
"]",
"}",
"else",
"{",
"Vue",
".",
"options",
"[",
"'validators'",
"]",
... | Register or retrieve a global validator definition. | [
"Register",
"or",
"retrieve",
"a",
"global",
"validator",
"definition",
"."
] | a88304a5c71cb3273341678ae48b030dc71c5956 | https://github.com/kazupon/vue-validator/blob/a88304a5c71cb3273341678ae48b030dc71c5956/dist/vue-validator.common.js#L180-L192 | train |
RuntimeTools/appmetrics | probes/oracle-probe.js | addMonitoring | function addMonitoring(connection, probe) {
aspect.around(
connection,
'execute',
function(target, methodName, args, probeData) {
// Start the monitoring for the 'execute' method
probe.metricsProbeStart(probeData, methodName, args);
probe.requestProbeStart(probeData, methodName, args);
... | javascript | function addMonitoring(connection, probe) {
aspect.around(
connection,
'execute',
function(target, methodName, args, probeData) {
// Start the monitoring for the 'execute' method
probe.metricsProbeStart(probeData, methodName, args);
probe.requestProbeStart(probeData, methodName, args);
... | [
"function",
"addMonitoring",
"(",
"connection",
",",
"probe",
")",
"{",
"aspect",
".",
"around",
"(",
"connection",
",",
"'execute'",
",",
"function",
"(",
"target",
",",
"methodName",
",",
"args",
",",
"probeData",
")",
"{",
"// Start the monitoring for the 'ex... | Monitor the 'execute' method on a connection or prepared statement | [
"Monitor",
"the",
"execute",
"method",
"on",
"a",
"connection",
"or",
"prepared",
"statement"
] | cdcb907b9d57f9531986cc87b454813d621f59f0 | https://github.com/RuntimeTools/appmetrics/blob/cdcb907b9d57f9531986cc87b454813d621f59f0/probes/oracle-probe.js#L59-L90 | train |
RuntimeTools/appmetrics | probes/https-outbound-probe.js | function(target, methodName, methodArgs, probeData, rc) {
// If no callback has been used then end the metrics after returning from the method instead
if (aspect.findCallbackArg(methodArgs) === undefined) {
// Need to get request method and URL again
var ri = getRequestItems(methodAr... | javascript | function(target, methodName, methodArgs, probeData, rc) {
// If no callback has been used then end the metrics after returning from the method instead
if (aspect.findCallbackArg(methodArgs) === undefined) {
// Need to get request method and URL again
var ri = getRequestItems(methodAr... | [
"function",
"(",
"target",
",",
"methodName",
",",
"methodArgs",
",",
"probeData",
",",
"rc",
")",
"{",
"// If no callback has been used then end the metrics after returning from the method instead",
"if",
"(",
"aspect",
".",
"findCallbackArg",
"(",
"methodArgs",
")",
"==... | After 'https.request' function returns | [
"After",
"https",
".",
"request",
"function",
"returns"
] | cdcb907b9d57f9531986cc87b454813d621f59f0 | https://github.com/RuntimeTools/appmetrics/blob/cdcb907b9d57f9531986cc87b454813d621f59f0/probes/https-outbound-probe.js#L95-L105 | train | |
RuntimeTools/appmetrics | probes/leveldown-probe.js | function() {
var lvldownObj = target.apply(null, arguments);
lvldownObj._ddProbeAttached_ = true;
aspectLvldownMethod(lvldownObj, methods, that);
return lvldownObj;
} | javascript | function() {
var lvldownObj = target.apply(null, arguments);
lvldownObj._ddProbeAttached_ = true;
aspectLvldownMethod(lvldownObj, methods, that);
return lvldownObj;
} | [
"function",
"(",
")",
"{",
"var",
"lvldownObj",
"=",
"target",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"lvldownObj",
".",
"_ddProbeAttached_",
"=",
"true",
";",
"aspectLvldownMethod",
"(",
"lvldownObj",
",",
"methods",
",",
"that",
")",
";",... | Wrapping the target in new function as leveldown returns constructor | [
"Wrapping",
"the",
"target",
"in",
"new",
"function",
"as",
"leveldown",
"returns",
"constructor"
] | cdcb907b9d57f9531986cc87b454813d621f59f0 | https://github.com/RuntimeTools/appmetrics/blob/cdcb907b9d57f9531986cc87b454813d621f59f0/probes/leveldown-probe.js#L56-L61 | train | |
RuntimeTools/appmetrics | probes/http-outbound-probe.js | function(obj, methodName, methodArgs, probeData) {
// Start metrics
that.metricsProbeStart(probeData);
that.requestProbeStart(probeData);
// End metrics
aspect.aroundCallback(
methodArgs,
probeData,
function(target, args, probeData) {
// ... | javascript | function(obj, methodName, methodArgs, probeData) {
// Start metrics
that.metricsProbeStart(probeData);
that.requestProbeStart(probeData);
// End metrics
aspect.aroundCallback(
methodArgs,
probeData,
function(target, args, probeData) {
// ... | [
"function",
"(",
"obj",
",",
"methodName",
",",
"methodArgs",
",",
"probeData",
")",
"{",
"// Start metrics",
"that",
".",
"metricsProbeStart",
"(",
"probeData",
")",
";",
"that",
".",
"requestProbeStart",
"(",
"probeData",
")",
";",
"// End metrics",
"aspect",
... | Before 'http.request' function | [
"Before",
"http",
".",
"request",
"function"
] | cdcb907b9d57f9531986cc87b454813d621f59f0 | https://github.com/RuntimeTools/appmetrics/blob/cdcb907b9d57f9531986cc87b454813d621f59f0/probes/http-outbound-probe.js#L69-L88 | train | |
adamgruber/mochawesome | src/mochawesome.js | done | function done(output, options, config, failures, exit) {
return marge.create(output, options)
.then(([ htmlFile, jsonFile ]) => {
if (!htmlFile && !jsonFile) {
log('No files were generated', 'warn', config);
} else {
jsonFile && log(`Report JSON saved to ${jsonFile}`, null, config);
... | javascript | function done(output, options, config, failures, exit) {
return marge.create(output, options)
.then(([ htmlFile, jsonFile ]) => {
if (!htmlFile && !jsonFile) {
log('No files were generated', 'warn', config);
} else {
jsonFile && log(`Report JSON saved to ${jsonFile}`, null, config);
... | [
"function",
"done",
"(",
"output",
",",
"options",
",",
"config",
",",
"failures",
",",
"exit",
")",
"{",
"return",
"marge",
".",
"create",
"(",
"output",
",",
"options",
")",
".",
"then",
"(",
"(",
"[",
"htmlFile",
",",
"jsonFile",
"]",
")",
"=>",
... | Done function gets called before mocha exits
Creates and saves the report HTML and JSON files
@param {Object} output Final report object
@param {Object} options Options to pass to report generator
@param {Object} config Reporter config object
@param {Number} failures Number of reported failures
@param {Funct... | [
"Done",
"function",
"gets",
"called",
"before",
"mocha",
"exits"
] | ce0cafe0994f4226b1a63b7c14bad2c585193c70 | https://github.com/adamgruber/mochawesome/blob/ce0cafe0994f4226b1a63b7c14bad2c585193c70/src/mochawesome.js#L31-L47 | train |
adamgruber/mochawesome | src/mochawesome.js | Mochawesome | function Mochawesome(runner, options) {
// Set the config options
this.config = conf(options);
// Reporter options
const reporterOptions = Object.assign(
{},
(options.reporterOptions || {}),
{
reportFilename: this.config.reportFilename,
saveHtml: this.config.saveHtml,
saveJson: th... | javascript | function Mochawesome(runner, options) {
// Set the config options
this.config = conf(options);
// Reporter options
const reporterOptions = Object.assign(
{},
(options.reporterOptions || {}),
{
reportFilename: this.config.reportFilename,
saveHtml: this.config.saveHtml,
saveJson: th... | [
"function",
"Mochawesome",
"(",
"runner",
",",
"options",
")",
"{",
"// Set the config options",
"this",
".",
"config",
"=",
"conf",
"(",
"options",
")",
";",
"// Reporter options",
"const",
"reporterOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
... | Initialize a new reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"reporter",
"."
] | ce0cafe0994f4226b1a63b7c14bad2c585193c70 | https://github.com/adamgruber/mochawesome/blob/ce0cafe0994f4226b1a63b7c14bad2c585193c70/src/mochawesome.js#L55-L145 | 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.