Skip to content

Commit cb8dd54

Browse files
committed
fix: update import path for Collection type definition and improve types
Ref: stdlib-js@bde4671
1 parent 33f4a75 commit cb8dd54

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

lib/node_modules/@stdlib/utils/circular-buffer/docs/types/index.d.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,33 @@
2020

2121
/// <reference types="@stdlib/types"/>
2222

23-
import { IterableIterator } from '@stdlib/types/iter';
24-
import { Collection } from '@stdlib/types/object';
23+
import { TypedIterableIterator } from '@stdlib/types/iter';
24+
import { Collection } from '@stdlib/types/array';
25+
26+
/**
27+
* Interface describing a JSON-serialized circular buffer.
28+
*/
29+
interface JSON<T> {
30+
/**
31+
* Object type.
32+
*/
33+
type: 'circular-buffer';
34+
35+
/**
36+
* Number of elements.
37+
*/
38+
length: number;
39+
40+
/**
41+
* Buffer elements.
42+
*/
43+
data: Array<T>;
44+
}
2545

2646
/**
2747
* Circular buffer.
2848
*/
29-
declare class CircularBuffer {
49+
declare class CircularBuffer<T> {
3050
/**
3151
* Circular buffer constructor.
3252
*
@@ -51,7 +71,7 @@ declare class CircularBuffer {
5171
* v = b.push( 'boop' );
5272
* // returns 'foo'
5373
*/
54-
constructor( buffer: number | Collection );
74+
constructor( buffer: number | Collection<T> );
5575

5676
/**
5777
* Clears the buffer.
@@ -78,7 +98,7 @@ declare class CircularBuffer {
7898
* n = b.count;
7999
* // returns 0
80100
*/
81-
clear(): CircularBuffer;
101+
clear(): CircularBuffer<T>;
82102

83103
/**
84104
* Number of elements currently in the buffer.
@@ -158,7 +178,7 @@ declare class CircularBuffer {
158178
* var bool = it.next().done;
159179
* // returns true
160180
*/
161-
iterator( niters?: number ): IterableIterator;
181+
iterator( niters?: number ): TypedIterableIterator<T>;
162182

163183
/**
164184
* Circular buffer length (i.e., capacity).
@@ -175,6 +195,7 @@ declare class CircularBuffer {
175195
/**
176196
* Adds a value to the circular buffer.
177197
*
198+
* @param value - value to add
178199
* @returns removed element or undefined
179200
*
180201
* @example
@@ -194,7 +215,7 @@ declare class CircularBuffer {
194215
* v = b.push( 'boop' );
195216
* // returns 'foo'
196217
*/
197-
push(): any;
218+
push( value: T ): T;
198219

199220
/**
200221
* Returns an array of circular buffer values.
@@ -214,7 +235,7 @@ declare class CircularBuffer {
214235
* var vals = b.toArray();
215236
* // returns [ 'bar', 'beep', 'boop' ]
216237
*/
217-
toArray(): Array<any>;
238+
toArray(): Array<T>;
218239

219240
/**
220241
* Serializes a circular buffer as JSON.
@@ -238,7 +259,7 @@ declare class CircularBuffer {
238259
* var o = b.toJSON();
239260
* // returns { 'type': 'circular-buffer', 'length': 3, 'data': [ 'bar', 'beep', 'boop' ] }
240261
*/
241-
toJSON(): any;
262+
toJSON(): JSON<T>;
242263
}
243264

244265

lib/node_modules/@stdlib/utils/circular-buffer/docs/types/test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
import CircularBuffer = require( './index' );
2222

2323

24+
// FIXME: add tests
25+
26+
2427
// TESTS //
2528

2629
// The function returns a circular buffer instance...
2730
{
28-
new CircularBuffer( 3 ); // $ExpectType CircularBuffer
31+
new CircularBuffer( 3 ); // $ExpectType CircularBuffer<unknown>
2932
}
3033

3134
// The compiler throws an error if the constructor function is provided an invalid number of arguments...

0 commit comments

Comments
 (0)