Skip to content

Commit

Permalink
feat: PositionalInfo
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Mar 12, 2024
1 parent 14b136b commit 4ce8664
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/__tests__/positional-info.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @file Type Tests - PositionalInfo
* @module unist-util-types/tests/unit-d/PositionalInfo
*/

import type * as mdast from 'mdast'
import type TestSubject from '../positional-info'

describe('unit-d:PositionalInfo', () => {
it('should equal Pick<T, "position">', () => {
// Arrange
type T = mdast.Code

// Expect
expectTypeOf<TestSubject<T>>().toEqualTypeOf<Pick<T, 'position'>>()
})
})
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
export type { default as Decrement } from './decrement'
export type { default as InclusiveDescendant } from './descendant-inclusive'
export type { default as Increment } from './increment'
export type { default as PositionalInfo } from './positional-info'
export type { default as Uint } from './uint'
20 changes: 20 additions & 0 deletions src/positional-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @file PositionalInfo
* @module unist-util-types/PositionalInfo
*/

import type { Node } from 'unist'

/**
* Object containing the [*positional information*][1] of [node][2] `T`.
*
* [1]: https://github.com/syntax-tree/unist#positional-information
* [2]: https://github.com/syntax-tree/unist#node
*
* @see {@linkcode Node}
*
* @template {Node} [T=Node] - Node to get positional information from
*/
type PositionalInfo<T extends Node = Node> = Pick<T, 'position'>

export type { PositionalInfo as default }

0 comments on commit 4ce8664

Please sign in to comment.