Skip to content

RamiresOliv/ArrayPrinter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

ArrayPrinter

Print Array values using Node

I just did this out of boredom and wanted to save it for future use, perhaps. If you have a bug or problem, I don't even know if I'll fix it.
I was bored so.. Yeah. I maded a Node.js module to print arrays........ I.. Well. Good luck bye.

using:

const { printArray, doArray } = require("arrayPrinter");

const array = [
  "Hello World",
  1234567890,
  [
    "hello",
    "world",
    123,
    function aaa() {
      return "hello world";
    },
  ],

printArray(array) // <- this is the pure
// Ex: printArray(array, returnString, needsIndex, returnStringTranslated)

Pure usage

printArray(array);

//Return:
//[0]: "Hello World"
//[1]: 1234567890
//[2]: ["hello", "world", 123, function aaa() { return "hello world"; }]
//[3]: { hello: "world" number: 123 }
//[4]: () => { return "hello world"; }

String return usage

returnString

const return = printArray(array, true);
console.log(return)

//Return:
//[
//  '[0]: "Hello World"',
//  '[1]: 1234567890',
//  '[2]: ["hello", "world", 123, function aaa() {  return "hello world"; }]',
//  '[3]: { hello: "world" number: 123 }',
//  '[4]: () => { return "hello world"; }'
//]

Removing index in return

needsIndex

const return = printArray(array, [false/true], false); // (default is true)
console.log(return)

//return:
//"Hello World"
//1234567890
//["hello", "world", 123, function aaa() {  return "hello world"; }]
//{ hello: "world" number: 123 }
//() => { return "hello world"; }
//OR
//[
//  '"Hello World"',
//  '1234567890',
//  '["hello", "world", 123, function aaa() {  return "hello world"; }]',
//  '{ hello: "world" number: 123 }',
//  '() => { return "hello world"; }'
//]

Translate return

returnStringTranslated

const return = printArray(array, true, false, true); // (default is false) [Important note: the first value (returnString) must be true for return a array, and the second value (needsIndex) needs be false.]
console.log(return)

//return:
//[
//  'Hello World', // is not '"Hello world"' any more.
//  1234567890, // numbers is now numbers
//  [ 'hello', 'world', 123, [Function: aaa] ], // arrays is now arrays. & functions in arrays are functions.
//  { hello: '"world"', number: 123 }, // objects is istil in dev just.. dont put functions inside here.
//  [Function (anonymous)] // functions is now functions
//]

About

Print Array values using Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published