1.1.0 • Published 3 years ago

extract-dom-content v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

extract-dom-content

NPM version of extract-dom-content

Provide a DOM element and get all of its cleaned and standardized text content in an array or string.

This library was originally developed with webpage spellchecking in mind, but can be used for any purpose you might have for it.

Installation

npm install extract-dom-content

API

extractDomContent(originalNode, options) ⇒ String | Array

Takes in a DOM element and returns all of its text content.

ParamTypeDefaultDescription
originalNodeElementDOM element to get the content from.
optionsObject{}An object of options to apply additionals filters and/or change the return type.
options.returnAsArraybooleanfalseWhether the content should be returned as a linebreak-separated string or an array of strings.
options.removeDuplicatesbooleanfalseWhether duplicate strings should be removed or kept.

Contributing

If you would like to add features, fix bugs or optimize this package, feel free to fork this repository and submit a pull request.