@berriz44/mathext
v1.0.3-readme
Published
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/the-one-with-raspberry/mathext) [![GitHub last commit (master)](https://img.shields.io/github/last-commit/the-one-with-raspberry/mathext/master)](https://github
Downloads
2
Readme
mathext
mathext
is an extension of the math
interface in JavaScript.
how to install:
npm install @berriz44/mathext
usage:
const MathExt = require('@berriz44/mathext')
items
MathExt.numberRow: number | string | Array<number>
description:
makes a row of numbers
arguments:
end: number
| to what number should it countstart: number
| what number should it start with. defaults to 1.step: number
| how much to increment each number. defaults to 1. affected bystart
andend
.datatype: number | string | Array<any>
| can be any number, array or string. defaults to array. determines the return type of the function.
returns:
a number
, string
, or Array<number>
representing a row of numbers
examples:
MathExt.numberRow(10, 1)
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
typeof MathExt.numberRow(10, 1)
/// Array<number>
MathExt.numberRow(11, 1, 2)
// [1, 3, 5, 7, 9, 11]
MathExt.numberRow(10, 1, 1, "")
// "12345678910"
typeof MathExt.numberRow(10, 1, 1, "")
// 'string'
MathExt.numberRow(10, 1, 1, 0)
// 12345678910
typeof MathExt.numberRow(10, 1, 1, 0)
// 'number'
MathExt.isPositive: boolean
description:
says if a number is positive or not
arguments:
i: number
| which number to know whether it is positive or negative
returns:
true
if i
is positive, false
if i
is negative
examples:
MathExt.isPositive(77)
// true
MathExt.isPositive(-24)
// false
examples:
MathExt.infinity: number
description:
returns infinity or negative infinity based on a parameter
arguments:
side: number
| any number. affects the return value.
returns:
infinity
if side
is a positive number and -infinity
if side
is a negative number
examples:
MathExt.infinity(1)
// Infinity
MathExt.infinity(-1)
// -Infinity
MathExt.turnStringArrayToNumberArray: Array<number>
description:
turns a string array into a number array
arguments:
arr: Array<string>
| the array to convert
returns:
an Array<number>
with numbers from the arr
parameter
examples:
MathExt.turnStringArrayToNumberArray(["10", "4", "9", "fffg"])
// [10, 4, 9, NaN]