1.0.6 • Published 6 years ago

parsist v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago