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 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: The API is now async/await based There are numerous changes, the most significant one is that the API is no longer callback based, but it using async/await. The properties of DAGNode and DAGLink are now in sync with the paths that are used for resolving. This means that e.g. `name` is now called `Name` and `size` is `Tsize`. All return values from `resolve()` now conform to the [IPLD Data Model], this means that e.g. links are no longer represented as `{'/': "baseecodedcid"}`, but as [CID] instances instead. For the full new API please see the [IPLD Formats spec]. [IPLD Data Model]: https://github.com/ipld/specs/blob/master/IPLD-Data-Model-v1.md [CID]: https://github.com/multiformats/js-cid/ [IPLD Formats spec]: https://github.com/ipld/interface-ipld-format
- Loading branch information
Showing
21 changed files
with
745 additions
and
1,149 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 was deleted.
Oops, something went wrong.
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
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,25 @@ | ||
'use strict' | ||
|
||
/** | ||
* Adds a link with its name as property to an object. | ||
* | ||
* The link won't be added if its name is empty or matches one of the existing | ||
* properties. | ||
* | ||
* @param {Object} object - The object that contains an array of links | ||
* @param {string} name - The name of the link to add | ||
* @param {numner} position - The position within the array of links | ||
*/ | ||
const addNamedLink = (object, name, position) => { | ||
const skipNames = ['', ...Object.keys(this)] | ||
if (skipNames.includes(name)) { | ||
return | ||
} | ||
Object.defineProperty(object, name, { | ||
enumerable: true, | ||
configurable: true, | ||
get: () => object._links[position] | ||
}) | ||
} | ||
|
||
module.exports = addNamedLink |
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.