Merge pull request #15005 from shiftkey/add-klaw-sync

add type definitions for `klaw-sync`
This commit is contained in:
Mine Starks
2017-03-09 14:10:33 -08:00
committed by GitHub
4 changed files with 88 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
// Type definitions for klaw-sync 1.1
// Project: https://github.com/manidlou/node-klaw-sync
// Definitions by: Brendan Forster <https://github.com/shiftkey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as fs from "fs"
interface Item {
path: string
stats: fs.Stats
}
interface Options {
/**
* any paths or `micromatch` patterns to ignore.
*
* For more information on micromatch patterns: https://github.com/jonschlinkert/micromatch#features
*/
ignore?: string | string[]
/**
* True to only return files (ignore directories).
*
* Defaults to false if not specified.
*/
nodir?: boolean
/**
* True to only return directories (ignore files).
*
* Defaults to false if not specified.
*/
nofile?: boolean
}
export function klawSync(root: string, options?: Options): ReadonlyArray<Item>
+20
View File
@@ -0,0 +1,20 @@
import { klawSync, Item } from "klaw-sync"
import * as path from "path"
const outputMessage = (result: 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 = {
ignore: [ '.exe' ],
nodir: true,
nofile: false
}
klawSync('/some/dir', options).forEach(outputMessage)
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"klaw-sync-tests.ts"
]
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../tslint.json",
"rules": {
"semicolon": [
true,
"never"
]
}
}