Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unist-util-position

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-position - npm Package Compare versions

Comparing version 3.0.4 to 3.1.0

13

index.js
'use strict'
var position = exports
var start = factory('start')
var end = factory('end')
position.start = factory('start')
position.end = factory('end')
module.exports = position
position.start = start
position.end = end
function position(node) {
return {start: start(node), end: end(node)}
}
function factory(type) {

@@ -9,0 +16,0 @@ point.displayName = type

{
"name": "unist-util-position",
"version": "3.0.4",
"description": "Utility to get the position of unist nodes",
"version": "3.1.0",
"description": "unist utility to get the position of a node",
"license": "MIT",
"keywords": [
"unist",
"unist-util",
"util",
"utility",
"node",
"position",
"point",
"util",
"utility"
"point"
],

@@ -30,3 +31,3 @@ "repository": "syntax-tree/unist-util-position",

"browserify": "^16.0.0",
"nyc": "^14.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",

@@ -37,3 +38,3 @@ "remark-cli": "^7.0.0",

"tinyify": "^2.0.0",
"xo": "^0.25.0"
"xo": "^0.26.0"
},

@@ -40,0 +41,0 @@ "scripts": {

@@ -21,3 +21,3 @@ # unist-util-position

## Usage
## Use

@@ -30,29 +30,36 @@ ```js

position.start(tree) // => {line: 1, column: 1}
position.end(tree) // => {line: 4, column: 1}
console.log(position(tree))
console.log(position.start(tree))
console.log(position.end(tree))
position.start() // => {line: null, column: null}
position.end() // => {line: null, column: null}
console.log(position())
console.log(position.start())
console.log(position.end())
```
## API
Yields:
### `position.start([node])`
```js
{start: {line: 1, column: 1, offset: 0}, end: {line: 4, column: 1, offset: 13}}
{line: 1, column: 1, offset: 0}
{line: 4, column: 1, offset: 13}
{start: {line: null, column: null, offset: null}, end: {line: null, column: null, offset: null}}
{line: null, column: null, offset: null}
{line: null, column: null, offset: null}
```
### `position.end([node])`
## API
Get the start or end points in the positional info of `node`.
### `position(node?)`
###### Parameters
Get the positional info of `node` ([`Node?`][node]).
Returns [`Position`][position].
* `node` ([`Node?`][node]) — Node to check.
### `position.start(node?)`
###### Returns
### `position.end(node?)`
[`Point`][point] — Filled with `line` (nullable `uint32 >= 1`),
`column` (nullable `uint32 >= 1`), `offset` (nullable `uint32 >= 0`).
Get the start or end points in the positional info of `node` ([`Node?`][node]).
Returns [`Point`][point].
Note that in [unist][], `line` and `column` are 1-indexed integers and
`offset` is a 0-indexed integer.
## Contribute

@@ -64,4 +71,4 @@

This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

@@ -97,3 +104,3 @@

[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg

@@ -118,2 +125,4 @@ [chat]: https://spectrum.chat/unified/syntax-tree

[position]: https://github.com/syntax-tree/unist#position
[point]: https://github.com/syntax-tree/unist#point
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc