-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
205 lines (164 loc) · 3.62 KB
/
repl.txt
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
{{alias}}( buffer )
Circular buffer constructor.
Parameters
----------
buffer: integer|ArrayLike
Buffer size or an array-like object to use as the underlying buffer.
Returns
-------
buf: Object
Circular buffer data structure.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.length
3
> b.count
3
> b.push( 'boop' )
'foo'
{{alias}}.prototype.clear()
Clears a buffer.
Returns
-------
out: Object
Circular buffer instance.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.count
3
> b.clear();
> b.count
0
{{alias}}.prototype.count
Read-only property returning the number of elements currently in the buffer.
Returns
-------
out: integer
Number of elements currently in the buffer.
Examples
--------
> var b = {{alias}}( 3 );
> b.count
0
> b.push( 'foo' );
> b.count
1
> b.push( 'bar' );
> b.count
2
{{alias}}.prototype.full
Read-only property returning a boolean indicating whether a circular buffer
is full.
Returns
-------
out: boolean
Boolean indicating whether a circular buffer is full.
Examples
--------
> var b = {{alias}}( 3 );
> b.full
false
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.full
true
{{alias}}.prototype.iterator( [niters] )
Returns an iterator for iterating over a circular buffer.
A returned iterator does not iterate over partially full buffers.
Parameters
----------
niters: integer (optional)
Number of iterations. Default: infinity.
Returns
-------
out: Iterator
Iterator.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.push( 'boop' );
> var it = b.iterator( b.length );
> var v = it.next().value
'bar'
> v = it.next().value
'beep'
> v = it.next().value
'boop'
> var bool = it.next().done
true
{{alias}}.prototype.length
Read-only property returning the buffer length (i.e., capacity).
Returns
-------
out: integer
Buffer length.
Examples
--------
> var b = {{alias}}( [ 0, 0, 0 ] );
> var len = b.length
3
{{alias}}.prototype.push( value )
Adds a value to a circular buffer.
Parameters
----------
value: any
Value to add.
Returns
-------
out: any
Removed element (or undefined).
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' )
undefined
> b.push( 'bar' )
undefined
> b.push( 'beep' )
undefined
> b.push( 'boop' )
'foo'
{{alias}}.prototype.toArray()
Returns an array of circular buffer values.
Returns
-------
out: Array
Circular buffer values.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.push( 'boop' );
> var vals = b.toArray()
[ 'bar', 'beep', 'boop' ]
{{alias}}.prototype.toJSON()
Serializes a circular buffer as JSON.
Returns
-------
out: Object
Serialized circular buffer.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.push( 'boop' );
> var o = b.toJSON()
{'type':'circular-buffer','length':3,'data':['bar','beep','boop']}
See Also
--------