mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for sudokus (#36800)
This commit is contained in:
parent
cd095172b8
commit
dfa2e41ed3
17
types/sudokus/index.d.ts
vendored
Normal file
17
types/sudokus/index.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Type definitions for sudokus 1.0
|
||||
// Project: https://github.com/Moeriki/node-sudokus#readme
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type ProgressFn = (state: Cell[][]) => void;
|
||||
|
||||
export interface Cell {
|
||||
fixed: boolean;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
onProgress?: ProgressFn;
|
||||
}
|
||||
|
||||
export function solve(data: number[][], options?: Options): number[][];
|
||||
21
types/sudokus/sudokus-tests.ts
Normal file
21
types/sudokus/sudokus-tests.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { solve, ProgressFn, Cell } from 'sudokus';
|
||||
|
||||
const onProgress: ProgressFn = (cell: Cell[][]) => {
|
||||
cell[0][0].fixed;
|
||||
cell[0][0].value;
|
||||
};
|
||||
|
||||
solve(
|
||||
[
|
||||
[0, 0, 0, 2, 9, 0, 1, 0, 0],
|
||||
[6, 0, 0, 5, 0, 1, 0, 7, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 3, 4],
|
||||
[0, 0, 0, 0, 0, 0, 9, 4, 0],
|
||||
[4, 5, 0, 3, 0, 0, 0, 6, 2],
|
||||
[2, 0, 9, 0, 0, 4, 3, 1, 0],
|
||||
[0, 2, 0, 0, 0, 0, 4, 9, 0],
|
||||
[0, 0, 6, 0, 0, 8, 0, 0, 0],
|
||||
[0, 4, 3, 0, 2, 0, 0, 8, 7],
|
||||
],
|
||||
{ onProgress }
|
||||
);
|
||||
23
types/sudokus/tsconfig.json
Normal file
23
types/sudokus/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sudokus-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/sudokus/tslint.json
Normal file
1
types/sudokus/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user