tagged-comment-parser
TypeScript icon, indicating that this package has built-in type declarations

1.3.6 • Public • Published

tagged-comment-parser

This is a simple parser for tagged comments.

import { parse, tryParse } from "tagged-comment-parser";

const result = parse("@cached @alias:foo this comment is tagged!");
/*
result:
{
  "comment": "this comment is tagged!",
  "tags": {
    "cached": true,
    "alias": "foo"
  }
}
*/

// If you want to avoid exceptions, use tryParse
const result = tryParse(null);
/*
result:
{
  "comment": undefined,
  "tags": {}
}
*/

The tags can appear as the first xor last part of the string.

Syntax

  • '@tag' (no value specified): tag will have a value of true
  • '@tag:something' (value after colon): tag will be the string 'something'
  • '@tag(12, "some string")' (parentheses with multiple values): tag will be the array ["12", "some string"]

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i tagged-comment-parser

    Weekly Downloads

    16,175

    Version

    1.3.6

    License

    MIT

    Unpacked Size

    31 kB

    Total Files

    10

    Last publish

    Collaborators

    • kristiandupont