Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

29
my-app/node_modules/fs-monkey/docs/api/patchFs.md generated vendored Executable file
View file

@ -0,0 +1,29 @@
# `patchFs(vol[, fs])`
Rewrites Node's filesystem module `fs` with *fs-like* object.
- `vol` - fs-like object
- `fs` *(optional)* - a filesystem to patch, defaults to `require('fs')`
```js
import {patchFs} from 'fs-monkey';
const myfs = {
readFileSync: () => 'hello world',
};
patchFs(myfs);
console.log(require('fs').readFileSync('/foo/bar')); // hello world
```
You don't need to create *fs-like* objects yourself, use [`memfs`](https://github.com/streamich/memfs)
to create a virtual filesystem for you:
```js
import {vol} from 'memfs';
import {patchFs} from 'fs-monkey';
vol.fromJSON({'/dir/foo': 'bar'});
patchFs(vol);
console.log(require('fs').readdirSync('/')); // [ 'dir' ]
```

55
my-app/node_modules/fs-monkey/docs/api/patchRequire.md generated vendored Executable file
View file

@ -0,0 +1,55 @@
# `patchRequire(vol[, unixifyPaths[, Module]])`
Patches Node's `module` module to use a given *fs-like* object `vol` for module loading.
- `vol` - fs-like object
- `unixifyPaths` *(optional)* - whether to convert Windows paths to unix style paths, defaults to `false`.
- `Module` *(optional)* - a module to patch, defaults to `require('module')`
Monkey-patches the `require` function in Node, this way you can make
Node.js to *require* modules from your custom filesystem.
It expects an object with three filesystem methods implemented that are
needed for the `require` function to work.
```js
let vol = {
readFileSync: () => {},
realpathSync: () => {},
statSync: () => {},
};
```
If you want to make Node.js to *require* your files from memory, you
don't need to implement those functions yourself, just use the
[`memfs`](https://github.com/streamich/memfs) package:
```js
import {vol} from 'memfs';
import {patchRequire} from 'fs-monkey';
vol.fromJSON({'/foo/bar.js': 'console.log("obi trice");'});
patchRequire(vol);
require('/foo/bar'); // obi trice
```
Now the `require` function will only load the files from the `vol` file
system, but not from the actual filesystem on the disk.
If you want the `require` function to load modules from both file
systems, use the [`unionfs`](https://github.com/streamich/unionfs) package
to combine both filesystems into a union:
```js
import {vol} from 'memfs';
import {patchRequire} from 'fs-monkey';
import {ufs} from 'unionfs';
import * as fs from 'fs';
vol.fromJSON({'/foo/bar.js': 'console.log("obi trice");'});
ufs
.use(vol)
.use(fs);
patchRequire(ufs);
require('/foo/bar.js'); // obi trice
```