Skip to content

Commit 6ebe50b

Browse files
committed
feat: Options#tabSize
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 4d76f9b commit 6ebe50b

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ Options for wrapping a string (`interface`).
202202
— the size of the string to use for padding the right side of each line (as a number or numeric), or the string to use
203203
- `stringify?` ([`ToString`](#tostringt) | `null` | `undefined`, optional)
204204
— convert a value to a string
205+
- `tabSize?` (`number` | `null` | `undefined`, optional)
206+
— the number of spaces a tab is equivalent to
207+
- default: `2`
205208
- `trim?` (`boolean` | `null` | `undefined`, optional)
206209
— whether to remove whitespace from the end of each line
207210
> 👉 **note**: lines are trimmed before applying indents or padding.

src/interfaces/__tests__/options.spec-d.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ describe('unit-d:interfaces/Options', () => {
5454
.toEqualTypeOf<Nilable<ToString>>()
5555
})
5656

57+
it('should match [tabSize?: number | null | undefined]', () => {
58+
expectTypeOf<TestSubject>()
59+
.toHaveProperty('tabSize')
60+
.toEqualTypeOf<Nilable<number>>()
61+
})
62+
5763
it('should match [trim?: boolean | null | undefined]', () => {
5864
expectTypeOf<TestSubject>()
5965
.toHaveProperty('trim')

src/interfaces/options.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ interface Options {
6060
*/
6161
stringify?: ToString | null | undefined
6262

63+
/**
64+
* The number of spaces a tab is equivalent to.
65+
*
66+
* @default 2
67+
*/
68+
tabSize?: number | null | undefined
69+
6370
/**
6471
* Whether to remove whitespace from the beginning and end of each line.
6572
*

src/internal/tokenize.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ function tokenize(
118118
[codes.vcr]: eol,
119119
[codes.vlf]: eol,
120120
null: [sequence, eoc]
121-
})
121+
}),
122+
tabSize: config.tabSize ?? +chars.digit2
122123
})
123124

124125
/**

0 commit comments

Comments
 (0)