console_2darray_formater

1.0.0 • Public • Published

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
  ]
]
*/

Readme

Keywords

Package Sidebar

Install

npm i console_2darray_formater

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.89 kB

Total Files

4

Last publish

Collaborators

  • 1euro7cent