query-registry
Version:
Query the npm registry for packuments, manifests, packages and download counts
15 lines (12 loc) • 465 B
text/typescript
/**
* `getUntypedName` returns the name of the normal package
* corresponding to a DefinitelyTyped package.
*/
export function getUntypedName({ name }: { name: string }): string | undefined {
if (!name.startsWith('@types/')) {
return undefined;
}
// ['foo', undefined] or ['@bar', 'baz']
const [scopeOrName, scopedName] = name.replace('@types/', '').split('__');
return scopedName ? `@${scopeOrName}/${scopedName}` : scopeOrName;
}