hast-util-is-element
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -10,2 +10,6 @@ /** | ||
/** | ||
* @template {Element} T | ||
* @typedef {null|undefined|T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>} PredicateTest | ||
*/ | ||
/** | ||
* Check if an element passes a test | ||
@@ -24,3 +28,3 @@ * | ||
* @callback TestFunctionPredicate | ||
* @param {X} element | ||
* @param {Element} element | ||
* @param {number|null|undefined} [index] | ||
@@ -49,20 +53,18 @@ * @param {Parent|null|undefined} [parent] | ||
*/ | ||
export const isElement: (<T extends import('hast').Element>( | ||
node: unknown, | ||
test: | ||
| T['tagName'] | ||
| TestFunctionPredicate<T> | ||
| (T['tagName'] | TestFunctionPredicate<T>)[], | ||
index?: number | undefined, | ||
parent?: | ||
| import('unist').Parent< | ||
import('unist').Node<import('unist').Data>, | ||
import('unist').Data | ||
> | ||
| undefined, | ||
context?: unknown | ||
) => node is T) & | ||
export const isElement: (() => false) & | ||
(<T extends import('hast').Element = import('hast').Element>( | ||
node: unknown, | ||
test?: PredicateTest<T>, | ||
index?: number | undefined, | ||
parent?: | ||
| import('unist').Parent< | ||
import('unist').Node<import('unist').Data>, | ||
import('unist').Data | ||
> | ||
| undefined, | ||
context?: unknown | ||
) => node is T) & | ||
(( | ||
node?: unknown, | ||
test?: Test, | ||
node: unknown, | ||
test: Test, | ||
index?: number | undefined, | ||
@@ -91,2 +93,8 @@ parent?: | ||
| Array<TagName | TestFunctionAnything> | ||
export type PredicateTest<T extends import('hast').Element> = | ||
| null | ||
| undefined | ||
| T['tagName'] | ||
| TestFunctionPredicate<T> | ||
| Array<T['tagName'] | TestFunctionPredicate<T>> | ||
/** | ||
@@ -104,3 +112,3 @@ * Check if an element passes a test | ||
export type TestFunctionPredicate<X extends import('hast').Element> = ( | ||
element: X, | ||
element: Element, | ||
index?: number | null | undefined, | ||
@@ -107,0 +115,0 @@ parent?: Parent | null | undefined |
12
index.js
@@ -11,2 +11,7 @@ /** | ||
/** | ||
* @template {Element} T | ||
* @typedef {null|undefined|T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>} PredicateTest | ||
*/ | ||
/** | ||
* Check if an element passes a test | ||
@@ -26,3 +31,3 @@ * | ||
* @callback TestFunctionPredicate | ||
* @param {X} element | ||
* @param {Element} element | ||
* @param {number|null|undefined} [index] | ||
@@ -61,4 +66,5 @@ * @param {Parent|null|undefined} [parent] | ||
* @type {( | ||
* (<T extends Element>(node: unknown, test: T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>, index?: number, parent?: Parent, context?: unknown) => node is T) & | ||
* ((node?: unknown, test?: Test, index?: number, parent?: Parent, context?: unknown) => boolean) | ||
* (() => false) & | ||
* (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) & | ||
* ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean) | ||
* )} | ||
@@ -65,0 +71,0 @@ */ |
{ | ||
"name": "hast-util-is-element", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "hast utility to check if a node is a (certain) element", | ||
@@ -42,11 +42,11 @@ "license": "MIT", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"tsd": "^0.17.0", | ||
"tsd": "^0.19.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"unified": "^10.0.0", | ||
"xo": "^0.42.0" | ||
"xo": "^0.47.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20238
346