move-by-move 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -6
- package/lib/index.js +4 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export interface GameAction {
|
|
2
2
|
type: string;
|
|
3
3
|
}
|
|
4
|
-
export interface Game {
|
|
4
|
+
export interface Game<Type> {
|
|
5
5
|
subscribe(listener: Function): void;
|
|
6
6
|
unsubscribe(listener: Function): void;
|
|
7
|
-
getState():
|
|
7
|
+
getState(): Type;
|
|
8
8
|
move(action: GameAction): void;
|
|
9
9
|
}
|
|
10
|
-
export declare type
|
|
11
|
-
export declare
|
|
12
|
-
declare const createGame: (rules: ((input: RuleIO) => RuleIO)[], initialGameState: GameState) => Game;
|
|
13
|
-
export default createGame;
|
|
10
|
+
export declare type RuleIO<Type> = [action: GameAction, state: Type];
|
|
11
|
+
export declare function createGame<Type>(rules: Array<(input: RuleIO<Type>) => RuleIO<Type>>, initialGameState: Type): Game<Type>;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGame = void 0;
|
|
3
4
|
const helpers_1 = require("./helpers");
|
|
4
|
-
|
|
5
|
+
function createGame(rules, initialGameState) {
|
|
5
6
|
let listeners = [];
|
|
6
7
|
let state = initialGameState;
|
|
7
8
|
const subscribe = (listener) => {
|
|
@@ -26,5 +27,5 @@ const createGame = (rules, initialGameState) => {
|
|
|
26
27
|
getState,
|
|
27
28
|
move,
|
|
28
29
|
};
|
|
29
|
-
}
|
|
30
|
-
exports.
|
|
30
|
+
}
|
|
31
|
+
exports.createGame = createGame;
|