Coder Social home page Coder Social logo

alterebro / beaufort-scale Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 651 KB

Translate speed to Beaufort wind force scale in both Node and the Browser

Home Page: https://www.npmjs.com/package/beaufort-scale

License: MIT License

JavaScript 100.00%
beaufort wind

beaufort-scale's Introduction

beaufort-scale npm

Translate speed to Beaufort wind force scale in both Node and the Browser. Returns the Beaufort Scale intensity grade number from a given wind speed (in Kilometres per hour).

Install and Include the module

  • Node

     $ npm install beaufort-scale
     var beaufort = require('beaufort-scale')
  • or Browser

    Clone the repo or download the minified file : beaufort-scale.min.js

     $ git clone https://github.com/alterebro/beaufort-scale.git
     <script src="/your/path/to//beaufort-scale/dist/beaufort-scale.min.js"></script>

Usage

beaufort(40)

// returns an object
{
	grade: 6.09,
	desc: "Strong breeze"
}

Options

There are two options that can be sent to the beaufort function. These are optional and have to be passed as an Object.

  • lang : String or Array the language of the description string ( desc ). As a string there are two possible values, en for English or es for Spanish, the default value is en.
    As an array you can add your own language string values
  • int : Boolean determines if the grade returns an integer or a floating number, default value is false.

Example

beaufort(40, {lang: 'es', int: true})

// returns the following object
{
	grade: 6,
	desc: "Brisa fuerte"
}

With an array of values as a lang parameter, for example with the greek strings as provided by @groubis

beaufort(1, { lang: ["Άπνοια", "Σχεδόν άπνοια", "Πολύ ασθενής", "Ασθενής", "Σχεδόν μέτριος", "Μέτριος", "Ισχυρός", "Σχεδόν θυελλώδης", "Θυελλώδης", "Πολύ θυελλώδης", "Θύελλα", "Σφοδρή θύελλα", "Τυφώνας"], int : true });

// returns the object:
{
	grade: 0,
	desc: "Άπνοια"
}

Build

$ npm run build
# or alternatively just:
$ gulp

Tests

$ npm test
$ npm run cov 	# with test coverage

beaufort-scale's People

Contributors

alterebro avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

shafdog

beaufort-scale's Issues

Greek Translation

Hello and thanks for your nice script,

if you want to add Greek translation, this is the array of objects including Greek:

var s = [ { speed: 0, desc: { en: "Calm", es: "Calma", el: "Άπνοια" } }, { speed: 2, desc: { en: "Light air", es: "Ventolina",el :"Σχεδόν άπνοια" } }, { speed: 6, desc: { en: "Light breeze", es: "Brisa muy débil",el :"Πολύ ασθενής" } }, { speed: 12, desc: { en: "Gentle breeze", es: "Brisa ligera",el :"Ασθενής" } }, { speed: 20, desc: { en: "Moderate breeze", es: "Brisa moderada",el :"Σχεδόν μέτριος" } }, { speed: 29, desc: { en: "Fresh breeze", es: "Brisa fresca",el :"Μέτριος" } }, { speed: 39, desc: { en: "Strong breeze", es: "Brisa fuerte",el :"Ισχυρός" } }, { speed: 50, desc: { en: "High wind", es: "Viento fuerte",el :"Σχεδόν θυελλώδης" } }, { speed: 62, desc: { en: "Gale", es: "Temporal",el :"Θυελλώδης" } }, { speed: 75, desc: { en: "Strong gale", es: "Temporal fuerte", el: "Πολύ θυελλώδης" } }, { speed: 89, desc: { en: "Storm", es: "Temporal duro", el : "Θύελλα" } }, { speed: 103, desc: { en: "Violent Storm", es: "Borrasca", el : "Σφοδρή θύελλα" } }, { speed: 118, desc: { en: "Hurricane", es: "Huracán", el : "Τυφώνας" } } ]

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.