@unified-latex/unified-latex-util-split
Advanced tools
Comparing version 1.6.1 to 1.7.0
@@ -1,15 +0,42 @@ | ||
export * from "./libs/split-on-macro"; | ||
export * from "./libs/split-on-condition"; | ||
export * from "./libs/unsplit-on-macro"; | ||
export * from "./libs/array-join"; | ||
import * as Ast from '@unified-latex/unified-latex-types'; | ||
/** | ||
* ## What is this? | ||
* Joins an array of arrays with the item `sep` | ||
*/ | ||
export declare function arrayJoin<T>(array: T[][], sep: T | T[]): T[]; | ||
/** | ||
* 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. | ||
*/ | ||
export declare function splitOnCondition(nodes: Ast.Node[], splitFunc?: (node: Ast.Node) => boolean, options?: { | ||
onlySplitOnFirstOccurrence?: boolean; | ||
}): { | ||
segments: Ast.Node[][]; | ||
separators: Ast.Node[]; | ||
}; | ||
/** | ||
* 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] + ...`. | ||
* | ||
* 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. | ||
* @param {[object]} ast | ||
* @param {(string|[string])} macroName | ||
* @returns {{segments: [object], macros: [object]}} | ||
*/ | ||
//# sourceMappingURL=index.d.ts.map | ||
export declare function splitOnMacro(ast: Ast.Node[], macroName: string | string[]): { | ||
segments: Ast.Node[][]; | ||
macros: Ast.Macro[]; | ||
}; | ||
/** | ||
* Does the reverse of `splitOnMacro` | ||
*/ | ||
export declare function unsplitOnMacro({ segments, macros, }: { | ||
segments: Ast.Node[][]; | ||
macros: Ast.Node[] | Ast.Node[][]; | ||
}): Ast.Node[]; | ||
export { } |
@@ -1,5 +0,2 @@ | ||
// libs/split-on-macro.ts | ||
import { match } from "@unified-latex/unified-latex-util-match"; | ||
// libs/split-on-condition.ts | ||
function splitOnCondition(nodes, splitFunc = () => false, options) { | ||
@@ -32,4 +29,2 @@ if (!Array.isArray(nodes)) { | ||
} | ||
// libs/split-on-macro.ts | ||
function splitOnMacro(ast, macroName) { | ||
@@ -46,4 +41,2 @@ if (typeof macroName === "string") { | ||
} | ||
// libs/unsplit-on-macro.ts | ||
function unsplitOnMacro({ | ||
@@ -68,4 +61,2 @@ segments, | ||
} | ||
// libs/array-join.ts | ||
function arrayJoin(array, sep) { | ||
@@ -72,0 +63,0 @@ return array.flatMap((item, i) => { |
{ | ||
"name": "@unified-latex/unified-latex-util-split", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "Functions for modifying a unified-latex AST", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@unified-latex/unified-latex-types": "^1.6.1", | ||
"@unified-latex/unified-latex-util-match": "^1.6.1" | ||
"@unified-latex/unified-latex-types": "^1.7.0", | ||
"@unified-latex/unified-latex-util-match": "^1.7.0" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20974
7
191
1