@rethinkhealth/hl7v2-utils 0.2.8 → 0.2.10
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/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { Nodes } from '@rethinkhealth/hl7v2-ast';
|
|
1
2
|
/**
|
|
2
3
|
* HL7v2 Delimiters type
|
|
3
4
|
*/
|
|
4
|
-
export
|
|
5
|
+
export type HL7v2Delimiters = {
|
|
5
6
|
field: string;
|
|
6
7
|
component: string;
|
|
7
8
|
subcomponent: string;
|
|
8
9
|
repetition: string;
|
|
9
10
|
escape: string;
|
|
10
11
|
segment: string;
|
|
11
|
-
}
|
|
12
|
+
};
|
|
12
13
|
export declare const DEFAULT_DELIMITERS: {
|
|
13
14
|
field: string;
|
|
14
15
|
component: string;
|
|
@@ -17,4 +18,8 @@ export declare const DEFAULT_DELIMITERS: {
|
|
|
17
18
|
escape: string;
|
|
18
19
|
segment: string;
|
|
19
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Utility: check if a node is semantically empty
|
|
23
|
+
*/
|
|
24
|
+
export declare function isEmptyNode(node: Nodes | null | undefined): boolean;
|
|
20
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAMtD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAMF;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CA2BnE"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,26 @@ var DEFAULT_DELIMITERS = {
|
|
|
7
7
|
escape: "\\",
|
|
8
8
|
segment: "\r"
|
|
9
9
|
};
|
|
10
|
+
function isEmptyNode(node) {
|
|
11
|
+
if (!node) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if ("value" in node) {
|
|
15
|
+
return !node.value || node.value.trim() === "";
|
|
16
|
+
}
|
|
17
|
+
if ("children" in node) {
|
|
18
|
+
if (!node.children || node.children.length === 0) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (node.children.length > 1) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return isEmptyNode(node.children[0]);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
10
28
|
export {
|
|
11
|
-
DEFAULT_DELIMITERS
|
|
29
|
+
DEFAULT_DELIMITERS,
|
|
30
|
+
isEmptyNode
|
|
12
31
|
};
|
|
13
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * HL7v2 Delimiters type\n */\nexport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Nodes } from '@rethinkhealth/hl7v2-ast';\n\n// -------------\n// Delimiters\n// -------------\n\n/**\n * HL7v2 Delimiters type\n */\nexport type HL7v2Delimiters = {\n field: string;\n component: string;\n subcomponent: string;\n repetition: string;\n escape: string;\n segment: string; // now always a string\n};\n\nexport const DEFAULT_DELIMITERS = {\n field: '|',\n component: '^',\n repetition: '~',\n subcomponent: '&',\n escape: '\\\\',\n segment: '\\r',\n};\n\n// -------------\n// General\n// -------------\n\n/**\n * Utility: check if a node is semantically empty\n */\nexport function isEmptyNode(node: Nodes | null | undefined): boolean {\n if (!node) {\n return true;\n }\n\n // If node has a \"value\" property (Subcomponent, maybe Component)\n if ('value' in node) {\n return !node.value || node.value.trim() === '';\n }\n\n // If node has children (Field, Component, Repetition, Segment, Root, etc.)\n if ('children' in node) {\n if (!node.children || node.children.length === 0) {\n return true;\n }\n\n // If node has more than one child, then it is considered non-empty\n if (node.children.length > 1) {\n return false;\n }\n\n // If node has only one child, then it is considered empty if the child is also empty\n return isEmptyNode(node.children[0]);\n }\n\n // Fallback: consider unknown node as non-empty\n return false;\n}\n"],"mappings":";AAkBO,IAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,SAAS;AACX;AASO,SAAS,YAAY,MAAyC;AACnE,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AAGA,MAAI,WAAW,MAAM;AACnB,WAAO,CAAC,KAAK,SAAS,KAAK,MAAM,KAAK,MAAM;AAAA,EAC9C;AAGA,MAAI,cAAc,MAAM;AACtB,QAAI,CAAC,KAAK,YAAY,KAAK,SAAS,WAAW,GAAG;AAChD,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,SAAS,SAAS,GAAG;AAC5B,aAAO;AAAA,IACT;AAGA,WAAO,YAAY,KAAK,SAAS,CAAC,CAAC;AAAA,EACrC;AAGA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rethinkhealth/hl7v2-utils",
|
|
3
3
|
"description": "hl7v2 utilities",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Melek Somai",
|
|
@@ -17,13 +17,16 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "22.15.31",
|
|
20
|
+
"@types/unist": "^3.0.3",
|
|
20
21
|
"@vitest/coverage-c8": "^0.33.0",
|
|
21
22
|
"@vitest/coverage-v8": "^3.2.4",
|
|
22
23
|
"tsup": "8.5.0",
|
|
23
24
|
"typescript": "^5.8.3",
|
|
25
|
+
"unist-builder": "^4.0.0",
|
|
24
26
|
"vitest": "^3.2.4",
|
|
25
|
-
"@rethinkhealth/
|
|
26
|
-
"@rethinkhealth/
|
|
27
|
+
"@rethinkhealth/testing": "0.0.1",
|
|
28
|
+
"@rethinkhealth/tsconfig": "0.0.1",
|
|
29
|
+
"@rethinkhealth/hl7v2-ast": "0.2.10"
|
|
27
30
|
},
|
|
28
31
|
"repository": "rethinkhealth/hl7v2.git",
|
|
29
32
|
"homepage": "https://www.rethinkhealth.io/hl7v2/docs",
|
|
@@ -35,12 +38,15 @@
|
|
|
35
38
|
"nodejs",
|
|
36
39
|
"typescript"
|
|
37
40
|
],
|
|
38
|
-
"packageManager": "pnpm@10.
|
|
41
|
+
"packageManager": "pnpm@10.14.0",
|
|
39
42
|
"publishConfig": {
|
|
40
43
|
"access": "public"
|
|
41
44
|
},
|
|
42
45
|
"scripts": {
|
|
43
46
|
"build": "tsup && tsc --emitDeclarationOnly",
|
|
44
|
-
"check-types": "tsc --noEmit"
|
|
47
|
+
"check-types": "tsc --noEmit",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:coverage": "vitest run --coverage",
|
|
50
|
+
"test:watch": "vitest"
|
|
45
51
|
}
|
|
46
52
|
}
|