Skip to content

Commit 70000c2

Browse files
committed
newFilename example in Typescript
1 parent 29f0dbe commit 70000c2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,19 @@ filename based on path and current time.
7878

7979
_Example:_
8080

81-
```js
82-
const strftime = require('ultra-strftime')
81+
```ts
82+
import strftime from 'ultra-strftime'
8383

8484
class MyFileTimestampStream extends FileTimestampStream {
85-
constructor (options) {
86-
super(options)
87-
/** count how many files has been created */
88-
this.counter = 0
89-
}
90-
function newFilename () {
85+
/** count how many files has been created */
86+
counter = 0
87+
88+
// for pure Javascript explicit constructor is necessary
89+
// constructor (options) { super(options); this.counter = 0 }
90+
91+
protected newFilename (): string {
9192
const filename = strftime(this.path)
92-
if (filename !== this.currentFilename) counter++
93+
if (filename !== this.currentFilename) this.counter++
9394
return filename
9495
}
9596
}

0 commit comments

Comments
 (0)