forked from sindresorhus/npm-name
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
62 lines (50 loc) · 1.32 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
declare class InvalidNameErrorClass extends Error {}
declare const npmName: {
/**
Check whether a package name is available (not registered) on npm.
@param name - Name to check.
@returns Whether the given name is available.
@example
```
import npmName = require('npm-name');
(async () => {
console.log(await npmName('chalk'));
//=> false
try {
await npmName('_ABC');
} catch (error) {
console.log(error.message);
// Invalid package name: _ABC
// - name cannot start with an underscore
// - name can no longer contain capital letters
}
})();
```
*/
(name: string): Promise<boolean>;
/**
Check whether multiple package names are available (not registered) on npm.
@param names - Multiple names to check.
@returns A `Map` of name and status.
@example
```
import npmName = require('npm-name');
(async () => {
const result = await npmName.many(['chalk', '@sindresorhus/is', 'abc123']);
console.log(result.get('chalk'));
//=> false
console.log(result.get('@sindresorhus/is'));
//=> false
console.log(result.get('abc123'));
//=> true
})();
```
*/
many<NameType extends string>(
names: NameType[]
): Promise<Map<NameType, boolean>>;
InvalidNameError: typeof InvalidNameErrorClass;
// TODO: remove this in the next major version
default: typeof npmName;
};
export = npmName;