From 7d47fba0546c9c054e247c0b01ed7200de48f3ac Mon Sep 17 00:00:00 2001 From: AlexAegis Date: Sun, 14 Jan 2024 13:31:59 +0100 Subject: [PATCH] chore: removed duplicate interface --- pnpm-lock.yaml | 7 +++++-- solutions/typescript/2018/03/package.json | 3 ++- .../typescript/2018/03/src/interpret.function.ts | 12 ++++++++---- .../typescript/2018/03/src/model/claim.interface.ts | 6 +++--- solutions/typescript/2018/15/package.json | 5 ----- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 547272d96..60217a1ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -521,6 +521,9 @@ importers: '@alexaegis/advent-of-code-lib': specifier: workspace:^ version: link:../../libs/lib + arktype: + specifier: ^1.0.29-alpha + version: 1.0.29-alpha devDependencies: '@alexaegis/eslint-config-vitest': specifier: ^0.9.2 @@ -4542,7 +4545,7 @@ importers: solutions/typescript/libs/intcode: dependencies: '@alexaegis/advent-of-code-lib': - specifier: workspace:^ + specifier: ^1.0.1 version: link:../lib devDependencies: '@alexaegis/eslint-config-vitest': @@ -14765,7 +14768,7 @@ packages: '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 '@types/node': 20.11.0 - acorn: 8.11.2 + acorn: 8.11.3 acorn-walk: 8.3.2 arg: 4.1.3 create-require: 1.1.1 diff --git a/solutions/typescript/2018/03/package.json b/solutions/typescript/2018/03/package.json index 01156d190..374c34c2d 100644 --- a/solutions/typescript/2018/03/package.json +++ b/solutions/typescript/2018/03/package.json @@ -63,7 +63,8 @@ "./readme": "./readme.md" }, "dependencies": { - "@alexaegis/advent-of-code-lib": "workspace:^" + "@alexaegis/advent-of-code-lib": "workspace:^", + "arktype": "^1.0.29-alpha" }, "devDependencies": { "@alexaegis/eslint-config-vitest": "^0.9.2", diff --git a/solutions/typescript/2018/03/src/interpret.function.ts b/solutions/typescript/2018/03/src/interpret.function.ts index b3fe890c7..2f7a2388b 100644 --- a/solutions/typescript/2018/03/src/interpret.function.ts +++ b/solutions/typescript/2018/03/src/interpret.function.ts @@ -1,10 +1,14 @@ +import { Vec2 } from '@alexaegis/advent-of-code-lib'; +import { type } from 'arktype'; import type { Claim } from './model/claim.interface.js'; export const interpret = (line: string): Claim => { - const parts = line.split(/[#,:@x]/).map((e) => e.trim()); + const strings = type(['string', 'string', 'string', 'string', 'string', 'string']); + const parts = strings.assert(line.split(/[#,:@x]/).map((e) => e.trim())); + return { - id: Number(parts[1]), - starting: { x: Number(parts[2]), y: Number(parts[3]) }, - size: { x: Number(parts[4]), y: Number(parts[5]) }, + id: Number.parseInt(parts[1], 10), + starting: new Vec2(Number.parseInt(parts[2], 10), Number.parseInt(parts[3], 10)), + size: new Vec2(Number.parseInt(parts[4], 10), Number.parseInt(parts[5], 10)), }; }; diff --git a/solutions/typescript/2018/03/src/model/claim.interface.ts b/solutions/typescript/2018/03/src/model/claim.interface.ts index 029e776a3..c13322f6e 100644 --- a/solutions/typescript/2018/03/src/model/claim.interface.ts +++ b/solutions/typescript/2018/03/src/model/claim.interface.ts @@ -1,7 +1,7 @@ -import type { Coord } from './coord.interface.js'; +import type { Vec2 } from '@alexaegis/advent-of-code-lib'; export interface Claim { id: number; - starting: Coord; - size: Coord; + starting: Vec2; + size: Vec2; } diff --git a/solutions/typescript/2018/15/package.json b/solutions/typescript/2018/15/package.json index 770a66129..b13dd70b4 100644 --- a/solutions/typescript/2018/15/package.json +++ b/solutions/typescript/2018/15/package.json @@ -50,11 +50,6 @@ "import": "./dist/cave.class.js", "default": "./dist/cave.class.js" }, - "./coord.class": { - "types": "./src/coord.class.ts", - "import": "./dist/coord.class.js", - "default": "./dist/coord.class.js" - }, "./reader.function": { "types": "./src/reader.function.ts", "import": "./dist/reader.function.js",