@nodelib/fs.walk
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -6,11 +6,11 @@ /// <reference types="node" /> | ||
import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings'; | ||
import { Entry } from './types/index'; | ||
declare function walk(dir: string, callback: AsyncCallback): void; | ||
declare function walk(dir: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void; | ||
import { Entry } from './types'; | ||
declare function walk(directory: string, callback: AsyncCallback): void; | ||
declare function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void; | ||
declare namespace walk { | ||
function __promisify__(dir: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>; | ||
function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>; | ||
} | ||
declare function walkSync(dir: string, optionsOrSettings?: Options | Settings): Entry[]; | ||
declare function walkStream(dir: string, optionsOrSettings?: Options | Settings): Readable; | ||
declare function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[]; | ||
declare function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable; | ||
export { walk, walkSync, walkStream, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options, DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,18 +8,18 @@ "use strict"; | ||
exports.Settings = settings_1.default; | ||
function walk(dir, optionsOrSettingsOrCallback, callback) { | ||
function walk(directory, optionsOrSettingsOrCallback, callback) { | ||
if (typeof optionsOrSettingsOrCallback === 'function') { | ||
return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); | ||
return new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback); | ||
} | ||
new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); | ||
new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback); | ||
} | ||
exports.walk = walk; | ||
function walkSync(dir, optionsOrSettings) { | ||
function walkSync(directory, optionsOrSettings) { | ||
const settings = getSettings(optionsOrSettings); | ||
const provider = new sync_1.default(dir, settings); | ||
const provider = new sync_1.default(directory, settings); | ||
return provider.read(); | ||
} | ||
exports.walkSync = walkSync; | ||
function walkStream(dir, optionsOrSettings) { | ||
function walkStream(directory, optionsOrSettings) { | ||
const settings = getSettings(optionsOrSettings); | ||
const provider = new stream_1.default(dir, settings); | ||
const provider = new stream_1.default(directory, settings); | ||
return provider.read(); | ||
@@ -26,0 +26,0 @@ } |
import AsyncReader from '../readers/async'; | ||
import Settings from '../settings'; | ||
import { Entry, Errno } from '../types/index'; | ||
import { Entry, Errno } from '../types'; | ||
export declare type AsyncCallback = (err: Errno, entries: Entry[]) => void; | ||
@@ -5,0 +5,0 @@ export default class AsyncProvider { |
@@ -19,3 +19,3 @@ "use strict"; | ||
this._reader.onEnd(() => { | ||
callSuccessCallback(callback, Array.from(this._storage)); | ||
callSuccessCallback(callback, [...this._storage]); | ||
}); | ||
@@ -22,0 +22,0 @@ this._reader.read(); |
import SyncReader from '../readers/sync'; | ||
import Settings from '../settings'; | ||
import { Entry } from '../types/index'; | ||
import { Entry } from '../types'; | ||
export default class SyncProvider { | ||
@@ -5,0 +5,0 @@ private readonly _root; |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import Settings from '../settings'; | ||
import { Entry, Errno } from '../types/index'; | ||
import { Entry, Errno } from '../types'; | ||
import Reader from './reader'; | ||
@@ -8,0 +8,0 @@ declare type EntryEventCallback = (entry: Entry) => void; |
@@ -47,6 +47,6 @@ "use strict"; | ||
} | ||
_pushToQueue(dir, base) { | ||
const queueItem = { dir, base }; | ||
_pushToQueue(directory, base) { | ||
const queueItem = { directory, base }; | ||
this._queue.push(queueItem, (error) => { | ||
if (error) { | ||
if (error !== null) { | ||
this._handleError(error); | ||
@@ -57,4 +57,4 @@ } | ||
_worker(item, done) { | ||
this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { | ||
if (error) { | ||
this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => { | ||
if (error !== null) { | ||
return done(error, undefined); | ||
@@ -61,0 +61,0 @@ } |
import Settings, { FilterFunction } from '../settings'; | ||
import { Errno } from '../types/index'; | ||
import { Errno } from '../types'; | ||
export declare function isFatalError(settings: Settings, error: Errno): boolean; | ||
@@ -4,0 +4,0 @@ export declare function isAppliedFilter<T>(filter: FilterFunction<T> | null, value: T): boolean; |
@@ -15,3 +15,3 @@ "use strict"; | ||
function replacePathSegmentSeparator(filepath, separator) { | ||
return filepath.split(/[\\\/]/).join(separator); | ||
return filepath.split(/[\\/]/).join(separator); | ||
} | ||
@@ -18,0 +18,0 @@ exports.replacePathSegmentSeparator = replacePathSegmentSeparator; |
import * as fsScandir from '@nodelib/fs.scandir'; | ||
import { Entry } from '../types/index'; | ||
import { Entry } from '../types'; | ||
import Reader from './reader'; | ||
@@ -4,0 +4,0 @@ export default class SyncReader extends Reader { |
@@ -16,15 +16,15 @@ "use strict"; | ||
this._handleQueue(); | ||
return Array.from(this._storage); | ||
return [...this._storage]; | ||
} | ||
_pushToQueue(dir, base) { | ||
this._queue.add({ dir, base }); | ||
_pushToQueue(directory, base) { | ||
this._queue.add({ directory, base }); | ||
} | ||
_handleQueue() { | ||
for (const item of this._queue.values()) { | ||
this._handleDirectory(item.dir, item.base); | ||
this._handleDirectory(item.directory, item.base); | ||
} | ||
} | ||
_handleDirectory(dir, base) { | ||
_handleDirectory(directory, base) { | ||
try { | ||
const entries = this._scandir(dir, this._settings.fsScandirSettings); | ||
const entries = this._scandir(directory, this._settings.fsScandirSettings); | ||
for (const entry of entries) { | ||
@@ -31,0 +31,0 @@ this._handleEntry(entry, base); |
import * as fsScandir from '@nodelib/fs.scandir'; | ||
import { Entry, Errno } from './types/index'; | ||
import { Entry, Errno } from './types'; | ||
export declare type FilterFunction<T> = (value: T) => boolean; | ||
@@ -7,3 +7,3 @@ export declare type DeepFilterFunction = FilterFunction<Entry>; | ||
export declare type ErrorFilterFunction = FilterFunction<Errno>; | ||
export interface Options { | ||
export declare type Options = { | ||
basePath?: string; | ||
@@ -19,3 +19,3 @@ concurrency?: number; | ||
throwErrorOnBrokenSymbolicLink?: boolean; | ||
} | ||
}; | ||
export default class Settings { | ||
@@ -22,0 +22,0 @@ private readonly _options; |
@@ -5,6 +5,6 @@ /// <reference types="node" /> | ||
export declare type Errno = NodeJS.ErrnoException; | ||
export interface QueueItem { | ||
dir: string; | ||
export declare type QueueItem = { | ||
directory: string; | ||
base?: string; | ||
} | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@nodelib/fs.walk", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "A library for efficiently walking a directory recursively", | ||
@@ -23,3 +23,3 @@ "license": "MIT", | ||
"clean": "rimraf {tsconfig.tsbuildinfo,out}", | ||
"lint": "tslint \"src/**/*.ts\" -p . -t stylish", | ||
"lint": "eslint \"src/**/*.ts\" --cache", | ||
"compile": "tsc -b .", | ||
@@ -32,6 +32,6 @@ "compile:watch": "tsc -p . --watch --sourceMap", | ||
"dependencies": { | ||
"@nodelib/fs.scandir": "2.1.2", | ||
"@nodelib/fs.scandir": "2.1.3", | ||
"fastq": "^1.6.0" | ||
}, | ||
"gitHead": "b56e041e80bc6ae6c5fa31c327d5174ed1b8957a" | ||
"gitHead": "3b1ef7554ad7c061b3580858101d483fba847abf" | ||
} |
26194
+ Added@nodelib/fs.scandir@2.1.3(transitive)
+ Added@nodelib/fs.stat@2.0.3(transitive)
- Removed@nodelib/fs.scandir@2.1.2(transitive)
- Removed@nodelib/fs.stat@2.0.2(transitive)
Updated@nodelib/fs.scandir@2.1.3