Replace tabs with spaces.
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Contribute
- Security
- License
This package can turn a string with tabs into a string with spaces.
You can use this package if you want to define how big the tab size is.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install detab
In Deno with esm.sh
:
import {detab} from 'https://esm.sh/detab@3'
In browsers with esm.sh
:
<script type="module">
import {detab} from 'https://esm.sh/detab@3?bundle'
</script>
import {detab} from 'detab'
console.log(detab('\tfoo\nbar\tbaz'))
console.log(detab('\tfoo\nbar\tbaz', 2))
console.log(detab('\tfoo\nbar\tbaz', 8))
Yields:
foo
bar baz
foo
bar baz
foo
bar baz
This package exports the identifier detab
.
There is no default export.
Replace tabs with spaces in value
(string
), being smart about which column
the tab is at and which size
(number
, default: 4
) should be used.
This package is fully typed with TypeScript. It exports no additional types.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
Yes please! See How to Contribute to Open Source.
This package is safe.
MIT © Titus Wormer