mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #15005 from shiftkey/add-klaw-sync
add type definitions for `klaw-sync`
This commit is contained in:
Vendored
+37
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"semicolon": [
|
||||
true,
|
||||
"never"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user