0.0.2 • Published 8 years ago

sweeties v0.0.2

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

sweeties

Extensions for primitive JS types

Installation

$ npm install sweeties

Usage

const sweeties = require('sweeties')
sweeties()

OR

require('sweeties')()

Module does not export anything, so assigning require result to a variable would be pretty useless.

Extensions of Number

Static

random (min, max): Number

Generates random number between min and max. Default value for min = 0, for max = Number.MAX_SAFE_INTEGER

Instance

between (min, max): Boolean

Returns true if reference number is between (non-inclusive) min and max, false otherwise.

Example:

let x = 5
x.between(1, 10) // true
x.between(5, 7) // false

betweenIncl (min, max): Boolean

Returns true if reference number is between (inclusive) min and max, false otherwise.

Example:

let x = 5
x.between(1, 10) // true
x.between(5, 7) // true

isPositive (): Boolean

Returns true if reference number is bigger or equeals to 0 (eg. positive), false otherwise.

Example:

let x = 5
x.isPositive() // true

isNegative (): Boolean

Returns true if reference number is less than 0 (eg. negative), false otherwise.

Example:

let x = 5
x.isPositive() // false