Skip to content

Commit 41e6879

Browse files
authored
refactor: export all types through index (#43)
Signed-off-by: Josh-Cena <[email protected]>
1 parent cd56d36 commit 41e6879

7 files changed

+35
-39
lines changed

src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
/*!
2+
* reading-time
3+
* Copyright (c) Nicolas Gryman <[email protected]>
4+
* MIT Licensed
5+
*/
6+
17
import readingTime, { countWords, readingTimeWithCount } from './reading-time'
28
import ReadingTimeStream from './stream'
39

10+
export * from './types'
11+
412
// This part is to make TS happy
513
export { ReadingTimeStream, countWords, readingTimeWithCount }
614
export default readingTime

src/reading-time.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* MIT Licensed
55
*/
66

7-
import type { Options, ReadingTimeStats, WordCountStats, ReadingTimeResult } from 'reading-time'
7+
import type { Options, ReadingTimeStats, WordCountStats, ReadingTimeResult } from './types'
88

99
type WordBoundFunction = Options['wordBound']
1010

src/stream.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { countWords } from './reading-time'
88
import { Transform, TransformCallback } from 'stream'
9-
import type { Options, WordCountStats } from 'reading-time'
9+
import type { Options, WordCountStats } from './types'
1010

1111
class ReadingTimeStream extends Transform {
1212
options: Options;

src/types.d.ts

-33
This file was deleted.

src/types.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*!
2+
* reading-time
3+
* Copyright (c) Nicolas Gryman <[email protected]>
4+
* MIT Licensed
5+
*/
6+
7+
export type Options = {
8+
wordBound?: (char: string) => boolean;
9+
wordsPerMinute?: number;
10+
}
11+
12+
export type ReadingTimeStats = {
13+
time: number;
14+
minutes: number;
15+
}
16+
17+
export type WordCountStats = {
18+
total: number;
19+
}
20+
21+
export type ReadingTimeResult = ReadingTimeStats & {
22+
words: WordCountStats;
23+
}

test/reading-time.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
* MIT Licensed
55
*/
66

7-
import readingTime from '../src'
7+
import readingTime, { Options, ReadingTimeResult } from '../src'
88
import chai from 'chai'
9-
import { Options, ReadingTimeResult } from 'reading-time'
109

1110
chai.should()
1211

test/stream.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
* MIT Licensed
55
*/
66

7-
import { ReadingTimeStream } from '../src'
7+
import { ReadingTimeStream, Options, WordCountStats } from '../src'
88
import chai from 'chai'
9-
import { Options, WordCountStats } from 'reading-time'
109

1110
chai.should()
1211

0 commit comments

Comments
 (0)