Commit 159e255779ce023db47837d0b076a8b3e1ad29dc
fix clear
wanderer committed on 4/4/2018, 12:47:09 AMParent: e26440a2d84bce6ce2e97e7fc53f2f0ce009e6e2
Files changed
index.js | changed |
tests/index.js | changed |
index.js | ||
---|---|---|
@@ -42,18 +42,18 @@ | ||
42 | 42 … | * @param {integer} |
43 | 43 … | * @return {boolean} whether or not the object was deleted |
44 | 44 … | */ |
45 | 45 … | delete (ref) { |
46 | - delete this._map[ref][this.intRefProp] | |
46 … | + delete this._map[ref].obj[this.intRefProp] | |
47 | 47 … | delete this._map[ref] |
48 | 48 … | } |
49 | 49 … | |
50 | 50 … | /** |
51 | 51 … | * clears the referance map of a objects |
52 | 52 … | */ |
53 | 53 … | clear () { |
54 | 54 … | this._map.forEach(el => { |
55 | - delete el[this.intRefProp] | |
55 … | + delete el.obj[this.intRefProp] | |
56 | 56 … | }) |
57 | 57 … | this._map = [] |
58 | 58 … | } |
59 | 59 … |
tests/index.js | ||
---|---|---|
@@ -49,4 +49,14 @@ | ||
49 | 49 … | } catch (e) { |
50 | 50 … | t.true(true, 'should throw if wrong type') |
51 | 51 … | } |
52 | 52 … | }) |
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