diia-open-source / be-pkg-utils

European Union Public License 1.2
14 stars 10 forks source link

You will never need this util #20

Closed tshemsedinov closed 12 hours ago

tshemsedinov commented 4 months ago

https://github.com/diia-open-source/be-pkg-utils/blob/e969374fb769e59ab6bbdb709caeba0199e14a8c/src/guards.ts#L69-L74

Let's optimize:

   static isSettledError(value: PromiseSettledResult<unknown>): value is PromiseRejectedResult {
        return value.status === 'rejected'
    }

So you can simply use inplace expression Instead you can use in place just isSettledError:

value.status === 'rejected'
doichev-kostia commented 3 months ago

The key value of this util is in value is PromiseRejectedResult. This is needed for TypeScript in Array.filter method.

Screenshot 2024-03-21 at 11 25 47 Screenshot 2024-03-21 at 11 26 16
FowiFlowi commented 12 hours ago

@doichev-kostia exactly!