npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coords-formater

v1.0.3

Published

A coordinates parser and formater

Downloads

11

Readme

Introduction

This library is intended to facilitate the use of coordinates, making conversions between formats and preparing the fields to receive this type of data effortlessly.

Instalation

# NPM
npm install coords-formater --save

# Yarn
yarn add coords-formater
// Es6 module pattern
import coords from 'coords-formater'

// Node module pattern
const coords = require('coords-formater')

Destructuring

// Es6 module pattern
import { convert, parse } from 'coords-formater'

// Node module pattern
const { normalize } = require('coords-formater')

Properties

The properties below can be used to configurate some methods.

Property|Description|Default Value|Type ---|---|---|--- degrees|Show degrees. Always true|true|Boolean minutes|Show minutes|true|Boolean seconds|Show seconds. False if minutes is also false|true|Boolean spaces|Show spaces between parts|true|Boolean degreeIndicator|Degree part indicator|°|String minuteIndicator|Minute part indicator|'|String secondIndicator|Second part indicator|"|String showSign|Configure to show [+/-] sign at start|true|Boolean showCompassDirection|Configure to show compass direction at end|true|Boolean decimalSeparator|Last part's decimal separator|.|String decimalPlaces|Number of decimal places|5|Integer

Methods

normalize( String coordinate )

Normalizes input coordinate, removing unpattern characters

Parameters

Name|Type|Optional|Description ---|---|---|--- coordinate|String|required|Coordinate in any Accepted Input Formats

Example

// Import
const { normalize } = require('coords-formater');

// Replaces "º" by "°"
normalize('41º 12.123"') 

// Returns
// 41° 12.123"

parse( String coordinate )

Extract coordinates components from passed string

Parameters

Name|Type|Optional|Description ---|---|---|--- coordinate|String|required|Coordinate in any Accepted Input Formats

Example

const { parse } = require('coords-formater');

parse('S17 33 08.352');

/*Returns
{
    compass:"S",
    degrees:17,
    minutes:33,
    seconds:8.352,
    signal:"-"
}*/

convert( String coordinate [ , Object options ] )

Convert cordinate to other format according options

Parameters

Name|Type|Optional|Description ---|---|---|--- coordinate|String|required|Coordinate in any Accepted Input Formats options|Object|optional|Properties object

Example


const { convert } = require('coords-formater') ;

convert('41° 25\' 01" W', { 
  showSign: true, 
  showCompassDirection: false, 
  minutes: false 
  } 
);

// Returns
// - 41.41694444444445°

toString( Object parsedCoordinate [ , Object options ] )

Convert the object parsedCordinate to other format according options

Parameters

Name|Type|Optional|Description ---|---|---|--- parsedCordinate|Object|required|Object of coordinates parts, like returned by parse() options|Object|optional|Properties object

Example


const { toString } = require('coords-formater') ;

// object returned by parse()
const parts = {
  compass:"S",
  degrees:17,
  minutes:33,
  seconds:8.352,
  signal:"-"
}

// Configuration options
const options = {
  showSign:false, 
  showCompassDirection:true
}

toString(parts, options );

// Returns 
// 17° 33' 8.352" S

toFloat( String coordinate [ , Object options ] )

Convert cordinate to numeric format with float type

Parameters

Name|Type|Optional|Description ---|---|---|--- coordinate|String|required|Coordinate in any Accepted Input Formats

Example


const { toFloat } = require('coords-formater') ;

toFloat('42 12 10')
// Returns
// 42.202777777777776

toFloat('S 42 12 10')
// Returns
// - 42.202777777777776

Accepted Input Formats

  • 41 25 01N
  • 41°25'01"N
  • S17 33 08.352
  • +17 33 08.352
  • -41°25'01"
  • 41 25N
  • 41°25'N
  • N41 25.117
  • -41 25.117
  • -41°25'
  • 41 N
  • 41°N
  • N41.092
  • 90S
  • -41°
  • +N41.092

License

MIT

Copyright

(c) klawdyo.com (klawdyo) 2020