How to use the tui-code-snippet.forEachArray function in tui-code-snippet

To help you get started, weโ€™ve selected a few tui-code-snippet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nhn / tui.grid / src / js / model / coordColumn.js View on Github external
indexOf: function(posX, withMeta) {
        var widths = this.getWidths();
        var totalColumnWidth = this.getFrameWidth();
        var adjustableIndex = (withMeta) ? 0 : this.columnModel.getVisibleMetaColumnCount();
        var columnIndex = 0;

        if (posX >= totalColumnWidth) {
            columnIndex = widths.length - 1;
        } else {
            snippet.forEachArray(widths, function(width, index) { // eslint-disable-line consistent-return
                width += CELL_BORDER_WIDTH;
                columnIndex = index;

                if (posX > width) {
                    posX -= width;
                } else {
                    return false;
                }
            });
        }

        return Math.max(0, columnIndex - adjustableIndex);
    },
github nhn / tui.editor / src / js / markdownCommands / heading.js View on Github external
const from = {
      line: range.from.line,
      ch: 0
    };

    const to = {
      line: range.to.line,
      ch: doc.getLineHandle(range.to.line).text.length
    };

    const lengthOfCurrentLineBefore = doc.getLine(to.line).length;
    const textToModify = doc.getRange(from, to);
    const textLinesToModify = textToModify.split('\n');

    util.forEachArray(textLinesToModify, (line, index) => {
      textLinesToModify[index] = getHeadingMarkdown(line, size);
    });

    doc.replaceRange(textLinesToModify.join('\n'), from, to);

    range.to.ch += doc.getLine(to.line).length - lengthOfCurrentLineBefore;

    doc.setSelection(from, range.to);

    cm.focus();
  }
});
github nhn / tui.chart / src / js / helpers / arrayUtil.js View on Github external
function max(arr, condition, context) {
    let result;

    if (!condition) {
        result = Math.max(...arr);
    } else {
        ([result] = arr);
        const rest = arr.slice(1);
        let maxValue = condition.call(context, result, 0);
        snippet.forEachArray(rest, (item, index) => {
            const compareValue = condition.call(context, item, index + 1);
            if (compareValue > maxValue) {
                maxValue = compareValue;
                result = item;
            }
        });
    }

    return result;
}
github nhn / tui.chart / src / js / models / bounds / legendCalculator.js View on Github external
_divideLegendLabels: function(labels, count) {
        var limitCount = Math.round(labels.length / count);
        var results = [];
        var temp = [];

        snippet.forEachArray(labels, function(label) {
            if (temp.length < limitCount) {
                temp.push(label);
            } else {
                results.push(temp);
                temp = [label];
            }
        });

        if (temp.length) {
            results.push(temp);
        }

        return results;
    },
github nhn / tui.chart / src / js / helpers / dataExporter.js View on Github external
snippet.forEachArray(chartData2DArray, function(row, rowIndex) {
        var lastCellIndex = row.length - 1;

        snippet.forEachArray(row, function(cell, cellIndex) {
            var cellContent = (snippet.isNumber(cell) ? cell : '"' + cell + '"');

            csvText += cellContent;

            if (cellIndex < lastCellIndex) {
                csvText += itemDelimiter;
            }
        });

        if (rowIndex < lastRowIndex) {
            csvText += lineDelimiter;
        }
    });
github nhn / tui.chart / src / js / helpers / dataExporter.js View on Github external
function _makeCsvBodyWithRawData(chartData2DArray, option) {
    var csvText = '';
    var lineDelimiter = (option && option.lineDelimiter) || '\u000a';
    var itemDelimiter = (option && option.itemDelimiter) || ',';
    var lastRowIndex = chartData2DArray.length - 1;

    snippet.forEachArray(chartData2DArray, function(row, rowIndex) {
        var lastCellIndex = row.length - 1;

        snippet.forEachArray(row, function(cell, cellIndex) {
            var cellContent = (snippet.isNumber(cell) ? cell : '"' + cell + '"');

            csvText += cellContent;

            if (cellIndex < lastCellIndex) {
                csvText += itemDelimiter;
            }
        });

        if (rowIndex < lastRowIndex) {
            csvText += lineDelimiter;
        }
    });
github nhn / tui.editor / src / js / wysiwygEditor.js View on Github external
let handlers, isNeedNext;

    handlers = this._keyEventHandlers.DEFAULT;

    if (handlers) {
      util.forEachArray(handlers, handler => {
        isNeedNext = handler(event, range, keyMap);

        return isNeedNext;
      });
    }

    handlers = this._keyEventHandlers[keyMap];

    if (handlers && isNeedNext !== false) {
      util.forEachArray(handlers, handler => handler(event, range, keyMap));
    }
  }
github nhn / tui.chart / src / js / models / bounds / boundsModel.js View on Github external
getDimensionMap: function(types) {
        var self = this;
        var dimensionMap = {};

        if (types && types.length) {
            snippet.forEachArray(types, function(type) {
                dimensionMap[type] = self.dimensionMap[type];
            });
        } else {
            dimensionMap = this.dimensionMap;
        }

        return JSON.parse(JSON.stringify((dimensionMap)));
    },
github nhn / tui.editor / src / js / wysiwygEditor.js View on Github external
_runKeyEventHandlers(event, keyMap) {
    const range = this.getRange();
    let handlers, isNeedNext;

    handlers = this._keyEventHandlers.DEFAULT;

    if (handlers) {
      util.forEachArray(handlers, handler => {
        isNeedNext = handler(event, range, keyMap);

        return isNeedNext;
      });
    }

    handlers = this._keyEventHandlers[keyMap];

    if (handlers && isNeedNext !== false) {
      util.forEachArray(handlers, handler => handler(event, range, keyMap));
    }
  }