{"name":"ipfs-unixfs","version":"6.0.4-rc.0","description":"JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)","leadMaintainer":"Alex Potsides <alex.potsides@protocol.ai>","main":"./cjs/src/index.js","browser":{".":"./cjs/src/index.js"},"scripts":{"prepare":"aegir build --no-bundle && cp -R types dist","prepare:proto":"pbjs -t static-module -w es6 -r ipfs-unixfs --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/unixfs.js ./src/unixfs.proto","prepare:proto-types":"pbts -o src/unixfs.d.ts src/unixfs.js","pretest":"aegir build --esm-tests","test":"aegir test","build":"aegir build && cp -R types dist","clean":"rimraf ./dist","lint":"aegir ts -p check && aegir lint","coverage":"nyc -s aegir test -t node && nyc report --reporter=html","depcheck":"aegir dep-check -i mkdirp -i @types/mocha -i nyc -i npm-run-all -i copy -i util"},"repository":{"type":"git","url":"git+https://github.com/ipfs/js-ipfs-unixfs.git"},"keywords":["IPFS"],"license":"MIT","bugs":{"url":"https://github.com/ipfs/js-ipfs-unixfs/issues"},"engines":{"node":">=14.0.0","npm":">=6.0.0"},"homepage":"https://github.com/ipfs/js-ipfs-unixfs#readme","publishConfig":{"directory":"dist"},"devDependencies":{"@types/mocha":"^8.2.1","aegir":"^35.0.1","copy":"^0.3.2","mkdirp":"^1.0.4","npm-run-all":"^4.1.5","nyc":"^15.0.0","uint8arrays":"^3.0.0","util":"^0.12.3"},"dependencies":{"err-code":"^3.0.1","protobufjs":"^6.10.2"},"types":"types/src/index.d.ts","eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"},"ignorePatterns":["src/unixfs.d.ts"]},"gitHead":"2b429cc4c0e7362632d9288c58923f1c629d0cd0","exports":{".":{"browser":"./esm/src/index.js","require":"./cjs/src/index.js","import":"./esm/src/index.js"}},"readme":"# ipfs-unixfs JavaScript Implementation <!-- omit in toc -->\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![Build Status](https://flat.badgen.net/travis/ipfs/js-ipfs-unixfs)](https://travis-ci.com/ipfs/js-ipfs-unixfs)\n[![Codecov](https://codecov.io/gh/ipfs/js-ipfs-unixfs/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-unixfs)\n\n> JavaScript implementation of IPFS' UnixFS (a Unix FileSystem files representation on top of a MerkleDAG)\n\nThe UnixFS spec can be found inside the [ipfs/specs repository](http://github.com/ipfs/specs)\n\n## Lead Maintainer <!-- omit in toc -->\n\n[Alex Potsides](https://github.com/achingbrain)\n\n## Table of Contents <!-- omit in toc -->\n\n- [Install](#install)\n  - [npm](#npm)\n  - [Use in Node.js](#use-in-nodejs)\n  - [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler)\n  - [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag)\n- [Usage](#usage)\n  - [Examples](#examples)\n    - [Create a file composed by several blocks](#create-a-file-composed-by-several-blocks)\n    - [Create a directory that contains several files](#create-a-directory-that-contains-several-files)\n- [API](#api)\n    - [UnixFS Data Structure](#unixfs-data-structure)\n    - [create an unixfs Data element](#create-an-unixfs-data-element)\n    - [add and remove a block size to the block size list](#add-and-remove-a-block-size-to-the-block-size-list)\n    - [get total fileSize](#get-total-filesize)\n    - [marshal and unmarshal](#marshal-and-unmarshal)\n    - [is this UnixFS entry a directory?](#is-this-unixfs-entry-a-directory)\n    - [has an mtime been set?](#has-an-mtime-been-set)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Install\n\n### npm\n\n```sh\n> npm i ipfs-unixfs\n```\n\n### Use in Node.js\n\n```JavaScript\nvar { UnixFS } = require('ipfs-unixfs')\n```\n\n### Use in a browser with browserify, webpack or any other bundler\n\nThe code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust asset management process.\n\n```JavaScript\nvar { UnixFS } = require('ipfs-unixfs')\n```\n\n### Use in a browser Using a script tag\n\nLoading this module through a script tag will make the `UnixFS` obj available in the global namespace.\n\n```html\n<script src=\"https://npmcdn.com/ipfs-unixfs/dist/index.min.js\"></script>\n<!-- OR -->\n<script src=\"https://npmcdn.com/ipfs-unixfs/dist/index.js\"></script>\n```\n\n## Usage\n\n### Examples\n\n#### Create a file composed by several blocks\n\n```JavaScript\nconst data = new UnixFS({ type: 'file' })\ndata.addBlockSize(256) // add the size of each block\ndata.addBlockSize(256)\n// ...\n```\n\n#### 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```JavaScript\nconst data = new UnixFS({ type: 'directory' })\n```\n\n## API\n\n#### UnixFS Data Structure\n\n```protobuf\nsyntax = \"proto2\";\n\nmessage Data {\n  enum DataType {\n    Raw = 0;\n    Directory = 1;\n    File = 2;\n    Metadata = 3;\n    Symlink = 4;\n    HAMTShard = 5;\n  }\n\n  required DataType Type = 1;\n  optional bytes Data = 2;\n  optional uint64 filesize = 3;\n  repeated uint64 blocksizes = 4;\n  optional uint64 hashType = 5;\n  optional uint64 fanout = 6;\n  optional uint32 mode = 7;\n  optional UnixTime mtime = 8;\n}\n\nmessage UnixTime {\n  required int64 Seconds = 1;\n  optional fixed32 FractionalNanoseconds = 2;\n}\n\nmessage Metadata {\n  optional string MimeType = 1;\n}\n```\n\n#### create an unixfs Data element\n\n```JavaScript\nconst data = new UnixFS([options])\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#### add and remove a block size to the block size list\n\n```JavaScript\ndata.addBlockSize(<size in bytes>)\n```\n\n```JavaScript\ndata.removeBlockSize(<index>)\n```\n\n#### get total fileSize\n\n```JavaScript\ndata.fileSize() // => size in bytes\n```\n\n#### marshal and unmarshal\n\n```javascript\nconst marshaled = data.marshal()\nconst unmarshaled = Unixfs.unmarshal(marshaled)\n```\n\n#### is this UnixFS entry a directory?\n\n```JavaScript\nconst dir = new Data({ type: 'directory' })\ndir.isDirectory() // true\n\nconst file = new Data({ type: 'file' })\nfile.isDirectory() // false\n```\n\n#### 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```JavaScript\nconst file = new Data({ type: 'file' })\nfile.mtime // undefined\n\nObject.prototype.hasOwnProperty.call(file, 'mtime') // false\n\nconst dir = new Data({ type: 'dir', mtime: new Date() })\ndir.mtime // { secs: Number, nsecs: Number }\n```\n\n## Contribute\n\nFeel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs/issues)!\n\nThis repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md","_id":"ipfs-unixfs@6.0.4-rc.0","_nodeVersion":"14.17.5","_npmVersion":"lerna/3.22.1/node@v14.17.5+x64 (linux)","dist":{"integrity":"sha512-A+5C+EGqF/3anQ/0oHl9TxzhorcBSRcT1qeGoR2ri2wHwIL5C1Dq+eeBBLv38lO+/ftnguadYK6tx3R7zNHmNA==","shasum":"5a8df2da8d1583852f54ed5fbd0240897e6f874b","tarball":"http://registry-npm.ywwl.com/ipfs-unixfs/download/ipfs-unixfs-6.0.4-rc.0.tgz","fileCount":17,"unpackedSize":99545,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhJkYPCRA9TVsSAnZWagAAECoQAIAbMTtw/HXsy+iZCev3\nzWcoXu3fPZvBU3Cmf/UJYRZxqGpLkD9CbzRn7wAnNNKuOwUnrYYNRsgBXgJr\nqf9P+5uuyf+r0BK8oM9o//N2t7VpdewzzzuoqIFY7yy2swd8dh5hJdbojkqG\n+e5cc3nfEh6M9OVhFEL52MJ4I+2rRMCl+muGgu4cVJZfiXAjemYymYBlxXlS\nWwD6c+vppW2jrp0AW1jPKyDwldfpj+M9KX33XBz4mKQ96LkNbWa2cjhK4LtI\nbm3iMsjD72vKYdbcJ2RZ2RJtwRIakSL8Tll+chwLp4MAqK1njzeEr08haU//\nmEjwHrF2stDhmnsYsyttKPJA2mZmrkZW+Qg7GK9YfgfLJ0ej1WsJIWvcezzd\nFhYIL0iBaVwMVHaMLYMF/SoOZPnCj5PqSX/g2G+jVsp+W9mR1ttYPzT2agoV\n5J5phmZOOyceZffdXbaB5zt+dp4IGNZKvNdXD2XgU1mmGo+pMOuAO7bof8Nn\nQ7x5lyOltIvrhXCi4LgwOKRTzo8oBVLpg23v09cFKYH4ngsX60zBbolWi+f1\nILREsJkv8RVqK/Px0N1y89uYzjMFRYZOybB2NMo3x/Prkf7sSf7sX0fi+SVJ\naktuBVqOeAsi37GuYfnw0E4dPjMPPONRSX0Jbxgxq4lG7c5rY/2SKMBUbvl7\nu2Wz\r\n=dqlQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIECHFfzJkm1ZnnsbmDuukEsMu2Ff9zF3u/8VhHx0nZaNAiEAiQYrFzv0NNmoked5QgYEJjdq4uKR9e1nt0BRE07Vtcs="}],"size":19604,"noattachment":false,"key":"/ipfs-unixfs/-/ipfs-unixfs-6.0.4-rc.0.tgz"},"_npmUser":{"name":"ipfs-npm-publisher-bot","email":"alex.potsides+ipfs-npm-publisher-bot@protocol.ai"},"directories":{},"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"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ipfs-unixfs_6.0.4-rc.0_1629898255436_0.9390652149209642"},"_hasShrinkwrap":false,"publish_time":1629898255569,"_cnpm_publish_time":1629898255569,"dist-tags":{"latest":"13.1.2","next":"6.0.7-rc.5"}}