# habitants-location

> location object helper for 2d cartesian coordinates

Latest version **0.0.2** (published 2014-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install habitants-location
pnpm add habitants-location
yarn add habitants-location
bun add habitants-location
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2014-11-28 |
| First published | 2014-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alexander Vados |
| Maintainers | alexander-daniel |

## Links

- npm: https://www.npmjs.com/package/habitants-location
- npm.io page: https://npm.io/package/habitants-location

## Dependencies (2)

- [tap](https://npm.io/package/tap.md) ^0.4.13
- [tape](https://npm.io/package/tape.md) ^3.0.3

## Recent versions

- 0.0.2 (latest) — 2014-11-28
- 0.0.1 — 2014-11-28

## README

# Location
[![Build Status](https://travis-ci.org/habitants/location.svg?branch=master)](https://travis-ci.org/habitants/location)

A helper module for dealing with locations. You can assign these to units, tiles, whatever.

# Example
```javascript
var Location = require('location');

var myLocation = new Location('2:3');
var hugeArrayOfLocations = [location, ...]

hugeArrayOfLocations.forEach(function (location) {
    if (myLocation.isEqualTo(location)) return 'Same Location!' + location;
    else return 'Not the same Location!' + location;
});
```

# Methods
```bash
var Location = require('location');
```


## var location = new Location(x, y)
Returns a `Location` object at `(x, y)`.

Also accepts `String` input:

```javascript
var loc = new Location('8:8')`
```

is equivalent to:

```javascript
var loc = new Location(8,8)
```

## location.toString()
Returns (x,y) coordinates as a string, separated by a colon.

```javascript
var location = new Location(5, 4);
location.toString() -> '5:4'
```

## location.isEqualTo(location)
Compare two location objects, and it will return a `boolean`.

Both `x` and `y` values must match to be `true`.

```javascript
var location1 = new Location(5, 4);
var location2 = new Location(5, 4);

location1.isEqualTo(location2) -> true

var location3 = new Location(2, 8);
var location4 = new Location(2, 2);

location3.isEqualTo(location4) -> false
```

## location.isNextTo(location)
Compare two location objects. If adjacent, returns `true`.

```javascript
var location1 = new Location(5, 4);
var location2 = new Location(5, 3);

location1.isNextTo(location2) -> true
```

## location.copy()
Returns a new instance of `Location` with the same values.

# Installation
```
npm install habitants-location
```

# Tests
```bash
npm test
```

---
_Source: https://npm.io/package/habitants-location · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
