Skip to content

Commit 30c4284

Browse files
👕 refactor: Initial lint.
1 parent b859a6c commit 30c4284

File tree

15 files changed

+503
-1143
lines changed

15 files changed

+503
-1143
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"pinst": "2.1.6",
102102
"power-assert": "1.6.1",
103103
"regenerator-runtime": "0.13.9",
104-
"xo": "0.36.1"
104+
"xo": "0.47.0"
105105
},
106106
"ava": {
107107
"files": [
@@ -203,6 +203,7 @@
203203
"xo": {
204204
"prettier": true,
205205
"rules": {
206+
"no-bitwise": "off",
206207
"unicorn/filename-case": [
207208
"error",
208209
{

src/array/api/index.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
import sort from './sort.js';
2-
import sortFloat32 from './sortFloat32.js';
3-
import sortInt16 from './sortInt16.js';
4-
import sortInt32 from './sortInt32.js';
5-
import sortInt8 from './sortInt8.js';
6-
import sortUint16 from './sortUint16.js';
7-
import sortUint32 from './sortUint32.js';
8-
import sortUint8 from './sortUint8.js';
9-
10-
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
11-
export default {
12-
sort,
13-
sortFloat32,
14-
sortInt16,
15-
sortInt32,
16-
sortInt8,
17-
sortUint16,
18-
sortUint32,
19-
sortUint8
20-
};
21-
22-
export {
23-
sort,
24-
sortFloat32,
25-
sortInt16,
26-
sortInt32,
27-
sortInt8,
28-
sortUint16,
29-
sortUint32,
30-
sortUint8
31-
};
1+
export {default as sort} from './sort.js';
2+
export {default as sortInt16} from './sortInt16.js';
3+
export {default as sortFloat32} from './sortFloat32.js';
4+
export {default as sortInt8} from './sortInt8.js';
5+
export {default as sortInt32} from './sortInt32.js';
6+
export {default as sortUint32} from './sortUint32.js';
7+
export {default as sortUint16} from './sortUint16.js';
8+
export {default as sortUint8} from './sortUint8.js';

src/array/api/sort.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const sort = (k, M, tuples) => {
1515
return tuples;
1616
}
1717

18+
// eslint-disable-next-line unicorn/no-new-array
1819
const output = new Array(N);
1920
if (k >= 1) {
2021
return sortFixedLengthTuples(k, M, tuples, output, 0, N);

src/array/api/sortFloat32.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import sortUint32 from './sortUint32.js';
33
// http://www.codercorner.com/RadixSortRevisited.htm
44
// http://stereopsis.com/radix.html
55
const floatFlip = (f) => {
6-
const mask = -(f >>> 31) | 0x80000000;
6+
const mask = -(f >>> 31) | 0x80_00_00_00;
77
return f ^ mask;
88
};
99

1010
const iFloatFlip = (f) => {
11-
const mask = ((f >>> 31) - 1) | 0x80000000;
11+
const mask = ((f >>> 31) - 1) | 0x80_00_00_00;
1212
return f ^ mask;
1313
};
1414

src/array/api/sortUint16.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const sortUint16 = (array) => {
55
const M = 2 ** 8;
66
// TODO avoid copying back and forth
77
const tuples = Array.prototype.map.call(array, (x) => [
8-
(x & 0xff00) >>> 8,
9-
(x & 0xff) >>> 0
8+
(x & 0xff_00) >>> 8,
9+
(x & 0xff) >>> 0,
1010
]);
1111
const output = sort(k, M, tuples);
1212
return Array.prototype.map.call(output, ([c, d]) => ((c << 8) | d) >>> 0);

src/array/api/sortUint32.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const sortUint32 = (array) => {
55
const M = 2 ** 8; // TODO another good option is k = 3 M = 2**11
66
// TODO avoid copying back and forth
77
const tuples = Array.prototype.map.call(array, (x) => [
8-
(x & 0xff000000) >>> 24,
9-
(x & 0xff0000) >>> 16,
10-
(x & 0xff00) >>> 8,
11-
(x & 0xff) >>> 0
8+
(x & 0xff_00_00_00) >>> 24,
9+
(x & 0xff_00_00) >>> 16,
10+
(x & 0xff_00) >>> 8,
11+
(x & 0xff) >>> 0,
1212
]);
1313
const output = sort(k, M, tuples);
1414
return Array.prototype.map.call(
1515
output,
16-
([a, b, c, d]) => ((a << 24) | (b << 16) | (c << 8) | d) >>> 0
16+
([a, b, c, d]) => ((a << 24) | (b << 16) | (c << 8) | d) >>> 0,
1717
);
1818
};
1919

src/array/core/reset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import fill from './fill.js';
2+
23
const reset = (array, i, j) => fill(array, 0, i, j);
34
export default reset;

src/index.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,10 @@
1-
import {
1+
export {
22
sort,
3-
sortFloat32,
43
sortInt16,
5-
sortInt32,
6-
sortInt8,
7-
sortUint16,
8-
sortUint32,
9-
sortUint8
10-
} from './array/api/index.js';
11-
12-
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
13-
export default {
14-
sort,
154
sortFloat32,
16-
sortInt16,
17-
sortInt32,
185
sortInt8,
19-
sortUint16,
20-
sortUint32,
21-
sortUint8
22-
};
23-
24-
export {
25-
sort,
26-
sortFloat32,
27-
sortInt16,
286
sortInt32,
29-
sortInt8,
307
sortUint16,
8+
sortUint8,
319
sortUint32,
32-
sortUint8
33-
};
10+
} from './array/api/index.js';

test/_old/nodes.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ export function nodes(lsb, head, hi, lo, si, sj) {
2323

2424
while (head !== null) {
2525
if (lsb(head.value, si) === 0) {
26-
_lo = _lo.next = head;
26+
_lo.next = head;
27+
_lo = head;
2728
} else {
28-
_hi = _hi.next = head;
29+
_hi.next = head;
30+
_hi = head;
2931
}
3032

3133
head = head.next;

test/src/api/sort.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import test from 'ava';
21
import {AssertionError} from 'assert';
2+
import test from 'ava';
33
import {list} from '@iterable-iterator/list';
44
import {all} from '@iterable-iterator/reduce';
55
import {map} from '@iterable-iterator/map';
@@ -48,7 +48,7 @@ test(throws, 2, 2, [[1], [0]]);
4848
test(throws, 3, 3, [
4949
[2, 1, 3],
5050
[3, 2, 1],
51-
[1, 2, 3]
51+
[1, 2, 3],
5252
]);
5353

5454
// Degenerates to counting sort
@@ -59,14 +59,14 @@ test(singletons, 3, [0, 2, 1]);
5959
test(limbs, 3, 3, [
6060
[2, 1, 0],
6161
[0, 2, 1],
62-
[1, 2, 0]
62+
[1, 2, 0],
6363
]);
6464

6565
// Custom radix
6666
test(limbs, 3, 4, [
6767
[2, 1, 3],
6868
[3, 2, 1],
69-
[1, 2, 3]
69+
[1, 2, 3],
7070
]);
7171

7272
test('Wikipedia example', limbs, 3, 10, [
@@ -77,7 +77,7 @@ test('Wikipedia example', limbs, 3, 10, [
7777
[0, 0, 2],
7878
[0, 2, 4],
7979
[8, 0, 2],
80-
[0, 6, 6]
80+
[0, 6, 6],
8181
]);
8282

8383
// Variable tuple length
@@ -89,5 +89,5 @@ test(limbs, -1, 10, [
8989
[2],
9090
[8, 0, 2],
9191
[2],
92-
[6, 6]
92+
[6, 6],
9393
]);

0 commit comments

Comments
 (0)