Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

domutils

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domutils - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

19

lib/stringify.d.ts

@@ -18,2 +18,18 @@ import { Node } from "domhandler";

/**
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
*
* @deprecated Use `textContent` instead.
* @param node Node to get the inner text of.
* @returns `node`'s inner text.
*/
export declare function getText(node: Node | Node[]): string;
/**
* Get a node's text content.
*
* @param node Node to get the text content of.
* @returns `node`'s text content.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
*/
export declare function textContent(node: Node | Node[]): string;
/**
* Get a node's inner text.

@@ -23,4 +39,5 @@ *

* @returns `node`'s inner text.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
*/
export declare function getText(node: Node | Node[]): string;
export declare function innerText(node: Node | Node[]): string;
//# sourceMappingURL=stringify.d.ts.map

@@ -6,5 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0;
exports.innerText = exports.textContent = exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0;
var domhandler_1 = require("domhandler");
var dom_serializer_1 = __importDefault(require("dom-serializer"));
var domelementtype_1 = require("domelementtype");
/**

@@ -33,4 +34,5 @@ * @param node Node to get the outer HTML of.

/**
* Get a node's inner text.
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
*
* @deprecated Use `textContent` instead.
* @param node Node to get the inner text of.

@@ -51,1 +53,40 @@ * @returns `node`'s inner text.

exports.getText = getText;
/**
* Get a node's text content.
*
* @param node Node to get the text content of.
* @returns `node`'s text content.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
*/
function textContent(node) {
if (Array.isArray(node))
return node.map(textContent).join("");
if (domhandler_1.isTag(node))
return textContent(node.children);
if (domhandler_1.isCDATA(node))
return textContent(node.children);
if (domhandler_1.isText(node))
return node.data;
return "";
}
exports.textContent = textContent;
/**
* Get a node's inner text.
*
* @param node Node to get the inner text of.
* @returns `node`'s inner text.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
*/
function innerText(node) {
if (Array.isArray(node))
return node.map(innerText).join("");
if (domhandler_1.hasChildren(node) && node.type === domelementtype_1.ElementType.Tag) {
return innerText(node.children);
}
if (domhandler_1.isCDATA(node))
return innerText(node.children);
if (domhandler_1.isText(node))
return node.data;
return "";
}
exports.innerText = innerText;

10

package.json
{
"name": "domutils",
"version": "2.6.0",
"version": "2.7.0",
"description": "Utilities for working with htmlparser2's dom",

@@ -45,3 +45,3 @@ "author": "Felix Boehm <me@feedic.com>",

"@types/jest": "^26.0.0",
"@types/node": "^14.0.5",
"@types/node": "^15.0.1",
"@typescript-eslint/eslint-plugin": "^4.1.0",

@@ -52,7 +52,7 @@ "@typescript-eslint/parser": "^4.1.0",

"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jsdoc": "^32.0.2",
"eslint-plugin-jsdoc": "^35.1.0",
"htmlparser2": "~6.1.0",
"jest": "^26.0.1",
"jest": "^27.0.1",
"prettier": "^2.0.5",
"ts-jest": "^26.0.0",
"ts-jest": "^27.0.1",
"typedoc": "^0.20.5",

@@ -59,0 +59,0 @@ "typescript": "^4.0.2"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc