import Fs from 'fs' ; import { join } from 'path' ; import * as Rx from 'rxjs' ; import { map , mergeAll , mergeMap } from 'rxjs/operators' ; import { assertAbsolute } from './fs' ; const getStat$ = Rx . bindNodeCallback ( Fs . stat ) as ( path : string ) => Rx . Observable < Fs . Stats > ; const getReadDir$ = Rx . bindNodeCallback ( Fs . readdir ) as ( path : string ) => Rx . Observable < string [ ] > ; param directory export function scan$ ( directory ) { const getChildPath$ = ( path ) => getReadDir$ ( path ) . pipe ( mergeAll ( ) , map ( ( name ) => join ( path , name ) ) ) ; const getPaths$ = ( path ) : Rx . Observable < string > => { return Rx . concat ( [ path ] , getStat$ ( path ) . pipe ( mergeMap ( ( stat ) => ( stat . isDirectory ( ) ? getChildPath$ ( path ) : Rx . EMPTY ) ) , mergeMap ( getPaths$ ) ) ) ; } ; return getPaths$ ( directory ) ; }