How to use the neverthrow.ok function in neverthrow

To help you get started, we’ve selected a few neverthrow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robotty / dank-twitch-irc / lib / client / multi-client.ts View on Github external
return this.joinLock.wrapAll(channelNames, async () => {
            let results: Record> = {};
            let needToJoin: string[] = [];

            for (let channelName of channelNames) {
                if (this.channels.has(channelName)) {
                    results[channelName] = ok(this.roomStateTracker.getState(channelName) as RoomState);
                } else {
                    needToJoin.push(channelName);
                }
            }

            let promises: Promise[] = [];


            let idx = 0;
            while (idx < needToJoin.length) {
                let conn = this.requireConnection(
                    c => c.channels.size < this.configuration.maxChannelCountPerConnection);
                let canJoin = this.configuration.maxChannelCountPerConnection - conn.channels.size;
                let slice = needToJoin.slice(idx, idx += canJoin);

                promises.push((async () => {

neverthrow

Stop throwing errors, and instead return Results!

MIT
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis

Popular neverthrow functions