syntax-tree / unist-util-position

Compare 7924cd7 ... +23 ... e2b6fde

Coverage Reach
index.js

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 10 files from the diff.
Other files ignored by Codecov

@@ -1,22 +1,53 @@
Loading
1 -
'use strict'
1 +
/**
2 +
 * @typedef {import('unist').Position} Position
3 +
 * @typedef {import('unist').Point} Point
4 +
 *
5 +
 * @typedef {Partial<Point>} PointLike
6 +
 *
7 +
 * @typedef {Object} PositionLike
8 +
 * @property {PointLike} [start]
9 +
 * @property {PointLike} [end]
10 +
 *
11 +
 * @typedef {Object} NodeLike
12 +
 * @property {PositionLike} [position]
13 +
 */
2 14
3 -
var position = exports
15 +
export const pointStart = point('start')
16 +
export const pointEnd = point('end')
4 17
5 -
position.start = factory('start')
6 -
position.end = factory('end')
7 -
8 -
function factory(type) {
9 -
  point.displayName = type
18 +
/**
19 +
 * Get the positional info of `node`.
20 +
 *
21 +
 * @param {NodeLike} [node]
22 +
 * @returns {Position}
23 +
 */
24 +
export function position(node) {
25 +
  return {start: pointStart(node), end: pointEnd(node)}
26 +
}
10 27
28 +
/**
29 +
 * Get the positional info of `node`.
30 +
 *
31 +
 * @param {'start'|'end'} type
32 +
 */
33 +
function point(type) {
11 34
  return point
12 35
36 +
  /**
37 +
   * Get the positional info of `node`.
38 +
   *
39 +
   * @param {NodeLike} [node]
40 +
   * @returns {Point}
41 +
   */
13 42
  function point(node) {
14 -
    var point = (node && node.position && node.position[type]) || {}
43 +
    /** @type {Point} */
44 +
    // @ts-expect-error looks like a point
45 +
    const point = (node && node.position && node.position[type]) || {}
15 46
16 47
    return {
17 48
      line: point.line || null,
18 49
      column: point.column || null,
19 -
      offset: isNaN(point.offset) ? null : point.offset
50 +
      offset: point.offset > -1 ? point.offset : null
20 51
    }
21 52
  }
22 53
}

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.

25 Commits

Hiding 1 contexual commits
Hiding 2 contexual commits
-2
-2
+1 Files
+55
+55
Hiding 4 contexual commits
-1 Files
-8
-8
Hiding 1 contexual commits
Hiding 1 contexual commits
-2
-2
Hiding 1 contexual commits Hiding 4 contexual commits
+3
+3
Files Coverage
index.js 100.00%
Project Totals (1 files) 100.00%
Loading