
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
cardinal-direction
Advanced tools
Each of the 4 main compass quadrants (N,E,S,W), contain 7 sub-regions. This tool can be used to convert a degree ranging from 0-360 to a correlated cardinal direction.
Example of North Quadrant Cardinal Directions
See CardinalDirection for the full list.
npm install cardinal-direction
const Compass = require("cardinal-direction");
Converts a compass degree value into its correlated cardinal value.
| Param | Type | Required | Description |
|---|---|---|---|
| degree | number | yes | A number between 0 and 360. |
| subset | CardinalSubset | no | Restricts the return value to a subset of the possible cardinal directions. The default is Full. See CardinalSubset for more. |
/*
* Basic usage.
* - returns "SW"
*/
Compass.cardinalFromDegree(221);
/*
* Restricting results with subset.
* - returns "W"
*/
Compass.cardinalFromDegree(221, Compass.CardinalSubset.Basic);
Converts a cardinal direction into its correlated degree value.
| Param | Type | Required | Description |
|---|---|---|---|
| cardinal | CardinalDirection | yes | One of the possible cardinal directions. See CardinalDirection for more. |
/*
* These all return 90.
*/
Compass.degreeFromCardinal("E");
Compass.degreeFromCardinal(Compass.CardinalDirection["E"]);
Compass.degreeFromCardinal(Compass.CardinalDirection.E);
Compass.degreeFromCardinal(Compass.CardinalDirection[8]);
Compass.degreeFromCardinal(8);
Converts a cardinal value to either its abbreviation or full title.
| Param | Type | Required | Description |
|---|---|---|---|
| cardinal | string/number | yes | One of the CardinalDirection enum member values, or its full title. See Cardinal Table for context. |
Compass.cardinalConverter(3): // NEbN
Compass.cardinalConverter("NEbN"): // Northeast by North
Compass.cardinalConverter("Northeast by North"); // NEbN
This subset enum can be used to fine tune the return value of cardinalFromDegree. When used the specified degree will be pushed to the nearest accepted cardinal direction, based on your restriction.
| Value | Description |
|---|---|
| Full | Enables all possible cardinal directions to be retuned. Default |
| Basic | Restricts the possible returned cardinals to N,E,S,W. |
| Ordinal | Extends Basic to include NE,SE,SW,NW,. |
| Intercardinal | Extends Ordinal to include NNE,ENE,ESE,SSE,SSW,WSW,WNW,NNW. |
There are 32 cardinal directions on a compass. But this numeric enum is 0 indexed.
Compass.CardinalDirection[0]; // "N"
Compass.CardinalDirection["N"]; // 0
Compass.CardinalDirection.N; // 0
| Integer | Abbreviation | Title |
|---|---|---|
| 0 | N | North |
| 1 | NbE | North by East |
| 2 | NNE | North Northeast |
| 3 | NEbN | Northeast by North |
| 4 | NE | Northeast |
| 5 | NEbE | Northeast by East |
| 6 | ENE | East Northeast |
| 7 | EbN | East by North |
| 8 | E | East |
| 9 | EbS | East by South |
| 10 | ESE | East Southeast |
| 11 | SEbE | Southeast by East |
| 12 | SE | Southeast |
| 13 | SEbS | Southeast by South |
| 14 | SSE | South Southeast |
| 15 | SbE | South by East |
| 16 | S | South |
| 17 | SbW | South by West |
| 18 | SSW | South Southwest |
| 19 | SWbS | Southwest by South |
| 20 | SW | Southwest |
| 21 | SWbW | Southwest by West |
| 22 | WSW | West Southwest |
| 23 | WbS | West by South |
| 24 | W | West |
| 25 | Wbs | West by North |
| 26 | WNW | West Northwest |
| 27 | NWbW | Northwest by West |
| 28 | NW | Northwest |
| 29 | NWbN | Northwest by North |
| 30 | NNW | North Northwest |
| 31 | NbW | North by West |
FAQs
Convert compass degrees to and from cardinal direction values.
The npm package cardinal-direction receives a total of 404 weekly downloads. As such, cardinal-direction popularity was classified as not popular.
We found that cardinal-direction demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.