-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(engines): add MT19937 as the DefaultEngine
Also refactor and reorganize src and test files using UpperCamelCase to support sensible class usage. BREAKING CHANGE: complete refactor with a DefaultEngine
- Loading branch information
Showing
26 changed files
with
69 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/common/engines/src/crypto/index.ts → ...on/engines/src/CrossCryptoEngine/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/common/engines/src/mt19937/index.ts → ...common/engines/src/MT19937Engine/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/common/engines/src/basic/index.ts → ...mon/engines/src/MathRandomEngine/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export { default as BasicEngine } from './basic' | ||
export { default as CryptoEngine } from './crypto' | ||
export { default as SeededEngine } from './mt19937' | ||
// common engine shorthands | ||
export { default as BasicEngine } from './MathRandomEngine' | ||
export { default as SeededEngine } from './MT19937Engine' | ||
export { default as CryptoEngine } from './CrossCryptoEngine' | ||
|
||
// the default engine is a seedable engine | ||
export { default as DefaultEngine } from './MT19937Engine' |
2 changes: 1 addition & 1 deletion
2
...n/engines/test/crypto/env.browser.test.ts → ...est/CrossCryptoEngine/env.browser.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...engines/test/crypto/env.no-crypto.test.ts → ...t/CrossCryptoEngine/env.no-crypto.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../common/engines/test/mt19937/seed.test.ts → ...n/engines/test/MT19937Engine/seed.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
BasicEngine, | ||
SeededEngine, | ||
CryptoEngine, | ||
DefaultEngine | ||
} from '../src' | ||
|
||
describe('@grandom/engines', () => { | ||
test('basic engine', () => { | ||
const engine = new BasicEngine() | ||
|
||
expect(engine.name).toBe('math-random') | ||
}) | ||
|
||
test('seeded engine', () => { | ||
const engine = new SeededEngine() | ||
|
||
expect(engine.name).toBe('mt19937') | ||
}) | ||
|
||
test('crypto engine', () => { | ||
const engine = new CryptoEngine() | ||
|
||
expect(engine.name).toBe('cross-crypto') | ||
}) | ||
|
||
test('default engine', () => { | ||
const engine = new DefaultEngine() | ||
|
||
expect(engine.name).toBe('mt19937') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default } from '../src/basic' | ||
export { default } from '../src/MathRandomEngine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default } from '../src/crypto' | ||
export { default } from '../src/CrossCryptoEngine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { default } from '../src/mt19937' | ||
export { default } from '../src/MT19937Engine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { | ||
BasicEngine, | ||
SeededEngine, | ||
CryptoEngine | ||
CryptoEngine, | ||
DefaultEngine | ||
} from '../src' | ||
|
||
export default { | ||
BasicEngine, | ||
SeededEngine, | ||
CryptoEngine | ||
CryptoEngine, | ||
DefaultEngine | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters