Skip to content

Commit

Permalink
docs(readme): rename to placeholder from delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jun 3, 2023
1 parent 4566ad0 commit da29780
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ assertEquals(format("{0} world!", ["Hello"]), "Hello world!");
format("{0} world!", []);
```

### Delimiter
### Placeholder

A delimiter is a pair of prefix and suffix.
Placeholder is a pair of prefix and suffix.

| Name | Default |
| ------ | ------- |
Expand All @@ -83,12 +83,12 @@ import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
const result = format("should be ${expected}, actual ${actual}", {
expected: "string",
actual: "number",
}, { delimiters: [{ prefix: "${", suffix: "}" }] });
}, { placeholders: [{ prefix: "${", suffix: "}" }] });
assertEquals(result, "should be string, actual number");

//@ts-expect-error it should be error
format("should be ${expected}, actual ${actual}", {}, {
delimiters: [{ prefix: "${", suffix: "}" }],
placeholders: [{ prefix: "${", suffix: "}" }],
});
```

Expand All @@ -99,12 +99,12 @@ import { format } from "https://deno.land/x/format@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

const result = format("Hello %s!!!", { "": "world" }, {
delimiters: [{ prefix: "%", suffix: "s" }],
placeholders: [{ prefix: "%", suffix: "s" }],
});
assertEquals(result, "Hello world!!!");
```

Multiple delimiters:
Multiple placeholders:

```ts
import { format } from "https://deno.land/x/format@$VERSION/mod.ts";
Expand All @@ -115,16 +115,16 @@ const result = format("[0] {name}: {title}", {
name: "",
title: "",
}, {
delimiters: [
placeholders: [
{ prefix: "{", suffix: "}" },
{ prefix: "[", suffix: "]" },
],
});
assertEquals(result, "abcde{fg}ijk]a}");
```

The computational complexity of delimiter is O(n) compared to argument. It is
recommended to reduce the number of delimiters as much as possible.
The computational complexity of placeholder is O(n) compared to argument. It is
recommended to reduce the number of placeholders as much as possible.

### Custom serialization

Expand Down

0 comments on commit da29780

Please sign in to comment.