Skip to content

Commit

Permalink
4.2.3: #35, adjust layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Aug 17, 2022
1 parent 80fcd67 commit ffec399
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,18 @@ interface Location {
### Query comments in TypeScript
`comment-json` provides a `symbol`-type called `CommentSymbol` which can be used for querying comments.
`comment-json` provides a `symbol`-type called `CommentSymbol` which can be used for querying comments.
Furthermore, a type `CommentDescriptor` is provided for enforcing properly formatted symbol names:
```ts
import { CommentDescriptor, CommentSymbol, parse } from "comment-json"
import {
CommentDescriptor, CommentSymbol, parse
} from 'comment-json'

const parsed = parse(`{ /* test */ "foo": "bar" }`)
const symbolName: CommentDescriptor: "before-prop:foo"; // typescript only allows properly formatted symbol names here
// typescript only allows properly formatted symbol names here
const symbolName: CommentDescriptor: 'before-prop:foo'

console.log(parsed[Symbol.for(symbolName) as CommentSymbol][0].value)
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "comment-json",
"version": "4.2.2",
"version": "4.2.3",
"description": "Parse and stringify JSON with comments. It will retain comments even after saved!",
"main": "src/index.js",
"scripts": {
Expand Down

0 comments on commit ffec399

Please sign in to comment.