Socket
Socket
Sign inDemoInstall

mdast-util-phrasing

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-phrasing - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

lib/index.d.ts

7

index.d.ts

@@ -1,6 +0,1 @@

/**
* @type {AssertPredicatePhrasing}
*/
export const phrasing: AssertPredicatePhrasing
export type PhrasingContent = import('mdast').PhrasingContent
export type AssertPredicatePhrasing = import('unist-util-is').AssertPredicate<PhrasingContent>
export {phrasing} from './lib/index.js'

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

/**
* @typedef {import('mdast').PhrasingContent} PhrasingContent
* @typedef {import('unist-util-is').AssertPredicate<PhrasingContent>} AssertPredicatePhrasing
*/
import {convert} from 'unist-util-is'
/**
* @type {AssertPredicatePhrasing}
*/
// @ts-ignore hush, it’s fine!
export const phrasing = convert([
'break',
'delete',
'emphasis',
'footnote',
'footnoteReference',
'image',
'imageReference',
'inlineCode',
'link',
'linkReference',
'strong',
'text'
])
export {phrasing} from './lib/index.js'
{
"name": "mdast-util-phrasing",
"version": "3.0.0",
"version": "3.0.1",
"description": "mdast utility to check if a node is phrasing content",

@@ -31,2 +31,3 @@ "license": "MIT",

"files": [
"lib/",
"index.d.ts",

@@ -40,19 +41,17 @@ "index.js"

"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.53.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"

@@ -69,7 +68,3 @@ },

"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -76,0 +71,0 @@ "remarkConfig": {

@@ -11,11 +11,37 @@ # mdast-util-phrasing

Check if a [mdast][] [node][] is [phrasing content][phrasing].
[mdast][] utility to check if a node is phrasing content.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`phrasing(value)`](#phrasingvalue)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a tiny utility to check that a given [node][] is [phrasing
content][phrasing].
## When should I use this?
This utility is typically useful if you’re making other utilities.
It uses [`unist-util-is`][unist-util-is], which you can use for your own checks.
A different utility, [`hast-util-phrasing`][hast-util-phrasing], does the same
but on [hast][].
## Install
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -25,2 +51,16 @@ npm install mdast-util-phrasing

In Deno with [`esm.sh`][esmsh]:
```js
import {phrasing} from 'https://esm.sh/mdast-util-phrasing@3'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {phrasing} from 'https://esm.sh/mdast-util-phrasing@3?bundle'
</script>
```
## Use

@@ -31,11 +71,7 @@

phrasing({
type: 'paragraph',
children: [{type: 'text', value: 'Alpha'}]
}) // => false
phrasing({type: 'paragraph', children: [{type: 'text', value: 'Alpha'}]})
// => false
phrasing({
type: 'strong',
children: [{type: 'text', value: 'Delta'}]
}) // => true
phrasing({type: 'strong', children: [{type: 'text', value: 'Delta'}]})
// => true
```

@@ -45,22 +81,35 @@

This package exports the following identifiers: `phrasing`.
This package exports the identifier [`phrasing`][api-phrasing].
There is no default export.
### `phrasing(node)`
### `phrasing(value)`
Check if the given value is a phrasing element.
Check if the given value is *[phrasing content][phrasing]*.
###### Parameters
`node` (`*`) — Value to check, typically a [node][].
* `value` (`unknown`)
— thing to check, typically [`Node`][node]
###### Returns
`boolean` — whether `node` is [phrasing content][phrasing].
Whether `value` is phrasing content (`boolean`).
## Types
This package is fully typed with [TypeScript][].
It does not export extra types.
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
## Security
Use of `mdast-util-phrasing` does not involve [**hast**][hast], user content,
or change the tree, so there are no openings for
[cross-site scripting (XSS)][xss] attacks.
Use of `mdast-util-phrasing` does not involve **[hast][]**, user content, or
change the tree, so there are no openings for [cross-site scripting (XSS)][xss]
attacks.

@@ -76,4 +125,4 @@ ## Related

See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.

@@ -119,2 +168,8 @@

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[license]: license

@@ -124,8 +179,14 @@

[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[health]: https://github.com/syntax-tree/.github
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[hast]: https://github.com/syntax-tree/hast
[mdast]: https://github.com/syntax-tree/mdast

@@ -137,4 +198,6 @@

[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[unist-util-is]: https://github.com/syntax-tree/unist-util-is
[hast]: https://github.com/syntax-tree/hast
[hast-util-phrasing]: https://github.com/syntax-tree/hast-util-phrasing
[api-phrasing]: #phrasingvalue
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