Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.04 KB

pad.md

File metadata and controls

63 lines (41 loc) · 1.04 KB

pad

Expand tab characters to fixed column stops.

API

Numeric.string.pad(text, width = 8)

Replaces tab stops with spaces up to the width.

  • Parameters:
    • text: String or array of strings to expand
    • width: Column width of each tab stop
  • Returns: Expanded strings matching the input shape
  • NumPy: Covers np.strings.expandtabs, np.char.expandtabs through a single Numerix method.

Examples

Expand a tab stop

import Numeric from '@neabyte/numerix'

const value = Numeric.string.pad('a\tb', 8)

console.log(value)
// a       b

Expand with a narrower tab stop

import Numeric from '@neabyte/numerix'

const value = Numeric.string.pad('a\tb', 4)

console.log(value)
// a   b

Expand a string without tabs

import Numeric from '@neabyte/numerix'

const value = Numeric.string.pad('ab', 8)

console.log(value)
// ab

Expand an array of strings

import Numeric from '@neabyte/numerix'

const values = Numeric.string.pad(['a\tb', 'c\td'], 4)

console.log(values)
// ["a   b","c   d"]