1
+ /* eslint-disable */
2
+
1
3
'use strict' ;
2
4
var _ = require ( 'lodash' ) ;
3
5
4
6
var BufferUtil = require ( './util/buffer' ) ;
5
7
var JSUtil = require ( './util/js' ) ;
6
- var networks = [ ] ;
7
- var networkMaps = { } ;
8
+ var networks : networkType [ ] = [ ] ;
9
+ var networkMaps : any = { } ;
8
10
9
11
/**
10
12
* A network is merely a map containing values that correspond to version
11
13
* numbers for each bitcoin network. Currently only supporting "livenet"
12
14
* (a.k.a. "mainnet") and "testnet".
13
15
* @constructor
14
16
*/
15
- function Network ( ) { }
17
+ export const Network : any = ( ) => { }
16
18
17
19
Network . prototype . toString = function toString ( ) {
18
20
return this . name ;
@@ -26,17 +28,15 @@ Network.prototype.toString = function toString() {
26
28
* @param {string|Array } keys - if set, only check if the magic number associated with this name matches
27
29
* @return Network
28
30
*/
29
- function get ( arg , keys ) {
31
+ function get ( arg ?: networkType , keys ?: keyType ) {
30
32
if ( ~ networks . indexOf ( arg ) ) {
31
33
return arg ;
32
34
}
33
35
if ( keys ) {
34
36
if ( ! _ . isArray ( keys ) ) {
35
37
keys = [ keys ] ;
36
38
}
37
- var containsArg = function ( key ) {
38
- return networks [ index ] [ key ] === arg ;
39
- } ;
39
+ var containsArg = ( key : keyType , index :number ) => networks [ index ] [ key ] === arg ;
40
40
for ( var index in networks ) {
41
41
if ( _ . some ( keys , containsArg ) ) {
42
42
return networks [ index ] ;
@@ -69,9 +69,9 @@ function get(arg, keys) {
69
69
* @param {Array } data.dnsSeeds - An array of dns seeds
70
70
* @return Network
71
71
*/
72
- function addNetwork ( data ) {
72
+ function addNetwork ( data : any ) {
73
73
74
- var network = new Network ( ) ;
74
+ var network : any = new Network ( ) ;
75
75
76
76
JSUtil . defineImmutable ( network , {
77
77
name : data . name ,
@@ -101,7 +101,7 @@ function addNetwork(data) {
101
101
dnsSeeds : data . dnsSeeds
102
102
} ) ;
103
103
}
104
- _ . each ( network , function ( value ) {
104
+ _ . each ( network , function ( value : any ) {
105
105
if ( ! _ . isUndefined ( value ) && ! _ . isObject ( value ) ) {
106
106
if ( ! networkMaps [ value ] ) {
107
107
networkMaps [ value ] = [ ] ;
@@ -122,7 +122,7 @@ function addNetwork(data) {
122
122
* Will remove a custom network
123
123
* @param {Network } network
124
124
*/
125
- function removeNetwork ( network ) {
125
+ function removeNetwork ( network : networkType ) {
126
126
for ( var i = 0 ; i < networks . length ; i ++ ) {
127
127
if ( networks [ i ] === network ) {
128
128
networks . splice ( i , 1 ) ;
0 commit comments