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

@unified-latex/unified-latex-util-split

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unified-latex/unified-latex-util-split

Functions for modifying a unified-latex AST

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

unified-latex-util-split

What is this?

Functions to manipulate unified-latex Abstract Syntax Tree (AST).

When should I use this?

If you want break apart or join an array of nodes based on a condition. For example, this is used to split on & characters in the align environment.

Install

npm install @unified-latex/unified-latex-util-split

This package contains both esm and commonjs exports. To explicitly access the esm export, import the .js file. To explicitly access the commonjs export, import the .cjs file.

Functions

arrayJoin(array, sep)

Joins an array of arrays with the item sep

function arrayJoin<T>(array: T[][], sep: T | T[]): T[];

Parameters

ParamType
arrayT[][]
sepT | T[]

splitOnCondition(nodes, splitFunc, options)

Split a list of nodes based on whether splitFunc returns true. If onlySplitOnFirstOccurrence is set to true in the options object, then there will be at most two segments returned.

function splitOnCondition(
  nodes: Ast.Node[],
  splitFunc: (node: Ast.Node) => boolean,
  options: { onlySplitOnFirstOccurrence?: boolean }
): { segments: Ast.Node[][]; separators: Ast.Node[] };

Parameters

ParamType
nodesAst.Node[]
splitFunc(node: Ast.Node) => boolean
optionsOmitted

splitOnMacro(ast, macroName)

Split an array of AST nodes based on a macro. An object {segments: [], macros: []} is returned. The original array is reconstructed as segments[0] + macros[0] + segments[1] + ....

function splitOnMacro(
  ast: Ast.Node[],
  macroName: string | string[]
): { segments: Ast.Node[][]; macros: Ast.Macro[] };

Parameters

ParamType
astAst.Node[]
macroNamestring | string[]

unsplitOnMacro({ segments, macros, })

Does the reverse of splitOnMacro

function unsplitOnMacro({
  segments,
  macros,
}: {
  segments: Ast.Node[][];
  macros: Ast.Node[] | Ast.Node[][];
}): Ast.Node[];

Parameters

ParamType
{ segments, macros, }Omitted

Keywords

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc