@edgeros/fs 0.0.1 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/src/_require.ts +0 -21
- package/src/fs.ts +0 -40
package/package.json
CHANGED
package/tsconfig.json
CHANGED
package/src/_require.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
// eslint-disable @typescript-eslint/no-unnecessary-type-parameters -- ignore
|
2
|
-
const isJSRE = () => {
|
3
|
-
try {
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore
|
5
|
-
require('iosched')
|
6
|
-
} catch (e) {
|
7
|
-
return false
|
8
|
-
}
|
9
|
-
|
10
|
-
return true
|
11
|
-
}
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- ignore
|
13
|
-
export default function<T = any> (moduleName: string): T {
|
14
|
-
if (isJSRE()) {
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports -- require is needed for dynamic imports
|
16
|
-
return require(`./jsre/${moduleName}`)
|
17
|
-
} else {
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-member-access -- require is needed for dynamic imports and accessing default export
|
19
|
-
return require(`./node/${moduleName}`).default
|
20
|
-
}
|
21
|
-
}
|
package/src/fs.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import _require from './_require'
|
2
|
-
import type { PathLike, WriteStream, Stats } from 'fs'
|
3
|
-
export default _require<IFs>('fs')
|
4
|
-
export type { WriteStream } from 'fs'
|
5
|
-
export interface IFs {
|
6
|
-
WriteStream: WriteStream
|
7
|
-
createWriteStream: (path: PathLike, options?: StreamOptions) => WriteStream
|
8
|
-
stat: (path: PathLike) => Promise<Stats>
|
9
|
-
rename: (oldPath: PathLike, newPath: PathLike) => Promise<void>
|
10
|
-
mkdir: (path: PathLike, options?: any) => Promise<void>
|
11
|
-
mkdirSync: (path: PathLike, options: any) => void
|
12
|
-
}
|
13
|
-
|
14
|
-
export function createWriteStream(path: PathLike, options?: StreamOptions): WriteStream {
|
15
|
-
return _require<IFs>('fs').createWriteStream(path, options)
|
16
|
-
}
|
17
|
-
|
18
|
-
export async function stat(path: PathLike): Promise<Stats> {
|
19
|
-
return await _require<IFs>('fs').stat(path)
|
20
|
-
}
|
21
|
-
|
22
|
-
export async function rename(oldPath: PathLike, newPath: PathLike): Promise<void> {
|
23
|
-
await _require<IFs>('fs').rename(oldPath, newPath)
|
24
|
-
}
|
25
|
-
|
26
|
-
export async function mkdir(path: PathLike, options?: any): Promise<void> {
|
27
|
-
await _require<IFs>('fs').mkdir(path, options)
|
28
|
-
}
|
29
|
-
|
30
|
-
export function mkdirSync(path: PathLike, options: any): void {
|
31
|
-
_require<IFs>('fs').mkdirSync(path, options)
|
32
|
-
}
|
33
|
-
|
34
|
-
interface StreamOptions {
|
35
|
-
flags?: string | undefined
|
36
|
-
mode?: string | undefined
|
37
|
-
start?: number | undefined
|
38
|
-
autoClose?: boolean | undefined
|
39
|
-
emitClose?: boolean | undefined
|
40
|
-
}
|