Skip to content

Commit

Permalink
refactor(random): Add type alias RandomRecordId for PK<RandomRecord>
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Aug 3, 2019
1 parent 9169cbf commit ab1afe0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/random/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export {
SEED_LENGTH,
DEFAULT_SEED_CHARSET
} from "./impl";
export { RandomRecord } from "./random-record";
export { RandomRecord, RandomRecordId } from "./random-record";

import * as Charsets from "./charsets";
export { Charsets };
6 changes: 3 additions & 3 deletions src/random/instance-random-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Licensed under MIT License (see https://github.com/regal/regal)
*/

import { FK, PK } from "../common";
import { FK } from "../common";
import { GameInstanceInternal } from "../state";
import { InstanceRandom } from "./instance-random";
import { RandomRecord } from "./random-record";
import { RandomRecordId } from "./random-record";

/**
* Internal interface for `InstanceRandom`.
Expand All @@ -29,7 +29,7 @@ export interface InstanceRandomInternal extends InstanceRandom {
* The key of the last `RandomRecord` that was generated, or the default key if
* none have been.
*/
readonly lastKey: FK<PK<RandomRecord>>;
readonly lastKey: FK<RandomRecordId>;

/**
* Generates a new `InstanceRandomInternal` for the new `GameInstance`, preserving
Expand Down
5 changes: 4 additions & 1 deletion src/random/random-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

import { PK } from "../common";

/** A random record primary key. */
export type RandomRecordId = PK<RandomRecord>;

/**
* Record of a single random value's generation.
*/
export interface RandomRecord {
/** The random value's unique id. */
id: PK<RandomRecord>;
id: RandomRecordId;
/** The random value. */
value: number | string | boolean;
}

0 comments on commit ab1afe0

Please sign in to comment.