Skip to content

Commit f92cb8d

Browse files
committed
chore: fix slow types in ideas/parser.ts
Fix the slow types in ideas/parser.ts so I can publish to JSR.io. Also updated the git workflows to use deno for publishing and the newest deno for testing. Added all operating systems to the testing matrix as well.
1 parent d34975a commit f92cb8d

3 files changed

Lines changed: 23 additions & 27 deletions

File tree

.github/workflows/deno.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow will install Deno and run tests across stable and nightly builds on Windows, Ubuntu and macOS.
7-
# For more information see: https://github.com/denolib/setup-deno
8-
9-
name: Deno
1+
name: Format and Test
102

113
on:
124
push:
@@ -40,9 +32,8 @@ jobs:
4032

4133
strategy:
4234
matrix:
43-
deno: ["v1.41.1"]
44-
# os: [macOS-latest, windows-latest, ubuntu-latest]
45-
os: [ubuntu-latest]
35+
deno: ["v2.2.12"]
36+
os: [macOS-latest, windows-latest, ubuntu-latest]
4637

4738
steps:
4839
- name: Setup repo

.github/workflows/jsr.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
name: JSR.io
1+
name: Publish to JSR.io
22
on:
33
push:
4-
branches:
5-
- main
4+
branches: [main]
65

76
jobs:
87
publish:
@@ -13,7 +12,13 @@ jobs:
1312
id-token: write
1413

1514
steps:
16-
- uses: actions/checkout@v4
15+
- name: Setup repo
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Deno
19+
uses: denoland/setup-deno@v1
20+
with:
21+
deno-version: "v2.2.12"
1722

1823
- name: Publish package
19-
run: npx jsr publish
24+
run: deno publish

ideas/parser.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,24 +281,24 @@ export function withDefault<T extends AnyParserLike>(
281281
return pipe(maybe(parser), map((a) => N.isNil(a) ? def : a));
282282
}
283283

284-
export const lower = range("a", "z");
285-
export const upper = range("A", "Z");
286-
export const nonzero = range("1", "9");
287-
export const digit = any(literal("0"), nonzero);
288-
export const alpha = any(lower, upper);
289-
export const alphanumeric = any(alpha, digit);
290-
291-
export const natural_number = pipe(
284+
export const lower: Parser<string> = range("a", "z");
285+
export const upper: Parser<string> = range("A", "Z");
286+
export const nonzero: Parser<string> = range("1", "9");
287+
export const digit: Parser<string> = any(literal("0"), nonzero);
288+
export const alpha: Parser<string> = any(lower, upper);
289+
export const alphanumeric: Parser<string> = any(alpha, digit);
290+
291+
export const natural_number: Parser<number> = pipe(
292292
sequence(nonzero, many(digit)),
293293
map(([lead, rest]) => parseInt(`${lead}${rest.join("")}`, 10)),
294294
);
295295

296-
export const integer = pipe(
296+
export const integer: Parser<number> = pipe(
297297
sequence(maybe(literal("-")), natural_number),
298298
map(([sign, number]) => N.isNil(sign) ? number : -1 * number),
299299
);
300300

301-
export const decimal = pipe(
301+
export const decimal: Parser<number> = pipe(
302302
sequence(integer, maybe(sequence(literal("."), many(digit)))),
303303
map(([w, or]) => N.isNil(or) ? w : w + parseFloat(`0.${or[1].join("")}`)),
304304
);

0 commit comments

Comments
 (0)