@helia/unixfs 0.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/dist/index.min.js +1 -1
- package/dist/src/commands/cat.d.ts +1 -1
- package/dist/src/commands/cat.d.ts.map +1 -1
- package/dist/src/commands/cat.js +1 -1
- package/dist/src/commands/cat.js.map +1 -1
- package/dist/src/commands/chmod.d.ts.map +1 -1
- package/dist/src/commands/chmod.js +14 -12
- package/dist/src/commands/chmod.js.map +1 -1
- package/dist/src/commands/cp.d.ts +1 -1
- package/dist/src/commands/cp.d.ts.map +1 -1
- package/dist/src/commands/cp.js +5 -2
- package/dist/src/commands/cp.js.map +1 -1
- package/dist/src/commands/ls.d.ts +2 -1
- package/dist/src/commands/ls.d.ts.map +1 -1
- package/dist/src/commands/ls.js +1 -1
- package/dist/src/commands/ls.js.map +1 -1
- package/dist/src/commands/mkdir.d.ts.map +1 -1
- package/dist/src/commands/mkdir.js +4 -2
- package/dist/src/commands/mkdir.js.map +1 -1
- package/dist/src/commands/rm.d.ts +1 -1
- package/dist/src/commands/rm.d.ts.map +1 -1
- package/dist/src/commands/rm.js +9 -3
- package/dist/src/commands/rm.js.map +1 -1
- package/dist/src/commands/stat.d.ts +1 -1
- package/dist/src/commands/stat.d.ts.map +1 -1
- package/dist/src/commands/stat.js +19 -15
- package/dist/src/commands/stat.js.map +1 -1
- package/dist/src/commands/touch.d.ts.map +1 -1
- package/dist/src/commands/touch.js +15 -13
- package/dist/src/commands/touch.js.map +1 -1
- package/dist/src/commands/utils/add-link.d.ts +4 -2
- package/dist/src/commands/utils/add-link.d.ts.map +1 -1
- package/dist/src/commands/utils/add-link.js +24 -24
- package/dist/src/commands/utils/add-link.js.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.d.ts +3 -3
- package/dist/src/commands/utils/cid-to-directory.d.ts.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.js +1 -1
- package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
- package/dist/src/commands/utils/cid-to-pblink.d.ts +3 -3
- package/dist/src/commands/utils/cid-to-pblink.d.ts.map +1 -1
- package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
- package/dist/src/commands/utils/constants.d.ts +2 -0
- package/dist/src/commands/utils/constants.d.ts.map +1 -0
- package/dist/src/commands/utils/constants.js +2 -0
- package/dist/src/commands/utils/constants.js.map +1 -0
- package/dist/src/commands/utils/dir-sharded.d.ts +47 -41
- package/dist/src/commands/utils/dir-sharded.d.ts.map +1 -1
- package/dist/src/commands/utils/dir-sharded.js +99 -15
- package/dist/src/commands/utils/dir-sharded.js.map +1 -1
- package/dist/src/commands/utils/errors.d.ts +22 -6
- package/dist/src/commands/utils/errors.d.ts.map +1 -1
- package/dist/src/commands/utils/errors.js +34 -8
- package/dist/src/commands/utils/errors.js.map +1 -1
- package/dist/src/commands/utils/hamt-constants.d.ts +1 -1
- package/dist/src/commands/utils/hamt-constants.d.ts.map +1 -1
- package/dist/src/commands/utils/hamt-constants.js +1 -1
- package/dist/src/commands/utils/hamt-constants.js.map +1 -1
- package/dist/src/commands/utils/hamt-utils.d.ts +15 -12
- package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
- package/dist/src/commands/utils/hamt-utils.js +40 -39
- package/dist/src/commands/utils/hamt-utils.js.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts +10 -0
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -0
- package/dist/src/commands/utils/is-over-shard-threshold.js +62 -0
- package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -0
- package/dist/src/commands/utils/persist.d.ts +7 -6
- package/dist/src/commands/utils/persist.d.ts.map +1 -1
- package/dist/src/commands/utils/persist.js +6 -3
- package/dist/src/commands/utils/persist.js.map +1 -1
- package/dist/src/commands/utils/remove-link.d.ts +6 -2
- package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
- package/dist/src/commands/utils/remove-link.js +143 -55
- package/dist/src/commands/utils/remove-link.js.map +1 -1
- package/dist/src/commands/utils/resolve.d.ts +6 -3
- package/dist/src/commands/utils/resolve.d.ts.map +1 -1
- package/dist/src/commands/utils/resolve.js +4 -4
- package/dist/src/commands/utils/resolve.js.map +1 -1
- package/dist/src/index.d.ts +14 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +14 -0
- package/package.json +8 -7
- package/src/commands/cat.ts +3 -2
- package/src/commands/chmod.ts +13 -10
- package/src/commands/cp.ts +7 -4
- package/src/commands/ls.ts +4 -3
- package/src/commands/mkdir.ts +5 -3
- package/src/commands/rm.ts +9 -5
- package/src/commands/stat.ts +22 -17
- package/src/commands/touch.ts +15 -12
- package/src/commands/utils/add-link.ts +32 -31
- package/src/commands/utils/cid-to-directory.ts +4 -4
- package/src/commands/utils/cid-to-pblink.ts +3 -3
- package/src/commands/utils/constants.ts +2 -0
- package/src/commands/utils/dir-sharded.ts +162 -63
- package/src/commands/utils/errors.ts +42 -8
- package/src/commands/utils/hamt-constants.ts +1 -1
- package/src/commands/utils/hamt-utils.ts +59 -50
- package/src/commands/utils/is-over-shard-threshold.ts +78 -0
- package/src/commands/utils/persist.ts +13 -8
- package/src/commands/utils/remove-link.ts +178 -77
- package/src/commands/utils/resolve.ts +12 -7
- package/src/index.ts +15 -17
- package/dist/src/commands/add.d.ts +0 -6
- package/dist/src/commands/add.d.ts.map +0 -1
- package/dist/src/commands/add.js +0 -38
- package/dist/src/commands/add.js.map +0 -1
- package/src/commands/add.ts +0 -46
package/src/commands/add.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Blockstore } from 'interface-blockstore'
|
|
2
|
-
import { ImportCandidate, importer, ImportResult, UserImporterOptions } from 'ipfs-unixfs-importer'
|
|
3
|
-
import last from 'it-last'
|
|
4
|
-
import type { CID } from 'multiformats/cid'
|
|
5
|
-
import { UnknownError } from './utils/errors.js'
|
|
6
|
-
|
|
7
|
-
function isIterable (obj: any): obj is Iterator<Uint8Array> {
|
|
8
|
-
return obj[Symbol.iterator] != null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function isAsyncIterable (obj: any): obj is AsyncIterator<Uint8Array> {
|
|
12
|
-
return obj[Symbol.asyncIterator] != null
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function add (source: Uint8Array | Iterator<Uint8Array> | AsyncIterator<Uint8Array> | ImportCandidate, blockstore: Blockstore, options: UserImporterOptions = {}): Promise<CID> {
|
|
16
|
-
let importCandidate: ImportCandidate
|
|
17
|
-
|
|
18
|
-
if (source instanceof Uint8Array || isIterable(source) || isAsyncIterable(source)) {
|
|
19
|
-
importCandidate = {
|
|
20
|
-
// @ts-expect-error FIXME: work out types
|
|
21
|
-
content: source
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
importCandidate = source
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const result = await last(importer(importCandidate, blockstore, {
|
|
28
|
-
cidVersion: 1,
|
|
29
|
-
rawLeaves: true,
|
|
30
|
-
...options
|
|
31
|
-
}))
|
|
32
|
-
|
|
33
|
-
if (result == null) {
|
|
34
|
-
throw new UnknownError('Could not import')
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return result.cid
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function * addStream (source: Iterable<ImportCandidate> | AsyncIterable<ImportCandidate>, blockstore: Blockstore, options: UserImporterOptions = {}): AsyncGenerator<ImportResult> {
|
|
41
|
-
yield * importer(source, blockstore, {
|
|
42
|
-
cidVersion: 1,
|
|
43
|
-
rawLeaves: true,
|
|
44
|
-
...options
|
|
45
|
-
})
|
|
46
|
-
}
|