refactor: migrate RNG and utility functions to common package
- Removed RNG interface and related utility classes from logic package. - Added RNG interface and utility classes in common package. - Implemented various RNG classes (ConstantRNG, MidpointRNG, SineRNG, SequenceRNG) in common package. - Updated conversion utilities for BytesLike to ArrayBuffer and Uint8Array in common package. - Adjusted tests to import RNG utilities from the new common package. - Updated vitest configuration to resolve common package imports.
This commit is contained in:
1 parent
27b243b121
commit
fa22562bb1
17 files changed
+30
-18
No files matched your search
@@ -11,6 +11,8 @@
|
||||
"lint": "node -e \"console.log('lint not configured')\"",
|
||||
"test": "node -e \"console.log('test not configured')\""
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"js-sha512": "^0.9.0"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
@@ -1 +1,8 @@
|
||||
export {};
|
||||
export * from './rng.js';
|
||||
export * from './util/BytesLike.js';
|
||||
export * from './util/convertBytesLikeToArrayBuffer.js';
|
||||
export * from './util/convertBytesLikeToUint8Array.js';
|
||||
export * from './util/LiteHashDRBG.js';
|
||||
export * from './util/RNG.js';
|
||||
export * from './util/RandUtil.js';
|
||||
export * from './util/TestRNG.js';
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -18,7 +18,7 @@
|
||||
"test": "vitest run --config vitest.config.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-sha512": "^0.9.0"
|
||||
"@sammo-ts/common": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest": "^4.0.16"
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
export * from './domain/entities.js';
|
||||
export * from './ports/rng.js';
|
||||
export type { RandomGenerator } from '@sammo-ts/common';
|
||||
export * from './ports/world.js';
|
||||
export * from './triggers/index.js';
|
||||
export * from './util/BytesLike.js';
|
||||
export * from './util/convertBytesLikeToArrayBuffer.js';
|
||||
export * from './util/convertBytesLikeToUint8Array.js';
|
||||
export * from './util/LiteHashDRBG.js';
|
||||
export * from './util/RNG.js';
|
||||
export * from './util/RandUtil.js';
|
||||
export * from './util/TestRNG.js';
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { General, GeneralTriggerState } from '../domain/entities.js';
|
||||
import type { RandomGenerator } from '../ports/rng.js';
|
||||
import type { RandomGenerator } from '@sammo-ts/common';
|
||||
import type { WorldStateRepository } from '../ports/world.js';
|
||||
import { TriggerCaller, type Trigger } from './core.js';
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { bufferByteSize, LiteHashDRBG } from '../src/util/LiteHashDRBG.js';
|
||||
import { RandUtil } from '../src/util/RandUtil.js';
|
||||
import { convertBytesLikeToArrayBuffer } from '../src/util/convertBytesLikeToArrayBuffer.js';
|
||||
import { convertBytesLikeToUint8Array as toBytes } from '../src/util/convertBytesLikeToUint8Array.js';
|
||||
import {
|
||||
bufferByteSize,
|
||||
convertBytesLikeToArrayBuffer,
|
||||
convertBytesLikeToUint8Array as toBytes,
|
||||
LiteHashDRBG,
|
||||
RandUtil,
|
||||
} from '@sammo-ts/common';
|
||||
|
||||
type Bytes = ArrayBuffer | DataView<ArrayBuffer> | Uint8Array<ArrayBuffer>;
|
||||
type MaybeBytes = Bytes | string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { ConstantRNG, MidpointRNG, SequenceRNG, SineRNG } from '../src/util/TestRNG.js';
|
||||
import { ConstantRNG, MidpointRNG, SequenceRNG, SineRNG } from '@sammo-ts/common';
|
||||
|
||||
const toArray = (bytes: Uint8Array): number[] => Array.from(bytes);
|
||||
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@sammo-ts/common': path.resolve(__dirname, '../common/src/index.ts'),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: 'node',
|
||||
globals: true,
|
||||
|
||||
Reference in new issue
Block a user