{"name":"@humanfs/core","version":"0.19.1","description":"The core 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":"c8 mocha tests"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/humanfs.git"},"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":{"@humanfs/types":"^0.15.0","c8":"^9.0.0","mocha":"^10.2.0","typescript":"^5.2.2"},"_id":"@humanfs/core@0.19.1","gitHead":"514883417ddb4880179b4000d874d2d764e30f2d","_nodeVersion":"22.9.0","_npmVersion":"10.4.0","dist":{"integrity":"sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==","shasum":"17c55ca7d426733fe3c561906b8173c336b40a77","tarball":"http://registry-npm.ywwl.com/@humanfs/core/download/@humanfs/core-0.19.1.tgz","fileCount":12,"unpackedSize":72735,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDB3b20eOAYRinW1zzvD+RxyGsywllcdBQvBYI0Yp9ZbQIhAOYNzfk58oMYBJVKxugcQ8JlwUCfHvDdRFFJUiMjmO/w"}],"size":14260,"noattachment":false,"key":"/@humanfs/core/-/@humanfs/core-0.19.1.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_0.19.1_1730123750762_0.3628290915081207"},"_hasShrinkwrap":false,"readme":"# `@humanfs/core`\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 core functionality for humanfs that is shared across all implementations for all runtimes. The contents of this package are intentionally runtime agnostic and are not intended to be used alone.\n\nCurrently, this package simply exports the `Hfs` class, which is an abstract base class intended to be inherited from in runtime-specific hfs packages (like `@humanfs/node`).\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\n### Node.js\n\nInstall using your favorite package manager for Node.js:\n\n```shell\nnpm install @humanfs/core\n\n# or\n\npnpm install @humanfs/core\n\n# or\n\nyarn add @humanfs/core\n\n# or\n\nbun install @humanfs/core\n```\n\nThen you can import the `Hfs` and `Path` classes like this:\n\n```js\nimport { Hfs, Path } from \"@humanfs/core\";\n```\n\n### Deno\n\nInstall using [JSR](https://jsr.io):\n\n```shell\ndeno add @humanfs/core\n\n# or\n\njsr add @humanfs/core\n```\n\nThen you can import the `Hfs` class like this:\n\n```js\nimport { Hfs, Path } from \"@humanfs/core\";\n```\n\n### Browser\n\nIt's recommended to import the minified version to save bandwidth:\n\n```js\nimport { Hfs, Path } from \"https://cdn.skypack.dev/@humanfs/core?min\";\n```\n\nHowever, you can also import the unminified version for debugging purposes:\n\n```js\nimport { Hfs, Path } from \"https://cdn.skypack.dev/@humanfs/core\";\n```\n\n## Usage\n\n### `Hfs` Class\n\nThe `Hfs` class contains all of the basic functionality for an `Hfs` instance *without* a predefined impl. This class is mostly used for creating runtime-specific impls, such as `NodeHfs` and `DenoHfs`.\n\nYou can create your own instance by providing an `impl` directly:\n\n```js\nconst hfs = new Hfs({ impl: { async text() {} }});\n```\n\nThe specified `impl` becomes the base impl for the instance, meaning you can always reset back to it using `resetImpl()`.\n\nYou can also inherit from `Hfs` to create your own class with a preconfigured impl, such as:\n\n```js\nclass MyHfs extends Hfs {\n\tconstructor() {\n\t\tsuper({\n\t\t\timpl: myImpl\n\t\t});\n\t}\n}\n```\n\n### `Path` Class\n\nThe `Path` class represents the path to a directory or file within a file system. It's an abstract representation that can be used even outside of traditional file systems where string paths might not make sense.\n\n```js\nconst myPath = new Path([\"dir\", \"subdir\"]);\nconsole.log(myPath.toString());\t\t// \"dir/subdir\"\n\n// add another step\nmyPath.push(\"file.txt\");\nconsole.log(myPath.toString());\t\t// \"dir/subdir/file.txt\"\n\n// get just the last step\nconsole.log(myPath.name);\t\t\t// \"file.txt\"\n\n// change just the last step\nmyPath.name = \"file.json\";\nconsole.log(myPath.name);\t\t\t// \"file.json\"\nconsole.log(myPath.toString());\t\t// \"dir/subdir/file.json\"\n\n// get the size of the path\nconsole.log(myPath.size);\t\t\t// 3\n\n// remove the last step\nmyPath.pop();\nconsole.log(myPath.toString());\t\t// \"dir/subdir\"\n\n// iterate over the steps\nfor (const step of myPath) {\n\t// do something\n}\n\n// create a new path from a string\nconst newPath = Path.fromString(\"/foo/bar\");\n```\n\n## License\n\nApache 2.0\n","publish_time":1730123750943,"maintainers":[{"name":"nzakas","email":"nicholas@nczconsulting.com"}],"_cnpm_publish_time":1730123750943,"dist-tags":{"latest":"0.20.0"}}