This repository was archived by the owner on Oct 3, 2023. It is now read-only.
File tree 8 files changed +51
-16
lines changed
8 files changed +51
-16
lines changed Original file line number Diff line number Diff line change 1
1
{
2
+ "tags" : {
3
+ "allowUnknownTags" : true
4
+ },
2
5
"source" : {
3
6
"include" : [" src/" ],
4
7
"exclude" : [" node_modules" ]
5
8
},
6
9
"opts" : {
7
10
"destination" : " src/" ,
8
11
"template" : " ./node_modules/tsd-jsdoc/dist"
9
- }
12
+ },
13
+ "plugins" : [" ./node_modules/jsdoc-export-default-interop/dist/index" ]
14
+
10
15
}
Original file line number Diff line number Diff line change 23
23
script :
24
24
- npx aegir dep-check
25
25
- npm run lint
26
- - npm run generate-typings
27
26
28
27
- stage : test
29
28
name : chrome
Original file line number Diff line number Diff line change 33
33
"aegir" : " ^20.0.0" ,
34
34
"chai" : " ^4.2.0" ,
35
35
"jsdoc" : " ^3.6.3" ,
36
+ "jsdoc-export-default-interop" : " ^0.3.1" ,
36
37
"tsd-jsdoc" : " ^2.3.1" ,
37
38
"typescript-definition-tester" : " 0.0.6"
38
39
},
Original file line number Diff line number Diff line change 1
1
/**
2
- * @module js- libp2p-bootstrap
2
+ * @module libp2p-bootstrap
3
3
*/
4
4
'use strict'
5
5
@@ -14,14 +14,14 @@ const log = debug('libp2p:bootstrap')
14
14
log . error = debug ( 'libp2p:bootstrap:error' )
15
15
16
16
/**
17
- * Emits 'peer' events on a regular interval for each peer in the provided list.
18
17
* @class
19
- * @memberof module:js- libp2p-bootstrap
18
+ * @memberof module:libp2p-bootstrap
20
19
*/
21
20
class Bootstrap extends EventEmitter {
22
21
/**
23
- * Constructs a new Bootstrap.
22
+ * Emits 'peer' events on a regular interval for each peer in the provided list
24
23
*
24
+ * @constructs
25
25
* @param {Object } options
26
26
* @param {Array<string> } options.list - the list of peer addresses in multi-address format
27
27
* @param {number } [options.interval] - the interval between emitting addresses (in milli-seconds)
@@ -49,6 +49,7 @@ class Bootstrap extends EventEmitter {
49
49
50
50
/**
51
51
* Emit each address in the list as a PeerInfo.
52
+ * @ignore
52
53
*/
53
54
_discoverBootstrapPeers ( ) {
54
55
this . _list . forEach ( async ( candidate ) => {
Original file line number Diff line number Diff line change 1
1
/**
2
- * @module js- libp2p-bootstrap
2
+ * @module libp2p-bootstrap
3
3
*/
4
- declare module "js- libp2p-bootstrap" {
4
+ declare module "libp2p-bootstrap" {
5
5
/**
6
- * Constructs a new Bootstrap .
6
+ * Emits 'peer' events on a regular interval for each peer in the provided list .
7
7
*
8
+ * @constructs
8
9
* @param {Object } options
9
10
* @param {Array<string> } options.list - the list of peer addresses in multi-address format
10
11
* @param {number } [options.interval] - the interval between emitting addresses (in milli-seconds)
@@ -19,10 +20,6 @@ declare module "js-libp2p-bootstrap" {
19
20
* Start emitting events.
20
21
*/
21
22
start ( ) : void ;
22
- /**
23
- * Emit each address in the list as a PeerInfo.
24
- */
25
- _discoverBootstrapPeers ( ) : void ;
26
23
/**
27
24
* Stop emitting events.
28
25
*/
@@ -32,5 +29,18 @@ declare module "js-libp2p-bootstrap" {
32
29
* @type string
33
30
*/
34
31
var tag : string ;
32
+
33
+ /**
34
+ * NB: Always include the snippet below because its not
35
+ * generated by tsd-jsdoc else the test would keep failing
36
+ *
37
+ * Due to some wierd behaviour in Node.JS module resolution
38
+ * it's not possible to access 'Bootstrap' via dot notation
39
+ * even though its exported as
40
+ * ```
41
+ * exports = module.exports = Bootstrap
42
+ * ```
43
+ */
44
+ export default Bootstrap ;
35
45
}
36
46
Original file line number Diff line number Diff line change 1
1
/* eslint-env mocha */
2
2
'use strict'
3
+ /// <reference path="../../src/types.d.ts" />
3
4
4
5
const tt = require ( 'typescript-definition-tester' )
5
6
// typings test should run only in the node
@@ -8,8 +9,21 @@ describe('typings declaration tests', () => {
8
9
it ( 'should compile typings examples successfully against types.d.ts' , ( done ) => {
9
10
tt . compileDirectory (
10
11
`${ __dirname } /typings` ,
11
- ( fileName ) => fileName . indexOf ( '.ts' ) > - 1 ,
12
+ ( fileName ) => fileName . indexOf ( '.pass. ts' ) > - 1 ,
12
13
( error ) => done ( error )
13
14
)
14
15
} )
16
+
17
+ it ( 'should fail to compile typings examples successfully against types.d.ts' , ( done ) => {
18
+ tt . compileDirectory (
19
+ `${ __dirname } /typings` ,
20
+ ( fileName ) => fileName . indexOf ( '.fail.ts' ) > - 1 ,
21
+ ( error ) => {
22
+ if ( error ) {
23
+ return done ( null )
24
+ }
25
+ done ( new Error ( 'Should throw compilation error as Bootstrap is default export' ) )
26
+ }
27
+ )
28
+ } )
15
29
} )
Original file line number Diff line number Diff line change 1
1
/// <reference path="../../src/types.d.ts" />
2
-
3
- import { Bootstrap } from "js-libp2p-bootstrap" ;
2
+ import { Bootstrap } from "libp2p-bootstrap" ;
4
3
const bootstrap1 = new Bootstrap ( { list : [ "item" ] , interval : 1 } )
5
4
bootstrap1 . start ( )
Original file line number Diff line number Diff line change
1
+ /// <reference path="../../src/types.d.ts" />
2
+
3
+ import Bootstrap from "libp2p-bootstrap" ;
4
+ const bootstrap1 = new Bootstrap ( { list : [ "item" ] , interval : 1 } )
5
+ bootstrap1 . start ( )
6
+ bootstrap1 . stop ( )
You can’t perform that action at this time.
0 commit comments