-
Notifications
You must be signed in to change notification settings - Fork 20
Remove DAGNode.create? #132
Comments
I had a look. the problem is that we would need to call |
It only does a call to ... Anyway I've found this is only a concern when creating trees of We only assert on serialized size in the DAGNode constructor if it's non-zero in order to do this sort of thing: const node = new DAGNode(buf, links, 0) // dunno How about defaulting it (and the links?) in the constructor? class DAGNode {
constructor (data, links = [], serializedSize = 0) {
if (serializedSize !== 0) {
assert(serializedSize, 'A DAGNode requires it\'s serialized size')
}
... This way you can use If fact you could probably remove the |
BREAKING CHANGE: DAGNode.create() is removed Instead of `DAGNode.create()`, please use `new DAGNode()` instead. It takes the same parameters and is compatible to `create()`. Example: Prior to this change: const node = DAGNode.create('some data', links) Now: const node = new DAGNode('some data', links) Closes #132.
BREAKING CHANGE: DAGNode.create() is removed Instead of `DAGNode.create()`, please use `new DAGNode()` instead. It takes the same parameters and is compatible to `create()`. Example: Prior to this change: const node = DAGNode.create('some data', links) Now: const node = new DAGNode('some data', links) Closes #132.
Sort of related to #131 but if
DAGNode.create
can now calculate the serialized size of a node synchronously, why not do that in theDAGNode
constructor if the serialized size is not passed and remove the.create
function?The text was updated successfully, but these errors were encountered: