Skip to content

Commit b24e8d8

Browse files
⬆️ deps: Upgrade xo to v0.41.0.
1 parent ded0c89 commit b24e8d8

File tree

9 files changed

+725
-1013
lines changed

9 files changed

+725
-1013
lines changed

doc/scripts/header.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ domReady(() => {
1717
header.insertBefore(projectname, header.firstChild);
1818

1919
const testlink = document.querySelector('header > a[data-ice="testLink"]');
20-
testlink.href = 'https://coveralls.io/github/make-github-pseudonymous-again/js-pseudo-random';
20+
testlink.href =
21+
'https://coveralls.io/github/make-github-pseudonymous-again/js-pseudo-random';
2122
testlink.target = '_BLANK';
2223

2324
const searchBox = document.querySelector('.search-box');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"pinst": "2.1.6",
9393
"power-assert": "1.6.1",
9494
"regenerator-runtime": "0.13.7",
95-
"xo": "0.36.1"
95+
"xo": "0.41.0"
9696
},
9797
"ava": {
9898
"files": [
@@ -197,6 +197,7 @@
197197
"unicorn"
198198
],
199199
"rules": {
200+
"unicorn/prefer-node-protocol": "off",
200201
"unicorn/filename-case": "off",
201202
"unicorn/prefer-math-trunc": "off"
202203
},

src/genUint16.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function* genUint16(prng) {
22
for (const x of prng) {
3-
yield (x >>> 0) & 0xffff;
4-
yield (x >>> 16) & 0xffff;
3+
yield (x >>> 0) & 0xff_ff;
4+
yield (x >>> 16) & 0xff_ff;
55
}
66
}

src/nextUint16.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function nextUint16(prng) {
2-
return (prng.next().value >>> 16) & 0xffff;
2+
return (prng.next().value >>> 16) & 0xff_ff;
33
}

src/splitmix64.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import {add64, mul64, xor64, shr64, get64} from '@arithmetic-type/uint64';
33
export default function* splitmix64(seed) {
44
let state = get64(...seed);
55
while (true) {
6-
state = add64(state, get64(0x9e3779b9, 0x7f4a7c15));
6+
state = add64(state, get64(0x9e_37_79_b9, 0x7f_4a_7c_15));
77
let z = state;
8-
z = mul64(xor64(z, shr64(z, 30)), get64(0xbf58476d, 0x1ce4e5b9));
9-
z = mul64(xor64(z, shr64(z, 27)), get64(0x94d049bb, 0x133111eb));
8+
z = mul64(xor64(z, shr64(z, 30)), get64(0xbf_58_47_6d, 0x1c_e4_e5_b9));
9+
z = mul64(xor64(z, shr64(z, 27)), get64(0x94_d0_49_bb, 0x13_31_11_eb));
1010
yield* xor64(z, shr64(z, 31));
1111
}
1212
}

src/xoroshiro128plus.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class XoRoShiRo128Plus {
1010
this.a = a || 24;
1111
this.b = b || 16;
1212
this.c = c || 37;
13-
this.JUMP = JUMP || [0xd8f554a5, 0xdf900294, 0x4b3201fc, 0x170865df];
13+
this.JUMP = JUMP || [
14+
0xd8_f5_54_a5, 0xdf_90_02_94, 0x4b_32_01_fc, 0x17_08_65_df,
15+
];
1416
this.p = 0;
1517
this.z = 0;
1618
this.s0 = get64(seed[0], seed[1]);

test/src/splitmix64.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ test('https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 #1', (t) =>
99
/**
1010
* Show the first five integers generated using the seed 1234567.
1111
*/
12-
const seed = [0, 1234567];
12+
const seed = [0, 1_234_567];
1313
const prng = splitmix64(seed);
14-
t.deepEqual(nextUint64(prng), [0x599ed017 | 0, 0xfb08fc85 | 0]); // 6457827717110365317
15-
t.deepEqual(nextUint64(prng), [0x2c73f084 | 0, 0x58540fa5 | 0]); // 3203168211198807973
16-
t.deepEqual(nextUint64(prng), [0x883ebce5 | 0, 0xa3f27c77 | 0]); // 9817491932198370423
17-
t.deepEqual(nextUint64(prng), [0x3fbef740 | 0, 0xe9177b3f | 0]); // 4593380528125082431
18-
t.deepEqual(nextUint64(prng), [0xe3b83467 | 0, 0x08cb5ecd | 0]); // 16408922859458223821
14+
t.deepEqual(nextUint64(prng), [0x59_9e_d0_17 | 0, 0xfb_08_fc_85 | 0]); // 6457827717110365317
15+
t.deepEqual(nextUint64(prng), [0x2c_73_f0_84 | 0, 0x58_54_0f_a5 | 0]); // 3203168211198807973
16+
t.deepEqual(nextUint64(prng), [0x88_3e_bc_e5 | 0, 0xa3_f2_7c_77 | 0]); // 9817491932198370423
17+
t.deepEqual(nextUint64(prng), [0x3f_be_f7_40 | 0, 0xe9_17_7b_3f | 0]); // 4593380528125082431
18+
t.deepEqual(nextUint64(prng), [0xe3_b8_34_67 | 0, 0x08_cb_5e_cd | 0]); // 16408922859458223821
1919
});
2020

2121
test('https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 #2', (t) => {
@@ -26,30 +26,30 @@ test('https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64 #2', (t) =>
2626
* 0: 20027, 1: 19892, 2: 20073, 3: 19978, 4: 20030
2727
*/
2828

29-
const seed = [0, 987654321];
29+
const seed = [0, 987_654_321];
3030
const prng = splitmix64(seed);
31-
const histogram = new Array(5).fill(0);
31+
const histogram = Array.from({length: 5}).fill(0);
3232
for (const k of map(
3333
() => Math.floor(nextFloat64(prng) * 5) | 0,
34-
range(100000),
34+
range(100_000),
3535
)) {
3636
++histogram[k];
3737
}
3838

39-
t.deepEqual(histogram, [20027, 19892, 20073, 19978, 20030]);
39+
t.deepEqual(histogram, [20_027, 19_892, 20_073, 19_978, 20_030]);
4040
});
4141

4242
test('Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L9', (t) => {
43-
const seed = [0, 0xdeadbeef];
43+
const seed = [0, 0xde_ad_be_ef];
4444
const prng = splitmix64(seed);
45-
t.deepEqual(nextUint64(prng), get64(0x4adfb90f, 0x68c9eb9b)); // 5395234354446855067
46-
t.deepEqual(nextUint64(prng), get64(0xde586a31, 0x41a10922)); // 16021672434157553954
47-
t.deepEqual(nextUint64(prng), get64(0x021fbc2f, 0x8e1cfc1d)); // 153047824787635229
48-
t.deepEqual(nextUint64(prng), get64(0x7466ce73, 0x7be16790)); // 8387618351419058064
49-
t.deepEqual(nextUint64(prng), get64(0x3bfa8764, 0xf685bd1c)); // 4321915660117851420
50-
t.deepEqual(nextUint64(prng), get64(0xab203e50, 0x3cb55b3f)); // 12330924294077242175
51-
t.deepEqual(nextUint64(prng), get64(0x5a2fdc2b, 0xf68cedb3)); // 6498654868697050547
52-
t.deepEqual(nextUint64(prng), get64(0xb30a4ccf, 0x430b1b5a)); // 12901208535622949722
53-
t.deepEqual(nextUint64(prng), get64(0x0a904150, 0x39bd5985)); // 761180149847513477
54-
t.deepEqual(nextUint64(prng), get64(0x26ae5084, 0x7745eb7e)); // 2787253749255891838
45+
t.deepEqual(nextUint64(prng), get64(0x4a_df_b9_0f, 0x68_c9_eb_9b)); // 5395234354446855067
46+
t.deepEqual(nextUint64(prng), get64(0xde_58_6a_31, 0x41_a1_09_22)); // 16021672434157553954
47+
t.deepEqual(nextUint64(prng), get64(0x02_1f_bc_2f, 0x8e_1c_fc_1d)); // 153047824787635229
48+
t.deepEqual(nextUint64(prng), get64(0x74_66_ce_73, 0x7b_e1_67_90)); // 8387618351419058064
49+
t.deepEqual(nextUint64(prng), get64(0x3b_fa_87_64, 0xf6_85_bd_1c)); // 4321915660117851420
50+
t.deepEqual(nextUint64(prng), get64(0xab_20_3e_50, 0x3c_b5_5b_3f)); // 12330924294077242175
51+
t.deepEqual(nextUint64(prng), get64(0x5a_2f_dc_2b, 0xf6_8c_ed_b3)); // 6498654868697050547
52+
t.deepEqual(nextUint64(prng), get64(0xb3_0a_4c_cf, 0x43_0b_1b_5a)); // 12901208535622949722
53+
t.deepEqual(nextUint64(prng), get64(0x0a_90_41_50, 0x39_bd_59_85)); // 761180149847513477
54+
t.deepEqual(nextUint64(prng), get64(0x26_ae_50_84, 0x77_45_eb_7e)); // 2787253749255891838
5555
});

test/src/xoroshiro128plus.js

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,76 @@ import test from 'ava';
22

33
import {get64} from '@arithmetic-type/uint64';
44

5-
import {splitmix64, xoroshiro128plus, fill, nextUint64} from '../../src/index.js';
5+
import {
6+
splitmix64,
7+
xoroshiro128plus,
8+
fill,
9+
nextUint64,
10+
} from '../../src/index.js';
611

712
test('Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L28', (t) => {
813
const prng = xoroshiro128plus([0, 1, 0, 2], {a: 55, b: 14, c: 36});
914

10-
t.deepEqual(nextUint64(prng), get64(0x00000000, 0x00000003)); // 3
11-
t.deepEqual(nextUint64(prng), get64(0x00800030, 0x0000c003)); // 36029003177443331
12-
t.deepEqual(nextUint64(prng), get64(0x01184060, 0x38000363)); // 78883775479546723
13-
t.deepEqual(nextUint64(prng), get64(0xa080fe50, 0x30c4c366)); // 11565523463456473958
14-
t.deepEqual(nextUint64(prng), get64(0x3ae0e84f, 0x181c8404)); // 4242646275387589636
15-
t.deepEqual(nextUint64(prng), get64(0x03902839, 0x17940944)); // 256749404433942852
16-
t.deepEqual(nextUint64(prng), get64(0x98dcc1f0, 0x6360888c)); // 11014892026844973196
17-
t.deepEqual(nextUint64(prng), get64(0x7db94a02, 0x5d95c80f)); // 9059353499452950543
18-
t.deepEqual(nextUint64(prng), get64(0x77508804, 0x6d70b290)); // 8597521241247625872
19-
t.deepEqual(nextUint64(prng), get64(0x412422d9, 0x4084790d)); // 4693915028112570637
15+
t.deepEqual(nextUint64(prng), get64(0x00_00_00_00, 0x00_00_00_03)); // 3
16+
t.deepEqual(nextUint64(prng), get64(0x00_80_00_30, 0x00_00_c0_03)); // 36029003177443331
17+
t.deepEqual(nextUint64(prng), get64(0x01_18_40_60, 0x38_00_03_63)); // 78883775479546723
18+
t.deepEqual(nextUint64(prng), get64(0xa0_80_fe_50, 0x30_c4_c3_66)); // 11565523463456473958
19+
t.deepEqual(nextUint64(prng), get64(0x3a_e0_e8_4f, 0x18_1c_84_04)); // 4242646275387589636
20+
t.deepEqual(nextUint64(prng), get64(0x03_90_28_39, 0x17_94_09_44)); // 256749404433942852
21+
t.deepEqual(nextUint64(prng), get64(0x98_dc_c1_f0, 0x63_60_88_8c)); // 11014892026844973196
22+
t.deepEqual(nextUint64(prng), get64(0x7d_b9_4a_02, 0x5d_95_c8_0f)); // 9059353499452950543
23+
t.deepEqual(nextUint64(prng), get64(0x77_50_88_04, 0x6d_70_b2_90)); // 8597521241247625872
24+
t.deepEqual(nextUint64(prng), get64(0x41_24_22_d9, 0x40_84_79_0d)); // 4693915028112570637
2025
});
2126

2227
test('Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L47', (t) => {
2328
const prng = xoroshiro128plus(
24-
[0x0916df85, 0x1e2aee44, 0x9ade0f09, 0xffca1bc4],
29+
[0x09_16_df_85, 0x1e_2a_ee_44, 0x9a_de_0f_09, 0xff_ca_1b_c4],
2530
{
2631
a: 55,
2732
b: 14,
2833
c: 36,
29-
JUMP: [0xeba5facb, 0xbeac0467, 0x86aa9922, 0xd86b048b],
34+
JUMP: [0xeb_a5_fa_cb, 0xbe_ac_04_67, 0x86_aa_99_22, 0xd8_6b_04_8b],
3035
},
3136
);
3237

3338
prng.jump();
34-
t.deepEqual(nextUint64(prng), get64(0x658bac67, 0x42f1cb34)); // 7317131579098254132
39+
t.deepEqual(nextUint64(prng), get64(0x65_8b_ac_67, 0x42_f1_cb_34)); // 7317131579098254132
3540
prng.jump();
36-
t.deepEqual(nextUint64(prng), get64(0x7ea22887, 0x3c5d2ad5)); // 9124900356304480981
41+
t.deepEqual(nextUint64(prng), get64(0x7e_a2_28_87, 0x3c_5d_2a_d5)); // 9124900356304480981
3742
prng.jump();
38-
t.deepEqual(nextUint64(prng), get64(0xe794ec98, 0xaebcd8bc)); // 16687222659825326268
43+
t.deepEqual(nextUint64(prng), get64(0xe7_94_ec_98, 0xae_bc_d8_bc)); // 16687222659825326268
3944
prng.jump();
40-
t.deepEqual(nextUint64(prng), get64(0x93e0f50d, 0x5d924d3a)); // 10655786156111842618
45+
t.deepEqual(nextUint64(prng), get64(0x93_e0_f5_0d, 0x5d_92_4d_3a)); // 10655786156111842618
4146
prng.jump();
42-
t.deepEqual(nextUint64(prng), get64(0x0555abbe, 0x490eb380)); // 384402176967881600
47+
t.deepEqual(nextUint64(prng), get64(0x05_55_ab_be, 0x49_0e_b3_80)); // 384402176967881600
4348
prng.jump();
44-
t.deepEqual(nextUint64(prng), get64(0x1e2935c4, 0x3d1ceffa)); // 2173327412138143738
49+
t.deepEqual(nextUint64(prng), get64(0x1e_29_35_c4, 0x3d_1c_ef_fa)); // 2173327412138143738
4550
prng.jump();
46-
t.deepEqual(nextUint64(prng), get64(0xc94b9bd3, 0x583ae4dd)); // 14504858356897473757
51+
t.deepEqual(nextUint64(prng), get64(0xc9_4b_9b_d3, 0x58_3a_e4_dd)); // 14504858356897473757
4752
prng.jump();
48-
t.deepEqual(nextUint64(prng), get64(0x426bc5ee, 0x5b3a4f93)); // 4786136656534720403
53+
t.deepEqual(nextUint64(prng), get64(0x42_6b_c5_ee, 0x5b_3a_4f_93)); // 4786136656534720403
4954
prng.jump();
50-
t.deepEqual(nextUint64(prng), get64(0x2ac1f1af, 0xddd342bf)); // 3081009357741310655
55+
t.deepEqual(nextUint64(prng), get64(0x2a_c1_f1_af, 0xdd_d3_42_bf)); // 3081009357741310655
5156
prng.jump();
52-
t.deepEqual(nextUint64(prng), get64(0x3884d3ed, 0xd6ffd586)); // 4072612981517571462
57+
t.deepEqual(nextUint64(prng), get64(0x38_84_d3_ed, 0xd6_ff_d5_86)); // 4072612981517571462
5358
});
5459

5560
test('Example found at https://github.com/dgryski/go-xoroshiro/blob/ea5ca0291510c1f8b16321d610ae73e1006d499f/xoro_test.go#L80', (t) => {
56-
const seeder = splitmix64([0x0ddc0ffe, 0xebadf00d]);
61+
const seeder = splitmix64([0x0d_dc_0f_fe, 0xeb_ad_f0_0d]);
5762
const seed = new Int32Array(4);
5863
fill(seeder, seed);
5964

6065
const prng = xoroshiro128plus(seed, {a: 55, b: 14, c: 36});
6166

62-
t.deepEqual(nextUint64(prng), get64(0xa3f4ee8f, 0x1df50a08)); // 11814330020949985800
63-
t.deepEqual(nextUint64(prng), get64(0xa3febba4, 0x5a9ce9c5)); // 11817088786836023749
64-
t.deepEqual(nextUint64(prng), get64(0x16f4c81d, 0x130768eb)); // 1654166990350674155
65-
t.deepEqual(nextUint64(prng), get64(0xc3da8db5, 0x1d9cc8ea)); // 14112748191344281834
66-
t.deepEqual(nextUint64(prng), get64(0x3b8315d6, 0xf1f63305)); // 4288295283113472773
67-
t.deepEqual(nextUint64(prng), get64(0x747636fe, 0x553bb5ca)); // 8391955421631067594
68-
t.deepEqual(nextUint64(prng), get64(0x0255d516, 0xf81d9239)); // 168274855724945977
69-
t.deepEqual(nextUint64(prng), get64(0x27114eb0, 0xcdd2961f)); // 2815117763357611551
70-
t.deepEqual(nextUint64(prng), get64(0xa92195f5, 0x93148843)); // 12187186948608395331
71-
t.deepEqual(nextUint64(prng), get64(0x9381f38a, 0x6d63d35c)); // 10629044371437376348
67+
t.deepEqual(nextUint64(prng), get64(0xa3_f4_ee_8f, 0x1d_f5_0a_08)); // 11814330020949985800
68+
t.deepEqual(nextUint64(prng), get64(0xa3_fe_bb_a4, 0x5a_9c_e9_c5)); // 11817088786836023749
69+
t.deepEqual(nextUint64(prng), get64(0x16_f4_c8_1d, 0x13_07_68_eb)); // 1654166990350674155
70+
t.deepEqual(nextUint64(prng), get64(0xc3_da_8d_b5, 0x1d_9c_c8_ea)); // 14112748191344281834
71+
t.deepEqual(nextUint64(prng), get64(0x3b_83_15_d6, 0xf1_f6_33_05)); // 4288295283113472773
72+
t.deepEqual(nextUint64(prng), get64(0x74_76_36_fe, 0x55_3b_b5_ca)); // 8391955421631067594
73+
t.deepEqual(nextUint64(prng), get64(0x02_55_d5_16, 0xf8_1d_92_39)); // 168274855724945977
74+
t.deepEqual(nextUint64(prng), get64(0x27_11_4e_b0, 0xcd_d2_96_1f)); // 2815117763357611551
75+
t.deepEqual(nextUint64(prng), get64(0xa9_21_95_f5, 0x93_14_88_43)); // 12187186948608395331
76+
t.deepEqual(nextUint64(prng), get64(0x93_81_f3_8a, 0x6d_63_d3_5c)); // 10629044371437376348
7277
});

0 commit comments

Comments
 (0)