New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unified-latex/unified-latex-util-arguments

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unified-latex/unified-latex-util-arguments - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

4

index.d.ts
export { gobbleArguments } from "./libs/gobble-arguments";
export { attachMacroArgs, attachMacroArgsInArray } from "./libs/attach-arguments";
export { attachMacroArgs, attachMacroArgsInArray, } from "./libs/attach-arguments";
export * from "./libs/unified-latex-attach-macro-arguments";
export * from "./libs/get-args-content";
export * from "./libs/gobble-single-argument";
export * from "./libs/gobble-arguments";
/**

@@ -6,0 +8,0 @@ * ## What is this?

@@ -9,2 +9,3 @@ // libs/gobble-arguments.ts

import { match } from "@unified-latex/unified-latex-util-match";
import { scan } from "@unified-latex/unified-latex-util-scan";
import { arg } from "@unified-latex/unified-latex-builder";

@@ -105,2 +106,34 @@ function gobbleSingleArgument(nodes, argSpec, startPos = 0) {

break;
case "until": {
if (argSpec.stopTokens.length > 1) {
console.warn(
`"until" matches with multi-token stop conditions are not yet implemented`
);
break;
}
const rawToken = argSpec.stopTokens[0];
const stopToken = rawToken === " " ? { type: "whitespace" } : { type: "string", content: argSpec.stopTokens[0] };
let matchPos = scan(nodes, stopToken, {
startIndex: startPos,
allowSubstringMatches: true
});
if (matchPos != null && partialStringMatch(nodes[matchPos], stopToken)) {
console.warn(
`"until" arguments that stop at non-punctuation symbols is not yet implemented`
);
break;
}
if (matchPos == null) {
break;
}
argument = arg(nodes.slice(startPos, matchPos), {
openMark: "",
closeMark: rawToken
});
currPos = matchPos;
if (currPos < nodes.length) {
currPos++;
}
break;
}
default:

@@ -115,5 +148,11 @@ console.warn(

}
function partialStringMatch(node, token) {
return match.anyString(node) && match.anyString(token) && node.content.length > token.content.length;
}
// libs/gobble-arguments.ts
function gobbleArguments(nodes, argSpec, startPos = 0) {
if (typeof argSpec === "function") {
return argSpec(nodes, startPos);
}
if (typeof argSpec === "string") {

@@ -163,3 +202,4 @@ argSpec = parseArgspec(argSpec);

updateRenderInfo(macro, macroInfo.renderInfo);
if (macroInfo.signature == null) {
const signatureOrParser = macroInfo.argumentParser || macroInfo.signature;
if (signatureOrParser == null) {
currIndex--;

@@ -173,3 +213,3 @@ continue;

currIndex++;
const { args } = gobbleArguments(nodes, macroInfo.signature, currIndex);
const { args } = gobbleArguments(nodes, signatureOrParser, currIndex);
macro.args = args;

@@ -247,4 +287,5 @@ currIndex = macroIndex - 1;

gobbleArguments,
gobbleSingleArgument,
unifiedLatexAttachMacroArguments
};
//# sourceMappingURL=index.js.map
import { ArgSpecAst as ArgSpec } from "@unified-latex/unified-latex-util-argspec";
import * as Ast from "@unified-latex/unified-latex-types";
import { ArgumentParser } from "@unified-latex/unified-latex-types";
/**

@@ -8,3 +9,3 @@ * Gobbles an argument of whose type is specified

*/
export declare function gobbleArguments(nodes: Ast.Node[], argSpec: string | ArgSpec.Node[], startPos?: number): {
export declare function gobbleArguments(nodes: Ast.Node[], argSpec: string | ArgSpec.Node[] | ArgumentParser, startPos?: number): {
args: Ast.Argument[];

@@ -11,0 +12,0 @@ nodesRemoved: number;

{
"name": "@unified-latex/unified-latex-util-arguments",
"version": "1.2.2",
"version": "1.3.0",
"description": "Tools for manipulating unified-latex ASTs",

@@ -8,8 +8,9 @@ "main": "index.js",

"dependencies": {
"@unified-latex/unified-latex-builder": "^1.2.2",
"@unified-latex/unified-latex-types": "^1.2.2",
"@unified-latex/unified-latex-util-argspec": "^1.2.2",
"@unified-latex/unified-latex-util-match": "^1.2.2",
"@unified-latex/unified-latex-util-render-info": "^1.2.2",
"@unified-latex/unified-latex-util-visit": "^1.2.2",
"@unified-latex/unified-latex-builder": "^1.3.0",
"@unified-latex/unified-latex-types": "^1.3.0",
"@unified-latex/unified-latex-util-argspec": "^1.3.0",
"@unified-latex/unified-latex-util-match": "^1.3.0",
"@unified-latex/unified-latex-util-render-info": "^1.3.0",
"@unified-latex/unified-latex-util-scan": "^1.3.0",
"@unified-latex/unified-latex-util-visit": "^1.3.0",
"unified": "^10.1.2"

@@ -16,0 +17,0 @@ },

@@ -95,1 +95,23 @@ <!-- DO NOT MODIFY -->

| namedArgumentsFallback | `readonly string[]` |
## `gobbleSingleArgument(nodes, argSpec, startPos)`
Gobbles an argument of whose type is specified
by `argSpec` starting at the position `startPos`. If an argument couldn't be found,
`argument` will be `null`.
```typescript
function gobbleSingleArgument(
nodes: Ast.Node[],
argSpec: ArgSpec.Node,
startPos: Number
): { argument: Ast.Argument | null; nodesRemoved: number };
```
**Parameters**
| Param | Type |
| :------- | :------------- |
| nodes | `Ast.Node[]` |
| argSpec | `ArgSpec.Node` |
| startPos | `Number` |

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

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

Sorry, the diff of this file is not supported yet

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