{"name":"ipfs-unixfs","version":"11.2.2","keywords":["IPFS"],"license":"Apache-2.0 OR MIT","_id":"ipfs-unixfs@11.2.2","maintainers":[{"name":"daviddias","email":"mail@daviddias.me"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"ipfs-npm-publisher-bot","email":"alex.potsides+ipfs-npm-publisher-bot@protocol.ai"},{"name":"npm-service-account-ipfs","email":"npm-service-account+ipfs@ipfs.tech"}],"homepage":"https://github.com/ipfs/js-ipfs-unixfs/tree/main/packages/ipfs-unixfs#readme","bugs":{"url":"https://github.com/ipfs/js-ipfs-unixfs/issues"},"dist":{"shasum":"9ea67e82ebc7375d9940e9840bfffb6ab7f33034","tarball":"http://registry-npm.ywwl.com/ipfs-unixfs/download/ipfs-unixfs-11.2.2.tgz","fileCount":22,"integrity":"sha512-tpLnyKsP9ZnVWWSZipG+2AtvhE7lq6GG9IK/S2p7bEkRJh/GwiQec+k+PTg7ROq960UW7xlsf3038b+Jzo66Cg==","signatures":[{"sig":"MEUCIHEsQH36nJMzZmMXdvvpQvsctYiFQ6gqDinNl8+xC8GWAiEAtg+XRS0gCc9usfsAmVG1SGSNljoA1sXP1py43sVuwY4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/ipfs-unixfs@11.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":257900,"size":65093,"noattachment":false,"key":"/ipfs-unixfs/-/ipfs-unixfs-11.2.2.tgz"},"type":"module","types":"./dist/src/index.d.ts","browser":{"fs":false},"exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"89006d7e907be06477ac77fd678036f9ce215219","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"],"branches":["main"]},"scripts":{"lint":"aegir lint","test":"aegir test","build":"aegir build","clean":"aegir clean","release":"aegir release","generate":"protons src/unixfs.proto","dep-check":"aegir dep-check","test:node":"aegir test -t node --cov","test:chrome":"aegir test -t browser --cov","test:firefox":"aegir test -t browser -- --browser firefox"},"_npmUser":{"name":"npm-service-account-ipfs","email":"npm-service-account+ipfs@ipfs.tech"},"repository":{"url":"git+https://github.com/ipfs/js-ipfs-unixfs.git","type":"git"},"_npmVersion":"10.9.2","description":"JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)","directories":{},"sideEffects":false,"_nodeVersion":"22.16.0","dependencies":{"uint8arraylist":"^2.4.8","protons-runtime":"^5.5.0"},"eslintConfig":{"extends":"ipfs","parserOptions":{"project":true,"sourceType":"module"},"ignorePatterns":["src/unixfs.d.ts"]},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^45.0.8","protons":"^7.6.0","uint8arrays":"^5.1.0"},"_npmOperationalInternal":{"tmp":"tmp/ipfs-unixfs_11.2.2_1750077921983_0.6107167017948991","host":"s3://npm-registry-packages-npm-production"},"readme":"# ipfs-unixfs\n\n[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)\n[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)\n[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-unixfs)\n[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-unixfs/js-test-and-release.yml?branch=main\\&style=flat-square)](https://github.com/ipfs/js-ipfs-unixfs/actions/workflows/js-test-and-release.yml?query=branch%3Amain)\n\n> JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nThis module contains the protobuf definition of the UnixFS data structure found at the root of all UnixFS DAGs.\n\nThe UnixFS spec can be found in the [ipfs/specs repository](http://github.com/ipfs/specs)\n\n## Example - Create a file composed of several blocks\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'file' })\ndata.addBlockSize(256n) // add the size of each block\ndata.addBlockSize(256n)\n// ...\n```\n\n## Example - Create a directory that contains several files\n\nCreating a directory that contains several files is achieve by creating a unixfs element that identifies a MerkleDAG node as a directory. The links of that MerkleDAG node are the files that are contained in this directory.\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'directory' })\n```\n\n## Example - Create an unixfs Data element\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({\n  // ...options\n})\n```\n\n`options` is an optional object argument that might include the following keys:\n\n- type (string, default `file`): The type of UnixFS entry.  Can be:\n  - `raw`\n  - `directory`\n  - `file`\n  - `metadata`\n  - `symlink`\n  - `hamt-sharded-directory`\n- data (Uint8Array): The optional data field for this node\n- blockSizes (Array, default: `[]`): If this is a `file` node that is made up of multiple blocks, `blockSizes` is a list numbers that represent the size of the file chunks stored in each child node. It is used to calculate the total file size.\n- mode (Number, default `0644` for files, `0755` for directories/hamt-sharded-directories) file mode\n- mtime (`Date`, `{ secs, nsecs }`, `{ Seconds, FractionalNanoseconds }`, `[ secs, nsecs ]`): The modification time of this node\n\n## Example - Add and remove a block size to the block size list\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'file' })\nconst sizeInBytes = 100n\ndata.addBlockSize(sizeInBytes)\n```\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'file' })\n\nconst index = 0\ndata.removeBlockSize(index)\n```\n\n## Example - Get total fileSize\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'file' })\ndata.fileSize() // => size in bytes\n```\n\n## Example - Marshal and unmarshal\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst data = new UnixFS({ type: 'file' })\nconst marshaled = data.marshal()\nconst unmarshaled = UnixFS.unmarshal(marshaled)\n```\n\n## Example - Is this UnixFS entry a directory?\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst dir = new UnixFS({ type: 'directory' })\ndir.isDirectory() // true\n\nconst file = new UnixFS({ type: 'file' })\nfile.isDirectory() // false\n```\n\n## Example - Has an mtime been set?\n\nIf no modification time has been set, no `mtime` property will be present on the `Data` instance:\n\n```TypeScript\nimport { UnixFS } from 'ipfs-unixfs'\n\nconst file = new UnixFS({ type: 'file' })\nfile.mtime // undefined\n\nObject.prototype.hasOwnProperty.call(file, 'mtime') // false\n\nconst dir = new UnixFS({ type: 'directory', mtime: { secs: 5n } })\ndir.mtime // { secs: Number, nsecs: Number }\n```\n\n# Install\n\n```console\n$ npm i ipfs-unixfs\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make its exports available as `IpfsUnixfs` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/ipfs-unixfs/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://ipfs.github.io/js-ipfs-unixfs/modules/ipfs-unixfs.html>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/js-ipfs-unixfs/blob/main/packages/ipfs-unixfs/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/ipfs/js-ipfs-unixfs/blob/main/packages/ipfs-unixfs/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribute\n\nContributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-unixfs/issues).\n\nAlso see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.\n\nPlease be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)\n","publish_time":1750077922164,"_cnpm_publish_time":1750077922164,"dist-tags":{"latest":"13.1.2","next":"6.0.7-rc.5"}}