From 0ce53f122af80184326c85936fa1a926eaf34708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Thu, 25 Mar 2021 12:52:01 +0100 Subject: [PATCH] :shirt: refactor: Lint all JavaScript files. --- doc/scripts/header.js | 40 ++++++++---------- package.json | 2 + src/arithmetic/add.js | 2 +- src/arithmetic/constants/add1.js | 2 +- src/arithmetic/constants/div2.js | 2 +- src/arithmetic/constants/iadd1.js | 2 +- src/arithmetic/constants/idiv2.js | 2 +- src/arithmetic/constants/imul2.js | 2 +- src/arithmetic/constants/imul5.js | 2 +- src/arithmetic/constants/index.js | 20 ++++----- src/arithmetic/constants/isub1.js | 2 +- src/arithmetic/constants/mul2.js | 2 +- src/arithmetic/constants/mul5.js | 2 +- src/arithmetic/constants/sub1.js | 2 +- src/arithmetic/div.js | 2 +- src/arithmetic/divmod.js | 2 +- src/arithmetic/iadd.js | 2 +- src/arithmetic/idiv.js | 2 +- src/arithmetic/idivmod.js | 8 ++-- src/arithmetic/imod.js | 2 +- src/arithmetic/imul.js | 2 +- src/arithmetic/index.js | 42 +++++++++---------- src/arithmetic/ishl.js | 2 +- src/arithmetic/ishr.js | 2 +- src/arithmetic/ishu.js | 2 +- src/arithmetic/isub.js | 2 +- src/arithmetic/mod.js | 2 +- src/arithmetic/mul.js | 2 +- src/arithmetic/neg.js | 2 +- src/arithmetic/shl.js | 2 +- src/arithmetic/shr.js | 2 +- src/arithmetic/shu.js | 2 +- src/arithmetic/special/div2n.js | 2 +- src/arithmetic/special/index.js | 2 +- src/arithmetic/sub.js | 2 +- src/compare/decreasing.js | 2 +- src/compare/increasing.js | 2 +- src/compare/index.js | 4 +- src/constants/$0.js | 2 +- src/constants/$1.js | 2 +- src/constants/$2.js | 2 +- src/constants/$5.js | 2 +- src/constants/$_1.js | 2 +- src/constants/index.js | 10 ++--- src/exponential/constants/index.js | 4 +- src/exponential/constants/ipow2.js | 2 +- src/exponential/constants/pow2.js | 2 +- src/exponential/exp.js | 2 +- src/exponential/index.js | 8 ++-- src/exponential/pow.js | 2 +- src/exponential/sqrt.js | 2 +- src/index.js | 18 ++++---- src/io/index.js | 4 +- src/io/parse.js | 2 +- src/io/stringify.js | 2 +- src/logarithmic/index.js | 12 +++--- src/logarithmic/log.js | 2 +- src/logarithmic/log2.js | 2 +- src/logarithmic/loge.js | 2 +- src/logarithmic/loglog.js | 3 +- src/logarithmic/loglog2.js | 2 +- src/logarithmic/logloge.js | 2 +- src/memory/copy.js | 2 +- src/memory/index.js | 2 +- src/predicate/constants/eq0.js | 2 +- src/predicate/constants/eq1.js | 2 +- src/predicate/constants/eq_1.js | 2 +- src/predicate/constants/ge1.js | 2 +- src/predicate/constants/gt0.js | 2 +- src/predicate/constants/gt1.js | 2 +- src/predicate/constants/index.js | 16 +++---- src/predicate/constants/le1.js | 2 +- src/predicate/constants/lt1.js | 2 +- src/predicate/eq.js | 2 +- src/predicate/ge.js | 2 +- src/predicate/gt.js | 2 +- src/predicate/index.js | 14 +++---- src/predicate/le.js | 2 +- src/predicate/lt.js | 2 +- src/predicate/ne.js | 2 +- src/trigonometry/PI.js | 2 +- src/trigonometry/atan2.js | 2 +- src/trigonometry/cos.js | 2 +- src/trigonometry/index.js | 8 ++-- src/trigonometry/sin.js | 2 +- test/src/arithmetic/add.js | 56 ++++++++++++++----------- test/src/arithmetic/constants/add1.js | 28 ++++++------- test/src/arithmetic/constants/div2.js | 26 ++++++------ test/src/arithmetic/constants/iadd1.js | 32 ++++++-------- test/src/arithmetic/constants/idiv2.js | 30 ++++++------- test/src/arithmetic/constants/imul2.js | 34 +++++++-------- test/src/arithmetic/constants/imul5.js | 34 +++++++-------- test/src/arithmetic/constants/isub1.js | 32 ++++++-------- test/src/arithmetic/constants/mul2.js | 30 +++++++------ test/src/arithmetic/constants/mul5.js | 30 +++++++------ test/src/arithmetic/constants/sub1.js | 28 ++++++------- test/src/arithmetic/div.js | 48 ++++++++++----------- test/src/arithmetic/divmod.js | 30 +++++++------ test/src/arithmetic/iadd.js | 56 ++++++++++++++----------- test/src/arithmetic/idiv.js | 50 ++++++++++------------ test/src/arithmetic/idivmod.js | 36 +++++++--------- test/src/arithmetic/imod.js | 34 +++++++-------- test/src/arithmetic/imul.js | 50 ++++++++++------------ test/src/arithmetic/ishl.js | 24 +++++------ test/src/arithmetic/ishr.js | 24 +++++------ test/src/arithmetic/ishu.js | 24 +++++------ test/src/arithmetic/isub.js | 46 ++++++++++---------- test/src/arithmetic/mod.js | 31 +++++++------- test/src/arithmetic/mul.js | 42 +++++++++---------- test/src/arithmetic/neg.js | 26 ++++++------ test/src/arithmetic/shl.js | 22 ++++------ test/src/arithmetic/shr.js | 22 ++++------ test/src/arithmetic/shu.js | 22 ++++------ test/src/arithmetic/special/div2n.js | 28 ++++++------- test/src/arithmetic/sub.js | 46 +++++++++++--------- test/src/compare/decreasing.js | 19 +++++---- test/src/compare/increasing.js | 19 +++++---- test/src/constants/all.js | 32 +++++++------- test/src/exponential/constants/ipow2.js | 34 +++++++-------- test/src/exponential/constants/pow2.js | 32 +++++++------- test/src/exponential/exp.js | 26 ++++++------ test/src/exponential/pow.js | 36 ++++++++-------- test/src/exponential/sqrt.js | 32 +++++++------- test/src/io/parse.js | 26 ++++++------ test/src/io/stringify.js | 26 ++++++------ test/src/logarithmic/log.js | 40 +++++++++--------- test/src/logarithmic/log2.js | 26 ++++++------ test/src/logarithmic/loge.js | 24 +++++------ test/src/logarithmic/loglog.js | 53 ++++++++++++----------- test/src/logarithmic/loglog2.js | 36 +++++++--------- test/src/logarithmic/logloge.js | 37 +++++++--------- test/src/memory/copy.js | 41 ++++++++---------- test/src/predicate/constants/ge1.js | 26 ++++++------ test/src/predicate/constants/gt0.js | 26 ++++++------ test/src/predicate/constants/gt1.js | 26 ++++++------ test/src/predicate/constants/le1.js | 26 ++++++------ test/src/predicate/constants/lt1.js | 26 ++++++------ test/src/predicate/eq.js | 36 ++++++++-------- test/src/predicate/ge.js | 42 +++++++++---------- test/src/predicate/gt.js | 36 ++++++++-------- test/src/predicate/le.js | 36 ++++++++-------- test/src/predicate/lt.js | 36 ++++++++-------- test/src/predicate/ne.js | 36 ++++++++-------- 143 files changed, 1061 insertions(+), 1202 deletions(-) diff --git a/doc/scripts/header.js b/doc/scripts/header.js index 02f26a4..a8835e7 100644 --- a/doc/scripts/header.js +++ b/doc/scripts/header.js @@ -1,34 +1,30 @@ -var domReady = function(callback) { - var state = document.readyState ; - if ( state === 'interactive' || state === 'complete' ) { - callback() ; - } - else { +const domReady = function (callback) { + const state = document.readyState; + if (state === 'interactive' || state === 'complete') { + callback(); + } else { document.addEventListener('DOMContentLoaded', callback); } -} ; - +}; -domReady(function(){ - - var projectname = document.createElement('a'); +domReady(() => { + const projectname = document.createElement('a'); projectname.classList.add('project-name'); projectname.text = 'aureooms/js-number'; - projectname.href = './index.html' ; + projectname.href = './index.html'; - var header = document.getElementsByTagName('header')[0] ; - header.insertBefore(projectname,header.firstChild); + const header = document.querySelectorAll('header')[0]; + header.insertBefore(projectname, header.firstChild); - var testlink = document.querySelector('header > a[data-ice="testLink"]') ; - testlink.href = 'https://coveralls.io/github/aureooms/js-number' ; - testlink.target = '_BLANK' ; + const testlink = document.querySelector('header > a[data-ice="testLink"]'); + testlink.href = 'https://coveralls.io/github/aureooms/js-number'; + testlink.target = '_BLANK'; - var searchBox = document.querySelector('.search-box'); - var input = document.querySelector('.search-input'); + const searchBox = document.querySelector('.search-box'); + const input = document.querySelector('.search-input'); - // active search box when focus on searchBox. - input.addEventListener('focus', function(){ + // Active search box when focus on searchBox. + input.addEventListener('focus', () => { searchBox.classList.add('active'); }); - }); diff --git a/package.json b/package.json index 095b9bd..efb0711 100644 --- a/package.json +++ b/package.json @@ -192,6 +192,8 @@ "no-constant-condition": "off", "unicorn/prefer-math-trunc": "off", "unicorn/no-new-array": "off", + "prefer-exponentiation-operator": "off", + "no-return-assign": "off", "no-negated-condition": "off" }, "overrides": [ diff --git a/src/arithmetic/add.js b/src/arithmetic/add.js index 450986c..d0f87bf 100644 --- a/src/arithmetic/add.js +++ b/src/arithmetic/add.js @@ -1 +1 @@ -export const add = ( a , b ) => a + b ; +export const add = (a, b) => a + b; diff --git a/src/arithmetic/constants/add1.js b/src/arithmetic/constants/add1.js index fb9d82d..6ab39a1 100644 --- a/src/arithmetic/constants/add1.js +++ b/src/arithmetic/constants/add1.js @@ -1 +1 @@ -export const add1 = n => n + 1 ; +export const add1 = (n) => n + 1; diff --git a/src/arithmetic/constants/div2.js b/src/arithmetic/constants/div2.js index 0568e34..5884355 100644 --- a/src/arithmetic/constants/div2.js +++ b/src/arithmetic/constants/div2.js @@ -1 +1 @@ -export const div2 = n => n / 2 ; +export const div2 = (n) => n / 2; diff --git a/src/arithmetic/constants/iadd1.js b/src/arithmetic/constants/iadd1.js index f776a5f..6564e04 100644 --- a/src/arithmetic/constants/iadd1.js +++ b/src/arithmetic/constants/iadd1.js @@ -1 +1 @@ -export const iadd1 = n => n += 1 ; +export const iadd1 = (n) => (n += 1); diff --git a/src/arithmetic/constants/idiv2.js b/src/arithmetic/constants/idiv2.js index 6a2f96d..28add9b 100644 --- a/src/arithmetic/constants/idiv2.js +++ b/src/arithmetic/constants/idiv2.js @@ -1 +1 @@ -export const idiv2 = n => n /= 2 ; +export const idiv2 = (n) => (n /= 2); diff --git a/src/arithmetic/constants/imul2.js b/src/arithmetic/constants/imul2.js index 000ffaa..3bc14ed 100644 --- a/src/arithmetic/constants/imul2.js +++ b/src/arithmetic/constants/imul2.js @@ -1 +1 @@ -export const imul2 = a => a *= 2 ; +export const imul2 = (a) => (a *= 2); diff --git a/src/arithmetic/constants/imul5.js b/src/arithmetic/constants/imul5.js index 37f661a..5996dc1 100644 --- a/src/arithmetic/constants/imul5.js +++ b/src/arithmetic/constants/imul5.js @@ -1 +1 @@ -export const imul5 = a => a *= 5 ; +export const imul5 = (a) => (a *= 5); diff --git a/src/arithmetic/constants/index.js b/src/arithmetic/constants/index.js index 83ef41a..2879729 100644 --- a/src/arithmetic/constants/index.js +++ b/src/arithmetic/constants/index.js @@ -1,10 +1,10 @@ -export * from "./add1.js" ; -export * from "./div2.js" ; -export * from "./iadd1.js" ; -export * from "./idiv2.js" ; -export * from "./imul2.js" ; -export * from "./imul5.js" ; -export * from "./isub1.js" ; -export * from "./mul2.js" ; -export * from "./mul5.js" ; -export * from "./sub1.js" ; +export * from './add1.js'; +export * from './div2.js'; +export * from './iadd1.js'; +export * from './idiv2.js'; +export * from './imul2.js'; +export * from './imul5.js'; +export * from './isub1.js'; +export * from './mul2.js'; +export * from './mul5.js'; +export * from './sub1.js'; diff --git a/src/arithmetic/constants/isub1.js b/src/arithmetic/constants/isub1.js index 0e6c659..b701683 100644 --- a/src/arithmetic/constants/isub1.js +++ b/src/arithmetic/constants/isub1.js @@ -1 +1 @@ -export const isub1 = n => n -= 1 ; +export const isub1 = (n) => (n -= 1); diff --git a/src/arithmetic/constants/mul2.js b/src/arithmetic/constants/mul2.js index e726a5f..1ed32f3 100644 --- a/src/arithmetic/constants/mul2.js +++ b/src/arithmetic/constants/mul2.js @@ -1 +1 @@ -export const mul2 = a => a * 2 ; +export const mul2 = (a) => a * 2; diff --git a/src/arithmetic/constants/mul5.js b/src/arithmetic/constants/mul5.js index 1844392..98225e3 100644 --- a/src/arithmetic/constants/mul5.js +++ b/src/arithmetic/constants/mul5.js @@ -1 +1 @@ -export const mul5 = a => a * 5 ; +export const mul5 = (a) => a * 5; diff --git a/src/arithmetic/constants/sub1.js b/src/arithmetic/constants/sub1.js index 38b0f6a..cf9a5a8 100644 --- a/src/arithmetic/constants/sub1.js +++ b/src/arithmetic/constants/sub1.js @@ -1 +1 @@ -export const sub1 = n => n - 1 ; +export const sub1 = (n) => n - 1; diff --git a/src/arithmetic/div.js b/src/arithmetic/div.js index e500490..00b84e7 100644 --- a/src/arithmetic/div.js +++ b/src/arithmetic/div.js @@ -1 +1 @@ -export const div = ( a , b ) => a / b ; +export const div = (a, b) => a / b; diff --git a/src/arithmetic/divmod.js b/src/arithmetic/divmod.js index 7440a90..b92388a 100644 --- a/src/arithmetic/divmod.js +++ b/src/arithmetic/divmod.js @@ -1 +1 @@ -export const divmod = ( a, b ) => [ a / b | 0, a % b ] ; +export const divmod = (a, b) => [(a / b) | 0, a % b]; diff --git a/src/arithmetic/iadd.js b/src/arithmetic/iadd.js index 112ad17..205b0b9 100644 --- a/src/arithmetic/iadd.js +++ b/src/arithmetic/iadd.js @@ -1 +1 @@ -export const iadd = ( a , b ) => a += b ; +export const iadd = (a, b) => (a += b); diff --git a/src/arithmetic/idiv.js b/src/arithmetic/idiv.js index 24a1789..9e1f520 100644 --- a/src/arithmetic/idiv.js +++ b/src/arithmetic/idiv.js @@ -1 +1 @@ -export const idiv = ( a , b ) => a /= b ; +export const idiv = (a, b) => (a /= b); diff --git a/src/arithmetic/idivmod.js b/src/arithmetic/idivmod.js index 53536b5..ff4610e 100644 --- a/src/arithmetic/idivmod.js +++ b/src/arithmetic/idivmod.js @@ -1,7 +1,5 @@ -export function idivmod ( a , b ) { - - const q = a / b | 0 ; - - return [ q , a %= b ] ; +export function idivmod(a, b) { + const q = (a / b) | 0; + return [q, (a %= b)]; } diff --git a/src/arithmetic/imod.js b/src/arithmetic/imod.js index 727cf1e..3a01f1d 100644 --- a/src/arithmetic/imod.js +++ b/src/arithmetic/imod.js @@ -1 +1 @@ -export const imod = ( a , b ) => a %= b ; +export const imod = (a, b) => (a %= b); diff --git a/src/arithmetic/imul.js b/src/arithmetic/imul.js index 938adf8..3497094 100644 --- a/src/arithmetic/imul.js +++ b/src/arithmetic/imul.js @@ -1 +1 @@ -export const imul = ( a , b ) => a *= b ; +export const imul = (a, b) => (a *= b); diff --git a/src/arithmetic/index.js b/src/arithmetic/index.js index 20cfb4d..97fb9e4 100644 --- a/src/arithmetic/index.js +++ b/src/arithmetic/index.js @@ -1,21 +1,21 @@ -export * from "./add.js" ; -export * from "./constants/index.js" ; -export * from "./div.js" ; -export * from "./divmod.js" ; -export * from "./iadd.js" ; -export * from "./idiv.js" ; -export * from "./idivmod.js" ; -export * from "./imod.js" ; -export * from "./imul.js" ; -export * from "./ishl.js" ; -export * from "./ishr.js" ; -export * from "./ishu.js" ; -export * from "./isub.js" ; -export * from "./mod.js" ; -export * from "./mul.js" ; -export * from "./neg.js" ; -export * from "./shl.js" ; -export * from "./shr.js" ; -export * from "./shu.js" ; -export * from "./special/index.js" ; -export * from "./sub.js" ; +export * from './add.js'; +export * from './constants/index.js'; +export * from './div.js'; +export * from './divmod.js'; +export * from './iadd.js'; +export * from './idiv.js'; +export * from './idivmod.js'; +export * from './imod.js'; +export * from './imul.js'; +export * from './ishl.js'; +export * from './ishr.js'; +export * from './ishu.js'; +export * from './isub.js'; +export * from './mod.js'; +export * from './mul.js'; +export * from './neg.js'; +export * from './shl.js'; +export * from './shr.js'; +export * from './shu.js'; +export * from './special/index.js'; +export * from './sub.js'; diff --git a/src/arithmetic/ishl.js b/src/arithmetic/ishl.js index e5926f2..953d38a 100644 --- a/src/arithmetic/ishl.js +++ b/src/arithmetic/ishl.js @@ -1 +1 @@ -export const ishl = ( a , n ) => a <<= n ; +export const ishl = (a, n) => (a <<= n); diff --git a/src/arithmetic/ishr.js b/src/arithmetic/ishr.js index 39d5430..7f917b9 100644 --- a/src/arithmetic/ishr.js +++ b/src/arithmetic/ishr.js @@ -1 +1 @@ -export const ishr = ( a , n ) => a >>= n ; +export const ishr = (a, n) => (a >>= n); diff --git a/src/arithmetic/ishu.js b/src/arithmetic/ishu.js index f519c22..15ca69c 100644 --- a/src/arithmetic/ishu.js +++ b/src/arithmetic/ishu.js @@ -1 +1 @@ -export const ishu = ( a , n ) => a >>>= n ; +export const ishu = (a, n) => (a >>>= n); diff --git a/src/arithmetic/isub.js b/src/arithmetic/isub.js index 0ec1c5d..008910d 100644 --- a/src/arithmetic/isub.js +++ b/src/arithmetic/isub.js @@ -1 +1 @@ -export const isub = ( a , b ) => a -= b ; +export const isub = (a, b) => (a -= b); diff --git a/src/arithmetic/mod.js b/src/arithmetic/mod.js index 91ee4ed..e1d6192 100644 --- a/src/arithmetic/mod.js +++ b/src/arithmetic/mod.js @@ -1 +1 @@ -export const mod = ( a , b ) => a % b ; +export const mod = (a, b) => a % b; diff --git a/src/arithmetic/mul.js b/src/arithmetic/mul.js index fb7bd94..c206336 100644 --- a/src/arithmetic/mul.js +++ b/src/arithmetic/mul.js @@ -1 +1 @@ -export const mul = ( a , b ) => a * b ; +export const mul = (a, b) => a * b; diff --git a/src/arithmetic/neg.js b/src/arithmetic/neg.js index c4c8a99..a9c8bf3 100644 --- a/src/arithmetic/neg.js +++ b/src/arithmetic/neg.js @@ -1 +1 @@ -export const neg = n => -n ; +export const neg = (n) => -n; diff --git a/src/arithmetic/shl.js b/src/arithmetic/shl.js index 86d5176..a6fb52a 100644 --- a/src/arithmetic/shl.js +++ b/src/arithmetic/shl.js @@ -1 +1 @@ -export const shl = ( a , n ) => a << n ; +export const shl = (a, n) => a << n; diff --git a/src/arithmetic/shr.js b/src/arithmetic/shr.js index a7b238a..c11b362 100644 --- a/src/arithmetic/shr.js +++ b/src/arithmetic/shr.js @@ -1 +1 @@ -export const shr = ( a , n ) => a >> n ; +export const shr = (a, n) => a >> n; diff --git a/src/arithmetic/shu.js b/src/arithmetic/shu.js index 9115c3a..ac31d5f 100644 --- a/src/arithmetic/shu.js +++ b/src/arithmetic/shu.js @@ -1 +1 @@ -export const shu = ( a , n ) => a >>> n ; +export const shu = (a, n) => a >>> n; diff --git a/src/arithmetic/special/div2n.js b/src/arithmetic/special/div2n.js index 72e95e2..63a7180 100644 --- a/src/arithmetic/special/div2n.js +++ b/src/arithmetic/special/div2n.js @@ -1 +1 @@ -export const div2n = ( a , n ) => a / Math.pow( 2 , n ) ; +export const div2n = (a, n) => a / 2 ** n; diff --git a/src/arithmetic/special/index.js b/src/arithmetic/special/index.js index 9b3c390..d65b3e7 100644 --- a/src/arithmetic/special/index.js +++ b/src/arithmetic/special/index.js @@ -1 +1 @@ -export * from "./div2n.js" ; +export * from './div2n.js'; diff --git a/src/arithmetic/sub.js b/src/arithmetic/sub.js index b43266a..42277c7 100644 --- a/src/arithmetic/sub.js +++ b/src/arithmetic/sub.js @@ -1 +1 @@ -export const sub = ( a , b ) => a - b ; +export const sub = (a, b) => a - b; diff --git a/src/compare/decreasing.js b/src/compare/decreasing.js index 933d9fe..689f1dd 100644 --- a/src/compare/decreasing.js +++ b/src/compare/decreasing.js @@ -1 +1 @@ -export const decreasing = ( a , b ) => ( a > b ) ? -1 : ( ( a === b ) ? 0 : 1 ) ; +export const decreasing = (a, b) => (a > b ? -1 : a === b ? 0 : 1); diff --git a/src/compare/increasing.js b/src/compare/increasing.js index 91874a9..49c4ea0 100644 --- a/src/compare/increasing.js +++ b/src/compare/increasing.js @@ -1 +1 @@ -export const increasing = ( a , b ) => ( a < b ) ? -1 : ( ( a === b ) ? 0 : 1 ) ; +export const increasing = (a, b) => (a < b ? -1 : a === b ? 0 : 1); diff --git a/src/compare/index.js b/src/compare/index.js index e362186..89729d1 100644 --- a/src/compare/index.js +++ b/src/compare/index.js @@ -1,2 +1,2 @@ -export * from "./decreasing.js" ; -export * from "./increasing.js" ; +export * from './decreasing.js'; +export * from './increasing.js'; diff --git a/src/constants/$0.js b/src/constants/$0.js index d3f6637..ff3ca0f 100644 --- a/src/constants/$0.js +++ b/src/constants/$0.js @@ -1 +1 @@ -export const $0 = ( ) => 0 ; +export const $0 = () => 0; diff --git a/src/constants/$1.js b/src/constants/$1.js index 543f40b..d47a46b 100644 --- a/src/constants/$1.js +++ b/src/constants/$1.js @@ -1 +1 @@ -export const $1 = ( ) => 1 ; +export const $1 = () => 1; diff --git a/src/constants/$2.js b/src/constants/$2.js index e78d0ac..f0f8146 100644 --- a/src/constants/$2.js +++ b/src/constants/$2.js @@ -1 +1 @@ -export const $2 = ( ) => 2 ; +export const $2 = () => 2; diff --git a/src/constants/$5.js b/src/constants/$5.js index f7a5e26..92098b8 100644 --- a/src/constants/$5.js +++ b/src/constants/$5.js @@ -1 +1 @@ -export const $5 = ( ) => 5 ; +export const $5 = () => 5; diff --git a/src/constants/$_1.js b/src/constants/$_1.js index 61fdc1a..35b302f 100644 --- a/src/constants/$_1.js +++ b/src/constants/$_1.js @@ -1 +1 @@ -export const $_1 = ( ) => -1 ; +export const $_1 = () => -1; diff --git a/src/constants/index.js b/src/constants/index.js index 16a0529..539859d 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -1,5 +1,5 @@ -export * from "./$0.js" ; -export * from "./$1.js" ; -export * from "./$2.js" ; -export * from "./$5.js" ; -export * from "./$_1.js" ; +export * from './$0.js'; +export * from './$1.js'; +export * from './$2.js'; +export * from './$5.js'; +export * from './$_1.js'; diff --git a/src/exponential/constants/index.js b/src/exponential/constants/index.js index 500bdda..0be98de 100644 --- a/src/exponential/constants/index.js +++ b/src/exponential/constants/index.js @@ -1,2 +1,2 @@ -export * from "./ipow2.js" ; -export * from "./pow2.js" ; +export * from './ipow2.js'; +export * from './pow2.js'; diff --git a/src/exponential/constants/ipow2.js b/src/exponential/constants/ipow2.js index 4f3c1e1..ab53f61 100644 --- a/src/exponential/constants/ipow2.js +++ b/src/exponential/constants/ipow2.js @@ -1 +1 @@ -export const ipow2 = a => a *= a ; +export const ipow2 = (a) => (a *= a); diff --git a/src/exponential/constants/pow2.js b/src/exponential/constants/pow2.js index d807b1e..d76e356 100644 --- a/src/exponential/constants/pow2.js +++ b/src/exponential/constants/pow2.js @@ -1 +1 @@ -export const pow2 = a => a * a ; +export const pow2 = (a) => a * a; diff --git a/src/exponential/exp.js b/src/exponential/exp.js index dd91121..3572823 100644 --- a/src/exponential/exp.js +++ b/src/exponential/exp.js @@ -1 +1 @@ -export const exp = Math.exp ; +export const exp = Math.exp; diff --git a/src/exponential/index.js b/src/exponential/index.js index 0c53294..386d5f8 100644 --- a/src/exponential/index.js +++ b/src/exponential/index.js @@ -1,4 +1,4 @@ -export * from "./constants/index.js" ; -export * from "./pow.js" ; -export * from "./exp.js" ; -export * from "./sqrt.js" ; +export * from './constants/index.js'; +export * from './pow.js'; +export * from './exp.js'; +export * from './sqrt.js'; diff --git a/src/exponential/pow.js b/src/exponential/pow.js index b1e1628..cfc7983 100644 --- a/src/exponential/pow.js +++ b/src/exponential/pow.js @@ -1 +1 @@ -export const pow = Math.pow ; +export const pow = Math.pow; diff --git a/src/exponential/sqrt.js b/src/exponential/sqrt.js index 09baefd..5132290 100644 --- a/src/exponential/sqrt.js +++ b/src/exponential/sqrt.js @@ -1 +1 @@ -export const sqrt = Math.sqrt ; +export const sqrt = Math.sqrt; diff --git a/src/index.js b/src/index.js index bb4ba60..bd3bedf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ -export * from "./arithmetic/index.js" ; -export * from "./compare/index.js" ; -export * from "./constants/index.js" ; -export * from "./exponential/index.js" ; -export * from "./io/index.js" ; -export * from "./logarithmic/index.js" ; -export * from "./memory/index.js" ; -export * from "./predicate/index.js" ; -export * from "./trigonometry/index.js" ; +export * from './arithmetic/index.js'; +export * from './compare/index.js'; +export * from './constants/index.js'; +export * from './exponential/index.js'; +export * from './io/index.js'; +export * from './logarithmic/index.js'; +export * from './memory/index.js'; +export * from './predicate/index.js'; +export * from './trigonometry/index.js'; diff --git a/src/io/index.js b/src/io/index.js index f9409be..8771e73 100644 --- a/src/io/index.js +++ b/src/io/index.js @@ -1,2 +1,2 @@ -export * from "./parse.js" ; -export * from "./stringify.js" ; +export * from './parse.js'; +export * from './stringify.js'; diff --git a/src/io/parse.js b/src/io/parse.js index 00fc832..138f343 100644 --- a/src/io/parse.js +++ b/src/io/parse.js @@ -1 +1 @@ -export const parse = n => +n ; +export const parse = (n) => Number(n); diff --git a/src/io/stringify.js b/src/io/stringify.js index f577cec..b89dd13 100644 --- a/src/io/stringify.js +++ b/src/io/stringify.js @@ -1 +1 @@ -export const stringify = n => n.toString( ) ; +export const stringify = (n) => n.toString(); diff --git a/src/logarithmic/index.js b/src/logarithmic/index.js index 5ddc59c..d0da3af 100644 --- a/src/logarithmic/index.js +++ b/src/logarithmic/index.js @@ -1,6 +1,6 @@ -export * from "./log.js" ; -export * from "./log2.js" ; -export * from "./loge.js" ; -export * from "./loglog.js" ; -export * from "./loglog2.js" ; -export * from "./logloge.js" ; +export * from './log.js'; +export * from './log2.js'; +export * from './loge.js'; +export * from './loglog.js'; +export * from './loglog2.js'; +export * from './logloge.js'; diff --git a/src/logarithmic/log.js b/src/logarithmic/log.js index 96b3536..2e43788 100644 --- a/src/logarithmic/log.js +++ b/src/logarithmic/log.js @@ -1 +1 @@ -export const log = ( a , b ) => Math.log( b ) / Math.log( a ) ; +export const log = (a, b) => Math.log(b) / Math.log(a); diff --git a/src/logarithmic/log2.js b/src/logarithmic/log2.js index 7bd2c59..0f4ecbc 100644 --- a/src/logarithmic/log2.js +++ b/src/logarithmic/log2.js @@ -1 +1 @@ -export const log2 = n => Math.log2( n ) ; +export const log2 = (n) => Math.log2(n); diff --git a/src/logarithmic/loge.js b/src/logarithmic/loge.js index 81c5dfe..8bce3fb 100644 --- a/src/logarithmic/loge.js +++ b/src/logarithmic/loge.js @@ -1 +1 @@ -export const loge = n => Math.log( n ) ; +export const loge = (n) => Math.log(n); diff --git a/src/logarithmic/loglog.js b/src/logarithmic/loglog.js index dcefe74..7589039 100644 --- a/src/logarithmic/loglog.js +++ b/src/logarithmic/loglog.js @@ -1 +1,2 @@ -export const loglog = ( a , b ) => Math.log( Math.log( b ) / Math.log( a ) ) / Math.log( a ) ; +export const loglog = (a, b) => + Math.log(Math.log(b) / Math.log(a)) / Math.log(a); diff --git a/src/logarithmic/loglog2.js b/src/logarithmic/loglog2.js index effe771..6d43257 100644 --- a/src/logarithmic/loglog2.js +++ b/src/logarithmic/loglog2.js @@ -1 +1 @@ -export const loglog2 = n => Math.log( Math.log( n ) / Math.log( 2 ) ) / Math.log( 2 ) ; +export const loglog2 = (n) => Math.log(Math.log(n) / Math.log(2)) / Math.log(2); diff --git a/src/logarithmic/logloge.js b/src/logarithmic/logloge.js index e690746..82214b9 100644 --- a/src/logarithmic/logloge.js +++ b/src/logarithmic/logloge.js @@ -1 +1 @@ -export const logloge = n => Math.log( Math.log( n ) ) ; +export const logloge = (n) => Math.log(Math.log(n)); diff --git a/src/memory/copy.js b/src/memory/copy.js index b8db6d7..b745221 100644 --- a/src/memory/copy.js +++ b/src/memory/copy.js @@ -1 +1 @@ -export const copy = a => a ; +export const copy = (a) => a; diff --git a/src/memory/index.js b/src/memory/index.js index ca75773..b1f148f 100644 --- a/src/memory/index.js +++ b/src/memory/index.js @@ -1 +1 @@ -export * from "./copy.js" ; +export * from './copy.js'; diff --git a/src/predicate/constants/eq0.js b/src/predicate/constants/eq0.js index c445922..1e17430 100644 --- a/src/predicate/constants/eq0.js +++ b/src/predicate/constants/eq0.js @@ -1 +1 @@ -export const eq0 = n => n === 0 ; +export const eq0 = (n) => n === 0; diff --git a/src/predicate/constants/eq1.js b/src/predicate/constants/eq1.js index fb3b976..7918f62 100644 --- a/src/predicate/constants/eq1.js +++ b/src/predicate/constants/eq1.js @@ -1 +1 @@ -export const eq1 = n => n === 1 ; +export const eq1 = (n) => n === 1; diff --git a/src/predicate/constants/eq_1.js b/src/predicate/constants/eq_1.js index 85dd30e..36b0531 100644 --- a/src/predicate/constants/eq_1.js +++ b/src/predicate/constants/eq_1.js @@ -1 +1 @@ -export const eq_1 = n => n === -1 ; +export const eq_1 = (n) => n === -1; diff --git a/src/predicate/constants/ge1.js b/src/predicate/constants/ge1.js index 267da61..308b2ba 100644 --- a/src/predicate/constants/ge1.js +++ b/src/predicate/constants/ge1.js @@ -1 +1 @@ -export const ge1 = n => n >= 1 ; +export const ge1 = (n) => n >= 1; diff --git a/src/predicate/constants/gt0.js b/src/predicate/constants/gt0.js index c5ae501..14d56e1 100644 --- a/src/predicate/constants/gt0.js +++ b/src/predicate/constants/gt0.js @@ -1 +1 @@ -export const gt0 = n => n > 0 ; +export const gt0 = (n) => n > 0; diff --git a/src/predicate/constants/gt1.js b/src/predicate/constants/gt1.js index c31a33b..dc45fa4 100644 --- a/src/predicate/constants/gt1.js +++ b/src/predicate/constants/gt1.js @@ -1 +1 @@ -export const gt1 = n => n > 1 ; +export const gt1 = (n) => n > 1; diff --git a/src/predicate/constants/index.js b/src/predicate/constants/index.js index 9b839b6..43a3acf 100644 --- a/src/predicate/constants/index.js +++ b/src/predicate/constants/index.js @@ -1,8 +1,8 @@ -export * from "./eq0.js" ; -export * from "./eq1.js" ; -export * from "./eq_1.js" ; -export * from "./ge1.js" ; -export * from "./gt0.js" ; -export * from "./gt1.js" ; -export * from "./le1.js" ; -export * from "./lt1.js" ; +export * from './eq0.js'; +export * from './eq1.js'; +export * from './eq_1.js'; +export * from './ge1.js'; +export * from './gt0.js'; +export * from './gt1.js'; +export * from './le1.js'; +export * from './lt1.js'; diff --git a/src/predicate/constants/le1.js b/src/predicate/constants/le1.js index 99a40d5..bacff78 100644 --- a/src/predicate/constants/le1.js +++ b/src/predicate/constants/le1.js @@ -1 +1 @@ -export const le1 = n => n <= 1 ; +export const le1 = (n) => n <= 1; diff --git a/src/predicate/constants/lt1.js b/src/predicate/constants/lt1.js index 93e78c9..059a290 100644 --- a/src/predicate/constants/lt1.js +++ b/src/predicate/constants/lt1.js @@ -1 +1 @@ -export const lt1 = n => n < 1 ; +export const lt1 = (n) => n < 1; diff --git a/src/predicate/eq.js b/src/predicate/eq.js index 52c947b..4ce0d59 100644 --- a/src/predicate/eq.js +++ b/src/predicate/eq.js @@ -1 +1 @@ -export const eq = ( a , b ) => a === b ; +export const eq = (a, b) => a === b; diff --git a/src/predicate/ge.js b/src/predicate/ge.js index 6411912..26d9c8e 100644 --- a/src/predicate/ge.js +++ b/src/predicate/ge.js @@ -1 +1 @@ -export const ge = ( a , b ) => a >= b ; +export const ge = (a, b) => a >= b; diff --git a/src/predicate/gt.js b/src/predicate/gt.js index b039432..863c978 100644 --- a/src/predicate/gt.js +++ b/src/predicate/gt.js @@ -1 +1 @@ -export const gt = ( a , b ) => a > b ; +export const gt = (a, b) => a > b; diff --git a/src/predicate/index.js b/src/predicate/index.js index 97d7f6c..20563af 100644 --- a/src/predicate/index.js +++ b/src/predicate/index.js @@ -1,7 +1,7 @@ -export * from "./constants/index.js" ; -export * from "./eq.js" ; -export * from "./ge.js" ; -export * from "./gt.js" ; -export * from "./le.js" ; -export * from "./lt.js" ; -export * from "./ne.js" ; +export * from './constants/index.js'; +export * from './eq.js'; +export * from './ge.js'; +export * from './gt.js'; +export * from './le.js'; +export * from './lt.js'; +export * from './ne.js'; diff --git a/src/predicate/le.js b/src/predicate/le.js index 2aceca3..6384b5f 100644 --- a/src/predicate/le.js +++ b/src/predicate/le.js @@ -1 +1 @@ -export const le = ( a , b ) => a <= b ; +export const le = (a, b) => a <= b; diff --git a/src/predicate/lt.js b/src/predicate/lt.js index 8d1b9b3..c46a4f5 100644 --- a/src/predicate/lt.js +++ b/src/predicate/lt.js @@ -1 +1 @@ -export const lt = ( a , b ) => a < b ; +export const lt = (a, b) => a < b; diff --git a/src/predicate/ne.js b/src/predicate/ne.js index 7835c06..5ebd017 100644 --- a/src/predicate/ne.js +++ b/src/predicate/ne.js @@ -1 +1 @@ -export const ne = ( a , b ) => a !== b ; +export const ne = (a, b) => a !== b; diff --git a/src/trigonometry/PI.js b/src/trigonometry/PI.js index 9307123..1392bf6 100644 --- a/src/trigonometry/PI.js +++ b/src/trigonometry/PI.js @@ -1 +1 @@ -export const PI = Math.PI ; +export const PI = Math.PI; diff --git a/src/trigonometry/atan2.js b/src/trigonometry/atan2.js index c68d80c..1ecd0d3 100644 --- a/src/trigonometry/atan2.js +++ b/src/trigonometry/atan2.js @@ -1 +1 @@ -export const atan2 = Math.atan2 ; +export const atan2 = Math.atan2; diff --git a/src/trigonometry/cos.js b/src/trigonometry/cos.js index 5f557a8..6fac23b 100644 --- a/src/trigonometry/cos.js +++ b/src/trigonometry/cos.js @@ -1 +1 @@ -export const cos = Math.cos ; +export const cos = Math.cos; diff --git a/src/trigonometry/index.js b/src/trigonometry/index.js index ac5977e..e603524 100644 --- a/src/trigonometry/index.js +++ b/src/trigonometry/index.js @@ -1,4 +1,4 @@ -export * from "./PI.js" ; -export * from "./atan2.js" ; -export * from "./cos.js" ; -export * from "./sin.js" ; +export * from './PI.js'; +export * from './atan2.js'; +export * from './cos.js'; +export * from './sin.js'; diff --git a/src/trigonometry/sin.js b/src/trigonometry/sin.js index d98c358..d782c6d 100644 --- a/src/trigonometry/sin.js +++ b/src/trigonometry/sin.js @@ -1 +1 @@ -export const sin = Math.sin ; +export const sin = Math.sin; diff --git a/test/src/arithmetic/add.js b/test/src/arithmetic/add.js index 78e68c6..f92694d 100644 --- a/test/src/arithmetic/add.js +++ b/test/src/arithmetic/add.js @@ -1,31 +1,37 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test ( "add" , t => { +test('add', (t) => { + const one = function (a, b) { + t.is(number.add(a, b), a + b, a + ' + ' + b); + }; - const one = function ( a , b ) { - t.is ( number . add ( a , b ) , a + b , a + " + " + b ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - const a = Math . random ( ) ; - const b = Math . random ( ) ; - - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one ( Infinity , Infinity ) ; - one ( Infinity , 0 ) ; - one ( 0 , Infinity ) ; - one ( -Infinity , -Infinity ) ; - one ( -Infinity , 0 ) ; - one ( 0 , -Infinity ) ; - - t.truthy ( isNaN( number.add( -Infinity , Infinity ) ) , '-Infinity + Infinity' ) ; - t.truthy ( isNaN( number.add( Infinity , -Infinity ) ) , 'Infinity + -Infinity' ) ; - -} ) ; + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + + t.true( + Number.isNaN( + number.add(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY), + ), + '-Infinity + Infinity', + ); + t.true( + Number.isNaN( + number.add(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY), + ), + 'Infinity + -Infinity', + ); +}); diff --git a/test/src/arithmetic/constants/add1.js b/test/src/arithmetic/constants/add1.js index 8addc80..9f9b0c8 100644 --- a/test/src/arithmetic/constants/add1.js +++ b/test/src/arithmetic/constants/add1.js @@ -1,21 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "add1" , assert => { +test('add1', (t) => { + const one = function (n) { + t.deepEqual(number.add1(n), n + 1, n + ' + ' + 1); + }; - const one = function ( n ) { - assert . deepEqual ( number . add1 ( n ) , n + 1 , n + " + " + 1 ) ; - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - one ( Math . random ( ) ) ; + const n = 10; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/div2.js b/test/src/arithmetic/constants/div2.js index 439c5bf..aba381d 100644 --- a/test/src/arithmetic/constants/div2.js +++ b/test/src/arithmetic/constants/div2.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "div2" , assert => { +test('div2', (t) => { + const one = function (n) { + t.deepEqual(number.div2(n), n / 2, n + ' / ' + 2); + }; - const one = function ( n ) { - assert . deepEqual ( number . div2 ( n ) , n / 2 , n + " / " + 2 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) ) ; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/iadd1.js b/test/src/arithmetic/constants/iadd1.js index 7ce6ebd..df0036d 100644 --- a/test/src/arithmetic/constants/iadd1.js +++ b/test/src/arithmetic/constants/iadd1.js @@ -1,25 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "iadd1" , assert => { +test('iadd1', (t) => { + const one = function (n) { + const x = n; - const one = function ( n ) { + t.deepEqual(number.iadd1(x), (n += 1), x + ' += ' + 1); + }; - const x = n ; - - assert . deepEqual ( number . iadd1 ( x ) , n += 1 , x + " += " + 1 ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - one ( Math . random ( ) ) ; + const n = 10; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/idiv2.js b/test/src/arithmetic/constants/idiv2.js index 0c29526..db9faa0 100644 --- a/test/src/arithmetic/constants/idiv2.js +++ b/test/src/arithmetic/constants/idiv2.js @@ -1,23 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "idiv2" , assert => { +test('idiv2', (t) => { + const one = function (n) { + const x = n; - const one = function ( n ) { + t.deepEqual(number.idiv2(x), (n /= 2), x + ' /= ' + 2); + }; - let x = n ; + const n = 10; - assert.deepEqual ( number . idiv2 ( x ) , n /= 2 , x + " /= " + 2 ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) ) ; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/imul2.js b/test/src/arithmetic/constants/imul2.js index 64cc987..1c3a381 100644 --- a/test/src/arithmetic/constants/imul2.js +++ b/test/src/arithmetic/constants/imul2.js @@ -1,25 +1,21 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "imul2" , assert => { +test('imul2', (t) => { + const one = function (a) { + const x = a; - const one = function ( a ) { + t.deepEqual(number.imul2(x), (a *= 2), x + ' *= 2'); + }; - let x = a ; + const n = 10; - assert.deepEqual( number.imul2( x ) , a *= 2 , x + " *= 2" ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/imul5.js b/test/src/arithmetic/constants/imul5.js index 11abbbd..a5b2acb 100644 --- a/test/src/arithmetic/constants/imul5.js +++ b/test/src/arithmetic/constants/imul5.js @@ -1,25 +1,21 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "imul5" , assert => { +test('imul5', (t) => { + const one = function (a) { + const x = a; - const one = function ( a ) { + t.deepEqual(number.imul5(x), (a *= 5), x + ' *= 5'); + }; - let x = a ; + const n = 10; - assert.deepEqual( number.imul5( x ) , a *= 5 , x + " *= 5" ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/isub1.js b/test/src/arithmetic/constants/isub1.js index 2f1e8c3..79573be 100644 --- a/test/src/arithmetic/constants/isub1.js +++ b/test/src/arithmetic/constants/isub1.js @@ -1,25 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "isub1" , assert => { +test('isub1', (t) => { + const one = function (n) { + const x = n; - const one = function ( n ) { + t.deepEqual(number.isub1(x), (n -= 1), x + ' -= ' + 1); + }; - let x = n ; - - assert.deepEqual ( number . isub1 ( x ) , n -= 1 , x + " -= " + 1 ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - one ( Math . random ( ) ) ; + const n = 10; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/mul2.js b/test/src/arithmetic/constants/mul2.js index 2d4865c..cf7bfd4 100644 --- a/test/src/arithmetic/constants/mul2.js +++ b/test/src/arithmetic/constants/mul2.js @@ -1,21 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "mul2" , assert => { +test('mul2', (t) => { + const one = function (a) { + t.deepEqual(number.mul2(a), a * 2, a + ' * 2'); + }; - const one = function ( a ) { - assert.deepEqual( number.mul2( a ) , a * 2 , a + " * 2" ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/mul5.js b/test/src/arithmetic/constants/mul5.js index d65d7d9..a042525 100644 --- a/test/src/arithmetic/constants/mul5.js +++ b/test/src/arithmetic/constants/mul5.js @@ -1,21 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "mul5" , assert => { +test('mul5', (t) => { + const one = function (a) { + t.deepEqual(number.mul5(a), a * 5, a + ' * 5'); + }; - const one = function ( a ) { - assert.deepEqual( number.mul5( a ) , a * 5 , a + " * 5" ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/constants/sub1.js b/test/src/arithmetic/constants/sub1.js index 9261ae5..6d3e46c 100644 --- a/test/src/arithmetic/constants/sub1.js +++ b/test/src/arithmetic/constants/sub1.js @@ -1,21 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "sub1" , assert => { +test('sub1', (t) => { + const one = function (n) { + t.deepEqual(number.sub1(n), n - 1, n + ' - ' + 1); + }; - const one = function ( n ) { - assert . deepEqual ( number . sub1 ( n ) , n - 1 , n + " - " + 1 ) ; - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - one ( Math . random ( ) ) ; + const n = 10; + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/div.js b/test/src/arithmetic/div.js index 379cb16..b33e455 100644 --- a/test/src/arithmetic/div.js +++ b/test/src/arithmetic/div.js @@ -1,32 +1,30 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test ( "div" , t => { +test('div', (t) => { + const one = function (a, b) { + t.deepEqual(number.div(a, b), a / b, a + ' / ' + b); + }; - const one = function ( a , b ) { - t.deepEqual ( number . div ( a , b ) , a / b , a + " / " + b ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - let a = Math . random ( ) ; - let b = Math . random ( ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - - const nan = function ( a, b ) { - t.truthy( isNaN( number.div( a, b ) ), a + " / " + b ); - } ; + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); - nan( Infinity, Infinity ); - nan( -Infinity, -Infinity ); - nan( -Infinity, Infinity ); - nan( Infinity, -Infinity ); + const nan = function (a, b) { + t.true(Number.isNaN(number.div(a, b)), a + ' / ' + b); + }; -} ) ; + nan(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + nan(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/divmod.js b/test/src/arithmetic/divmod.js index e605e7f..ea0539b 100644 --- a/test/src/arithmetic/divmod.js +++ b/test/src/arithmetic/divmod.js @@ -1,20 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import int32 from "@aureooms/js-int32" ; -import * as random from "@aureooms/js-random" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import int32 from '@aureooms/js-int32'; +import * as random from '@aureooms/js-random'; -test ( "divmod" , t => { +test('divmod', (t) => { + const one = function (a, b) { + t.deepEqual(number.divmod(a, b), [(a / b) | 0, a % b], a + ' /% ' + b); + }; - const one = function ( a , b ) { - t.deepEqual ( number . divmod ( a , b ) , [ a / b | 0 , a % b ] , a + " /% " + b ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = random . randint ( int32 . min , int32 . max + 1 ) ; - const b = random . randint ( int32 . min , int32 . max + 1 ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = random.randint(int32.min, int32.max + 1); + const b = random.randint(int32.min, int32.max + 1); + one(a, b); } - -} ) ; +}); diff --git a/test/src/arithmetic/iadd.js b/test/src/arithmetic/iadd.js index 20bfb29..1d43b48 100644 --- a/test/src/arithmetic/iadd.js +++ b/test/src/arithmetic/iadd.js @@ -1,32 +1,38 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "iadd", t => { +test('iadd', (t) => { + const one = function (a, b) { + const x = a; - const one = function ( a, b ) { - - let x = a ; - - t.deepEqual( number.iadd( x, b ), a += b, x + " += " + b ); - - } ; + t.deepEqual(number.iadd(x, b), (a += b), x + ' += ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - let a = Math.random(); - let b = Math.random(); - one( a, b ); + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - - t.truthy ( isNaN( number.iadd( -Infinity , Infinity ) ) , '-Infinity += Infinity' ) ; - t.truthy ( isNaN( number.iadd( Infinity , -Infinity ) ) , 'Infinity += -Infinity' ) ; - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + + t.true( + Number.isNaN( + number.iadd(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY), + ), + '-Infinity += Infinity', + ); + t.true( + Number.isNaN( + number.iadd(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY), + ), + 'Infinity += -Infinity', + ); +}); diff --git a/test/src/arithmetic/idiv.js b/test/src/arithmetic/idiv.js index f081050..d688519 100644 --- a/test/src/arithmetic/idiv.js +++ b/test/src/arithmetic/idiv.js @@ -1,36 +1,32 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "idiv", t => { +test('idiv', (t) => { + const one = function (a, b) { + const x = a; - const one = function ( a, b ) { - - let x = a ; - - t.deepEqual( number.idiv( x, b ), a /= b, x + " /= " + b ); - - } ; + t.deepEqual(number.idiv(x, b), (a /= b), x + ' /= ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - let a = Math.random(); - let b = Math.random(); - one( a, b ); + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - - const nan = function ( a, b ) { - t.truthy( isNaN( number.idiv( a, b ) ), a + " /= " + b ); - } ; + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); - nan( Infinity, Infinity ); - nan( -Infinity, -Infinity ); - nan( -Infinity, Infinity ); - nan( Infinity, -Infinity ); + const nan = function (a, b) { + t.true(Number.isNaN(number.idiv(a, b)), a + ' /= ' + b); + }; -} ); + nan(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + nan(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/idivmod.js b/test/src/arithmetic/idivmod.js index c3ac874..2bc3b5d 100644 --- a/test/src/arithmetic/idivmod.js +++ b/test/src/arithmetic/idivmod.js @@ -1,25 +1,21 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import int32 from "@aureooms/js-int32" ; -import * as random from "@aureooms/js-random" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import int32 from '@aureooms/js-int32'; +import * as random from '@aureooms/js-random'; -test ( "idivmod" , t => { +test('idivmod', (t) => { + const one = function (a, b) { + const q = (a / b) | 0; + const x = a; - const one = function ( a , b ) { + t.deepEqual(number.idivmod(x, b), [q, (a %= b)], x + ' /%= ' + b); + }; - let q = a / b | 0 ; - let x = a ; + const n = 10; - t.deepEqual ( number . idivmod ( x , b ) , [ q , a %= b ] , x + " /%= " + b ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - let a = random . randint ( int32 . min , int32 . max + 1 ) ; - let b = random . randint ( int32 . min , int32 . max + 1 ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = random.randint(int32.min, int32.max + 1); + const b = random.randint(int32.min, int32.max + 1); + one(a, b); } - -} ) ; +}); diff --git a/test/src/arithmetic/imod.js b/test/src/arithmetic/imod.js index 772b6a9..c525afd 100644 --- a/test/src/arithmetic/imod.js +++ b/test/src/arithmetic/imod.js @@ -1,24 +1,20 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import int32 from "@aureooms/js-int32" ; -import * as random from "@aureooms/js-random" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import int32 from '@aureooms/js-int32'; +import * as random from '@aureooms/js-random'; -test ( "imod" , t => { +test('imod', (t) => { + const one = function (a, b) { + const x = a; - const one = function ( a , b ) { + t.deepEqual(number.imod(x, b), (a %= b), x + ' %= ' + b); + }; - let x = a ; + const n = 10; - t.deepEqual ( number . imod ( x , b ) , a %= b , x + " %= " + b ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - let a = random . randint ( int32 . min , int32 . max + 1 ) ; - let b = random . randint ( int32 . min , int32 . max + 1 ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = random.randint(int32.min, int32.max + 1); + const b = random.randint(int32.min, int32.max + 1); + one(a, b); } - -} ) ; +}); diff --git a/test/src/arithmetic/imul.js b/test/src/arithmetic/imul.js index 664bcd6..cb97fb8 100644 --- a/test/src/arithmetic/imul.js +++ b/test/src/arithmetic/imul.js @@ -1,36 +1,32 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "imul", t => { +test('imul', (t) => { + const one = function (a, b) { + const x = a; - const one = function ( a, b ) { - - let x = a ; - - t.deepEqual( number.imul( x, b ), a *= b, x + " *= " + b ); - - } ; + t.deepEqual(number.imul(x, b), (a *= b), x + ' *= ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - let a = Math.random(); - let b = Math.random(); - one( a, b ); + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one( Infinity, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - - const nan = function ( a, b ) { - t.truthy( isNaN( number.mul( a, b ) ), a + " *= " + b ); - } ; + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); - nan( Infinity, 0 ); - nan( 0, Infinity ); - nan( -Infinity, 0 ); - nan( 0, -Infinity ); + const nan = function (a, b) { + t.true(Number.isNaN(number.mul(a, b)), a + ' *= ' + b); + }; -} ); + nan(Number.POSITIVE_INFINITY, 0); + nan(0, Number.POSITIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, 0); + nan(0, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/ishl.js b/test/src/arithmetic/ishl.js index 276b720..5671b54 100644 --- a/test/src/arithmetic/ishl.js +++ b/test/src/arithmetic/ishl.js @@ -1,18 +1,14 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "ishl" , t => { +test('ishl', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - let a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - let b = Math.floor( Math.random() * 32 ) ; - let x = a ; - - t.deepEqual( number.ishl( x , b ) , a <<= b , x + " <<= " + b ) ; + for (let i = 0; i < n; ++i) { + let a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + const x = a; + t.deepEqual(number.ishl(x, b), (a <<= b), x + ' <<= ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/ishr.js b/test/src/arithmetic/ishr.js index d3215bf..435d4bb 100644 --- a/test/src/arithmetic/ishr.js +++ b/test/src/arithmetic/ishr.js @@ -1,18 +1,14 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "ishr" , t => { +test('ishr', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - let a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - let b = Math.floor( Math.random() * 32 ) ; - let x = a ; - - t.deepEqual( number.ishr( x , b ) , a >>= b , x + " >>= " + b ) ; + for (let i = 0; i < n; ++i) { + let a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + const x = a; + t.deepEqual(number.ishr(x, b), (a >>= b), x + ' >>= ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/ishu.js b/test/src/arithmetic/ishu.js index 3785024..fde30ac 100644 --- a/test/src/arithmetic/ishu.js +++ b/test/src/arithmetic/ishu.js @@ -1,18 +1,14 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "ishu" , t => { +test('ishu', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - let a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - let b = Math.floor( Math.random() * 32 ) ; - let x = a ; - - t.deepEqual( number.ishu( x , b ) , a >>>= b , x + " >>> " + b ) ; + for (let i = 0; i < n; ++i) { + let a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + const x = a; + t.deepEqual(number.ishu(x, b), (a >>>= b), x + ' >>> ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/isub.js b/test/src/arithmetic/isub.js index 32d7364..25ec514 100644 --- a/test/src/arithmetic/isub.js +++ b/test/src/arithmetic/isub.js @@ -1,36 +1,32 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "isub", t => { +test('isub', (t) => { + const one = function (a, b) { + const x = a; - const one = function ( a, b ) { - - let x = a ; - - t.deepEqual( number.isub( x, b ), a -= b, x + " -= " + b ); - - } ; + t.deepEqual(number.isub(x, b), (a -= b), x + ' -= ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - - const nan = function ( a, b ) { - t.truthy( isNaN( number.isub( a, b ) ), a + " -= " + b ); - } ; + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); - nan( Infinity, Infinity ); - nan( -Infinity, -Infinity ); + const nan = function (a, b) { + t.true(Number.isNaN(number.isub(a, b)), a + ' -= ' + b); + }; -} ); + nan(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/mod.js b/test/src/arithmetic/mod.js index 037c05c..a18333a 100644 --- a/test/src/arithmetic/mod.js +++ b/test/src/arithmetic/mod.js @@ -1,21 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import int32 from "@aureooms/js-int32" ; -import * as random from "@aureooms/js-random" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import int32 from '@aureooms/js-int32'; +import * as random from '@aureooms/js-random'; +test('mod', (t) => { + const one = function (a, b) { + t.deepEqual(number.mod(a, b), a % b, a + ' % ' + b); + }; -test ( "mod" , t => { + const n = 10; - const one = function ( a , b ) { - t.deepEqual ( number . mod ( a , b ) , a % b , a + " % " + b ) ; - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = random . randint ( int32 . min , int32 . max + 1 ) ; - const b = random . randint ( int32 . min , int32 . max + 1 ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = random.randint(int32.min, int32.max + 1); + const b = random.randint(int32.min, int32.max + 1); + one(a, b); } - -} ) ; +}); diff --git a/test/src/arithmetic/mul.js b/test/src/arithmetic/mul.js index 3a81261..d65ca66 100644 --- a/test/src/arithmetic/mul.js +++ b/test/src/arithmetic/mul.js @@ -1,32 +1,30 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "mul", t => { - - const one = function ( a, b ) { - t.deepEqual( number.mul( a, b ), a * b, a + " * " + b ); - } ; +test('mul', (t) => { + const one = function (a, b) { + t.deepEqual(number.mul(a, b), a * b, a + ' * ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - - const nan = function ( a, b ) { - t.truthy( isNaN( number.mul( a, b ) ), a + " * " + b ); - } ; + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); - nan( Infinity, 0 ); - nan( 0, Infinity ); - nan( -Infinity, 0 ); - nan( 0, -Infinity ); + const nan = function (a, b) { + t.true(Number.isNaN(number.mul(a, b)), a + ' * ' + b); + }; -} ); + nan(Number.POSITIVE_INFINITY, 0); + nan(0, Number.POSITIVE_INFINITY); + nan(Number.NEGATIVE_INFINITY, 0); + nan(0, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/neg.js b/test/src/arithmetic/neg.js index 315864a..1921279 100644 --- a/test/src/arithmetic/neg.js +++ b/test/src/arithmetic/neg.js @@ -1,20 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "neg", t => { - - const one = function ( a ) { - t.deepEqual( number.neg( a ), -a, "-" + a ); - } ; +test('neg', (t) => { + const one = function (a) { + t.deepEqual(number.neg(a), -a, '-' + a); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - one( Math.random( ) ); + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one( Infinity ); - one( 0 ); - one( -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/arithmetic/shl.js b/test/src/arithmetic/shl.js index 22bf6b9..d80aaa2 100644 --- a/test/src/arithmetic/shl.js +++ b/test/src/arithmetic/shl.js @@ -1,17 +1,13 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "shl" , t => { +test('shl', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - const a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - const b = Math.floor( Math.random() * 32 ) ; - - t.deepEqual( number.shl( a , b ) , a << b , a + " << " + b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + t.deepEqual(number.shl(a, b), a << b, a + ' << ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/shr.js b/test/src/arithmetic/shr.js index f5329f2..0bc341d 100644 --- a/test/src/arithmetic/shr.js +++ b/test/src/arithmetic/shr.js @@ -1,17 +1,13 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "shr" , t => { +test('shr', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - const a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - const b = Math.floor( Math.random() * 32 ) ; - - t.deepEqual( number.shr( a , b ) , a >> b , a + " >> " + b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + t.deepEqual(number.shr(a, b), a >> b, a + ' >> ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/shu.js b/test/src/arithmetic/shu.js index 010724d..f580659 100644 --- a/test/src/arithmetic/shu.js +++ b/test/src/arithmetic/shu.js @@ -1,17 +1,13 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "shu" , t => { +test('shu', (t) => { + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - - const a = Math.floor( Math.random() * Math.pow( 2 , 32 ) ) ; - const b = Math.floor( Math.random() * 32 ) ; - - t.deepEqual( number.shu( a , b ) , a >>> b , a + " >>> " + b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.floor(Math.random() * 2 ** 32); + const b = Math.floor(Math.random() * 32); + t.deepEqual(number.shu(a, b), a >>> b, a + ' >>> ' + b); } - -} ) ; +}); diff --git a/test/src/arithmetic/special/div2n.js b/test/src/arithmetic/special/div2n.js index a7ec901..c2fa5fa 100644 --- a/test/src/arithmetic/special/div2n.js +++ b/test/src/arithmetic/special/div2n.js @@ -1,20 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "div2n" , t => { +test('div2n', (t) => { + const one = function (n, l) { + t.deepEqual(number.div2n(n, l), n / 2 ** l, n + ' / ' + 2 ** l); + }; - const one = function ( n , l ) { - t.deepEqual ( number . div2n ( n , l ) , n / Math.pow( 2 , l ) , n + " / " + Math.pow( 2 , l ) ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) , i ) ; + for (let i = 0; i < n; ++i) { + one(Math.random(), i); } - one ( Infinity , 4 ) ; - one ( 0 , 4 ) ; - one ( -Infinity , 4 ) ; - -} ) ; + one(Number.POSITIVE_INFINITY, 4); + one(0, 4); + one(Number.NEGATIVE_INFINITY, 4); +}); diff --git a/test/src/arithmetic/sub.js b/test/src/arithmetic/sub.js index 0c2cc8c..a6a1f8d 100644 --- a/test/src/arithmetic/sub.js +++ b/test/src/arithmetic/sub.js @@ -1,28 +1,36 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "sub", t => { - - const one = function ( a, b ) { - t.deepEqual( number.sub( a, b ), a - b, a + " - " + b ); - } ; +test('sub', (t) => { + const one = function (a, b) { + t.deepEqual(number.sub(a, b), a - b, a + ' - ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - - t.truthy( isNaN( number.sub( Infinity, Infinity ) ) , "Infinity - Infinity" ); -t.truthy( isNaN( number.sub( -Infinity, -Infinity ) ) , "-Infinity - -Infinity" ); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); -} ); + t.true( + Number.isNaN( + number.sub(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY), + ), + 'Infinity - Infinity', + ); + t.true( + Number.isNaN( + number.sub(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY), + ), + '-Infinity - -Infinity', + ); +}); diff --git a/test/src/compare/decreasing.js b/test/src/compare/decreasing.js index b643f6c..b26da2c 100644 --- a/test/src/compare/decreasing.js +++ b/test/src/compare/decreasing.js @@ -1,10 +1,11 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "decreasing", t => { - - t.truthy( number.decreasing( Infinity, 0 ) < 0, "number <" ); - t.truthy( number.decreasing( Infinity, Infinity ) === 0, "number =" ); - t.truthy( number.decreasing( 0, Infinity ) > 0, "number >" ); - -} ); +test('decreasing', (t) => { + t.true(number.decreasing(Number.POSITIVE_INFINITY, 0) < 0, 'number <'); + t.true( + number.decreasing(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) === 0, + 'number =', + ); + t.true(number.decreasing(0, Number.POSITIVE_INFINITY) > 0, 'number >'); +}); diff --git a/test/src/compare/increasing.js b/test/src/compare/increasing.js index ae37f05..b6a12b2 100644 --- a/test/src/compare/increasing.js +++ b/test/src/compare/increasing.js @@ -1,10 +1,11 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "increasing", t => { - - t.truthy( number.increasing( 0, Infinity ) < 0, "number <" ); - t.truthy( number.increasing( Infinity, Infinity ) === 0, "number =" ); - t.truthy( number.increasing( Infinity, 0 ) > 0, "number >" ); - -} ); +test('increasing', (t) => { + t.true(number.increasing(0, Number.POSITIVE_INFINITY) < 0, 'number <'); + t.true( + number.increasing(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) === 0, + 'number =', + ); + t.true(number.increasing(Number.POSITIVE_INFINITY, 0) > 0, 'number >'); +}); diff --git a/test/src/constants/all.js b/test/src/constants/all.js index 22897a2..cfa14fa 100644 --- a/test/src/constants/all.js +++ b/test/src/constants/all.js @@ -1,21 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "constants", t => { +test('constants', (t) => { + t.deepEqual(number.$_1(), -1, '$_1'); + t.is(number.$0(), 0, '$0'); + t.is(number.$1(), 1, '$1'); - t.deepEqual( number.$_1(), -1, "$_1" ); - t.deepEqual( number.$0(), 0, "$0" ); - t.deepEqual( number.$1(), 1, "$1" ); + t.is(number.eq_1(-1), true, 'eq_1 -1'); + t.is(number.eq0(0), true, 'eq0 0'); + t.is(number.eq1(1), true, 'eq1 1'); - t.deepEqual( number.eq_1( -1 ), true, "eq_1 -1" ); - t.deepEqual( number.eq0( 0 ), true, "eq0 0" ); - t.deepEqual( number.eq1( 1 ), true, "eq1 1" ); + t.is(number.eq_1(0), false, 'eq_1 0'); + t.is(number.eq0(1), false, 'eq0 1'); + t.is(number.eq1(-1), false, 'eq1 -1'); - t.deepEqual( number.eq_1( 0 ), false, "eq_1 0" ); - t.deepEqual( number.eq0( 1 ), false, "eq0 1" ); - t.deepEqual( number.eq1( -1 ), false, "eq1 -1" ); - - t.deepEqual( number.$2(), 2, "two" ); - t.deepEqual( number.$5(), 5, "five" ); - -} ); + t.is(number.$2(), 2, 'two'); + t.is(number.$5(), 5, 'five'); +}); diff --git a/test/src/exponential/constants/ipow2.js b/test/src/exponential/constants/ipow2.js index b3f84b7..6d57b27 100644 --- a/test/src/exponential/constants/ipow2.js +++ b/test/src/exponential/constants/ipow2.js @@ -1,25 +1,21 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "ipow2" , t => { +test('ipow2', (t) => { + const one = function (a) { + const x = a; - const one = function ( a ) { + t.deepEqual(number.ipow2(x), (a *= a), x + ' *= ' + x); + }; - let x = a ; + const n = 10; - t.deepEqual( number.ipow2( x ) , a *= a , x + " *= " + x ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - let a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/exponential/constants/pow2.js b/test/src/exponential/constants/pow2.js index 60019db..5cc6bf1 100644 --- a/test/src/exponential/constants/pow2.js +++ b/test/src/exponential/constants/pow2.js @@ -1,23 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test( "pow2" , t => { +test('pow2', (t) => { + const one = function (a) { + t.deepEqual(number.pow2(a), a * a, a + ' * ' + a); + }; - const one = function ( a ) { + const n = 10; - t.deepEqual( number.pow2( a ) , a * a , a + " * " + a ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/exponential/exp.js b/test/src/exponential/exp.js index a0672eb..1b8e0e2 100644 --- a/test/src/exponential/exp.js +++ b/test/src/exponential/exp.js @@ -1,21 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "exp", t => { - - const one = function ( a ) { - t.deepEqual( number.exp( a ), Math.exp( a ) , `e^${a}` ); - } ; +test('exp', (t) => { + const one = function (a) { + t.deepEqual(number.exp(a), Math.exp(a), `e^${a}`); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); - one( a ); + one(a); } - one( Infinity ); - one( 0 ); - one( -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/exponential/pow.js b/test/src/exponential/pow.js index 36e72e1..bd0b08a 100644 --- a/test/src/exponential/pow.js +++ b/test/src/exponential/pow.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "pow", t => { - - const one = function ( a , b ) { - t.deepEqual( number.pow( a , b ), Math.pow( a , b ) , a + "^" + b ); - } ; +test('pow', (t) => { + const one = function (a, b) { + t.deepEqual(number.pow(a, b), a ** b, a + '^' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/exponential/sqrt.js b/test/src/exponential/sqrt.js index ee1e476..4f8f787 100644 --- a/test/src/exponential/sqrt.js +++ b/test/src/exponential/sqrt.js @@ -1,23 +1,19 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "sqrt" , t => { +test('sqrt', (t) => { + const one = function (a) { + t.deepEqual(number.sqrt(a), Math.sqrt(a), 'sqrt ' + a); + }; - const one = function ( a ) { + const n = 10; - t.deepEqual( number.sqrt( a ) , Math.sqrt( a ) , "sqrt " + a ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - t.truthy( isNaN(number.sqrt(-Infinity)) , "sqrt -Infinity" ) ; - -} ) ; + one(Number.POSITIVE_INFINITY); + one(0); + t.true(Number.isNaN(number.sqrt(Number.NEGATIVE_INFINITY)), 'sqrt -Infinity'); +}); diff --git a/test/src/io/parse.js b/test/src/io/parse.js index fb4e15c..1a40ac5 100644 --- a/test/src/io/parse.js +++ b/test/src/io/parse.js @@ -1,20 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "parse", t => { - - const one = function ( a ) { - t.deepEqual( number.parse( a.toString( ) ), a, "parse('" + a + "')" ); - } ; +test('parse', (t) => { + const one = function (a) { + t.deepEqual(number.parse(a.toString()), a, "parse('" + a + "')"); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - one( Math.random( ) ); + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one( Infinity ); - one( 0 ); - one( -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/io/stringify.js b/test/src/io/stringify.js index a723889..42dfaf2 100644 --- a/test/src/io/stringify.js +++ b/test/src/io/stringify.js @@ -1,20 +1,18 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "stringify", t => { - - const one = function ( a ) { - t.deepEqual( number.stringify( a ), a.toString( ), "stringify(" + a + ")" ); - } ; +test('stringify', (t) => { + const one = function (a) { + t.deepEqual(number.stringify(a), a.toString(), 'stringify(' + a + ')'); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { - one( Math.random( ) ); + for (let i = 0; i < n; ++i) { + one(Math.random()); } - one( Infinity ); - one( 0 ); - one( -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/logarithmic/log.js b/test/src/logarithmic/log.js index 48225d9..cba7143 100644 --- a/test/src/logarithmic/log.js +++ b/test/src/logarithmic/log.js @@ -1,28 +1,26 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -const e = Math.E ; +const e = Math.E; -test ( "log" , t => { +test('log', (t) => { + const one = function (a, b) { + const expected = Math.log(b) / Math.log(a); + t.deepEqual(number.log(a, b), expected, 'log ( ' + a + ' , ' + b + ' )'); + }; - const one = function ( a , b ) { - const expected = Math.log( b) / Math.log( a ) ; - t.deepEqual ( number.log ( a , b ) , expected , "log ( " + a + " , " + b + " )" ) ; - } ; + one(2, 1); + one(2, 2 * 2 * 2); + one(2, 2 * 2 * 2 * 2); - one ( 2 , 1 ) ; - one ( 2 , 2 * 2 * 2 ) ; - one ( 2 , 2 * 2 * 2 * 2 ) ; + one(2, 2 * 2 * 2 * Math.sqrt(2)); - one ( 2 , 2 * 2 * 2 * Math.sqrt ( 2 ) ) ; + one(3, 3 * 3); + one(3, 3 * 3 * 3 * 3); - one ( 3 , 3 * 3 ) ; - one ( 3 , 3 * 3 * 3 * 3 ) ; + one(5, 5 * 5 * Math.sqrt(5)); - one ( 5 , 5 * 5 * Math.sqrt ( 5 ) ) ; - - one ( e , e * Math.sqrt ( e ) ) ; - one ( e , e * e * Math.sqrt ( e ) ) ; - one ( e , e * e * e * Math.sqrt ( e ) ) ; - -} ) ; + one(e, e * Math.sqrt(e)); + one(e, e * e * Math.sqrt(e)); + one(e, e * e * e * Math.sqrt(e)); +}); diff --git a/test/src/logarithmic/log2.js b/test/src/logarithmic/log2.js index be2dfae..d29d58d 100644 --- a/test/src/logarithmic/log2.js +++ b/test/src/logarithmic/log2.js @@ -1,17 +1,15 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test ( "log2" , t => { +test('log2', (t) => { + const one = function (n) { + const expected = Math.log2(n); + t.deepEqual(number.log2(n), expected, 'log2 ( ' + n + ' )'); + }; - const one = function ( n ) { - const expected = Math.log2( n ) ; - t.deepEqual ( number.log2 ( n ) , expected , "log2 ( " + n + " )" ) ; - } ; + one(1); + one(2 * 2 * 2); + one(2 * 2 * 2 * 2); - one ( 1 ) ; - one ( 2 * 2 * 2 ) ; - one ( 2 * 2 * 2 * 2 ) ; - - one ( 2 * 2 * 2 * Math.sqrt ( 2 ) ) ; - -} ) ; + one(2 * 2 * 2 * Math.sqrt(2)); +}); diff --git a/test/src/logarithmic/loge.js b/test/src/logarithmic/loge.js index fe9e8e8..decdc71 100644 --- a/test/src/logarithmic/loge.js +++ b/test/src/logarithmic/loge.js @@ -1,16 +1,14 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -const e = Math.E ; +const e = Math.E; -test ( "loge" , t => { +test('loge', (t) => { + const one = function (n, expected) { + t.deepEqual(number.loge(n), expected, 'loge ( ' + n + ' )'); + }; - const one = function ( n , expected ) { - t.deepEqual ( number.loge ( n ) , expected , "loge ( " + n + " )" ) ; - } ; - - one ( e * Math.sqrt ( e ) , 1.5 ) ; - one ( e * e * Math.sqrt ( e ) , 2.5 ) ; - one ( e * e * e * Math.sqrt ( e ) , 3.5 ) ; - -} ) ; + one(e * Math.sqrt(e), 1.5); + one(e * e * Math.sqrt(e), 2.5); + one(e * e * e * Math.sqrt(e), 3.5); +}); diff --git a/test/src/logarithmic/loglog.js b/test/src/logarithmic/loglog.js index 1c7a15f..011934f 100644 --- a/test/src/logarithmic/loglog.js +++ b/test/src/logarithmic/loglog.js @@ -1,38 +1,37 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import algo from "@aureooms/js-algorithms" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import algo from '@aureooms/js-algorithms'; -const epsilon = 1e-6 ; +const epsilon = 1e-6; -const compare = algo . __relepsilon__ ( epsilon ) ; +const compare = algo.__relepsilon__(epsilon); -const e = Math.E ; +const e = Math.E; -test ( "loglog" , t => { +test('loglog', (t) => { + const one = function (a, b, expected) { + const computed = number.loglog(a, b); - const one = function ( a , b , expected ) { + const isok = compare(computed, expected) === 0; - const computed = number.loglog ( a , b ) ; + t.true( + isok, + 'loglog ( ' + a + ' , ' + b + ' ) is ' + expected + ' got ' + computed, + ); + }; - const isok = compare ( computed , expected ) === 0 ; + one(2, 2 ** 1, 0); + one(2, 2 ** (2 * 2 * 2), 3); + one(2, 2 ** (2 * 2 * 2 * 2), 4); - t.truthy ( isok , "loglog ( " + a + " , " + b + " ) is " + expected + " got " + computed ) ; + one(2, Math.pow(2 * 2 * 2 * Math.sqrt(2)), 3.5); - } ; + one(3, 3 ** (3 * 3), 2); + one(3, 3 ** (3 * 3 * 3 * 3), 4); - one ( 2 , Math.pow ( 2 , 1 ) , 0 ) ; - one ( 2 , Math.pow ( 2 , 2 * 2 * 2 ) , 3 ) ; - one ( 2 , Math.pow ( 2 , 2 * 2 * 2 * 2 ) , 4 ) ; + one(5, 5 ** (5 * 5 * Math.sqrt(5)), 2.5); - one ( 2 , Math.pow ( 2 * 2 * 2 * Math.sqrt ( 2 ) ) , 3.5 ) ; - - one ( 3 , Math.pow ( 3 , 3 * 3 ) , 2 ) ; - one ( 3 , Math.pow ( 3 , 3 * 3 * 3 * 3 ) , 4 ) ; - - one ( 5 , Math.pow ( 5 , 5 * 5 * Math.sqrt ( 5 ) ) , 2.5 ) ; - - one ( e , Math.pow ( e * Math.sqrt ( e ) ) , 1.5 ) ; - one ( e , Math.pow ( e * e * Math.sqrt ( e ) ) , 2.5 ) ; - one ( e , Math.pow ( e * e * e * Math.sqrt ( e ) ) , 3.5 ) ; - -} ) ; + one(e, Math.pow(e * Math.sqrt(e)), 1.5); + one(e, Math.pow(e * e * Math.sqrt(e)), 2.5); + one(e, Math.pow(e * e * e * Math.sqrt(e)), 3.5); +}); diff --git a/test/src/logarithmic/loglog2.js b/test/src/logarithmic/loglog2.js index eb25d7e..8bfe063 100644 --- a/test/src/logarithmic/loglog2.js +++ b/test/src/logarithmic/loglog2.js @@ -1,27 +1,23 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import algo from "@aureooms/js-algorithms" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import algo from '@aureooms/js-algorithms'; -const epsilon = 1e-6 ; +const epsilon = 1e-6; -const compare = algo . __relepsilon__ ( epsilon ) ; +const compare = algo.__relepsilon__(epsilon); -test ( "loglog2" , t => { +test('loglog2', (t) => { + const one = function (n, expected) { + const computed = number.loglog2(n); - const one = function ( n , expected ) { + const isok = compare(computed, expected) === 0; - const computed = number.loglog2 ( n ) ; + t.true(isok, 'loglog2 ( ' + n + ' ) is ' + expected + ' got ' + computed); + }; - const isok = compare ( computed , expected ) === 0 ; + one(2 ** 1, 0); + one(2 ** (2 * 2 * 2), 3); + one(2 ** (2 * 2 * 2 * 2), 4); - t.truthy ( isok , "loglog2 ( " + n + " ) is " + expected + " got " + computed ) ; - - } ; - - one ( Math.pow ( 2 , 1 ) , 0 ) ; - one ( Math.pow ( 2 , 2 * 2 * 2 ) , 3 ) ; - one ( Math.pow ( 2 , 2 * 2 * 2 * 2 ) , 4 ) ; - - one ( Math.pow ( 2 * 2 * 2 * Math.sqrt ( 2 ) ) , 3.5 ) ; - -} ) ; + one(Math.pow(2 * 2 * 2 * Math.sqrt(2)), 3.5); +}); diff --git a/test/src/logarithmic/logloge.js b/test/src/logarithmic/logloge.js index f0fe325..b0223b2 100644 --- a/test/src/logarithmic/logloge.js +++ b/test/src/logarithmic/logloge.js @@ -1,28 +1,23 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; -import algo from "@aureooms/js-algorithms" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; +import algo from '@aureooms/js-algorithms'; -const epsilon = 1e-6 ; +const epsilon = 1e-6; -const compare = algo . __relepsilon__ ( epsilon ) ; +const compare = algo.__relepsilon__(epsilon); -const e = Math.E ; +const e = Math.E; -test ( "logloge" , t => { +test('logloge', (t) => { + const one = function (n, expected) { + const computed = number.logloge(n); - const one = function ( n , expected ) { + const isok = compare(computed, expected) === 0; - const computed = number.logloge ( n ) ; + t.true(isok, 'logloge ( ' + n + ' ) is ' + expected + ' got ' + computed); + }; - const isok = compare ( computed , expected ) === 0 ; - - t.truthy ( isok , "logloge ( " + n + " ) is " + expected + " got " + computed ) ; - - } ; - - - one ( Math.pow ( e * Math.sqrt ( e ) ) , 1.5 ) ; - one ( Math.pow ( e * e * Math.sqrt ( e ) ) , 2.5 ) ; - one ( Math.pow ( e * e * e * Math.sqrt ( e ) ) , 3.5 ) ; - -} ) ; + one(Math.pow(e * Math.sqrt(e)), 1.5); + one(Math.pow(e * e * Math.sqrt(e)), 2.5); + one(Math.pow(e * e * e * Math.sqrt(e)), 3.5); +}); diff --git a/test/src/memory/copy.js b/test/src/memory/copy.js index 96de459..9c7c860 100644 --- a/test/src/memory/copy.js +++ b/test/src/memory/copy.js @@ -1,32 +1,27 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "memory" , t => { +test('memory', (t) => { + const one = function (a) { + const b = number.copy(a); - const one = function ( a ) { + t.true(a === b, a + ' === ' + b); - const b = number.copy( a ) ; + const x = Math.random(); - t.truthy( a === b , a + " === " + b ) ; + a -= x; - const x = Math.random( ) ; + t.true(a === b - x, a + ' === ' + b + ' - ' + x); + }; - a -= x ; + const n = 10; - t.truthy( a === b - x , a + " === " + b + " - " + x ) ; - - } ; - - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - let a = Math.random( ) ; - one( a ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + one(a); } - one( Infinity ) ; - one( 0 ) ; - one( -Infinity ) ; - - -} ) + one(Number.POSITIVE_INFINITY); + one(0); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/constants/ge1.js b/test/src/predicate/constants/ge1.js index 10ee9a8..6471e2e 100644 --- a/test/src/predicate/constants/ge1.js +++ b/test/src/predicate/constants/ge1.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "ge1" , t => { +test('ge1', (t) => { + const one = function (n) { + t.deepEqual(number.ge1(n), n >= 1, n + ' >= ' + 1); + }; - const one = function ( n ) { - t.deepEqual ( number . ge1 ( n ) , n >= 1 , n + " >= " + 1 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) + 0.5 ) ; + for (let i = 0; i < n; ++i) { + one(Math.random() + 0.5); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/constants/gt0.js b/test/src/predicate/constants/gt0.js index ac35812..5719cc3 100644 --- a/test/src/predicate/constants/gt0.js +++ b/test/src/predicate/constants/gt0.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "gt0" , t => { +test('gt0', (t) => { + const one = function (n) { + t.deepEqual(number.gt0(n), n > 0, n + ' > ' + 0); + }; - const one = function ( n ) { - t.deepEqual ( number . gt0 ( n ) , n > 0 , n + " > " + 0 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) - 0.5 ) ; + for (let i = 0; i < n; ++i) { + one(Math.random() - 0.5); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/constants/gt1.js b/test/src/predicate/constants/gt1.js index 52ceccb..7037dcc 100644 --- a/test/src/predicate/constants/gt1.js +++ b/test/src/predicate/constants/gt1.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "gt1" , t => { +test('gt1', (t) => { + const one = function (n) { + t.deepEqual(number.gt1(n), n > 1, n + ' > ' + 1); + }; - const one = function ( n ) { - t.deepEqual ( number . gt1 ( n ) , n > 1 , n + " > " + 1 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) + 0.5 ) ; + for (let i = 0; i < n; ++i) { + one(Math.random() + 0.5); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/constants/le1.js b/test/src/predicate/constants/le1.js index 2a35b56..342486e 100644 --- a/test/src/predicate/constants/le1.js +++ b/test/src/predicate/constants/le1.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "le1" , t => { +test('le1', (t) => { + const one = function (n) { + t.deepEqual(number.le1(n), n <= 1, n + ' <= ' + 1); + }; - const one = function ( n ) { - t.deepEqual ( number . le1 ( n ) , n <= 1 , n + " <= " + 1 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) + 0.5 ) ; + for (let i = 0; i < n; ++i) { + one(Math.random() + 0.5); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/constants/lt1.js b/test/src/predicate/constants/lt1.js index 45857d4..209fff1 100644 --- a/test/src/predicate/constants/lt1.js +++ b/test/src/predicate/constants/lt1.js @@ -1,19 +1,17 @@ -import test from 'ava' ; -import * as number from "../../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../../src/index.js'; -test ( "lt1" , t => { +test('lt1', (t) => { + const one = function (n) { + t.deepEqual(number.lt1(n), n < 1, n + ' < ' + 1); + }; - const one = function ( n ) { - t.deepEqual ( number . lt1 ( n ) , n < 1 , n + " < " + 1 ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - one ( Math . random ( ) + 0.5 ) ; + for (let i = 0; i < n; ++i) { + one(Math.random() + 0.5); } - one ( Infinity ) ; - one ( -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/eq.js b/test/src/predicate/eq.js index 00bd2bb..95793c8 100644 --- a/test/src/predicate/eq.js +++ b/test/src/predicate/eq.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "eq", t => { - - const one = function ( a, b ) { - t.deepEqual( number.eq( a, b ), a === b, a + " === " + b ); - } ; +test('eq', (t) => { + const one = function (a, b) { + t.deepEqual(number.eq(a, b), a === b, a + ' === ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/ge.js b/test/src/predicate/ge.js index 705dd3b..cb6e43a 100644 --- a/test/src/predicate/ge.js +++ b/test/src/predicate/ge.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "ge", t => { +test('ge', (t) => { + const one = function (a, b) { + t.deepEqual(number.ge(a, b), a >= b, a + ' >= ' + b); + }; - const one = function ( a , b ) { - t.deepEqual ( number . ge ( a , b ) , a >= b , a + " >= " + b ) ; - } ; + const n = 10; - const n = 10 ; - - for ( let i = 0 ; i < n ; ++i ) { - const a = Math . random ( ) ; - const b = Math . random ( ) ; - one ( a , b ) ; + for (let i = 0; i < n; ++i) { + const a = Math.random(); + const b = Math.random(); + one(a, b); } - one ( Infinity , Infinity ) ; - one ( Infinity , 0 ) ; - one ( 0 , Infinity ) ; - one ( -Infinity , -Infinity ) ; - one ( -Infinity , 0 ) ; - one ( 0 , -Infinity ) ; - one ( -Infinity , Infinity ) ; - one ( Infinity , -Infinity ) ; - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/gt.js b/test/src/predicate/gt.js index 70226e2..c1d07ba 100644 --- a/test/src/predicate/gt.js +++ b/test/src/predicate/gt.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "gt", t => { - - const one = function ( a, b ) { - t.deepEqual( number.gt( a, b ), a > b, a + " > " + b ); - } ; +test('gt', (t) => { + const one = function (a, b) { + t.deepEqual(number.gt(a, b), a > b, a + ' > ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/le.js b/test/src/predicate/le.js index 31e9001..6755539 100644 --- a/test/src/predicate/le.js +++ b/test/src/predicate/le.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "le", t => { - - const one = function ( a, b ) { - t.deepEqual( number.le( a, b ), a <= b, a + " <= " + b ); - } ; +test('le', (t) => { + const one = function (a, b) { + t.deepEqual(number.le(a, b), a <= b, a + ' <= ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/lt.js b/test/src/predicate/lt.js index 72f73a5..c52e519 100644 --- a/test/src/predicate/lt.js +++ b/test/src/predicate/lt.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "lt", t => { - - const one = function ( a, b ) { - t.deepEqual( number.lt( a, b ), a < b, a + " < " + b ); - } ; +test('lt', (t) => { + const one = function (a, b) { + t.deepEqual(number.lt(a, b), a < b, a + ' < ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +}); diff --git a/test/src/predicate/ne.js b/test/src/predicate/ne.js index ad9f626..287b8be 100644 --- a/test/src/predicate/ne.js +++ b/test/src/predicate/ne.js @@ -1,27 +1,25 @@ -import test from 'ava' ; -import * as number from "../../../src/index.js" ; +import test from 'ava'; +import * as number from '../../../src/index.js'; -test( "ne", t => { - - const one = function ( a, b ) { - t.deepEqual( number.ne( a, b ), a !== b, a + " !== " + b ); - } ; +test('ne', (t) => { + const one = function (a, b) { + t.deepEqual(number.ne(a, b), a !== b, a + ' !== ' + b); + }; const n = 10; - for ( let i = 0 ; i < n ; ++i ) { + for (let i = 0; i < n; ++i) { const a = Math.random(); const b = Math.random(); - one( a, b ); + one(a, b); } - one( Infinity, Infinity ); - one( Infinity, 0 ); - one( 0, Infinity ); - one( -Infinity, -Infinity ); - one( -Infinity, 0 ); - one( 0, -Infinity ); - one( -Infinity, Infinity ); - one( Infinity, -Infinity ); - -} ); + one(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, 0); + one(0, Number.POSITIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, 0); + one(0, Number.NEGATIVE_INFINITY); + one(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); + one(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY); +});