@pobedit/package-name-parser
A package name parser.
Installation
Install with npm or Yarn:
npm:
npm install @pobedit/package-name-parser --save
Yarn:
yarn add @pobedit/package-name
Basic usage
import {parse} from '@pobedit/package-name-parser';
try {
const {scope, name, version} = parse('@foo/bar@0.0.1');
console.log(scope, name, version);
/*
{
scope: 'foo',
name: 'bar',
version: '0.0.1'
}
*/
}
catch ({message}) {
console.error(message);
}
scope
and version
are optional:
parse('foo');
parse('@foo/bar');
parse('@foo/bar@0.0.1');
Contributing
Feel free to submit a pull request if you find any bugs. Please make sure all commits are properly documented.
Tests
npm test
Publishing
npm publish --access public --verbose
License
MIT