@viamrobotics/motion-tools 1.3.0 → 1.3.1
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.
|
@@ -7,7 +7,7 @@ export declare const Extensions: {
|
|
|
7
7
|
readonly PB_GZ: "pb.gz";
|
|
8
8
|
};
|
|
9
9
|
export declare const Prefixes: {
|
|
10
|
-
readonly Snapshot: "
|
|
10
|
+
readonly Snapshot: "visualization_snapshot";
|
|
11
11
|
};
|
|
12
12
|
declare class FileNameError extends Error {
|
|
13
13
|
constructor(message: string, options?: ErrorOptions);
|
|
@@ -6,7 +6,7 @@ export const Extensions = {
|
|
|
6
6
|
PB_GZ: 'pb.gz',
|
|
7
7
|
};
|
|
8
8
|
export const Prefixes = {
|
|
9
|
-
Snapshot: '
|
|
9
|
+
Snapshot: 'visualization_snapshot',
|
|
10
10
|
};
|
|
11
11
|
class FileNameError extends Error {
|
|
12
12
|
constructor(message, options) {
|
|
@@ -17,10 +17,12 @@ class FileNameError extends Error {
|
|
|
17
17
|
const isExtension = (extension) => {
|
|
18
18
|
return Object.values(Extensions).includes(extension);
|
|
19
19
|
};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const hasPrefix = (name) => {
|
|
21
|
+
for (const prefix of Object.values(Prefixes)) {
|
|
22
|
+
if (name.startsWith(prefix))
|
|
23
|
+
return prefix;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
24
26
|
};
|
|
25
27
|
const validatePrefix = (extension, prefix) => {
|
|
26
28
|
switch (prefix) {
|
|
@@ -57,8 +59,8 @@ export const parseFileName = (filename) => {
|
|
|
57
59
|
error: new FileNameError(`Only ${Object.values(Extensions).join(', ')} files are supported.`),
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
const prefix = name
|
|
61
|
-
if (
|
|
62
|
+
const prefix = hasPrefix(name);
|
|
63
|
+
if (prefix) {
|
|
62
64
|
const error = validatePrefix(extension, prefix);
|
|
63
65
|
if (error) {
|
|
64
66
|
return {
|