Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fisker/get-text-nodes
get child text nodes
https://github.com/fisker/get-text-nodes
Last synced: 6 days ago
JSON representation
get child text nodes
- Host: GitHub
- URL: https://github.com/fisker/get-text-nodes
- Owner: fisker
- License: mit
- Created: 2019-08-29T11:31:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T20:19:03.000Z (6 months ago)
- Last Synced: 2024-05-22T21:38:32.741Z (6 months ago)
- Language: JavaScript
- Size: 756 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# get-text-nodes
> get child text nodes
## Install
```sh
yarn add get-text-nodes
```## Files
```text
dist/
├─ index.js ( UMD )
├─ index.min.js ( UMD, compressed )
├─ index.mjs ( ES Module )
└─ index.min.mjs ( ES Module, compressed )
```## Usage
```html
import getTextNodes from 'https://unpkg.com/get-text-nodes?module'
```
`UMD` build exports a global function `getTextNodes`
## API
### getTextNodes(nodeList, options?)
get child text nodes from `nodeList`
```js
getTextNodes(document.body)
// -> [text, text, ...]
```#### nodeList
- `NodeList`, `Node`, `Array` or any `arrayLike`
```js
// Node
getTextNodes(document.body)// HTMLCollection
getTextNodes(document.getElementsByTagName('*'))// NodeList
getTextNodes(document.querySelectorAll('*'))// Array
getTextNodes([...document.getElementsByTagName('*')])
```#### options.ignoreWhiteSpace
- Type: `boolean`
- Default: `true`
- ignore WhiteSpace text node#### options.deep
- Type: `boolean`
- Default: `true`
- get text nodes from children