tarsec 0.0.7 → 0.0.9
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/README.md +6 -6
- package/dist/combinators.d.ts +8 -6
- package/dist/combinators.js +130 -57
- package/dist/lib/combinators.d.ts +8 -6
- package/dist/lib/combinators.js +130 -57
- package/dist/lib/parsers.d.ts +1 -1
- package/dist/lib/parsers.js +12 -39
- package/dist/lib/trace.d.ts +3 -3
- package/dist/lib/trace.js +1 -1
- package/dist/lib/types.d.ts +25 -9
- package/dist/lib/types.js +37 -0
- package/dist/parsers.d.ts +1 -1
- package/dist/parsers.js +12 -39
- package/dist/trace.d.ts +3 -3
- package/dist/trace.js +1 -1
- package/dist/types.d.ts +25 -9
- package/dist/types.js +37 -0
- package/package.json +3 -3
- package/dist/lib/parsers.test.d.ts +0 -1
- package/dist/lib/parsers.test.js +0 -235
- package/dist/tests/combinators/many.test.d.ts +0 -1
- package/dist/tests/combinators/many.test.js +0 -27
- package/dist/tests/combinators/many1.test.d.ts +0 -1
- package/dist/tests/combinators/many1.test.js +0 -27
- package/dist/tests/combinators/or.test.d.ts +0 -1
- package/dist/tests/combinators/or.test.js +0 -31
- package/dist/tests/combinators/seq.test.d.ts +0 -1
- package/dist/tests/combinators/seq.test.js +0 -41
- package/dist/tests/integration/hello_capture.test.d.ts +0 -1
- package/dist/tests/integration/hello_capture.test.js +0 -30
- package/dist/tests/integration/hello_world.test.d.ts +0 -1
- package/dist/tests/integration/hello_world.test.js +0 -23
- package/dist/tests/parsers/char.test.d.ts +0 -1
- package/dist/tests/parsers/char.test.js +0 -35
- package/dist/tests/parsers/noneOf.test.d.ts +0 -1
- package/dist/tests/parsers/noneOf.test.js +0 -26
- package/dist/tests/parsers/oneOf.test.d.ts +0 -1
- package/dist/tests/parsers/oneOf.test.js +0 -26
- package/dist/tests/parsers/str.test.d.ts +0 -1
- package/dist/tests/parsers/str.test.js +0 -38
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.js +0 -34
- package/dist/vitest.globals.d.ts +0 -18
- package/dist/vitest.globals.js +0 -25
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@/lib/parsers", "vitest", "vitest.globals"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const parsers_1 = require("@/lib/parsers");
|
|
13
|
-
const vitest_1 = require("vitest");
|
|
14
|
-
const vitest_globals_1 = require("vitest.globals");
|
|
15
|
-
(0, vitest_1.describe)("oneOf parser", () => {
|
|
16
|
-
const parser = (0, parsers_1.oneOf)("abc");
|
|
17
|
-
(0, vitest_1.it)("should parse any one of the given characters", () => {
|
|
18
|
-
const result = parser("b");
|
|
19
|
-
(0, vitest_1.expect)(result).toEqual((0, vitest_globals_1.success)({ rest: "", match: "b" }));
|
|
20
|
-
});
|
|
21
|
-
(0, vitest_1.it)("should fail if none of the characters match", () => {
|
|
22
|
-
const result = parser("d");
|
|
23
|
-
(0, vitest_1.expect)(result).toEqual((0, vitest_globals_1.failure)({ rest: "d", message: 'expected one of "abc", got d' }));
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@/lib/parsers", "vitest", "vitest.globals"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const parsers_1 = require("@/lib/parsers");
|
|
13
|
-
const vitest_1 = require("vitest");
|
|
14
|
-
const vitest_globals_1 = require("vitest.globals");
|
|
15
|
-
(0, vitest_1.describe)("str parser", () => {
|
|
16
|
-
(0, vitest_1.it)("should parse correct string", () => {
|
|
17
|
-
const parser = (0, parsers_1.str)("hello");
|
|
18
|
-
(0, vitest_1.expect)(parser("hello world")).toEqual((0, vitest_globals_1.success)({
|
|
19
|
-
match: "hello",
|
|
20
|
-
rest: " world",
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
23
|
-
(0, vitest_1.it)("should handle incorrect string", () => {
|
|
24
|
-
const parser = (0, parsers_1.str)("hello");
|
|
25
|
-
(0, vitest_1.expect)(parser("hi there")).toEqual((0, vitest_globals_1.failure)({
|
|
26
|
-
rest: "hi there",
|
|
27
|
-
message: "expected hello, got hi th",
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
(0, vitest_1.it)("should handle unexpected end of input", () => {
|
|
31
|
-
const parser = (0, parsers_1.str)("hello");
|
|
32
|
-
(0, vitest_1.expect)(parser("hel")).toEqual((0, vitest_globals_1.failure)({
|
|
33
|
-
rest: "hel",
|
|
34
|
-
message: "expected hello, got hel",
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
package/dist/vitest.config.d.ts
DELETED
package/dist/vitest.config.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
-
};
|
|
4
|
-
(function (factory) {
|
|
5
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
-
var v = factory(require, exports);
|
|
7
|
-
if (v !== undefined) module.exports = v;
|
|
8
|
-
}
|
|
9
|
-
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "path", "vitest/config"], factory);
|
|
11
|
-
}
|
|
12
|
-
})(function (require, exports) {
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const config_1 = require("vitest/config");
|
|
17
|
-
console.log("dirname", __dirname);
|
|
18
|
-
const config = (0, config_1.defineConfig)({
|
|
19
|
-
test: {
|
|
20
|
-
globals: true,
|
|
21
|
-
environment: "node",
|
|
22
|
-
setupFiles: "./vitest.globals.ts",
|
|
23
|
-
include: ["./lib/**/*.test.{js,ts,tsx}", "./tests/**/*.test.{js,ts,tsx}"],
|
|
24
|
-
exclude: [...config_1.configDefaults.exclude, "./build/**/*", "./dist/**/*"],
|
|
25
|
-
coverage: {
|
|
26
|
-
//include: ["./src/**/*", "./app/**/*"],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
resolve: {
|
|
30
|
-
alias: [{ find: "@/lib", replacement: path_1.default.resolve(__dirname, "./lib") }],
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
exports.default = config;
|
|
34
|
-
});
|
package/dist/vitest.globals.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function success<T>({ rest, match, captures, }: {
|
|
2
|
-
rest: string;
|
|
3
|
-
match: T;
|
|
4
|
-
captures?: Record<string, string>;
|
|
5
|
-
}): {
|
|
6
|
-
success: boolean;
|
|
7
|
-
rest: string;
|
|
8
|
-
match: T;
|
|
9
|
-
captures: Record<string, string> | undefined;
|
|
10
|
-
};
|
|
11
|
-
export declare function failure({ rest, message }: {
|
|
12
|
-
rest: string;
|
|
13
|
-
message: string;
|
|
14
|
-
}): {
|
|
15
|
-
success: boolean;
|
|
16
|
-
rest: string;
|
|
17
|
-
message: string;
|
|
18
|
-
};
|
package/dist/vitest.globals.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "vitest"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.failure = exports.success = void 0;
|
|
13
|
-
const vitest_1 = require("vitest");
|
|
14
|
-
vitest_1.vi.mock("nanoid", () => {
|
|
15
|
-
return { nanoid: () => "fakeid" };
|
|
16
|
-
});
|
|
17
|
-
function success({ rest, match, captures, }) {
|
|
18
|
-
return { success: true, rest, match, captures };
|
|
19
|
-
}
|
|
20
|
-
exports.success = success;
|
|
21
|
-
function failure({ rest, message }) {
|
|
22
|
-
return { success: false, rest, message };
|
|
23
|
-
}
|
|
24
|
-
exports.failure = failure;
|
|
25
|
-
});
|