git ssb

0+

wanderer🌟 / referenceMap



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.jschanged
package-lock.jsonchanged
package.jsonchanged
tests/index.jschanged
index.jsView
@@ -12,20 +12,20 @@
1212 * @param {*} obj
1313 * @return {integer}
1414 */
1515 add (obj, type) {
16- return this._map.push(obj) - 1
16 + return this._map.push({obj, type}) - 1
1717 }
1818
1919 /**
2020 * gets a POJO given a refernce as an int
2121 * @param {integer} ref
2222 * @param {Object} type - optional, a contructor that the retreived object should be an instance of
2323 * @return {*}
2424 */
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)) {
2828 throw new Error('invalid referance')
2929 }
3030 return obj
3131 }
package-lock.jsonView
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.jsonView
@@ -27,9 +27,9 @@
2727 "url": "https://github.com/wanderer/referenceMap/issues"
2828 },
2929 "devDependencies": {
3030 "coveralls": "^3.0.0",
31- "nyc": "^11.3.0",
31 + "nyc": "^11.4.1",
3232 "standard": "^10.0.3",
3333 "tape": "^4.8.0"
3434 }
3535 }
tests/index.jsView
@@ -37,12 +37,12 @@
3737 t.true(true, 'should clear refances')
3838 }
3939
4040 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)
4343 try {
44- referanceMap.get(ref3, Set)
44 + referanceMap.get(ref3, 'lol')
4545 } catch (e) {
4646 t.true(true, 'should throw if wrong type')
4747 }
4848 })

Built with git-ssb-web