-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
59 lines (50 loc) · 1.22 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
import {LiteralUnion} from 'type-fest';
export interface Options {
/**
Include `Object.prototype` properties like `isPrototypeOf`.
@default true
*/
readonly includeObjectPrototype?: boolean;
/**
Include [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) keys.
@default true
*/
readonly includeSymbols?: boolean;
}
/**
Get all property keys of an object including non-enumerable and inherited ones. Like [Reflect.ownKeys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys) but traverses up the prototype-chain.
@returns All property names from `object`.
@example
```
import allKeys from 'all-keys';
Object.getOwnPropertyNames(Symbol.prototype);
/*
[
'constructor',
'toString',
'valueOf'
]
*\/
allKeys(Symbol.prototype);
/*
Set {
'constructor',
'toString',
'valueOf',
'toLocaleString',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'__defineGetter__',
'__lookupGetter__',
'__defineSetter__',
'__lookupSetter__',
'__proto__'
}
*\/
```
*/
export default function allKeys<ObjectType extends Record<string, any>>(
object: ObjectType,
options?: Options
): Set<LiteralUnion<keyof ObjectType, PropertyKey>>;