mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge pull request #19410 from garbles/patch-2
Update klaw-sync type definition
This commit is contained in:
54
types/klaw-sync/index.d.ts
vendored
54
types/klaw-sync/index.d.ts
vendored
@@ -5,32 +5,36 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as fs from "fs"
|
||||
import * as fs from 'fs'
|
||||
|
||||
export interface Item {
|
||||
path: string
|
||||
stats: fs.Stats
|
||||
declare namespace klawSync {
|
||||
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 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
|
||||
}
|
||||
declare function klawSync(root: string, options?: klawSync.Options): ReadonlyArray<klawSync.Item>
|
||||
|
||||
export function klawSync(root: string, options?: Options): ReadonlyArray<Item>
|
||||
export = klawSync
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { klawSync, Item } from "klaw-sync"
|
||||
import * as path from "path"
|
||||
import * as path from 'path'
|
||||
import klawSync = require('klaw-sync')
|
||||
|
||||
const outputMessage = (result: Item) => {
|
||||
const outputMessage = (result: klawSync.Item) => {
|
||||
console.log(`file: ${result.path} has size '${result.stats.size}'`)
|
||||
}
|
||||
|
||||
klawSync('/some/dir').forEach(outputMessage)
|
||||
|
||||
const defaultOptions = { }
|
||||
const defaultOptions = {}
|
||||
|
||||
klawSync('/some/dir', defaultOptions).forEach(outputMessage)
|
||||
|
||||
const options = {
|
||||
ignore: [ '.exe' ],
|
||||
ignore: ['.exe'],
|
||||
nodir: true,
|
||||
nofile: false
|
||||
nofile: false,
|
||||
}
|
||||
|
||||
klawSync('/some/dir', options).forEach(outputMessage)
|
||||
|
||||
Reference in New Issue
Block a user