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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
sadiqhabib/tinymce-dist | tinymce.full.js | clearBars | function clearBars() {
var bars = editor.dom.select('.' + RESIZE_BAR_CLASS, getBody());
Tools.each(bars, function (bar) {
editor.dom.remove(bar);
});
} | javascript | function clearBars() {
var bars = editor.dom.select('.' + RESIZE_BAR_CLASS, getBody());
Tools.each(bars, function (bar) {
editor.dom.remove(bar);
});
} | [
"function",
"clearBars",
"(",
")",
"{",
"var",
"bars",
"=",
"editor",
".",
"dom",
".",
"select",
"(",
"'.'",
"+",
"RESIZE_BAR_CLASS",
",",
"getBody",
"(",
")",
")",
";",
"Tools",
".",
"each",
"(",
"bars",
",",
"function",
"(",
"bar",
")",
"{",
"edi... | Clear the bars. | [
"Clear",
"the",
"bars",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66086-L66091 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | generateBar | function generateBar(classToAdd, cursor, left, top, height, width, indexAttr, index) {
var bar = {
'data-mce-bogus': 'all',
'class': RESIZE_BAR_CLASS + ' ' + classToAdd,
'unselectable': 'on',
'data-mce-resize': false,
style: 'cursor: ' + cursor + '; ' +
... | javascript | function generateBar(classToAdd, cursor, left, top, height, width, indexAttr, index) {
var bar = {
'data-mce-bogus': 'all',
'class': RESIZE_BAR_CLASS + ' ' + classToAdd,
'unselectable': 'on',
'data-mce-resize': false,
style: 'cursor: ' + cursor + '; ' +
... | [
"function",
"generateBar",
"(",
"classToAdd",
",",
"cursor",
",",
"left",
",",
"top",
",",
"height",
",",
"width",
",",
"indexAttr",
",",
"index",
")",
"{",
"var",
"bar",
"=",
"{",
"'data-mce-bogus'",
":",
"'all'",
",",
"'class'",
":",
"RESIZE_BAR_CLASS",
... | Generates a resize bar object for the editor to add. | [
"Generates",
"a",
"resize",
"bar",
"object",
"for",
"the",
"editor",
"to",
"add",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66100-L66119 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | drawRows | function drawRows(rowPositions, tableWidth, tablePosition) {
Tools.each(rowPositions, function (rowPosition) {
var left = tablePosition.x,
top = rowPosition.y - RESIZE_BAR_THICKNESS / 2,
height = RESIZE_BAR_THICKNESS,
width = tableWidth;
editor.dom.add(ge... | javascript | function drawRows(rowPositions, tableWidth, tablePosition) {
Tools.each(rowPositions, function (rowPosition) {
var left = tablePosition.x,
top = rowPosition.y - RESIZE_BAR_THICKNESS / 2,
height = RESIZE_BAR_THICKNESS,
width = tableWidth;
editor.dom.add(ge... | [
"function",
"drawRows",
"(",
"rowPositions",
",",
"tableWidth",
",",
"tablePosition",
")",
"{",
"Tools",
".",
"each",
"(",
"rowPositions",
",",
"function",
"(",
"rowPosition",
")",
"{",
"var",
"left",
"=",
"tablePosition",
".",
"x",
",",
"top",
"=",
"rowPo... | Draw the row bars over the row borders. | [
"Draw",
"the",
"row",
"bars",
"over",
"the",
"row",
"borders",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66122-L66133 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | drawCols | function drawCols(cellPositions, tableHeight, tablePosition) {
Tools.each(cellPositions, function (cellPosition) {
var left = cellPosition.x - RESIZE_BAR_THICKNESS / 2,
top = tablePosition.y,
height = tableHeight,
width = RESIZE_BAR_THICKNESS;
editor.dom.... | javascript | function drawCols(cellPositions, tableHeight, tablePosition) {
Tools.each(cellPositions, function (cellPosition) {
var left = cellPosition.x - RESIZE_BAR_THICKNESS / 2,
top = tablePosition.y,
height = tableHeight,
width = RESIZE_BAR_THICKNESS;
editor.dom.... | [
"function",
"drawCols",
"(",
"cellPositions",
",",
"tableHeight",
",",
"tablePosition",
")",
"{",
"Tools",
".",
"each",
"(",
"cellPositions",
",",
"function",
"(",
"cellPosition",
")",
"{",
"var",
"left",
"=",
"cellPosition",
".",
"x",
"-",
"RESIZE_BAR_THICKNE... | Draw the column bars over the column borders. | [
"Draw",
"the",
"column",
"bars",
"over",
"the",
"column",
"borders",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66136-L66147 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getTableDetails | function getTableDetails(table) {
return Tools.map(table.rows, function (row) {
var cells = Tools.map(row.cells, function (cell) {
var rowspan = cell.hasAttribute('rowspan') ? parseInt(cell.getAttribute('rowspan'), 10) : 1;
var colspan = cell.hasAttribute('colspan') ? parseIn... | javascript | function getTableDetails(table) {
return Tools.map(table.rows, function (row) {
var cells = Tools.map(row.cells, function (cell) {
var rowspan = cell.hasAttribute('rowspan') ? parseInt(cell.getAttribute('rowspan'), 10) : 1;
var colspan = cell.hasAttribute('colspan') ? parseIn... | [
"function",
"getTableDetails",
"(",
"table",
")",
"{",
"return",
"Tools",
".",
"map",
"(",
"table",
".",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"var",
"cells",
"=",
"Tools",
".",
"map",
"(",
"row",
".",
"cells",
",",
"function",
"(",
"cell",
... | Get a matrix of the cells in each row and the rows in the table. | [
"Get",
"a",
"matrix",
"of",
"the",
"cells",
"in",
"each",
"row",
"and",
"the",
"rows",
"in",
"the",
"table",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66150-L66172 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getTableGrid | function getTableGrid(tableDetails) {
function key(rowIndex, colIndex) {
return rowIndex + ',' + colIndex;
}
function getAt(rowIndex, colIndex) {
return access[key(rowIndex, colIndex)];
}
function getAllCells() {
var allCells = [];
Tools.... | javascript | function getTableGrid(tableDetails) {
function key(rowIndex, colIndex) {
return rowIndex + ',' + colIndex;
}
function getAt(rowIndex, colIndex) {
return access[key(rowIndex, colIndex)];
}
function getAllCells() {
var allCells = [];
Tools.... | [
"function",
"getTableGrid",
"(",
"tableDetails",
")",
"{",
"function",
"key",
"(",
"rowIndex",
",",
"colIndex",
")",
"{",
"return",
"rowIndex",
"+",
"','",
"+",
"colIndex",
";",
"}",
"function",
"getAt",
"(",
"rowIndex",
",",
"colIndex",
")",
"{",
"return"... | Get a grid model of the table. | [
"Get",
"a",
"grid",
"model",
"of",
"the",
"table",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66175-L66249 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getColumnBlocks | function getColumnBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(cols, function (col) {
function getBlock() {
var details = [];
for (var i = 0; i < rows.length; i++) {
... | javascript | function getColumnBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(cols, function (col) {
function getBlock() {
var details = [];
for (var i = 0; i < rows.length; i++) {
... | [
"function",
"getColumnBlocks",
"(",
"tableGrid",
")",
"{",
"var",
"cols",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxCols",
")",
";",
"var",
"rows",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxRows",
")",
";",... | Attempt to get representative blocks for the width of each column. | [
"Attempt",
"to",
"get",
"representative",
"blocks",
"for",
"the",
"width",
"of",
"each",
"column",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66277-L66313 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getRowBlocks | function getRowBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(rows, function (row) {
function getBlock() {
var details = [];
for (var i = 0; i < cols.length; i++) {
va... | javascript | function getRowBlocks(tableGrid) {
var cols = range(0, tableGrid.grid.maxCols);
var rows = range(0, tableGrid.grid.maxRows);
return Tools.map(rows, function (row) {
function getBlock() {
var details = [];
for (var i = 0; i < cols.length; i++) {
va... | [
"function",
"getRowBlocks",
"(",
"tableGrid",
")",
"{",
"var",
"cols",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxCols",
")",
";",
"var",
"rows",
"=",
"range",
"(",
"0",
",",
"tableGrid",
".",
"grid",
".",
"maxRows",
")",
";",
... | Attempt to get representative blocks for the height of each row. | [
"Attempt",
"to",
"get",
"representative",
"blocks",
"for",
"the",
"height",
"of",
"each",
"row",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66316-L66342 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getWidths | function getWidths(tableGrid, isPercentageBased, table) {
var cols = getColumnBlocks(tableGrid);
var backups = Tools.map(cols, function (col) {
return getInnerEdge(col.colIndex, col.element).x;
});
var widths = [];
for (var i = 0; i < cols.length; i++) {
v... | javascript | function getWidths(tableGrid, isPercentageBased, table) {
var cols = getColumnBlocks(tableGrid);
var backups = Tools.map(cols, function (col) {
return getInnerEdge(col.colIndex, col.element).x;
});
var widths = [];
for (var i = 0; i < cols.length; i++) {
v... | [
"function",
"getWidths",
"(",
"tableGrid",
",",
"isPercentageBased",
",",
"table",
")",
"{",
"var",
"cols",
"=",
"getColumnBlocks",
"(",
"tableGrid",
")",
";",
"var",
"backups",
"=",
"Tools",
".",
"map",
"(",
"cols",
",",
"function",
"(",
"col",
")",
"{"... | Attempt to get the css width from column representative cells. | [
"Attempt",
"to",
"get",
"the",
"css",
"width",
"from",
"column",
"representative",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66442-L66462 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getPixelHeight | function getPixelHeight(element) {
var heightString = getStyleOrAttrib(element, 'height');
var heightNumber = parseInt(heightString, 10);
if (isPercentageBasedSize(heightString)) {
heightNumber = 0;
}
return !isNaN(heightNumber) && heightNumber > 0 ?
heigh... | javascript | function getPixelHeight(element) {
var heightString = getStyleOrAttrib(element, 'height');
var heightNumber = parseInt(heightString, 10);
if (isPercentageBasedSize(heightString)) {
heightNumber = 0;
}
return !isNaN(heightNumber) && heightNumber > 0 ?
heigh... | [
"function",
"getPixelHeight",
"(",
"element",
")",
"{",
"var",
"heightString",
"=",
"getStyleOrAttrib",
"(",
"element",
",",
"'height'",
")",
";",
"var",
"heightNumber",
"=",
"parseInt",
"(",
"heightString",
",",
"10",
")",
";",
"if",
"(",
"isPercentageBasedSi... | Attempt to get the pixel height from a cell. | [
"Attempt",
"to",
"get",
"the",
"pixel",
"height",
"from",
"a",
"cell",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66465-L66477 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getPixelHeights | function getPixelHeights(tableGrid) {
var rows = getRowBlocks(tableGrid);
var backups = Tools.map(rows, function (row) {
return getTopEdge(row.rowIndex, row.element).y;
});
var heights = [];
for (var i = 0; i < rows.length; i++) {
var span = rows[i].elemen... | javascript | function getPixelHeights(tableGrid) {
var rows = getRowBlocks(tableGrid);
var backups = Tools.map(rows, function (row) {
return getTopEdge(row.rowIndex, row.element).y;
});
var heights = [];
for (var i = 0; i < rows.length; i++) {
var span = rows[i].elemen... | [
"function",
"getPixelHeights",
"(",
"tableGrid",
")",
"{",
"var",
"rows",
"=",
"getRowBlocks",
"(",
"tableGrid",
")",
";",
"var",
"backups",
"=",
"Tools",
".",
"map",
"(",
"rows",
",",
"function",
"(",
"row",
")",
"{",
"return",
"getTopEdge",
"(",
"row",... | Attempt to get the css height from row representative cells. | [
"Attempt",
"to",
"get",
"the",
"css",
"height",
"from",
"row",
"representative",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66480-L66500 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | determineDeltas | function determineDeltas(sizes, column, step, min, isPercentageBased) {
var result = sizes.slice(0);
function generateZeros(array) {
return Tools.map(array, function () {
return 0;
});
}
function onOneColumn() {
var deltas;
if (isPer... | javascript | function determineDeltas(sizes, column, step, min, isPercentageBased) {
var result = sizes.slice(0);
function generateZeros(array) {
return Tools.map(array, function () {
return 0;
});
}
function onOneColumn() {
var deltas;
if (isPer... | [
"function",
"determineDeltas",
"(",
"sizes",
",",
"column",
",",
"step",
",",
"min",
",",
"isPercentageBased",
")",
"{",
"var",
"result",
"=",
"sizes",
".",
"slice",
"(",
"0",
")",
";",
"function",
"generateZeros",
"(",
"array",
")",
"{",
"return",
"Tool... | Determine how much each column's css width will need to change. Sizes = result = pixels widths OR percentage based widths | [
"Determine",
"how",
"much",
"each",
"column",
"s",
"css",
"width",
"will",
"need",
"to",
"change",
".",
"Sizes",
"=",
"result",
"=",
"pixels",
"widths",
"OR",
"percentage",
"based",
"widths"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66504-L66576 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | recalculateWidths | function recalculateWidths(tableGrid, widths) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var width = total(cell.colIndex, cell.colIndex + cell.colspan, widths);
return {
element: cell.element,
width: width,
... | javascript | function recalculateWidths(tableGrid, widths) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var width = total(cell.colIndex, cell.colIndex + cell.colspan, widths);
return {
element: cell.element,
width: width,
... | [
"function",
"recalculateWidths",
"(",
"tableGrid",
",",
"widths",
")",
"{",
"var",
"allCells",
"=",
"tableGrid",
".",
"getAllCells",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allCells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"width",
"=... | Combine cell's css widths to determine widths of colspan'd cells. | [
"Combine",
"cell",
"s",
"css",
"widths",
"to",
"determine",
"widths",
"of",
"colspan",
"d",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66587-L66597 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | recalculateCellHeights | function recalculateCellHeights(tableGrid, heights) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var height = total(cell.rowIndex, cell.rowIndex + cell.rowspan, heights);
return {
element: cell.element,
height: height,... | javascript | function recalculateCellHeights(tableGrid, heights) {
var allCells = tableGrid.getAllCells();
return Tools.map(allCells, function (cell) {
var height = total(cell.rowIndex, cell.rowIndex + cell.rowspan, heights);
return {
element: cell.element,
height: height,... | [
"function",
"recalculateCellHeights",
"(",
"tableGrid",
",",
"heights",
")",
"{",
"var",
"allCells",
"=",
"tableGrid",
".",
"getAllCells",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allCells",
",",
"function",
"(",
"cell",
")",
"{",
"var",
"height... | Combine cell's css heights to determine heights of rowspan'd cells. | [
"Combine",
"cell",
"s",
"css",
"heights",
"to",
"determine",
"heights",
"of",
"rowspan",
"d",
"cells",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66600-L66610 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | recalculateRowHeights | function recalculateRowHeights(tableGrid, heights) {
var allRows = tableGrid.getAllRows();
return Tools.map(allRows, function (row, i) {
return {
element: row.element,
height: heights[i]
};
});
} | javascript | function recalculateRowHeights(tableGrid, heights) {
var allRows = tableGrid.getAllRows();
return Tools.map(allRows, function (row, i) {
return {
element: row.element,
height: heights[i]
};
});
} | [
"function",
"recalculateRowHeights",
"(",
"tableGrid",
",",
"heights",
")",
"{",
"var",
"allRows",
"=",
"tableGrid",
".",
"getAllRows",
"(",
")",
";",
"return",
"Tools",
".",
"map",
"(",
"allRows",
",",
"function",
"(",
"row",
",",
"i",
")",
"{",
"return... | Calculate row heights. | [
"Calculate",
"row",
"heights",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66613-L66621 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | adjustWidth | function adjustWidth(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
function setSizes(newSizes, styleExtension) {
Tools.each(newSizes, function (cell) {
editor.dom.setStyle(cell.element, 'width', cell.width + s... | javascript | function adjustWidth(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
function setSizes(newSizes, styleExtension) {
Tools.each(newSizes, function (cell) {
editor.dom.setStyle(cell.element, 'width', cell.width + s... | [
"function",
"adjustWidth",
"(",
"table",
",",
"delta",
",",
"index",
")",
"{",
"var",
"tableDetails",
"=",
"getTableDetails",
"(",
"table",
")",
";",
"var",
"tableGrid",
"=",
"getTableGrid",
"(",
"tableDetails",
")",
";",
"function",
"setSizes",
"(",
"newSiz... | Adjust the width of the column of table at index, with delta. | [
"Adjust",
"the",
"width",
"of",
"the",
"column",
"of",
"table",
"at",
"index",
"with",
"delta",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66632-L66683 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | adjustHeight | function adjustHeight(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
var heights = getPixelHeights(tableGrid);
var newHeights = [], newTotalHeight = 0;
for (var i = 0; i < heights.length; i++) {
newHeight... | javascript | function adjustHeight(table, delta, index) {
var tableDetails = getTableDetails(table);
var tableGrid = getTableGrid(tableDetails);
var heights = getPixelHeights(tableGrid);
var newHeights = [], newTotalHeight = 0;
for (var i = 0; i < heights.length; i++) {
newHeight... | [
"function",
"adjustHeight",
"(",
"table",
",",
"delta",
",",
"index",
")",
"{",
"var",
"tableDetails",
"=",
"getTableDetails",
"(",
"table",
")",
";",
"var",
"tableGrid",
"=",
"getTableGrid",
"(",
"tableDetails",
")",
";",
"var",
"heights",
"=",
"getPixelHei... | Adjust the height of the row of table at index, with delta. | [
"Adjust",
"the",
"height",
"of",
"the",
"row",
"of",
"table",
"at",
"index",
"with",
"delta",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L66686-L66717 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | innerText | function innerText(html) {
var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
var shortEndedElements = schema.getShortEndedElements();
var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
var blockElements = schema.getBloc... | javascript | function innerText(html) {
var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
var shortEndedElements = schema.getShortEndedElements();
var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
var blockElements = schema.getBloc... | [
"function",
"innerText",
"(",
"html",
")",
"{",
"var",
"schema",
"=",
"new",
"Schema",
"(",
")",
",",
"domParser",
"=",
"new",
"DomParser",
"(",
"{",
"}",
",",
"schema",
")",
",",
"text",
"=",
"''",
";",
"var",
"shortEndedElements",
"=",
"schema",
".... | Gets the innerText of the specified element. It will handle edge cases
and works better than textContent on Gecko.
@param {String} html HTML string to get text from.
@return {String} String of text with line feeds. | [
"Gets",
"the",
"innerText",
"of",
"the",
"specified",
"element",
".",
"It",
"will",
"handle",
"edge",
"cases",
"and",
"works",
"better",
"than",
"textContent",
"on",
"Gecko",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69341-L69396 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | pasteHtml | function pasteHtml(html, internalFlag) {
var args, dom = editor.dom, internal;
internal = internalFlag || InternalHtml.isMarked(html);
html = InternalHtml.unmark(html);
args = editor.fire('BeforePastePreProcess', { content: html, internal: internal }); // Internal event used by Quirks
... | javascript | function pasteHtml(html, internalFlag) {
var args, dom = editor.dom, internal;
internal = internalFlag || InternalHtml.isMarked(html);
html = InternalHtml.unmark(html);
args = editor.fire('BeforePastePreProcess', { content: html, internal: internal }); // Internal event used by Quirks
... | [
"function",
"pasteHtml",
"(",
"html",
",",
"internalFlag",
")",
"{",
"var",
"args",
",",
"dom",
"=",
"editor",
".",
"dom",
",",
"internal",
";",
"internal",
"=",
"internalFlag",
"||",
"InternalHtml",
".",
"isMarked",
"(",
"html",
")",
";",
"html",
"=",
... | Pastes the specified HTML. This means that the HTML is filtered and then
inserted at the current selection in the editor. It will also fire paste events
for custom user filtering.
@param {String} html HTML code to paste into the current selection.
@param {Boolean?} internalFlag Optional true/false flag if the contents... | [
"Pastes",
"the",
"specified",
"HTML",
".",
"This",
"means",
"that",
"the",
"HTML",
"is",
"filtered",
"and",
"then",
"inserted",
"at",
"the",
"current",
"selection",
"in",
"the",
"editor",
".",
"It",
"will",
"also",
"fire",
"paste",
"events",
"for",
"custom... | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69500-L69526 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | createPasteBin | function createPasteBin() {
var dom = editor.dom, body = editor.getBody();
var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
var scrollContainer;
lastRng = editor.selection.getRng();
if (editor.inline) {
scrollContainer = editor... | javascript | function createPasteBin() {
var dom = editor.dom, body = editor.getBody();
var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
var scrollContainer;
lastRng = editor.selection.getRng();
if (editor.inline) {
scrollContainer = editor... | [
"function",
"createPasteBin",
"(",
")",
"{",
"var",
"dom",
"=",
"editor",
".",
"dom",
",",
"body",
"=",
"editor",
".",
"getBody",
"(",
")",
";",
"var",
"viewport",
"=",
"editor",
".",
"dom",
".",
"getViewPort",
"(",
"editor",
".",
"getWin",
"(",
")",... | Creates a paste bin element as close as possible to the current caret location and places the focus inside that element
so that when the real paste event occurs the contents gets inserted into this element
instead of the current editor selection element. | [
"Creates",
"a",
"paste",
"bin",
"element",
"as",
"close",
"as",
"possible",
"to",
"the",
"current",
"caret",
"location",
"and",
"places",
"the",
"focus",
"inside",
"that",
"element",
"so",
"that",
"when",
"the",
"real",
"paste",
"event",
"occurs",
"the",
"... | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69571-L69683 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getCaretRect | function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = ... | javascript | function getCaretRect(rng) {
var rects, textNode, node, container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType != 1) {
return;
}
node = ... | [
"function",
"getCaretRect",
"(",
"rng",
")",
"{",
"var",
"rects",
",",
"textNode",
",",
"node",
",",
"container",
"=",
"rng",
".",
"startContainer",
";",
"rects",
"=",
"rng",
".",
"getClientRects",
"(",
")",
";",
"if",
"(",
"rects",
".",
"length",
")",... | Returns the rect of the current caret if the caret is in an empty block before a
BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
TODO: This might be useful in core. | [
"Returns",
"the",
"rect",
"of",
"the",
"current",
"caret",
"if",
"the",
"caret",
"is",
"in",
"an",
"empty",
"block",
"before",
"a",
"BR",
"we",
"insert",
"a",
"temporary",
"invisible",
"character",
"that",
"we",
"get",
"the",
"rect",
"this",
"way",
"we",... | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69594-L69634 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | removePasteBin | function removePasteBin() {
if (pasteBinElm) {
var pasteBinClone;
// WebKit/Blink might clone the div so
// lets make sure we remove all clones
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
while ((pasteBinClone = edito... | javascript | function removePasteBin() {
if (pasteBinElm) {
var pasteBinClone;
// WebKit/Blink might clone the div so
// lets make sure we remove all clones
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
while ((pasteBinClone = edito... | [
"function",
"removePasteBin",
"(",
")",
"{",
"if",
"(",
"pasteBinElm",
")",
"{",
"var",
"pasteBinClone",
";",
"// WebKit/Blink might clone the div so",
"// lets make sure we remove all clones",
"// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!",
... | Removes the paste bin if it exists. | [
"Removes",
"the",
"paste",
"bin",
"if",
"it",
"exists",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69688-L69706 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getPasteBinHtml | function getPasteBinHtml() {
var html = '', pasteBinClones, i, clone, cloneHtml;
// Since WebKit/Chrome might clone the paste bin when pasting
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
// TODO: Man o man is this ugly. WebKit is... | javascript | function getPasteBinHtml() {
var html = '', pasteBinClones, i, clone, cloneHtml;
// Since WebKit/Chrome might clone the paste bin when pasting
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
// TODO: Man o man is this ugly. WebKit is... | [
"function",
"getPasteBinHtml",
"(",
")",
"{",
"var",
"html",
"=",
"''",
",",
"pasteBinClones",
",",
"i",
",",
"clone",
",",
"cloneHtml",
";",
"// Since WebKit/Chrome might clone the paste bin when pasting",
"// for example: <img style=\"float: right\"> we need to check if any o... | Returns the contents of the paste bin as a HTML string.
@return {String} Get the contents of the paste bin. | [
"Returns",
"the",
"contents",
"of",
"the",
"paste",
"bin",
"as",
"a",
"HTML",
"string",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69713-L69735 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | pasteImageData | function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function processItems(items) {
var i, item, reader, hadImage = false;
if (items) {
for (i = 0; i < items.length; i++) {
item = items[i];
if (/^image\/(jp... | javascript | function pasteImageData(e, rng) {
var dataTransfer = e.clipboardData || e.dataTransfer;
function processItems(items) {
var i, item, reader, hadImage = false;
if (items) {
for (i = 0; i < items.length; i++) {
item = items[i];
if (/^image\/(jp... | [
"function",
"pasteImageData",
"(",
"e",
",",
"rng",
")",
"{",
"var",
"dataTransfer",
"=",
"e",
".",
"clipboardData",
"||",
"e",
".",
"dataTransfer",
";",
"function",
"processItems",
"(",
"items",
")",
"{",
"var",
"i",
",",
"item",
",",
"reader",
",",
"... | Checks if the clipboard contains image data if it does it will take that data
and convert it into a data url image and paste that image at the caret location.
@param {ClipboardEvent} e Paste/drop event object.
@param {DOMRange} rng Rng object to move selection to.
@return {Boolean} true/false if the image data was f... | [
"Checks",
"if",
"the",
"clipboard",
"contains",
"image",
"data",
"if",
"it",
"does",
"it",
"will",
"take",
"that",
"data",
"and",
"convert",
"it",
"into",
"a",
"data",
"url",
"image",
"and",
"paste",
"that",
"image",
"at",
"the",
"caret",
"location",
"."... | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69840-L69869 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | isBrokenAndroidClipboardEvent | function isBrokenAndroidClipboardEvent(e) {
var clipboardData = e.clipboardData;
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
} | javascript | function isBrokenAndroidClipboardEvent(e) {
var clipboardData = e.clipboardData;
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
} | [
"function",
"isBrokenAndroidClipboardEvent",
"(",
"e",
")",
"{",
"var",
"clipboardData",
"=",
"e",
".",
"clipboardData",
";",
"return",
"navigator",
".",
"userAgent",
".",
"indexOf",
"(",
"'Android'",
")",
"!=",
"-",
"1",
"&&",
"clipboardData",
"&&",
"clipboar... | Chrome on Android doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
@param {Event} e Paste event object to check if it contains any data.
@return {Boolean} true/false if the clipboard is empty or not. | [
"Chrome",
"on",
"Android",
"doesn",
"t",
"support",
"proper",
"clipboard",
"access",
"so",
"we",
"have",
"no",
"choice",
"but",
"to",
"allow",
"the",
"browser",
"default",
"behavior",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L69877-L69881 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | isNumericList | function isNumericList(text) {
var found, patterns;
patterns = [
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
... | javascript | function isNumericList(text) {
var found, patterns;
patterns = [
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
... | [
"function",
"isNumericList",
"(",
"text",
")",
"{",
"var",
"found",
",",
"patterns",
";",
"patterns",
"=",
"[",
"/",
"^[IVXLMCD]{1,2}\\.[ \\u00a0]",
"/",
",",
"// Roman upper case",
"/",
"^[ivxlmcd]{1,2}\\.[ \\u00a0]",
"/",
",",
"// Roman lower case",
"/",
"^[a-z]{1... | Checks if the specified text starts with "1. " or "a. " etc. | [
"Checks",
"if",
"the",
"specified",
"text",
"starts",
"with",
"1",
".",
"or",
"a",
".",
"etc",
"."
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L70245-L70268 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | removeExplorerBrElementsAfterBlocks | function removeExplorerBrElementsAfterBlocks(html) {
// Only filter word specific content
if (!WordFilter.isWordContent(html)) {
return html;
}
// Produce block regexp based on the block elements in schema
var blockElements = [];
Tools.each(editor.schema.getBl... | javascript | function removeExplorerBrElementsAfterBlocks(html) {
// Only filter word specific content
if (!WordFilter.isWordContent(html)) {
return html;
}
// Produce block regexp based on the block elements in schema
var blockElements = [];
Tools.each(editor.schema.getBl... | [
"function",
"removeExplorerBrElementsAfterBlocks",
"(",
"html",
")",
"{",
"// Only filter word specific content",
"if",
"(",
"!",
"WordFilter",
".",
"isWordContent",
"(",
"html",
")",
")",
"{",
"return",
"html",
";",
"}",
"// Produce block regexp based on the block elemen... | Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
block element when pasting from word. This removes those elements.
This:
<p>a</p><br><p>b</p>
Becomes:
<p>a</p><p>b</p> | [
"Removes",
"BR",
"elements",
"after",
"block",
"elements",
".",
"IE9",
"has",
"a",
"nasty",
"bug",
"where",
"it",
"puts",
"a",
"BR",
"element",
"after",
"each",
"block",
"element",
"when",
"pasting",
"from",
"word",
".",
"This",
"removes",
"those",
"elemen... | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L70761-L70792 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | getPatterns | function getPatterns() {
if (isPatternsDirty) {
patterns.sort(function (a, b) {
if (a.start.length > b.start.length) {
return -1;
}
if (a.start.length < b.start.length) {
return 1;
}
return 0;
});
... | javascript | function getPatterns() {
if (isPatternsDirty) {
patterns.sort(function (a, b) {
if (a.start.length > b.start.length) {
return -1;
}
if (a.start.length < b.start.length) {
return 1;
}
return 0;
});
... | [
"function",
"getPatterns",
"(",
")",
"{",
"if",
"(",
"isPatternsDirty",
")",
"{",
"patterns",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"start",
".",
"length",
">",
"b",
".",
"start",
".",
"length",
")",
"{"... | Returns a sorted patterns list, ordered descending by start length | [
"Returns",
"a",
"sorted",
"patterns",
"list",
"ordered",
"descending",
"by",
"start",
"length"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L71984-L72002 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | findPattern | function findPattern(text) {
var patterns = getPatterns();
for (var i = 0; i < patterns.length; i++) {
if (text.indexOf(patterns[i].start) !== 0) {
continue;
}
if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
... | javascript | function findPattern(text) {
var patterns = getPatterns();
for (var i = 0; i < patterns.length; i++) {
if (text.indexOf(patterns[i].start) !== 0) {
continue;
}
if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
... | [
"function",
"findPattern",
"(",
"text",
")",
"{",
"var",
"patterns",
"=",
"getPatterns",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"patterns",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"text",
".",
"indexOf",
"(",
... | Finds a matching pattern to the specified text | [
"Finds",
"a",
"matching",
"pattern",
"to",
"the",
"specified",
"text"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L72005-L72019 | train |
sadiqhabib/tinymce-dist | tinymce.full.js | findEndPattern | function findEndPattern(text, offset, delta) {
var patterns, pattern, i;
// Find best matching end
patterns = getPatterns();
for (i = 0; i < patterns.length; i++) {
pattern = patterns[i];
if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end... | javascript | function findEndPattern(text, offset, delta) {
var patterns, pattern, i;
// Find best matching end
patterns = getPatterns();
for (i = 0; i < patterns.length; i++) {
pattern = patterns[i];
if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end... | [
"function",
"findEndPattern",
"(",
"text",
",",
"offset",
",",
"delta",
")",
"{",
"var",
"patterns",
",",
"pattern",
",",
"i",
";",
"// Find best matching end",
"patterns",
"=",
"getPatterns",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"p... | Finds the best matching end pattern | [
"Finds",
"the",
"best",
"matching",
"end",
"pattern"
] | 3acf1e4fe83a541988fdca20f2aaf4e6dce72512 | https://github.com/sadiqhabib/tinymce-dist/blob/3acf1e4fe83a541988fdca20f2aaf4e6dce72512/tinymce.full.js#L72022-L72033 | train |
tenorviol/xjs | lib/xjs.js | interpret | function interpret(source) {
var tree = parser.parse(source);
var js = [
'module.exports = function (out, globals) {',
' var end = false;',
' if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {',
' out = new module.xjs.XjsStream(out);',
' end = true;',
' }',
' ... | javascript | function interpret(source) {
var tree = parser.parse(source);
var js = [
'module.exports = function (out, globals) {',
' var end = false;',
' if (Object.getPrototypeOf(out) !== module.xjs.XjsStream.prototype) {',
' out = new module.xjs.XjsStream(out);',
' end = true;',
' }',
' ... | [
"function",
"interpret",
"(",
"source",
")",
"{",
"var",
"tree",
"=",
"parser",
".",
"parse",
"(",
"source",
")",
";",
"var",
"js",
"=",
"[",
"'module.exports = function (out, globals) {'",
",",
"' var end = false;'",
",",
"' if (Object.getPrototypeOf(out) !== modul... | Convert xjs source into javascript. | [
"Convert",
"xjs",
"source",
"into",
"javascript",
"."
] | 1f0744354b311066d6e58d11f9f5c602dae926af | https://github.com/tenorviol/xjs/blob/1f0744354b311066d6e58d11f9f5c602dae926af/lib/xjs.js#L51-L80 | train |
princed/grunt-csswring | tasks/csswring.js | getMapOption | function getMapOption(from) {
if (typeof options.map === 'string') {
var mapPath = options.map + path.basename(from) + '.map';
if (grunt.file.exists(mapPath)) {
return grunt.file.read(mapPath);
}
}
return options.map;
} | javascript | function getMapOption(from) {
if (typeof options.map === 'string') {
var mapPath = options.map + path.basename(from) + '.map';
if (grunt.file.exists(mapPath)) {
return grunt.file.read(mapPath);
}
}
return options.map;
} | [
"function",
"getMapOption",
"(",
"from",
")",
"{",
"if",
"(",
"typeof",
"options",
".",
"map",
"===",
"'string'",
")",
"{",
"var",
"mapPath",
"=",
"options",
".",
"map",
"+",
"path",
".",
"basename",
"(",
"from",
")",
"+",
"'.map'",
";",
"if",
"(",
... | Returns an input source map if a map path was specified
or options.map value otherwise
@param {string} from
@returns {string|boolean|undefined} | [
"Returns",
"an",
"input",
"source",
"map",
"if",
"a",
"map",
"path",
"was",
"specified",
"or",
"options",
".",
"map",
"value",
"otherwise"
] | db199bde5b23b3abc6c3b43f4fe83e65fd765ac5 | https://github.com/princed/grunt-csswring/blob/db199bde5b23b3abc6c3b43f4fe83e65fd765ac5/tasks/csswring.js#L20-L30 | train |
princed/grunt-csswring | tasks/csswring.js | setBanner | function setBanner(text) {
return function(css) {
css.prepend(postcss.comment({ text: text }));
// New line after banner
if (css.rules[1]) {
css.rules[1].before = '\n';
}
};
} | javascript | function setBanner(text) {
return function(css) {
css.prepend(postcss.comment({ text: text }));
// New line after banner
if (css.rules[1]) {
css.rules[1].before = '\n';
}
};
} | [
"function",
"setBanner",
"(",
"text",
")",
"{",
"return",
"function",
"(",
"css",
")",
"{",
"css",
".",
"prepend",
"(",
"postcss",
".",
"comment",
"(",
"{",
"text",
":",
"text",
"}",
")",
")",
";",
"// New line after banner",
"if",
"(",
"css",
".",
"... | Setup banner processor
@param {string} text
@returns {Function} | [
"Setup",
"banner",
"processor"
] | db199bde5b23b3abc6c3b43f4fe83e65fd765ac5 | https://github.com/princed/grunt-csswring/blob/db199bde5b23b3abc6c3b43f4fe83e65fd765ac5/tasks/csswring.js#L37-L46 | train |
anyfs/anyfs | lib/plugins/core/move.js | move | function move(fs, a, b, method, cb) {
var parentA = path.dirname(a);
var parentB = path.dirname(b);
var nameA = path.basename(a);
var nameB = path.basename(b)
fs.metadata(a)
.then(function(metadata) {
return this.metadata(b)
.then(function(metadata) {
throw f... | javascript | function move(fs, a, b, method, cb) {
var parentA = path.dirname(a);
var parentB = path.dirname(b);
var nameA = path.basename(a);
var nameB = path.basename(b)
fs.metadata(a)
.then(function(metadata) {
return this.metadata(b)
.then(function(metadata) {
throw f... | [
"function",
"move",
"(",
"fs",
",",
"a",
",",
"b",
",",
"method",
",",
"cb",
")",
"{",
"var",
"parentA",
"=",
"path",
".",
"dirname",
"(",
"a",
")",
";",
"var",
"parentB",
"=",
"path",
".",
"dirname",
"(",
"b",
")",
";",
"var",
"nameA",
"=",
... | move file or directory - expensive way. | [
"move",
"file",
"or",
"directory",
"-",
"expensive",
"way",
"."
] | bbaec164fd74cbc977245af45b0b1e3d0772b6ff | https://github.com/anyfs/anyfs/blob/bbaec164fd74cbc977245af45b0b1e3d0772b6ff/lib/plugins/core/move.js#L7-L34 | train |
caridy/es6-module-transpiler-system-formatter | lib/replacement.js | Replacement | function Replacement(nodePath, nodes) {
this.queue = [];
if (nodePath && nodes) {
this.queue.push([nodePath, nodes]);
}
} | javascript | function Replacement(nodePath, nodes) {
this.queue = [];
if (nodePath && nodes) {
this.queue.push([nodePath, nodes]);
}
} | [
"function",
"Replacement",
"(",
"nodePath",
",",
"nodes",
")",
"{",
"this",
".",
"queue",
"=",
"[",
"]",
";",
"if",
"(",
"nodePath",
"&&",
"nodes",
")",
"{",
"this",
".",
"queue",
".",
"push",
"(",
"[",
"nodePath",
",",
"nodes",
"]",
")",
";",
"}... | Represents a replacement of a node path with zero or more nodes.
@constructor
@param {ast-types.NodePath} nodePath
@param {Array.<ast-types.Node>} nodes | [
"Represents",
"a",
"replacement",
"of",
"a",
"node",
"path",
"with",
"zero",
"or",
"more",
"nodes",
"."
] | c6da4fb8319c057e52188b0dc2bd2dd648dcef05 | https://github.com/caridy/es6-module-transpiler-system-formatter/blob/c6da4fb8319c057e52188b0dc2bd2dd648dcef05/lib/replacement.js#L11-L16 | train |
rtm/upward | src/Tst.js | consoleReporter | function consoleReporter(reports, options = {}) {
var hide = options.hide || {};
(function _consoleReporter(reports) {
reports.forEach(
({children, desc, status, counts, time, code, error}) => {
let countStr = makeCounts(counts);
let color = statusInfo[status].color;
let colorSt... | javascript | function consoleReporter(reports, options = {}) {
var hide = options.hide || {};
(function _consoleReporter(reports) {
reports.forEach(
({children, desc, status, counts, time, code, error}) => {
let countStr = makeCounts(counts);
let color = statusInfo[status].color;
let colorSt... | [
"function",
"consoleReporter",
"(",
"reports",
",",
"options",
"=",
"{",
"}",
")",
"{",
"var",
"hide",
"=",
"options",
".",
"hide",
"||",
"{",
"}",
";",
"(",
"function",
"_consoleReporter",
"(",
"reports",
")",
"{",
"reports",
".",
"forEach",
"(",
"(",... | Console reporter, which reports results on the console. | [
"Console",
"reporter",
"which",
"reports",
"results",
"on",
"the",
"console",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Tst.js#L51-L73 | train |
rtm/upward | src/Tst.js | htmlReporter | function htmlReporter(reports, options = {}) {
var {hide} = options;
hide = hide || {};
function htmlReporterOne({children, desc, status, counts, time, code}) {
var text = T(desc);
var attrs = {class: {[status]: true}};
if (children) {
return E('details') .
has([
E('summary') ... | javascript | function htmlReporter(reports, options = {}) {
var {hide} = options;
hide = hide || {};
function htmlReporterOne({children, desc, status, counts, time, code}) {
var text = T(desc);
var attrs = {class: {[status]: true}};
if (children) {
return E('details') .
has([
E('summary') ... | [
"function",
"htmlReporter",
"(",
"reports",
",",
"options",
"=",
"{",
"}",
")",
"{",
"var",
"{",
"hide",
"}",
"=",
"options",
";",
"hide",
"=",
"hide",
"||",
"{",
"}",
";",
"function",
"htmlReporterOne",
"(",
"{",
"children",
",",
"desc",
",",
"statu... | HTML reporter; returns an Array of DOM nodes. | [
"HTML",
"reporter",
";",
"returns",
"an",
"Array",
"of",
"DOM",
"nodes",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Tst.js#L76-L96 | train |
pghalliday/multiplex-stream | src/MultiplexStream.js | emitEvent | function emitEvent(emitter, event, data) {
process.nextTick(function() {
emitter.emit(event, data);
});
} | javascript | function emitEvent(emitter, event, data) {
process.nextTick(function() {
emitter.emit(event, data);
});
} | [
"function",
"emitEvent",
"(",
"emitter",
",",
"event",
",",
"data",
")",
"{",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"emitter",
".",
"emit",
"(",
"event",
",",
"data",
")",
";",
"}",
")",
";",
"}"
] | force all events to be asynchronous | [
"force",
"all",
"events",
"to",
"be",
"asynchronous"
] | 5d425a5c5409d6fe3c1f98ea496e7a039c495920 | https://github.com/pghalliday/multiplex-stream/blob/5d425a5c5409d6fe3c1f98ea496e7a039c495920/src/MultiplexStream.js#L14-L18 | train |
stayradiated/onepasswordjs | libs/sjcl.js | function (arr) {
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) === 0) {
tmp = arr[i/4];
}
out.push(tmp >>> 24);
tmp <<= 8;
}
return out;
} | javascript | function (arr) {
var out = [], bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) === 0) {
tmp = arr[i/4];
}
out.push(tmp >>> 24);
tmp <<= 8;
}
return out;
} | [
"function",
"(",
"arr",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"bl",
"=",
"sjcl",
".",
"bitArray",
".",
"bitLength",
"(",
"arr",
")",
",",
"i",
",",
"tmp",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bl",
"/",
"8",
";",
"i",
"++"... | Convert from a bitArray to an array of bytes. | [
"Convert",
"from",
"a",
"bitArray",
"to",
"an",
"array",
"of",
"bytes",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/libs/sjcl.js#L58-L68 | train | |
stayradiated/onepasswordjs | libs/sjcl.js | function (bytes) {
var out = [], i, tmp=0;
for (i=0; i<bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i&3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i&3) {
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
}
return out;
} | javascript | function (bytes) {
var out = [], i, tmp=0;
for (i=0; i<bytes.length; i++) {
tmp = tmp << 8 | bytes[i];
if ((i&3) === 3) {
out.push(tmp);
tmp = 0;
}
}
if (i&3) {
out.push(sjcl.bitArray.partial(8*(i&3), tmp));
}
return out;
} | [
"function",
"(",
"bytes",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"i",
",",
"tmp",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"tmp",
"=",
"tmp",
"<<",
"8",
"|",
"bytes",
... | Convert from an array of bytes to a bitArray. | [
"Convert",
"from",
"an",
"array",
"of",
"bytes",
"to",
"a",
"bitArray",
"."
] | 6f37d31bd5e7e57489885e89ef9df88e8197a2c3 | https://github.com/stayradiated/onepasswordjs/blob/6f37d31bd5e7e57489885e89ef9df88e8197a2c3/libs/sjcl.js#L70-L83 | train | |
smartface/sf-component-calendar | lib/services/StyleContext.js | createStyleContext | function createStyleContext(actors, hooks) {
var context;
/**
* Composes a context.
*
* @param {function) styling - Styling function from styler.
* @param {function} reducer - Reducer function to run actions
*/
return function composeContext(styling, reducer) {
var latestSta... | javascript | function createStyleContext(actors, hooks) {
var context;
/**
* Composes a context.
*
* @param {function) styling - Styling function from styler.
* @param {function} reducer - Reducer function to run actions
*/
return function composeContext(styling, reducer) {
var latestSta... | [
"function",
"createStyleContext",
"(",
"actors",
",",
"hooks",
")",
"{",
"var",
"context",
";",
"/**\n * Composes a context.\n * \n * @param {function) styling - Styling function from styler.\n * @param {function} reducer - Reducer function to run actions\n */",
"return",... | Style Context. Returns context composer
@param {Array.<Object>} actors - Actors List
@param {function} hooks - Hooks callback
@returns {function} - Context Composer Function | [
"Style",
"Context",
".",
"Returns",
"context",
"composer"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/lib/services/StyleContext.js#L256-L309 | train |
baijijs/baiji | lib/Controller.js | configure | function configure(proto, nameOrConfigs, actionConfig) {
if (!proto.__configs) proto.__configs = {};
if (typeof nameOrConfigs === 'string') {
// Set new configs
if (typeof actionConfig === 'object') {
proto.__configs = _.assign(
proto.__configs,
{ [nameOrConfigs]: actionConfig }
... | javascript | function configure(proto, nameOrConfigs, actionConfig) {
if (!proto.__configs) proto.__configs = {};
if (typeof nameOrConfigs === 'string') {
// Set new configs
if (typeof actionConfig === 'object') {
proto.__configs = _.assign(
proto.__configs,
{ [nameOrConfigs]: actionConfig }
... | [
"function",
"configure",
"(",
"proto",
",",
"nameOrConfigs",
",",
"actionConfig",
")",
"{",
"if",
"(",
"!",
"proto",
".",
"__configs",
")",
"proto",
".",
"__configs",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"nameOrConfigs",
"===",
"'string'",
")",
"{",
... | Route action for adding routes config for both Controller and its instance | [
"Route",
"action",
"for",
"adding",
"routes",
"config",
"for",
"both",
"Controller",
"and",
"its",
"instance"
] | 9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601 | https://github.com/baijijs/baiji/blob/9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601/lib/Controller.js#L13-L34 | train |
baijijs/baiji | lib/Controller.js | detectConflictActions | function detectConflictActions(instance) {
// Get all props and check reserved words
let propNames = Object.getOwnPropertyNames(instance.__proto__);
// Check internal action conflicts
_.each(propNames, function(name) {
assert(
!~RESERVED_METHODS.indexOf(name),
`Action: \`${name}\` is reserved b... | javascript | function detectConflictActions(instance) {
// Get all props and check reserved words
let propNames = Object.getOwnPropertyNames(instance.__proto__);
// Check internal action conflicts
_.each(propNames, function(name) {
assert(
!~RESERVED_METHODS.indexOf(name),
`Action: \`${name}\` is reserved b... | [
"function",
"detectConflictActions",
"(",
"instance",
")",
"{",
"// Get all props and check reserved words",
"let",
"propNames",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"instance",
".",
"__proto__",
")",
";",
"// Check internal action conflicts",
"_",
".",
"each",... | Detect whether user defined actions unexpectedly overwritten reserved actions
Error will be throwed out if any confliction found | [
"Detect",
"whether",
"user",
"defined",
"actions",
"unexpectedly",
"overwritten",
"reserved",
"actions",
"Error",
"will",
"be",
"throwed",
"out",
"if",
"any",
"confliction",
"found"
] | 9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601 | https://github.com/baijijs/baiji/blob/9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601/lib/Controller.js#L40-L51 | train |
lukewestby/class-name-builder | src/class-name-builder.js | unique | function unique(value) {
return value.reduce((memo, current) => {
return memo.indexOf(current) !== -1 ? memo : memo.concat(current);
}, []);
} | javascript | function unique(value) {
return value.reduce((memo, current) => {
return memo.indexOf(current) !== -1 ? memo : memo.concat(current);
}, []);
} | [
"function",
"unique",
"(",
"value",
")",
"{",
"return",
"value",
".",
"reduce",
"(",
"(",
"memo",
",",
"current",
")",
"=>",
"{",
"return",
"memo",
".",
"indexOf",
"(",
"current",
")",
"!==",
"-",
"1",
"?",
"memo",
":",
"memo",
".",
"concat",
"(",
... | Performaces a uniqueness reduction on an array
@param {Array} value - the array to reduce
@returns {Array} an array with unique values | [
"Performaces",
"a",
"uniqueness",
"reduction",
"on",
"an",
"array"
] | 2e252f0ef0ff0fa08ef1a7eda82bdd2be3a50e41 | https://github.com/lukewestby/class-name-builder/blob/2e252f0ef0ff0fa08ef1a7eda82bdd2be3a50e41/src/class-name-builder.js#L124-L128 | train |
lukewestby/class-name-builder | src/class-name-builder.js | cleanClassNames | function cleanClassNames(value) {
const classNamesArray = isString(value) ? splitString(value) : value;
const trimmedNamesArray = trimClassNames(classNamesArray);
const uniqueNamesArray = unique(trimmedNamesArray);
return uniqueNamesArray;
} | javascript | function cleanClassNames(value) {
const classNamesArray = isString(value) ? splitString(value) : value;
const trimmedNamesArray = trimClassNames(classNamesArray);
const uniqueNamesArray = unique(trimmedNamesArray);
return uniqueNamesArray;
} | [
"function",
"cleanClassNames",
"(",
"value",
")",
"{",
"const",
"classNamesArray",
"=",
"isString",
"(",
"value",
")",
"?",
"splitString",
"(",
"value",
")",
":",
"value",
";",
"const",
"trimmedNamesArray",
"=",
"trimClassNames",
"(",
"classNamesArray",
")",
"... | Converts class name input into an array of strings with space trimmed off
@param {string | Array<string>} value - the value to convert
@returns {Array<string>} the split and trimmed values | [
"Converts",
"class",
"name",
"input",
"into",
"an",
"array",
"of",
"strings",
"with",
"space",
"trimmed",
"off"
] | 2e252f0ef0ff0fa08ef1a7eda82bdd2be3a50e41 | https://github.com/lukewestby/class-name-builder/blob/2e252f0ef0ff0fa08ef1a7eda82bdd2be3a50e41/src/class-name-builder.js#L144-L149 | train |
reelyactive/chickadee | lib/server.js | ChickadeeServer | function ChickadeeServer(options) {
options = options || {};
var specifiedHttpPort = options.httpPort || HTTP_PORT;
var httpPort = process.env.PORT || specifiedHttpPort;
var app = express();
app.use(bodyParser.json());
var instance = new Chickadee(options);
options.app = app;
instance.configureRoutes(... | javascript | function ChickadeeServer(options) {
options = options || {};
var specifiedHttpPort = options.httpPort || HTTP_PORT;
var httpPort = process.env.PORT || specifiedHttpPort;
var app = express();
app.use(bodyParser.json());
var instance = new Chickadee(options);
options.app = app;
instance.configureRoutes(... | [
"function",
"ChickadeeServer",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"specifiedHttpPort",
"=",
"options",
".",
"httpPort",
"||",
"HTTP_PORT",
";",
"var",
"httpPort",
"=",
"process",
".",
"env",
".",
"PORT",
"||",
... | ChickadeeServer Class
Server for chickadee, returns an instance of chickadee with its own Express
server listening on the given port.
@param {Object} options The options as a JSON object.
@constructor | [
"ChickadeeServer",
"Class",
"Server",
"for",
"chickadee",
"returns",
"an",
"instance",
"of",
"chickadee",
"with",
"its",
"own",
"Express",
"server",
"listening",
"on",
"the",
"given",
"port",
"."
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/lib/server.js#L23-L40 | train |
rtm/upward | src/Obs.js | getTypesFromHandlers | function getTypesFromHandlers(handlers) {
var types = keys(handlers);
types = types.map(k => k.replace(/_.*/, ''));
if (types.indexOf('end') !== -1) {
types.push('add', 'update', 'delete');
}
return types;
} | javascript | function getTypesFromHandlers(handlers) {
var types = keys(handlers);
types = types.map(k => k.replace(/_.*/, ''));
if (types.indexOf('end') !== -1) {
types.push('add', 'update', 'delete');
}
return types;
} | [
"function",
"getTypesFromHandlers",
"(",
"handlers",
")",
"{",
"var",
"types",
"=",
"keys",
"(",
"handlers",
")",
";",
"types",
"=",
"types",
".",
"map",
"(",
"k",
"=>",
"k",
".",
"replace",
"(",
"/",
"_.*",
"/",
",",
"''",
")",
")",
";",
"if",
"... | Prepare the list of `type`s to pass to O.o, based on handler methods. Even if only `end` is present, we need to add `add` etc. If handler named `type_name` is there, register `type` as handled. | [
"Prepare",
"the",
"list",
"of",
"type",
"s",
"to",
"pass",
"to",
"O",
".",
"o",
"based",
"on",
"handler",
"methods",
".",
"Even",
"if",
"only",
"end",
"is",
"present",
"we",
"need",
"to",
"add",
"add",
"etc",
".",
"If",
"handler",
"named",
"type_name... | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L49-L56 | train |
rtm/upward | src/Obs.js | makeObserver | function makeObserver(handlers) {
console.assert(handlers && typeof handlers === 'object', "Argument to makeObserver must be hash.");
var handler = assign(create(observerPrototype), handlers);
var observer = handler.handle.bind(handler);
observer.keys = getTypesFromHandlers(handlers);
return observer;
} | javascript | function makeObserver(handlers) {
console.assert(handlers && typeof handlers === 'object', "Argument to makeObserver must be hash.");
var handler = assign(create(observerPrototype), handlers);
var observer = handler.handle.bind(handler);
observer.keys = getTypesFromHandlers(handlers);
return observer;
} | [
"function",
"makeObserver",
"(",
"handlers",
")",
"{",
"console",
".",
"assert",
"(",
"handlers",
"&&",
"typeof",
"handlers",
"===",
"'object'",
",",
"\"Argument to makeObserver must be hash.\"",
")",
";",
"var",
"handler",
"=",
"assign",
"(",
"create",
"(",
"ob... | Make an observer from a hash of handlers for observation types. This observer can be passed to `observeObject`. | [
"Make",
"an",
"observer",
"from",
"a",
"hash",
"of",
"handlers",
"for",
"observation",
"types",
".",
"This",
"observer",
"can",
"be",
"passed",
"to",
"observeObject",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L60-L66 | train |
rtm/upward | src/Obs.js | observeObject | function observeObject(o, observer) {
return o && typeof o === 'object' && observe(o, observer, observer.keys);
} | javascript | function observeObject(o, observer) {
return o && typeof o === 'object' && observe(o, observer, observer.keys);
} | [
"function",
"observeObject",
"(",
"o",
",",
"observer",
")",
"{",
"return",
"o",
"&&",
"typeof",
"o",
"===",
"'object'",
"&&",
"observe",
"(",
"o",
",",
"observer",
",",
"observer",
".",
"keys",
")",
";",
"}"
] | Invoke Object.observe with only the types available to be handled. | [
"Invoke",
"Object",
".",
"observe",
"with",
"only",
"the",
"types",
"available",
"to",
"be",
"handled",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L69-L71 | train |
rtm/upward | src/Obs.js | notifyRetroactively | function notifyRetroactively(object) {
if (object && typeof object === 'object') {
const type = 'add';
var notifier = Object.getNotifier(object);
keys(object).forEach(name => notifier.notify({type, name, object}));
}
return object;
} | javascript | function notifyRetroactively(object) {
if (object && typeof object === 'object') {
const type = 'add';
var notifier = Object.getNotifier(object);
keys(object).forEach(name => notifier.notify({type, name, object}));
}
return object;
} | [
"function",
"notifyRetroactively",
"(",
"object",
")",
"{",
"if",
"(",
"object",
"&&",
"typeof",
"object",
"===",
"'object'",
")",
"{",
"const",
"type",
"=",
"'add'",
";",
"var",
"notifier",
"=",
"Object",
".",
"getNotifier",
"(",
"object",
")",
";",
"ke... | Retroactively notify 'add' to all properties in an object. | [
"Retroactively",
"notify",
"add",
"to",
"all",
"properties",
"in",
"an",
"object",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L85-L92 | train |
rtm/upward | src/Obs.js | observeOnce | function observeOnce(object, observer, types) {
function _observer(changes) {
observer(changes);
unobserve(object, _observer);
}
observe(object, _observer, types);
} | javascript | function observeOnce(object, observer, types) {
function _observer(changes) {
observer(changes);
unobserve(object, _observer);
}
observe(object, _observer, types);
} | [
"function",
"observeOnce",
"(",
"object",
",",
"observer",
",",
"types",
")",
"{",
"function",
"_observer",
"(",
"changes",
")",
"{",
"observer",
"(",
"changes",
")",
";",
"unobserve",
"(",
"object",
",",
"_observer",
")",
";",
"}",
"observe",
"(",
"obje... | Set up an observer and tear it down after the first report | [
"Set",
"up",
"an",
"observer",
"and",
"tear",
"it",
"down",
"after",
"the",
"first",
"report"
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L95-L101 | train |
rtm/upward | src/Obs.js | mirrorProperties | function mirrorProperties(src, dest = {}) {
function set(name) { dest[name] = src[name]; }
function _delete(name) { delete dest[name]; }
var handlers = { add: set, update: set, delete: _delete};
assign(dest, src);
observe(src, makeObserver(handlers));
return dest;
} | javascript | function mirrorProperties(src, dest = {}) {
function set(name) { dest[name] = src[name]; }
function _delete(name) { delete dest[name]; }
var handlers = { add: set, update: set, delete: _delete};
assign(dest, src);
observe(src, makeObserver(handlers));
return dest;
} | [
"function",
"mirrorProperties",
"(",
"src",
",",
"dest",
"=",
"{",
"}",
")",
"{",
"function",
"set",
"(",
"name",
")",
"{",
"dest",
"[",
"name",
"]",
"=",
"src",
"[",
"name",
"]",
";",
"}",
"function",
"_delete",
"(",
"name",
")",
"{",
"delete",
... | Keep an object in sync with another. | [
"Keep",
"an",
"object",
"in",
"sync",
"with",
"another",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L104-L113 | train |
rtm/upward | src/Obs.js | Observer | function Observer(object, observer, types) {
return {
observe(_types) {
types = _types || types;
if (isObject(object)) observe(object, observer, types);
return this;
},
unobserve() {
if (isObject(object)) unobserve(object, observer);
return this;
},
reobserve(_object)... | javascript | function Observer(object, observer, types) {
return {
observe(_types) {
types = _types || types;
if (isObject(object)) observe(object, observer, types);
return this;
},
unobserve() {
if (isObject(object)) unobserve(object, observer);
return this;
},
reobserve(_object)... | [
"function",
"Observer",
"(",
"object",
",",
"observer",
",",
"types",
")",
"{",
"return",
"{",
"observe",
"(",
"_types",
")",
"{",
"types",
"=",
"_types",
"||",
"types",
";",
"if",
"(",
"isObject",
"(",
"object",
")",
")",
"observe",
"(",
"object",
"... | Make an Observer object, which allows easy unobserving and resobserving. | [
"Make",
"an",
"Observer",
"object",
"which",
"allows",
"easy",
"unobserving",
"and",
"resobserving",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Obs.js#L116-L133 | train |
node-tastypie/tastypie | lib/class/parent.js | function(method){
var parent, result;
parent = this._parent || this.constructor.parent;
this._parent = parent.constructor.parent;
result = attempt(parent[method], slice(arguments, 1) , this );
this._parent = parent;
if( result[0] ){
throw result[... | javascript | function(method){
var parent, result;
parent = this._parent || this.constructor.parent;
this._parent = parent.constructor.parent;
result = attempt(parent[method], slice(arguments, 1) , this );
this._parent = parent;
if( result[0] ){
throw result[... | [
"function",
"(",
"method",
")",
"{",
"var",
"parent",
",",
"result",
";",
"parent",
"=",
"this",
".",
"_parent",
"||",
"this",
".",
"constructor",
".",
"parent",
";",
"this",
".",
"_parent",
"=",
"parent",
".",
"constructor",
".",
"parent",
";",
"resul... | Calls a function on the parent class in the scope of the child class
@method module:tastypie/lib/class/parent#parent
@param {TYPE} name DESCRIPTION
@param {...Mixed} argument arguments to pass to the function
@return {?Object} returns the result of the parent function call | [
"Calls",
"a",
"function",
"on",
"the",
"parent",
"class",
"in",
"the",
"scope",
"of",
"the",
"child",
"class"
] | bf42227975704ac19cce2c5f62427a205cadafdb | https://github.com/node-tastypie/tastypie/blob/bf42227975704ac19cce2c5f62427a205cadafdb/lib/class/parent.js#L35-L48 | train | |
defunctzombie/ratelimit-middleware | index.js | throttle | function throttle(options) {
assert.object(options, 'options');
assert.number(options.burst, 'options.burst');
assert.number(options.rate, 'options.rate');
if (!xor(options.ip, options.xff, options.username)) {
throw new Error('(ip ^ username ^ xff)');
}
for (key in options.overrides) {... | javascript | function throttle(options) {
assert.object(options, 'options');
assert.number(options.burst, 'options.burst');
assert.number(options.rate, 'options.rate');
if (!xor(options.ip, options.xff, options.username)) {
throw new Error('(ip ^ username ^ xff)');
}
for (key in options.overrides) {... | [
"function",
"throttle",
"(",
"options",
")",
"{",
"assert",
".",
"object",
"(",
"options",
",",
"'options'",
")",
";",
"assert",
".",
"number",
"(",
"options",
".",
"burst",
",",
"'options.burst'",
")",
";",
"assert",
".",
"number",
"(",
"options",
".",
... | Creates an API rate limiter that can be plugged into the standard
restify request handling pipeline.
This throttle gives you three options on which to throttle:
username, IP address and 'X-Forwarded-For'. IP/XFF is a /32 match,
so keep that in mind if using it. Username takes the user specified
on req.username (which... | [
"Creates",
"an",
"API",
"rate",
"limiter",
"that",
"can",
"be",
"plugged",
"into",
"the",
"standard",
"restify",
"request",
"handling",
"pipeline",
"."
] | b5dc549e5498c6c4e50ec3daca4491f129536e6e | https://github.com/defunctzombie/ratelimit-middleware/blob/b5dc549e5498c6c4e50ec3daca4491f129536e6e/index.js#L63-L173 | train |
defunctzombie/node-influx-collector | index.js | Collector | function Collector(series, uri) {
if (!(this instanceof Collector)) {
return new Collector(series, uri);
}
var self = this;
if (!uri) {
return;
}
if (!series) {
throw new Error('series name must be specified');
}
var parsed = url.parse(uri, true /* parse query... | javascript | function Collector(series, uri) {
if (!(this instanceof Collector)) {
return new Collector(series, uri);
}
var self = this;
if (!uri) {
return;
}
if (!series) {
throw new Error('series name must be specified');
}
var parsed = url.parse(uri, true /* parse query... | [
"function",
"Collector",
"(",
"series",
",",
"uri",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Collector",
")",
")",
"{",
"return",
"new",
"Collector",
"(",
"series",
",",
"uri",
")",
";",
"}",
"var",
"self",
"=",
"this",
";",
"if",
"(",... | create a collector for the given series | [
"create",
"a",
"collector",
"for",
"the",
"given",
"series"
] | 4a6701bf6f7d6489fe25dc55e6eaa24c15ae5a50 | https://github.com/defunctzombie/node-influx-collector/blob/4a6701bf6f7d6489fe25dc55e6eaa24c15ae5a50/index.js#L6-L61 | train |
flyvictor/fortune-client | lib/resource-linker.js | fetchAncestor | function fetchAncestor(type, ids, includePath, req) {
return router.actions["get" + util.toCapitalisedCamelCase(type)](ids, {include: includePath, parentRequest: req});
} | javascript | function fetchAncestor(type, ids, includePath, req) {
return router.actions["get" + util.toCapitalisedCamelCase(type)](ids, {include: includePath, parentRequest: req});
} | [
"function",
"fetchAncestor",
"(",
"type",
",",
"ids",
",",
"includePath",
",",
"req",
")",
"{",
"return",
"router",
".",
"actions",
"[",
"\"get\"",
"+",
"util",
".",
"toCapitalisedCamelCase",
"(",
"type",
")",
"]",
"(",
"ids",
",",
"{",
"include",
":",
... | Returns the resource data for the external resource.
@param {String} The type of resource to lookup.
@param {Array} The link id(s) of the resource to be looked up.
@param {Object} The http request object.
@param {Array} The include url params.
@api private | [
"Returns",
"the",
"resource",
"data",
"for",
"the",
"external",
"resource",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L63-L65 | train |
flyvictor/fortune-client | lib/resource-linker.js | mergeLinked | function mergeLinked(source, target, pathArr, ancestorType) {
var linked, type, res;
if (pathArr.length) {
// the external is referenced by the ancestor
if (source.links && source.linked && source.links[ancestorType + "." + pathArr.join(".")]) {
type = source.links[ancestorType + "." + path... | javascript | function mergeLinked(source, target, pathArr, ancestorType) {
var linked, type, res;
if (pathArr.length) {
// the external is referenced by the ancestor
if (source.links && source.linked && source.links[ancestorType + "." + pathArr.join(".")]) {
type = source.links[ancestorType + "." + path... | [
"function",
"mergeLinked",
"(",
"source",
",",
"target",
",",
"pathArr",
",",
"ancestorType",
")",
"{",
"var",
"linked",
",",
"type",
",",
"res",
";",
"if",
"(",
"pathArr",
".",
"length",
")",
"{",
"// the external is referenced by the ancestor",
"if",
"(",
... | Replaces the target linked property with the external data.
@param {Object} The source from the external lookup.
@param {Object} The target resource.
@param {Object} The include properties.
@param {Object} The lookup resource type.
@api private | [
"Replaces",
"the",
"target",
"linked",
"property",
"with",
"the",
"external",
"data",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L76-L92 | train |
flyvictor/fortune-client | lib/resource-linker.js | mergeLinks | function mergeLinks(source, target, pathArr, ancestorType) {
var refType = ancestorType + ((pathArr.length > 1) ? "." + _.rest(pathArr).join(".") : "");
var link = source.links && source.links[refType];
if (link) target.links[rootName(target) + "." + pathArr.join(".")] = link;
} | javascript | function mergeLinks(source, target, pathArr, ancestorType) {
var refType = ancestorType + ((pathArr.length > 1) ? "." + _.rest(pathArr).join(".") : "");
var link = source.links && source.links[refType];
if (link) target.links[rootName(target) + "." + pathArr.join(".")] = link;
} | [
"function",
"mergeLinks",
"(",
"source",
",",
"target",
",",
"pathArr",
",",
"ancestorType",
")",
"{",
"var",
"refType",
"=",
"ancestorType",
"+",
"(",
"(",
"pathArr",
".",
"length",
">",
"1",
")",
"?",
"\".\"",
"+",
"_",
".",
"rest",
"(",
"pathArr",
... | Append meta data of included type to the links section of root resource.
@param {Object} The source from the external lookup.
@param {Object} The target resource.
@param {Object} The include properties.
@param {Object} The lookup resource type.
@api private | [
"Append",
"meta",
"data",
"of",
"included",
"type",
"to",
"the",
"links",
"section",
"of",
"root",
"resource",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L103-L109 | train |
flyvictor/fortune-client | lib/resource-linker.js | mergeAncestorData | function mergeAncestorData(target, pathArr, type, source) {
mergeLinked(source, target, _.rest(pathArr), type);
mergeLinks(source, target , pathArr, type);
} | javascript | function mergeAncestorData(target, pathArr, type, source) {
mergeLinked(source, target, _.rest(pathArr), type);
mergeLinks(source, target , pathArr, type);
} | [
"function",
"mergeAncestorData",
"(",
"target",
",",
"pathArr",
",",
"type",
",",
"source",
")",
"{",
"mergeLinked",
"(",
"source",
",",
"target",
",",
"_",
".",
"rest",
"(",
"pathArr",
")",
",",
"type",
")",
";",
"mergeLinks",
"(",
"source",
",",
"tar... | Combines the original target resource with the external resource data.
@param {Object} The target resource.
@param {Object} The include properties.
@param {Object} The lookup resource type.
@param {Object} The source from the external lookup.
@api private | [
"Combines",
"the",
"original",
"target",
"resource",
"with",
"the",
"external",
"resource",
"data",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L120-L123 | train |
flyvictor/fortune-client | lib/resource-linker.js | groupIncludes | function groupIncludes(includes, body) {
var root = rootName(body);
var requestsByType = {};
_.each(includes, function(include) {
var type = ((body.links && body.links[root + "." + include]) || {}).type,
split = include.split(".");
if (_.isUndefined(body.links) || _.isUndefined(body.li... | javascript | function groupIncludes(includes, body) {
var root = rootName(body);
var requestsByType = {};
_.each(includes, function(include) {
var type = ((body.links && body.links[root + "." + include]) || {}).type,
split = include.split(".");
if (_.isUndefined(body.links) || _.isUndefined(body.li... | [
"function",
"groupIncludes",
"(",
"includes",
",",
"body",
")",
"{",
"var",
"root",
"=",
"rootName",
"(",
"body",
")",
";",
"var",
"requestsByType",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"includes",
",",
"function",
"(",
"include",
")",
"{",
"va... | Batches together the includes by type, as to avoid multiple requests.
@param {Object} The resource body.
@api private | [
"Batches",
"together",
"the",
"includes",
"by",
"type",
"as",
"to",
"avoid",
"multiple",
"requests",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L134-L162 | train |
flyvictor/fortune-client | lib/resource-linker.js | fetchExternals | function fetchExternals(request, body) {
var includes = parseIncludes(request);
var user = request.user;
var requestsByType = groupIncludes(includes, body);
return when.all(_.map(requestsByType, function(requestData, ancestorType) {
var ids = _.uniq(requestData.ids);
return fetchAncest... | javascript | function fetchExternals(request, body) {
var includes = parseIncludes(request);
var user = request.user;
var requestsByType = groupIncludes(includes, body);
return when.all(_.map(requestsByType, function(requestData, ancestorType) {
var ids = _.uniq(requestData.ids);
return fetchAncest... | [
"function",
"fetchExternals",
"(",
"request",
",",
"body",
")",
"{",
"var",
"includes",
"=",
"parseIncludes",
"(",
"request",
")",
";",
"var",
"user",
"=",
"request",
".",
"user",
";",
"var",
"requestsByType",
"=",
"groupIncludes",
"(",
"includes",
",",
"b... | Reads the resource object and attaches data via external http calls
the properties marked as "external".
@param {Object} The http request object.
@param {Object} The body data from the response.
@api private | [
"Reads",
"the",
"resource",
"object",
"and",
"attaches",
"data",
"via",
"external",
"http",
"calls",
"the",
"properties",
"marked",
"as",
"external",
"."
] | 1d1eaccbe0cf5293201736d6563ff4cd70881542 | https://github.com/flyvictor/fortune-client/blob/1d1eaccbe0cf5293201736d6563ff4cd70881542/lib/resource-linker.js#L173-L194 | train |
smartface/sf-component-calendar | src/services/CalendarService.js | getMonth | function getMonth(moment, service, dt) {
const dateService = new service(moment, dt);
return {
longName: dateService.monthLong(),
shortName: dateService.monthShort(),
daysCount: dateService.daysCount(),
startDayOfMonth: dateService.startDayOfMonth(),
};
} | javascript | function getMonth(moment, service, dt) {
const dateService = new service(moment, dt);
return {
longName: dateService.monthLong(),
shortName: dateService.monthShort(),
daysCount: dateService.daysCount(),
startDayOfMonth: dateService.startDayOfMonth(),
};
} | [
"function",
"getMonth",
"(",
"moment",
",",
"service",
",",
"dt",
")",
"{",
"const",
"dateService",
"=",
"new",
"service",
"(",
"moment",
",",
"dt",
")",
";",
"return",
"{",
"longName",
":",
"dateService",
".",
"monthLong",
"(",
")",
",",
"shortName",
... | Returns current month data
@private
@returns {Object} | [
"Returns",
"current",
"month",
"data"
] | d6c8310564ff551b9424ac6955efa5e8cf5f8dff | https://github.com/smartface/sf-component-calendar/blob/d6c8310564ff551b9424ac6955efa5e8cf5f8dff/src/services/CalendarService.js#L75-L85 | train |
koliseoapi/alt-ng | Alt.js | generateActions | function generateActions({ generate, ...actions }) {
return !generate
? actions
: Object.assign(
generate.reduce((obj, name) => {
obj[name] = forwardValue;
return obj;
}, {}),
actions
);
} | javascript | function generateActions({ generate, ...actions }) {
return !generate
? actions
: Object.assign(
generate.reduce((obj, name) => {
obj[name] = forwardValue;
return obj;
}, {}),
actions
);
} | [
"function",
"generateActions",
"(",
"{",
"generate",
",",
"...",
"actions",
"}",
")",
"{",
"return",
"!",
"generate",
"?",
"actions",
":",
"Object",
".",
"assign",
"(",
"generate",
".",
"reduce",
"(",
"(",
"obj",
",",
"name",
")",
"=>",
"{",
"obj",
"... | process the "generate" field of an Actions object. Adds a new pass-through
method with each name from the generated values | [
"process",
"the",
"generate",
"field",
"of",
"an",
"Actions",
"object",
".",
"Adds",
"a",
"new",
"pass",
"-",
"through",
"method",
"with",
"each",
"name",
"from",
"the",
"generated",
"values"
] | cfb4cbfb15f5a286d24fc18fa3e49d7dc58549b4 | https://github.com/koliseoapi/alt-ng/blob/cfb4cbfb15f5a286d24fc18fa3e49d7dc58549b4/Alt.js#L14-L24 | train |
DeviaVir/node-transip | transip.js | TransIP | function TransIP(login, privateKey) {
this.version = 5.1;
this.mode = 'readwrite';
this.endpoint = 'api.transip.nl';
this.login = (login ? login : config.transip.login);
this.privateKey = (privateKey ? privateKey : config.transip.privateKey);
this.domainService = new domainService(this);
} | javascript | function TransIP(login, privateKey) {
this.version = 5.1;
this.mode = 'readwrite';
this.endpoint = 'api.transip.nl';
this.login = (login ? login : config.transip.login);
this.privateKey = (privateKey ? privateKey : config.transip.privateKey);
this.domainService = new domainService(this);
} | [
"function",
"TransIP",
"(",
"login",
",",
"privateKey",
")",
"{",
"this",
".",
"version",
"=",
"5.1",
";",
"this",
".",
"mode",
"=",
"'readwrite'",
";",
"this",
".",
"endpoint",
"=",
"'api.transip.nl'",
";",
"this",
".",
"login",
"=",
"(",
"login",
"?"... | TransIP instance constructor
@prototype
@class TransIP | [
"TransIP",
"instance",
"constructor"
] | 8bc5283a0bf2c6a21455f9f4629872cd08b65ac0 | https://github.com/DeviaVir/node-transip/blob/8bc5283a0bf2c6a21455f9f4629872cd08b65ac0/transip.js#L21-L29 | train |
mattdot/passport-mspassport | lib/strategy.js | function(defaults, options) {
options = options || {};
for (var option in defaults) {
if (defaults.hasOwnProperty(option) && !options.hasOwnProperty(option)) {
options[option] = defaults[option];
}
}
return options;
} | javascript | function(defaults, options) {
options = options || {};
for (var option in defaults) {
if (defaults.hasOwnProperty(option) && !options.hasOwnProperty(option)) {
options[option] = defaults[option];
}
}
return options;
} | [
"function",
"(",
"defaults",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"option",
"in",
"defaults",
")",
"{",
"if",
"(",
"defaults",
".",
"hasOwnProperty",
"(",
"option",
")",
"&&",
"!",
"options",
".... | Merges default options with actual options
@param {Object} defaults The default options
@param {Object} options The set options
@api private | [
"Merges",
"default",
"options",
"with",
"actual",
"options"
] | 0a89357e58d77db219beef0cd994ad8d6f8e53b2 | https://github.com/mattdot/passport-mspassport/blob/0a89357e58d77db219beef0cd994ad8d6f8e53b2/lib/strategy.js#L13-L22 | train | |
mattdot/passport-mspassport | lib/strategy.js | MSPassportStrategy | function MSPassportStrategy(options) {
Strategy.call(this);
this.name = "mspassport";
var default_options = {
protocol : "querystring",
protocolHandler : function() { self.fail("protocolHandler must be implemented if protocol === 'custom'") }
};
this.options = _defaults(default... | javascript | function MSPassportStrategy(options) {
Strategy.call(this);
this.name = "mspassport";
var default_options = {
protocol : "querystring",
protocolHandler : function() { self.fail("protocolHandler must be implemented if protocol === 'custom'") }
};
this.options = _defaults(default... | [
"function",
"MSPassportStrategy",
"(",
"options",
")",
"{",
"Strategy",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"name",
"=",
"\"mspassport\"",
";",
"var",
"default_options",
"=",
"{",
"protocol",
":",
"\"querystring\"",
",",
"protocolHandler",
":",
... | Creates an instance of `MSPassportStrategy`.
@constructor
@api public | [
"Creates",
"an",
"instance",
"of",
"MSPassportStrategy",
"."
] | 0a89357e58d77db219beef0cd994ad8d6f8e53b2 | https://github.com/mattdot/passport-mspassport/blob/0a89357e58d77db219beef0cd994ad8d6f8e53b2/lib/strategy.js#L104-L114 | train |
rodmcnew/tabular-sarsa-js | example/index.js | runGame | function runGame() {
var totalReward = 0;
var environment = new exampleWorld.Environment();
var lastReward = null;
function tick() {
//Tell the agent about the current environment state and have it choose an action to take
var action = sarsaAgent.decide(lastReward, environment.getCurren... | javascript | function runGame() {
var totalReward = 0;
var environment = new exampleWorld.Environment();
var lastReward = null;
function tick() {
//Tell the agent about the current environment state and have it choose an action to take
var action = sarsaAgent.decide(lastReward, environment.getCurren... | [
"function",
"runGame",
"(",
")",
"{",
"var",
"totalReward",
"=",
"0",
";",
"var",
"environment",
"=",
"new",
"exampleWorld",
".",
"Environment",
"(",
")",
";",
"var",
"lastReward",
"=",
"null",
";",
"function",
"tick",
"(",
")",
"{",
"//Tell the agent abou... | Run a game where we see how high of a total reward we can get in 100 actions
@returns {number} Total reward for this game | [
"Run",
"a",
"game",
"where",
"we",
"see",
"how",
"high",
"of",
"a",
"total",
"reward",
"we",
"can",
"get",
"in",
"100",
"actions"
] | 5058e788a6c87742ccd2ad9d579378233d999156 | https://github.com/rodmcnew/tabular-sarsa-js/blob/5058e788a6c87742ccd2ad9d579378233d999156/example/index.js#L14-L35 | train |
rtm/upward | src/Out.js | objectToString | function objectToString(o) {
return '{' + keys(o).map(k => `${k}: ${o[k]}`).join(', ') + '}';
} | javascript | function objectToString(o) {
return '{' + keys(o).map(k => `${k}: ${o[k]}`).join(', ') + '}';
} | [
"function",
"objectToString",
"(",
"o",
")",
"{",
"return",
"'{'",
"+",
"keys",
"(",
"o",
")",
".",
"map",
"(",
"k",
"=>",
"`",
"${",
"k",
"}",
"${",
"o",
"[",
"k",
"]",
"}",
"`",
")",
".",
"join",
"(",
"', '",
")",
"+",
"'}'",
";",
"}"
] | User-friendly representation of an object. | [
"User",
"-",
"friendly",
"representation",
"of",
"an",
"object",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L15-L17 | train |
rtm/upward | src/Out.js | mapObjectInPlace | function mapObjectInPlace(o, fn, ctxt) {
for (let key in o) {
if (o.hasOwnProperty(key)) {
o[key] = fn.call(ctxt, o[key], key, o);
}
}
return o;
} | javascript | function mapObjectInPlace(o, fn, ctxt) {
for (let key in o) {
if (o.hasOwnProperty(key)) {
o[key] = fn.call(ctxt, o[key], key, o);
}
}
return o;
} | [
"function",
"mapObjectInPlace",
"(",
"o",
",",
"fn",
",",
"ctxt",
")",
"{",
"for",
"(",
"let",
"key",
"in",
"o",
")",
"{",
"if",
"(",
"o",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"o",
"[",
"key",
"]",
"=",
"fn",
".",
"call",
"(",
"c... | Map an object's values, replacing existing ones. | [
"Map",
"an",
"object",
"s",
"values",
"replacing",
"existing",
"ones",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L37-L44 | train |
rtm/upward | src/Out.js | copyOf | function copyOf(o) {
if (Array.isArray(o)) return o.slice();
if (isObject(o)) return assign({}, o);
return o;
} | javascript | function copyOf(o) {
if (Array.isArray(o)) return o.slice();
if (isObject(o)) return assign({}, o);
return o;
} | [
"function",
"copyOf",
"(",
"o",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"o",
")",
")",
"return",
"o",
".",
"slice",
"(",
")",
";",
"if",
"(",
"isObject",
"(",
"o",
")",
")",
"return",
"assign",
"(",
"{",
"}",
",",
"o",
")",
";",
... | Make a copy of something. | [
"Make",
"a",
"copy",
"of",
"something",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L47-L51 | train |
rtm/upward | src/Out.js | copyOntoArray | function copyOntoArray(a1, a2) {
for (let i = 0; i < a2.length; i++) {
a1[i] = a2[i];
}
a1.length = a2.length;
return a1;
} | javascript | function copyOntoArray(a1, a2) {
for (let i = 0; i < a2.length; i++) {
a1[i] = a2[i];
}
a1.length = a2.length;
return a1;
} | [
"function",
"copyOntoArray",
"(",
"a1",
",",
"a2",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"a2",
".",
"length",
";",
"i",
"++",
")",
"{",
"a1",
"[",
"i",
"]",
"=",
"a2",
"[",
"i",
"]",
";",
"}",
"a1",
".",
"length",
"="... | Copy a second array onto a first one destructively. | [
"Copy",
"a",
"second",
"array",
"onto",
"a",
"first",
"one",
"destructively",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L54-L60 | train |
rtm/upward | src/Out.js | copyOntoObject | function copyOntoObject(o1, o2) {
assign(o1, o2);
keys(o1)
.filter(key => !(key in o2))
.forEach(key => (delete o1[key]));
return o1;
} | javascript | function copyOntoObject(o1, o2) {
assign(o1, o2);
keys(o1)
.filter(key => !(key in o2))
.forEach(key => (delete o1[key]));
return o1;
} | [
"function",
"copyOntoObject",
"(",
"o1",
",",
"o2",
")",
"{",
"assign",
"(",
"o1",
",",
"o2",
")",
";",
"keys",
"(",
"o1",
")",
".",
"filter",
"(",
"key",
"=>",
"!",
"(",
"key",
"in",
"o2",
")",
")",
".",
"forEach",
"(",
"key",
"=>",
"(",
"de... | Overwrite a first object entirely with a second one. | [
"Overwrite",
"a",
"first",
"object",
"entirely",
"with",
"a",
"second",
"one",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L63-L69 | train |
rtm/upward | src/Out.js | copyOnto | function copyOnto(a1, a2) {
if (Array.isArray(a1) && Array.isArray(a2)) return copyOntoArray (a1, a2);
if (isObject (a1) && isObject (a2)) return copyOntoObject(a1, a2);
return (a1 = a2);
} | javascript | function copyOnto(a1, a2) {
if (Array.isArray(a1) && Array.isArray(a2)) return copyOntoArray (a1, a2);
if (isObject (a1) && isObject (a2)) return copyOntoObject(a1, a2);
return (a1 = a2);
} | [
"function",
"copyOnto",
"(",
"a1",
",",
"a2",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"a1",
")",
"&&",
"Array",
".",
"isArray",
"(",
"a2",
")",
")",
"return",
"copyOntoArray",
"(",
"a1",
",",
"a2",
")",
";",
"if",
"(",
"isObject",
"(",... | Copy a second object or array destructively onto a first one. | [
"Copy",
"a",
"second",
"object",
"or",
"array",
"destructively",
"onto",
"a",
"first",
"one",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L72-L76 | train |
rtm/upward | src/Out.js | invertObject | function invertObject(o) {
var result = {};
for (let pair of objectPairs(o)) {
let [key, val] = pair;
result[val] = key;
}
return result;
} | javascript | function invertObject(o) {
var result = {};
for (let pair of objectPairs(o)) {
let [key, val] = pair;
result[val] = key;
}
return result;
} | [
"function",
"invertObject",
"(",
"o",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"pair",
"of",
"objectPairs",
"(",
"o",
")",
")",
"{",
"let",
"[",
"key",
",",
"val",
"]",
"=",
"pair",
";",
"result",
"[",
"val",
"]",
"=",
... | "Invert" an object, swapping keys and values. | [
"Invert",
"an",
"object",
"swapping",
"keys",
"and",
"values",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L79-L86 | train |
rtm/upward | src/Out.js | objectFromLists | function objectFromLists(keys, vals) {
var result = {};
for (let i = 0, len = keys.length; i < len; i++) {
result[keys[i]] = vals[i];
}
return result;
} | javascript | function objectFromLists(keys, vals) {
var result = {};
for (let i = 0, len = keys.length; i < len; i++) {
result[keys[i]] = vals[i];
}
return result;
} | [
"function",
"objectFromLists",
"(",
"keys",
",",
"vals",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"len",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"result",
"[",
"... | Create an object from two arrays of keys and values. | [
"Create",
"an",
"object",
"from",
"two",
"arrays",
"of",
"keys",
"and",
"values",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Out.js#L98-L104 | train |
twolfson/doubleshot | lib/renderBatch.js | addHooks | function addHooks(fn, value) {
// Upcast val to an array
var values = value;
if (!Array.isArray(values)) {
values = [value];
}
// Call each of the functions with hook
values.forEach(fn);
} | javascript | function addHooks(fn, value) {
// Upcast val to an array
var values = value;
if (!Array.isArray(values)) {
values = [value];
}
// Call each of the functions with hook
values.forEach(fn);
} | [
"function",
"addHooks",
"(",
"fn",
",",
"value",
")",
"{",
"// Upcast val to an array",
"var",
"values",
"=",
"value",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"values",
")",
")",
"{",
"values",
"=",
"[",
"value",
"]",
";",
"}",
"// Call each... | Helper function to add hooks | [
"Helper",
"function",
"to",
"add",
"hooks"
] | 3523177d7bcaeeb8c5198d154da0b5fdaba8d7fe | https://github.com/twolfson/doubleshot/blob/3523177d7bcaeeb8c5198d154da0b5fdaba8d7fe/lib/renderBatch.js#L5-L14 | train |
baijijs/baiji | lib/utils/addHookByType.js | addHookByType | function addHookByType(ctx, type, methodNames, fn) {
let i = methodNames.length;
// If no hook specified, add wildcard
if (i === 0) {
methodNames = ['*'];
i = 1;
}
let hookType = `${type}Hooks`;
if (!ctx[hookType]) ctx[hookType] = {};
while (i--) {
let methodName = methodNames[i];
// f... | javascript | function addHookByType(ctx, type, methodNames, fn) {
let i = methodNames.length;
// If no hook specified, add wildcard
if (i === 0) {
methodNames = ['*'];
i = 1;
}
let hookType = `${type}Hooks`;
if (!ctx[hookType]) ctx[hookType] = {};
while (i--) {
let methodName = methodNames[i];
// f... | [
"function",
"addHookByType",
"(",
"ctx",
",",
"type",
",",
"methodNames",
",",
"fn",
")",
"{",
"let",
"i",
"=",
"methodNames",
".",
"length",
";",
"// If no hook specified, add wildcard",
"if",
"(",
"i",
"===",
"0",
")",
"{",
"methodNames",
"=",
"[",
"'*'"... | Add hook by method names, nested method names will be flattened | [
"Add",
"hook",
"by",
"method",
"names",
"nested",
"method",
"names",
"will",
"be",
"flattened"
] | 9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601 | https://github.com/baijijs/baiji/blob/9e5938d5ce4991d0f9d12dbb4f50b3f30adbe601/lib/utils/addHookByType.js#L6-L32 | train |
assemble/assemble-streams | index.js | viewStream | function viewStream(view) {
return function() {
var stream = utils.through.obj();
stream.setMaxListeners(0);
setImmediate(function(item) {
stream.write(item);
stream.end();
}, this);
return outStream(stream, view);
};
} | javascript | function viewStream(view) {
return function() {
var stream = utils.through.obj();
stream.setMaxListeners(0);
setImmediate(function(item) {
stream.write(item);
stream.end();
}, this);
return outStream(stream, view);
};
} | [
"function",
"viewStream",
"(",
"view",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"stream",
"=",
"utils",
".",
"through",
".",
"obj",
"(",
")",
";",
"stream",
".",
"setMaxListeners",
"(",
"0",
")",
";",
"setImmediate",
"(",
"function",
"(",
... | Push the current view into a vinyl stream.
```js
app.pages.getView('a.html').toStream()
.on('data', function(file) {
console.log(file);
//=> <Page "a.html" <Buffer 2e 2e 2e>>
});
```
@name view.toStream
@return {Stream}
@api public | [
"Push",
"the",
"current",
"view",
"into",
"a",
"vinyl",
"stream",
"."
] | 674e81cd523d50dce96455bea18f1b271bb4870a | https://github.com/assemble/assemble-streams/blob/674e81cd523d50dce96455bea18f1b271bb4870a/index.js#L145-L155 | train |
eblanshey/safenet | src/utils.js | parseJson | function parseJson(text) {
try {
var o = JSON.parse(text);
if (o && typeof o === "object" && o !== null)
return o;
}
catch (e) {}
return text;
} | javascript | function parseJson(text) {
try {
var o = JSON.parse(text);
if (o && typeof o === "object" && o !== null)
return o;
}
catch (e) {}
return text;
} | [
"function",
"parseJson",
"(",
"text",
")",
"{",
"try",
"{",
"var",
"o",
"=",
"JSON",
".",
"parse",
"(",
"text",
")",
";",
"if",
"(",
"o",
"&&",
"typeof",
"o",
"===",
"\"object\"",
"&&",
"o",
"!==",
"null",
")",
"return",
"o",
";",
"}",
"catch",
... | Return parsed JSON if needed, otherwise returns text as is.
@source http://stackoverflow.com/a/20392392/371699
@param text | [
"Return",
"parsed",
"JSON",
"if",
"needed",
"otherwise",
"returns",
"text",
"as",
"is",
"."
] | 8438251bf0999b43f39c231df299b05d01dd4618 | https://github.com/eblanshey/safenet/blob/8438251bf0999b43f39c231df299b05d01dd4618/src/utils.js#L38-L47 | train |
gardenhq/o | examples/b/bundled.js | substiteVariable | function substiteVariable(variable, options, cb) {
var value;
var err = null;
var s = variable.split(':', 2);
if (s.length == 2) {
value = options.env[s[0]];
if (typeof value == 'function') {
value = value();
}
if (s[1][0] == '+') {
// Substitute r... | javascript | function substiteVariable(variable, options, cb) {
var value;
var err = null;
var s = variable.split(':', 2);
if (s.length == 2) {
value = options.env[s[0]];
if (typeof value == 'function') {
value = value();
}
if (s[1][0] == '+') {
// Substitute r... | [
"function",
"substiteVariable",
"(",
"variable",
",",
"options",
",",
"cb",
")",
"{",
"var",
"value",
";",
"var",
"err",
"=",
"null",
";",
"var",
"s",
"=",
"variable",
".",
"split",
"(",
"':'",
",",
"2",
")",
";",
"if",
"(",
"s",
".",
"length",
"... | Shell variable substitution code taken from 'somewhere'?
Not sure who :(
This will be cleaned up at some point anyway | [
"Shell",
"variable",
"substitution",
"code",
"taken",
"from",
"somewhere",
"?"
] | cbca7760987d628de0b0d0647c95936f24577b00 | https://github.com/gardenhq/o/blob/cbca7760987d628de0b0d0647c95936f24577b00/examples/b/bundled.js#L1054-L1097 | train |
mjtb/unidata | unidata.js | UnidataHeaders | function UnidataHeaders(d,m,e) {
if(!d) {
d = new Date();
}
if(!m) {
m = d;
}
if(!e) {
const year = 1000 * 60 * 60 * 24 * 365;
e = new Date(m.valueOf() + year);
} else if(typeof(e) === 'number') {
e = new Date(m.valueOf() + e);
}
/**
* Date the database was downloaded.
*
* @type {Date}
*/
this.da... | javascript | function UnidataHeaders(d,m,e) {
if(!d) {
d = new Date();
}
if(!m) {
m = d;
}
if(!e) {
const year = 1000 * 60 * 60 * 24 * 365;
e = new Date(m.valueOf() + year);
} else if(typeof(e) === 'number') {
e = new Date(m.valueOf() + e);
}
/**
* Date the database was downloaded.
*
* @type {Date}
*/
this.da... | [
"function",
"UnidataHeaders",
"(",
"d",
",",
"m",
",",
"e",
")",
"{",
"if",
"(",
"!",
"d",
")",
"{",
"d",
"=",
"new",
"Date",
"(",
")",
";",
"}",
"if",
"(",
"!",
"m",
")",
"{",
"m",
"=",
"d",
";",
"}",
"if",
"(",
"!",
"e",
")",
"{",
"... | Provides date information about the Unicode character database.
<p>If the date of last modification is not provided, the download date is used.
<p>Database expiration can be specified as a date or as a time period (in milliseconds) that
is added to the last modification date. If not provided, an expiration period of ... | [
"Provides",
"date",
"information",
"about",
"the",
"Unicode",
"character",
"database",
"."
] | 0d4de343c51dbf882161aea7ee50ffd93aa3a9c3 | https://github.com/mjtb/unidata/blob/0d4de343c51dbf882161aea7ee50ffd93aa3a9c3/unidata.js#L1071-L1102 | train |
mjtb/unidata | unidata.js | Fraction | function Fraction(n, d) {
if(typeof(d) === "number") {
this.denominator = d;
} else {
this.denominator = 1;
}
if(typeof(n) === "number") {
this.numerator = n;
} else if(typeof(n) === "string") {
let slash = n.indexOf('/');
if(slash > 0) {
/**
* The numerator of the fraction.
*
* @type {num... | javascript | function Fraction(n, d) {
if(typeof(d) === "number") {
this.denominator = d;
} else {
this.denominator = 1;
}
if(typeof(n) === "number") {
this.numerator = n;
} else if(typeof(n) === "string") {
let slash = n.indexOf('/');
if(slash > 0) {
/**
* The numerator of the fraction.
*
* @type {num... | [
"function",
"Fraction",
"(",
"n",
",",
"d",
")",
"{",
"if",
"(",
"typeof",
"(",
"d",
")",
"===",
"\"number\"",
")",
"{",
"this",
".",
"denominator",
"=",
"d",
";",
"}",
"else",
"{",
"this",
".",
"denominator",
"=",
"1",
";",
"}",
"if",
"(",
"ty... | Represents a fraction i.e., a numerator and a denominator.
@class
@constructor
@param n {number|string} numerator or string representation of the fraction
@param d {number} (optional) denominator of the fraction | [
"Represents",
"a",
"fraction",
"i",
".",
"e",
".",
"a",
"numerator",
"and",
"a",
"denominator",
"."
] | 0d4de343c51dbf882161aea7ee50ffd93aa3a9c3 | https://github.com/mjtb/unidata/blob/0d4de343c51dbf882161aea7ee50ffd93aa3a9c3/unidata.js#L1528-L1567 | train |
nknapp/tree-from-paths | src/index.js | render | function render (files, baseDir, renderLabelFn, options = {}) {
baseDir = baseDir.replace(/\/$/, '/')
const strippedFiles = files.map(file => {
/* istanbul ignore else: Else-case should never happen */
if (file.lastIndexOf(baseDir, 0) === 0) {
return file.substr(baseDir.length)
}
/* istanbul i... | javascript | function render (files, baseDir, renderLabelFn, options = {}) {
baseDir = baseDir.replace(/\/$/, '/')
const strippedFiles = files.map(file => {
/* istanbul ignore else: Else-case should never happen */
if (file.lastIndexOf(baseDir, 0) === 0) {
return file.substr(baseDir.length)
}
/* istanbul i... | [
"function",
"render",
"(",
"files",
",",
"baseDir",
",",
"renderLabelFn",
",",
"options",
"=",
"{",
"}",
")",
"{",
"baseDir",
"=",
"baseDir",
".",
"replace",
"(",
"/",
"\\/$",
"/",
",",
"'/'",
")",
"const",
"strippedFiles",
"=",
"files",
".",
"map",
... | Renders a list of files like
```
['abc/cde/efg/', 'abc/cde/abc', 'abc/zyx']
```
as ascii-art tree (using [archy](https://www.npmjs.com/package/archy))
@param {string[]} files an array of sorted file paths relative to `parent`
@param {string} baseDir the root path of the tree.
@param {function({parent:string, file:st... | [
"Renders",
"a",
"list",
"of",
"files",
"like"
] | 0eabbbd96f33e7367c3f5292cb1a0a38b1975dfc | https://github.com/nknapp/tree-from-paths/blob/0eabbbd96f33e7367c3f5292cb1a0a38b1975dfc/src/index.js#L31-L44 | train |
nknapp/tree-from-paths | src/index.js | childNodesFromPaths | function childNodesFromPaths (files, parent, renderLabelFn, originalFiles, baseDir) {
// Group by first path element
var groups = _.groupBy(files, file => file.match(/^[^/]*\/?/))
return Object.keys(groups).map(function (groupKey) {
const group = groups[groupKey]
// Is this group explicitly part of the re... | javascript | function childNodesFromPaths (files, parent, renderLabelFn, originalFiles, baseDir) {
// Group by first path element
var groups = _.groupBy(files, file => file.match(/^[^/]*\/?/))
return Object.keys(groups).map(function (groupKey) {
const group = groups[groupKey]
// Is this group explicitly part of the re... | [
"function",
"childNodesFromPaths",
"(",
"files",
",",
"parent",
",",
"renderLabelFn",
",",
"originalFiles",
",",
"baseDir",
")",
"{",
"// Group by first path element",
"var",
"groups",
"=",
"_",
".",
"groupBy",
"(",
"files",
",",
"file",
"=>",
"file",
".",
"ma... | Compute the child nodes of a node, given a list of paths
@param files
@param parent
@param renderLabelFn
@returns {Array} | [
"Compute",
"the",
"child",
"nodes",
"of",
"a",
"node",
"given",
"a",
"list",
"of",
"paths"
] | 0eabbbd96f33e7367c3f5292cb1a0a38b1975dfc | https://github.com/nknapp/tree-from-paths/blob/0eabbbd96f33e7367c3f5292cb1a0a38b1975dfc/src/index.js#L85-L114 | train |
joneit/filter-tree | build/demo.js | msgBox | function msgBox(messageHTML) {
var msgEl = document.querySelector('.msg-box'),
rect = this.getBoundingClientRect();
msgEl.style.top = window.scrollY + rect.bottom + 8 + 'px';
msgEl.style.left = window.scrollX + rect.left + 8 + 'px';
msgEl.style.display = 'block';
m... | javascript | function msgBox(messageHTML) {
var msgEl = document.querySelector('.msg-box'),
rect = this.getBoundingClientRect();
msgEl.style.top = window.scrollY + rect.bottom + 8 + 'px';
msgEl.style.left = window.scrollX + rect.left + 8 + 'px';
msgEl.style.display = 'block';
m... | [
"function",
"msgBox",
"(",
"messageHTML",
")",
"{",
"var",
"msgEl",
"=",
"document",
".",
"querySelector",
"(",
"'.msg-box'",
")",
",",
"rect",
"=",
"this",
".",
"getBoundingClientRect",
"(",
")",
";",
"msgEl",
".",
"style",
".",
"top",
"=",
"window",
".... | Display an error message box.
@this {Element} The offending input field.
@param {string} messageHTML | [
"Display",
"an",
"error",
"message",
"box",
"."
] | c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e | https://github.com/joneit/filter-tree/blob/c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e/build/demo.js#L131-L144 | train |
joneit/filter-tree | build/demo.js | captureExpressions | function captureExpressions(expressionChain, booleans) {
var expressions, re;
if (booleans) {
re = new RegExp(PREFIX + booleans.join(INFIX) + POSTFIX, 'i');
expressions = expressionChain.match(re);
expressions.shift(); // discard [0] (input)
} else {
... | javascript | function captureExpressions(expressionChain, booleans) {
var expressions, re;
if (booleans) {
re = new RegExp(PREFIX + booleans.join(INFIX) + POSTFIX, 'i');
expressions = expressionChain.match(re);
expressions.shift(); // discard [0] (input)
} else {
... | [
"function",
"captureExpressions",
"(",
"expressionChain",
",",
"booleans",
")",
"{",
"var",
"expressions",
",",
"re",
";",
"if",
"(",
"booleans",
")",
"{",
"re",
"=",
"new",
"RegExp",
"(",
"PREFIX",
"+",
"booleans",
".",
"join",
"(",
"INFIX",
")",
"+",
... | Break an expression chain into a list of expressions.
@param {string} expressionChain
@returns {string[]} | [
"Break",
"an",
"expression",
"chain",
"into",
"a",
"list",
"of",
"expressions",
"."
] | c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e | https://github.com/joneit/filter-tree/blob/c070a4045fced3e4ab20ed2e0c706c9a5fd07d1e/build/demo.js#L253-L265 | train |
rtm/upward | src/Fun.js | observeArgs | function observeArgs(args, run) {
function observeArg(arg, i, args) {
var observer = Observer(
arg,
function argObserver(changes) {
changes.forEach(({type, newValue}) => {
if (type === 'upward') {
args[i] = newValue;
observer.reobserve(newValue);
}
... | javascript | function observeArgs(args, run) {
function observeArg(arg, i, args) {
var observer = Observer(
arg,
function argObserver(changes) {
changes.forEach(({type, newValue}) => {
if (type === 'upward') {
args[i] = newValue;
observer.reobserve(newValue);
}
... | [
"function",
"observeArgs",
"(",
"args",
",",
"run",
")",
"{",
"function",
"observeArg",
"(",
"arg",
",",
"i",
",",
"args",
")",
"{",
"var",
"observer",
"=",
"Observer",
"(",
"arg",
",",
"function",
"argObserver",
"(",
"changes",
")",
"{",
"changes",
".... | Observe changes to arguments. This will handle 'compute' changes, and trigger recomputation of function. When args changes, the new value is reobserved. | [
"Observe",
"changes",
"to",
"arguments",
".",
"This",
"will",
"handle",
"compute",
"changes",
"and",
"trigger",
"recomputation",
"of",
"function",
".",
"When",
"args",
"changes",
"the",
"new",
"value",
"is",
"reobserved",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Fun.js#L99-L121 | train |
lrlna/olivaw | index.js | _setState | function _setState (lattice, size) {
for (var num = 0; num < size; num++) {
var cell = {}
cell.state = getRandomState()
lattice.push(cell)
}
return lattice
} | javascript | function _setState (lattice, size) {
for (var num = 0; num < size; num++) {
var cell = {}
cell.state = getRandomState()
lattice.push(cell)
}
return lattice
} | [
"function",
"_setState",
"(",
"lattice",
",",
"size",
")",
"{",
"for",
"(",
"var",
"num",
"=",
"0",
";",
"num",
"<",
"size",
";",
"num",
"++",
")",
"{",
"var",
"cell",
"=",
"{",
"}",
"cell",
".",
"state",
"=",
"getRandomState",
"(",
")",
"lattice... | get a random state and create all cells | [
"get",
"a",
"random",
"state",
"and",
"create",
"all",
"cells"
] | 2e195a4a79f8cf15389942973bd00f09461e7da6 | https://github.com/lrlna/olivaw/blob/2e195a4a79f8cf15389942973bd00f09461e7da6/index.js#L41-L49 | train |
lrlna/olivaw | index.js | _getRule | function _getRule (neighbourhood) {
var currentState = null
var currentRule = [...rule]
neighbourhoods.forEach(function (hood, index) {
if (hood === neighbourhood) {
currentState = currentRule[index]
}
})
return currentState
} | javascript | function _getRule (neighbourhood) {
var currentState = null
var currentRule = [...rule]
neighbourhoods.forEach(function (hood, index) {
if (hood === neighbourhood) {
currentState = currentRule[index]
}
})
return currentState
} | [
"function",
"_getRule",
"(",
"neighbourhood",
")",
"{",
"var",
"currentState",
"=",
"null",
"var",
"currentRule",
"=",
"[",
"...",
"rule",
"]",
"neighbourhoods",
".",
"forEach",
"(",
"function",
"(",
"hood",
",",
"index",
")",
"{",
"if",
"(",
"hood",
"==... | let's see which rule we are currently looking at | [
"let",
"s",
"see",
"which",
"rule",
"we",
"are",
"currently",
"looking",
"at"
] | 2e195a4a79f8cf15389942973bd00f09461e7da6 | https://github.com/lrlna/olivaw/blob/2e195a4a79f8cf15389942973bd00f09461e7da6/index.js#L107-L117 | train |
nicktindall/cyclon.p2p-rtc-client | lib/PeerConnection.js | addLocalIceCandidate | function addLocalIceCandidate(event) {
if (event && event.candidate) {
// Add the ICE candidate only if we haven't already seen it
var serializedCandidate = JSON.stringify(event.candidate);
if (!storedIceCandidates.hasOwnProperty(serializedCandidate)) {
stored... | javascript | function addLocalIceCandidate(event) {
if (event && event.candidate) {
// Add the ICE candidate only if we haven't already seen it
var serializedCandidate = JSON.stringify(event.candidate);
if (!storedIceCandidates.hasOwnProperty(serializedCandidate)) {
stored... | [
"function",
"addLocalIceCandidate",
"(",
"event",
")",
"{",
"if",
"(",
"event",
"&&",
"event",
".",
"candidate",
")",
"{",
"// Add the ICE candidate only if we haven't already seen it",
"var",
"serializedCandidate",
"=",
"JSON",
".",
"stringify",
"(",
"event",
".",
... | An ICE candidate was received
@param event | [
"An",
"ICE",
"candidate",
"was",
"received"
] | eb586ce288a6ad7e1b221280825037e855b03904 | https://github.com/nicktindall/cyclon.p2p-rtc-client/blob/eb586ce288a6ad7e1b221280825037e855b03904/lib/PeerConnection.js#L248-L264 | train |
reelyactive/chickadee | web/js/bubble.js | function() {
var self = this;
if (typeof CompilerInitialized !== "undefined") return true;
oldPrepend = $.fn.prepend;
$.fn.prepend = function()
{
var isFragment =
arguments[0][0] && arguments[0][0].parentNode
&& arguments[0][0].parentNode.nodeName == "#document-fragme... | javascript | function() {
var self = this;
if (typeof CompilerInitialized !== "undefined") return true;
oldPrepend = $.fn.prepend;
$.fn.prepend = function()
{
var isFragment =
arguments[0][0] && arguments[0][0].parentNode
&& arguments[0][0].parentNode.nodeName == "#document-fragme... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"CompilerInitialized",
"!==",
"\"undefined\"",
")",
"return",
"true",
";",
"oldPrepend",
"=",
"$",
".",
"fn",
".",
"prepend",
";",
"$",
".",
"fn",
".",
"prepend",
"=",
"... | need Angular to recompile new elements after DOM manipulation | [
"need",
"Angular",
"to",
"recompile",
"new",
"elements",
"after",
"DOM",
"manipulation"
] | 1f65c2d369694d93796aae63318fa76326275120 | https://github.com/reelyactive/chickadee/blob/1f65c2d369694d93796aae63318fa76326275120/web/js/bubble.js#L356-L396 | train | |
adplabs/PigeonKeeper | lib/vertex.js | Vertex | function Vertex(pkGloballyUniqueId, id, state, data)
{
var self = this;
var pkGuid = pkGloballyUniqueId;
var serviceStartMethod;
if(VALID_STATES.indexOf(state) > -1)
{
this.id = id;
this.state = state;
this.data = data;
}
else
{
throw new Error("Invalid S... | javascript | function Vertex(pkGloballyUniqueId, id, state, data)
{
var self = this;
var pkGuid = pkGloballyUniqueId;
var serviceStartMethod;
if(VALID_STATES.indexOf(state) > -1)
{
this.id = id;
this.state = state;
this.data = data;
}
else
{
throw new Error("Invalid S... | [
"function",
"Vertex",
"(",
"pkGloballyUniqueId",
",",
"id",
",",
"state",
",",
"data",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"pkGuid",
"=",
"pkGloballyUniqueId",
";",
"var",
"serviceStartMethod",
";",
"if",
"(",
"VALID_STATES",
".",
"indexOf",
... | Creates a vertex for use in a digraph
@constructor
@param {string} pkGloballyUniqueId - ID of the associated PigeonKeeper, usually passed-in from digraph
@param {string} id - The ID of this vertex
@param {VALID_STATES} state - The initial state of this vertex
@param {Object} data - Optional data object associated with... | [
"Creates",
"a",
"vertex",
"for",
"use",
"in",
"a",
"digraph"
] | c0a92d2032415617c2b6f6bd49d00a2c59bfaa41 | https://github.com/adplabs/PigeonKeeper/blob/c0a92d2032415617c2b6f6bd49d00a2c59bfaa41/lib/vertex.js#L18-L94 | train |
building5/sails-hook-bunyan | index.js | function () {
var config = sails.config[this.configKey];
// the ship drawing looks pretty silly in JSON
sails.config.log.noShip = true;
// as do color codes
sails.config.log.colors = false;
// setup some defaults
config.logger.name = config.logger.name || 'sails';
conf... | javascript | function () {
var config = sails.config[this.configKey];
// the ship drawing looks pretty silly in JSON
sails.config.log.noShip = true;
// as do color codes
sails.config.log.colors = false;
// setup some defaults
config.logger.name = config.logger.name || 'sails';
conf... | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"sails",
".",
"config",
"[",
"this",
".",
"configKey",
"]",
";",
"// the ship drawing looks pretty silly in JSON",
"sails",
".",
"config",
".",
"log",
".",
"noShip",
"=",
"true",
";",
"// as do color codes",
"sa... | Hook configuration function. | [
"Hook",
"configuration",
"function",
"."
] | 0c46395198a0ad1105a7bc1946f5015bf4c7a185 | https://github.com/building5/sails-hook-bunyan/blob/0c46395198a0ad1105a7bc1946f5015bf4c7a185/index.js#L97-L115 | train | |
building5/sails-hook-bunyan | index.js | function (done) {
var config = sails.config[this.configKey];
_this = this;
// If a rotationSignal is given, listen for it
if (config.rotationSignal) {
process.on(config.rotationSignal, function () {
_this.logger.reopenFileStreams();
});
}
// If logUncaugh... | javascript | function (done) {
var config = sails.config[this.configKey];
_this = this;
// If a rotationSignal is given, listen for it
if (config.rotationSignal) {
process.on(config.rotationSignal, function () {
_this.logger.reopenFileStreams();
});
}
// If logUncaugh... | [
"function",
"(",
"done",
")",
"{",
"var",
"config",
"=",
"sails",
".",
"config",
"[",
"this",
".",
"configKey",
"]",
";",
"_this",
"=",
"this",
";",
"// If a rotationSignal is given, listen for it",
"if",
"(",
"config",
".",
"rotationSignal",
")",
"{",
"proc... | Hook initialization function. | [
"Hook",
"initialization",
"function",
"."
] | 0c46395198a0ad1105a7bc1946f5015bf4c7a185 | https://github.com/building5/sails-hook-bunyan/blob/0c46395198a0ad1105a7bc1946f5015bf4c7a185/index.js#L120-L160 | train | |
dogada/wpml | lib/compiler.js | urlize | function urlize(worker, text) {
if (!linkify.test(text)) return escape(text)
var matches = linkify.match(text)
var lastIndex = 0;
var buf = []
for (var i = 0, match; (match = matches[i++]); ) {
buf.push(escape(text.slice(lastIndex, match.index)))
var link = {tag: true, name: 'a',
attrs... | javascript | function urlize(worker, text) {
if (!linkify.test(text)) return escape(text)
var matches = linkify.match(text)
var lastIndex = 0;
var buf = []
for (var i = 0, match; (match = matches[i++]); ) {
buf.push(escape(text.slice(lastIndex, match.index)))
var link = {tag: true, name: 'a',
attrs... | [
"function",
"urlize",
"(",
"worker",
",",
"text",
")",
"{",
"if",
"(",
"!",
"linkify",
".",
"test",
"(",
"text",
")",
")",
"return",
"escape",
"(",
"text",
")",
"var",
"matches",
"=",
"linkify",
".",
"match",
"(",
"text",
")",
"var",
"lastIndex",
"... | Escape and urlize text. | [
"Escape",
"and",
"urlize",
"text",
"."
] | 283e72a530151c4086afb4f78c0d97af6d213405 | https://github.com/dogada/wpml/blob/283e72a530151c4086afb4f78c0d97af6d213405/lib/compiler.js#L65-L88 | train |
dogada/wpml | lib/compiler.js | compile | function compile(ast, opts) {
opts = assign({}, config.defaultOpts, opts)
debug('compile', opts, ast)
var worker = makeWorker(opts)
for (var i = 0, text = ast.value, len = text.length; i < len; i++) {
compileLine(text[i], worker)
}
return worker.buf.join('')
} | javascript | function compile(ast, opts) {
opts = assign({}, config.defaultOpts, opts)
debug('compile', opts, ast)
var worker = makeWorker(opts)
for (var i = 0, text = ast.value, len = text.length; i < len; i++) {
compileLine(text[i], worker)
}
return worker.buf.join('')
} | [
"function",
"compile",
"(",
"ast",
",",
"opts",
")",
"{",
"opts",
"=",
"assign",
"(",
"{",
"}",
",",
"config",
".",
"defaultOpts",
",",
"opts",
")",
"debug",
"(",
"'compile'",
",",
"opts",
",",
"ast",
")",
"var",
"worker",
"=",
"makeWorker",
"(",
"... | Compile parsed MML-document into HTML.
@param {object} ast Parsed WPML document
@param {object} opts Same as opts in mml.doc
@return{ string} Generated html string. | [
"Compile",
"parsed",
"MML",
"-",
"document",
"into",
"HTML",
"."
] | 283e72a530151c4086afb4f78c0d97af6d213405 | https://github.com/dogada/wpml/blob/283e72a530151c4086afb4f78c0d97af6d213405/lib/compiler.js#L196-L204 | train |
brindille/brindille-component | lib/index.js | findComponents | function findComponents(nodes, callback) {
nodes = toArray(nodes);
nodes = [].slice.call(nodes);
var node;
for (var i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node && node.hasAttribute && node.hasAttribute('data-component')) {
callback(node);
} else if (node.childNodes && no... | javascript | function findComponents(nodes, callback) {
nodes = toArray(nodes);
nodes = [].slice.call(nodes);
var node;
for (var i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node && node.hasAttribute && node.hasAttribute('data-component')) {
callback(node);
} else if (node.childNodes && no... | [
"function",
"findComponents",
"(",
"nodes",
",",
"callback",
")",
"{",
"nodes",
"=",
"toArray",
"(",
"nodes",
")",
";",
"nodes",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"nodes",
")",
";",
"var",
"node",
";",
"for",
"(",
"var",
"i",
"=",
"0... | Recursively Applies a callback on each Node that is found to be a Component
@param {Array} nodes an array of Node
@param {*} callback function to call on each Node that has data-component | [
"Recursively",
"Applies",
"a",
"callback",
"on",
"each",
"Node",
"that",
"is",
"found",
"to",
"be",
"a",
"Component"
] | a53b4a568ff93c76d7f73d8b401c0d57cc9d1685 | https://github.com/brindille/brindille-component/blob/a53b4a568ff93c76d7f73d8b401c0d57cc9d1685/lib/index.js#L250-L264 | train |
darul75/ng-audio | src/public/bower_components/ngprogress/src/provider.js | function () {
count = 100;
this.updateCount(count);
var self = this;
$timeout(function () {
self.hide();
$timeout(function () {
count = 0;
... | javascript | function () {
count = 100;
this.updateCount(count);
var self = this;
$timeout(function () {
self.hide();
$timeout(function () {
count = 0;
... | [
"function",
"(",
")",
"{",
"count",
"=",
"100",
";",
"this",
".",
"updateCount",
"(",
"count",
")",
";",
"var",
"self",
"=",
"this",
";",
"$timeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"hide",
"(",
")",
";",
"$timeout",
"(",
"function",
... | Jumps to 100% progress and fades away progressbar. | [
"Jumps",
"to",
"100%",
"progress",
"and",
"fades",
"away",
"progressbar",
"."
] | 602f9fe92134955dc16d725732f508a4ebc4fb75 | https://github.com/darul75/ng-audio/blob/602f9fe92134955dc16d725732f508a4ebc4fb75/src/public/bower_components/ngprogress/src/provider.js#L133-L145 | train | |
rtm/upward | src/Asy.js | promisify | function promisify(f) { // given an underlying function,
return function _promisify(...args) { // return a function which
return new Promise( // returns a promise
resolve => Promise.all([this, ...args]) // which, when all args are... | javascript | function promisify(f) { // given an underlying function,
return function _promisify(...args) { // return a function which
return new Promise( // returns a promise
resolve => Promise.all([this, ...args]) // which, when all args are... | [
"function",
"promisify",
"(",
"f",
")",
"{",
"// given an underlying function,",
"return",
"function",
"_promisify",
"(",
"...",
"args",
")",
"{",
"// return a function which",
"return",
"new",
"Promise",
"(",
"// returns a promise",
"resolve",
"=>",
"Promise",
".",
... | "Promisify" a function, meaning to create a function which returns a promise for the value of the function once `this` and all arguments have been fulfilled. | [
"Promisify",
"a",
"function",
"meaning",
"to",
"create",
"a",
"function",
"which",
"returns",
"a",
"promise",
"for",
"the",
"value",
"of",
"the",
"function",
"once",
"this",
"and",
"all",
"arguments",
"have",
"been",
"fulfilled",
"."
] | 82495c34f70c9a4336a3b34cc6781e5662324c03 | https://github.com/rtm/upward/blob/82495c34f70c9a4336a3b34cc6781e5662324c03/src/Asy.js#L82-L91 | 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.