UNPKG

@speedy-js/depcost

Version:

[![npm version](https://badgen.net/npm/v/@speedy-js/depcost)](https://npm.im/@speedy-js/depcost)

13 lines (11 loc) 247 B
module.exports = function (name) { const REG = /(@?[^@]+)@?(.*)?/ const matched = name.match(REG) if (matched) { return { name: matched[1], version: matched[2], } } throw new Error(`Invalid package name: ${name}`) }