From 766c63c1caf71a68ea5df8bc501756e0a5c05bb4 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 5 Jun 2022 16:14:15 +0200 Subject: [PATCH 01/13] Update dev-dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d23327..374887c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "tape": "^5.0.0", "type-coverage": "^2.0.0", "typescript": "^4.0.0", - "xo": "^0.48.0" + "xo": "^0.49.0" }, "scripts": { "prepack": "npm run build && npm run format", From dcf4b52926ed57388ff3375573e17a8486a1b291 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 5 Jun 2022 16:17:13 +0200 Subject: [PATCH 02/13] Refactor some docs --- readme.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 5fe2e1d..e9987d8 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ [![Backers][backers-badge]][collective] [![Chat][chat-badge]][chat] -**[unist][]** utility to pretty print the positional information of a node. +[unist][] utility to pretty print the positional info of a node. ## Contents @@ -39,7 +39,7 @@ For example, when throwing errors or warning messages about something. ## Install This package is [ESM only][esm]. -In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: +In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]: ```sh npm install unist-util-stringify-position @@ -83,7 +83,7 @@ There is no default export. ### `stringifyPosition(node|position|point)` -Stringify a [point][], [position][], or a [node][]. +Stringify a point, position, or node. ###### Parameters @@ -96,22 +96,23 @@ Stringify a [point][], [position][], or a [node][]. ###### Returns -`string?` — A range `ls:cs-le:ce` (when given `node` or `position`) or a point -`l:c` (when given `point`), where `l` stands for line, `c` for column, `s` for -`start`, and `e` for end. +Pretty printed positional info of a node (`string`). +In the format of a range `ls:cs-le:ce` (when given `node` or `position`) or a +point `l:c` (when given `point`), where `l` stands for line, `c` for column, `s` +for `start`, and `e` for end. An empty string (`''`) is returned if the given value is neither `node`, `position`, nor `point`. ## Types This package is fully typed with [TypeScript][]. -There are no additional types exported. +It exports no additional types. ## Compatibility Projects maintained by the unified collective are compatible with all maintained versions of Node.js. -As of now, that is Node.js 12.20+, 14.14+, and 16.0+. +As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed. ## Security From 55fe3ee4619614ddf7e8e1abb6e0bbe022e82bfc Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:03:11 +0100 Subject: [PATCH 03/13] Update dev-dependencies --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 374887c..25f5d94 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,13 @@ "@types/tape": "^4.0.0", "c8": "^7.0.0", "prettier": "^2.0.0", - "remark-cli": "^10.0.0", + "remark-cli": "^11.0.0", "remark-preset-wooorm": "^9.0.0", "rimraf": "^3.0.0", "tape": "^5.0.0", "type-coverage": "^2.0.0", "typescript": "^4.0.0", - "xo": "^0.49.0" + "xo": "^0.53.0" }, "scripts": { "prepack": "npm run build && npm run format", From 7020fea1aba888b1a47806ac73fc6551b4cb2779 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:03:16 +0100 Subject: [PATCH 04/13] Fix types --- index.js | 24 +++++++++++++++++++----- test.js | 17 +---------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 848978f..20ce0d1 100644 --- a/index.js +++ b/index.js @@ -2,14 +2,28 @@ * @typedef {import('unist').Point} Point * @typedef {import('unist').Node} Node * @typedef {import('unist').Position} Position - * @typedef {object & {type: string, position?: Position|undefined}} NodeLike + */ + +/** + * @typedef NodeLike + * @property {string} type + * @property {PositionLike | null | undefined} [position] + * + * @typedef PositionLike + * @property {PointLike | null | undefined} [start] + * @property {PointLike | null | undefined} [end] + * + * @typedef PointLike + * @property {number | null | undefined} [line] + * @property {number | null | undefined} [column] + * @property {number | null | undefined} [offset] */ /** * Stringify one point, a position (start and end points), or a node’s * positional information. * - * @param {Node|NodeLike|Position|Point|null} [value] + * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] * @returns {string} */ export function stringifyPosition(value) { @@ -38,7 +52,7 @@ export function stringifyPosition(value) { } /** - * @param {Point|undefined} point + * @param {Point | PointLike | null | undefined} point * @returns {string} */ function point(point) { @@ -46,7 +60,7 @@ function point(point) { } /** - * @param {Position|undefined} pos + * @param {Position | PositionLike | null | undefined} pos * @returns {string} */ function position(pos) { @@ -54,7 +68,7 @@ function position(pos) { } /** - * @param {number|undefined} value + * @param {number | null | undefined} value * @returns {number} */ function index(value) { diff --git a/test.js b/test.js index 921e87c..d850a64 100644 --- a/test.js +++ b/test.js @@ -24,12 +24,7 @@ test('stringifyPosition', function (t) { '', 'should return empty `string` with `number`' ) - t.equal( - // @ts-expect-error runtime. - stringifyPosition({}), - '', - 'should return empty `string` with `{}`' - ) + t.equal(stringifyPosition({}), '', 'should return empty `string` with `{}`') t.equal( stringifyPosition({type: 'text'}), @@ -47,7 +42,6 @@ test('stringifyPosition', function (t) { t.equal( stringifyPosition({ type: 'text', - // @ts-expect-error runtime. position: {start: {}, end: {}} }), '1:1-1:1', @@ -58,9 +52,7 @@ test('stringifyPosition', function (t) { stringifyPosition({ type: 'text', position: { - // @ts-expect-error runtime. start: {line: null, column: null}, - // @ts-expect-error runtime. end: {line: null, column: null} } }), @@ -96,7 +88,6 @@ test('stringifyPosition', function (t) { ) t.equal( - // @ts-expect-error runtime. stringifyPosition({start: null, end: null}), '1:1-1:1', 'should return a range for a `position` without `point`s' @@ -110,7 +101,6 @@ test('stringifyPosition', function (t) { ) t.equal( - // @ts-expect-error runtime. stringifyPosition({start: {}, end: {}}), '1:1-1:1', 'should return range for `position` with invalid `point`s #1' @@ -118,9 +108,7 @@ test('stringifyPosition', function (t) { t.equal( stringifyPosition({ - // @ts-expect-error runtime. start: {line: null, column: null}, - // @ts-expect-error runtime. end: {line: null, column: null} }), '1:1-1:1', @@ -137,7 +125,6 @@ test('stringifyPosition', function (t) { ) t.equal( - // @ts-expect-error runtime. stringifyPosition({line: null, column: null}), '1:1', 'should return a point for a `point` without indices' @@ -151,14 +138,12 @@ test('stringifyPosition', function (t) { ) t.equal( - // @ts-expect-error runtime. stringifyPosition({line: 4}), '4:1', 'should return a point for a partially valid `point` #1' ) t.equal( - // @ts-expect-error runtime. stringifyPosition({column: 12}), '1:12', 'should return a point for a partially valid `point` #1' From 908163ad2078bfe632690a87190c1514a0ea539d Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:03:25 +0100 Subject: [PATCH 05/13] Update Actions --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe284ad..89dc06c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,15 +7,15 @@ jobs: name: ${{matrix.node}} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: dcodeIO/setup-node-nvm@master + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{matrix.node}} - run: npm install - run: npm test - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 strategy: matrix: node: - - lts/erbium + - lts/fermium - node From 9054f2debe4205cbae1c84d5d54eed8b4db60acf Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:03:56 +0100 Subject: [PATCH 06/13] Update `tsconfig.json` --- package.json | 6 +++--- tsconfig.json | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 25f5d94..cc75df8 100644 --- a/package.json +++ b/package.json @@ -51,10 +51,10 @@ }, "scripts": { "prepack": "npm run build && npm run format", - "build": "rimraf \"*.d.ts\" && tsc && type-coverage", + "build": "tsc --build --clean && tsc --build && type-coverage", "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", - "test-api": "node test.js", - "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", + "test-api": "node --conditions development test.js", + "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", "test": "npm run build && npm run format && npm run test-coverage" }, "prettier": { diff --git a/tsconfig.json b/tsconfig.json index e31adf8..ebe8889 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,17 @@ { - "include": ["*.js"], + "include": ["**/*.js"], + "exclude": ["coverage/", "node_modules/"], "compilerOptions": { - "target": "ES2020", - "lib": ["ES2020"], - "module": "ES2020", - "moduleResolution": "node", - "allowJs": true, "checkJs": true, "declaration": true, "emitDeclarationOnly": true, - "allowSyntheticDefaultImports": true, + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es2020"], + "module": "node16", + "newLine": "lf", "skipLibCheck": true, - "strict": true + "strict": true, + "target": "es2020" } } From 3b5aa323c02fd012ddc1238dc2ae8351247ec1be Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:04:37 +0100 Subject: [PATCH 07/13] Refactor to move implementation to `lib/` --- index.js | 77 +--------------------------------------------------- lib/index.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 78 insertions(+), 76 deletions(-) create mode 100644 lib/index.js diff --git a/index.js b/index.js index 20ce0d1..93163ea 100644 --- a/index.js +++ b/index.js @@ -1,76 +1 @@ -/** - * @typedef {import('unist').Point} Point - * @typedef {import('unist').Node} Node - * @typedef {import('unist').Position} Position - */ - -/** - * @typedef NodeLike - * @property {string} type - * @property {PositionLike | null | undefined} [position] - * - * @typedef PositionLike - * @property {PointLike | null | undefined} [start] - * @property {PointLike | null | undefined} [end] - * - * @typedef PointLike - * @property {number | null | undefined} [line] - * @property {number | null | undefined} [column] - * @property {number | null | undefined} [offset] - */ - -/** - * Stringify one point, a position (start and end points), or a node’s - * positional information. - * - * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] - * @returns {string} - */ -export function stringifyPosition(value) { - // Nothing. - if (!value || typeof value !== 'object') { - return '' - } - - // Node. - if ('position' in value || 'type' in value) { - return position(value.position) - } - - // Position. - if ('start' in value || 'end' in value) { - return position(value) - } - - // Point. - if ('line' in value || 'column' in value) { - return point(value) - } - - // ? - return '' -} - -/** - * @param {Point | PointLike | null | undefined} point - * @returns {string} - */ -function point(point) { - return index(point && point.line) + ':' + index(point && point.column) -} - -/** - * @param {Position | PositionLike | null | undefined} pos - * @returns {string} - */ -function position(pos) { - return point(pos && pos.start) + '-' + point(pos && pos.end) -} - -/** - * @param {number | null | undefined} value - * @returns {number} - */ -function index(value) { - return value && typeof value === 'number' ? value : 1 -} +export {stringifyPosition} from './lib/index.js' diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..20ce0d1 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,76 @@ +/** + * @typedef {import('unist').Point} Point + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Position} Position + */ + +/** + * @typedef NodeLike + * @property {string} type + * @property {PositionLike | null | undefined} [position] + * + * @typedef PositionLike + * @property {PointLike | null | undefined} [start] + * @property {PointLike | null | undefined} [end] + * + * @typedef PointLike + * @property {number | null | undefined} [line] + * @property {number | null | undefined} [column] + * @property {number | null | undefined} [offset] + */ + +/** + * Stringify one point, a position (start and end points), or a node’s + * positional information. + * + * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] + * @returns {string} + */ +export function stringifyPosition(value) { + // Nothing. + if (!value || typeof value !== 'object') { + return '' + } + + // Node. + if ('position' in value || 'type' in value) { + return position(value.position) + } + + // Position. + if ('start' in value || 'end' in value) { + return position(value) + } + + // Point. + if ('line' in value || 'column' in value) { + return point(value) + } + + // ? + return '' +} + +/** + * @param {Point | PointLike | null | undefined} point + * @returns {string} + */ +function point(point) { + return index(point && point.line) + ':' + index(point && point.column) +} + +/** + * @param {Position | PositionLike | null | undefined} pos + * @returns {string} + */ +function position(pos) { + return point(pos && pos.start) + '-' + point(pos && pos.end) +} + +/** + * @param {number | null | undefined} value + * @returns {number} + */ +function index(value) { + return value && typeof value === 'number' ? value : 1 +} diff --git a/package.json b/package.json index cc75df8..c48bdd9 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "main": "index.js", "types": "index.d.ts", "files": [ + "lib/", "index.d.ts", "index.js" ], From 474ed7b41d0576be8db58155fd6e937423334e1a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:06:06 +0100 Subject: [PATCH 08/13] Refactor code-style * Add more docs to JSDoc --- lib/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 20ce0d1..82c20b4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,6 @@ /** - * @typedef {import('unist').Point} Point * @typedef {import('unist').Node} Node + * @typedef {import('unist').Point} Point * @typedef {import('unist').Position} Position */ @@ -20,11 +20,13 @@ */ /** - * Stringify one point, a position (start and end points), or a node’s - * positional information. + * Serialize the positional info of a point, position (start and end points), + * or node. * * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] + * Node, position, or point. * @returns {string} + * Positional info. */ export function stringifyPosition(value) { // Nothing. From 9af09562460e7e3f492fe5516d6a2d7f1c473f3a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:06:16 +0100 Subject: [PATCH 09/13] Add `ignore-scripts` to `.npmrc` --- .npmrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmrc b/.npmrc index 43c97e7..9951b11 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ package-lock=false +ignore-scripts=true From 0964663484db703416cb4f18073a473e692abe16 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:07:00 +0100 Subject: [PATCH 10/13] Use Node test runner --- .github/workflows/main.yml | 2 +- package.json | 4 +-- test.js | 53 ++++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89dc06c..fb63387 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,5 +17,5 @@ jobs: strategy: matrix: node: - - lts/fermium + - lts/gallium - node diff --git a/package.json b/package.json index c48bdd9..f353978 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,11 @@ }, "devDependencies": { "@types/mdast": "^3.0.0", - "@types/tape": "^4.0.0", + "@types/node": "^18.0.0", "c8": "^7.0.0", "prettier": "^2.0.0", "remark-cli": "^11.0.0", "remark-preset-wooorm": "^9.0.0", - "rimraf": "^3.0.0", - "tape": "^5.0.0", "type-coverage": "^2.0.0", "typescript": "^4.0.0", "xo": "^0.53.0" diff --git a/test.js b/test.js index d850a64..591a6f9 100644 --- a/test.js +++ b/test.js @@ -1,45 +1,50 @@ -import test from 'tape' +import assert from 'node:assert/strict' +import test from 'node:test' import {stringifyPosition} from './index.js' -test('stringifyPosition', function (t) { - t.equal( +test('stringifyPosition', function () { + assert.equal( stringifyPosition(), '', 'should return empty `string` with `undefined`' ) - t.equal( + assert.equal( stringifyPosition(null), '', 'should return empty `string` with `null`' ) - t.equal( + assert.equal( // @ts-expect-error runtime. stringifyPosition('foo'), '', 'should return empty `string` with `string`' ) - t.equal( + assert.equal( // @ts-expect-error runtime. stringifyPosition(5), '', 'should return empty `string` with `number`' ) - t.equal(stringifyPosition({}), '', 'should return empty `string` with `{}`') + assert.equal( + stringifyPosition({}), + '', + 'should return empty `string` with `{}`' + ) - t.equal( + assert.equal( stringifyPosition({type: 'text'}), '1:1-1:1', 'should return a range for a `node` without `position`' ) - t.equal( + assert.equal( // @ts-expect-error runtime. stringifyPosition({type: 'text', position: 3}), '1:1-1:1', 'should return a range for `node` with invalid `position` #1' ) - t.equal( + assert.equal( stringifyPosition({ type: 'text', position: {start: {}, end: {}} @@ -48,7 +53,7 @@ test('stringifyPosition', function (t) { 'should return a range for `node` with invalid `position` #2' ) - t.equal( + assert.equal( stringifyPosition({ type: 'text', position: { @@ -60,7 +65,7 @@ test('stringifyPosition', function (t) { 'should return a range for `node` with invalid `position` #3' ) - t.equal( + assert.equal( stringifyPosition({ type: 'text', position: { @@ -72,7 +77,7 @@ test('stringifyPosition', function (t) { 'should return a range for `node` with valid `position` (types: literal object)' ) - t.equal( + assert.equal( stringifyPosition( /** @type {import('mdast').Root} */ ({ type: 'root', @@ -87,26 +92,26 @@ test('stringifyPosition', function (t) { 'should return a range for `node` with valid `position` (types: explicit instance of node)' ) - t.equal( + assert.equal( stringifyPosition({start: null, end: null}), '1:1-1:1', 'should return a range for a `position` without `point`s' ) - t.equal( + assert.equal( // @ts-expect-error runtime. stringifyPosition({start: 3, end: 6}), '1:1-1:1', 'should return a range for `position` with invalid `point`s #1' ) - t.equal( + assert.equal( stringifyPosition({start: {}, end: {}}), '1:1-1:1', 'should return range for `position` with invalid `point`s #1' ) - t.equal( + assert.equal( stringifyPosition({ start: {line: null, column: null}, end: {line: null, column: null} @@ -115,7 +120,7 @@ test('stringifyPosition', function (t) { 'should return range for `position` with invalid `point`s #3' ) - t.equal( + assert.equal( stringifyPosition({ start: {line: 2, column: 5}, end: {line: 2, column: 6} @@ -124,36 +129,34 @@ test('stringifyPosition', function (t) { 'should return range for `position` with valid `point`s' ) - t.equal( + assert.equal( stringifyPosition({line: null, column: null}), '1:1', 'should return a point for a `point` without indices' ) - t.equal( + assert.equal( // @ts-expect-error runtime. stringifyPosition({line: 'foo', column: 'bar'}), '1:1', 'should return a point for a `point` with invalid indices #1' ) - t.equal( + assert.equal( stringifyPosition({line: 4}), '4:1', 'should return a point for a partially valid `point` #1' ) - t.equal( + assert.equal( stringifyPosition({column: 12}), '1:12', 'should return a point for a partially valid `point` #1' ) - t.equal( + assert.equal( stringifyPosition({line: 5, column: 2}), '5:2', 'should return a point for a valid `point`' ) - - t.end() }) From 3fcfc0ed1bbbec441b042d8df55163bc2f7d4e15 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:07:16 +0100 Subject: [PATCH 11/13] Add tests for exposed identifiers --- test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test.js b/test.js index 591a6f9..9681c10 100644 --- a/test.js +++ b/test.js @@ -1,8 +1,15 @@ import assert from 'node:assert/strict' import test from 'node:test' import {stringifyPosition} from './index.js' +import * as mod from './index.js' test('stringifyPosition', function () { + assert.deepEqual( + Object.keys(mod).sort(), + ['stringifyPosition'], + 'should expose the public api' + ) + assert.equal( stringifyPosition(), '', From 8becab7934e9e1e6b8775e6d43d688cc4882d8e1 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:09:47 +0100 Subject: [PATCH 12/13] Add improved docs --- lib/index.js | 8 +++++++- readme.md | 18 +++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index 82c20b4..7474343 100644 --- a/lib/index.js +++ b/lib/index.js @@ -26,7 +26,13 @@ * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] * Node, position, or point. * @returns {string} - * Positional info. + * Pretty printed positional info of a node (`string`). + * + * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) + * or a point `l:c` (when given `point`), where `l` stands for line, `c` for + * column, `s` for `start`, and `e` for end. + * An empty string (`''`) is returned if the given value is neither `node`, + * `position`, nor `point`. */ export function stringifyPosition(value) { // Nothing. diff --git a/readme.md b/readme.md index e9987d8..323f960 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ For example, when throwing errors or warning messages about something. ## Install This package is [ESM only][esm]. -In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]: +In Node.js (version 14.14+ and 16.0+), install with [npm][]: ```sh npm install unist-util-stringify-position @@ -78,25 +78,27 @@ stringifyPosition({ ## API -This package exports the identifier `stringifyPosition`. +This package exports the identifier [`stringifyPosition`][stringifyposition]. There is no default export. ### `stringifyPosition(node|position|point)` -Stringify a point, position, or node. +Serialize the positional info of a point, position (start and end points), or +node. ###### Parameters * `node` ([`Node`][node]) - — node whose `'position'` property to stringify + — node whose `position` fields to serialize * `position` ([`Position`][position]) - — position whose `'start'` and `'end'` points to stringify + — position whose `start` and `end` points to serialize * `point` ([`Point`][point]) - — point whose `'line'` and `'column'` to stringify + — point whose `line` and `column` fields to serialize ###### Returns Pretty printed positional info of a node (`string`). + In the format of a range `ls:cs-le:ce` (when given `node` or `position`) or a point `l:c` (when given `point`), where `l` stands for line, `c` for column, `s` for `start`, and `e` for end. @@ -112,7 +114,7 @@ It exports no additional types. Projects maintained by the unified collective are compatible with all maintained versions of Node.js. -As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+. +As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed. ## Security @@ -197,3 +199,5 @@ abide by its terms. [position]: https://github.com/syntax-tree/unist#position [point]: https://github.com/syntax-tree/unist#point + +[stringifyposition]: #stringifypositionnodepositionpoint From e0cad5fc199831b457ce0efc1fab11dcdc097d11 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 23 Jan 2023 13:10:48 +0100 Subject: [PATCH 13/13] 3.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f353978..51e32c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unist-util-stringify-position", - "version": "3.0.2", + "version": "3.0.3", "description": "unist utility to serialize a node, position, or point as a human readable location", "license": "MIT", "keywords": [ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy