newline-decoder

Simple chunked decoder for newline delimited string

MIT 3 个版本
安装
npm install newline-decoder
yarn add newline-decoder
pnpm add newline-decoder
bun add newline-decoder
README

newline-decoder

Simple chunked decoder for newline delimited string that isn't a stream

npm install newline-decoder

Usage

const NewlineDecoder = require('newline-decoder')

const nl = new NewlineDecoder()

nl.push('test') // returns []
nl.push('of') // returns []
nl.push('this\n') // returns ['testofthis']

API

nl = new NewlineDecoder([enc])

Create a new instance. enc defaults to utf-8

lines = nl.push(data)

Push a new data chunk to the decoder. Can be a buffer or a string. Returns the lines decoded.

lines = nl.end()

End the decoder. Returns whatever is left in the buffer in an array for consistency.

License

MIT

版本列表
1.0.2 2023-09-20
1.0.1 2023-08-15
1.0.0 2020-04-28