From ffec399ae579daf2e789482c7fe48af22991a75a Mon Sep 17 00:00:00 2001 From: Kael Zhang Date: Wed, 17 Aug 2022 12:25:19 +0800 Subject: [PATCH] 4.2.3: #35, adjust layout --- README.md | 10 +++++++--- package.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3ddd7d3..51e6a67 100644 --- a/README.md +++ b/README.md @@ -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) ``` diff --git a/package.json b/package.json index d1af9ac..51bce5a 100644 --- a/package.json +++ b/package.json @@ -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": {