ipfs-unixfs-importer
Advanced tools
Comparing version 15.2.3 to 15.2.4
@@ -0,1 +1,9 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Chunker functions split an incoming stream of bytes into chunks. | ||
* | ||
* The default is a fixed-size chunker which splits them into equally sized | ||
* chunks though other strategies are available such as Rabin chunking. | ||
*/ | ||
export interface Chunker { | ||
@@ -2,0 +10,0 @@ (source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>; |
@@ -0,3 +1,11 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Chunker functions split an incoming stream of bytes into chunks. | ||
* | ||
* The default is a fixed-size chunker which splits them into equally sized | ||
* chunks though other strategies are available such as Rabin chunking. | ||
*/ | ||
export { rabin } from './rabin.js'; | ||
export { fixedSize } from './fixed-size.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,64 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* @example | ||
* | ||
* Let's create a little directory to import: | ||
* | ||
* ```console | ||
* > cd /tmp | ||
* > mkdir foo | ||
* > echo 'hello' > foo/bar | ||
* > echo 'world' > foo/quux | ||
* ``` | ||
* | ||
* And write the importing logic: | ||
* | ||
* ```js | ||
* import { importer } from 'ipfs-unixfs-importer' | ||
* import { MemoryBlockstore } from 'blockstore-core/memory' | ||
* import * as fs from 'node:fs' | ||
* | ||
* // Where the blocks will be stored | ||
* const blockstore = new MemoryBlockstore() | ||
* | ||
* // Import path /tmp/foo/ | ||
* const source = [{ | ||
* path: '/tmp/foo/bar', | ||
* content: fs.createReadStream('/tmp/foo/bar') | ||
* }, { | ||
* path: '/tmp/foo/quxx', | ||
* content: fs.createReadStream('/tmp/foo/quux') | ||
* }] | ||
* | ||
* for await (const entry of importer(source, blockstore)) { | ||
* console.info(entry) | ||
* } | ||
* ``` | ||
* | ||
* When run, metadata about DAGNodes in the created tree is printed until the root: | ||
* | ||
* ```js | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/bar', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/quxx', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* ``` | ||
*/ | ||
import { type BufferImportProgressEvents } from './dag-builder/buffer-importer.js'; | ||
@@ -2,0 +65,0 @@ import { type DAGBuilder, type DagBuilderProgressEvents } from './dag-builder/index.js'; |
@@ -0,1 +1,64 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* @example | ||
* | ||
* Let's create a little directory to import: | ||
* | ||
* ```console | ||
* > cd /tmp | ||
* > mkdir foo | ||
* > echo 'hello' > foo/bar | ||
* > echo 'world' > foo/quux | ||
* ``` | ||
* | ||
* And write the importing logic: | ||
* | ||
* ```js | ||
* import { importer } from 'ipfs-unixfs-importer' | ||
* import { MemoryBlockstore } from 'blockstore-core/memory' | ||
* import * as fs from 'node:fs' | ||
* | ||
* // Where the blocks will be stored | ||
* const blockstore = new MemoryBlockstore() | ||
* | ||
* // Import path /tmp/foo/ | ||
* const source = [{ | ||
* path: '/tmp/foo/bar', | ||
* content: fs.createReadStream('/tmp/foo/bar') | ||
* }, { | ||
* path: '/tmp/foo/quxx', | ||
* content: fs.createReadStream('/tmp/foo/quux') | ||
* }] | ||
* | ||
* for await (const entry of importer(source, blockstore)) { | ||
* console.info(entry) | ||
* } | ||
* ``` | ||
* | ||
* When run, metadata about DAGNodes in the created tree is printed until the root: | ||
* | ||
* ```js | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/bar', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/quxx', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* ``` | ||
*/ | ||
import errcode from 'err-code'; | ||
@@ -2,0 +65,0 @@ import first from 'it-first'; |
@@ -0,1 +1,8 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Layout functions allow customising the shape of final DAGs | ||
* | ||
* {@link https://dag.ipfs.tech} can be used to explore different conigurations. | ||
*/ | ||
import type { InProgressImportResult } from '../index.js'; | ||
@@ -2,0 +9,0 @@ export interface Reducer { |
@@ -0,1 +1,8 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Layout functions allow customising the shape of final DAGs | ||
* | ||
* {@link https://dag.ipfs.tech} can be used to explore different conigurations. | ||
*/ | ||
export { balanced } from './balanced.js'; | ||
@@ -2,0 +9,0 @@ export { flat } from './flat.js'; |
104
package.json
{ | ||
"name": "ipfs-unixfs-importer", | ||
"version": "15.2.3", | ||
"version": "15.2.4", | ||
"description": "JavaScript implementation of the UnixFs importer used by IPFS", | ||
@@ -14,9 +14,9 @@ "license": "Apache-2.0 OR MIT", | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
}, | ||
"keywords": [ | ||
"IPFS" | ||
], | ||
"engines": { | ||
"node": ">=16.0.0", | ||
"npm": ">=7.0.0" | ||
}, | ||
"type": "module", | ||
@@ -63,90 +63,6 @@ "types": "./dist/src/index.d.ts", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
} | ||
}, | ||
"release": { | ||
"branches": [ | ||
"master" | ||
], | ||
"plugins": [ | ||
[ | ||
"@semantic-release/commit-analyzer", | ||
{ | ||
"preset": "conventionalcommits", | ||
"releaseRules": [ | ||
{ | ||
"breaking": true, | ||
"release": "major" | ||
}, | ||
{ | ||
"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" | ||
] | ||
}, | ||
"scripts": { | ||
@@ -160,4 +76,3 @@ "test": "aegir test", | ||
"lint": "aegir lint", | ||
"dep-check": "aegir dep-check", | ||
"release": "aegir release" | ||
"dep-check": "aegir dep-check" | ||
}, | ||
@@ -183,3 +98,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"aegir": "^41.3.2", | ||
"aegir": "^42.2.2", | ||
"blockstore-core": "^4.0.1", | ||
@@ -191,6 +106,3 @@ "it-last": "^3.0.2", | ||
"fs": false | ||
}, | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts" | ||
} | ||
} |
@@ -10,31 +10,4 @@ # ipfs-unixfs-importer <!-- omit in toc --> | ||
## Table of contents <!-- omit in toc --> | ||
# About | ||
- [Install](#install) | ||
- [Browser `<script>` tag](#browser-script-tag) | ||
- [Example](#example) | ||
- [API](#api) | ||
- [const stream = importer(source, blockstore \[, options\])](#const-stream--importersource-blockstore--options) | ||
- [const result = await importFile(content, blockstore \[, options\])](#const-result--await-importfilecontent-blockstore--options) | ||
- [const result = await importDirectory(content, blockstore \[, options\])](#const-result--await-importdirectorycontent-blockstore--options) | ||
- [const result = await importBytes(buf, blockstore \[, options\])](#const-result--await-importbytesbuf-blockstore--options) | ||
- [const result = await importByteStream(source, blockstore \[, options\])](#const-result--await-importbytestreamsource-blockstore--options) | ||
- [API Docs](#api-docs) | ||
- [License](#license) | ||
- [Contribute](#contribute) | ||
## Install | ||
```console | ||
$ npm i ipfs-unixfs-importer | ||
``` | ||
### Browser `<script>` tag | ||
Loading this module through a script tag will make it's exports available as `IpfsUnixfsImporter` in the global namespace. | ||
```html | ||
<script src="https://unpkg.com/ipfs-unixfs-importer/dist/index.min.js"></script> | ||
``` | ||
## Example | ||
@@ -44,3 +17,3 @@ | ||
```sh | ||
```console | ||
> cd /tmp | ||
@@ -101,48 +74,21 @@ > mkdir foo | ||
## API | ||
# Install | ||
```js | ||
import { importer, importFile, importDir, importBytes, importByteStream } from 'ipfs-unixfs-importer' | ||
```console | ||
$ npm i ipfs-unixfs-importer | ||
``` | ||
### const stream = importer(source, blockstore \[, options]) | ||
## Browser `<script>` tag | ||
The `importer` function returns an async iterator takes a source async iterator that yields objects of the form: | ||
Loading this module through a script tag will make it's exports available as `IpfsUnixfsImporter` in the global namespace. | ||
```js | ||
{ | ||
path: 'a name', | ||
content: (Buffer or iterator emitting Buffers), | ||
mtime: (Number representing seconds since (positive) or before (negative) the Unix Epoch), | ||
mode: (Number representing ugo-rwx, setuid, setguid and sticky bit) | ||
} | ||
```html | ||
<script src="https://unpkg.com/ipfs-unixfs-importer/dist/index.min.js"></script> | ||
``` | ||
`stream` will output file info objects as files get stored in IPFS. When stats on a node are emitted they are guaranteed to have been written. | ||
# API Docs | ||
`blockstore` is an instance of a [blockstore][] | ||
The input's file paths and directory structure will be preserved in the [`dag-pb`](https://github.com/ipld/js-dag-pb) created nodes. | ||
### const result = await importFile(content, blockstore \[, options]) | ||
A convenience function for importing a single file or directory. | ||
### const result = await importDirectory(content, blockstore \[, options]) | ||
A convenience function for importing a directory - note this is non-recursive, to import recursively use the [importer](#const-stream--importersource-blockstore--options) function. | ||
### const result = await importBytes(buf, blockstore \[, options]) | ||
A convenience function for importing a single Uint8Array. | ||
### const result = await importByteStream(source, blockstore \[, options]) | ||
A convenience function for importing a single stream of Uint8Arrays. | ||
## API Docs | ||
- <https://ipfs.github.io/js-ipfs-unixfs/modules/ipfs_unixfs_importer.html> | ||
## License | ||
# License | ||
@@ -154,3 +100,3 @@ Licensed under either of | ||
## Contribute | ||
# Contribute | ||
@@ -157,0 +103,0 @@ Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-unixfs/issues). |
@@ -0,1 +1,10 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Chunker functions split an incoming stream of bytes into chunks. | ||
* | ||
* The default is a fixed-size chunker which splits them into equally sized | ||
* chunks though other strategies are available such as Rabin chunking. | ||
*/ | ||
export interface Chunker { (source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array> } | ||
@@ -2,0 +11,0 @@ |
@@ -0,1 +1,65 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* @example | ||
* | ||
* Let's create a little directory to import: | ||
* | ||
* ```console | ||
* > cd /tmp | ||
* > mkdir foo | ||
* > echo 'hello' > foo/bar | ||
* > echo 'world' > foo/quux | ||
* ``` | ||
* | ||
* And write the importing logic: | ||
* | ||
* ```js | ||
* import { importer } from 'ipfs-unixfs-importer' | ||
* import { MemoryBlockstore } from 'blockstore-core/memory' | ||
* import * as fs from 'node:fs' | ||
* | ||
* // Where the blocks will be stored | ||
* const blockstore = new MemoryBlockstore() | ||
* | ||
* // Import path /tmp/foo/ | ||
* const source = [{ | ||
* path: '/tmp/foo/bar', | ||
* content: fs.createReadStream('/tmp/foo/bar') | ||
* }, { | ||
* path: '/tmp/foo/quxx', | ||
* content: fs.createReadStream('/tmp/foo/quux') | ||
* }] | ||
* | ||
* for await (const entry of importer(source, blockstore)) { | ||
* console.info(entry) | ||
* } | ||
* ``` | ||
* | ||
* When run, metadata about DAGNodes in the created tree is printed until the root: | ||
* | ||
* ```js | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/bar', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo/quxx', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp/foo', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* { | ||
* cid: CID, // see https://github.com/multiformats/js-cid | ||
* path: 'tmp', | ||
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs | ||
* } | ||
* ``` | ||
*/ | ||
import errcode from 'err-code' | ||
@@ -2,0 +66,0 @@ import first from 'it-first' |
@@ -0,1 +1,9 @@ | ||
/** | ||
* @packageDocumentation | ||
* | ||
* Layout functions allow customising the shape of final DAGs | ||
* | ||
* {@link https://dag.ipfs.tech} can be used to explore different conigurations. | ||
*/ | ||
import type { InProgressImportResult } from '../index.js' | ||
@@ -2,0 +10,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
105
4015
285609
116