{"id":20348981,"url":"https://github.com/here-be/snapdragon-token","last_synced_at":"2025-07-15T12:43:09.004Z","repository":{"id":57364573,"uuid":"110080249","full_name":"here-be/snapdragon-token","owner":"here-be","description":"Create a snapdragon token. Used by the snapdragon lexer, but can also be used by plugins.","archived":false,"fork":false,"pushed_at":"2018-04-26T10:44:45.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T23:05:18.371Z","etag":null,"topics":["compiler","javascript","lexer","node","nodejs","parser","snapdragon","token","tokenize","tokenizer"],"latest_commit_sha":null,"homepage":"https://github.com/here-be","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/here-be.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-09T07:09:30.000Z","updated_at":"2018-04-26T10:44:37.000Z","dependencies_parsed_at":"2022-09-13T21:00:50.213Z","dependency_job_id":null,"html_url":"https://github.com/here-be/snapdragon-token","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/here-be/snapdragon-token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/here-be","download_url":"https://codeload.github.com/here-be/snapdragon-token/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/here-be%2Fsnapdragon-token/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265293258,"owners_count":23742252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","javascript","lexer","node","nodejs","parser","snapdragon","token","tokenize","tokenizer"],"created_at":"2024-11-14T22:23:31.449Z","updated_at":"2025-07-15T12:43:08.951Z","avatar_url":"https://github.com/here-be.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snapdragon-token [![NPM version](https://img.shields.io/npm/v/snapdragon-token.svg?style=flat)](https://www.npmjs.com/package/snapdragon-token) [![NPM monthly downloads](https://img.shields.io/npm/dm/snapdragon-token.svg?style=flat)](https://npmjs.org/package/snapdragon-token) [![NPM total downloads](https://img.shields.io/npm/dt/snapdragon-token.svg?style=flat)](https://npmjs.org/package/snapdragon-token) [![Linux Build Status](https://img.shields.io/travis/here-be/snapdragon-token.svg?style=flat\u0026label=Travis)](https://travis-ci.org/here-be/snapdragon-token)\n\n\u003e Create a snapdragon token. Used by the snapdragon lexer, but can also be used by plugins.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save snapdragon-token\n```\n\n## Usage\n\n```js\nconst Token = require('snapdragon-token');\n```\n\n## API\n\n### [Token](index.js#L18)\n\nCreate a new `Token` with the given `value` and `type`.\n\n**Params**\n\n* `type` **{String|Object}**: The token type to use when `value` is a string.\n* `value` **{String}**: Value to set\n* `returns` **{Object}**: Token instance\n\n**Example**\n\n```js\nconst token = new Token('*', 'Star');\nconst token = new Token({type: 'star', value: '*'});\nconsole.log(token) //=\u003e Token { type: 'star', value: '*' }\n```\n\n## Release history\n\nSee [the changelog](CHANGELOG.md).\n\n## Token objects\n\nLexer tokens are represented as `Token` objects that implement the following interface:\n\n```js\ninterface Token {\n  type: string;\n  value: string;\n  match: array | undefined;\n}\n```\n\n### Token properties\n\n* `type` **{string}** - A string representing the token variant type. This property is necessary for classifying one or more characters so that parsers or compilers can determine what to do with the token.\n* `value` **{string}** - The substring (or [lexeme](#lexeme)) that was captured for the token.\n* `match` **{array|undefined}** - If a regular expression was used to capture a substring, the `RegExp.exec()` or `String.match()` arguments array can be stored on the token.\n\n**Source location**\n\nAdd the source location (start, end, index and range) information to tokens using either of the following plugins (depending on preference for property naming conventions):\n\n* [snapdragon-position](https://github.com/here-be/snapdragon-position)\n* [snapdragon-location](https://github.com/here-be/snapdragon-location)\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [snapdragon-node](https://www.npmjs.com/package/snapdragon-node): Snapdragon utility for creating a new AST node in custom code, such as plugins. | [homepage](https://github.com/jonschlinkert/snapdragon-node \"Snapdragon utility for creating a new AST node in custom code, such as plugins.\")\n* [snapdragon-util](https://www.npmjs.com/package/snapdragon-util): Utilities for the snapdragon parser/compiler. | [homepage](https://github.com/here-be/snapdragon-util \"Utilities for the snapdragon parser/compiler.\")\n* [snapdragon](https://www.npmjs.com/package/snapdragon): Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map… [more](https://github.com/here-be/snapdragon) | [homepage](https://github.com/here-be/snapdragon \"Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map support.\")\n\n### Author\n\n**Jon Schlinkert**\n\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 26, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhere-be%2Fsnapdragon-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhere-be%2Fsnapdragon-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhere-be%2Fsnapdragon-token/lists"}