This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implementation of the new
resolve()
function
BREAKING CHANGE: `resolve()` replaces parts of `get()`. The API docs for it: > Retrieves IPLD Nodes along the `path` that is rooted at `cid`. - `cid` (`CID`, required): the CID the resolving starts. - `path` (`IPLD Path`, required): the path that should be resolved. Returns an async iterator of all the IPLD Nodes that were traversed during the path resolving. Every element is an object with these fields: - `remainderPath` (`string`): the part of the path that wasn’t resolved yet. - `value` (`*`): the value where the resolved path points to. If further traversing is possible, then the value is a CID object linking to another IPLD Node. If it was possible to fully resolve the path, `value` is the value the `path` points to. So if you need the CID of the IPLD Node you’re currently at, just take the `value` of the previously returned IPLD Node.
- Loading branch information
Showing
13 changed files
with
616 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
|
||
exports.first = async (iterator) => { | ||
for await (const value of iterator) { | ||
return value | ||
} | ||
} | ||
|
||
exports.last = async (iterator) => { | ||
let value | ||
for await (value of iterator) { | ||
// Intentionally empty | ||
} | ||
return value | ||
} | ||
|
||
exports.all = async (iterator) => { | ||
const values = [] | ||
for await (const value of iterator) { | ||
values.push(value) | ||
} | ||
return values | ||
} | ||
|
||
exports.fancyIterator = (next) => { | ||
const iterator = { next } | ||
iterator[Symbol.asyncIterator] = function () { return this } | ||
iterator.first = () => exports.first(iterator) | ||
iterator.last = () => exports.last(iterator) | ||
iterator.all = () => exports.all(iterator) | ||
return iterator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.