First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

221
node_modules/@huggingface/jinja/dist/ast.d.ts generated vendored Normal file
View File

@@ -0,0 +1,221 @@
import type { Token } from "./lexer";
/**
* Statements do not result in a value at runtime. They contain one or more expressions internally.
*/
export declare class Statement {
type: string;
}
/**
* Defines a block which contains many statements. Each chat template corresponds to one Program.
*/
export declare class Program extends Statement {
body: Statement[];
type: string;
constructor(body: Statement[]);
}
export declare class If extends Statement {
test: Expression;
body: Statement[];
alternate: Statement[];
type: string;
constructor(test: Expression, body: Statement[], alternate: Statement[]);
}
/**
* Loop over each item in a sequence
* https://jinja.palletsprojects.com/en/3.0.x/templates/#for
*/
export declare class For extends Statement {
loopvar: Identifier | TupleLiteral;
iterable: Expression;
body: Statement[];
defaultBlock: Statement[];
type: string;
constructor(loopvar: Identifier | TupleLiteral, iterable: Expression, body: Statement[], defaultBlock: Statement[]);
}
export declare class Break extends Statement {
type: string;
}
export declare class Continue extends Statement {
type: string;
}
export declare class SetStatement extends Statement {
assignee: Expression;
value: Expression | null;
body: Statement[];
type: string;
constructor(assignee: Expression, value: Expression | null, body: Statement[]);
}
export declare class Macro extends Statement {
name: Identifier;
args: Expression[];
body: Statement[];
type: string;
constructor(name: Identifier, args: Expression[], body: Statement[]);
}
export declare class Comment extends Statement {
value: string;
type: string;
constructor(value: string);
}
/**
* Expressions will result in a value at runtime (unlike statements).
*/
export declare class Expression extends Statement {
type: string;
}
export declare class MemberExpression extends Expression {
object: Expression;
property: Expression;
computed: boolean;
type: string;
constructor(object: Expression, property: Expression, computed: boolean);
}
export declare class CallExpression extends Expression {
callee: Expression;
args: Expression[];
type: string;
constructor(callee: Expression, args: Expression[]);
}
/**
* Represents a user-defined variable or symbol in the template.
*/
export declare class Identifier extends Expression {
value: string;
type: string;
/**
* @param {string} value The name of the identifier
*/
constructor(value: string);
}
/**
* Abstract base class for all Literal expressions.
* Should not be instantiated directly.
*/
declare abstract class Literal<T> extends Expression {
value: T;
type: string;
constructor(value: T);
}
export declare class IntegerLiteral extends Literal<number> {
type: string;
}
export declare class FloatLiteral extends Literal<number> {
type: string;
}
/**
* Represents a text constant in the template.
*/
export declare class StringLiteral extends Literal<string> {
type: string;
}
/**
* Represents an array literal in the template.
*/
export declare class ArrayLiteral extends Literal<Expression[]> {
type: string;
}
/**
* Represents a tuple literal in the template.
*/
export declare class TupleLiteral extends Literal<Expression[]> {
type: string;
}
/**
* Represents an object literal in the template.
*/
export declare class ObjectLiteral extends Literal<Map<Expression, Expression>> {
type: string;
}
/**
* An operation with two sides, separated by an operator.
* Note: Either side can be a Complex Expression, with order
* of operations being determined by the operator.
*/
export declare class BinaryExpression extends Expression {
operator: Token;
left: Expression;
right: Expression;
type: string;
constructor(operator: Token, left: Expression, right: Expression);
}
/**
* An operation with two sides, separated by the | operator.
* Operator precedence: https://github.com/pallets/jinja/issues/379#issuecomment-168076202
*/
export declare class FilterExpression extends Expression {
operand: Expression;
filter: Identifier | CallExpression;
type: string;
constructor(operand: Expression, filter: Identifier | CallExpression);
}
export declare class FilterStatement extends Statement {
filter: Identifier | CallExpression;
body: Statement[];
type: string;
constructor(filter: Identifier | CallExpression, body: Statement[]);
}
/**
* An operation which filters a sequence of objects by applying a test to each object,
* and only selecting the objects with the test succeeding.
*
* It may also be used as a shortcut for a ternary operator.
*/
export declare class SelectExpression extends Expression {
lhs: Expression;
test: Expression;
type: string;
constructor(lhs: Expression, test: Expression);
}
/**
* An operation with two sides, separated by the "is" operator.
*/
export declare class TestExpression extends Expression {
operand: Expression;
negate: boolean;
test: Identifier;
type: string;
constructor(operand: Expression, negate: boolean, test: Identifier);
}
/**
* An operation with one side (operator on the left).
*/
export declare class UnaryExpression extends Expression {
operator: Token;
argument: Expression;
type: string;
constructor(operator: Token, argument: Expression);
}
export declare class SliceExpression extends Expression {
start: Expression | undefined;
stop: Expression | undefined;
step: Expression | undefined;
type: string;
constructor(start?: Expression | undefined, stop?: Expression | undefined, step?: Expression | undefined);
}
export declare class KeywordArgumentExpression extends Expression {
key: Identifier;
value: Expression;
type: string;
constructor(key: Identifier, value: Expression);
}
export declare class SpreadExpression extends Expression {
argument: Expression;
type: string;
constructor(argument: Expression);
}
export declare class CallStatement extends Statement {
call: CallExpression;
callerArgs: Expression[] | null;
body: Statement[];
type: string;
constructor(call: CallExpression, callerArgs: Expression[] | null, body: Statement[]);
}
export declare class Ternary extends Expression {
condition: Expression;
trueExpr: Expression;
falseExpr: Expression;
type: string;
constructor(condition: Expression, trueExpr: Expression, falseExpr: Expression);
}
export {};
//# sourceMappingURL=ast.d.ts.map

1
node_modules/@huggingface/jinja/dist/ast.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;GAEG;AACH,qBAAa,SAAS;IACrB,IAAI,SAAe;CACnB;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IAGlB,IAAI,EAAE,SAAS,EAAE;IAF3B,IAAI,SAAa;gBAEP,IAAI,EAAE,SAAS,EAAE;CAGpC;AAED,qBAAa,EAAG,SAAQ,SAAS;IAIxB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,SAAS,EAAE;IACjB,SAAS,EAAE,SAAS,EAAE;IALrB,IAAI,SAAQ;gBAGb,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EAAE,EACjB,SAAS,EAAE,SAAS,EAAE;CAI9B;AAED;;;GAGG;AACH,qBAAa,GAAI,SAAQ,SAAS;IAIzB,OAAO,EAAE,UAAU,GAAG,YAAY;IAClC,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,SAAS,EAAE;IACjB,YAAY,EAAE,SAAS,EAAE;IANxB,IAAI,SAAS;gBAGd,OAAO,EAAE,UAAU,GAAG,YAAY,EACl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,SAAQ,UAAU;IAG5B,QAAQ,EAAE,UAAU;IAF9B,IAAI,SAAsB;gBAEhB,QAAQ,EAAE,UAAU;CAGvC;AAED,qBAAa,aAAc,SAAQ,SAAS;IAInC,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI;IAC/B,IAAI,EAAE,SAAS,EAAE;IALhB,IAAI,SAAmB;gBAGxB,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,EAC/B,IAAI,EAAE,SAAS,EAAE;CAIzB;AAED,qBAAa,OAAQ,SAAQ,UAAU;IAG9B,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;IAJpB,IAAI,SAAa;gBAElB,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,UAAU;CAI7B"}

3
node_modules/@huggingface/jinja/dist/format.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { Program } from "./ast";
export declare function format(program: Program, indent?: string | number): string;
//# sourceMappingURL=format.d.ts.map

1
node_modules/@huggingface/jinja/dist/format.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,OAAO,EA4BP,MAAM,OAAO,CAAC;AAsBf,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,MAAM,GAAG,MAAa,GAAG,MAAM,CAI/E"}

2857
node_modules/@huggingface/jinja/dist/index.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

29
node_modules/@huggingface/jinja/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* @file Jinja templating engine
*
* A minimalistic JavaScript reimplementation of the [Jinja](https://github.com/pallets/jinja) templating engine,
* to support the chat templates. Special thanks to [Tyler Laceby](https://github.com/tlaceby) for his amazing
* ["Guide to Interpreters"](https://github.com/tlaceby/guide-to-interpreters-series) tutorial series,
* which provided the basis for this implementation.
*
* See the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/chat_templating) for more information.
*
* @module index
*/
import { tokenize } from "./lexer";
import { parse } from "./parser";
import { Environment, Interpreter } from "./runtime";
import type { Program } from "./ast";
export declare class Template {
parsed: Program;
/**
* @param {string} template The template string
*/
constructor(template: string);
render(items?: Record<string, unknown>): string;
format(options?: {
indent: string | number;
}): string;
}
export { Environment, Interpreter, tokenize, parse };
//# sourceMappingURL=index.d.ts.map

1
node_modules/@huggingface/jinja/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAgB,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIrC,qBAAa,QAAQ;IACpB,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;gBACS,QAAQ,EAAE,MAAM;IAQ5B,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAkB/C,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM;CAGrD;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC"}

2826
node_modules/@huggingface/jinja/dist/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

53
node_modules/@huggingface/jinja/dist/lexer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
/**
* Represents tokens that our language understands in parsing.
*/
export declare const TOKEN_TYPES: Readonly<{
Text: "Text";
NumericLiteral: "NumericLiteral";
StringLiteral: "StringLiteral";
Identifier: "Identifier";
Equals: "Equals";
OpenParen: "OpenParen";
CloseParen: "CloseParen";
OpenStatement: "OpenStatement";
CloseStatement: "CloseStatement";
OpenExpression: "OpenExpression";
CloseExpression: "CloseExpression";
OpenSquareBracket: "OpenSquareBracket";
CloseSquareBracket: "CloseSquareBracket";
OpenCurlyBracket: "OpenCurlyBracket";
CloseCurlyBracket: "CloseCurlyBracket";
Comma: "Comma";
Dot: "Dot";
Colon: "Colon";
Pipe: "Pipe";
CallOperator: "CallOperator";
AdditiveBinaryOperator: "AdditiveBinaryOperator";
MultiplicativeBinaryOperator: "MultiplicativeBinaryOperator";
ComparisonBinaryOperator: "ComparisonBinaryOperator";
UnaryOperator: "UnaryOperator";
Comment: "Comment";
}>;
export type TokenType = keyof typeof TOKEN_TYPES;
/**
* Represents a single token in the template.
*/
export declare class Token {
value: string;
type: TokenType;
/**
* Constructs a new Token.
* @param {string} value The raw value as seen inside the source code.
* @param {TokenType} type The type of token.
*/
constructor(value: string, type: TokenType);
}
export interface PreprocessOptions {
trim_blocks?: boolean;
lstrip_blocks?: boolean;
}
/**
* Generate a list of tokens from a source string.
*/
export declare function tokenize(source: string, options?: PreprocessOptions): Token[];
//# sourceMappingURL=lexer.d.ts.map

1
node_modules/@huggingface/jinja/dist/lexer.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../src/lexer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BtB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,WAAW,CAAC;AAEjD;;GAEG;AACH,qBAAa,KAAK;IAOT,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,SAAS;IAPvB;;;;OAIG;gBAEK,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS;CAEvB;AAgED,MAAM,WAAW,iBAAiB;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AA8BD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,KAAK,EAAE,CAqPjF"}

8
node_modules/@huggingface/jinja/dist/parser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { Token } from "./lexer";
import { Program } from "./ast";
/**
* Generate the Abstract Syntax Tree (AST) from a list of tokens.
* Operator precedence can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence#table
*/
export declare function parse(tokens: Token[]): Program;
//# sourceMappingURL=parser.d.ts.map

1
node_modules/@huggingface/jinja/dist/parser.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,SAAS,CAAC;AAG7C,OAAO,EACN,OAAO,EA4BP,MAAM,OAAO,CAAC;AAEf;;;GAGG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAunB9C"}

201
node_modules/@huggingface/jinja/dist/runtime.d.ts generated vendored Normal file
View File

@@ -0,0 +1,201 @@
import type { Statement, Program } from "./ast";
export type AnyRuntimeValue = IntegerValue | FloatValue | StringValue | BooleanValue | ObjectValue | ArrayValue | FunctionValue | NullValue | UndefinedValue;
/**
* Abstract base class for all Runtime values.
* Should not be instantiated directly.
*/
declare abstract class RuntimeValue<T> {
type: string;
value: T;
/**
* A collection of built-in functions for this type.
*/
builtins: Map<string, AnyRuntimeValue>;
/**
* Creates a new RuntimeValue.
*/
constructor(value?: T);
/**
* Determines truthiness or falsiness of the runtime value.
* This function should be overridden by subclasses if it has custom truthiness criteria.
* @returns {BooleanValue} BooleanValue(true) if the value is truthy, BooleanValue(false) otherwise.
*/
__bool__(): BooleanValue;
toString(): string;
}
/**
* Represents an integer value at runtime.
*/
export declare class IntegerValue extends RuntimeValue<number> {
type: string;
}
/**
* Represents a float value at runtime.
*/
export declare class FloatValue extends RuntimeValue<number> {
type: string;
toString(): string;
}
/**
* Represents a string value at runtime.
*/
export declare class StringValue extends RuntimeValue<string> {
type: string;
builtins: Map<string, AnyRuntimeValue>;
}
/**
* Represents a boolean value at runtime.
*/
export declare class BooleanValue extends RuntimeValue<boolean> {
type: string;
}
/**
* Represents an Object value at runtime.
*/
export declare class ObjectValue extends RuntimeValue<Map<string, AnyRuntimeValue>> {
type: string;
/**
* NOTE: necessary to override since all JavaScript arrays are considered truthy,
* while only non-empty Python arrays are consider truthy.
*
* e.g.,
* - JavaScript: {} && 5 -> 5
* - Python: {} and 5 -> {}
*/
__bool__(): BooleanValue;
builtins: Map<string, AnyRuntimeValue>;
items(): ArrayValue;
keys(): ArrayValue;
values(): ArrayValue;
toString(): string;
}
/**
* Represents a KeywordArguments value at runtime.
*/
export declare class KeywordArgumentsValue extends ObjectValue {
type: string;
}
/**
* Represents an Array value at runtime.
*/
export declare class ArrayValue extends RuntimeValue<AnyRuntimeValue[]> {
type: string;
builtins: Map<string, AnyRuntimeValue>;
/**
* NOTE: necessary to override since all JavaScript arrays are considered truthy,
* while only non-empty Python arrays are consider truthy.
*
* e.g.,
* - JavaScript: [] && 5 -> 5
* - Python: [] and 5 -> []
*/
__bool__(): BooleanValue;
toString(): string;
}
/**
* Represents a Tuple value at runtime.
* NOTE: We extend ArrayValue since JavaScript does not have a built-in Tuple type.
*/
export declare class TupleValue extends ArrayValue {
type: string;
}
/**
* Represents a Function value at runtime.
*/
export declare class FunctionValue extends RuntimeValue<(args: AnyRuntimeValue[], scope: Environment) => AnyRuntimeValue> {
type: string;
}
/**
* Represents a Null value at runtime.
*/
export declare class NullValue extends RuntimeValue<null> {
type: string;
}
/**
* Represents an Undefined value at runtime.
*/
export declare class UndefinedValue extends RuntimeValue<undefined> {
type: string;
}
/**
* Represents the current environment (scope) at runtime.
*/
export declare class Environment {
parent?: Environment | undefined;
/**
* The variables declared in this environment.
*/
variables: Map<string, AnyRuntimeValue>;
/**
* The tests available in this environment.
*/
tests: Map<string, (...value: AnyRuntimeValue[]) => boolean>;
constructor(parent?: Environment | undefined);
/**
* Set the value of a variable in the current environment.
*/
set(name: string, value: unknown): AnyRuntimeValue;
private declareVariable;
/**
* Set variable in the current scope.
* See https://jinja.palletsprojects.com/en/3.0.x/templates/#assignments for more information.
*/
setVariable(name: string, value: AnyRuntimeValue): AnyRuntimeValue;
/**
* Resolve the environment in which the variable is declared.
* @param {string} name The name of the variable.
* @returns {Environment} The environment in which the variable is declared.
*/
private resolve;
lookupVariable(name: string): AnyRuntimeValue;
}
export declare function setupGlobals(env: Environment): void;
export declare class Interpreter {
global: Environment;
constructor(env?: Environment);
/**
* Run the program.
*/
run(program: Program): AnyRuntimeValue;
/**
* Evaluates expressions following the binary operation type.
*/
private evaluateBinaryExpression;
private evaluateArguments;
private applyFilter;
/**
* Evaluates expressions following the filter operation type.
*/
private evaluateFilterExpression;
/**
* Evaluates expressions following the test operation type.
*/
private evaluateTestExpression;
/**
* Evaluates expressions following the select operation type.
*/
private evaluateSelectExpression;
/**
* Evaluates expressions following the unary operation type.
*/
private evaluateUnaryExpression;
private evaluateTernaryExpression;
private evalProgram;
private evaluateBlock;
private evaluateIdentifier;
private evaluateCallExpression;
private evaluateSliceExpression;
private evaluateMemberExpression;
private evaluateSet;
private evaluateIf;
private evaluateFor;
/**
* See https://jinja.palletsprojects.com/en/3.1.x/templates/#macros for more information.
*/
private evaluateMacro;
private evaluateCallStatement;
private evaluateFilterStatement;
evaluate(statement: Statement | undefined, environment: Environment): AnyRuntimeValue;
}
export {};
//# sourceMappingURL=runtime.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runt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D;AAiGD,qBAAa,WAAW;IACvB,MAAM,EAAE,WAAW,CAAC;gBAER,GAAG,CAAC,EAAE,WAAW;IAI7B;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe;IAItC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA8GhC,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,WAAW;IAuZnB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAKhC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAQhC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,wBAAwB;IAyChC,OAAO,CAAC,WAAW;IAuCnB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,WAAW;IAsHnB;;OAEG;IACH,OAAO,CAAC,aAAa;IA2CrB,OAAO,CAAC,qBAAqB;IA0B7B,OAAO,CAAC,uBAAuB;IAK/B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,eAAe;CA0ErF"}

33
node_modules/@huggingface/jinja/dist/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/**
* Function that mimics Python's range() function.
* @param start The start value of the range.
* @param stop The stop value of the range. If not provided, start will be 0 and stop will be the provided start value.
* @param step The step value of the range. Defaults to 1.
* @returns The range of numbers.
*/
export declare function range(start: number, stop?: number, step?: number): number[];
/**
* Function that mimics Python's array slicing.
* @param array The array to slice.
* @param start The start index of the slice. Defaults to 0.
* @param stop The last index of the slice. Defaults to `array.length`.
* @param step The step value of the slice. Defaults to 1.
* @returns The sliced array.
*/
export declare function slice<T>(array: T[], start?: number, stop?: number, step?: number): T[];
/**
* Function that mimics Python's string.title() function.
* @param value The string to title case.
* @returns The title cased string.
*/
export declare function titleCase(value: string): string;
export declare function strftime_now(format: string): string;
/**
* A minimalistic implementation of Python's strftime function.
*/
export declare function strftime(date: Date, format: string): string;
/**
* Function that mimics Python's string.replace() function.
*/
export declare function replace(str: string, oldvalue: string, newvalue: string, count?: number | null): string;
//# sourceMappingURL=utils.d.ts.map

1
node_modules/@huggingface/jinja/dist/utils.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,MAAM,EAAE,CAqBtE;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,CAAC,EAAE,CAgBjF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CA6B3D;AAMD;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAYtG"}