1.0.0 • Published 3 years ago

console_2darray_formater v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago