hast utility to check if an element is a JavaScript script
npm install hast-util-is-javascript[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][funding-sponsors-badge]][funding]
[![Backers][funding-backers-badge]][funding]
[![Chat][chat-badge]][chat]
[hast][hast] utility to check if an element is a JavaScript script.
* What is this?
* When should I use this?
* Install
* Use
* API
* isJavaScript(node)
* Syntax
* Syntax tree
* Types
* Compatibility
* Security
* Contribute
* License
This package is a utility to check whether a hast node is a that
contains or references JavaScript.
You can use this package to check whether elements contain or
reference JavaScript or something else.
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install hast-util-is-javascript
In Deno with [esm.sh][esm-sh]:
`js`
import {isJavaScript} from 'https://esm.sh/hast-util-is-javascript@3'
In browsers with [esm.sh][esm-sh]:
`html`
`js
import {h} from 'hastscript'
import {isJavaScript} from 'hast-util-is-javascript'
isJavaScript(h('script')) //=> true
isJavaScript(h('script', {type: 'text/ecmascript'})) //=> true
isJavaScript(h('script', {language: 'ecmascript'})) //=> true
isJavaScript(h('script', {type: 'text/fooscript'})) //=> false
isJavaScript(h('script', {language: 'fooscript'})) //=> false
`
This package exports the identifier
isJavaScript.
There is no default export.
Check if a node is a