syntax-tree / unist-util-is
Showing 1 of 3 files from the diff.
Other files ignored by Codecov
test/main.js has changed.
.gitignore has changed.

@@ -48,32 +48,45 @@
Loading
48 48
 * @returns {node is Y}
49 49
 */
50 50
51 +
/**
52 +
 * Check if a node passes a test.
53 +
 * When a `parent` node is known the `index` of node should also be given.
54 +
 *
55 +
 * @param node
56 +
 *   Node to check, can be anything.
57 +
 * @param test
58 +
 *   *   When nullish, checks if `node` is a `Node`.
59 +
 *   *   When `string`, works like passing `(node) => node.type === test`.
60 +
 *   *   When `function` checks if function passed the node is true.
61 +
 *   *   When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
62 +
 *   *   When `array`, checks any one of the subtests pass.
63 +
 * @param index
64 +
 *   Position of `node` in `parent`, must be a number if `parent` is also given.
65 +
 * @param parent
66 +
 *   Parent of `node`, must be given if `index` is also given.
67 +
 * @param context
68 +
 *   Context object to invoke `test` with, optional
69 +
 * @returns
70 +
 *   Whether test passed and `node` is a `Node` (object with `type` set to
71 +
 *   non-empty `string`).
72 +
 */
51 73
export const is =
52 74
  /**
53 -
   * Check if a node passes a test.
54 -
   * When a `parent` node is known the `index` of node should also be given.
55 -
   *
56 75
   * @type {(
57 -
   *   (<T extends Node>(node: unknown, test: T['type']|Partial<T>|TestFunctionPredicate<T>|Array.<T['type']|Partial<T>|TestFunctionPredicate<T>>, index?: number|null|undefined, parent?: Parent|null|undefined, context?: unknown) => node is T) &
58 -
   *   ((node?: unknown, test?: Test, index?: number|null|undefined, parent?: Parent|null|undefined, context?: unknown) => boolean)
76 +
   *   (<ExplicitNode extends Node>(node: unknown, test: ExplicitNode['type']|Partial<ExplicitNode>|TestFunctionPredicate<ExplicitNode>|Array.<ExplicitNode['type']|Partial<ExplicitNode>|TestFunctionPredicate<ExplicitNode>>, index: number, parent: Parent, context?: unknown) => node is ExplicitNode) &
77 +
   *   (<ExplicitNode extends Node>(node: unknown, test: ExplicitNode['type']|Partial<ExplicitNode>|TestFunctionPredicate<ExplicitNode>|Array.<ExplicitNode['type']|Partial<ExplicitNode>|TestFunctionPredicate<ExplicitNode>>, index?: null|undefined, parent?: null|undefined, context?: unknown) => node is ExplicitNode) &
78 +
   *   ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &
79 +
   *   ((node?: unknown, test?: Test, index?: null|undefined, parent?: null|undefined, context?: unknown) => boolean)
59 80
   * )}
60 81
   */
61 82
  (
62 83
    /**
63 -
     * Check if a node passes a test.
64 -
     * When a `parent` node is known the `index` of node should also be given.
65 -
     *
66 -
     * @param {unknown} [node] Node to check
84 +
     * @param {unknown} [node]
67 85
     * @param {Test} [test]
68 -
     * When nullish, checks if `node` is a `Node`.
69 -
     * When `string`, works like passing `function (node) {return node.type === test}`.
70 -
     * When `function` checks if function passed the node is true.
71 -
     * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
72 -
     * When `array`, checks any one of the subtests pass.
73 -
     * @param {number|null|undefined} [index] Position of `node` in `parent`
74 -
     * @param {Parent|null|undefined} [parent] Parent of `node`
75 -
     * @param {unknown} [context] Context object to invoke `test` with
76 -
     * @returns {boolean} Whether test passed and `node` is a `Node` (object with `type` set to non-empty `string`).
86 +
     * @param {number|null|undefined} [index]
87 +
     * @param {Parent|null|undefined} [parent]
88 +
     * @param {unknown} [context]
89 +
     * @returns {boolean}
77 90
     */
78 91
    // eslint-disable-next-line max-params
79 92
    function is(node, test, index, parent, context) {
@@ -114,7 +127,7 @@
Loading
114 127
export const convert =
115 128
  /**
116 129
   * @type {(
117 -
   *   (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
130 +
   *   (<ExplicitNode extends Node>(test: ExplicitNode['type']|Partial<ExplicitNode>|TestFunctionPredicate<ExplicitNode>) => AssertPredicate<ExplicitNode>) &
118 131
   *   ((test?: Test) => AssertAnything)
119 132
   * )}
120 133
   */
Files Coverage
index.js 100.00%
Project Totals (1 files) 100.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading