New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jscoord

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscoord - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

4

index.js
module.exports = {
JSCoord: require("./src/JSCoord"),
CoordChunk: require("./src/CoordChunk")
}
CoordChunk: require("./src/CoordChunk"),
}
{
"name": "jscoord",
"version": "0.0.17",
"version": "0.0.18",
"description": "A simple Map coordinate system for NodeJS and potentially the browser.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -91,3 +91,3 @@ # JSCoord

#### `.getMapJSON()`
#### `.mapJSON`

@@ -97,6 +97,6 @@ Get Map as Object.

```js
coords.getMapJSON() // {x: 20, y: 0, z: 0}
coords.mapJSON // {x: 20, y: 0, z: 0}
```
#### `.getMapArray()`
#### `.mapArray`

@@ -106,6 +106,6 @@ Get Map as Array.

```js
coords.getMapArray() // [x, y, z]
coords.mapArray // [x, y, z]
```
#### `.getJSON()`
#### `.JSON`

@@ -115,11 +115,11 @@ Returns the X, Y and Z axis values as an object.

```js
coords.getJSON() // {x: 20, y: 0, z: 0}
coords.JSON // {x: 20, y: 0, z: 0}
```
#### `.getArray()`
#### `.array`
Returns the X, Y and Z axis values as an array. `.getArray()[0]` contains the X axis, `.getArray()[1]` the Y axis and `.getArray()[2]` the Z axis.
Returns the X, Y and Z axis values as an array. `.array[0]` contains the X axis, `.array[1]` the Y axis and `.array[2]` the Z axis.
```js
coords.getArray() // [x, y, z]
coords.array // [x, y, z]
```

@@ -143,3 +143,3 @@

#### `.getRltJSON()`
#### `.rltJSON`

@@ -149,6 +149,6 @@ Get the relativity set as an object.

```js
coords.getRltJSON() // {x: 1, y: 2, z: 3}
coords.rltJSON // {x: 1, y: 2, z: 3}
```
#### `.getRltArray()`
#### `.rltArray`

@@ -158,3 +158,3 @@ Get the relativity set as an array.

```js
coords.getRltArray() // [x, y, z]
coords.rltArray // [x, y, z]
```

@@ -161,0 +161,0 @@

const JSCoord = require("./JSCoord")
class CoordChunk {
/**
/**
* Create a new Coordinate Chunk.

@@ -8,74 +8,67 @@ * @param {Number[]} boundaries

*/
constructor (maxLength = Infinity) {
this.limit = maxLength
this.sets = []
}
/**
constructor (maxLength = Infinity) {
this.limit = maxLength
this.sets = []
}
/**
* Add a Set to the Chunk.
* @param {Number[]|JSCoord} coords
*/
addSet (coords) {
if (
(this.sets.findIndex(t => { return t.x == coords.x && t.y == coords.y && t.z == coords.z }) > -1) ||
addSet (coords) {
if (
(this.sets.findIndex(t => t.x == coords.x && t.y == coords.y && t.z == coords.z) > -1) ||
(this.limit < this.sets.length + 1)
) {
throw new Error("Invaild coordinates or maximum Chunk size reached.")
return
} else {
if (coords instanceof JSCoord) {
this.sets.push(coords)
} else {
this.sets.push(new JSCoord(coords))
}
return this
}
}
/**
) {
throw new Error("Invaild coordinates or maximum Chunk size reached.")
} else {
if (coords instanceof JSCoord) {
this.sets.push(coords)
} else {
this.sets.push(new JSCoord(coords))
}
return this
}
}
/**
* Get a Set from the Chunk.
* @param {Number[]} coords
* @param {Number[]} coords
* @returns {JSCoord}
*/
getSet (coords) {
let item = this.sets.find(t => { return t.x == coords[0] && t.y == coords[1] && t.z == coords[2] })
if (item) {
return item
} else {
throw new Error("Set not found in Chunk.")
return
}
}
/**
getSet (coords) {
let item = this.sets.find(t => t.x == coords[0] && t.y == coords[1] && t.z == coords[2])
if (item) {
return item
} else {
throw new Error("Set not found in Chunk.")
}
}
/**
* Delete a Set from the Chunk.
* @param {Number[]|JSCoord} coords
* @param {Number[]|JSCoord} coords
* @returns {JSCoord}
*/
delSet (coords) {
var index
if (coords instanceof JSCoord) {
var index = this.sets.findIndex(t => {
return (
t.x == coords.x &&
delSet (coords) {
var index
if (coords instanceof JSCoord) {
index = this.sets.findIndex(t =>
t.x == coords.x &&
t.y == coords.y &&
t.z == coords.z
)
})
} else {
var index = this.sets.findIndex(t => {
return (
t.x == coords[0] &&
)
} else {
index = this.sets.findIndex(t =>
t.x == coords[0] &&
t.y == coords[1] &&
t.z == coords[2]
)
})
}
if (index > -1) {
this.sets.splice(index, 1)
return this
} else {
throw new Error("Set not found in Chunk.")
return
}
}
)
}
if (index > -1) {
this.sets.splice(index, 1)
return this
} else {
throw new Error("Set not found in Chunk.")
}
}
}
module.exports = CoordChunk
module.exports = CoordChunk

@@ -104,6 +104,6 @@ class JSCoord {

}
getArray () {
get array () {
return [this.x, this.y, this.z]
}
getJSON () {
get JSON () {
return {

@@ -132,3 +132,3 @@ x: this.x,

*/
getMapArray () {
get mapArray () {
return [this.map.x, this.map.y, this.map.z]

@@ -139,3 +139,3 @@ }

*/
getMapArray () {
get mapJSON () {
return this.map

@@ -172,40 +172,57 @@ }

}
}
/**
}
/**
* Resets x, y, z to 0.
*/
reset () {
this.x = 0
this.y = 0
this.z = 0
return this
}
/**
reset () {
this.x = 0
this.y = 0
this.z = 0
return this
}
/**
* Get value difference of 2 coordinate sets.
* @param {Number} x
* @param {Number} y
* @param {Number} z
* @param {Number} x
* @param {Number} y
* @param {Number} z
*/
rlt (x, y, z) {
this.relativitySet = {
x: x - this.x,
y: y - this.y,
z: z - this.z
}
return this
}
/**
rlt (x, y, z) {
this.relativitySet = {
x: x - this.x,
y: y - this.y,
z: z - this.z,
}
return this
}
/**
* Get the calculated relativity as an object.
*/
getRltJSON () {
return this.relativitySet
}
/**
get rltJSON () {
return this.relativitySet
}
/**
* Get the calculated relativity as an array.
*/
getRltArray () {
return [this.relativitySet.x, this.relativitySet.y, this.relativitySet.z]
get rltArray () {
return [this.relativitySet.x, this.relativitySet.y, this.relativitySet.z]
}
/**
*
* @param {String} set
* Get the angle of 2 coordinate set values.
*/
getRltAngle (set) {
if (set.toLowerCase() == "xy" || set.toLowerCase() == "yx") {
return Math.atan(this.relativitySet.y / this.relativitySet.x) * 180 / Math.PI
}
if (set.toLowerCase() == "yz" || set.toLowerCase() == "zy") {
return Math.atan(this.relativitySet.z / this.relativitySet.y) * 180 / Math.PI
}
if (set.toLowerCase() == "zx" || set.toLowerCase() == "xz") {
return Math.atan(this.relativitySet.x / this.relativitySet.z) * 180 / Math.PI
}
return undefined
}
}
module.exports = JSCoord
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