UNPKG

c2array

Version:

Convert console output to an array

28 lines (27 loc) 701 B
"use strict"; function newline(str) { if (str.endsWith('\r\n')) return str.split('\r\n'); if (str.endsWith('\n')) return str.split('\n'); return [str]; } function removeEmpty(arr) { return arr.filter(arr => arr.length > 0); } function select(arr, chunk) { return arr.filter(str => str.split(chunk)[0] !== str); } function splitter(arr, chunk) { return arr.map(str => str.split(chunk)); } function removeEmptyString(arr) { return arr.map(arr => arr.filter(str => str)); } module.exports = { newline: newline, removeEmpty: removeEmpty, select: select, splitter: splitter, removeEmptyString: removeEmptyString };