Commit be536d78f588a72a29acd71fb3ab0fa35b0789eb
updated deps
Signed-off-by: wanderer <mjbecze@gmail.com>wanderer committed on 2/6/2018, 9:32:53 PM
Parent: 1595f393542986eb83bbe2ded2a9af07990574b0
Files changed
index.js | changed |
package-lock.json | changed |
package.json | changed |
tests/index.js | changed |
index.js | |||
---|---|---|---|
@@ -12,20 +12,20 @@ | |||
12 | 12 … | * @param {*} obj | |
13 | 13 … | * @return {integer} | |
14 | 14 … | */ | |
15 | 15 … | add (obj, type) { | |
16 | - return this._map.push(obj) - 1 | ||
16 … | + return this._map.push({obj, type}) - 1 | ||
17 | 17 … | } | |
18 | 18 … | ||
19 | 19 … | /** | |
20 | 20 … | * gets a POJO given a refernce as an int | |
21 | 21 … | * @param {integer} ref | |
22 | 22 … | * @param {Object} type - optional, a contructor that the retreived object should be an instance of | |
23 | 23 … | * @return {*} | |
24 | 24 … | */ | |
25 | - get (ref, type) { | ||
26 | - const obj = this._map[ref] | ||
27 | - if (obj === undefined || (type && type !== obj.constructor)) { | ||
25 … | + get (ref, typeCheck) { | ||
26 … | + const {obj, type} = this._map[ref] | ||
27 … | + if (obj === undefined || (typeCheck && type !== typeCheck)) { | ||
28 | 28 … | throw new Error('invalid referance') | |
29 | 29 … | } | |
30 | 30 … | return obj | |
31 | 31 … | } |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 110756 bytes New file size: 110074 bytes |
package.json | ||
---|---|---|
@@ -27,9 +27,9 @@ | ||
27 | 27 … | "url": "https://github.com/wanderer/referenceMap/issues" |
28 | 28 … | }, |
29 | 29 … | "devDependencies": { |
30 | 30 … | "coveralls": "^3.0.0", |
31 | - "nyc": "^11.3.0", | |
31 … | + "nyc": "^11.4.1", | |
32 | 32 … | "standard": "^10.0.3", |
33 | 33 … | "tape": "^4.8.0" |
34 | 34 … | } |
35 | 35 … | } |
tests/index.js | ||
---|---|---|
@@ -37,12 +37,12 @@ | ||
37 | 37 … | t.true(true, 'should clear refances') |
38 | 38 … | } |
39 | 39 … | |
40 | 40 … | const aMap = new Map() |
41 | - const ref3 = referanceMap.add(aMap) | |
42 | - t.equals(referanceMap.get(ref3, Map), aMap) | |
41 … | + const ref3 = referanceMap.add(aMap, 'set') | |
42 … | + t.equals(referanceMap.get(ref3, 'set'), aMap) | |
43 | 43 … | try { |
44 | - referanceMap.get(ref3, Set) | |
44 … | + referanceMap.get(ref3, 'lol') | |
45 | 45 … | } catch (e) { |
46 | 46 … | t.true(true, 'should throw if wrong type') |
47 | 47 … | } |
48 | 48 … | }) |
Built with git-ssb-web