range parser, move typings

This commit is contained in:
Rowan 2025-05-25 08:21:36 -05:00
parent 3d061e1b67
commit 9a56b99eff
21 changed files with 33 additions and 3 deletions

View file

@ -3,7 +3,7 @@
"version": "1.0.0",
"type": "module",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"types": "./typings/index.d.ts",
"author": "Rowan <rowan@kitsu.cafe> (https://kitsu.cafe)",
"scripts": {
"test": "./tests/index.js",

View file

@ -46,3 +46,18 @@ export const many = curry((parser, state) => {
export const many1 = parser => seq(parser, many(parser))
const _range = (start, end, step = 1) => {
const len = end - start + 1
const result = new Array(len)
for (let i = 0, n = start; i <= len; i += i, n += step) {
result[i] = n
}
return result
}
export const range = (start, end) => {
return anyChar(_range(start.codePointAt(0), end.codePointAt(0)))
}

View file

@ -59,7 +59,7 @@
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
"outDir": "./typings", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
@ -109,5 +109,8 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
},
"exclude": [
"typings"
]
}

0
typings/dist/index.d.ts vendored Normal file
View file

View file

View file

@ -5,3 +5,4 @@ export const takeUntil: any;
export const skip: any;
export const many: any;
export function many1(parser: any): any;
export function range(start: any, end: any): any;

2
typings/tests/index.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

1
typings/tests/units/bytes.d.ts vendored Normal file
View file

@ -0,0 +1 @@
export const Byte: any[];

3
typings/tests/units/common.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
export const assertState: any;
export const parseEq: any;
export const parseErr: any;

1
typings/tests/units/cond.d.ts vendored Normal file
View file

@ -0,0 +1 @@
export const Conditionals: any[];

3
typings/tests/units/index.d.ts vendored Normal file
View file

@ -0,0 +1,3 @@
export * from "./bytes.js";
export * from "./iter.js";
export * from "./cond.js";

1
typings/tests/units/iter.d.ts vendored Normal file
View file

@ -0,0 +1 @@
export const Iterator: any[];