git ssb

0+

wanderer🌟 / referenceMap



Commit 159e255779ce023db47837d0b076a8b3e1ad29dc

fix clear

wanderer committed on 4/4/2018, 12:47:09 AM
Parent: e26440a2d84bce6ce2e97e7fc53f2f0ce009e6e2

Files changed

index.jschanged
tests/index.jschanged
index.jsView
@@ -42,18 +42,18 @@
4242 * @param {integer}
4343 * @return {boolean} whether or not the object was deleted
4444 */
4545 delete (ref) {
46- delete this._map[ref][this.intRefProp]
46 + delete this._map[ref].obj[this.intRefProp]
4747 delete this._map[ref]
4848 }
4949
5050 /**
5151 * clears the referance map of a objects
5252 */
5353 clear () {
5454 this._map.forEach(el => {
55- delete el[this.intRefProp]
55 + delete el.obj[this.intRefProp]
5656 })
5757 this._map = []
5858 }
5959
tests/index.jsView
@@ -49,4 +49,14 @@
4949 } catch (e) {
5050 t.true(true, 'should throw if wrong type')
5151 }
5252 })
53 +
54 +tape('failures', t => {
55 + const referanceMap = new ReferanceMap()
56 + const buf = Buffer.from('hello')
57 + referanceMap.add(buf)
58 + referanceMap.clear()
59 + const ref = referanceMap.add(buf)
60 + t.deepEquals(referanceMap.get(ref), buf)
61 + t.end()
62 +})

Built with git-ssb-web