skir 0.0.1 → 0.0.2
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/dist/casing.d.ts +1 -4
- package/dist/casing.d.ts.map +1 -1
- package/dist/casing.js +0 -29
- package/dist/casing.js.map +1 -1
- package/dist/casing.test.js +2 -13
- package/dist/casing.test.js.map +1 -1
- package/dist/command_line_parser.d.ts +3 -3
- package/dist/command_line_parser.d.ts.map +1 -1
- package/dist/command_line_parser.js +35 -38
- package/dist/command_line_parser.js.map +1 -1
- package/dist/command_line_parser.test.js +73 -78
- package/dist/command_line_parser.test.js.map +1 -1
- package/dist/compatibility_checker.d.ts +9 -3
- package/dist/compatibility_checker.d.ts.map +1 -1
- package/dist/compatibility_checker.js +17 -4
- package/dist/compatibility_checker.js.map +1 -1
- package/dist/compatibility_checker.test.js +55 -1
- package/dist/compatibility_checker.test.js.map +1 -1
- package/dist/compiler.js +34 -17
- package/dist/compiler.js.map +1 -1
- package/dist/config.d.ts +5 -35
- package/dist/config.d.ts.map +1 -1
- package/dist/definition_finder.d.ts +1 -1
- package/dist/definition_finder.d.ts.map +1 -1
- package/dist/doc_comment_parser.d.ts +3 -0
- package/dist/doc_comment_parser.d.ts.map +1 -0
- package/dist/doc_comment_parser.js +219 -0
- package/dist/doc_comment_parser.js.map +1 -0
- package/dist/doc_comment_parser.test.d.ts +2 -0
- package/dist/doc_comment_parser.test.d.ts.map +1 -0
- package/dist/doc_comment_parser.test.js +494 -0
- package/dist/doc_comment_parser.test.js.map +1 -0
- package/dist/error_renderer.d.ts +1 -1
- package/dist/error_renderer.d.ts.map +1 -1
- package/dist/error_renderer.js +84 -65
- package/dist/error_renderer.js.map +1 -1
- package/dist/formatter.d.ts +15 -2
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +191 -234
- package/dist/formatter.js.map +1 -1
- package/dist/formatter.test.js +322 -88
- package/dist/formatter.test.js.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/language_server.js +1 -1
- package/dist/language_server.js.map +1 -1
- package/dist/literals.d.ts +1 -2
- package/dist/literals.d.ts.map +1 -1
- package/dist/literals.js +1 -12
- package/dist/literals.js.map +1 -1
- package/dist/literals.test.js +1 -4
- package/dist/literals.test.js.map +1 -1
- package/dist/module_set.d.ts +3 -7
- package/dist/module_set.d.ts.map +1 -1
- package/dist/module_set.js +205 -51
- package/dist/module_set.js.map +1 -1
- package/dist/module_set.test.js +595 -28
- package/dist/module_set.test.js.map +1 -1
- package/dist/parser.d.ts +3 -4
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +185 -92
- package/dist/parser.js.map +1 -1
- package/dist/parser.test.js +243 -15
- package/dist/parser.test.js.map +1 -1
- package/dist/project_initializer.d.ts +2 -0
- package/dist/project_initializer.d.ts.map +1 -0
- package/dist/project_initializer.js +30 -0
- package/dist/project_initializer.js.map +1 -0
- package/dist/snapshotter.d.ts +3 -0
- package/dist/snapshotter.d.ts.map +1 -1
- package/dist/snapshotter.js +43 -6
- package/dist/snapshotter.js.map +1 -1
- package/dist/tokenizer.d.ts +8 -2
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +26 -20
- package/dist/tokenizer.js.map +1 -1
- package/dist/tokenizer.test.js +285 -269
- package/dist/tokenizer.test.js.map +1 -1
- package/package.json +7 -5
- package/src/casing.ts +1 -36
- package/src/command_line_parser.ts +42 -48
- package/src/compatibility_checker.ts +29 -7
- package/src/compiler.ts +35 -18
- package/src/definition_finder.ts +1 -1
- package/src/doc_comment_parser.ts +246 -0
- package/src/error_renderer.ts +90 -66
- package/src/formatter.ts +249 -238
- package/src/index.ts +0 -6
- package/src/language_server.ts +8 -8
- package/src/literals.ts +5 -14
- package/src/module_set.ts +259 -79
- package/src/parser.ts +213 -98
- package/src/project_initializer.ts +39 -0
- package/src/snapshotter.ts +46 -5
- package/src/tokenizer.ts +47 -25
- package/dist/encoding.d.ts +0 -2
- package/dist/encoding.d.ts.map +0 -1
- package/dist/encoding.js +0 -38
- package/dist/encoding.js.map +0 -1
- package/dist/encoding.test.d.ts +0 -2
- package/dist/encoding.test.d.ts.map +0 -1
- package/dist/encoding.test.js +0 -23
- package/dist/encoding.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -14
- package/dist/index.test.js.map +0 -1
- package/dist/types.d.ts +0 -375
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/encoding.ts +0 -32
- package/src/types.ts +0 -518
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as paths from "path";
|
|
3
|
+
|
|
4
|
+
export function initializeProject(rootDir: string): void {
|
|
5
|
+
const skirYmlPath = paths.join(rootDir, "skir.yml");
|
|
6
|
+
|
|
7
|
+
// Check if skir.yml already exists
|
|
8
|
+
if (fs.existsSync(skirYmlPath)) {
|
|
9
|
+
console.log(
|
|
10
|
+
"A skir.yml file already exists in this directory. Skipping project initialization.",
|
|
11
|
+
);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Create skir.yml file
|
|
16
|
+
fs.writeFileSync(skirYmlPath, SKIR_YML_CONTENT, "utf-8");
|
|
17
|
+
|
|
18
|
+
// Check if skir-src directory exists
|
|
19
|
+
const skirSrcDir = paths.join(rootDir, "skir-src");
|
|
20
|
+
if (!fs.existsSync(skirSrcDir)) {
|
|
21
|
+
// Create skir-src directory
|
|
22
|
+
fs.mkdirSync(skirSrcDir, { recursive: true });
|
|
23
|
+
|
|
24
|
+
// Create hello_world.skir file
|
|
25
|
+
const helloWorldPath = paths.join(skirSrcDir, "hello_world.skir");
|
|
26
|
+
fs.writeFileSync(helloWorldPath, HELLO_WORLD_SKIR_CONTENT, "utf-8");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log(`Done. Please edit: ${paths.resolve(skirYmlPath)}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const SKIR_YML_CONTENT = `srcDir: skir-src
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const HELLO_WORLD_SKIR_CONTENT = `struct Point {
|
|
36
|
+
x: int32;
|
|
37
|
+
y: int32;
|
|
38
|
+
}
|
|
39
|
+
`;
|
package/src/snapshotter.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { checkBackwardCompatibility } from "./compatibility_checker.js";
|
|
4
4
|
import {
|
|
5
5
|
formatError,
|
|
6
|
+
makeGreen,
|
|
6
7
|
makeRed,
|
|
7
8
|
renderBreakingChanges,
|
|
8
9
|
renderErrors,
|
|
@@ -42,8 +43,9 @@ export async function takeSnapshot(args: {
|
|
|
42
43
|
});
|
|
43
44
|
process.exit(1);
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
46
|
+
const now = new Date();
|
|
47
|
+
const newSnapshot = makeSnapshot(newModuleSet, now);
|
|
48
|
+
if (sameModules(newSnapshot, makeSnapshot(oldModuleSet, now))) {
|
|
47
49
|
console.log("No changes detected since last snapshot.");
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
@@ -51,7 +53,7 @@ export async function takeSnapshot(args: {
|
|
|
51
53
|
console.error(
|
|
52
54
|
makeRed(
|
|
53
55
|
`Modules have changed since the last snapshot. ` +
|
|
54
|
-
`Run the command without
|
|
56
|
+
`Run the command without 'check' to take a new snapshot.`,
|
|
55
57
|
),
|
|
56
58
|
);
|
|
57
59
|
process.exit(1);
|
|
@@ -110,20 +112,58 @@ async function readLastSnapshot(snapshotPath: string): Promise<
|
|
|
110
112
|
return moduleSet;
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
export async function viewSnapshot(args: { rootDir: string }): Promise<void> {
|
|
116
|
+
const snapshotPath = join(args.rootDir, "skir-snapshot.json");
|
|
117
|
+
let snapshot: Snapshot;
|
|
118
|
+
try {
|
|
119
|
+
const textContent = await readFile(snapshotPath, "utf-8");
|
|
120
|
+
snapshot = JSON.parse(textContent);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error instanceof SyntaxError) {
|
|
123
|
+
console.error(makeRed(`Corrupted snapshot file: ${snapshotPath}`));
|
|
124
|
+
console.error(`Error: ${error.toString()}`);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
const isNotFoundError =
|
|
128
|
+
error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
129
|
+
if (isNotFoundError) {
|
|
130
|
+
console.log("No snapshot found.");
|
|
131
|
+
return;
|
|
132
|
+
} else {
|
|
133
|
+
// Rethrow I/O error
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
console.log(`Last snapshot: ${snapshot.lastChange}\n`);
|
|
139
|
+
|
|
140
|
+
const modulePaths = Object.keys(snapshot.modules).sort();
|
|
141
|
+
for (const path of modulePaths) {
|
|
142
|
+
console.log(makeGreen("-".repeat(80)));
|
|
143
|
+
console.log(makeGreen(path));
|
|
144
|
+
console.log(makeGreen("-".repeat(80)));
|
|
145
|
+
console.log();
|
|
146
|
+
const sourceCode = snapshot.modules[path]!;
|
|
147
|
+
console.log(sourceCode);
|
|
148
|
+
console.log();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
113
152
|
function makeSnapshot(moduleSet: ModuleSet, now: Date): Snapshot {
|
|
114
153
|
const modules: { [path: string]: string } = {};
|
|
115
154
|
for (const module of moduleSet.resolvedModules) {
|
|
116
155
|
modules[module.path] = module.sourceCode;
|
|
117
156
|
}
|
|
118
157
|
return {
|
|
158
|
+
readMe: "DO NOT EDIT. To update, run: npx skir snapshot",
|
|
119
159
|
lastChange: now.toISOString(),
|
|
120
|
-
modules
|
|
160
|
+
modules,
|
|
121
161
|
};
|
|
122
162
|
}
|
|
123
163
|
|
|
124
164
|
function sameModules(a: Snapshot, b: Snapshot): boolean {
|
|
125
165
|
return (
|
|
126
|
-
Object.keys(a.modules).length === Object.keys(b.modules).length
|
|
166
|
+
Object.keys(a.modules).length === Object.keys(b.modules).length &&
|
|
127
167
|
Object.entries(a.modules).every(([path, sourceCode]) => {
|
|
128
168
|
return sourceCode === b.modules[path];
|
|
129
169
|
})
|
|
@@ -131,6 +171,7 @@ function sameModules(a: Snapshot, b: Snapshot): boolean {
|
|
|
131
171
|
}
|
|
132
172
|
|
|
133
173
|
interface Snapshot {
|
|
174
|
+
readMe: string;
|
|
134
175
|
lastChange: string;
|
|
135
176
|
modules: { [path: string]: string };
|
|
136
177
|
}
|
package/src/tokenizer.ts
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
unquoteAndUnescape,
|
|
3
|
+
type CodeLine,
|
|
4
|
+
type ErrorSink,
|
|
5
|
+
type Result,
|
|
6
|
+
type SkirError,
|
|
7
|
+
type Token,
|
|
8
|
+
} from "skir-internal";
|
|
9
|
+
|
|
10
|
+
export interface ModuleTokens {
|
|
11
|
+
/// Includes regular comments and doc comments.
|
|
12
|
+
readonly tokens: readonly Token[];
|
|
13
|
+
/// Includes both kinds of comments.
|
|
14
|
+
readonly tokensWithComments: readonly Token[];
|
|
15
|
+
readonly sourceCode: string;
|
|
16
|
+
readonly modulePath: string;
|
|
17
|
+
}
|
|
3
18
|
|
|
4
19
|
/** Tokenizes the given module. */
|
|
5
20
|
export function tokenizeModule(
|
|
6
|
-
|
|
21
|
+
sourceCode: string,
|
|
7
22
|
modulePath: string,
|
|
8
|
-
|
|
9
|
-
): Result<Token[]> {
|
|
23
|
+
): Result<ModuleTokens> {
|
|
10
24
|
const tokens: Token[] = [];
|
|
11
25
|
const errors: SkirError[] = [];
|
|
12
26
|
|
|
13
|
-
const lines = new Lines(
|
|
27
|
+
const lines = new Lines(sourceCode, modulePath);
|
|
14
28
|
|
|
15
29
|
// Multiline comment: \/\*([^*]|\*[^\/])*(\*\/)?
|
|
16
30
|
// Single-line comment: \/\/[^\n\r]*
|
|
@@ -28,7 +42,7 @@ export function tokenizeModule(
|
|
|
28
42
|
|
|
29
43
|
let group: RegExpExecArray | null;
|
|
30
44
|
let expectedPosition = 0;
|
|
31
|
-
while ((group = re.exec(
|
|
45
|
+
while ((group = re.exec(sourceCode)) !== null) {
|
|
32
46
|
const position = re.lastIndex - group[0].length;
|
|
33
47
|
|
|
34
48
|
// Check that all the regex matches are consecutive.
|
|
@@ -37,9 +51,11 @@ export function tokenizeModule(
|
|
|
37
51
|
if (position !== expectedPosition) {
|
|
38
52
|
const line = lines.advancePosition(expectedPosition);
|
|
39
53
|
const colNumber = expectedPosition - line.position;
|
|
54
|
+
const text = sourceCode.substring(expectedPosition, position);
|
|
40
55
|
errors.push({
|
|
41
56
|
token: {
|
|
42
|
-
text:
|
|
57
|
+
text: text,
|
|
58
|
+
originalText: text,
|
|
43
59
|
position: expectedPosition,
|
|
44
60
|
line: line,
|
|
45
61
|
colNumber: colNumber,
|
|
@@ -51,28 +67,19 @@ export function tokenizeModule(
|
|
|
51
67
|
|
|
52
68
|
const line = lines.advancePosition(position);
|
|
53
69
|
const colNumber = position - line.position;
|
|
54
|
-
const token = {
|
|
70
|
+
const token: Token = {
|
|
55
71
|
text: group[0],
|
|
72
|
+
originalText: group[0],
|
|
56
73
|
position: position,
|
|
57
74
|
line: line,
|
|
58
75
|
colNumber: colNumber,
|
|
59
76
|
};
|
|
60
77
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
token: token,
|
|
67
|
-
message: "Unterminated multi-line comment",
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Skip single-line comments.
|
|
74
|
-
if (group[4] !== undefined && !keepComments) {
|
|
75
|
-
continue;
|
|
78
|
+
if (group[1] !== undefined && !group[1].endsWith("*/")) {
|
|
79
|
+
errors.push({
|
|
80
|
+
token: token,
|
|
81
|
+
message: "Unterminated multi-line comment",
|
|
82
|
+
});
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
if (group[8] !== undefined) {
|
|
@@ -126,7 +133,15 @@ export function tokenizeModule(
|
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
return {
|
|
136
|
+
return {
|
|
137
|
+
result: {
|
|
138
|
+
tokens: tokens.filter((t) => !isRegularComment(t.originalText)),
|
|
139
|
+
tokensWithComments: tokens,
|
|
140
|
+
sourceCode: sourceCode,
|
|
141
|
+
modulePath: modulePath,
|
|
142
|
+
},
|
|
143
|
+
errors: errors,
|
|
144
|
+
};
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
function validateWord(token: Token, errors: ErrorSink): boolean {
|
|
@@ -173,6 +188,13 @@ function validateWord(token: Token, errors: ErrorSink): boolean {
|
|
|
173
188
|
return true;
|
|
174
189
|
}
|
|
175
190
|
|
|
191
|
+
function isRegularComment(token: string): boolean {
|
|
192
|
+
return (
|
|
193
|
+
token.startsWith("/*") ||
|
|
194
|
+
(token.startsWith("//") && !token.startsWith("///"))
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
176
198
|
class Lines {
|
|
177
199
|
/** Splits the given code into multiple lines. */
|
|
178
200
|
constructor(code: string, modulePath: string) {
|
package/dist/encoding.d.ts
DELETED
package/dist/encoding.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CA+BjD"}
|
package/dist/encoding.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export function encodeInt32(i) {
|
|
2
|
-
const buffer = new ArrayBuffer(5);
|
|
3
|
-
const dataView = new DataView(buffer);
|
|
4
|
-
let n;
|
|
5
|
-
if (i < 0) {
|
|
6
|
-
if (i >= -256) {
|
|
7
|
-
dataView.setUint8(0, 235);
|
|
8
|
-
dataView.setUint8(1, i + 256);
|
|
9
|
-
n = 2;
|
|
10
|
-
}
|
|
11
|
-
else if (i >= -65536) {
|
|
12
|
-
dataView.setUint8(0, 236);
|
|
13
|
-
dataView.setUint16(1, i + 65536, true);
|
|
14
|
-
n = 3;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
dataView.setUint8(0, 237);
|
|
18
|
-
dataView.setInt32(1, i, true);
|
|
19
|
-
n = 5;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (i < 232) {
|
|
23
|
-
dataView.setUint8(0, i);
|
|
24
|
-
n = 1;
|
|
25
|
-
}
|
|
26
|
-
else if (i < 65536) {
|
|
27
|
-
dataView.setUint8(0, 232);
|
|
28
|
-
dataView.setUint16(1, i, true);
|
|
29
|
-
n = 3;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
dataView.setUint8(0, 233);
|
|
33
|
-
dataView.setInt32(1, i, true);
|
|
34
|
-
n = 5;
|
|
35
|
-
}
|
|
36
|
-
return new Uint8Array(buffer, 0, n);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=encoding.js.map
|
package/dist/encoding.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,CAAS,CAAC;IACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,QAAQ,CAAC,QAAQ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CAAC"}
|
package/dist/encoding.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.test.d.ts","sourceRoot":"","sources":["../src/encoding.test.ts"],"names":[],"mappings":""}
|
package/dist/encoding.test.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { expect } from "buckwheat";
|
|
2
|
-
import { describe, it } from "mocha";
|
|
3
|
-
import { encodeInt32 } from "./encoding.js";
|
|
4
|
-
function toHexString(a) {
|
|
5
|
-
return [...a].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
6
|
-
}
|
|
7
|
-
describe("encoding", () => {
|
|
8
|
-
it("encodeInt32 works", () => {
|
|
9
|
-
expect(toHexString(encodeInt32(4))).toMatch("04");
|
|
10
|
-
expect(toHexString(encodeInt32(231))).toMatch("e7");
|
|
11
|
-
expect(toHexString(encodeInt32(232))).toMatch("e8e800");
|
|
12
|
-
expect(toHexString(encodeInt32(65535))).toMatch("e8ffff");
|
|
13
|
-
expect(toHexString(encodeInt32(65536))).toMatch("e900000100");
|
|
14
|
-
expect(toHexString(encodeInt32(2147483647))).toMatch("e9ffffff7f");
|
|
15
|
-
expect(toHexString(encodeInt32(-255))).toMatch("eb01");
|
|
16
|
-
expect(toHexString(encodeInt32(-256))).toMatch("eb00");
|
|
17
|
-
expect(toHexString(encodeInt32(-257))).toMatch("ecfffe");
|
|
18
|
-
expect(toHexString(encodeInt32(-65536))).toMatch("ec0000");
|
|
19
|
-
expect(toHexString(encodeInt32(-65537))).toMatch("edfffffeff");
|
|
20
|
-
expect(toHexString(encodeInt32(-2147483648))).toMatch("ed00000080");
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=encoding.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.test.js","sourceRoot":"","sources":["../src/encoding.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACn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AAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzD,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC/D,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.test.d.ts
DELETED
package/dist/index.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
package/dist/index.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { expect } from "buckwheat";
|
|
2
|
-
import { describe, it } from "mocha";
|
|
3
|
-
import * as exports from "./index.js";
|
|
4
|
-
describe("index.ts", () => {
|
|
5
|
-
it("exports the right symbols", () => {
|
|
6
|
-
// The actual logic is covered in other unit tests.
|
|
7
|
-
// Here we just want to make sure the right symbols are exported.
|
|
8
|
-
let _;
|
|
9
|
-
expect(exports.convertCase("foo", "lowerCamel", "UPPER_UNDERSCORE")).toBe("FOO");
|
|
10
|
-
expect(exports.capitalize("foo")).toBe("Foo");
|
|
11
|
-
expect(exports.unquoteAndUnescape('"foo"')).toBe("foo");
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=index.test.js.map
|
package/dist/index.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,mDAAmD;QACnD,iEAAiE;QACjE,IAAI,CAAiB,CAAC;QACtB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CACvE,KAAK,CACN,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|