reference-map
Advanced tools
Comparing version 0.1.0 to 1.0.0
24
API.md
@@ -5,3 +5,3 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
[index.js:5-7](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L5-L7 "Source code on GitHub") | ||
[index.js:5-7](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L5-L7 "Source code on GitHub") | ||
@@ -12,3 +12,3 @@ Handle mapping arbitary JS object to ints | ||
[index.js:15-17](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L15-L17 "Source code on GitHub") | ||
[index.js:15-17](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L15-L17 "Source code on GitHub") | ||
@@ -26,3 +26,3 @@ Adds an object to the referance map returning an int to be used as a | ||
[index.js:24-30](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L24-L30 "Source code on GitHub") | ||
[index.js:24-30](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L24-L30 "Source code on GitHub") | ||
@@ -39,3 +39,3 @@ gets a POJO given a refernce as an int | ||
[index.js:37-39](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L37-L39 "Source code on GitHub") | ||
[index.js:37-39](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L37-L39 "Source code on GitHub") | ||
@@ -53,3 +53,3 @@ deletes an object given a referance as an int | ||
[index.js:44-46](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L44-L46 "Source code on GitHub") | ||
[index.js:44-46](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L44-L46 "Source code on GitHub") | ||
@@ -60,3 +60,3 @@ clears the referance map of a objects | ||
[index.js:52-54](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L52-L54 "Source code on GitHub") | ||
[index.js:52-54](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L52-L54 "Source code on GitHub") | ||
@@ -66,1 +66,13 @@ returns the number of items in the refernace map | ||
Returns **integer** | ||
# has | ||
[index.js:60-63](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L60-L63 "Source code on GitHub") | ||
tests wether a given referance is valid or not | ||
**Parameters** | ||
- `ref` | ||
Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** |
@@ -1,1 +0,1 @@ | ||
{"/home/null/code/referenceMap/index.js":{"path":"/home/null/code/referenceMap/index.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":55,"column":1}},"1":{"start":{"line":6,"column":4},"end":{"line":6,"column":18}},"2":{"start":{"line":16,"column":4},"end":{"line":16,"column":34}},"3":{"start":{"line":25,"column":16},"end":{"line":25,"column":30}},"4":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"5":{"start":{"line":27,"column":6},"end":{"line":27,"column":42}},"6":{"start":{"line":29,"column":4},"end":{"line":29,"column":14}},"7":{"start":{"line":38,"column":4},"end":{"line":38,"column":25}},"8":{"start":{"line":45,"column":4},"end":{"line":45,"column":18}},"9":{"start":{"line":53,"column":4},"end":{"line":53,"column":27}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":2},"end":{"line":5,"column":3}},"loc":{"start":{"line":5,"column":17},"end":{"line":7,"column":3}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":2},"end":{"line":15,"column":3}},"loc":{"start":{"line":15,"column":12},"end":{"line":17,"column":3}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":24,"column":2},"end":{"line":24,"column":3}},"loc":{"start":{"line":24,"column":12},"end":{"line":30,"column":3}},"line":24},"3":{"name":"(anonymous_3)","decl":{"start":{"line":37,"column":2},"end":{"line":37,"column":3}},"loc":{"start":{"line":37,"column":15},"end":{"line":39,"column":3}},"line":37},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":2},"end":{"line":44,"column":3}},"loc":{"start":{"line":44,"column":11},"end":{"line":46,"column":3}},"line":44},"5":{"name":"(anonymous_5)","decl":{"start":{"line":52,"column":2},"end":{"line":52,"column":3}},"loc":{"start":{"line":52,"column":14},"end":{"line":54,"column":3}},"line":52}},"branchMap":{"0":{"loc":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},{"start":{"line":26,"column":4},"end":{"line":28,"column":5}}],"line":26}},"s":{"0":1,"1":1,"2":2,"3":4,"4":4,"5":2,"6":2,"7":1,"8":1,"9":1},"f":{"0":1,"1":2,"2":4,"3":1,"4":1,"5":1},"b":{"0":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"501819713a08e964a8dd82a76a2836b39d1a9a97"}} | ||
{"/home/null/code/referenceMap/index.js":{"path":"/home/null/code/referenceMap/index.js","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":64,"column":1}},"1":{"start":{"line":6,"column":4},"end":{"line":6,"column":18}},"2":{"start":{"line":16,"column":4},"end":{"line":16,"column":34}},"3":{"start":{"line":25,"column":16},"end":{"line":25,"column":30}},"4":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"5":{"start":{"line":27,"column":6},"end":{"line":27,"column":42}},"6":{"start":{"line":29,"column":4},"end":{"line":29,"column":14}},"7":{"start":{"line":38,"column":4},"end":{"line":38,"column":25}},"8":{"start":{"line":45,"column":4},"end":{"line":45,"column":18}},"9":{"start":{"line":53,"column":4},"end":{"line":53,"column":27}},"10":{"start":{"line":61,"column":16},"end":{"line":61,"column":30}},"11":{"start":{"line":62,"column":4},"end":{"line":62,"column":28}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":2},"end":{"line":5,"column":3}},"loc":{"start":{"line":5,"column":17},"end":{"line":7,"column":3}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":2},"end":{"line":15,"column":3}},"loc":{"start":{"line":15,"column":12},"end":{"line":17,"column":3}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":24,"column":2},"end":{"line":24,"column":3}},"loc":{"start":{"line":24,"column":12},"end":{"line":30,"column":3}},"line":24},"3":{"name":"(anonymous_3)","decl":{"start":{"line":37,"column":2},"end":{"line":37,"column":3}},"loc":{"start":{"line":37,"column":15},"end":{"line":39,"column":3}},"line":37},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":2},"end":{"line":44,"column":3}},"loc":{"start":{"line":44,"column":11},"end":{"line":46,"column":3}},"line":44},"5":{"name":"(anonymous_5)","decl":{"start":{"line":52,"column":2},"end":{"line":52,"column":3}},"loc":{"start":{"line":52,"column":14},"end":{"line":54,"column":3}},"line":52},"6":{"name":"(anonymous_6)","decl":{"start":{"line":60,"column":2},"end":{"line":60,"column":3}},"loc":{"start":{"line":60,"column":12},"end":{"line":63,"column":3}},"line":60}},"branchMap":{"0":{"loc":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},{"start":{"line":26,"column":4},"end":{"line":28,"column":5}}],"line":26}},"s":{"0":1,"1":1,"2":2,"3":4,"4":4,"5":2,"6":2,"7":1,"8":1,"9":1,"10":2,"11":2},"f":{"0":1,"1":2,"2":4,"3":1,"4":1,"5":1,"6":2},"b":{"0":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"dc2c534631bc44935676d095c93dedca20a26eff"}} |
11
index.js
@@ -26,3 +26,3 @@ module.exports = class ReferanceMap { | ||
const obj = this._map[ref] | ||
if (!obj) { | ||
if (obj === undefined) { | ||
throw new Error('invalid referance') | ||
@@ -56,2 +56,11 @@ } | ||
} | ||
/** | ||
* tests wether a given referance is valid or not | ||
* @return {boolean} | ||
*/ | ||
has (ref) { | ||
const obj = this._map[ref] | ||
return obj !== undefined | ||
} | ||
} |
{ | ||
"name": "reference-map", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "This is a simple determinstic map that maps POJOs to an integer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,3 +17,3 @@ [![NPM Package](https://img.shields.io/npm/v/reference-map.svg?style=flat-square)](https://www.npmjs.org/package/reference-map) | ||
[index.js:5-7](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L5-L7 "Source code on GitHub") | ||
[index.js:5-7](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L5-L7 "Source code on GitHub") | ||
@@ -24,3 +24,3 @@ Handle mapping arbitary JS object to ints | ||
[index.js:15-17](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L15-L17 "Source code on GitHub") | ||
[index.js:15-17](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L15-L17 "Source code on GitHub") | ||
@@ -38,3 +38,3 @@ Adds an object to the referance map returning an int to be used as a | ||
[index.js:24-30](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L24-L30 "Source code on GitHub") | ||
[index.js:24-30](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L24-L30 "Source code on GitHub") | ||
@@ -51,3 +51,3 @@ gets a POJO given a refernce as an int | ||
[index.js:37-39](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L37-L39 "Source code on GitHub") | ||
[index.js:37-39](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L37-L39 "Source code on GitHub") | ||
@@ -65,3 +65,3 @@ deletes an object given a referance as an int | ||
[index.js:44-46](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L44-L46 "Source code on GitHub") | ||
[index.js:44-46](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L44-L46 "Source code on GitHub") | ||
@@ -72,3 +72,3 @@ clears the referance map of a objects | ||
[index.js:52-54](https://github.com/wanderer/referanceMap/blob/31b26dc43440dd6bb683c2f0e63e413890f26274/index.js#L52-L54 "Source code on GitHub") | ||
[index.js:52-54](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L52-L54 "Source code on GitHub") | ||
@@ -79,3 +79,15 @@ returns the number of items in the refernace map | ||
## has | ||
[index.js:60-63](https://github.com/wanderer/referanceMap/blob/e1f2c200e1e82a761064a31fb0aebf800a54e6ea/index.js#L60-L63 "Source code on GitHub") | ||
tests wether a given referance is valid or not | ||
**Parameters** | ||
- `ref` | ||
Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** | ||
# LICENSE | ||
[MPL-2.0](https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)) |
@@ -5,3 +5,3 @@ const tape = require('tape') | ||
tape('referance mapping', t => { | ||
t.plan(7) | ||
t.plan(9) | ||
const referanceMap = new ReferanceMap() | ||
@@ -15,2 +15,4 @@ const obj1 = {} | ||
t.equals(referanceMap.has(ref1), true, 'should detect if it has the ref') | ||
const foundObj1 = referanceMap.get(ref1) | ||
@@ -31,2 +33,4 @@ const foundObj2 = referanceMap.get(ref2) | ||
t.equals(referanceMap.has(ref1), false, 'should detect if it does not has the ref') | ||
referanceMap.clear() | ||
@@ -33,0 +37,0 @@ try { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
50281
504
1
87