console_2darray_formater
v1.0.0
Published
This formats 2d arrays to be printed to the console nicely
Downloads
1
Readme
Install
npm i console_2darray_formater
Import
const format = require('console_2darray_formater')
Use
// first arg is the array to format
// second arg is if the formated array should have commas
//it returns a STRING!
console.log(format([
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 2, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 6, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 'a', 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]
], true));
// it is only tested and meant to be used as 2d array formater
/* Expected output:
[0,0,0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0,0,0,0,2,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0,0,0,6,0,0,0,0,0]
[0,0,0,0,0,a,0,0,0]
[0,0,0,0,0,0,0,0,0]
[0,0,0,0,0,0,0,0,0]
old: [
[
0, 0, 0, 0, 0,
0, 0, 0, 0
],
[
0, 0, 0, 0, 0,
0, 0, 0, 0
],
[
0, 0, 0, 0, 0,
0, 0, 0, 0
],
[
0, 0, 0, 0, 2,
0, 0, 0, 0
],
[
0, 0, 0, 0, 0,
0, 0, 0, 0
],
[
0, 0, 0, 6, 0,
0, 0, 0, 0
],
[
0, 0, 0, 0, 0,
'a', 0, 0, 0
],
[
0, 0, 0, 0, 0,
0, 0, 0, 0
],
[
0, 0, 0, 0, 0,
0, 0, 0, 0
]
]
*/