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

mdast-util-to-nlcst

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-to-nlcst - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

24

index.d.ts

@@ -14,17 +14,21 @@ /**

options?: Options | undefined
): import('unist').Node<import('unist').Data>
): import('nlcst').Root
export type Point = import('unist').Point
export type UnistLiteral = import('unist').Literal<string>
export type UnistParent = import('unist').Parent
export type UnistNode = import('unist').Node
export type NlcstRoot = import('nlcst').Root
export type NlcstContent = import('nlcst').Content
export type NlcstSentenceContent = import('nlcst').SentenceContent
export type NlcstWhiteSpace = import('nlcst').WhiteSpace
export type NlcstSource = import('nlcst').Source
export type NlcstNode = NlcstRoot | NlcstContent
export type MdastRoot = import('mdast').Root
export type MdastContent = import('mdast').Content
export type MdastNode = MdastRoot | MdastContent
export type MdastParent = Extract<MdastNode, import('unist').Parent>
export type VFile = import('vfile').VFile
export type Location = ReturnType<typeof location>
export type ParserInstance = {
parse(nodes: UnistNode[]): UnistNode
tokenizeSource(value: string): UnistNode
tokenizeWhiteSpace(value: string): UnistNode
tokenize(value: string): UnistNode[]
parse(nodes: NlcstContent[]): NlcstRoot
tokenizeSource(value: string): NlcstSource
tokenizeWhiteSpace(value: string): NlcstWhiteSpace
tokenize(value: string): NlcstSentenceContent[]
}

@@ -40,5 +44,5 @@ export type ParserConstructor = new () => ParserInstance

parser: ParserInstance
ignore: Array<string>
source: Array<string>
ignore: string[]
source: string[]
}
import {location} from 'vfile-location'
/**
* @typedef {import('unist').Point} Point
* @typedef {import('unist').Literal<string>} UnistLiteral
* @typedef {import('unist').Parent} UnistParent
* @typedef {import('unist').Node} UnistNode
*
* @typedef {import('nlcst').Root} NlcstRoot
* @typedef {import('nlcst').Content} NlcstContent
* @typedef {import('nlcst').SentenceContent} NlcstSentenceContent
* @typedef {import('nlcst').WhiteSpace} NlcstWhiteSpace
* @typedef {import('nlcst').Source} NlcstSource
* @typedef {NlcstRoot|NlcstContent} NlcstNode
*
* @typedef {import('mdast').Root} MdastRoot
* @typedef {import('mdast').Content} MdastContent
* @typedef {MdastRoot|MdastContent} MdastNode
* @typedef {Extract<MdastNode, import('unist').Parent>} MdastParent
*
*
* @typedef {import('vfile').VFile} VFile
* @typedef {ReturnType<import('vfile-location').location>} Location
* @typedef {{
* parse(nodes: UnistNode[]): UnistNode
* tokenizeSource(value: string): UnistNode
* tokenizeWhiteSpace(value: string): UnistNode
* tokenize(value: string): UnistNode[]
* parse(nodes: NlcstContent[]): NlcstRoot
* tokenizeSource(value: string): NlcstSource
* tokenizeWhiteSpace(value: string): NlcstWhiteSpace
* tokenize(value: string): NlcstSentenceContent[]
* }} ParserInstance

@@ -20,4 +28,4 @@ * @typedef {new () => ParserInstance} ParserConstructor

* @typedef Options
* @property {Array.<string>} [ignore]
* @property {Array.<string>} [source]
* @property {string[]} [ignore]
* @property {string[]} [source]
*

@@ -28,4 +36,4 @@ * @typedef Context

* @property {ParserInstance} parser
* @property {Array.<string>} ignore
* @property {Array.<string>} source
* @property {string[]} ignore
* @property {string[]} source
*/

@@ -98,3 +106,3 @@

* @param {MdastNode} node
* @returns {Array.<UnistNode>|undefined}
* @returns {NlcstContent[]|undefined}
*/

@@ -142,8 +150,8 @@ function one(config, node) {

* @param {Context} config
* @param {UnistParent} parent
* @returns {Array.<UnistNode>}
* @param {MdastParent} parent
* @returns {NlcstContent[]}
*/
function all(config, parent) {
let index = -1
/** @type {Array.<UnistNode>} */
/** @type {NlcstContent[]} */
const results = []

@@ -154,4 +162,2 @@ /** @type {Point|undefined} */

while (++index < parent.children.length) {
/** @type {MdastContent} */
// @ts-expect-error Assume `parent` is an mdast parent.
const child = parent.children[index]

@@ -166,3 +172,3 @@ const start = pointStart(child)

if (literal(lineEnding) && lineEnding.value.length < 2) {
if (lineEnding.value.length < 2) {
lineEnding.value = '\n\n'

@@ -186,3 +192,3 @@ }

*
* @template {Array.<UnistNode>} T
* @template {NlcstContent[]} T
* @param {Context} config

@@ -200,3 +206,3 @@ * @param {T} nodes

if (parent(node)) {
if ('children' in node) {
patch(config, node.children, start)

@@ -221,17 +227,1 @@ }

}
/**
* @param {UnistNode} node
* @returns {node is UnistLiteral}
*/
function literal(node) {
return 'value' in node
}
/**
* @param {UnistNode} node
* @returns {node is UnistParent}
*/
function parent(node) {
return 'children' in node
}
{
"name": "mdast-util-to-nlcst",
"version": "5.1.0",
"version": "5.2.0",
"description": "mdast utility to transform to nlcst",

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

"@types/mdast": "^3.0.0",
"@types/nlcst": "^1.0.0",
"@types/unist": "^2.0.0",

@@ -53,7 +54,7 @@ "nlcst-to-string": "^3.0.0",

"prettier": "^2.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-frontmatter": "^3.0.0",
"remark-gfm": "^1.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark": "^14.0.0",
"remark-cli": "^10.0.0",
"remark-frontmatter": "^4.0.0",
"remark-gfm": "^2.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",

@@ -64,3 +65,3 @@ "tape": "^5.0.0",

"typescript": "^4.0.0",
"xo": "^0.42.0"
"xo": "^0.44.0"
},

@@ -67,0 +68,0 @@ "scripts": {

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