unist-util-select
Advanced tools
Comparing version 1.5.0 to 2.0.0
50
index.js
@@ -1,40 +0,20 @@ | ||
'use strict'; | ||
'use strict' | ||
var parseSelector = require('./lib/selector'), | ||
matchSelector = require('./lib/select'); | ||
exports.matches = matches | ||
exports.selectAll = selectAll | ||
exports.select = select | ||
var debug = require('debug')('unist-util-select'); | ||
var any = require('./lib/any') | ||
var parse = require('./lib/parse') | ||
function matches(selector, node) { | ||
return Boolean(any(parse(selector), node, {one: true, shallow: true})[0]) | ||
} | ||
var select = function select (ast, selector) { | ||
if (arguments.length == 1) { | ||
return select.bind(this, ast); | ||
} | ||
function select(selector, node) { | ||
return any(parse(selector), node, {one: true})[0] || null | ||
} | ||
debug('Selector: %j', selector); | ||
selector = parseSelector(selector); | ||
debug('AST: %s', | ||
JSON.stringify(selector, null, 2).replace(/(^|\n)/g, '\n ')); | ||
return selector ? matchSelector[selector.type](selector, ast) : []; | ||
}; | ||
select.one = function selectOne (ast, selector) { | ||
if (arguments.length == 1) { | ||
return selectOne.bind(this, ast); | ||
} | ||
var nodes = select(ast, selector); | ||
if (!nodes.length) { | ||
throw Error('Node not found by ' + JSON.stringify(selector)); | ||
} | ||
if (nodes.length > 1) { | ||
throw Error('Node matched by ' + JSON.stringify(selector) + ' is not unique'); | ||
} | ||
return nodes[0]; | ||
}; | ||
module.exports = select; | ||
function selectAll(selector, node) { | ||
return any(parse(selector), node, {}) | ||
} |
{ | ||
"name": "unist-util-select", | ||
"version": "1.5.0", | ||
"version": "2.0.0", | ||
"description": "Select unist nodes using css-like selectors", | ||
"author": "Eugene Sharygin <eush77@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"lib/" | ||
], | ||
"homepage": "https://github.com/eush77/unist-util-select", | ||
"repository": "eush77/unist-util-select", | ||
"bugs": { | ||
"url": "https://github.com/eush77/unist-util-select/issues" | ||
}, | ||
"keywords": [ | ||
@@ -42,11 +29,62 @@ "child", | ||
], | ||
"repository": "syntax-tree/unist-util-select", | ||
"bugs": "https://github.com/syntax-tree/unist-util-select/issues", | ||
"author": "Eugene Sharygin <eush77@gmail.com>", | ||
"contributors": [ | ||
"Eugene Sharygin <eush77@gmail.com>", | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
"files": [ | ||
"index.js", | ||
"lib/" | ||
], | ||
"dependencies": { | ||
"css-selector-parser": "^1.1.0", | ||
"debug": "^2.2.0", | ||
"nth-check": "^1.0.1" | ||
"debug": "^3.1.0", | ||
"not": "^0.1.0", | ||
"nth-check": "^1.0.1", | ||
"unist-util-is": "^2.1.2", | ||
"zwitch": "^1.0.3" | ||
}, | ||
"devDependencies": { | ||
"nyc": "^13.1.0", | ||
"prettier": "^1.15.1", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.2.0", | ||
"unist-builder": "^1.0.1" | ||
"unist-builder": "^1.0.3", | ||
"xo": "^0.23.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test/index.js", | ||
"test": "npm run format && npm run test-coverage" | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
"lines": 100, | ||
"functions": 100, | ||
"branches": 100 | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"esnext": false, | ||
"rules": { | ||
"max-params": "off" | ||
} | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
31864
12
604
194
6
7
1
1
3
+ Addednot@^0.1.0
+ Addedunist-util-is@^2.1.2
+ Addedzwitch@^1.0.3
+ Addeddebug@3.2.7(transitive)
+ Addedms@2.1.3(transitive)
+ Addednot@0.1.0(transitive)
+ Addedunist-util-is@2.1.3(transitive)
+ Addedzwitch@1.0.5(transitive)
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)
Updateddebug@^3.1.0