{"id":23377992,"url":"https://github.com/beyondjs/specifier-parser","last_synced_at":"2025-04-08T04:50:04.384Z","repository":{"id":64126106,"uuid":"572996706","full_name":"beyondjs/specifier-parser","owner":"beyondjs","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-24T12:49:34.000Z","size":103,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-23T21:37:27.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beyondjs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-01T13:34:17.000Z","updated_at":"2024-01-24T12:50:07.000Z","dependencies_parsed_at":"2024-12-21T18:33:59.665Z","dependency_job_id":"712117dd-c421-4359-be50-5ff002e04c50","html_url":"https://github.com/beyondjs/specifier-parser","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"c7f4ebfd659d4de46d314ed8d3378623297d7c5f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fspecifier-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fspecifier-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fspecifier-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beyondjs%2Fspecifier-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beyondjs","download_url":"https://codeload.github.com/beyondjs/specifier-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247779763,"owners_count":20994572,"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":[],"created_at":"2024-12-21T18:33:45.718Z","updated_at":"2025-04-08T04:50:04.346Z","avatar_url":"https://github.com/beyondjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @beyond-js/specifier-parser\n\n`@beyond-js/specifier-parser` is a TypeScript package developed for internal use by the BeyondJS framework, a universal\nand modular TypeScript-first framework that emphasizes modularity and efficient bundling of modules, akin to what\nSkypack or JSPM offer. This package provides robust functionality for parsing and validating module specifiers, crucial\nfor managing module references within the BeyondJS ecosystem and beyond.\n\nA module specifier is a string that identifies a module within a project or as an external dependency, encapsulating\ndetails such as the package name, version, scope, and subpaths. `@beyond-js/specifier-parser` simplifies handling these\nspecifiers, offering an intuitive API for extracting and validating their components.\n\n## Features\n\n-   Parses module specifiers into their constituent components: package name, version, scope, and subpaths.\n-   Validates the correctness of module specifiers, ensuring they meet the standards required by BeyondJS and other\n    module bundlers.\n-   Allows serialization of parsed specifiers back into their original string format.\n-   Provides clear error messages for invalid specifiers to aid in troubleshooting and correction.\n\n## Installation\n\nInstall `@beyond-js/specifier-parser` using npm or yarn:\n\n```bash\nnpm install @beyond-js/specifier-parser\n```\n\nor\n\n```bash\nyarn add @beyond-js/specifier-parser\n```\n\n## Usage\n\nHere is how you can use `@beyond-js/specifier-parser` within your BeyondJS projects or any JavaScript/TypeScript module:\n\n```typescript\nimport { PackageSpecifier } from '@beyond-js/specifier-parser/main';\n\nconst specifier = new PackageSpecifier('@scope/package-name@1.0.0/subpath');\n\nconsole.log(`Package: ${specifier.pkg}`); // Outputs: @scope/package-name\nconsole.log(`Version: ${specifier.version}`); // Outputs: 1.0.0\nconsole.log(`Subpath: ${specifier.subpath}`); // Outputs: ./subpath\nconsole.log(`Valid: ${specifier.valid}`); // Outputs: true\n```\n\n## API Reference\n\n### `PackageSpecifier`\n\nThe primary class exported by `@beyond-js/specifier-parser/main`, designed for parsing and validating module specifiers.\n\n#### Constructor\n\n-   **`constructor(value: string)`**: Initializes a new instance with the given module specifier string.\n\n#### Properties\n\n-   **`value`**: The original module specifier string.\n-   **`pkg`**: Package name, including scope if provided.\n-   **`vpkg`**: Full package string with version, if specified.\n-   **`version`**: The specified version of the package, if any.\n-   **`subpath`**: The subpath within the package.\n-   **`specifier`**: The complete specifier combining the package name and subpath.\n-   **`error`**: An error message if the specifier is deemed invalid; otherwise, undefined.\n-   **`valid`**: A boolean indicating the validity of the specifier.\n\n#### Methods\n\n-   **`toJSON()`**: Serializes the class instance to a plain object, detailing the parsed components and the validity of\n    the module specifier.\n\n## BeyondJS Framework\n\n`@beyond-js/specifier-parser` is tailored for the BeyondJS framework, enhancing its module handling capabilities.\nDevelopers using or considering BeyondJS for their projects are encouraged to explore its functionalities further.\nBeyondJS is available on npm as the `beyond` package. As a modular framework, BeyondJS facilitates the bundling of\nmodules in a manner similar to Skypack or JSPM, optimizing development and deployment workflows.\n\n## Contributing\n\nContributions to `@beyond-js/specifier-parser` are warmly welcomed. Whether you're fixing a bug, proposing new features,\nor improving documentation, your help is appreciated. Please follow the standard GitHub fork-and-pull request workflow\nto submit your contributions.\n\n## License\n\n`@beyond-js/specifier-parser` is licensed under the MIT License. See the LICENSE file in the source repository for more\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fspecifier-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeyondjs%2Fspecifier-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeyondjs%2Fspecifier-parser/lists"}