pad-buffer
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Pad Buffer

This package provides two function (bufferPadStart and bufferPadEnd). They can be used to add padding to a buffer. By default, the padding consists of null bytes, but you can choose a custom filling value.

Usage

Importing the functions

const { bufferPadStart, bufferPadEnd } = require('pad-buffer')

or

import { bufferPadStart, bufferPadEnd } from 'pad-buffer'

Using the functions

// <Buffer 01 02 03>
const buffer = Buffer.from([1, 2, 3])
 
// <Buffer 00 00 01 02 03>
const padStartResult = bufferPadStart(buffer, 5)
// <Buffer 01 02 03 00 00>
const padEndResult = bufferPadEnd(buffer, 5)
 
// <Buffer 09 09 01 02 03>
const customPaddingResult = bufferPadStart(buffer, 5, 9)

Readme

Keywords

Package Sidebar

Install

npm i pad-buffer

Weekly Downloads

4

Version

1.0.3

License

GPL-3.0-or-later

Unpacked Size

5.01 kB

Total Files

4

Last publish

Collaborators

  • cl00e9ment