Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coordinate-set

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coordinate-set - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

13

dist/coordinate-set.d.ts

@@ -7,11 +7,20 @@ export declare class CoordinateSet {

private _validateCoordinate;
[Symbol.iterator](): Generator<[number, number][], void, unknown>;
entries(): Generator<[number, number][], void, unknown>;
[Symbol.iterator](): Generator<[number, number], void, unknown>;
/** The entries() method returns a new Iterator object that contains an array of [value, value] */
entries(): {
[Symbol.iterator]: () => Generator<[number, number][], void, unknown>;
};
/** Executes a provided function once for each set coordinate. */
forEach(callback: (value: [number, number], index: number, set: CoordinateSet) => void): void;
/** Gets the number of coordinates in the set */
get size(): number;
set size(value: number);
/** Determines if a given coordinate is present in the set */
has(coordinate: [number, number]): boolean;
/** Adds a passed coordinate to the set */
add(coordinate: [number, number]): this;
/** Deletes a coordinate from the set */
delete(coordinate: [number, number]): boolean;
/** Removes all coordinates from the set */
clear(): void;
}

2

dist/coordinate-set.modern.js

@@ -1,2 +0,2 @@

let t;t=Symbol.iterator;class e{constructor(t){this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(t)?(t.forEach(t=>{this._validateCoordinate(t),this._map.set(this._getKey(t),t)}),this._size=t.length):t instanceof e?(t.forEach(t=>{this._map.set(this._getKey(t),t)}),this._size=t.size):this._size=0}_getKey(t){return`${t[0]},${t[1]}`}_validateCoordinate([t,e]){if(!("number"==typeof t&&!isNaN(t)&&t>=-180&&t<=180))throw new Error("Longitude must be valid");if(!("number"==typeof e&&!isNaN(e)&&e>=-90&&e<=90))throw new Error("Latitude must be valid")}*[t](){for(let t of this._map.entries())yield[t[1],t[1]]}entries(){return this[Symbol.iterator]()}forEach(t){[...this.entries()].forEach((e,i)=>{t(e[0],i,this)})}get size(){return this._size}set size(t){}has(t){return this._validateCoordinate(t),Boolean(this._map.get(this._getKey(t)))}add(t){this._validateCoordinate(t);const e=this._getKey(t);if(!this._map.get(e))return this._size++,this._map.set(e,t),this}delete(t){this._validateCoordinate(t);const e=this._getKey(t);return!!this._map.get(e)&&(this._size--,this._map.delete(e))}clear(){this._map=new Map,this._size=0}}export{e as CoordinateSet};
let t;t=Symbol.iterator;class e{constructor(t){this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(t)?(t.forEach(t=>{this._validateCoordinate(t),this._map.set(this._getKey(t),t)}),this._size=t.length):t instanceof e?(t.forEach(t=>{this._map.set(this._getKey(t),t)}),this._size=t.size):this._size=0}_getKey(t){return`${t[0]},${t[1]}`}_validateCoordinate([t,e]){if(!("number"==typeof t&&!isNaN(t)&&t>=-180&&t<=180))throw new Error(`Longitude must be valid (${t})`);if(!("number"==typeof e&&!isNaN(e)&&e>=-90&&e<=90))throw new Error(`Latitude must be valid (${e})`)}*[t](){for(let t of this._map.entries())yield t[1]}entries(){const t=()=>this._map.entries();return{[Symbol.iterator]:function*(){for(let e of t())yield[e[1],e[1]]}}}forEach(t){[...this.entries()].forEach((e,i)=>{t(e[0],i,this)})}get size(){return this._size}set size(t){}has(t){return this._validateCoordinate(t),Boolean(this._map.get(this._getKey(t)))}add(t){this._validateCoordinate(t);const e=this._getKey(t);if(!this._map.get(e))return this._size++,this._map.set(e,t),this}delete(t){this._validateCoordinate(t);const e=this._getKey(t);return!!this._map.get(e)&&(this._size--,this._map.delete(e))}clear(){this._map=new Map,this._size=0}}export{e as CoordinateSet};
//# sourceMappingURL=coordinate-set.modern.js.map

@@ -1,2 +0,2 @@

function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r;r=Symbol.iterator;var n=/*#__PURE__*/function(){function t(e){var r=this;this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(e)?(e.forEach(function(t){r._validateCoordinate(t),r._map.set(r._getKey(t),t)}),this._size=e.length):e instanceof t?(e.forEach(function(t){r._map.set(r._getKey(t),t)}),this._size=e.size):this._size=0}var n,i,a=t.prototype;return a._getKey=function(t){return t[0]+","+t[1]},a._validateCoordinate=function(t){var e=t[0],r=t[1];if(!("number"==typeof e&&!isNaN(e)&&e>=-180&&e<=180))throw new Error("Longitude must be valid");if(!("number"==typeof r&&!isNaN(r)&&r>=-90&&r<=90))throw new Error("Latitude must be valid")},a[r]=/*#__PURE__*/regeneratorRuntime.mark(function t(){var r,n,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=e(this._map.entries());case 1:if((n=r()).done){t.next=7;break}return i=n.value,t.next=5,[i[1],i[1]];case 5:t.next=1;break;case 7:case"end":return t.stop()}},t,this)}),a.entries=function(){return this[Symbol.iterator]()},a.forEach=function(t){var e=this;[].concat(this.entries()).forEach(function(r,n){t(r[0],n,e)})},a.has=function(t){return this._validateCoordinate(t),Boolean(this._map.get(this._getKey(t)))},a.add=function(t){this._validateCoordinate(t);var e=this._getKey(t);if(!this._map.get(e))return this._size++,this._map.set(e,t),this},a.delete=function(t){this._validateCoordinate(t);var e=this._getKey(t);return!!this._map.get(e)&&(this._size--,this._map.delete(e))},a.clear=function(){this._map=new Map,this._size=0},n=t,(i=[{key:"size",get:function(){return this._size},set:function(t){}}])&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),t}();export{n as CoordinateSet};
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function t(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r;r=Symbol.iterator;var n=/*#__PURE__*/function(){function e(t){var r=this;this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(t)?(t.forEach(function(e){r._validateCoordinate(e),r._map.set(r._getKey(e),e)}),this._size=t.length):t instanceof e?(t.forEach(function(e){r._map.set(r._getKey(e),e)}),this._size=t.size):this._size=0}var n,i,a=e.prototype;return a._getKey=function(e){return e[0]+","+e[1]},a._validateCoordinate=function(e){var t=e[0],r=e[1];if(!("number"==typeof t&&!isNaN(t)&&t>=-180&&t<=180))throw new Error("Longitude must be valid ("+t+")");if(!("number"==typeof r&&!isNaN(r)&&r>=-90&&r<=90))throw new Error("Latitude must be valid ("+r+")")},a[r]=/*#__PURE__*/regeneratorRuntime.mark(function e(){var r,n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:r=t(this._map.entries());case 1:if((n=r()).done){e.next=7;break}return i=n.value,e.next=5,i[1];case 5:e.next=1;break;case 7:case"end":return e.stop()}},e,this)}),a.entries=function(){var e,r=this;return(e={})[Symbol.iterator]=/*#__PURE__*/regeneratorRuntime.mark(function e(){var n,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t(r._map.entries());case 1:if((i=n()).done){e.next=7;break}return a=i.value,e.next=5,[a[1],a[1]];case 5:e.next=1;break;case 7:case"end":return e.stop()}},e)}),e},a.forEach=function(e){var t=this;[].concat(this.entries()).forEach(function(r,n){e(r[0],n,t)})},a.has=function(e){return this._validateCoordinate(e),Boolean(this._map.get(this._getKey(e)))},a.add=function(e){this._validateCoordinate(e);var t=this._getKey(e);if(!this._map.get(t))return this._size++,this._map.set(t,e),this},a.delete=function(e){this._validateCoordinate(e);var t=this._getKey(e);return!!this._map.get(t)&&(this._size--,this._map.delete(t))},a.clear=function(){this._map=new Map,this._size=0},n=e,(i=[{key:"size",get:function(){return this._size},set:function(e){}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),e}();export{n as CoordinateSet};
//# sourceMappingURL=coordinate-set.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).coordinateSet={})}(this,function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n;n=Symbol.iterator,e.CoordinateSet=/*#__PURE__*/function(){function e(t){var r=this;this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(t)?(t.forEach(function(e){r._validateCoordinate(e),r._map.set(r._getKey(e),e)}),this._size=t.length):t instanceof e?(t.forEach(function(e){r._map.set(r._getKey(e),e)}),this._size=t.size):this._size=0}var t,i,o=e.prototype;return o._getKey=function(e){return e[0]+","+e[1]},o._validateCoordinate=function(e){var t=e[0],r=e[1];if(!("number"==typeof t&&!isNaN(t)&&t>=-180&&t<=180))throw new Error("Longitude must be valid");if(!("number"==typeof r&&!isNaN(r)&&r>=-90&&r<=90))throw new Error("Latitude must be valid")},o[n]=/*#__PURE__*/regeneratorRuntime.mark(function e(){var t,n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=r(this._map.entries());case 1:if((n=t()).done){e.next=7;break}return i=n.value,e.next=5,[i[1],i[1]];case 5:e.next=1;break;case 7:case"end":return e.stop()}},e,this)}),o.entries=function(){return this[Symbol.iterator]()},o.forEach=function(e){var t=this;[].concat(this.entries()).forEach(function(r,n){e(r[0],n,t)})},o.has=function(e){return this._validateCoordinate(e),Boolean(this._map.get(this._getKey(e)))},o.add=function(e){this._validateCoordinate(e);var t=this._getKey(e);if(!this._map.get(t))return this._size++,this._map.set(t,e),this},o.delete=function(e){this._validateCoordinate(e);var t=this._getKey(e);return!!this._map.get(t)&&(this._size--,this._map.delete(t))},o.clear=function(){this._map=new Map,this._size=0},t=e,(i=[{key:"size",get:function(){return this._size},set:function(e){}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),Object.defineProperty(t,"prototype",{writable:!1}),e}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).coordinateSet={})}(this,function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n;n=Symbol.iterator,e.CoordinateSet=/*#__PURE__*/function(){function e(t){var r=this;this._size=void 0,this._map=void 0,this._map=new Map,Array.isArray(t)?(t.forEach(function(e){r._validateCoordinate(e),r._map.set(r._getKey(e),e)}),this._size=t.length):t instanceof e?(t.forEach(function(e){r._map.set(r._getKey(e),e)}),this._size=t.size):this._size=0}var t,i,a=e.prototype;return a._getKey=function(e){return e[0]+","+e[1]},a._validateCoordinate=function(e){var t=e[0],r=e[1];if(!("number"==typeof t&&!isNaN(t)&&t>=-180&&t<=180))throw new Error("Longitude must be valid ("+t+")");if(!("number"==typeof r&&!isNaN(r)&&r>=-90&&r<=90))throw new Error("Latitude must be valid ("+r+")")},a[n]=/*#__PURE__*/regeneratorRuntime.mark(function e(){var t,n,i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=r(this._map.entries());case 1:if((n=t()).done){e.next=7;break}return i=n.value,e.next=5,i[1];case 5:e.next=1;break;case 7:case"end":return e.stop()}},e,this)}),a.entries=function(){var e,t=this;return(e={})[Symbol.iterator]=/*#__PURE__*/regeneratorRuntime.mark(function e(){var n,i,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=r(t._map.entries());case 1:if((i=n()).done){e.next=7;break}return a=i.value,e.next=5,[a[1],a[1]];case 5:e.next=1;break;case 7:case"end":return e.stop()}},e)}),e},a.forEach=function(e){var t=this;[].concat(this.entries()).forEach(function(r,n){e(r[0],n,t)})},a.has=function(e){return this._validateCoordinate(e),Boolean(this._map.get(this._getKey(e)))},a.add=function(e){this._validateCoordinate(e);var t=this._getKey(e);if(!this._map.get(t))return this._size++,this._map.set(t,e),this},a.delete=function(e){this._validateCoordinate(e);var t=this._getKey(e);return!!this._map.get(t)&&(this._size--,this._map.delete(t))},a.clear=function(){this._map=new Map,this._size=0},t=e,(i=[{key:"size",get:function(){return this._size},set:function(e){}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,i),Object.defineProperty(t,"prototype",{writable:!1}),e}()});
//# sourceMappingURL=coordinate-set.umd.js.map
{
"name": "coordinate-set",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Set that treats coordinate arrays like values rather than references",

@@ -5,0 +5,0 @@ "author": "James Milner",

import { CoordinateSet } from "./coordinate-set";
describe("CoordinateSet", () => {
describe("constuctor does not throw", () => {
it("no argument doesn't throw", () => {
expect(() => {
new CoordinateSet();
}).not.toThrowError();
});
describe("constuctor ", () => {
describe("does not throw", () => {
it("with no argument", () => {
expect(() => {
new CoordinateSet();
}).not.toThrowError();
});
it("array argument doesn't throw", () => {
expect(() => {
new CoordinateSet([[0.1, 0.2]]);
}).not.toThrowError();
});
it("with coordinate array argument", () => {
expect(() => {
new CoordinateSet([[0.1, 0.2]]);
}).not.toThrowError();
});
it("non array argument", () => {
expect(() => {
new CoordinateSet(1 as any);
}).not.toThrowError();
it("with non array argument", () => {
expect(() => {
new CoordinateSet(1 as any);
}).not.toThrowError();
});
it("with CoordinateSet argument", () => {
expect(() => {
new CoordinateSet(new CoordinateSet());
}).not.toThrowError();
});
});
it("CoordinateSet is passed", () => {
expect(() => {
new CoordinateSet(new CoordinateSet());
}).not.toThrowError();
describe("uses value", () => {
it("coordinate array", () => {
const set = new CoordinateSet([[0.1, 0.2]]);
expect(set.has([0.1, 0.2])).toBe(true);
});
});

@@ -71,8 +80,8 @@ });

it("entries", () => {
it("entries - for of", () => {
const set = new CoordinateSet(input);
const iterator1 = set.entries();
const iterator = set.entries();
let values = [];
for (const entry of iterator1) {
for (const entry of iterator) {
values.push(entry);

@@ -96,2 +105,22 @@ }

});
it("entries - spread", () => {
const set = new CoordinateSet(input);
const iterator = set.entries();
expect([...iterator]).toStrictEqual([
[
[0, 0],
[0, 0],
],
[
[1, 1],
[1, 1],
],
[
[2, 2],
[2, 2],
],
]);
});
});

@@ -98,0 +127,0 @@

@@ -32,7 +32,7 @@ export class CoordinateSet {

) {
throw new Error("Longitude must be valid");
throw new Error(`Longitude must be valid (${lng})`);
} else if (
!(typeof lat === "number" && !isNaN(lat) && lat >= -90 && lat <= 90)
) {
throw new Error("Latitude must be valid");
throw new Error(`Latitude must be valid (${lat})`);
}

@@ -49,9 +49,14 @@ }

entries() {
const map = this._map;
const getEntries = () => {
return this._map.entries();
};
const iterator = function* () {
for (let entry of getEntries()) {
yield [entry[1], entry[1]];
}
};
return {
[Symbol.iterator]: function* () {
for (let entry of map.entries()) {
yield [entry[1], entry[1]];
}
},
[Symbol.iterator]: iterator,
};

@@ -58,0 +63,0 @@ }

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc