{"library":"mdast-util-assert","title":"mdast-util-assert: Markdown Abstract Syntax Tree Assertion Utility","description":"mdast-util-assert is a focused utility from the unified collective designed to validate the structure and properties of mdast (Markdown Abstract Syntax Tree) nodes. It provides functions to assert that a given object conforms to the expected shape of mdast nodes, including parent, literal, and void nodes. This package is particularly useful within API contexts where specific node types are expected, ensuring data integrity and preventing unexpected runtime errors. The current stable version is 5.0.0, which requires Node.js 16+ and is exclusively an ES Module (ESM). Release cadence generally follows semver, with major versions introducing breaking changes related to Node.js compatibility or module systems, while minor versions address bug fixes and documentation. Its key differentiator is its specialization for mdast nodes, building upon and re-exporting parts of the more general `unist-util-assert` for universal syntax trees.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mdast-util-assert"],"cli":null},"imports":["import { assert } from 'mdast-util-assert'","import { parent } from 'mdast-util-assert'","import { AssertionError } from 'mdast-util-assert'","import { literal } from 'mdast-util-assert'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { assert } from 'mdast-util-assert'\n\n// Assert valid mdast nodes\nassert({type: 'root', children: []})\nassert({type: 'break'})\nassert({type: 'listItem', checked: true, children: []})\n\n// This will throw an AssertionError due to missing 'type' property\ntry {\n  assert({children: []})\n} catch (error) {\n  console.error(error.message) // AssertionError: node should have a type: `{ children: [] }`\n}\n\n// This will throw an AssertionError due to incorrect property for a 'paragraph' node\ntry {\n  assert({type: 'paragraph', value: 'foo'})\n} catch (error) {\n  console.error(error.message) // AssertionError: parent should have children: `{ type: 'paragraph', value: 'foo' }`\n}\n","lang":"typescript","description":"Demonstrates how to use `assert` to validate mdast nodes, showing successful and failing assertions with error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}