1.0.1 • Published 4 years ago

@xitsdanger/periodictable-js v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

PeriodicTable-JS

PeriodicTableJS is an complete module for getting data of every element of the periodic table.

Installation

First, make sure you have a node_modules folder in your project's directory. If not, just run this command and follot its steps.

$ npm init

Now that you initiallizated npm, just run this:

$ npm install @xitsdanger/periodictable-js

It will install the latest version of the npm module for you.

Now that you installed the module, now require it in your file as shown below.

const pt = require("@xitsdanger/periodictable-js")

Done! You've sucessfully installed the module!

Usage

Now, let's learn how to use it. This module has some functions (they will be shown below). But here's a quick example of its usage.

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.get("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
{
    'atomic mass': 1.00797,
    'atomic number': 1,
    group: '1',
    period: '1',
    sintetic: false,
    state: 'gas',
    symbol: 'H'
  }
*/

As you can see, it uses Promises. But if you don't like the .then() statement, you can use await as long as your file has an async statement.

Documentation

Functions

pt.get()

It requires a string (element) and returns a Promise() which is an Object

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.get("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
{
    'atomic mass': 1.00797,
    'atomic number': 1,
    group: '1',
    period: '1',
    sintetic: false,
    state: 'gas',
    symbol: 'H'
  }
*/

pt.getSymbol()

It requires a string (element) and returns a Promise() which is a string

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getSymbol("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    H
*/

pt.getName()

It requires a string (element) and returns a Promise() which is a string

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getName("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    Hydrogen
*/

pt.getState()

It requires a string (element) and returns a Promise() which is a string

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getState("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    gas
*/

pt.getAtomicNumber()

It requires a string (element) and returns a Promise() which is an int

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getAtomicNumber("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    1
*/

pt.getAtomicMass()

It requires a string (element) and returns a Promise() which is an int

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getAtomicMass("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    1.00797
*/

pt.getGroup()

It requires a string (element) and returns a Promise() which is a string

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getGroup("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    1
*/

pt.getPeriod()

It requires a string (element) and returns a Promise() which is a string

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.getPeriod("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    1
*/

pt.isSintetic()

It requires a string (element) and returns a Promise() which is a Boolean

Example:

// Requires the module
const pt = require("@xitsdanger/periodictable-js")

pt.isSintetic("hydrogen").then(data => {
    console.log(data)
})

/* Console will log:
    false
*/
1.0.1

4 years ago

1.0.0

4 years ago