ByteEncoder
Encode data to utf8 bytes. Browser or NodeJS.
Table of Contents
Install
npm i byte-encoder
Usage
static (class) ByteEncoder.Iterator
:
Args [string: string
]
import ByteView from 'byteview'
import ByteEncoder from 'byte-encoder'
const chunks = []
for (const chunk of new ByteEncoder.Iterator('Hello World!')) {
chunks.push(chunk)
}
console.log(ByteView.from(chunks))
(method) ByteEncoder.encode
:
Args [string: string
]
import ByteEncoder from 'byte-encoder'
const byteEncoder = new ByteEncoder()
console.log(byteEncoder.encode('Hello World!'))
(method) ByteEncoder.encodeInto
:
Args [string: string, byteView: ByteView | Buffer | ArrayBufferView
]
import ByteEncoder from 'byte-encoder'
const byteEncoder = new ByteEncoder()
const byteView = ByteView.alloc(12)
console.log(byteView)
console.log(byteEncoder.encodeInto('Hello World!', byteView))
console.log(byteView)