API Docs for: 0.0.1
Show:

Math Class

Module: lib/math.js
Parent Module: js-ext

Extension of Math Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/

Item Index

Methods

ceilFromZero

(
  • value
)
Number

Ceils a value from zero up. Native Math.ceil does this for positive values, but negative values are ceiled more into the less negative (Math.ceil(-2.3) === -2). This method ceiles up from zero: (Math.ceilFromZero(-2.3) === -3)

Parameters:

  • value Number

    the original value that should be inbetween the edges

Returns:

Number:

the floored value

floorToZero

(
  • value
)
Number

Floors a value in the direction to zero. Native Math.floor does this for positive values, but negative values are floored more into the negative (Math.floor(-2.3) === -3). This method floores into the direction of zero: (Math.floorToZero(-2.3) === -2)

Parameters:

  • value Number

    the original value that should be inbetween the edges

Returns:

Number:

the floored value

inbetween

(
  • min
  • value
  • max
  • [absoluteValue]
)
Number | Undefined

Returns the value, while forcing it to be inbetween the specified edges.

Parameters:

  • min Number

    lower-edgde

  • value Number

    the original value that should be inbetween the edges

  • max Number

    upper-edgde

  • [absoluteValue] Boolean optional

    whether value should be treaded as an absolute value

Returns:

Number | Undefined:

the value, forced to be inbetween the edges. Returns undefined if max is lower than min.