Socket
Socket
Sign inDemoInstall

node-html-light

Package Overview
Dependencies
6
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.9.0 to 2.10.0

16

CHANGELOG.md

@@ -0,1 +1,17 @@

# [2.10.0](https://github.com/stfsy/node-html-light/compare/v2.9.0...v2.10.0) (2021-07-07)
### Bug Fixes
* self closing tags not recognized ([2d5ba56](https://github.com/stfsy/node-html-light/commit/2d5ba56ed2d0f3808908af45897f92bbc36324f5))
### Features
* add filter by type function ([c3e11a8](https://github.com/stfsy/node-html-light/commit/c3e11a860ffa335aabc0bcd38b8bc44e1fe55bfb))
* add getter for root element ([acb9c31](https://github.com/stfsy/node-html-light/commit/acb9c31902ad433558693d0014d3381cd9b142de))
* add method to get children of current node ([4c0538e](https://github.com/stfsy/node-html-light/commit/4c0538e081811944edb3afa3d0a1beb71fe9640f))
# [2.9.0](https://github.com/stfsy/node-html-light/compare/v2.8.1...v2.9.0) (2021-07-06)

@@ -2,0 +18,0 @@

38

lib/node.js

@@ -63,3 +63,3 @@ 'use strict'

recognizeCDATA: false,
recognizeSelfClosing: false,
recognizeSelfClosing: true,
lowerCaseAttributeNames: false,

@@ -84,3 +84,3 @@ lowerCaseTags: false,

* Creates a new Node with name and attributes
* @param {string|Object} tag the nodes name or a pojo that will be wrapped
* @param {Object} tag the nodes name or a pojo that will be wrapped
* @param {Array.<Attribute>} [attrs=empty] attrs an array of attributes

@@ -96,3 +96,2 @@ * @returns {Node} a new Node

const node = {

@@ -181,2 +180,10 @@ name: tag,

/**
*
* @returns {Array<Node>}
*/
get children() {
return this.get().children.map(child => new Node(child))
}
/**
* Returns the previous sibling of the current node

@@ -205,2 +212,10 @@ * @returns {Node}

get root() {
let root = this.parent
while (root.parent && root.parent.type !== 'root') {
root = root.parent
}
return Node.of(root)
}
/**

@@ -262,3 +277,3 @@ * @private

* Search a node and its children for nodes passing a test function.
* @param {Node} node the root node
* @param {Function} callback the callback returns true for elements that should be in the returned array
* @param {Number} [limit=Infinity] limit the max number of results

@@ -272,2 +287,17 @@ * @returns {Array<Node>}

/**
* Search a node and its children by type for nodes passing a test function.
* @param {Function} callback the callback returns true for elements that should be in the returned array
* @param {Array<String>} types for these types the callback will be fired @see i.e. Node.TYPE_TAG
* @param {Number} [limit=Infinity] limit the max number of results
* @returns {Array<Node>}
*/
filterByType(callback, types, limit = Infinity) {
return this.filter((node) => {
if (types.includes(node.type)) {
callback(node)
}
}, limit)
}
/**
* Removes a child node

@@ -274,0 +304,0 @@ * @param {Node|Array<Node>} child the child node to remove

2

package.json
{
"name": "node-html-light",
"version": "2.9.0",
"version": "2.10.0",
"description": "HTML Parser for NodeJS providing a lightweight object oriented interface",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -43,7 +43,2 @@ # Node HTML Light

#### Instance properties
- name
- parent
- attributes
#### Instance methods

@@ -63,3 +58,8 @@ - **html**() -> [Node](#node)

- name
- type
- parent
- children
- root
- nextSibling
- previousSibling
- attributes

@@ -66,0 +66,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc