@libp2p/utils 5.1.1-388d02b33 → 5.1.1-581574d6d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Metrics } from '@libp2p/interface';
|
|
2
|
+
export interface CreateTrackedListInit {
|
|
3
|
+
/**
|
|
4
|
+
* The metric name to use
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* A metrics implementation
|
|
9
|
+
*/
|
|
10
|
+
metrics?: Metrics;
|
|
11
|
+
}
|
|
12
|
+
export declare function trackedList<V>(config: CreateTrackedListInit): V[];
|
|
13
|
+
//# sourceMappingURL=tracked-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracked-list.d.ts","sourceRoot":"","sources":["../../src/tracked-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAE,CAAC,EAAG,MAAM,EAAE,qBAAqB,GAAG,CAAC,EAAE,CAWnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracked-list.js","sourceRoot":"","sources":["../../src/tracked-list.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,WAAW,CAAM,MAA6B;IAC5D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAChC,MAAM,IAAI,GAAQ,EAAE,CAAA;IAEpB,OAAO,EAAE,cAAc,CAAC,IAAI,EAAE;QAC5B,SAAS,EAAE,GAAG,EAAE;YACd,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/utils",
|
|
3
|
-
"version": "5.1.1-
|
|
3
|
+
"version": "5.1.1-581574d6d",
|
|
4
4
|
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/utils#readme",
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"types": "./dist/src/stream-to-ma-conn.d.ts",
|
|
85
85
|
"import": "./dist/src/stream-to-ma-conn.js"
|
|
86
86
|
},
|
|
87
|
+
"./tracked-list": {
|
|
88
|
+
"types": "./dist/src/tracked-list.d.ts",
|
|
89
|
+
"import": "./dist/src/tracked-list.js"
|
|
90
|
+
},
|
|
87
91
|
"./tracked-map": {
|
|
88
92
|
"types": "./dist/src/tracked-map.d.ts",
|
|
89
93
|
"import": "./dist/src/tracked-map.js"
|
|
@@ -111,8 +115,8 @@
|
|
|
111
115
|
},
|
|
112
116
|
"dependencies": {
|
|
113
117
|
"@chainsafe/is-ip": "^2.0.2",
|
|
114
|
-
"@libp2p/interface": "1.1.0-
|
|
115
|
-
"@libp2p/peer-collections": "5.1.2-
|
|
118
|
+
"@libp2p/interface": "1.1.0-581574d6d",
|
|
119
|
+
"@libp2p/peer-collections": "5.1.2-581574d6d",
|
|
116
120
|
"@multiformats/multiaddr": "^12.1.10",
|
|
117
121
|
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
118
122
|
"get-iterator": "^2.0.1",
|
|
@@ -125,8 +129,8 @@
|
|
|
125
129
|
"uint8arraylist": "^2.4.3"
|
|
126
130
|
},
|
|
127
131
|
"devDependencies": {
|
|
128
|
-
"@libp2p/logger": "4.0.3-
|
|
129
|
-
"@libp2p/peer-id-factory": "4.0.2-
|
|
132
|
+
"@libp2p/logger": "4.0.3-581574d6d",
|
|
133
|
+
"@libp2p/peer-id-factory": "4.0.2-581574d6d",
|
|
130
134
|
"aegir": "^41.0.2",
|
|
131
135
|
"delay": "^6.0.0",
|
|
132
136
|
"it-all": "^3.0.3",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Metrics } from '@libp2p/interface'
|
|
2
|
+
|
|
3
|
+
export interface CreateTrackedListInit {
|
|
4
|
+
/**
|
|
5
|
+
* The metric name to use
|
|
6
|
+
*/
|
|
7
|
+
name: string
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A metrics implementation
|
|
11
|
+
*/
|
|
12
|
+
metrics?: Metrics
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function trackedList <V> (config: CreateTrackedListInit): V[] {
|
|
16
|
+
const { name, metrics } = config
|
|
17
|
+
const list: V[] = []
|
|
18
|
+
|
|
19
|
+
metrics?.registerMetric(name, {
|
|
20
|
+
calculate: () => {
|
|
21
|
+
return list.length
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return list
|
|
26
|
+
}
|