Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/generated/ts/bytes.ts
2070 views
1
2
3
/**
4
* Buffer is a bytes/Uint8Array type in javascript
5
* @example
6
* ```javascript
7
* const bytes = require('nuclei/bytes');
8
* const bytes = new bytes.Buffer();
9
* ```
10
* @example
11
* ```javascript
12
* const bytes = require('nuclei/bytes');
13
* // optionally it can accept existing byte/Uint8Array as input
14
* const bytes = new bytes.Buffer([1, 2, 3]);
15
* ```
16
*/
17
export class Buffer {
18
19
20
// Constructor of Buffer
21
constructor() {}
22
/**
23
* Write appends the given data to the buffer.
24
* @example
25
* ```javascript
26
* const bytes = require('nuclei/bytes');
27
* const buffer = new bytes.Buffer();
28
* buffer.Write([1, 2, 3]);
29
* ```
30
*/
31
public Write(data: Uint8Array): Buffer {
32
return this;
33
}
34
35
36
/**
37
* WriteString appends the given string data to the buffer.
38
* @example
39
* ```javascript
40
* const bytes = require('nuclei/bytes');
41
* const buffer = new bytes.Buffer();
42
* buffer.WriteString('hello');
43
* ```
44
*/
45
public WriteString(data: string): Buffer {
46
return this;
47
}
48
49
50
/**
51
* Bytes returns the byte representation of the buffer.
52
* @example
53
* ```javascript
54
* const bytes = require('nuclei/bytes');
55
* const buffer = new bytes.Buffer();
56
* buffer.WriteString('hello');
57
* log(buffer.Bytes());
58
* ```
59
*/
60
public Bytes(): Uint8Array {
61
return new Uint8Array(8);
62
}
63
64
65
/**
66
* String returns the string representation of the buffer.
67
* @example
68
* ```javascript
69
* const bytes = require('nuclei/bytes');
70
* const buffer = new bytes.Buffer();
71
* buffer.WriteString('hello');
72
* log(buffer.String());
73
* ```
74
*/
75
public String(): string {
76
return "";
77
}
78
79
80
/**
81
* Len returns the length of the buffer.
82
* @example
83
* ```javascript
84
* const bytes = require('nuclei/bytes');
85
* const buffer = new bytes.Buffer();
86
* buffer.WriteString('hello');
87
* log(buffer.Len());
88
* ```
89
*/
90
public Len(): number {
91
return 0;
92
}
93
94
95
/**
96
* Hex returns the hex representation of the buffer.
97
* @example
98
* ```javascript
99
* const bytes = require('nuclei/bytes');
100
* const buffer = new bytes.Buffer();
101
* buffer.WriteString('hello');
102
* log(buffer.Hex());
103
* ```
104
*/
105
public Hex(): string {
106
return "";
107
}
108
109
110
/**
111
* Hexdump returns the hexdump representation of the buffer.
112
* @example
113
* ```javascript
114
* const bytes = require('nuclei/bytes');
115
* const buffer = new bytes.Buffer();
116
* buffer.WriteString('hello');
117
* log(buffer.Hexdump());
118
* ```
119
*/
120
public Hexdump(): string {
121
return "";
122
}
123
124
125
/**
126
* Pack uses structs.Pack and packs given data and appends it to the buffer.
127
* it packs the data according to the given format.
128
* @example
129
* ```javascript
130
* const bytes = require('nuclei/bytes');
131
* const buffer = new bytes.Buffer();
132
* buffer.Pack('I', 123);
133
* ```
134
*/
135
public Pack(formatStr: string, msg: any): void {
136
return;
137
}
138
139
140
}
141
142
143