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

mdast-util-definitions

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-definitions - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

license

32

index.js

@@ -1,12 +0,12 @@

'use strict';
'use strict'
var visit = require('unist-util-visit');
var visit = require('unist-util-visit')
module.exports = getDefinitionFactory;
module.exports = getDefinitionFactory
var own = {}.hasOwnProperty;
var own = {}.hasOwnProperty
/* Get a definition in `node` by `identifier`. */
function getDefinitionFactory(node, options) {
return getterFactory(gather(node, options));
return getterFactory(gather(node, options))
}

@@ -16,16 +16,16 @@

function gather(node, options) {
var cache = {};
var cache = {}
if (!node || !node.type) {
throw new Error('mdast-util-definitions expected node');
throw new Error('mdast-util-definitions expected node')
}
visit(node, 'definition', options && options.commonmark ? commonmark : normal);
visit(node, 'definition', options && options.commonmark ? commonmark : normal)
return cache;
return cache
function commonmark(definition) {
var id = normalise(definition.identifier);
var id = normalise(definition.identifier)
if (!own.call(cache, id)) {
cache[id] = definition;
cache[id] = definition
}

@@ -35,3 +35,3 @@ }

function normal(definition) {
cache[normalise(definition.identifier)] = definition;
cache[normalise(definition.identifier)] = definition
}

@@ -42,8 +42,8 @@ }

function getterFactory(cache) {
return getter;
return getter
/* Get a node from the bound definition-cache. */
function getter(identifier) {
var id = identifier && normalise(identifier);
return id && own.call(cache, id) ? cache[id] : null;
var id = identifier && normalise(identifier)
return id && own.call(cache, id) ? cache[id] : null
}

@@ -53,3 +53,3 @@ }

function normalise(identifier) {
return identifier.toUpperCase();
return identifier.toUpperCase()
}
{
"name": "mdast-util-definitions",
"version": "1.2.2",
"version": "1.2.3",
"description": "Find definition nodes in mdast nodes",

@@ -15,6 +15,3 @@ "license": "MIT",

],
"dependencies": {
"unist-util-visit": "^1.0.0"
},
"repository": "https://github.com/syntax-tree/mdast-util-definitions",
"repository": "syntax-tree/mdast-util-definitions",
"bugs": "https://github.com/syntax-tree/mdast-util-definitions/issues",

@@ -28,24 +25,41 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

],
"dependencies": {
"unist-util-visit": "^1.0.0"
},
"devDependencies": {
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"remark": "^7.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"browserify": "^16.0.0",
"nyc": "^12.0.0",
"prettier": "^1.14.2",
"remark": "^9.0.0",
"remark-cli": "^5.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.0.0",
"xo": "^0.18.2"
"tinyify": "^2.4.3",
"xo": "^0.22.0"
},
"scripts": {
"build-md": "remark . --quiet --frail --output",
"build-bundle": "browserify index.js --no-builtins -s mdastUtilDefinitions > mdast-util-definitions.js",
"build-mangle": "esmangle mdast-util-definitions.js > mdast-util-definitions.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test.js",
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"build-bundle": "browserify . -s mdastUtilDefinitions > mdast-util-definitions.js",
"build-mangle": "browserify . -s mdastUtilDefinitions -p tinyify > mdast-util-definitions.min.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"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"space": true,
"prettier": true,
"esnext": false,

@@ -52,0 +66,0 @@ "ignore": [

@@ -17,14 +17,14 @@ # mdast-util-definitions [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]

```js
var remark = require('remark');
var definitions = require('mdast-util-definitions');
var remark = require('remark')
var definitions = require('mdast-util-definitions')
var ast = remark().parse('[example]: http://example.com "Example"');
var ast = remark().parse('[example]: http://example.com "Example"')
var definition = definitions(ast);
var definition = definitions(ast)
definition('example');
// {type: 'definition', 'title': 'Example', ...}
definition('example')
// => {type: 'definition', 'title': 'Example', ...}
definition('foo');
// null
definition('foo')
// => null
```

@@ -58,2 +58,10 @@

## Contribute
See [`contributing.md` in `syntax-tree/mdast`][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

@@ -77,3 +85,3 @@

[license]: LICENSE
[license]: license

@@ -89,1 +97,5 @@ [author]: http://wooorm.com

[definition]: #definitionidentifier
[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md
[coc]: https://github.com/syntax-tree/mdast/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