JSPM

string-align

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 364
  • Score
    100M100P100Q84313F
  • License MIT

Align string with whitespace

Package Exports

  • string-align

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string-align) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

string-align Build Status Dependency Status DevDependency Status

npm

Align string with whitespace. Whitespace character defaults to ascii space.

Examples

> align('foo', 7, 'center')
'  foo  '

> align('foo', 7, 'left')
'foo    '

> align('foo', 7, 'right')
'    foo'

> align('-=', 7, 'fill')
'-=-=-=-'

> align('foo', 7, 'center', '_')
'__foo__'

> align(7, {
    width: 4,
    alignment: 'right',
    placeholder: 0
  })
'0007'

API

stringAlign(string, width, [alignment], [placeholder])

stringAlign(string, options)

If string or placeholder is not a string, it is converted to.

Option Type Required? Default
width number Yes
alignment "center", "left", "right", "fill" No "center"
placeholder string No " "

Install

npm install string-align

License

MIT