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

@huggingface/jinja

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@huggingface/jinja - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

6

dist/ast.d.ts

@@ -106,2 +106,8 @@ import type { Token } from "./lexer";

/**
* Represents null (none) in the template.
*/
export declare class NullLiteral extends Literal<null> {
type: string;
}
/**
* Represents an array literal in the template.

@@ -108,0 +114,0 @@ */

32

dist/index.js

@@ -9,2 +9,4 @@ // src/lexer.ts

// true or false
NullLiteral: "NullLiteral",
// none
StringLiteral: "StringLiteral",

@@ -90,2 +92,3 @@ // 'string'

false: TOKEN_TYPES.BooleanLiteral,
none: TOKEN_TYPES.NullLiteral,
// NOTE: According to the Jinja docs: The special constants true, false, and none are indeed lowercase.

@@ -96,3 +99,4 @@ // Because that caused confusion in the past, (True used to expand to an undefined variable that was considered false),

True: TOKEN_TYPES.BooleanLiteral,
False: TOKEN_TYPES.BooleanLiteral
False: TOKEN_TYPES.BooleanLiteral,
None: TOKEN_TYPES.NullLiteral
});

@@ -232,2 +236,3 @@ var Token = class {

case TOKEN_TYPES.BooleanLiteral:
case TOKEN_TYPES.NullLiteral:
case TOKEN_TYPES.StringLiteral:

@@ -376,2 +381,5 @@ case TOKEN_TYPES.CloseParen:

};
var NullLiteral = class extends Literal {
type = "NullLiteral";
};
var ArrayLiteral = class extends Literal {

@@ -775,2 +783,4 @@ type = "ArrayLiteral";

filter = new Identifier(filter.value.toString());
} else if (filter instanceof NullLiteral) {
filter = new Identifier("none");
}

@@ -811,2 +821,5 @@ if (!(filter instanceof Identifier)) {

return new BooleanLiteral(token.value.toLowerCase() === "true");
case TOKEN_TYPES.NullLiteral:
++current;
return new NullLiteral(null);
case TOKEN_TYPES.Identifier:

@@ -945,3 +958,15 @@ ++current;

],
["length", new NumericValue(this.value.length)]
["length", new NumericValue(this.value.length)],
[
"rstrip",
new FunctionValue(() => {
return new StringValue(this.value.trimEnd());
})
],
[
"lstrip",
new FunctionValue(() => {
return new StringValue(this.value.trimStart());
})
]
]);

@@ -1062,2 +1087,3 @@ };

["true", (operand) => operand.type === "BooleanValue" && operand.value],
["none", (operand) => operand.type === "NullValue"],
["string", (operand) => operand.type === "StringValue"],

@@ -1689,2 +1715,4 @@ ["number", (operand) => operand.type === "NumericValue"],

return new BooleanValue(statement.value);
case "NullLiteral":
return new NullValue(statement.value);
case "ArrayLiteral":

@@ -1691,0 +1719,0 @@ return new ArrayValue(statement.value.map((x) => this.evaluate(x, environment)));

@@ -8,2 +8,3 @@ /**

BooleanLiteral: "BooleanLiteral";
NullLiteral: "NullLiteral";
StringLiteral: "StringLiteral";

@@ -10,0 +11,0 @@ Identifier: "Identifier";

4

package.json
{
"name": "@huggingface/jinja",
"packageManager": "pnpm@8.10.5",
"version": "0.3.0",
"version": "0.3.1",
"description": "A minimalistic JavaScript implementation of the Jinja templating engine, specifically designed for parsing and rendering ML chat templates.",

@@ -43,3 +43,3 @@ "repository": "https://github.com/huggingface/huggingface.js.git",

"@xenova/transformers": "^2.9.0",
"@huggingface/hub": "^0.15.1"
"@huggingface/hub": "^0.15.2"
},

@@ -46,0 +46,0 @@ "scripts": {

@@ -150,2 +150,9 @@ import type { Token } from "./lexer";

/**
* Represents null (none) in the template.
*/
export class NullLiteral extends Literal<null> {
override type = "NullLiteral";
}
/**
* Represents an array literal in the template.

@@ -152,0 +159,0 @@ */

@@ -9,2 +9,3 @@ /**

BooleanLiteral: "BooleanLiteral", // true or false
NullLiteral: "NullLiteral", // none
StringLiteral: "StringLiteral", // 'string'

@@ -77,2 +78,3 @@ Identifier: "Identifier", // Variables, functions, etc.

false: TOKEN_TYPES.BooleanLiteral,
none: TOKEN_TYPES.NullLiteral,

@@ -85,2 +87,3 @@ // NOTE: According to the Jinja docs: The special constants true, false, and none are indeed lowercase.

False: TOKEN_TYPES.BooleanLiteral,
None: TOKEN_TYPES.NullLiteral,
});

@@ -277,2 +280,3 @@

case TOKEN_TYPES.BooleanLiteral:
case TOKEN_TYPES.NullLiteral:
case TOKEN_TYPES.StringLiteral:

@@ -279,0 +283,0 @@ case TOKEN_TYPES.CloseParen:

@@ -15,2 +15,3 @@ import type { Token, TokenType } from "./lexer";

BooleanLiteral,
NullLiteral,
ArrayLiteral,

@@ -490,2 +491,4 @@ ObjectLiteral,

filter = new Identifier(filter.value.toString());
} else if (filter instanceof NullLiteral) {
filter = new Identifier("none");
}

@@ -532,2 +535,5 @@ if (!(filter instanceof Identifier)) {

return new BooleanLiteral(token.value.toLowerCase() === "true");
case TOKEN_TYPES.NullLiteral:
++current;
return new NullLiteral(null);
case TOKEN_TYPES.Identifier:

@@ -534,0 +540,0 @@ ++current;

@@ -5,2 +5,3 @@ import type {

BooleanLiteral,
NullLiteral,
ArrayLiteral,

@@ -108,2 +109,14 @@ Statement,

["length", new NumericValue(this.value.length)],
[
"rstrip",
new FunctionValue(() => {
return new StringValue(this.value.trimEnd());
}),
],
[
"lstrip",
new FunctionValue(() => {
return new StringValue(this.value.trimStart());
}),
],
]);

@@ -262,2 +275,3 @@ }

["true", (operand) => operand.type === "BooleanValue" && (operand as BooleanValue).value],
["none", (operand) => operand.type === "NullValue"],
["string", (operand) => operand.type === "StringValue"],

@@ -1045,2 +1059,4 @@ ["number", (operand) => operand.type === "NumericValue"],

return new BooleanValue((statement as BooleanLiteral).value);
case "NullLiteral":
return new NullValue((statement as NullLiteral).value);
case "ArrayLiteral":

@@ -1047,0 +1063,0 @@ return new ArrayValue((statement as ArrayLiteral).value.map((x) => this.evaluate(x, environment)));

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