Skip to content

Commit 438ea36

Browse files
🤖 chore: Lint source files.
These changes were automatically generated by a transform whose code can be found at: - https://github.com/aureooms/rejuvenate/blob/e086830dfe927964be93f46b8ecdacd2597eb487/src/transforms/sources:initial-lint.js Please contact the author of the transform if you believe there was an error.
1 parent 6fd535f commit 438ea36

19 files changed

+590
-560
lines changed

doc/scripts/header.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
var domReady = function(callback) {
2-
var state = document.readyState ;
3-
if ( state === 'interactive' || state === 'complete' ) {
4-
callback() ;
5-
}
6-
else {
1+
const domReady = function (callback) {
2+
const state = document.readyState;
3+
if (state === 'interactive' || state === 'complete') {
4+
callback();
5+
} else {
76
document.addEventListener('DOMContentLoaded', callback);
87
}
9-
} ;
10-
8+
};
119

12-
domReady(function(){
13-
14-
var projectname = document.createElement('a');
10+
domReady(() => {
11+
const projectname = document.createElement('a');
1512
projectname.classList.add('project-name');
1613
projectname.text = 'aureooms/js-rational';
17-
projectname.href = './index.html' ;
14+
projectname.href = './index.html';
1815

19-
var header = document.getElementsByTagName('header')[0] ;
20-
header.insertBefore(projectname,header.firstChild);
16+
const header = document.querySelectorAll('header')[0];
17+
header.insertBefore(projectname, header.firstChild);
2118

22-
var testlink = document.querySelector('header > a[data-ice="testLink"]') ;
23-
testlink.href = 'https://coveralls.io/github/aureooms/js-rational' ;
24-
testlink.target = '_BLANK' ;
19+
const testlink = document.querySelector('header > a[data-ice="testLink"]');
20+
testlink.href = 'https://coveralls.io/github/aureooms/js-rational';
21+
testlink.target = '_BLANK';
2522

26-
var searchBox = document.querySelector('.search-box');
27-
var input = document.querySelector('.search-input');
23+
const searchBox = document.querySelector('.search-box');
24+
const input = document.querySelector('.search-input');
2825

29-
// active search box when focus on searchBox.
30-
input.addEventListener('focus', function(){
26+
// Active search box when focus on searchBox.
27+
input.addEventListener('focus', () => {
3128
searchBox.classList.add('active');
3229
});
33-
3430
});

src/_constants.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
2-
export const DECIMAL_PREFIX = '.' ;
3-
export const REPETEND_PREFIX = '|' ;
4-
export const FRACTION_SEP = '/' ;
1+
export const DECIMAL_PREFIX = '.';
2+
export const REPETEND_PREFIX = '|';
3+
export const FRACTION_SEP = '/';

src/_parse_fixed_point.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1+
import {DECIMAL_PREFIX, REPETEND_PREFIX} from './_constants.js';
12

2-
import { DECIMAL_PREFIX , REPETEND_PREFIX } from "./_constants.js" ;
3+
export function _parse_fixed_point({_chr, reg, sub}) {
4+
return function (base, s) {
5+
const [integral, decimal] = s.split(DECIMAL_PREFIX);
6+
const [transient, repetend] = decimal.split(REPETEND_PREFIX);
37

4-
export function _parse_fixed_point ( { _chr , reg , sub } ) {
8+
const _integral = integral === '0' ? '' : integral;
9+
const _repetend = repetend || '';
510

6-
return function ( base , s ) {
11+
const _denominator =
12+
(!_repetend
13+
? _chr(1)
14+
: new Array(repetend.length + 1).join(_chr(base - 1))) +
15+
new Array(transient.length + 1).join(_chr(0));
716

8-
const [ integral , decimal ] = s.split(DECIMAL_PREFIX) ;
9-
const [ transient , repetend ] = decimal.split(REPETEND_PREFIX) ;
17+
const _big = _integral + transient + _repetend;
18+
const _small = _integral + transient || '0';
1019

11-
const _integral = integral === '0' ? '' : integral ;
12-
const _repetend = repetend || '' ;
20+
const _bign = reg(_big, base);
21+
const _smalln = reg(_small, base);
1322

14-
const _denominator = ( !_repetend ?
15-
_chr(1) :
16-
(new Array(repetend.length+1)).join( _chr(base-1) )
17-
) +
18-
(new Array(transient.length+1)).join( _chr(0) ) ;
19-
20-
const _big = _integral + transient + _repetend ;
21-
const _small = ( _integral + transient ) || '0' ;
22-
23-
const _bign = reg(_big, base) ;
24-
const _smalln = reg(_small, base) ;
25-
26-
const numerator = _repetend ? sub(_bign, _smalln) : _smalln ;
27-
const denominator = reg(_denominator, base) ;
28-
29-
return [ numerator , denominator ] ;
30-
31-
}
23+
const numerator = _repetend ? sub(_bign, _smalln) : _smalln;
24+
const denominator = reg(_denominator, base);
3225

26+
return [numerator, denominator];
27+
};
3328
}

src/_parse_fraction.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1+
import {FRACTION_SEP} from './_constants.js';
12

2-
import { FRACTION_SEP } from "./_constants.js" ;
3-
4-
export function _parse_fraction ( { reg } ) {
5-
6-
return function ( base , s ) {
7-
8-
const [ _numerator , _denominator ] = s.split(FRACTION_SEP) ;
9-
10-
return [ reg(_numerator, base), reg(_denominator, base) ] ;
11-
12-
}
3+
export function _parse_fraction({reg}) {
4+
return function (base, s) {
5+
const [_numerator, _denominator] = s.split(FRACTION_SEP);
136

7+
return [reg(_numerator, base), reg(_denominator, base)];
8+
};
149
}

src/_stringify_digits.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
export function _stringify_digits ( { str } ) {
1+
export function _stringify_digits({str}) {
2+
return function (base, {sign, integral, transient, repetend}) {
3+
const toStr = (x) => str(x, base);
24

3-
return function ( base , { sign , integral , transient , repetend } ) {
5+
let repr = '';
46

5-
const toStr = x => str(x, base);
7+
if (sign < 0) repr += '-';
68

7-
let repr = '' ;
9+
repr += toStr(integral);
810

9-
if (sign < 0) repr += '-' ;
10-
11-
repr += toStr(integral) ;
12-
13-
if (transient.length || repetend.length) repr += '.' ;
11+
if (transient.length > 0 || repetend.length > 0) repr += '.';
1412
// eslint-disable-next-line unicorn/no-array-callback-reference
15-
repr += transient.map(toStr).join('') ;
13+
repr += transient.map(toStr).join('');
1614

17-
if (repetend.length) repr += '|' ;
15+
if (repetend.length > 0) repr += '|';
1816
// eslint-disable-next-line unicorn/no-array-callback-reference
19-
repr += repetend.map(toStr).join('') ;
20-
21-
return repr ;
22-
23-
} ;
17+
repr += repetend.map(toStr).join('');
2418

19+
return repr;
20+
};
2521
}

src/add.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
21
/**
32
* Dummy add template.
43
*/
54

6-
export function _add ( { mul , add } ) {
7-
8-
return function ( a0 , a1 , b0 , b1 ) {
9-
10-
const d = mul( a1 , b1 ) ;
11-
const x = mul( a0 , b1 ) ;
12-
const y = mul( b0 , a1 ) ;
13-
const n = add( x , y ) ;
14-
15-
return [ n , d ] ;
16-
17-
} ;
5+
export function _add({mul, add}) {
6+
return function (a0, a1, b0, b1) {
7+
const d = mul(a1, b1);
8+
const x = mul(a0, b1);
9+
const y = mul(b0, a1);
10+
const n = add(x, y);
1811

12+
return [n, d];
13+
};
1914
}
20-

src/cmp.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
export function _cmp ( { jz , lt0 , cmp , neg , divmod } ) {
2-
3-
const compare_positive_fractions = function (a,b,c,d) {
1+
export function _cmp({jz, lt0, cmp, neg, divmod}) {
2+
const compare_positive_fractions = function (a, b, c, d) {
43
if (jz(b)) {
5-
if(jz(d)) return 0;
4+
if (jz(d)) return 0;
65
return 1;
76
}
7+
88
if (jz(d)) return -1;
9-
const [ q1 , r1 ] = divmod(a, b) ;
10-
const [ q2 , r2 ] = divmod(c, d) ;
11-
return cmp(q1, q2) || compare_positive_fractions(d,r2,b,r1);
12-
}
9+
const [q1, r1] = divmod(a, b);
10+
const [q2, r2] = divmod(c, d);
11+
return cmp(q1, q2) || compare_positive_fractions(d, r2, b, r1);
12+
};
13+
14+
return function (a, b, c, d) {
15+
if (lt0(b)) {
16+
b = neg(b);
17+
a = neg(a);
18+
}
19+
20+
if (lt0(d)) {
21+
d = neg(d);
22+
c = neg(c);
23+
}
1324

14-
return function (a,b,c,d) {
15-
if (lt0(b)) { b = neg(b); a = neg(a); }
16-
if (lt0(d)) { d = neg(d); c = neg(c); }
1725
if (lt0(a)) {
18-
if (lt0(c)) return compare_positive_fractions(neg(c),d,neg(a),b);
26+
if (lt0(c)) return compare_positive_fractions(neg(c), d, neg(a), b);
1927
return -1;
2028
}
21-
if (lt0(c)) return 1;
22-
return compare_positive_fractions(a,b,c,d);
23-
}
2429

30+
if (lt0(c)) return 1;
31+
return compare_positive_fractions(a, b, c, d);
32+
};
2533
}

src/cmp_no_bounds.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
export function _cmp_no_bounds ( { jz , lt0 , mul , cmp } ) {
2-
return function (a,b,c,d) {
1+
export function _cmp_no_bounds({jz, lt0, mul, cmp}) {
2+
return function (a, b, c, d) {
33
if (jz(b)) {
4-
if(lt0(a)) {
5-
// a/b = -Infinity
6-
return jz(d) ? lt0(c) ?
7-
0 : // b/d = -Infinity
8-
-1 : // b/d = Infinity
9-
-1 ; // b/d is finite
10-
}
11-
else {
12-
// a/b = Infinity
13-
return jz(d) ? lt0(c) ?
14-
1 : // b/d = -Infinity
15-
0 : // b/d = Infinity
16-
1 ; // b/d is finite
4+
if (lt0(a)) {
5+
// A/b = -Infinity
6+
return jz(d)
7+
? lt0(c)
8+
? 0 // B/d = -Infinity
9+
: -1 // B/d = Infinity
10+
: -1; // B/d is finite
1711
}
12+
13+
// A/b = Infinity
14+
return jz(d)
15+
? lt0(c)
16+
? 1 // B/d = -Infinity
17+
: 0 // B/d = Infinity
18+
: 1; // B/d is finite
1819
}
19-
// a/b is finite
20-
if (jz(d)) return lt0(c) ?
21-
1 : // b/d = -Infinity
22-
-1 ; // b/d = Infinity
2320

24-
return cmp(mul(a,d), mul(b,c)) ;
25-
} ;
21+
// A/b is finite
22+
if (jz(d))
23+
return lt0(c)
24+
? 1 // B/d = -Infinity
25+
: -1; // B/d = Infinity
26+
27+
return cmp(mul(a, d), mul(b, c));
28+
};
2629
}

src/decimals.js

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,32 @@
22
// for transient + repetend by multiplying x by b**M and do a single division ?
33
// That may be too much space in most cases. Though necessary when d is prime.
44

5-
export function _decimals ( { eq , muln , divmod } ) {
6-
7-
return function* ( b , d , n , hasrepetend , x ) {
8-
5+
export function _decimals({eq, muln, divmod}) {
6+
return function* (b, d, n, hasrepetend, x) {
97
// Computes the length of the repetend of x/d (1 <= x < d) in base b
108
// with transient part of size n.
119

12-
while ( n-- ) {
13-
14-
x = muln(x, b) ;
15-
const [q, r] = divmod(x, d) ;
16-
yield q ;
17-
x = r ;
18-
10+
while (n--) {
11+
x = muln(x, b);
12+
const [q, r] = divmod(x, d);
13+
yield q;
14+
x = r;
1915
}
2016

21-
if ( !hasrepetend ) return ;
17+
if (!hasrepetend) return;
2218

23-
const first = x ;
19+
const first = x;
2420

25-
x = muln(x, b) ;
26-
const [q, r] = divmod(x, d) ;
27-
yield q ;
28-
x = r ;
21+
x = muln(x, b);
22+
const [q, r] = divmod(x, d);
23+
yield q;
24+
x = r;
2925

3026
while (!eq(first, x)) {
31-
32-
x = muln(x, b) ;
33-
const [q, r] = divmod(x, d) ;
34-
yield q ;
35-
x = r ;
36-
27+
x = muln(x, b);
28+
const [q, r] = divmod(x, d);
29+
yield q;
30+
x = r;
3731
}
38-
39-
} ;
40-
32+
};
4133
}

0 commit comments

Comments
 (0)