forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ref-union.d.ts
64 lines (55 loc) · 2.04 KB
/
ref-union.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
63
64
// Type definitions for ref-union
// Project: https://github.com/TooTallNate/ref-union
// Definitions by: Paul Loyd <https://github.com/loyd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node-ffi/node-ffi-buffer.d.ts" />
/// <reference path="../ref/ref.d.ts" />
declare module "ref-union" {
import ref = require('ref');
/**
* This is the `constructor` of the Struct type that gets returned.
*
* Invoke it with `new` to create a new Buffer instance backing the union.
* Pass it an existing Buffer instance to use that as the backing buffer.
* Pass in an Object containing the union fields to auto-populate the
* union with the data.
*
* @constructor
*/
interface UnionType extends ref.Type {
/** Pass it an existing Buffer instance to use that as the backing buffer. */
new (arg: Buffer, data?: {}): any;
new (data?: {}): any;
/** Pass it an existing Buffer instance to use that as the backing buffer. */
(arg: Buffer, data?: {}): any;
(data?: {}): any;
fields: {[key: string]: {type: ref.Type}};
/**
* Adds a new field to the union instance with the given name and type.
* Note that this function will throw an Error if any instances of the union
* type have already been created, therefore this function must be called at the
* beginning, before any instances are created.
*/
defineProperty(name: string, type: ref.Type): void;
/**
* Adds a new field to the union instance with the given name and type.
* Note that this function will throw an Error if any instances of the union
* type have already been created, therefore this function must be called at the
* beginning, before any instances are created.
*/
defineProperty(name: string, type: string): void;
/**
* Custom for union type instances.
* @override
*/
toString(): string;
}
/** The union type meta-constructor. */
var UnionType: {
new (fields?: {}): UnionType;
new (fields?: any[]): UnionType;
(fields?: {}): UnionType;
(fields?: any[]): UnionType;
}
export = UnionType;
}