diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..c5ebf5e2 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +; package-lock with tarball deps breaks lerna/nx - remove when https://github.com/semantic-release/github/pull/487 is merged +package-lock=false diff --git a/lerna.json b/lerna.json index fe9f1a3a..b8a9e8e2 100644 --- a/lerna.json +++ b/lerna.json @@ -1,13 +1,10 @@ { - "lerna": "5.4.0", + "lerna": "6.0.1", "useWorkspaces": true, "version": "independent", "command": { "run": { "stream": true } - }, - "packages": [ - "packages/*" - ] + } } diff --git a/packages/ipfs-unixfs-exporter/README.md b/packages/ipfs-unixfs-exporter/README.md index a4dee931..b1ef3d59 100644 --- a/packages/ipfs-unixfs-exporter/README.md +++ b/packages/ipfs-unixfs-exporter/README.md @@ -10,15 +10,14 @@ ## Table of contents - [Install](#install) -- [Lead Maintainer](#lead-maintainer) -- [Usage](#usage) - - [Example](#example) - - [API](#api) + - [Browser ` +``` -### Example +## Example ```js // import a file and export it again @@ -78,7 +79,7 @@ for await (const buf of entry.content()) { console.info(bytes) // 0, 1, 2, 3 ``` -#### API +## API ```js import { exporter } from 'ipfs-unixfs-exporter' @@ -94,7 +95,7 @@ Returns a Promise which resolves to a `UnixFSEntry`. - `signal` ([AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)): Used to cancel any network requests that are initiated as a result of this export -#### UnixFSEntry +### UnixFSEntry ```javascript { @@ -127,7 +128,7 @@ if (entry.type === 'directory') { } ``` -#### Raw entries +### Raw entries Entries with a `raw` codec `CID` return raw entries: @@ -151,7 +152,7 @@ for await (const chunk of entry.content()) { Unless you an options object containing `offset` and `length` keys as an argument to `entry.content()`, `chunk` will be equal to `entry.node`. -#### CBOR entries +### CBOR entries Entries with a `dag-cbor` codec `CID` return JavaScript object entries: @@ -167,7 +168,7 @@ Entries with a `dag-cbor` codec `CID` return JavaScript object entries: There is no `content` function for a `CBOR` node. -#### `entry.content({ offset, length })` +### `entry.content({ offset, length })` When `entry` is a file or a `raw` node, `offset` and/or `length` arguments can be passed to `entry.content()` to return slices of data: diff --git a/packages/ipfs-unixfs-importer/README.md b/packages/ipfs-unixfs-importer/README.md index be2cac5b..3c914fc6 100644 --- a/packages/ipfs-unixfs-importer/README.md +++ b/packages/ipfs-unixfs-importer/README.md @@ -10,11 +10,10 @@ ## Table of contents - [Install](#install) -- [Lead Maintainer ](#lead-maintainer----omit-in-toc---) -- [Usage](#usage) - - [Example](#example) - - [API](#api) - - [const stream = importer(source, blockstore \[, options\])](#const-stream--importersource-blockstore--options) + - [Browser ` +``` -### Example +## Example Let's create a little directory to import: @@ -91,13 +92,13 @@ When run, metadata about DAGNodes in the created tree is printed until the root: } ``` -#### API +## API ```js import { importer } from 'ipfs-unixfs-importer' ``` -#### const stream = importer(source, blockstore \[, options]) +### const stream = importer(source, blockstore \[, options]) The `importer` function returns an async iterator takes a source async iterator that yields objects of the form: diff --git a/packages/ipfs-unixfs/README.md b/packages/ipfs-unixfs/README.md index 65ffd966..aff89d89 100644 --- a/packages/ipfs-unixfs/README.md +++ b/packages/ipfs-unixfs/README.md @@ -10,22 +10,20 @@ ## Table of contents - [Install](#install) -- [Lead Maintainer ](#lead-maintainer----omit-in-toc---) + - [Browser ` ``` +## Spec + +The UnixFS spec can be found inside the [ipfs/specs repository](http://github.com/ipfs/specs) + ### Use in Node.js ```JavaScript @@ -60,21 +60,9 @@ The code published to npm that gets loaded on require is in fact a ES5 transpile import { UnixFS } from 'ipfs-unixfs' ``` -### Use in a browser Using a script tag +## Examples -Loading this module through a script tag will make the `UnixFS` obj available in the global namespace. - -```html - - - -``` - -## Usage - -### Examples - -#### Create a file composed by several blocks +### Create a file composed by several blocks ```JavaScript const data = new UnixFS({ type: 'file' }) @@ -83,7 +71,7 @@ data.addBlockSize(256) // ... ``` -#### Create a directory that contains several files +### Create a directory that contains several files Creating 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. @@ -91,9 +79,7 @@ Creating a directory that contains several files is achieve by creating a unixfs const data = new UnixFS({ type: 'directory' }) ``` -## API - -#### UnixFS Data Structure +### UnixFS Data Structure ```protobuf syntax = "proto2"; @@ -128,7 +114,7 @@ message Metadata { } ``` -#### create an unixfs Data element +### create an unixfs Data element ```JavaScript const data = new UnixFS([options]) @@ -148,7 +134,7 @@ const data = new UnixFS([options]) - mode (Number, default `0644` for files, `0755` for directories/hamt-sharded-directories) file mode - mtime (`Date`, `{ secs, nsecs }`, `{ Seconds, FractionalNanoseconds }`, `[ secs, nsecs ]`): The modification time of this node -#### add and remove a block size to the block size list +### add and remove a block size to the block size list ```JavaScript data.addBlockSize() @@ -158,20 +144,20 @@ data.addBlockSize() data.removeBlockSize() ``` -#### get total fileSize +### get total fileSize ```JavaScript data.fileSize() // => size in bytes ``` -#### marshal and unmarshal +### marshal and unmarshal ```javascript const marshaled = data.marshal() const unmarshaled = Unixfs.unmarshal(marshaled) ``` -#### is this UnixFS entry a directory? +### is this UnixFS entry a directory? ```JavaScript const dir = new Data({ type: 'directory' }) @@ -181,7 +167,7 @@ const file = new Data({ type: 'file' }) file.isDirectory() // false ``` -#### has an mtime been set? +### has an mtime been set? If no modification time has been set, no `mtime` property will be present on the `Data` instance: