Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
7
decreased by-30%
Maintainers
1
Weekly downloads
 
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc