Files
DefinitelyTyped/types/klaw-sync/klaw-sync-tests.ts
Colin Luo 3363dfb20e Update klaw-sync module interface from v1.0 to v2.0.0 + (#25134)
*  commit 'Update `klaw-sync` module interface to v2.0.0 +

[v2.0.0 apis](https://github.com/manidlou/node-klaw-sync/tree/v2.0.0) [v3.0.2 apis](https://github.com/manidlou/node-klaw-sync/tree/v3.0.2)

* Update `klaw-sync` module interface from v1.0 to v2.0.0 +

* Update `klaw-sync` module interface from v1.0 to v2.0.0 +

* Change `klaw-sync` types version from `3.0` to `2.0` and remove ignore parameter.

* Update test case.

* Improve the test case of `options.filter`.

* Add definitions of `klaw-sync`

* Remove `Colin Luo` from `klaw-sync` Difinitions.
2018-04-24 16:05:35 -07:00

24 lines
571 B
TypeScript

import * as path from 'path'
import klawSync = require('klaw-sync')
const outputMessage = (result: klawSync.Item) => {
console.log(`file: ${result.path} has size '${result.stats.size}'`)
}
klawSync('/some/dir').forEach(outputMessage)
const defaultOptions = {}
klawSync('/some/dir', defaultOptions).forEach(outputMessage)
const options = {
nodir: true,
nofile: false,
noRecurseOnFailedFilter: false,
filter(item: klawSync.Item) {
return item.path.indexOf('node_modules') < 0
},
}
klawSync('/some/dir', options).forEach(outputMessage)