Comparing version 1.0.3 to 1.0.4
@@ -30,3 +30,3 @@ 'use strict'; | ||
_insert(node) { | ||
let indices = Lazy(node.next).map((next) => Lazy(this._items).map((f) => f.hash).indexOf(next.hash)) // Find the item's parent's indices | ||
let indices = Lazy(node.next).map((next) => Lazy(this._items).map((f) => f.hash).indexOf(next)) // Find the item's parent's indices | ||
const index = indices.toArray().length > 0 ? Math.max(indices.max() + 1, 0) : 0; // find the largest index (latest parent) | ||
@@ -130,3 +130,2 @@ this._items.splice(index, 0, node); | ||
.map((f) => f.next).flatten() // Go through all heads | ||
.filter((f) => !(f instanceof Node === true)) // OrbitNode vs. {}, filter out instances (we already have them in mem) | ||
.async() // Do the next map asynchronously | ||
@@ -188,2 +187,3 @@ .map((f) => { | ||
.filter((f) => !Log.isReferencedInChain(log, f)) | ||
.map((f) => f.hash) | ||
.toArray(); | ||
@@ -190,0 +190,0 @@ } |
@@ -6,5 +6,12 @@ 'use strict'; | ||
this._ipfs = ipfs; | ||
this.next = next ? (next instanceof Array ? next : [next]) : []; | ||
this.payload = payload || null; | ||
this.hash = null; | ||
this.next = next ? (next instanceof Array ? next : [next]) : []; | ||
// Convert instances of Node to its hash | ||
this.next = this.next.map((f) => { | ||
if(f instanceof Node) | ||
return f.hash; | ||
return f; | ||
}) | ||
} | ||
@@ -25,3 +32,3 @@ | ||
for(let i = 0; i < this.next.length; i++) { | ||
if(this.next[i] === a) | ||
if(this.next[i] === a.hash) | ||
return true; | ||
@@ -28,0 +35,0 @@ } |
{ | ||
"name": "ipfs-log", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Append-only log for IPFS", | ||
@@ -5,0 +5,0 @@ "main": "lib/log.js", |
@@ -270,3 +270,3 @@ 'use strict'; | ||
assert.equal(last.next.length, 1); | ||
assert.equal(last.next[0].hash, 'QmdZwCR96sP61aaTbcLj9DXy9EaiMhTXLRrTxPSXpcZCct'); | ||
assert.equal(last.next[0], 'QmdZwCR96sP61aaTbcLj9DXy9EaiMhTXLRrTxPSXpcZCct'); | ||
done(); | ||
@@ -490,3 +490,3 @@ })); | ||
assert.equal(heads.length, 1); | ||
assert.equal(heads[0].hash, 'QmUEH5SEuRZhZ7RETwEX2df2BtTR2xUYZR3qBrhjnxqocb'); | ||
assert.equal(heads[0], 'QmUEH5SEuRZhZ7RETwEX2df2BtTR2xUYZR3qBrhjnxqocb'); | ||
done(); | ||
@@ -505,3 +505,3 @@ })); | ||
assert.equal(heads.length, 1); | ||
assert.equal(heads[0].hash, 'Qma1PaYbyW1rZA4npPnuJzA3ov5Je4N9cvAn2p6Ju1iPQS'); | ||
assert.equal(heads[0], 'Qma1PaYbyW1rZA4npPnuJzA3ov5Je4N9cvAn2p6Ju1iPQS'); | ||
done(); | ||
@@ -524,4 +524,4 @@ })); | ||
assert.equal(heads.length, 2); | ||
assert.equal(heads[0].hash, expectedHead2.hash); | ||
assert.equal(heads[1].hash, expectedHead1.hash); | ||
assert.equal(heads[0], expectedHead2.hash); | ||
assert.equal(heads[1], expectedHead1.hash); | ||
done(); | ||
@@ -545,3 +545,3 @@ })); | ||
assert.equal(heads.length, 1); | ||
assert.equal(heads[0].hash, expectedHead.hash); | ||
assert.equal(heads[0], expectedHead.hash); | ||
done(); | ||
@@ -570,4 +570,4 @@ })); | ||
assert.equal(heads.length, 2); | ||
assert.equal(heads[0].hash, expectedHead2.hash); | ||
assert.equal(heads[1].hash, expectedHead1.hash); | ||
assert.equal(heads[0], expectedHead2.hash); | ||
assert.equal(heads[1], expectedHead1.hash); | ||
done(); | ||
@@ -596,5 +596,5 @@ })); | ||
assert.equal(heads.length, 3); | ||
assert.equal(heads[0].hash, expectedHead3.hash); | ||
assert.equal(heads[1].hash, expectedHead2.hash); | ||
assert.equal(heads[2].hash, expectedHead1.hash); | ||
assert.equal(heads[0], expectedHead3.hash); | ||
assert.equal(heads[1], expectedHead2.hash); | ||
assert.equal(heads[2], expectedHead1.hash); | ||
done(); | ||
@@ -601,0 +601,0 @@ })); |
@@ -76,3 +76,3 @@ 'use strict'; | ||
const node2 = await(Node.create(ipfs, null, node1)); | ||
assert.equal(typeof node2.next[0] === 'string', false); | ||
assert.equal(typeof node2.next[0] === 'string', true); | ||
done(); | ||
@@ -173,3 +173,3 @@ })); | ||
const node2 = await(Node.create(ipfs, payload, node1)); | ||
assert.equal(typeof node2.next[0] === 'string', false); | ||
assert.equal(typeof node2.next[0] === 'string', true); | ||
assert.notEqual(node2.asJson, null); | ||
@@ -233,9 +233,2 @@ assert.equal(node2.asJson.payload, payload); | ||
}); | ||
describe('fetchPayload', () => { | ||
it('TODO', async((done) => { | ||
done(); | ||
})); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1191
48756