@libp2p/utils 6.3.1-06fc82da8 → 6.3.1-15a70af5f

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,2 @@
1
+ export declare function isAsyncGenerator(obj: unknown): obj is AsyncGenerator;
2
+ //# sourceMappingURL=is-async-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-async-generator.d.ts","sourceRoot":"","sources":["../../src/is-async-generator.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CASrE"}
@@ -0,0 +1,10 @@
1
+ export function isAsyncGenerator(obj) {
2
+ if (obj == null)
3
+ return false;
4
+ const asyncIterator = obj?.[Symbol.asyncIterator];
5
+ if (typeof asyncIterator !== 'function')
6
+ return false;
7
+ const instance = obj;
8
+ return typeof instance.next === 'function';
9
+ }
10
+ //# sourceMappingURL=is-async-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-async-generator.js","sourceRoot":"","sources":["../../src/is-async-generator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAE,GAAY;IAC5C,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7B,MAAM,aAAa,GAAI,GAA4C,EAAE,CACnE,MAAM,CAAC,aAAa,CACrB,CAAA;IACD,IAAI,OAAO,aAAa,KAAK,UAAU;QAAE,OAAO,KAAK,CAAA;IAErD,MAAM,QAAQ,GAAG,GAAyB,CAAA;IAC1C,OAAO,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function isGenerator(obj: unknown): obj is Generator;
2
+ //# sourceMappingURL=is-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-generator.d.ts","sourceRoot":"","sources":["../../src/is-generator.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAE,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,SAAS,CAO3D"}
@@ -0,0 +1,10 @@
1
+ export function isGenerator(obj) {
2
+ if (obj == null)
3
+ return false;
4
+ const iterator = obj?.[Symbol.iterator];
5
+ if (typeof iterator !== 'function')
6
+ return false;
7
+ const instance = obj;
8
+ return typeof instance.next === 'function';
9
+ }
10
+ //# sourceMappingURL=is-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-generator.js","sourceRoot":"","sources":["../../src/is-generator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAE,GAAY;IACvC,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7B,MAAM,QAAQ,GAAI,GAAuC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5E,IAAI,OAAO,QAAQ,KAAK,UAAU;QAAE,OAAO,KAAK,CAAA;IAEhD,MAAM,QAAQ,GAAG,GAAyB,CAAA;IAC1C,OAAO,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAA;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/utils",
3
- "version": "6.3.1-06fc82da8",
3
+ "version": "6.3.1-15a70af5f",
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,14 @@
84
84
  "types": "./dist/src/ip-port-to-multiaddr.d.ts",
85
85
  "import": "./dist/src/ip-port-to-multiaddr.js"
86
86
  },
87
+ "./is-async-generator": {
88
+ "types": "./dist/src/is-async-generator.d.ts",
89
+ "import": "./dist/src/is-async-generator.js"
90
+ },
91
+ "./is-generator": {
92
+ "types": "./dist/src/is-generator.d.ts",
93
+ "import": "./dist/src/is-generator.js"
94
+ },
87
95
  "./is-promise": {
88
96
  "types": "./dist/src/is-promise.d.ts",
89
97
  "import": "./dist/src/is-promise.js"
@@ -173,9 +181,9 @@
173
181
  "dependencies": {
174
182
  "@chainsafe/is-ip": "^2.0.2",
175
183
  "@chainsafe/netmask": "^2.0.0",
176
- "@libp2p/crypto": "5.0.9-06fc82da8",
177
- "@libp2p/interface": "2.4.0-06fc82da8",
178
- "@libp2p/logger": "5.1.6-06fc82da8",
184
+ "@libp2p/crypto": "5.0.9-15a70af5f",
185
+ "@libp2p/interface": "2.4.0-15a70af5f",
186
+ "@libp2p/logger": "5.1.6-15a70af5f",
179
187
  "@multiformats/multiaddr": "^12.3.3",
180
188
  "@sindresorhus/fnv1a": "^3.1.0",
181
189
  "@types/murmurhash3js-revisited": "^3.0.3",
@@ -196,7 +204,7 @@
196
204
  "uint8arrays": "^5.1.0"
197
205
  },
198
206
  "devDependencies": {
199
- "@libp2p/peer-id": "5.0.10-06fc82da8",
207
+ "@libp2p/peer-id": "5.0.10-15a70af5f",
200
208
  "@types/netmask": "^2.0.5",
201
209
  "aegir": "^45.0.5",
202
210
  "benchmark": "^2.1.4",
@@ -0,0 +1,10 @@
1
+ export function isAsyncGenerator (obj: unknown): obj is AsyncGenerator {
2
+ if (obj == null) return false
3
+ const asyncIterator = (obj as { [Symbol.asyncIterator]?: unknown })?.[
4
+ Symbol.asyncIterator
5
+ ]
6
+ if (typeof asyncIterator !== 'function') return false
7
+
8
+ const instance = obj as { next?: unknown }
9
+ return typeof instance.next === 'function'
10
+ }
@@ -0,0 +1,8 @@
1
+ export function isGenerator (obj: unknown): obj is Generator {
2
+ if (obj == null) return false
3
+ const iterator = (obj as { [Symbol.iterator]?: unknown })?.[Symbol.iterator]
4
+ if (typeof iterator !== 'function') return false
5
+
6
+ const instance = obj as { next?: unknown }
7
+ return typeof instance.next === 'function'
8
+ }