janus-parse 1.2.0 → 1.2.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.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -109,14 +109,10 @@ type Config {
109
109
  - **`config`**: Optional rule blocks to override standard cleaning lists.
110
110
  - **Returns**: A promise that resolves to a stripped, whitespace-normalized single-line string.
111
111
 
112
+ ---
113
+
112
114
  #### `janusClient(text: string, config?: Config): string`
113
115
 
114
116
  - **`text`**: The input raw HTML string.
115
117
  - **`config`**: Optional rule blocks to override standard cleaning lists.
116
118
  - **Returns**: A clean string containing target inner-text nodes parsed from the browser context.
117
-
118
- ---
119
-
120
- ## License
121
-
122
- Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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AAG,MAAM,CAgCT;AAwBD,KAAK,IAAI,GAAG,eAAe,GAAG,SAAS,CAAC"}
@@ -1,8 +1,7 @@
1
1
  const defaultBlacklistTags = new Set(["script", "style"]);
2
2
  export function validateText(text) {
3
- if (typeof text !== "string" ||
4
- (typeof text === "string" && text === "undefined")) {
5
- throw new Error("The text is not a valid string. Please provide a valid string to parse.", { cause: text });
3
+ if (typeof text !== "string") {
4
+ throw new TypeError(`\n======================================================\n=> ${text} recieved. String expected.\n======================================================`, { cause: `${text} is not of type string.` });
6
5
  }
7
6
  }
8
7
  export function normalizeWhitespace(text = "") {
@@ -28,18 +27,18 @@ export function serialize({ node, removedTags, preservedTags, }) {
28
27
  return "";
29
28
  if (node.nodeType === 3) {
30
29
  // DOM Text node => 3
31
- const rawText = validateNode(node, "rawText");
32
- const text = validateNode(node, "text");
30
+ const rawText = getNodeProperty(node, "rawText");
31
+ const text = getNodeProperty(node, "text");
33
32
  return rawText ?? text ?? node.textContent ?? "";
34
33
  }
35
- const tagName = validateNode(node, "tagName") ?? "";
34
+ const tagName = getNodeProperty(node, "tagName") ?? "";
36
35
  const tag = tagName.toLowerCase();
37
36
  // Completely ignore blacklisted tags
38
37
  if (removedTags.has(tag))
39
38
  return "";
40
39
  // Keep preserved tags intact along with their outer HTML structure
41
40
  if (preservedTags.has(tag)) {
42
- const outerHTML = validateNode(node, "outerHTML");
41
+ const outerHTML = getNodeProperty(node, "outerHTML");
43
42
  return (outerHTML ??
44
43
  (typeof node.toString === "function" ? node.toString() : undefined) ??
45
44
  "");
@@ -61,7 +60,7 @@ function addBlackListTags(preserveTags, tagsToRemove) {
61
60
  preserveTags.add(tag.toLowerCase());
62
61
  }
63
62
  }
64
- function validateNode(node, lookup = "outerHTML") {
63
+ function getNodeProperty(node, lookup = "outerHTML") {
65
64
  const targetNode = node;
66
65
  const value = targetNode[lookup];
67
66
  return value ?? undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "janus-parse",
3
3
  "license": "MIT",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "packageManager": "pnpm@11.15.1",
@@ -67,7 +67,7 @@
67
67
  "eslint-import-resolver-typescript": "^4.4.5",
68
68
  "eslint-plugin-import-x": "^4.17.1",
69
69
  "eslint-plugin-unicorn": "^72.0.0",
70
- "happy-dom": "^20.11.0",
70
+ "happy-dom": "^20.11.1",
71
71
  "prettier": "^3.9.6",
72
72
  "semantic-release": "^25.0.8",
73
73
  "tsx": "4.23.1",