Skip to content

Commit 88f528e

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/1fe650dc2407c6c6395828a28777fe8137a3bd2f/src/transforms/sources:initial-lint.js Please contact the author of the transform if you believe there was an error.
1 parent 77a5bda commit 88f528e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+377
-524
lines changed

doc/scripts/header.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
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 = 'combinatorics/permutation';
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/make-github-pseudonymous-again/js-permutation' ;
24-
testlink.target = '_BLANK' ;
19+
const testlink = document.querySelector('header > a[data-ice="testLink"]');
20+
testlink.href =
21+
'https://coveralls.io/github/make-github-pseudonymous-again/js-permutation';
22+
testlink.target = '_BLANK';
2523

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

29-
// active search box when focus on searchBox.
30-
input.addEventListener('focus', function(){
27+
// Active search box when focus on searchBox.
28+
input.addEventListener('focus', () => {
3129
searchBox.classList.add('active');
3230
});
33-
3431
});

src/_apply.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _transpose } from './_transpose.js' ;
1+
import {_transpose} from './_transpose.js';
22

33
/**
44
* Applies a given sequence (in the given order) of transpositions (given as
@@ -8,9 +8,6 @@ import { _transpose } from './_transpose.js' ;
88
* @param {Array} sigma The permutation to apply the transpositions to
99
* (modified in-place).
1010
*/
11-
export function _apply ( transpositions , sigma ) {
12-
13-
for ( const [ s , t ] of transpositions ) _transpose( s , t , sigma ) ;
14-
11+
export function _apply(transpositions, sigma) {
12+
for (const [s, t] of transpositions) _transpose(s, t, sigma);
1513
}
16-

src/_bitreversal.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Fills an input array with the bitreversal permutation for input
43
* <code>n</code> items. The array is filled starting at index <code>0</code>
@@ -8,23 +7,16 @@
87
* @param {Array} array The array to fill.
98
* @param {Number} n The size of the permutation, must be a power of 2.
109
*/
11-
export function _bitreversal ( array , n ) {
12-
13-
let i = 1 ;
14-
15-
array[0] = 0 ;
16-
17-
while ( i < n ) {
10+
export function _bitreversal(array, n) {
11+
let i = 1;
1812

19-
for ( let j = 0 ; j < i ; ++j ) {
20-
21-
array[i+j] = ( array[j] <<= 1 ) + 1 ;
13+
array[0] = 0;
2214

15+
while (i < n) {
16+
for (let j = 0; j < i; ++j) {
17+
array[i + j] = (array[j] <<= 1) + 1;
2318
}
2419

25-
i <<= 1 ;
26-
20+
i <<= 1;
2721
}
28-
2922
}
30-

src/_compose.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Compose two input permutations. The resulting permutation is output as an
43
* iterator of indices instead of an array of indices.
@@ -7,9 +6,6 @@
76
* @param {Array} tau The second input permutation.
87
* @returns {Iterator} An iterator over the items of the resulting permutation.
98
*/
10-
export function* _compose ( sigma , tau ) {
11-
12-
for ( const t of tau ) yield sigma[t] ;
13-
9+
export function* _compose(sigma, tau) {
10+
for (const t of tau) yield sigma[t];
1411
}
15-

src/_copy.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
21
/**
32
* Copy an input permutation to an output array.
43
*
54
* @param {Array} sigma The input permutation.
65
* @param {Number} n The size of the input permutation to copy.
76
* @param {Array} tau The output array.
87
*/
9-
export function _copy ( sigma , n , tau ) {
10-
11-
for ( let i = 0 ; i < n ; ++i ) tau[i] = sigma[i] ;
12-
8+
export function _copy(sigma, n, tau) {
9+
for (let i = 0; i < n; ++i) tau[i] = sigma[i];
1310
}
14-

src/_cycles.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Computes a cycle decomposition of an input permutation. This algorithm is
43
* deterministic; the algorithm will procedes in a sequential manner, first
@@ -17,31 +16,24 @@
1716
* @param {Array} used The helper array.
1817
* @returns {Iterator} The cycles <code>[a, [b, c, ...]]</code> for sigma.
1918
*/
20-
export function* _cycles ( sigma , used ) {
21-
22-
for ( const s of sigma ) {
23-
24-
if ( used[s] ) continue ;
25-
26-
used[s] = true ;
19+
export function* _cycles(sigma, used) {
20+
for (const s of sigma) {
21+
if (used[s]) continue;
2722

28-
let image = sigma[s] ;
23+
used[s] = true;
2924

30-
const cycle = [ ] ;
25+
let image = sigma[s];
3126

32-
while ( image !== s ) {
27+
const cycle = [];
3328

34-
used[image] = true ;
29+
while (image !== s) {
30+
used[image] = true;
3531

36-
cycle.push( image ) ;
37-
38-
image = sigma[image] ;
32+
cycle.push(image);
3933

34+
image = sigma[image];
4035
}
4136

42-
yield [ s , cycle ] ;
43-
37+
yield [s, cycle];
4438
}
45-
4639
}
47-

src/_identity.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
21
/**
32
* Fills an input array with the identity permutation on input <code>n</code>
43
* elements.
54
*
65
* @param {Array} sigma The input array.
76
* @param {Number} n The size to use for the permutation.
87
*/
9-
export function _identity ( sigma , n ) {
10-
11-
for ( let i = 0 ; i < n ; ++i ) sigma[i] = i ;
12-
8+
export function _identity(sigma, n) {
9+
for (let i = 0; i < n; ++i) sigma[i] = i;
1310
}
14-

src/_invert.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* @param {Number} n The size of the input permutation.
1010
* @param {Array} tau The array where to put the inverse of the input permutation.
1111
*/
12-
export function _invert ( sigma , n , tau ) {
13-
14-
for ( let i = 0 ; i < n ; ++i ) tau[sigma[i]] = i ;
15-
12+
export function _invert(sigma, n, tau) {
13+
for (let i = 0; i < n; ++i) tau[sigma[i]] = i;
1614
}

src/_invertcycles.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _transpose } from './_transpose.js' ;
1+
import {_transpose} from './_transpose.js';
22

33
/**
44
* Inverts given cycles in a given permutation ___in-place___. Can be used as
@@ -16,13 +16,8 @@ import { _transpose } from './_transpose.js' ;
1616
* @param {Iterable} cycles The cycles to invert.
1717
* @param {Array} tau The given permutation (modified in-place).
1818
*/
19-
export function _invertcycles ( cycles , tau ) {
20-
21-
for ( const [ s , cycle ] of cycles ) {
22-
23-
for ( const t of cycle ) _transpose( s , t , tau ) ;
24-
19+
export function _invertcycles(cycles, tau) {
20+
for (const [s, cycle] of cycles) {
21+
for (const t of cycle) _transpose(s, t, tau);
2522
}
26-
2723
}
28-

src/_itranspositions.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,20 @@
88
* @param {Array} used Helper array.
99
* @return {Iterator} Iterator over the transpositions.
1010
*/
11-
export function* _itranspositions ( sigma , used ) {
11+
export function* _itranspositions(sigma, used) {
12+
for (const s of sigma) {
13+
if (used[s]) continue;
1214

13-
for ( const s of sigma ) {
15+
used[s] = true;
1416

15-
if ( used[s] ) continue ;
17+
let image = sigma[s];
1618

17-
used[s] = true ;
19+
while (image !== s) {
20+
used[image] = true;
1821

19-
let image = sigma[s] ;
20-
21-
while ( image !== s ) {
22-
23-
used[image] = true ;
24-
25-
yield [ s , image ] ;
26-
27-
image = sigma[image] ;
22+
yield [s, image];
2823

24+
image = sigma[image];
2925
}
30-
3126
}
32-
3327
}

src/_next.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { _transpose } from './_transpose.js' ;
2-
import { _reverse } from './_reverse.js' ;
1+
import {_transpose} from './_transpose.js';
2+
import {_reverse} from './_reverse.js';
33

44
/**
55
* Updates the input permutation to the next one ___in-place___. Returns true
@@ -11,29 +11,24 @@ import { _reverse } from './_reverse.js' ;
1111
* @returns {Boolean} Whether the input permutation is
1212
* __NOT__ the last for its elements.
1313
*/
14-
export function _next ( sigma , n ) {
14+
export function _next(sigma, n) {
15+
let i = n - 1;
1516

16-
let i = n - 1 ;
17+
while (i > 0) {
18+
--i;
1719

18-
while ( i > 0 ) {
20+
if (sigma[i] > sigma[i + 1]) continue;
1921

20-
--i ;
22+
let j = n - 1;
2123

22-
if ( sigma[i] > sigma[i+1] ) continue ;
24+
while (sigma[j] < sigma[i]) --j;
2325

24-
let j = n - 1 ;
26+
_transpose(i, j, sigma);
2527

26-
while ( sigma[j] < sigma[i] ) --j ;
27-
28-
_transpose( i , j , sigma ) ;
29-
30-
_reverse( sigma , i + 1 , n ) ;
31-
32-
return true ;
28+
_reverse(sigma, i + 1, n);
3329

30+
return true;
3431
}
3532

36-
return false ;
37-
33+
return false;
3834
}
39-

src/_permutations.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _next } from './_next.js' ;
1+
import {_next} from './_next.js';
22

33
/**
44
* Yields all permutations starting from a given one and ending at the last
@@ -9,9 +9,8 @@ import { _next } from './_next.js' ;
99
* @returns {Iterator} Iterator over all permutations between the starting one
1010
* and the last permutation on its elements.
1111
*/
12-
export function* _permutations ( sigma , n ) {
13-
14-
do { yield sigma ; } while ( _next( sigma , n ) ) ;
15-
12+
export function* _permutations(sigma, n) {
13+
do {
14+
yield sigma;
15+
} while (_next(sigma, n));
1616
}
17-

src/_reverse.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _transpose } from './_transpose.js' ;
1+
import {_transpose} from './_transpose.js';
22

33
/**
44
* Reverses input permutation ___in-place___ from input index <code>i</code>
@@ -8,8 +8,6 @@ import { _transpose } from './_transpose.js' ;
88
* @param {Number} i The left bound (included).
99
* @param {Number} j The right bound (excluded).
1010
*/
11-
export function _reverse ( sigma , i , j ) {
12-
13-
while ( i <-- j ) _transpose( i++ , j , sigma ) ;
14-
11+
export function _reverse(sigma, i, j) {
12+
while (i < --j) _transpose(i++, j, sigma);
1513
}

src/_transpose.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Transpose elements of input index <code>a</code> and <code>b</code> in the
43
* input permutation.
@@ -7,11 +6,8 @@
76
* @param {Number} b The second input index.
87
* @param {Array} sigma The input permutation.
98
*/
10-
export function _transpose ( a , b , sigma ) {
11-
12-
const tmp = sigma[a] ;
13-
sigma[a] = sigma[b] ;
14-
sigma[b] = tmp ;
15-
9+
export function _transpose(a, b, sigma) {
10+
const tmp = sigma[a];
11+
sigma[a] = sigma[b];
12+
sigma[b] = tmp;
1613
}
17-

0 commit comments

Comments
 (0)