{"name":"ipfs-unixfs","version":"0.3.1-rc.115","description":"JavaScript implementation of IPFS' unixfs (a Unix FileSystem representation on top of a MerkleDAG)","leadMaintainer":"Alex Potsides <alex.potsides@protocol.ai>","main":"src/index.js","browser":{"fs":false},"scripts":{"test":"aegir test -t node -t browser -t webworker","test:node":"aegir test -t node","test:browser":"aegir test -t browser","test:webworker":"aegir test -t webworker","build":"aegir build","clean":"rm -rf ./dist","lint":"aegir lint","coverage":"nyc -s aegir test -t node && nyc report --reporter=html","depcheck":"aegir dep-check"},"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":">=10.0.0","npm":">=4.0.0"},"homepage":"https://github.com/ipfs/js-ipfs-unixfs#readme","devDependencies":{"aegir":"^21.3.0","chai":"^4.2.0","dirty-chai":"^2.0.1","nyc":"^15.0.0"},"dependencies":{"err-code":"^2.0.0","protons":"^1.1.0"},"gitHead":"a012f22cf08683f9d6d5a3ddf34baf39ee29e24a","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 (Buffer): 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\n","readmeFilename":"README.md","_id":"ipfs-unixfs@0.3.1-rc.115","_nodeVersion":"12.16.1","_npmVersion":"lerna/3.20.2/node@v12.16.1+x64 (linux)","dist":{"integrity":"sha512-+XAxPXo2muK1QiHxhbz8bM8A5sgPr4c/KystTeVirmb6A2DhVZ0sy1F7fNdc1Zt/dgiJG8RuOouge0NjtYmrrA==","shasum":"c0fdaaa9c4719f2e09cacb58ad9aea39d676bb84","tarball":"http://registry-npm.ywwl.com/ipfs-unixfs/download/ipfs-unixfs-0.3.1-rc.115.tgz","fileCount":13,"unpackedSize":31145,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTxScCRA9TVsSAnZWagAAWtMQAJZ69q4q4m7zWI3R6AiP\nBgAdXTba2NNmGLZn9NbjpeQGpvXp0tk7PwLXKRwe7GjqMKjjXOxazPNkvKi3\n/06Rq6jFNLSSyh5m9PPtLJfqomw6sxYw5iZeh10be4pVx948ZitDhp5bbZ7q\nM5n4uJhWkCjghg/Ndd2Tq16IeIXsyKSUB5/pMKWZCt0kxSxlez7CrRVffX5j\nnz/uBXY2UKyek9hssWyl5IBHV8chx+y/hP7zCAofBWOLtwNHoJvEomk5K3nA\nTld1iuZ+ss9Mw2iV1DuXncaNPgz0j6lWrc9mg6d5uHG7fcOJSWZCC2DrvGOg\nrPw/aYvI2Eh5ghuqQU2NfEo3rSC4fc5W69JW9x5jq0OMShH8sn659wgymknV\nV4+3jMfEYeDvFcFDlCSf4QKbLBU5Onl+NX4mzwT5rgCx+lqxiEyHfA2MYCbx\nuq2yZCwMvw3/Kh16DgOBHh4h+0h4XoJe9invwihBX4pcx/QJ9QvbNs4bBBeh\nZzKehBN76WCkYHFxel8i5b/sYfxudCzte6Qfe/62idD2vqAUdw2OKruMj3ir\nRnDIorylMpzFHPgXWelupuVkiwysyeMUtkonCaPXemgXsJJvlpfhZKEqZrp4\nFfiBGGxptYyS831XB20aqLSsP1fM1eumTea6RxUYN8++H6YeT6LTfOk3TzLy\n+F/a\r\n=n5xO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwQSKKAbIJjhCsDX1gV+qblqt4x4146ve+nBv/Lu6kvgIhAOLoJPTFpqWbA3h1FbEPSQFXUcGf6qdsLIz5oDnepbjd"}],"size":8058,"noattachment":false,"key":"/ipfs-unixfs/-/ipfs-unixfs-0.3.1-rc.115.tgz"},"maintainers":[{"email":"alex@achingbrain.net","name":"achingbrain"},{"email":"mail@daviddias.me","name":"daviddias"},{"email":"infra-accounts@protocol.ai","name":"ipfsbot"}],"_npmUser":{"name":"ipfsbot","email":"infra-accounts@protocol.ai"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ipfs-unixfs_0.3.1-rc.115_1582240923486_0.049295864538236644"},"_hasShrinkwrap":false,"publish_time":1582240923691,"_cnpm_publish_time":1582240923691,"dist-tags":{"latest":"13.1.2","next":"6.0.7-rc.5"}}