Skip to content

v0.11.0

Latest

Choose a tag to compare

@amikheychik amikheychik released this 09 Mar 17:11
· 14 commits to main since this release
v0.11.0
931744a

Fixed ES modules imports

@perfective/common can now be imported from regular .js/.mjs ESM files.

Added wrappers for most of the Math functions (#20)

Unlike the standard Math functions, the following functions throw an Exception for invalid inputs:

  • absolute()
  • arccos(), arccosh()
  • arcsin(), arcsinh()
  • arctan(), arctan2(), arctanh()
  • cos(), cosh()
  • sin(), sinh()
  • tan(), tanh()
  • rounded(), roundedUp(), roundedDown(), roundedToFloat32(), truncated()
  • power(), powerOf()
  • squareRoot(), cubeRoot(), l2norm()
  • exp(), expm1()
  • log(), log10(), log1p(), log2()
  • sign() with the Sign nominal type

Replacing NaN with null is a redundant idea, because it’s trivial to use library functions with Maybe instead:

maybe(x).to(Math.acos).that(isNumber)

Meanwhile, throwing an exception gives library users an option to track invalid inputs.
In this case, the Result monad can be used:

result(x).onto(resultFrom(arccos))

Added more nominal types for numbers

  • Added the Infinity, PositiveInfinity, and NegativeInfinity nominal types with the isInfinity() type guard.
  • Added the FiniteNumber nominal type with the isFinite() type guard (#18) and assertIsFinite() assertion.
  • Added the PositiveNumber, NonPositiveNumber, NegativeNumber, NonNegativeNumber nominal types.
  • Added the assertIsNonNegativeNumber() type guard.

Introduced assertion functions

  • Added the assertIsNotNaN() (#53) and assertIsNonNegativeNumber() functions.
  • Added the typeException() function.