Socket
Socket
Sign inDemoInstall

vfile-sort

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

49

index.js

@@ -5,4 +5,4 @@ /**

* @license MIT
* @module vfile:sort
* @fileoverview Sort VFile messages by line/column.
* @module vfile-sort
* @fileoverview Sort vfile messages by line/column.
*/

@@ -12,40 +12,19 @@

/**
* Compare a single property.
*
* @param {VFileMessage} a - Original.
* @param {VFileMessage} b - Comparison.
* @param {string} property - Property to compare.
* @return {number}
*/
function check(a, b, property) {
return (a[property] || 0) - (b[property] || 0);
/* Expose. */
module.exports = sort;
/* Sort all `file`s messages by line/column. */
function sort(file) {
file.messages.sort(comparator);
return file;
}
/**
* Comparator.
*
* @param {VFileMessage} a - Original.
* @param {VFileMessage} b - Comparison.
* @return {number}
*/
/* Comparator. */
function comparator(a, b) {
return check(a, b, 'line') || check(a, b, 'column') || -1;
return check(a, b, 'line') || check(a, b, 'column') || -1;
}
/**
* Sort all `file`s messages by line/column.
*
* @param {VFile} file - Virtual file.
* @return {VFile} - `file`.
*/
function sort(file) {
file.messages.sort(comparator);
return file;
/* Compare a single property. */
function check(a, b, property) {
return (a[property] || 0) - (b[property] || 0);
}
/*
* Expose.
*/
module.exports = sort;
{
"name": "vfile-sort",
"version": "1.0.0",
"description": "Sort VFile messages by line/column",
"version": "2.0.0",
"description": "Sort vfile messages by line/column",
"license": "MIT",
"keywords": [
"vfile",
"node",
"sort",
"message",
"warning",
"error",
"retext",
"mdast"
"message"
],
"repository": "wooorm/vfile-sort",
"author": "Titus Wormer <tituswormer@gmail.com>",
"repository": "https://github.com/wooorm/vfile-sort",
"bugs": "https://github.com/wooorm/vfile-sort/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
],
"files": [
"index.js"
],
"dependencies": {},
"devDependencies": {
"browserify": "^11.0.0",
"eslint": "^1.0.0",
"esmangle": "^1.0.0",
"istanbul": "^0.3.0",
"jscs": "^2.0.0",
"jscs-jsdoc": "^1.0.0",
"mdast": "^1.0.0",
"mdast-github": "^0.3.0",
"mdast-lint": "^0.4.0",
"mdast-yaml-config": "^1.0.0",
"mocha": "^2.0.0",
"vfile": "^1.0.0"
"browserify": "^13.0.1",
"esmangle": "^1.0.1",
"nyc": "^8.1.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"tape": "^4.0.0",
"vfile": "^2.0.0",
"xo": "^0.16.0"
},
"scripts": {
"test-api": "mocha --check-leaks test.js",
"test-coverage": "istanbul cover _mocha -- test.js",
"test-travis": "npm run test-coverage",
"test": "npm run test-api",
"lint-api": "eslint .",
"lint-style": "jscs --reporter inline .",
"lint": "npm run lint-api && npm run lint-style",
"make": "npm run lint && npm run test-coverage",
"bundle": "browserify index.js --no-builtins -s vfileSort > vfile-sort.js",
"postbundle": "esmangle vfile-sort.js > vfile-sort.min.js",
"build-md": "mdast . --quiet",
"build": "npm run bundle && npm run build-md"
"build-md": "remark . --quiet --frail",
"build-bundle": "browserify index.js --bare -s vfileSort > vfile-sort.js",
"build-mangle": "esmangle vfile-sort.js > vfile-sort.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"ignores": [
"vfile-sort.js"
]
},
"remarkConfig": {
"output": true,
"presets": "wooorm"
}
}

@@ -1,8 +0,8 @@

# vfile-sort [![Build Status](https://img.shields.io/travis/wooorm/vfile-sort.svg)](https://travis-ci.org/wooorm/vfile-sort) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/vfile-sort.svg)](https://codecov.io/github/wooorm/vfile-sort)
# vfile-sort [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
Sorts [`VFile`](https://github.com/wooorm/vfile) [`messages`](https://github.com/wooorm/vfile#vfilemessages).
Sort [vfile][] messages by line/column.
## Installation
[npm](https://docs.npmjs.com/cli/install):
[npm][]:

@@ -13,8 +13,2 @@ ```bash

**vfile-sort** is also available for [bower](http://bower.io/#install-packages),
[component](https://github.com/componentjs/component), and
[duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and globals
module, [uncompressed](vfile-sort.js) and
[compressed](vfile-sort.min.js).
## Usage

@@ -28,21 +22,9 @@

file.warn('Error!', {
'line': 3,
'column': 1
});
file.message('Error!', {line: 3, column: 1});
file.message('Another!', {line: 2, column: 2});
file.warn('Another!', {
'line': 2,
'column': 2
});
sort(file);
console.log(file.messages.map(String));
/*
* [
* '2:2: Another!',
* '3:1: Error!'
* ]
*/
//=> ['2:2: Another!', '3:1: Error!']
```

@@ -52,9 +34,26 @@

### sort(vfile)
### `sort(file)`
Sorts [`messages`](https://github.com/wooorm/vfile#vfilemessages) in the given
[`VFile`](https://github.com/wooorm/vfile).
Sort messages in the given [vfile][].
## License
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[travis-badge]: https://img.shields.io/travis/wooorm/vfile-sort.svg
[travis]: https://travis-ci.org/wooorm/vfile-sort
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/vfile-sort.svg
[codecov]: https://codecov.io/github/wooorm/vfile-sort
[npm]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[author]: http://wooorm.com
[vfile]: https://github.com/wooorm/vfile
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc