Socket
Socket
Sign inDemoInstall

@types/unist

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/unist

TypeScript definitions for Unist


Version published
Weekly downloads
16M
increased by1.4%
Maintainers
1
Install size
8.23 kB
Created
Weekly downloads
 

Package description

What is @types/unist?

The @types/unist package provides TypeScript definitions for Unist, a specification for syntax trees. It is used to add static typing to Unist-based projects, enabling developers to work with Unist syntax trees in a type-safe manner. This package is essential for TypeScript developers working with Unist or any Unist-compatible syntax tree, such as Markdown Abstract Syntax Trees (ASTs), providing auto-completion and type checking.

What are @types/unist's main functionalities?

Node Type Definition

Defines the basic structure of a Unist node, including types like 'text', 'element', etc. This is fundamental for creating and manipulating syntax trees.

{
  "type": "text",
  "value": "Hello, world!"
}

Parent Type Definition

Defines a parent node which can contain other nodes. This is crucial for representing hierarchical structures within syntax trees.

{
  "type": "paragraph",
  "children": [
    {
      "type": "text",
      "value": "Hello, world!"
    }
  ]
}

Literal Type Definition

Defines a literal node with a value. This is used for nodes that contain actual content, such as text.

{
  "type": "text",
  "value": "Example text"
}

Other packages similar to @types/unist

Readme

Source

Installation

npm install --save @types/unist

Summary

This package contains type definitions for Unist (https://github.com/syntax-tree/unist).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist.

index.d.ts

// Type definitions for non-npm package Unist 2.0
// Project: https://github.com/syntax-tree/unist
// Definitions by: bizen241 <https://github.com/bizen241>
//                 Jun Lu <https://github.com/lujun2>
//                 Hernan Rajchert <https://github.com/hrajchert>
//                 Titus Wormer <https://github.com/wooorm>
//                 Junyoung Choi <https://github.com/rokt33r>
//                 Ben Moon <https://github.com/GuiltyDolphin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0

/**
 * Syntactic units in unist syntax trees are called nodes.
 */
export interface Node {
    /**
     * The variant of a node.
     */
    type: string;

    /**
     * Information from the ecosystem.
     */
    data?: Data | undefined;

    /**
     * Location of a node in a source document.
     * Must not be present if a node is generated.
     */
    position?: Position | undefined;
}

/**
 * Information associated by the ecosystem with the node.
 * Space is guaranteed to never be specified by unist or specifications
 * implementing unist.
 */
export interface Data {
    [key: string]: unknown;
}

/**
 * Location of a node in a source file.
 */
export interface Position {
    /**
     * Place of the first character of the parsed source region.
     */
    start: Point;

    /**
     * Place of the first character after the parsed source region.
     */
    end: Point;

    /**
     * Start column at each index (plus start line) in the source region,
     * for elements that span multiple lines.
     */
    indent?: number[] | undefined;
}

/**
 * One place in a source file.
 */
export interface Point {
    /**
     * Line in a source file (1-indexed integer).
     */
    line: number;

    /**
     * Column in a source file (1-indexed integer).
     */
    column: number;
    /**
     * Character in a source file (0-indexed integer).
     */
    offset?: number | undefined;
}

/**
 * Nodes containing other nodes.
 */
export interface Parent extends Node {
    /**
     * List representing the children of a node.
     */
    children: Node[];
}

/**
 * Nodes containing a value.
 */
export interface Literal extends Node {
    value: unknown;
}

Additional Details

  • Last updated: Mon, 05 Jul 2021 15:31:19 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by bizen241, Jun Lu, Hernan Rajchert, Titus Wormer, Junyoung Choi, and Ben Moon.

FAQs

Last updated on 05 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc