syntax-tree / unist-util-stringify-position

Compare a7143fa ... +5 ... 8962290

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 13 files from the diff.

@@ -1,42 +1,66 @@
Loading
1 -
'use strict'
2 -
3 1
var own = {}.hasOwnProperty
4 2
5 -
module.exports = stringify
3 +
/**
4 +
 * @typedef {import('unist').Node} Node
5 +
 * @typedef {import('unist').Position} Position
6 +
 * @typedef {import('unist').Point} Point
7 +
 */
6 8
7 -
function stringify(value) {
9 +
/**
10 +
 * Stringify one point, a position (start and end points), or a node’s
11 +
 * positional information.
12 +
 *
13 +
 * @param {Node|Position|Point} [value]
14 +
 * @returns {string}
15 +
 */
16 +
export function stringifyPosition(value) {
8 17
  // Nothing.
9 18
  if (!value || typeof value !== 'object') {
10 19
    return ''
11 20
  }
12 21
13 22
  // Node.
14 23
  if (own.call(value, 'position') || own.call(value, 'type')) {
24 +
    // @ts-ignore looks like a node.
15 25
    return position(value.position)
16 26
  }
17 27
18 28
  // Position.
19 29
  if (own.call(value, 'start') || own.call(value, 'end')) {
30 +
    // @ts-ignore looks like a position.
20 31
    return position(value)
21 32
  }
22 33
23 34
  // Point.
24 35
  if (own.call(value, 'line') || own.call(value, 'column')) {
36 +
    // @ts-ignore looks like a point.
25 37
    return point(value)
26 38
  }
27 39
28 40
  // ?
29 41
  return ''
30 42
}
31 43
44 +
/**
45 +
 * @param {Point} point
46 +
 * @returns {string}
47 +
 */
32 48
function point(point) {
33 49
  return index(point && point.line) + ':' + index(point && point.column)
34 50
}
35 51
52 +
/**
53 +
 * @param {Position} pos
54 +
 * @returns {string}
55 +
 */
36 56
function position(pos) {
37 57
  return point(pos && pos.start) + '-' + point(pos && pos.end)
38 58
}
39 59
60 +
/**
61 +
 * @param {number} value
62 +
 * @returns {number}
63 +
 */
40 64
function index(value) {
41 65
  return value && typeof value === 'number' ? value : 1
42 66
}

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.
Files Coverage
index.js 100.00%
Project Totals (1 files) 100.00%
Loading