@libp2p/utils 3.0.2 → 3.0.4

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.
package/README.md CHANGED
@@ -1,21 +1,20 @@
1
1
  # @libp2p/utils <!-- omit in toc -->
2
2
 
3
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
- [![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
5
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
6
5
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-utils.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-utils)
7
- [![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-utils/actions/workflows/js-test-and-release.yml)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-utils/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-utils/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
8
7
 
9
8
  > Package to aggregate shared logic and dependencies for the libp2p ecosystem
10
9
 
11
10
  ## Table of contents <!-- omit in toc -->
12
11
 
13
12
  - [Install](#install)
14
- - [Lead Maintainer](#lead-maintainer)
13
+ - [Browser `<script>` tag](#browser-script-tag)
15
14
  - [Usage](#usage)
16
- - [Contribute](#contribute)
15
+ - [API Docs](#api-docs)
17
16
  - [License](#license)
18
- - [Contribute](#contribute-1)
17
+ - [Contribution](#contribution)
19
18
 
20
19
  ## Install
21
20
 
@@ -23,6 +22,14 @@
23
22
  $ npm i @libp2p/utils
24
23
  ```
25
24
 
25
+ ### Browser `<script>` tag
26
+
27
+ Loading this module through a script tag will make it's exports available as `Libp2pUtils` in the global namespace.
28
+
29
+ ```html
30
+ <script src="https://unpkg.com/@libp2p/utils/dist/index.min.js"></script>
31
+ ```
32
+
26
33
  The libp2p ecosystem has lots of repos with it comes several problems like:
27
34
 
28
35
  - Domain logic dedupe - all modules shared a lot of logic like validation, streams handling, etc.
@@ -30,10 +37,6 @@ The libp2p ecosystem has lots of repos with it comes several problems like:
30
37
 
31
38
  These problems are the motivation for this package, having shared logic in this package avoids creating cyclic dependencies, centralizes common use modules/functions (exactly like aegir does for the tooling), semantic versioning for 3rd party dependencies is handled in one single place (a good example is going from streams 2 to 3) and maintainers should only care about having `libp2p-utils` updated.
32
39
 
33
- ## Lead Maintainer
34
-
35
- [Vasco Santos](https://github.com/vasco-santos)
36
-
37
40
  ## Usage
38
41
 
39
42
  Each function should be imported directly.
@@ -44,13 +47,11 @@ import ipAndPortToMultiaddr from '@libp2p/utils/ip-port-to-multiaddr'
44
47
  const ma = ipAndPortToMultiaddr('127.0.0.1', 9000)
45
48
  ```
46
49
 
47
- You can check the [API docs](./API.md).
48
-
49
- ## Contribute
50
+ You can check the [API docs](https://libp2p.github.io/js-libp2p-utils).
50
51
 
51
- Contributions welcome. Please check out [the issues](https://github.com/libp2p/js-libp2p-utils/issues).
52
+ ## API Docs
52
53
 
53
- Check out our [contributing document](https://github.com/ipfs/community/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
54
+ - <https://libp2p.github.io/js-libp2p-utils>
54
55
 
55
56
  ## License
56
57
 
@@ -59,6 +60,6 @@ Licensed under either of
59
60
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
60
61
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
61
62
 
62
- ## Contribute
63
+ ## Contribution
63
64
 
64
65
  Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
@@ -0,0 +1,3 @@
1
+ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PUtils = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var Libp2PUtils=(()=>{var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(o,e,x,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of b(e))!c.call(o,p)&&p!==x&&t(o,p,{get:()=>e[p],enumerable:!(r=a(e,p))||r.enumerable});return o};var f=o=>d(t({},"__esModule",{value:!0}),o);var g={};return f(g);})();
3
+ return Libp2PUtils}));
@@ -1,3 +1,24 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies to sort a list of multiaddrs.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { publicAddressesFirst } from '@libp2p/utils/address-sort'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ *
13
+ * const addresses = [
14
+ * multiaddr('/ip4/127.0.0.1/tcp/9000'),
15
+ * multiaddr('/ip4/82.41.53.1/tcp/9000')
16
+ * ].sort(publicAddressesFirst)
17
+ *
18
+ * console.info(addresses)
19
+ * // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']
20
+ * ```
21
+ */
1
22
  import type { Address } from '@libp2p/interface-peer-store';
2
23
  /**
3
24
  * Compare function for array.sort().
@@ -5,4 +26,8 @@ import type { Address } from '@libp2p/interface-peer-store';
5
26
  * In case of equality, a certified address will come first.
6
27
  */
7
28
  export declare function publicAddressesFirst(a: Address, b: Address): -1 | 0 | 1;
29
+ /**
30
+ * A test thing
31
+ */
32
+ export declare function something(): Promise<Uint8Array>;
8
33
  //# sourceMappingURL=address-sort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAG3D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAiBxE"}
1
+ {"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAG3D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAiBxE;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAK,OAAO,CAAC,UAAU,CAAC,CAEtD"}
@@ -1,3 +1,24 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies to sort a list of multiaddrs.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { publicAddressesFirst } from '@libp2p/utils/address-sort'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ *
13
+ * const addresses = [
14
+ * multiaddr('/ip4/127.0.0.1/tcp/9000'),
15
+ * multiaddr('/ip4/82.41.53.1/tcp/9000')
16
+ * ].sort(publicAddressesFirst)
17
+ *
18
+ * console.info(addresses)
19
+ * // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']
20
+ * ```
21
+ */
1
22
  import { isPrivate } from './multiaddr/is-private.js';
2
23
  /**
3
24
  * Compare function for array.sort().
@@ -22,4 +43,10 @@ export function publicAddressesFirst(a, b) {
22
43
  }
23
44
  return 0;
24
45
  }
46
+ /**
47
+ * A test thing
48
+ */
49
+ export async function something() {
50
+ return Uint8Array.from([0, 1, 2]);
51
+ }
25
52
  //# sourceMappingURL=address-sort.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAE,CAAU,EAAE,CAAU;IAC1D,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAEzC,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAC7B,OAAO,CAAC,CAAA;KACT;SAAM,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE;QACpC,OAAO,CAAC,CAAC,CAAA;KACV;IACD,mBAAmB;IACnB,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE;QACnC,OAAO,CAAC,CAAC,CAAA;KACV;SAAM,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,EAAE;QAC1C,OAAO,CAAC,CAAA;KACT;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
1
+ {"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAE,CAAU,EAAE,CAAU;IAC1D,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAEzC,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAC7B,OAAO,CAAC,CAAA;KACT;SAAM,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE;QACpC,OAAO,CAAC,CAAC,CAAA;KACV;IACD,mBAAmB;IACnB,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE;QACnC,OAAO,CAAC,CAAC,CAAA;KACV;SAAM,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,EAAE;QAC1C,OAAO,CAAC,CAAA;KACT;IAED,OAAO,CAAC,CAAA;AACV,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
@@ -1,3 +1,21 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies ensure arrays are equivalent.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { arrayEquals } from '@libp2p/utils/array-equals'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ * const ma1 = multiaddr('/ip4/127.0.0.1/tcp/9000'),
13
+ * const ma2 = multiaddr('/ip4/82.41.53.1/tcp/9000')
14
+ *
15
+ * console.info(arrayEquals([ma1], [ma1])) // true
16
+ * console.info(arrayEquals([ma1], [ma2])) // false
17
+ * ```
18
+ */
1
19
  /**
2
20
  * Verify if two arrays of non primitive types with the "equals" function are equal.
3
21
  * Compatible with multiaddr, peer-id and others.
@@ -1 +1 @@
1
- {"version":3,"file":"array-equals.d.ts","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,WAAW,CAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,WAU9C"}
1
+ {"version":3,"file":"array-equals.d.ts","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,wBAAgB,WAAW,CAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,WAU9C"}
@@ -1,3 +1,21 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies ensure arrays are equivalent.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { arrayEquals } from '@libp2p/utils/array-equals'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ * const ma1 = multiaddr('/ip4/127.0.0.1/tcp/9000'),
13
+ * const ma2 = multiaddr('/ip4/82.41.53.1/tcp/9000')
14
+ *
15
+ * console.info(arrayEquals([ma1], [ma1])) // true
16
+ * console.info(arrayEquals([ma1], [ma2])) // false
17
+ * ```
18
+ */
1
19
  /**
2
20
  * Verify if two arrays of non primitive types with the "equals" function are equal.
3
21
  * Compatible with multiaddr, peer-id and others.
@@ -1 +1 @@
1
- {"version":3,"file":"array-equals.js","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,CAAQ,EAAE,CAAQ;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEzE,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;QACzB,OAAO,KAAK,CAAA;KACb;IAED,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACnE,CAAC"}
1
+ {"version":3,"file":"array-equals.js","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,CAAQ,EAAE,CAAQ;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEzE,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;QACzB,OAAO,KAAK,CAAA;KACb;IAED,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACnE,CAAC"}
@@ -16,10 +16,10 @@ export interface Timeline {
16
16
  */
17
17
  close?: number;
18
18
  }
19
- interface StreamOptions {
19
+ export interface StreamOptions {
20
20
  signal?: AbortSignal;
21
21
  }
22
- interface StreamProperties {
22
+ export interface StreamProperties {
23
23
  stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>;
24
24
  remoteAddr: Multiaddr;
25
25
  localAddr: Multiaddr;
@@ -29,5 +29,4 @@ interface StreamProperties {
29
29
  * https://github.com/libp2p/interface-transport#multiaddrconnection
30
30
  */
31
31
  export declare function streamToMaConnection(props: StreamProperties, options?: StreamOptions): MultiaddrConnection;
32
- export {};
33
32
  //# sourceMappingURL=stream-to-ma-conn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,WAAW,CAAA;CAErB;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,UAAU,CAAC,CAAA;IAC3D,UAAU,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAkB,uBAiDzF"}
1
+ {"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;CAErB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,UAAU,CAAC,CAAA;IAC3D,UAAU,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAkB,uBAiDzF"}
@@ -0,0 +1,13 @@
1
+ {
2
+ "publicAddressesFirst": "https://libp2p.github.io/js-libp2p-utils/functions/address_sort.publicAddressesFirst.html",
3
+ "something": "https://libp2p.github.io/js-libp2p-utils/functions/address_sort.something.html",
4
+ "arrayEquals": "https://libp2p.github.io/js-libp2p-utils/functions/array_equals.arrayEquals.html",
5
+ "Errors": "https://libp2p.github.io/js-libp2p-utils/variables/ip_port_to_multiaddr.Errors.html",
6
+ "ipPortToMultiaddr": "https://libp2p.github.io/js-libp2p-utils/functions/ip_port_to_multiaddr.ipPortToMultiaddr.html",
7
+ "isLoopback": "https://libp2p.github.io/js-libp2p-utils/functions/multiaddr_is_loopback.isLoopback.html",
8
+ "isPrivate": "https://libp2p.github.io/js-libp2p-utils/functions/multiaddr_is_private.isPrivate.html",
9
+ "StreamOptions": "https://libp2p.github.io/js-libp2p-utils/interfaces/stream_to_ma_conn.StreamOptions.html",
10
+ "StreamProperties": "https://libp2p.github.io/js-libp2p-utils/interfaces/stream_to_ma_conn.StreamProperties.html",
11
+ "Timeline": "https://libp2p.github.io/js-libp2p-utils/interfaces/stream_to_ma_conn.Timeline.html",
12
+ "streamToMaConnection": "https://libp2p.github.io/js-libp2p-utils/functions/stream_to_ma_conn.streamToMaConnection.html"
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/utils",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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-utils#readme",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "files": [
37
37
  "src",
38
- "dist/src",
38
+ "dist",
39
39
  "!dist/test",
40
40
  "!**/*.tsbuildinfo"
41
41
  ],
@@ -165,6 +165,7 @@
165
165
  "lint": "aegir lint",
166
166
  "dep-check": "aegir dep-check",
167
167
  "build": "aegir build",
168
+ "docs": "aegir docs",
168
169
  "test": "aegir test",
169
170
  "test:chrome": "aegir test -t browser --cov",
170
171
  "test:chrome-webworker": "aegir test -t webworker",
@@ -184,16 +185,16 @@
184
185
  "err-code": "^3.0.1",
185
186
  "is-loopback-addr": "^2.0.1",
186
187
  "it-stream-types": "^1.0.4",
187
- "private-ip": "^2.1.1",
188
+ "private-ip": "^3.0.0",
188
189
  "uint8arraylist": "^2.3.2"
189
190
  },
190
191
  "devDependencies": {
191
192
  "aegir": "^37.2.0",
192
- "it-all": "^1.0.6",
193
- "it-map": "^1.0.6",
193
+ "it-all": "^2.0.0",
194
+ "it-map": "^2.0.0",
194
195
  "it-pair": "^2.0.2",
195
196
  "it-pipe": "^2.0.2",
196
197
  "p-defer": "^4.0.0",
197
- "uint8arrays": "^3.0.0"
198
+ "uint8arrays": "^4.0.2"
198
199
  }
199
200
  }
@@ -1,3 +1,25 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies to sort a list of multiaddrs.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { publicAddressesFirst } from '@libp2p/utils/address-sort'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ *
13
+ * const addresses = [
14
+ * multiaddr('/ip4/127.0.0.1/tcp/9000'),
15
+ * multiaddr('/ip4/82.41.53.1/tcp/9000')
16
+ * ].sort(publicAddressesFirst)
17
+ *
18
+ * console.info(addresses)
19
+ * // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']
20
+ * ```
21
+ */
22
+
1
23
  import type { Address } from '@libp2p/interface-peer-store'
2
24
  import { isPrivate } from './multiaddr/is-private.js'
3
25
 
@@ -24,3 +46,10 @@ export function publicAddressesFirst (a: Address, b: Address): -1 | 0 | 1 {
24
46
 
25
47
  return 0
26
48
  }
49
+
50
+ /**
51
+ * A test thing
52
+ */
53
+ export async function something (): Promise<Uint8Array> {
54
+ return Uint8Array.from([0, 1, 2])
55
+ }
@@ -1,3 +1,22 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Provides strategies ensure arrays are equivalent.
5
+ *
6
+ * @example
7
+ *
8
+ * ```typescript
9
+ * import { arrayEquals } from '@libp2p/utils/array-equals'
10
+ * import { multiaddr } from '@multformats/multiaddr'
11
+ *
12
+ * const ma1 = multiaddr('/ip4/127.0.0.1/tcp/9000'),
13
+ * const ma2 = multiaddr('/ip4/82.41.53.1/tcp/9000')
14
+ *
15
+ * console.info(arrayEquals([ma1], [ma1])) // true
16
+ * console.info(arrayEquals([ma1], [ma2])) // false
17
+ * ```
18
+ */
19
+
1
20
  /**
2
21
  * Verify if two arrays of non primitive types with the "equals" function are equal.
3
22
  * Compatible with multiaddr, peer-id and others.
@@ -24,12 +24,12 @@ export interface Timeline {
24
24
  close?: number
25
25
  }
26
26
 
27
- interface StreamOptions {
27
+ export interface StreamOptions {
28
28
  signal?: AbortSignal
29
29
 
30
30
  }
31
31
 
32
- interface StreamProperties {
32
+ export interface StreamProperties {
33
33
  stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>
34
34
  remoteAddr: Multiaddr
35
35
  localAddr: Multiaddr