graz 0.0.44-alpha.2 → 0.0.45-alpha.1

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,30 @@
1
+ const { defineChainInfo, defineChains } = require("../dist");
2
+
3
+ /* REPLACE_MAINNET_DEFS */
4
+ /* REPLACE_TESTNET_DEFS */
5
+
6
+ const mainnetChains = defineChains({
7
+ /* REPLACE_MAINNET_CHAINS */
8
+ });
9
+
10
+ const mainnetChainsArray = [
11
+ /* REPLACE_MAINNET_CHAINS_ARRAY */
12
+ ];
13
+
14
+ const testnetChains = defineChains({
15
+ /* REPLACE_TESTNET_CHAINS */
16
+ });
17
+
18
+ const testnetChainsArray = [
19
+ /* REPLACE_TESTNET_CHAINS_ARRAY */
20
+ ];
21
+
22
+ module.exports = {
23
+ mainnetChains,
24
+ mainnetChainsArray,
25
+ testnetChains,
26
+ testnetChainsArray,
27
+
28
+ /* REPLACE_MAINNET_EXPORTS */
29
+ /* REPLACE_TESTNET_EXPORTS */
30
+ };
@@ -0,0 +1,20 @@
1
+ import { defineChainInfo, defineChains } from "../dist";
2
+
3
+ /* REPLACE_MAINNET_DEFS */
4
+ /* REPLACE_TESTNET_DEFS */
5
+
6
+ export const mainnetChains = defineChains({
7
+ /* REPLACE_MAINNET_CHAINS */
8
+ });
9
+
10
+ export const mainnetChainsArray = [
11
+ /* REPLACE_MAINNET_CHAINS_ARRAY */
12
+ ];
13
+
14
+ export const testnetChains = defineChains({
15
+ /* REPLACE_TESTNET_CHAINS */
16
+ });
17
+
18
+ export const testnetChainsArray = [
19
+ /* REPLACE_TESTNET_CHAINS_ARRAY */
20
+ ];
package/cli.mjs ADDED
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ import * as fs from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ import { Bech32Address } from "@keplr-wallet/cosmos";
8
+ import arg from "arg";
9
+ import { createClient, createTestnetClient } from "cosmos-directory-client";
10
+
11
+ import pmap from "./compiled/p-map/index.mjs";
12
+
13
+ const isNumber = (char) => /^\d+$/.test(char);
14
+
15
+ const chainNaming = (name) => {
16
+ if (isNumber(name[0])) {
17
+ return `_${name}`;
18
+ }
19
+ return name;
20
+ };
21
+
22
+ const HELP_MESSAGE = `Usage: graz [options]
23
+
24
+ Options:
25
+
26
+ -g, --generate Generate chain definitions and export to "graz/chains"
27
+ -h, --help Show this help message
28
+
29
+ Generate options:
30
+ -b, --best Set REST and RPC endpoint to best available nodes instead or first listed ones
31
+ -M, --mainnet Generate given mainnet chain paths seperated by commas (e.g. "axelar,cosmoshub,juno")
32
+ -T, --testnet Generate given testnet chain paths seperated by commas (e.g. "atlantic,bitcannadev,cheqdtestnet")
33
+ --authz Generate only authz compatible chains
34
+
35
+ https://github.com/strangelove-ventures/graz
36
+ `;
37
+
38
+ const args = arg({
39
+ "--generate": Boolean,
40
+ "-g": "--generate",
41
+
42
+ "--authz": Boolean,
43
+ "--best": Boolean,
44
+ "--mainnet": String,
45
+ "--testnet": String,
46
+ "-b": "--best",
47
+ "-M": "--mainnet",
48
+ "-T": "--testnet",
49
+
50
+ "--help": Boolean,
51
+ "-h": "--help",
52
+ });
53
+
54
+ const cli = async () => {
55
+ if (args["--help"]) {
56
+ console.log(HELP_MESSAGE);
57
+ return;
58
+ }
59
+
60
+ if (args["--generate"]) {
61
+ await generate();
62
+ return;
63
+ }
64
+
65
+ console.log(HELP_MESSAGE);
66
+ };
67
+
68
+ const generate = async () => {
69
+ console.log(`⏳\tGenerating chain list from cosmos.directory...`);
70
+ if (args["--authz"]) {
71
+ console.log(`✍️\tDetected authz flag, generating only compatible chains...`);
72
+ }
73
+ if (args["--best"]) {
74
+ console.log(`💁‍♂️\tDetected best flag, setting REST and RPC endpoints to best latency...`);
75
+ }
76
+ if (args["--mainnet"] || args["--testnet"]) {
77
+ console.log(`🐙\tDetected chain filtering flag, generating only given chain paths...`);
78
+ }
79
+
80
+ const [mainnetRecord, testnetRecord] = await Promise.all([
81
+ makeRecord(createClient(), { filter: args["--mainnet"] }),
82
+ makeRecord(createTestnetClient(), { filter: args["--testnet"] }),
83
+ ]);
84
+
85
+ const [jsStub, mjsStub] = await Promise.all([
86
+ fs.readFile(chainsDir("index.js.stub"), { encoding: "utf-8" }),
87
+ fs.readFile(chainsDir("index.mjs.stub"), { encoding: "utf-8" }),
88
+ ]);
89
+
90
+ const jsContent = jsStub
91
+ .replace("/* REPLACE_MAINNET_DEFS */", makeDefs(mainnetRecord))
92
+ .replace("/* REPLACE_TESTNET_DEFS */", makeDefs(testnetRecord, { testnet: true }))
93
+ .replace("/* REPLACE_MAINNET_CHAINS */", makeChainMap(mainnetRecord))
94
+ .replace("/* REPLACE_TESTNET_CHAINS */", makeChainMap(testnetRecord, { testnet: true }))
95
+ .replace("/* REPLACE_MAINNET_CHAINS_ARRAY */", makeExports(mainnetRecord))
96
+ .replace("/* REPLACE_TESTNET_CHAINS_ARRAY */", makeExports(testnetRecord, { testnet: true }))
97
+ .replace("/* REPLACE_MAINNET_EXPORTS */", makeExports(mainnetRecord))
98
+ .replace("/* REPLACE_TESTNET_EXPORTS */", makeExports(testnetRecord, { testnet: true }))
99
+ .replace(/"(.+)":/g, "$1:")
100
+ .trim();
101
+
102
+ const mjsContent = mjsStub
103
+ .replace("/* REPLACE_MAINNET_DEFS */", makeDefs(mainnetRecord, { mjs: true }))
104
+ .replace("/* REPLACE_TESTNET_DEFS */", makeDefs(testnetRecord, { mjs: true, testnet: true }))
105
+ .replace("/* REPLACE_MAINNET_CHAINS */", makeChainMap(mainnetRecord))
106
+ .replace("/* REPLACE_TESTNET_CHAINS */", makeChainMap(testnetRecord, { testnet: true }))
107
+ .replace("/* REPLACE_MAINNET_CHAINS_ARRAY */", makeExports(mainnetRecord))
108
+ .replace("/* REPLACE_TESTNET_CHAINS_ARRAY */", makeExports(testnetRecord, { testnet: true }))
109
+ .replace(/"(.+)":/g, "$1:")
110
+ .trim();
111
+
112
+ await Promise.all([
113
+ fs.writeFile(chainsDir("index.js"), jsContent, { encoding: "utf-8" }),
114
+ fs.writeFile(chainsDir("index.mjs"), mjsContent.replace('"../dist"', '"../dist/index.mjs"'), { encoding: "utf-8" }),
115
+ fs.writeFile(chainsDir("index.ts"), mjsContent, { encoding: "utf-8" }),
116
+ ]);
117
+
118
+ console.log('✨\tGenerate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');
119
+ };
120
+
121
+ /** @param {string[]} args */
122
+ const chainsDir = (...args) => path.resolve(path.dirname(fileURLToPath(import.meta.url)), "chains", ...args);
123
+
124
+ /**
125
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
126
+ * @param {Record<string, boolean>} opts
127
+ */
128
+ const makeChainMap = (record, { testnet = false } = {}) =>
129
+ Object.keys(record)
130
+ .map((k) => ` ${chainNaming(k)}: ${chainNaming(k)},`)
131
+ .join("\n");
132
+
133
+ /**
134
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
135
+ * @param {Record<string, boolean>} opts
136
+ */
137
+ const makeDefs = (record, { mjs = false, testnet = false } = {}) =>
138
+ Object.entries(record)
139
+ .map(([k, v]) => {
140
+ const jsVariable = `${chainNaming(k)}`;
141
+ const jsChainInfo = JSON.stringify(v, null, 2);
142
+ return `${mjs ? "export " : ""}const ${jsVariable} = defineChainInfo(${jsChainInfo});\n`;
143
+ })
144
+ .join("");
145
+
146
+ /**
147
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
148
+ * @param {Record<string, boolean>} opts
149
+ */
150
+ const makeExports = (record, { testnet = false } = {}) =>
151
+ Object.keys(record)
152
+ .map((k) => ` ${chainNaming(k)},`)
153
+ .join("\n");
154
+
155
+ /**
156
+ * @param {import("cosmos-directory-client").DirectoryClient} client
157
+ * @param {{ filter?: string }} opts
158
+ */
159
+ const makeRecord = async (client, { filter = "" } = {}) => {
160
+ const paths = filter
161
+ ? filter.split(",").map((path) => ({ path }))
162
+ : await client.fetchChains().then((c) => c.chains.map(({ path }) => ({ path })));
163
+
164
+ const chains = await pmap(paths, async (c) => client.fetchChain(c.path).then((x) => x.chain), { concurrency: 4 });
165
+
166
+ /** @type {Record<string, import(".").ChainInfoWithPath>} */
167
+ const record = {};
168
+
169
+ chains.forEach((chain) => {
170
+ try {
171
+ if (args["--authz"] && !chain.params?.authz) {
172
+ return;
173
+ }
174
+
175
+ const apis = args["--best"] ? chain.best_apis : chain.apis;
176
+ if (!apis || !apis.rest?.[0] || !apis.rpc?.[0]) {
177
+ throw new Error(`⚠️\t${chain.name} has no REST/RPC endpoints, skipping codegen...`);
178
+ }
179
+
180
+ if (!chain.assets) {
181
+ throw new Error(`⚠️\t${chain.name} has no assets, skipping codegen...`);
182
+ }
183
+ const mainAsset = chain.assets[0];
184
+
185
+ /** @type{import("@keplr-wallet/types").Currency} */
186
+ const nativeCurrency = {
187
+ coinDenom: mainAsset.denom_units[mainAsset.denom_units.length - 1].denom,
188
+ coinMinimalDenom: mainAsset.denom_units[0].denom,
189
+ coinDecimals: mainAsset.denom_units[mainAsset.denom_units.length - 1].exponent,
190
+ coinGeckoId: mainAsset.coingecko_id,
191
+ };
192
+
193
+ record[chain.path] = {
194
+ chainId: chain.chain_id,
195
+ currencies: chain.assets.map((asset) => ({
196
+ coinDenom: asset.denom_units[asset.denom_units.length - 1].denom,
197
+ coinMinimalDenom: asset.denom_units[0].denom,
198
+ coinDecimals: asset.denom_units[asset.denom_units.length - 1].exponent,
199
+ coinGeckoId: asset.coingecko_id,
200
+ })),
201
+ path: chain.path,
202
+ rest: apis.rest[0].address || "",
203
+ rpc: apis.rpc[0].address || "",
204
+ bech32Config: Bech32Address.defaultBech32Config(chain.bech32_prefix),
205
+ chainName: chain.chain_name,
206
+ feeCurrencies: [nativeCurrency],
207
+ stakeCurrency: nativeCurrency,
208
+ bip44: {
209
+ coinType: chain.slip44 ?? 0,
210
+ },
211
+ };
212
+ } catch (error) {
213
+ console.error(error instanceof Error ? error.message : String(error));
214
+ }
215
+ });
216
+ return record;
217
+ };
218
+
219
+ void cli();
@@ -0,0 +1,121 @@
1
+ export type Options = {
2
+ /**
3
+ Number of concurrently pending promises returned by `mapper`.
4
+
5
+ Must be an integer from 1 and up or `Infinity`.
6
+
7
+ @default Infinity
8
+ */
9
+ readonly concurrency?: number;
10
+
11
+ /**
12
+ When `true`, the first mapper rejection will be rejected back to the consumer.
13
+
14
+ When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.
15
+
16
+ Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. [Issue #51](https://github.com/sindresorhus/p-map/issues/51) can be implemented for abort control.
17
+
18
+ @default true
19
+ */
20
+ readonly stopOnError?: boolean;
21
+
22
+ /**
23
+ You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
24
+
25
+ @example
26
+ ```
27
+ import pMap from 'p-map';
28
+ import delay from 'delay';
29
+
30
+ const abortController = new AbortController();
31
+
32
+ setTimeout(() => {
33
+ abortController.abort();
34
+ }, 500);
35
+
36
+ const mapper = async value => value;
37
+
38
+ await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
39
+ // Throws AbortError (DOMException) after 500 ms.
40
+ ```
41
+ */
42
+ readonly signal?: AbortSignal;
43
+ };
44
+
45
+ type MaybePromise<T> = T | Promise<T>;
46
+
47
+ /**
48
+ Function which is called for every item in `input`. Expected to return a `Promise` or value.
49
+
50
+ @param element - Iterated element.
51
+ @param index - Index of the element in the source array.
52
+ */
53
+ export type Mapper<Element = any, NewElement = unknown> = (
54
+ element: Element,
55
+ index: number
56
+ ) => MaybePromise<NewElement | typeof pMapSkip>;
57
+
58
+ /**
59
+ @param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
60
+ @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
61
+ @returns A `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
62
+
63
+ @example
64
+ ```
65
+ import pMap from 'p-map';
66
+ import got from 'got';
67
+
68
+ const sites = [
69
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
70
+ 'https://avajs.dev',
71
+ 'https://github.com'
72
+ ];
73
+
74
+ const mapper = async site => {
75
+ const {requestUrl} = await got.head(site);
76
+ return requestUrl;
77
+ };
78
+
79
+ const result = await pMap(sites, mapper, {concurrency: 2});
80
+
81
+ console.log(result);
82
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
83
+ ```
84
+ */
85
+ export default function pMap<Element, NewElement>(
86
+ input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
87
+ mapper: Mapper<Element, NewElement>,
88
+ options?: Options
89
+ ): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
90
+
91
+ /**
92
+ Return this value from a `mapper` function to skip including the value in the returned array.
93
+
94
+ @example
95
+ ```
96
+ import pMap, {pMapSkip} from 'p-map';
97
+ import got from 'got';
98
+
99
+ const sites = [
100
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
101
+ 'https://avajs.dev',
102
+ 'https://example.invalid',
103
+ 'https://github.com'
104
+ ];
105
+
106
+ const mapper = async site => {
107
+ try {
108
+ const {requestUrl} = await got.head(site);
109
+ return requestUrl;
110
+ } catch {
111
+ return pMapSkip;
112
+ }
113
+ };
114
+
115
+ const result = await pMap(sites, mapper, {concurrency: 2});
116
+
117
+ console.log(result);
118
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
119
+ ```
120
+ */
121
+ export const pMapSkip: unique symbol;
@@ -0,0 +1 @@
1
+ var e={};(()=>{e.d=(r,t)=>{for(var n in t){if(e.o(t,n)&&!e.o(r,n)){Object.defineProperty(r,n,{enumerable:true,get:t[n]})}}}})();(()=>{e.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r)})();if(typeof e!=="undefined")e.ab=new URL(".",import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/)?1:0,-1)+"/";var r={};e.d(r,{Ud:()=>t,ZP:()=>pMap,_L:()=>AbortError});class AbortError extends Error{constructor(e){super();this.name="AbortError";this.message=e}}const getDOMException=e=>globalThis.DOMException===undefined?new AbortError(e):new DOMException(e);const getAbortedReason=e=>{const r=e.reason===undefined?getDOMException("This operation was aborted."):e.reason;return r instanceof Error?r:getDOMException(r)};async function pMap(e,r,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((i,s)=>{if(e[Symbol.iterator]===undefined&&e[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`)}const c=[];const f=[];const u=new Map;let p=false;let l=false;let y=false;let b=0;let d=0;const w=e[Symbol.iterator]===undefined?e[Symbol.asyncIterator]():e[Symbol.iterator]();const reject=e=>{p=true;l=true;s(e)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(l){return}const e=await w.next();const n=d;d++;if(e.done){y=true;if(b===0&&!l){if(!o&&f.length>0){reject(new AggregateError(f));return}l=true;if(u.size===0){i(c);return}const e=[];for(const[r,n]of c.entries()){if(u.get(r)===t){continue}e.push(n)}i(e)}return}b++;(async()=>{try{const o=await e.value;if(l){return}const a=await r(o,n);if(a===t){u.set(n,a)}c[n]=a;b--;await next()}catch(e){if(o){reject(e)}else{f.push(e);b--;try{await next()}catch(e){reject(e)}}}})()};(async()=>{for(let e=0;e<n;e++){try{await next()}catch(e){reject(e);break}if(y||p){break}}})()}))}const t=Symbol("skip");var n=r._L;var o=r.ZP;var a=r.Ud;export{n as AbortError,o as default,a as pMapSkip};
@@ -0,0 +1,123 @@
1
+ export interface Options {
2
+ /**
3
+ Number of concurrently pending promises returned by `mapper`.
4
+
5
+ Must be an integer from 1 and up or `Infinity`.
6
+
7
+ @default Infinity
8
+ */
9
+ readonly concurrency?: number;
10
+
11
+ /**
12
+ When `true`, the first mapper rejection will be rejected back to the consumer.
13
+
14
+ When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
15
+
16
+ Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. [Issue #51](https://github.com/sindresorhus/p-map/issues/51) can be implemented for abort control.
17
+
18
+ @default true
19
+ */
20
+ readonly stopOnError?: boolean;
21
+
22
+ /**
23
+ You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
24
+
25
+ **Requires Node.js 16 or later.*
26
+
27
+ @example
28
+ ```
29
+ import pMap from 'p-map';
30
+ import delay from 'delay';
31
+
32
+ const abortController = new AbortController();
33
+
34
+ setTimeout(() => {
35
+ abortController.abort();
36
+ }, 500);
37
+
38
+ const mapper = async value => value;
39
+
40
+ await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
41
+ // Throws AbortError (DOMException) after 500 ms.
42
+ ```
43
+ */
44
+ readonly signal?: AbortSignal;
45
+ }
46
+
47
+ type MaybePromise<T> = T | Promise<T>;
48
+
49
+ /**
50
+ Function which is called for every item in `input`. Expected to return a `Promise` or value.
51
+
52
+ @param element - Iterated element.
53
+ @param index - Index of the element in the source array.
54
+ */
55
+ export type Mapper<Element = any, NewElement = unknown> = (
56
+ element: Element,
57
+ index: number
58
+ ) => MaybePromise<NewElement | typeof pMapSkip>;
59
+
60
+ /**
61
+ @param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
62
+ @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
63
+ @returns A `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
64
+
65
+ @example
66
+ ```
67
+ import pMap from 'p-map';
68
+ import got from 'got';
69
+
70
+ const sites = [
71
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
72
+ 'https://avajs.dev',
73
+ 'https://github.com'
74
+ ];
75
+
76
+ const mapper = async site => {
77
+ const {requestUrl} = await got.head(site);
78
+ return requestUrl;
79
+ };
80
+
81
+ const result = await pMap(sites, mapper, {concurrency: 2});
82
+
83
+ console.log(result);
84
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
85
+ ```
86
+ */
87
+ export default function pMap<Element, NewElement>(
88
+ input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
89
+ mapper: Mapper<Element, NewElement>,
90
+ options?: Options
91
+ ): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
92
+
93
+ /**
94
+ Return this value from a `mapper` function to skip including the value in the returned array.
95
+
96
+ @example
97
+ ```
98
+ import pMap, {pMapSkip} from 'p-map';
99
+ import got from 'got';
100
+
101
+ const sites = [
102
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
103
+ 'https://avajs.dev',
104
+ 'https://example.invalid',
105
+ 'https://github.com'
106
+ ];
107
+
108
+ const mapper = async site => {
109
+ try {
110
+ const {requestUrl} = await got.head(site);
111
+ return requestUrl;
112
+ } catch {
113
+ return pMapSkip;
114
+ }
115
+ };
116
+
117
+ const result = await pMap(sites, mapper, {concurrency: 2});
118
+
119
+ console.log(result);
120
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
121
+ ```
122
+ */
123
+ export const pMapSkip: unique symbol;
@@ -0,0 +1,34 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // src/constant.ts
28
+ var RECONNECT_SESSION_KEY = "graz-reconnect-session";
29
+
30
+ export {
31
+ __commonJS,
32
+ __toESM,
33
+ RECONNECT_SESSION_KEY
34
+ };
package/dist/constant.js CHANGED
@@ -1 +1,30 @@
1
- "use strict";var E=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var s in e)E(n,s,{get:e[s],enumerable:!0})},C=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of t(e))!N.call(n,o)&&o!==s&&E(n,o,{get:()=>e[o],enumerable:!(c=r(e,o))||c.enumerable});return n};var O=n=>C(E({},"__esModule",{value:!0}),n);var a={};S(a,{RECONNECT_SESSION_KEY:()=>_});module.exports=O(a);var _="graz-reconnect-session";0&&(module.exports={RECONNECT_SESSION_KEY});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/constant.ts
21
+ var constant_exports = {};
22
+ __export(constant_exports, {
23
+ RECONNECT_SESSION_KEY: () => RECONNECT_SESSION_KEY
24
+ });
25
+ module.exports = __toCommonJS(constant_exports);
26
+ var RECONNECT_SESSION_KEY = "graz-reconnect-session";
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ RECONNECT_SESSION_KEY
30
+ });
package/dist/constant.mjs CHANGED
@@ -1 +1,6 @@
1
- import{c as a}from"./chunk-HBC2VYPF.mjs";export{a as RECONNECT_SESSION_KEY};
1
+ import {
2
+ RECONNECT_SESSION_KEY
3
+ } from "./chunk-PLO5KV6X.mjs";
4
+ export {
5
+ RECONNECT_SESSION_KEY
6
+ };
package/dist/cosmjs.js CHANGED
@@ -1 +1,30 @@
1
- "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/encoding"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);0&&(module.exports={...require("@cosmjs/cosmwasm-stargate"),...require("@cosmjs/encoding"),...require("@cosmjs/proto-signing"),...require("@cosmjs/stargate")});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/cosmjs.ts
18
+ var cosmjs_exports = {};
19
+ module.exports = __toCommonJS(cosmjs_exports);
20
+ __reExport(cosmjs_exports, require("@cosmjs/cosmwasm-stargate"), module.exports);
21
+ __reExport(cosmjs_exports, require("@cosmjs/encoding"), module.exports);
22
+ __reExport(cosmjs_exports, require("@cosmjs/proto-signing"), module.exports);
23
+ __reExport(cosmjs_exports, require("@cosmjs/stargate"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("@cosmjs/cosmwasm-stargate"),
27
+ ...require("@cosmjs/encoding"),
28
+ ...require("@cosmjs/proto-signing"),
29
+ ...require("@cosmjs/stargate")
30
+ });
package/dist/cosmjs.mjs CHANGED
@@ -1 +1,5 @@
1
- export*from"@cosmjs/cosmwasm-stargate";export*from"@cosmjs/encoding";export*from"@cosmjs/proto-signing";export*from"@cosmjs/stargate";
1
+ // src/cosmjs.ts
2
+ export * from "@cosmjs/cosmwasm-stargate";
3
+ export * from "@cosmjs/encoding";
4
+ export * from "@cosmjs/proto-signing";
5
+ export * from "@cosmjs/stargate";