parsist

1.0.6 • Public • Published

parsist

Raw text parser, cleaner and formatter

Install

npm i -s parsist

Docs

function parser(
  raw: string,
  delimiters: string | string[],
  toString: boolean,
  separator: string
): string | string[]
 
Parse and clean a string of raw items based on the given regex-character delimiters
 
@param raw — Raw text/paragraph to parse and clean
@param delimiters — Delimiters must be valid regex characters
@param toString — Whether to get the result as a string or not (return an array of strings)
@param separator — Used as the item separator when returning a string

Use

import { parser } from 'parsist'
 
let raw = `
  sample  ,
, raw  .  
text *  to 
  parse
`
 
let delimiter = '[\\.\\,\\n\\*\\t]'
 
// Example 1
console.log(
  parser(raw, delimiter, true, '\n')
)
 
// Example 2
console.log(
  parser(raw, delimiter, true, '')
)

Outputs

sample
raw
text
to
parse
sample, raw, text, to, parse

Check parsist/sample/index.js for specific use cases

Package Sidebar

Install

npm i parsist

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

5.45 kB

Total Files

4

Last publish

Collaborators

  • alpez