🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

fixed-string

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixed-string

FixedString is a class that allows you to manipulate fixed length strings. It is useful for creating fixed length records for files, printed receipts or other purposes.

1.0.3
latest
npm
Version published
Maintainers
1
Created
Source

FixedString

FixedString is a class that allows you to manipulate fixed length strings. It is useful for creating fixed length records for files, printed receipts or other purposes.

Installation

npm install fixed-string

Usage

const FixedString = require('../fixed-string').default;
const fixedLine = new FixedString(20);
fixedLine.rightAlign('abc');      // '                 abc'
fixedLine.leftAlign('def');       // 'def              abc'
fixedLine.centerAlign('xyz');     // 'def     xyz      abc'
// use a specific position
fixedLine.insert('012',9);        // 'def     012      abc'
//limit the length of the inserted string
// notice the behavior, the insertion is truncated to three characters
// but it chops off the left end (because it is right aligned)
fixedLine.rightAlign('WXYZ',9,3); // 'def     XYZ      abc'

Keywords

fixed

FAQs

Package last updated on 27 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts