{"name":"@humanfs/node","version":"0.16.8","description":"The Node.js bindings of the humanfs library.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{"import":{"types":"./dist/index.d.ts","default":"./src/index.js"}},"scripts":{"build":"tsc","prepare":"npm run build","pretest":"npm run build","test":"mocha ./tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/humanfs.git","directory":"packages/node"},"publishConfig":{"access":"public"},"keywords":["filesystem","fs","hfs","files"],"author":{"name":"Nicholas C. Zakas"},"license":"Apache-2.0","bugs":{"url":"https://github.com/humanwhocodes/humanfs/issues"},"homepage":"https://github.com/humanwhocodes/humanfs#readme","engines":{"node":">=18.18.0"},"devDependencies":{"@types/node":"^20.9.4","@humanfs/test":"^0.15.0","mocha":"^10.2.0","typescript":"^5.2.2"},"dependencies":{"@humanwhocodes/retry":"^0.4.0","@humanfs/core":"^0.19.2","@humanfs/types":"^0.15.0"},"_id":"@humanfs/node@0.16.8","gitHead":"f57df9bf460ccfedd2df4e48f72b215e0145f69f","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==","shasum":"8f800cccc13f4f8cd3116e2d9c0a94939da3e3ed","tarball":"http://registry-npm.ywwl.com/@humanfs/node/download/@humanfs/node-0.16.8.tgz","fileCount":8,"unpackedSize":44472,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDIpFvKADwmPjZGYyE6nW9HEMrfH/3OWJgQ9s5+Ozqh6AiEAn0ReBlvcohIoBjBfaWRn+/ygP1ksn88+iAuYMWEP5Rs="}],"size":9398,"noattachment":false,"key":"/@humanfs/node/-/@humanfs/node-0.16.8.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"directories":{},"maintainers":[{"name":"nzakas","email":"nicholas@nczconsulting.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node_0.16.8_1776459086737_0.0017189297117163882"},"_hasShrinkwrap":false,"readme":"# `@humanfs/node`\n\nby [Nicholas C. Zakas](https://humanwhocodes.com)\n\nIf you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate) or [nominate me](https://stars.github.com/nominate/) for a GitHub Star.\n\n## Description\n\nThe `hfs` bindings for use in Node.js and Node.js-compatible runtimes.\n\n> [!WARNING]\n> This project is **experimental** and may change significantly before v1.0.0. Use at your own caution and definitely not in production!\n\n## Installation\n\nInstall using your favorite package manager:\n\n```shell\nnpm install @humanfs/node\n\n# or\n\npnpm install @humanfs/node\n\n# or\n\nyarn add @humanfs/node\n\n# or\n\nbun install @humanfs/node\n```\n\n## Usage\n\nThe easiest way to use hfs in your project is to import the `hfs` object:\n\n```js\nimport { hfs } from \"@humanfs/node\";\n```\n\nThen, you can use the API methods:\n\n```js\n// 1. Files\n\n// read from a text file\nconst text = await hfs.text(\"file.txt\");\n\n// read from a JSON file\nconst json = await hfs.json(\"file.json\");\n\n// read raw bytes from a text file\nconst arrayBuffer = await hfs.arrayBuffer(\"file.txt\");\n\n// write text to a file\nawait hfs.write(\"file.txt\", \"Hello world!\");\n\n// write bytes to a file\nawait hfs.write(\"file.txt\", new TextEncoder().encode(\"Hello world!\"));\n\n// append text to a file\nawait hfs.append(\"file.txt\", \"Hello world!\");\n\n// append bytes to a file\nawait hfs.append(\"file.txt\", new TextEncoder().encode(\"Hello world!\"));\n\n// does the file exist?\nconst found = await hfs.isFile(\"file.txt\");\n\n// how big is the file?\nconst size = await hfs.size(\"file.txt\");\n\n// when was the file modified?\nconst mtime = await hfs.lastModified(\"file.txt\");\n\n// copy a file from one location to another\nawait hfs.copy(\"file.txt\", \"file-copy.txt\");\n\n// move a file from one location to another\nawait hfs.move(\"file.txt\", \"renamed.txt\");\n\n// delete a file\nawait hfs.delete(\"file.txt\");\n\n// 2. Directories\n\n// create a directory\nawait hfs.createDirectory(\"dir\");\n\n// create a directory recursively\nawait hfs.createDirectory(\"dir/subdir\");\n\n// does the directory exist?\nconst dirFound = await hfs.isDirectory(\"dir\");\n\n// copy the entire directory\nhfs.copyAll(\"from-dir\", \"to-dir\");\n\n// move the entire directory\nhfs.moveAll(\"from-dir\", \"to-dir\");\n\n// delete a directory\nawait hfs.delete(\"dir\");\n\n// delete a non-empty directory\nawait hfs.deleteAll(\"dir\");\n```\n\nIf you'd like to create your own instance, import the `NodeHfs` constructor:\n\n```js\nimport { NodeHfs } from \"@humanfs/node\";\nimport fsp from \"fs/promises\";\n\nconst hfs = new NodeHfs();\n\n// optionally specify the fs/promises object to use\nconst hfs = new NodeHfs({ fsp });\n```\n\nIf you'd like to use just the impl, import the `NodeHfsImpl` constructor:\n\n```js\nimport { NodeHfsImpl } from \"@humanfs/node\";\nimport fsp from \"fs/promises\";\n\nconst hfs = new NodeHfsImpl();\n\n// optionally specify the fs/promises object to use\nconst hfs = new NodeHfsImpl({ fsp });\n```\n\n## Errors Handled\n\n* `ENOENT` - in most cases, these errors are handled silently.\n* `ENFILE` and `EMFILE` - calls that result in these errors are retried for up to 60 seconds before giving up for good.\n\n## License\n\nApache 2.0\n","publish_time":1776459086959,"_cnpm_publish_time":1776459086959,"dist-tags":{"latest":"0.17.0"}}