# @warriorjs/geography

> WarriorJS directioning

Latest version **0.7.0** (published 2018-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @warriorjs/geography
pnpm add @warriorjs/geography
yarn add @warriorjs/geography
bun add @warriorjs/geography
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.7.0 |
| Published | 2018-07-06 |
| First published | 2018-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9542 |
| Author | Matias Olivera |
| Maintainers | olistic |

## Links

- npm: https://www.npmjs.com/package/@warriorjs/geography
- Repository: https://github.com/olistic/warriorjs/tree/master/packages/warriorjs-geography
- Homepage: https://warrior.js.org/
- npm.io page: https://npm.io/package/@warriorjs/geography

## Recent versions

- 0.7.0 (latest) — 2018-07-06
- 0.6.0 — 2018-06-17
- 0.4.0 — 2018-05-20
- 0.1.0 — 2018-05-03

## README

# @warriorjs/geography

> WarriorJS directioning.

## Install

```sh
npm install @warriorjs/geography
```

## Usage

```js
import { FORWARD, getAbsoluteDirection } from '@warriorjs/geography');
```

## Top Level Exports

All methods in the API Reference below, plus the following constants:

### `NORTH` _(string)_

A constant representing absolute direction north.

### `EAST` _(string)_

A constant representing absolute direction east.

### `SOUTH` _(string)_

A constant representing absolute direction south.

### `WEST` _(string)_

A constant representing absolute direction west.

### `ABSOLUTE_DIRECTIONS` _(string[])_

The absolute directions in clockwise order.

### `FORWARD` _(string)_

A constant representing relative direction forward.

### `RIGHT` _(string)_

A constant representing relative direction right.

### `BACKWARD` _(string)_

A constant representing relative direction backward.

### `LEFT` _(string)_

A constant representing relative direction left.

### `RELATIVE_DIRECTIONS` _(string[])_

The relative directions in clockwise order.

## API Reference

### `getAbsoluteDirection(direction: string, referenceDirection: string)`

Returns the absolute direction for a given direction, with reference to another
direction (reference direction).

### `getAbsoluteOffset(relativeOffset: number[], referenceDirection: string)`

Returns the absolute offset for a given relative offset with reference to a
given direction (reference direction).

### `getDirectionOfLocation(location: number[], referenceLocation: number[])`

Returns the direction of a location from another location (reference location).

### `getDistanceOfLocation(location: number[], referenceLocation: number[])`

Returns the Manhattan distance of a location from another location (reference
location).

### `getRelativeDirection(direction: string, referenceDirection: string)`

Returns the relative direction for a given direction, with reference to a
another direction (reference direction).

### `getRelativeOffset(location: number[], referenceLocation: number[], referenceDirection: string)`

Returns the relative offset for a given location, with reference to another
location (reference location) and direction (reference direction).

### `rotateRelativeOffset(offset: number[], direction: string)`

Rotates the given relative offset in the given direction.

### `translateLocation(location: number[], offset: number[])`

Translates the given location by a given offset.

### `verifyAbsoluteDirection(direction: string)`

Checks if the given direction is a valid absolute direction.

### `verifyRelativeDirection(direction: string)`

Checks if the given direction is a valid relative direction.

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