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

unist-util-position

Package Overview
Dependencies
Maintainers
1
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.0 to 3.0.1

30

index.js

@@ -1,23 +0,25 @@

'use strict';
'use strict'
/* Expose. */
var position = exports;
var position = exports
position.start = positionFactory('start');
position.end = positionFactory('end');
position.start = factory('start')
position.end = factory('end')
/* Factory to get a position at `type`. */
function positionFactory(type) {
return pos;
/* Factory to get a `type` point in the positional info of a node. */
function factory(type) {
point.displayName = type
/* Get a position in `node` at a bound `type`. */
function pos(node) {
var pos = (node && node.position && node.position[type]) || {};
return point
/* Get a point in `node.position` at a bound `type`. */
function point(node) {
var point = (node && node.position && node.position[type]) || {}
return {
line: pos.line || null,
column: pos.column || null,
offset: isNaN(pos.offset) ? null : pos.offset
};
line: point.line || null,
column: point.column || null,
offset: isNaN(point.offset) ? null : point.offset
}
}
}
{
"name": "unist-util-position",
"version": "3.0.0",
"version": "3.0.1",
"description": "Utility to get the position of unist nodes",

@@ -10,7 +10,8 @@ "license": "MIT",

"position",
"point",
"util",
"utility"
],
"repository": "https://github.com/wooorm/unist-util-position",
"bugs": "https://github.com/wooorm/unist-util-position/issues",
"repository": "syntax-tree/unist-util-position",
"bugs": "https://github.com/syntax-tree/unist-util-position/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

@@ -25,20 +26,19 @@ "contributors": [

"devDependencies": {
"browserify": "^13.0.0",
"browserify": "^16.0.0",
"esmangle": "^1.0.0",
"nyc": "^9.0.1",
"remark": "^6.2.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"nyc": "^11.0.0",
"prettier": "^1.12.1",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.4.0",
"xo": "^0.17.1"
"xo": "^0.20.0"
},
"scripts": {
"build-md": "remark . --quiet --frail --output",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify index.js --no-builtins -s unistUtilPosition > unist-util-position.js",
"build-mangle": "esmangle unist-util-position.js > unist-util-position.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
"test": "npm run format && npm run build && npm run test-coverage"
},

@@ -51,4 +51,18 @@ "nyc": {

},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,
"rules": {
"guard-for-in": "off",
"no-var": "off",
"prefer-arrow-callback": "off"
},
"ignores": [

@@ -59,4 +73,6 @@ "unist-util-position.js"

"remarkConfig": {
"presets": "wooorm"
"plugins": [
"preset-wooorm"
]
}
}
# unist-util-position [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]
[**unist**][unist] utility to get the position of nodes.
[**unist**][unist] utility to get the positional info of nodes.

@@ -16,17 +16,12 @@ ## Installation

```js
var remark = require('remark');
var position = require('unist-util-position');
var remark = require('remark')
var position = require('unist-util-position')
var tree = remark().parse([
'# foo',
'',
'* bar',
''
].join('\n'));
var tree = remark().parse(['# foo', '', '* bar', ''].join('\n'))
position.start(tree); //=> {line: 1, column: 1}
position.end(tree); //=> {line: 4, column: 1}
position.start(tree) // => {line: 1, column: 1}
position.end(tree) // => {line: 4, column: 1}
position.start(); //=> {line: null, column: null}
position.end(); //=> {line: null, column: null}
position.start() // => {line: null, column: null}
position.end() // => {line: null, column: null}
```

@@ -40,3 +35,3 @@

Get the start or end position, respectively, of `node`.
Get the start or end points in the positional info of `node`.

@@ -49,5 +44,13 @@ ###### Parameters

[`Position`][position] — Filled with `line` (nullable `uint32 >= 1`),
[`Point`][point] — Filled with `line` (nullable `uint32 >= 1`),
`column` (nullable `uint32 >= 1`), `offset` (nullable `uint32 >= 0`).
## Contribute
See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get
started.
This organisation has a [Code of Conduct][coc]. By interacting with this
repository, organisation, or community you agree to abide by its terms.
## License

@@ -59,9 +62,9 @@

[build-badge]: https://img.shields.io/travis/wooorm/unist-util-position.svg
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-position.svg
[build-status]: https://travis-ci.org/wooorm/unist-util-position
[build-status]: https://travis-ci.org/syntax-tree/unist-util-position
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/unist-util-position.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-position.svg
[coverage-status]: https://codecov.io/github/wooorm/unist-util-position
[coverage-status]: https://codecov.io/github/syntax-tree/unist-util-position

@@ -74,6 +77,10 @@ [license]: LICENSE

[unist]: https://github.com/wooorm/unist
[unist]: https://github.com/syntax-tree/unist
[node]: https://github.com/wooorm/unist#node
[node]: https://github.com/syntax-tree/unist#node
[position]: https://github.com/wooorm/unist#position
[point]: https://github.com/syntax-tree/unist#point
[contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md
[coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md
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