Skip to content
/ c2Array Public

c2Array convert output from a prompt console to array

License

Notifications You must be signed in to change notification settings

salsan/c2Array

Repository files navigation

c2Array

c2Array convert output from a prompt console to array

Install

npm install c2array

Usage

const c2Array  = require('c2array')
const fs = require('fs')

const data = fs.readFileSync(process.argv[2],
        { encoding: 'utf8', flag: 'r' })

console.log(c2Array(data, {
    newline : true, // split aray based from newline character - default is true
    removeEmpty : true, // remove empty array - default is true
    select: ':style=', // select only array which respect this word and delete if is not divisibile
    splitter: ': ', // split array in according with word choice
    removeEmptyString: true // remove empty string on array - default is false
}))

The return value is an Array

 node index.js fc-list.txt

[
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf',
    'DejaVu Serif:style=Bold'
  ],
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',
    'DejaVu Sans Mono:style=Book'
  ],
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',
    'DejaVu Sans:style=Book'
  ],
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf',
    'DejaVu Sans:style=Bold'
  ],
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf',
    'DejaVu Sans Mono:style=Bold'
  ],
  [
    '/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf',
    'DejaVu Serif:style=Book'
  ]
]

License

MIT License - Copyright 2021 Salvatore Santagati (mailto:me@salsan.dev)

About

c2Array convert output from a prompt console to array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published