Skip to content

Commit ad5a713

Browse files
committed
fix: rename primitivetype
1 parent 823fd7c commit ad5a713

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

formatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Interpreter } from "./interpreter.ts";
22
import type {
33
FormatParameters,
4-
FormatParameterValue,
54
Plugin,
5+
PrimitiveType,
66
Runtime,
77
} from "./types.ts";
88

@@ -33,7 +33,7 @@ export class Formatter {
3333
}
3434

3535
function createDecorator(locale: string, plugin: Plugin) {
36-
return (self: FormatParameterValue) => {
36+
return (self: PrimitiveType) => {
3737
let current = self;
3838
const metadata = {} as Record<string, unknown>;
3939
const decorated = new Proxy({}, {

interpreter.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assertEquals } from "@std/assert";
22
import { Interpreter } from "./interpreter.ts";
3-
import type { FormatParameterValue } from "./types.ts";
3+
import type { PrimitiveType } from "./types.ts";
44

55
Deno.test("interpreter, very simple text", () => {
66
const runtime = new Interpreter();
@@ -33,7 +33,7 @@ Deno.test("interpreter, basic template value", () => {
3333
Deno.test("interpreter, template value with method", () => {
3434
const runtime = new Interpreter();
3535

36-
const createParams = (name: FormatParameterValue) => ({
36+
const createParams = (name: PrimitiveType) => ({
3737
_: name,
3838
() {
3939
this._ += "이";

interpreter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import type { AstTemplate } from "./ast.ts";
22
import { parse } from "./parse.ts";
3-
import type {
4-
FormatParameters,
5-
FormatParameterValue,
6-
Runtime,
7-
} from "./types.ts";
3+
import type { FormatParameters, PrimitiveType, Runtime } from "./types.ts";
84

95
export class Interpreter implements Runtime {
106
_cache: Map<string, AstTemplate> = new Map();
117

128
execute(
139
text: string,
1410
parameters: FormatParameters,
15-
decorateValue?: (value: FormatParameterValue) => unknown,
11+
decorateValue?: (value: PrimitiveType) => unknown,
1612
): string {
1713
let ast = this._cache.get(text);
1814
if (!ast) {
@@ -25,7 +21,7 @@ export class Interpreter implements Runtime {
2521
executeAst(
2622
ast: AstTemplate,
2723
parameters: FormatParameters,
28-
decorateValue?: (value: FormatParameterValue) => unknown,
24+
decorateValue?: (value: PrimitiveType) => unknown,
2925
): string {
3026
const [strings, values] = ast;
3127
let result = strings[0] ?? "";

mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export type {
22
FormatParameters,
3-
FormatParameterValue,
43
Plugin,
54
PluginContext,
65
PluginHook,
6+
PrimitiveType,
77
Runtime,
88
} from "./types.ts";
99

types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
export type FormatParameterValue = string | number | bigint | boolean | null;
2-
export type FormatParameters = Record<string, FormatParameterValue>;
1+
export type PrimitiveType = string | number | boolean | null | undefined | Date;
2+
export type FormatParameters = Record<string, PrimitiveType>;
33

44
export interface Runtime {
55
execute(
66
text: string,
77
parameters: FormatParameters,
8-
decorateValue?: (value: FormatParameterValue) => unknown,
8+
decorateValue?: (value: PrimitiveType) => unknown,
99
): string;
1010
}
1111

1212
export interface PluginContext {
1313
locale: string;
14-
self: FormatParameterValue;
15-
current: FormatParameterValue;
14+
self: PrimitiveType;
15+
current: PrimitiveType;
1616
args: (string | number | (() => string))[];
1717
metadata: Record<string | symbol, unknown>;
1818
}
1919

20-
export type PluginHook = (ctx: PluginContext) => FormatParameterValue;
20+
export type PluginHook = (ctx: PluginContext) => PrimitiveType;
2121

2222
export interface Plugin {
2323
[name: string]: PluginHook;

0 commit comments

Comments
 (0)