@resultsafe/core-fp-result 0.1.6 → 0.1.8
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 +83 -54
- package/README.ru.md +111 -87
- package/{dist/cjs → cjs}/constructors/Err.js.map +1 -1
- package/{dist/cjs → cjs}/constructors/Ok.js.map +1 -1
- package/{dist/cjs → cjs}/guards/isErr.js.map +1 -1
- package/cjs/guards/isErrAnd.js.map +1 -0
- package/{dist/cjs → cjs}/guards/isOk.js.map +1 -1
- package/cjs/guards/isOkAnd.js.map +1 -0
- package/cjs/methods/andThen.js.map +1 -0
- package/cjs/methods/err.js.map +1 -0
- package/cjs/methods/expect.js.map +1 -0
- package/cjs/methods/expectErr.js.map +1 -0
- package/{dist/cjs → cjs}/methods/flatten.js.map +1 -1
- package/cjs/methods/inspect.js.map +1 -0
- package/cjs/methods/inspectErr.js.map +1 -0
- package/cjs/methods/map.js.map +1 -0
- package/cjs/methods/mapErr.js.map +1 -0
- package/{dist/cjs → cjs}/methods/match.js.map +1 -1
- package/cjs/methods/ok.js.map +1 -0
- package/cjs/methods/orElse.js.map +1 -0
- package/{dist/cjs → cjs}/methods/tap.js.map +1 -1
- package/cjs/methods/tapErr.js.map +1 -0
- package/cjs/methods/transpose.js.map +1 -0
- package/cjs/methods/unwrap.js.map +1 -0
- package/cjs/methods/unwrapErr.js.map +1 -0
- package/cjs/methods/unwrapOr.js.map +1 -0
- package/{dist/cjs → cjs}/methods/unwrapOrElse.js.map +1 -1
- package/cjs/refiners/refineAsyncResult.js.map +1 -0
- package/cjs/refiners/refineAsyncResultU.js.map +1 -0
- package/cjs/refiners/refineResult.js.map +1 -0
- package/cjs/refiners/refineResultU.js.map +1 -0
- package/cjs/refiners/refineVariantMap.js.map +1 -0
- package/cjs/refiners/utils/getPayloadKeys.js.map +1 -0
- package/docs/_category_.json +3 -3
- package/docs/assets/logo.svg +0 -0
- package/docs/examples/_category_.json +1 -1
- package/docs/examples/auth/_category_.json +1 -1
- package/docs/examples/auth/index.md +1 -1
- package/docs/examples/connection/_category_.json +1 -1
- package/docs/examples/connection/connect.md +1 -1
- package/docs/examples/connection/index.md +1 -1
- package/docs/examples/connection/reconnect.md +1 -1
- package/docs/examples/errors/_category_.json +1 -1
- package/docs/examples/errors/index.md +1 -1
- package/docs/examples/errors/retry.md +1 -1
- package/docs/examples/index.md +1 -1
- package/docs/examples/streaming/_category_.json +1 -1
- package/docs/examples/streaming/index.md +1 -1
- package/docs/examples/streaming/text.md +1 -1
- package/docs/meta/AI-AGENT-RULES.md +265 -0
- package/docs/meta/CONTEXT.md +70 -0
- package/docs/meta/MANIFEST.md +58 -0
- package/docs/meta/registry/COUNTERS.md +29 -0
- package/docs/meta/registry/ENTITIES.md +30 -0
- package/{dist/esm → esm}/constructors/Err.js.map +1 -1
- package/{dist/esm → esm}/constructors/Ok.js.map +1 -1
- package/{dist/esm → esm}/guards/isErr.js.map +1 -1
- package/esm/guards/isErrAnd.js.map +1 -0
- package/{dist/esm → esm}/guards/isOk.js.map +1 -1
- package/esm/guards/isOkAnd.js.map +1 -0
- package/esm/methods/andThen.js.map +1 -0
- package/esm/methods/err.js.map +1 -0
- package/esm/methods/expect.js.map +1 -0
- package/esm/methods/expectErr.js.map +1 -0
- package/{dist/esm → esm}/methods/flatten.js.map +1 -1
- package/esm/methods/inspect.js.map +1 -0
- package/esm/methods/inspectErr.js.map +1 -0
- package/esm/methods/map.js.map +1 -0
- package/esm/methods/mapErr.js.map +1 -0
- package/{dist/esm → esm}/methods/match.js.map +1 -1
- package/esm/methods/ok.js.map +1 -0
- package/esm/methods/orElse.js.map +1 -0
- package/{dist/esm → esm}/methods/tap.js.map +1 -1
- package/esm/methods/tapErr.js.map +1 -0
- package/esm/methods/transpose.js.map +1 -0
- package/esm/methods/unwrap.js.map +1 -0
- package/esm/methods/unwrapErr.js.map +1 -0
- package/esm/methods/unwrapOr.js.map +1 -0
- package/{dist/esm → esm}/methods/unwrapOrElse.js.map +1 -1
- package/esm/refiners/refineAsyncResult.js.map +1 -0
- package/esm/refiners/refineAsyncResultU.js.map +1 -0
- package/esm/refiners/refineResult.js.map +1 -0
- package/esm/refiners/refineResultU.js.map +1 -0
- package/esm/refiners/refineVariantMap.js.map +1 -0
- package/esm/refiners/utils/getPayloadKeys.js.map +1 -0
- package/package.json +18 -52
- package/{dist/types → types}/guards/isErrAnd.d.ts.map +1 -1
- package/{dist/types → types}/guards/isOkAnd.d.ts.map +1 -1
- package/{dist/types → types}/methods/andThen.d.ts.map +1 -1
- package/{dist/types → types}/methods/err.d.ts.map +1 -1
- package/types/methods/expect.d.ts.map +1 -0
- package/types/methods/expectErr.d.ts.map +1 -0
- package/{dist/types → types}/methods/inspect.d.ts.map +1 -1
- package/{dist/types → types}/methods/inspectErr.d.ts.map +1 -1
- package/{dist/types → types}/methods/map.d.ts.map +1 -1
- package/{dist/types → types}/methods/mapErr.d.ts.map +1 -1
- package/{dist/types → types}/methods/ok.d.ts.map +1 -1
- package/{dist/types → types}/methods/orElse.d.ts.map +1 -1
- package/{dist/types → types}/methods/tapErr.d.ts.map +1 -1
- package/{dist/types → types}/methods/transpose.d.ts.map +1 -1
- package/types/methods/unwrap.d.ts.map +1 -0
- package/types/methods/unwrapErr.d.ts.map +1 -0
- package/types/methods/unwrapOr.d.ts.map +1 -0
- package/{dist/types → types}/refiners/refineAsyncResult.d.ts.map +1 -1
- package/{dist/types → types}/refiners/refineAsyncResultU.d.ts.map +1 -1
- package/{dist/types → types}/refiners/refineResult.d.ts.map +1 -1
- package/{dist/types → types}/refiners/refineResultU.d.ts.map +1 -1
- package/{dist/types → types}/refiners/refineVariantMap.d.ts.map +1 -1
- package/{dist/types → types}/refiners/types/SyncRefinedResultUnion.d.ts.map +1 -1
- package/{dist/types → types}/refiners/utils/getPayloadKeys.d.ts.map +1 -1
- package/types/types/core/Option.d.ts +43 -0
- package/types/types/core/Option.d.ts.map +1 -0
- package/types/types/core/Result.d.ts +58 -0
- package/types/types/core/Result.d.ts.map +1 -0
- package/types/types/index.d.ts +7 -0
- package/types/types/index.d.ts.map +1 -0
- package/types/types/refiners/AsyncValidatorFn.d.ts +21 -0
- package/types/types/refiners/AsyncValidatorFn.d.ts.map +1 -0
- package/types/types/refiners/PayloadKeys.d.ts +20 -0
- package/types/types/refiners/PayloadKeys.d.ts.map +1 -0
- package/types/types/refiners/ValidatorFn.d.ts +23 -0
- package/types/types/refiners/ValidatorFn.d.ts.map +1 -0
- package/types/types/refiners/VariantConfig.d.ts +27 -0
- package/types/types/refiners/VariantConfig.d.ts.map +1 -0
- package/umd/resultsafe-monorepo-core-fp-result.umd.js.map +1 -0
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -273
- package/dist/README.ru.md +0 -278
- package/dist/cjs/guards/isErrAnd.js.map +0 -1
- package/dist/cjs/guards/isOkAnd.js.map +0 -1
- package/dist/cjs/methods/andThen.js.map +0 -1
- package/dist/cjs/methods/err.js.map +0 -1
- package/dist/cjs/methods/expect.js.map +0 -1
- package/dist/cjs/methods/expectErr.js.map +0 -1
- package/dist/cjs/methods/inspect.js.map +0 -1
- package/dist/cjs/methods/inspectErr.js.map +0 -1
- package/dist/cjs/methods/map.js.map +0 -1
- package/dist/cjs/methods/mapErr.js.map +0 -1
- package/dist/cjs/methods/ok.js.map +0 -1
- package/dist/cjs/methods/orElse.js.map +0 -1
- package/dist/cjs/methods/tapErr.js.map +0 -1
- package/dist/cjs/methods/transpose.js.map +0 -1
- package/dist/cjs/methods/unwrap.js.map +0 -1
- package/dist/cjs/methods/unwrapErr.js.map +0 -1
- package/dist/cjs/methods/unwrapOr.js.map +0 -1
- package/dist/cjs/refiners/refineAsyncResult.js.map +0 -1
- package/dist/cjs/refiners/refineAsyncResultU.js.map +0 -1
- package/dist/cjs/refiners/refineResult.js.map +0 -1
- package/dist/cjs/refiners/refineResultU.js.map +0 -1
- package/dist/cjs/refiners/refineVariantMap.js.map +0 -1
- package/dist/cjs/refiners/utils/getPayloadKeys.js.map +0 -1
- package/dist/docs/_category_.json +0 -6
- package/dist/docs/api/README.md +0 -9
- package/dist/docs/api/constructors/Err.md +0 -58
- package/dist/docs/api/constructors/Ok.md +0 -58
- package/dist/docs/api/constructors/index.md +0 -7
- package/dist/docs/api/guards/index.md +0 -9
- package/dist/docs/api/guards/isErr.md +0 -58
- package/dist/docs/api/guards/isErrAnd.md +0 -64
- package/dist/docs/api/guards/isOk.md +0 -58
- package/dist/docs/api/guards/isOkAnd.md +0 -64
- package/dist/docs/api/index.md +0 -9
- package/dist/docs/api/methods/andThen.md +0 -73
- package/dist/docs/api/methods/err.md +0 -58
- package/dist/docs/api/methods/expect.md +0 -68
- package/dist/docs/api/methods/expectErr.md +0 -68
- package/dist/docs/api/methods/flatten.md +0 -58
- package/dist/docs/api/methods/index.md +0 -24
- package/dist/docs/api/methods/inspect.md +0 -64
- package/dist/docs/api/methods/inspectErr.md +0 -64
- package/dist/docs/api/methods/map.md +0 -70
- package/dist/docs/api/methods/mapErr.md +0 -70
- package/dist/docs/api/methods/match.md +0 -76
- package/dist/docs/api/methods/ok.md +0 -58
- package/dist/docs/api/methods/orElse.md +0 -70
- package/dist/docs/api/methods/tap.md +0 -64
- package/dist/docs/api/methods/tapErr.md +0 -64
- package/dist/docs/api/methods/transpose.md +0 -58
- package/dist/docs/api/methods/unwrap.md +0 -62
- package/dist/docs/api/methods/unwrapErr.md +0 -62
- package/dist/docs/api/methods/unwrapOr.md +0 -64
- package/dist/docs/api/methods/unwrapOrElse.md +0 -64
- package/dist/docs/api/modules.md +0 -10
- package/dist/docs/api/refiners/index.md +0 -14
- package/dist/docs/api/refiners/isTypedVariant.md +0 -62
- package/dist/docs/api/refiners/isTypedVariantOf.md +0 -68
- package/dist/docs/api/refiners/matchVariant.md +0 -59
- package/dist/docs/api/refiners/matchVariantStrict.md +0 -63
- package/dist/docs/api/refiners/refineAsyncResult.md +0 -98
- package/dist/docs/api/refiners/refineAsyncResultU.md +0 -86
- package/dist/docs/api/refiners/refineResult.md +0 -98
- package/dist/docs/api/refiners/refineResultU.md +0 -86
- package/dist/docs/api/refiners/refineVariantMap.md +0 -79
- package/dist/docs/api/type-aliases/Handler.md +0 -49
- package/dist/docs/api/type-aliases/MatchBuilder.md +0 -57
- package/dist/docs/api/type-aliases/Matcher.md +0 -71
- package/dist/docs/api/type-aliases/SyncRefinedResult.md +0 -31
- package/dist/docs/api/type-aliases/SyncRefinedResultUnion.md +0 -21
- package/dist/docs/api/type-aliases/SyncValidatorMap.md +0 -17
- package/dist/docs/api/type-aliases/UniversalAsyncRefinedResult.md +0 -31
- package/dist/docs/api/type-aliases/UniversalRefinedResult.md +0 -31
- package/dist/docs/api/type-aliases/VariantOf.md +0 -23
- package/dist/docs/api/type-aliases/index.md +0 -14
- package/dist/docs/assets/logo.svg +0 -93
- package/dist/docs/examples/_category_.json +0 -4
- package/dist/docs/examples/auth/_category_.json +0 -4
- package/dist/docs/examples/auth/index.md +0 -3
- package/dist/docs/examples/auth/token.md +0 -5
- package/dist/docs/examples/connection/_category_.json +0 -4
- package/dist/docs/examples/connection/connect.md +0 -5
- package/dist/docs/examples/connection/index.md +0 -3
- package/dist/docs/examples/connection/reconnect.md +0 -5
- package/dist/docs/examples/errors/_category_.json +0 -4
- package/dist/docs/examples/errors/index.md +0 -3
- package/dist/docs/examples/errors/retry.md +0 -5
- package/dist/docs/examples/index.md +0 -9
- package/dist/docs/examples/streaming/_category_.json +0 -4
- package/dist/docs/examples/streaming/index.md +0 -3
- package/dist/docs/examples/streaming/text.md +0 -5
- package/dist/esm/guards/isErrAnd.js.map +0 -1
- package/dist/esm/guards/isOkAnd.js.map +0 -1
- package/dist/esm/methods/andThen.js.map +0 -1
- package/dist/esm/methods/err.js.map +0 -1
- package/dist/esm/methods/expect.js.map +0 -1
- package/dist/esm/methods/expectErr.js.map +0 -1
- package/dist/esm/methods/inspect.js.map +0 -1
- package/dist/esm/methods/inspectErr.js.map +0 -1
- package/dist/esm/methods/map.js.map +0 -1
- package/dist/esm/methods/mapErr.js.map +0 -1
- package/dist/esm/methods/ok.js.map +0 -1
- package/dist/esm/methods/orElse.js.map +0 -1
- package/dist/esm/methods/tapErr.js.map +0 -1
- package/dist/esm/methods/transpose.js.map +0 -1
- package/dist/esm/methods/unwrap.js.map +0 -1
- package/dist/esm/methods/unwrapErr.js.map +0 -1
- package/dist/esm/methods/unwrapOr.js.map +0 -1
- package/dist/esm/refiners/refineAsyncResult.js.map +0 -1
- package/dist/esm/refiners/refineAsyncResultU.js.map +0 -1
- package/dist/esm/refiners/refineResult.js.map +0 -1
- package/dist/esm/refiners/refineResultU.js.map +0 -1
- package/dist/esm/refiners/refineVariantMap.js.map +0 -1
- package/dist/esm/refiners/utils/getPayloadKeys.js.map +0 -1
- package/dist/package.json +0 -37
- package/dist/types/methods/expect.d.ts.map +0 -1
- package/dist/types/methods/expectErr.d.ts.map +0 -1
- package/dist/types/methods/unwrap.d.ts.map +0 -1
- package/dist/types/methods/unwrapErr.d.ts.map +0 -1
- package/dist/types/methods/unwrapOr.d.ts.map +0 -1
- package/dist/umd/resultsafe-monorepo-core-fp-result.umd.js.map +0 -1
- /package/{dist/cjs → cjs}/constructors/Err.js +0 -0
- /package/{dist/cjs → cjs}/constructors/Ok.js +0 -0
- /package/{dist/cjs → cjs}/guards/isErr.js +0 -0
- /package/{dist/cjs → cjs}/guards/isErrAnd.js +0 -0
- /package/{dist/cjs → cjs}/guards/isOk.js +0 -0
- /package/{dist/cjs → cjs}/guards/isOkAnd.js +0 -0
- /package/{dist/cjs → cjs}/index.js +0 -0
- /package/{dist/cjs → cjs}/index.js.map +0 -0
- /package/{dist/cjs → cjs}/internal/object.js +0 -0
- /package/{dist/cjs → cjs}/internal/object.js.map +0 -0
- /package/{dist/cjs → cjs}/internal/option.js +0 -0
- /package/{dist/cjs → cjs}/internal/option.js.map +0 -0
- /package/{dist/cjs → cjs}/methods/andThen.js +0 -0
- /package/{dist/cjs → cjs}/methods/err.js +0 -0
- /package/{dist/cjs → cjs}/methods/expect.js +0 -0
- /package/{dist/cjs → cjs}/methods/expectErr.js +0 -0
- /package/{dist/cjs → cjs}/methods/flatten.js +0 -0
- /package/{dist/cjs → cjs}/methods/inspect.js +0 -0
- /package/{dist/cjs → cjs}/methods/inspectErr.js +0 -0
- /package/{dist/cjs → cjs}/methods/map.js +0 -0
- /package/{dist/cjs → cjs}/methods/mapErr.js +0 -0
- /package/{dist/cjs → cjs}/methods/match.js +0 -0
- /package/{dist/cjs → cjs}/methods/ok.js +0 -0
- /package/{dist/cjs → cjs}/methods/orElse.js +0 -0
- /package/{dist/cjs → cjs}/methods/tap.js +0 -0
- /package/{dist/cjs → cjs}/methods/tapErr.js +0 -0
- /package/{dist/cjs → cjs}/methods/transpose.js +0 -0
- /package/{dist/cjs → cjs}/methods/unwrap.js +0 -0
- /package/{dist/cjs → cjs}/methods/unwrapErr.js +0 -0
- /package/{dist/cjs → cjs}/methods/unwrapOr.js +0 -0
- /package/{dist/cjs → cjs}/methods/unwrapOrElse.js +0 -0
- /package/{dist/cjs → cjs}/package.json +0 -0
- /package/{dist/cjs → cjs}/refiners/isTypedVariant.js +0 -0
- /package/{dist/cjs → cjs}/refiners/isTypedVariant.js.map +0 -0
- /package/{dist/cjs → cjs}/refiners/isTypedVariantOf.js +0 -0
- /package/{dist/cjs → cjs}/refiners/isTypedVariantOf.js.map +0 -0
- /package/{dist/cjs → cjs}/refiners/matchVariant.js +0 -0
- /package/{dist/cjs → cjs}/refiners/matchVariant.js.map +0 -0
- /package/{dist/cjs → cjs}/refiners/matchVariantStrict.js +0 -0
- /package/{dist/cjs → cjs}/refiners/matchVariantStrict.js.map +0 -0
- /package/{dist/cjs → cjs}/refiners/refineAsyncResult.js +0 -0
- /package/{dist/cjs → cjs}/refiners/refineAsyncResultU.js +0 -0
- /package/{dist/cjs → cjs}/refiners/refineResult.js +0 -0
- /package/{dist/cjs → cjs}/refiners/refineResultU.js +0 -0
- /package/{dist/cjs → cjs}/refiners/refineVariantMap.js +0 -0
- /package/{dist/cjs → cjs}/refiners/utils/getPayloadKeys.js +0 -0
- /package/{dist/esm → esm}/constructors/Err.js +0 -0
- /package/{dist/esm → esm}/constructors/Ok.js +0 -0
- /package/{dist/esm → esm}/guards/isErr.js +0 -0
- /package/{dist/esm → esm}/guards/isErrAnd.js +0 -0
- /package/{dist/esm → esm}/guards/isOk.js +0 -0
- /package/{dist/esm → esm}/guards/isOkAnd.js +0 -0
- /package/{dist/esm → esm}/index.js +0 -0
- /package/{dist/esm → esm}/index.js.map +0 -0
- /package/{dist/esm → esm}/internal/object.js +0 -0
- /package/{dist/esm → esm}/internal/object.js.map +0 -0
- /package/{dist/esm → esm}/internal/option.js +0 -0
- /package/{dist/esm → esm}/internal/option.js.map +0 -0
- /package/{dist/esm → esm}/methods/andThen.js +0 -0
- /package/{dist/esm → esm}/methods/err.js +0 -0
- /package/{dist/esm → esm}/methods/expect.js +0 -0
- /package/{dist/esm → esm}/methods/expectErr.js +0 -0
- /package/{dist/esm → esm}/methods/flatten.js +0 -0
- /package/{dist/esm → esm}/methods/inspect.js +0 -0
- /package/{dist/esm → esm}/methods/inspectErr.js +0 -0
- /package/{dist/esm → esm}/methods/map.js +0 -0
- /package/{dist/esm → esm}/methods/mapErr.js +0 -0
- /package/{dist/esm → esm}/methods/match.js +0 -0
- /package/{dist/esm → esm}/methods/ok.js +0 -0
- /package/{dist/esm → esm}/methods/orElse.js +0 -0
- /package/{dist/esm → esm}/methods/tap.js +0 -0
- /package/{dist/esm → esm}/methods/tapErr.js +0 -0
- /package/{dist/esm → esm}/methods/transpose.js +0 -0
- /package/{dist/esm → esm}/methods/unwrap.js +0 -0
- /package/{dist/esm → esm}/methods/unwrapErr.js +0 -0
- /package/{dist/esm → esm}/methods/unwrapOr.js +0 -0
- /package/{dist/esm → esm}/methods/unwrapOrElse.js +0 -0
- /package/{dist/esm → esm}/refiners/isTypedVariant.js +0 -0
- /package/{dist/esm → esm}/refiners/isTypedVariant.js.map +0 -0
- /package/{dist/esm → esm}/refiners/isTypedVariantOf.js +0 -0
- /package/{dist/esm → esm}/refiners/isTypedVariantOf.js.map +0 -0
- /package/{dist/esm → esm}/refiners/matchVariant.js +0 -0
- /package/{dist/esm → esm}/refiners/matchVariant.js.map +0 -0
- /package/{dist/esm → esm}/refiners/matchVariantStrict.js +0 -0
- /package/{dist/esm → esm}/refiners/matchVariantStrict.js.map +0 -0
- /package/{dist/esm → esm}/refiners/refineAsyncResult.js +0 -0
- /package/{dist/esm → esm}/refiners/refineAsyncResultU.js +0 -0
- /package/{dist/esm → esm}/refiners/refineResult.js +0 -0
- /package/{dist/esm → esm}/refiners/refineResultU.js +0 -0
- /package/{dist/esm → esm}/refiners/refineVariantMap.js +0 -0
- /package/{dist/esm → esm}/refiners/utils/getPayloadKeys.js +0 -0
- /package/{dist/types → types}/constructors/Err.d.ts +0 -0
- /package/{dist/types → types}/constructors/Err.d.ts.map +0 -0
- /package/{dist/types → types}/constructors/Ok.d.ts +0 -0
- /package/{dist/types → types}/constructors/Ok.d.ts.map +0 -0
- /package/{dist/types → types}/constructors/index.d.ts +0 -0
- /package/{dist/types → types}/constructors/index.d.ts.map +0 -0
- /package/{dist/types → types}/guards/index.d.ts +0 -0
- /package/{dist/types → types}/guards/index.d.ts.map +0 -0
- /package/{dist/types → types}/guards/isErr.d.ts +0 -0
- /package/{dist/types → types}/guards/isErr.d.ts.map +0 -0
- /package/{dist/types → types}/guards/isErrAnd.d.ts +0 -0
- /package/{dist/types → types}/guards/isOk.d.ts +0 -0
- /package/{dist/types → types}/guards/isOk.d.ts.map +0 -0
- /package/{dist/types → types}/guards/isOkAnd.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts.map +0 -0
- /package/{dist/types → types}/internal/object.d.ts +0 -0
- /package/{dist/types → types}/internal/object.d.ts.map +0 -0
- /package/{dist/types → types}/internal/option.d.ts +0 -0
- /package/{dist/types → types}/internal/option.d.ts.map +0 -0
- /package/{dist/types → types}/methods/andThen.d.ts +0 -0
- /package/{dist/types → types}/methods/err.d.ts +0 -0
- /package/{dist/types → types}/methods/expect.d.ts +0 -0
- /package/{dist/types → types}/methods/expectErr.d.ts +0 -0
- /package/{dist/types → types}/methods/flatten.d.ts +0 -0
- /package/{dist/types → types}/methods/flatten.d.ts.map +0 -0
- /package/{dist/types → types}/methods/index.d.ts +0 -0
- /package/{dist/types → types}/methods/index.d.ts.map +0 -0
- /package/{dist/types → types}/methods/inspect.d.ts +0 -0
- /package/{dist/types → types}/methods/inspectErr.d.ts +0 -0
- /package/{dist/types → types}/methods/map.d.ts +0 -0
- /package/{dist/types → types}/methods/mapErr.d.ts +0 -0
- /package/{dist/types → types}/methods/match.d.ts +0 -0
- /package/{dist/types → types}/methods/match.d.ts.map +0 -0
- /package/{dist/types → types}/methods/ok.d.ts +0 -0
- /package/{dist/types → types}/methods/orElse.d.ts +0 -0
- /package/{dist/types → types}/methods/tap.d.ts +0 -0
- /package/{dist/types → types}/methods/tap.d.ts.map +0 -0
- /package/{dist/types → types}/methods/tapErr.d.ts +0 -0
- /package/{dist/types → types}/methods/transpose.d.ts +0 -0
- /package/{dist/types → types}/methods/unwrap.d.ts +0 -0
- /package/{dist/types → types}/methods/unwrapErr.d.ts +0 -0
- /package/{dist/types → types}/methods/unwrapOr.d.ts +0 -0
- /package/{dist/types → types}/methods/unwrapOrElse.d.ts +0 -0
- /package/{dist/types → types}/methods/unwrapOrElse.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/index.d.ts +0 -0
- /package/{dist/types → types}/refiners/index.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/isTypedVariant.d.ts +0 -0
- /package/{dist/types → types}/refiners/isTypedVariant.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/isTypedVariantOf.d.ts +0 -0
- /package/{dist/types → types}/refiners/isTypedVariantOf.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/matchVariant.d.ts +0 -0
- /package/{dist/types → types}/refiners/matchVariant.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/matchVariantStrict.d.ts +0 -0
- /package/{dist/types → types}/refiners/matchVariantStrict.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/refineAsyncResult.d.ts +0 -0
- /package/{dist/types → types}/refiners/refineAsyncResultU.d.ts +0 -0
- /package/{dist/types → types}/refiners/refineResult.d.ts +0 -0
- /package/{dist/types → types}/refiners/refineResultU.d.ts +0 -0
- /package/{dist/types → types}/refiners/refineVariantMap.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/Handler.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/Handler.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/MatchBuilder.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/MatchBuilder.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/Matcher.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/Matcher.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/SyncRefinedResult.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/SyncRefinedResult.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/SyncRefinedResultUnion.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/SyncValidatorMap.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/SyncValidatorMap.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/UniversalAsyncRefinedResult.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/UniversalAsyncRefinedResult.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/UniversalRefinedResult.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/UniversalRefinedResult.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/VariantOf.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/VariantOf.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/types/index.d.ts +0 -0
- /package/{dist/types → types}/refiners/types/index.d.ts.map +0 -0
- /package/{dist/types → types}/refiners/utils/getPayloadKeys.d.ts +0 -0
- /package/{dist/types → types}/refiners/utils/index.d.ts +0 -0
- /package/{dist/types → types}/refiners/utils/index.d.ts.map +0 -0
- /package/{dist/types → types}/shared-types.d.ts +0 -0
- /package/{dist/types → types}/shared-types.d.ts.map +0 -0
- /package/{dist/umd → umd}/resultsafe-monorepo-core-fp-result.umd.js +0 -0
package/dist/README.md
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
# @resultsafe/core-fp-result
|
|
2
|
-
<a id="top"></a>
|
|
3
|
-
|
|
4
|
-

|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/@resultsafe/core-fp-result)
|
|
7
|
-
[](https://www.npmjs.com/package/@resultsafe/core-fp-result)
|
|
8
|
-
[](./LICENSE)
|
|
9
|
-
[](https://www.typescriptlang.org/)
|
|
10
|
-
[](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/README.md)
|
|
11
|
-
[](./package.json)
|
|
12
|
-
[](https://github.com/resultsafe/monorepo)
|
|
13
|
-
|
|
14
|
-
A Rust-inspired Result package for explicit, composable, and type-friendly APIs in TypeScript and JavaScript.
|
|
15
|
-
|
|
16
|
-
**Language:** English | [Русский](https://unpkg.com/@resultsafe/core-fp-result@latest/README.ru.md)
|
|
17
|
-
|
|
18
|
-
**Documentation:** [API index](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/README.md) · [Modules](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/modules.md)
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
## Contents
|
|
22
|
-
|
|
23
|
-
- [Why this package](#why-this-package)
|
|
24
|
-
- [Monorepo context](#monorepo-context)
|
|
25
|
-
- [Key features](#key-features)
|
|
26
|
-
- [Package](#package)
|
|
27
|
-
- [Installation](#installation)
|
|
28
|
-
- [Quick start](#quick-start)
|
|
29
|
-
- [Core API overview](#core-api-overview)
|
|
30
|
-
- [Build and distribution formats](#build-and-distribution-formats)
|
|
31
|
-
- [Monorepo and package structure](#monorepo-and-package-structure)
|
|
32
|
-
- [When to use this project](#when-to-use-this-project)
|
|
33
|
-
- [Documentation links](#documentation-links)
|
|
34
|
-
- [License](#license)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Why this package
|
|
39
|
-
|
|
40
|
-
`@resultsafe/core-fp-result` provides explicit success/error flows instead of hidden control paths and exception-first branching.
|
|
41
|
-
|
|
42
|
-
Its core package, [`@resultsafe/core-fp-result`](https://www.npmjs.com/package/@resultsafe/core-fp-result), provides a Rust-inspired `Result` API for TypeScript and JavaScript with:
|
|
43
|
-
|
|
44
|
-
- explicit `Ok` / `Err`
|
|
45
|
-
- predictable functional composition
|
|
46
|
-
- safe branching through guards and matching
|
|
47
|
-
- disciplined extraction APIs
|
|
48
|
-
- advanced refinement utilities for typed variants and strict matching
|
|
49
|
-
|
|
50
|
-
The goal is not to imitate Rust mechanically, but to bring the same clarity of intent to Node.js libraries: explicit values, predictable branching, and APIs organized for long-term maintenance.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Monorepo context
|
|
55
|
-
|
|
56
|
-
`@resultsafe/core-fp-result` is the TypeScript/JavaScript package inside the multilingual `resultsafe/monorepo`.
|
|
57
|
-
|
|
58
|
-
The monorepo applies shared Rust-inspired design concepts across language-specific packages. TypeScript/JavaScript is the current production package track, while Python is planned as a separate package track with the same conceptual model.
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Key features
|
|
63
|
-
|
|
64
|
-
- Rust-inspired `Result` model for TypeScript and JavaScript.
|
|
65
|
-
- Explicit constructors via `Ok` and `Err`.
|
|
66
|
-
- Composable transformations with APIs such as `map`, `mapErr`, `andThen`, and `orElse`.
|
|
67
|
-
- Safe branching through guards like `isOk`, `isErr`, `isOkAnd`, `isErrAnd`, and matching helpers.
|
|
68
|
-
- Controlled extraction with `unwrap`, `unwrapOr`, `unwrapErr`, `expect`, and `expectErr`.
|
|
69
|
-
- Advanced refinement layer for typed variants, strict matching, and result narrowing.
|
|
70
|
-
- Coherent module structure instead of a flat utility dump.
|
|
71
|
-
- Type output for TypeScript users for better DX and safer integrations.
|
|
72
|
-
- Flexible distribution formats with Types, ESM, CJS, and UMD builds.
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## Package
|
|
77
|
-
|
|
78
|
-
### `@resultsafe/core-fp-result`
|
|
79
|
-
|
|
80
|
-
A focused Result library for explicit error handling and FP-style composition.
|
|
81
|
-
|
|
82
|
-
It is designed for developers who want:
|
|
83
|
-
|
|
84
|
-
- clear success/error modeling
|
|
85
|
-
- predictable transformations
|
|
86
|
-
- explicit branching and extraction
|
|
87
|
-
- better readability in error-heavy flows
|
|
88
|
-
- a structured Rust-inspired API surface in TypeScript/JavaScript
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Installation
|
|
93
|
-
|
|
94
|
-
### Package
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
pnpm add @resultsafe/core-fp-result
|
|
98
|
-
|
|
99
|
-
# Alternative
|
|
100
|
-
npm install @resultsafe/core-fp-result
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Monorepo
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pnpm install
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## Quick start
|
|
112
|
-
|
|
113
|
-
A typical Result flow starts with explicit constructors and then composes through functions rather than implicit exception paths.
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
import {
|
|
117
|
-
Ok,
|
|
118
|
-
map,
|
|
119
|
-
unwrapOr,
|
|
120
|
-
} from "@resultsafe/core-fp-result";
|
|
121
|
-
|
|
122
|
-
const initial = Ok(21);
|
|
123
|
-
const doubled = map(initial, (value) => value * 2);
|
|
124
|
-
const finalValue = unwrapOr(doubled, 0);
|
|
125
|
-
|
|
126
|
-
console.log(finalValue); // 42
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Basic `Ok` / `Err` example
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
import { Ok, Err, match } from "@resultsafe/core-fp-result";
|
|
133
|
-
|
|
134
|
-
const parsePort = (input: string) => {
|
|
135
|
-
const port = Number(input);
|
|
136
|
-
return Number.isInteger(port) && port > 0
|
|
137
|
-
? Ok(port)
|
|
138
|
-
: Err("Invalid port");
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const result = parsePort("3000");
|
|
142
|
-
const message = match(result, (value) => `Port: ${value}`, (error) => `Error: ${error}`);
|
|
143
|
-
|
|
144
|
-
console.log(message);
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Core API overview
|
|
150
|
-
|
|
151
|
-
### Constructors
|
|
152
|
-
|
|
153
|
-
- `Ok`
|
|
154
|
-
- `Err`
|
|
155
|
-
|
|
156
|
-
### Guards
|
|
157
|
-
|
|
158
|
-
- `isOk`
|
|
159
|
-
- `isOkAnd`
|
|
160
|
-
- `isErr`
|
|
161
|
-
- `isErrAnd`
|
|
162
|
-
|
|
163
|
-
### Methods
|
|
164
|
-
|
|
165
|
-
- `andThen`
|
|
166
|
-
- `err`
|
|
167
|
-
- `expect`
|
|
168
|
-
- `expectErr`
|
|
169
|
-
- `flatten`
|
|
170
|
-
- `inspect`
|
|
171
|
-
- `inspectErr`
|
|
172
|
-
- `map`
|
|
173
|
-
- `mapErr`
|
|
174
|
-
- `match`
|
|
175
|
-
- `ok`
|
|
176
|
-
- `orElse`
|
|
177
|
-
- `tap`
|
|
178
|
-
- `tapErr`
|
|
179
|
-
- `transpose`
|
|
180
|
-
- `unwrap`
|
|
181
|
-
- `unwrapErr`
|
|
182
|
-
- `unwrapOr`
|
|
183
|
-
- `unwrapOrElse`
|
|
184
|
-
|
|
185
|
-
### Refiners
|
|
186
|
-
|
|
187
|
-
- `isTypedVariant`
|
|
188
|
-
- `isTypedVariantOf`
|
|
189
|
-
- `matchVariant`
|
|
190
|
-
- `matchVariantStrict`
|
|
191
|
-
- `refineAsyncResult`
|
|
192
|
-
- `refineAsyncResultU`
|
|
193
|
-
- `refineResult`
|
|
194
|
-
- `refineResultU`
|
|
195
|
-
- `refineVariantMap`
|
|
196
|
-
|
|
197
|
-
### Type aliases
|
|
198
|
-
|
|
199
|
-
- `Handler`
|
|
200
|
-
- `MatchBuilder`
|
|
201
|
-
- `Matcher`
|
|
202
|
-
- `SyncRefinedResult`
|
|
203
|
-
- `SyncRefinedResultUnion`
|
|
204
|
-
- `SyncValidatorMap`
|
|
205
|
-
- `UniversalAsyncRefinedResult`
|
|
206
|
-
- `UniversalRefinedResult`
|
|
207
|
-
- `VariantOf`
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## Build and distribution formats
|
|
212
|
-
|
|
213
|
-
- Types: `build:types`
|
|
214
|
-
- ESM: `build:esm`
|
|
215
|
-
- CJS: `build:cjs`
|
|
216
|
-
- UMD: `build:umd`
|
|
217
|
-
|
|
218
|
-
This package ships typed declarations and multiple runtime module formats for broad compatibility.
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## Monorepo and package structure
|
|
223
|
-
|
|
224
|
-
```txt
|
|
225
|
-
src/
|
|
226
|
-
constructors/
|
|
227
|
-
guards/
|
|
228
|
-
methods/
|
|
229
|
-
refiners/
|
|
230
|
-
types/
|
|
231
|
-
utils/
|
|
232
|
-
internal/
|
|
233
|
-
index.ts
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## When to use this project
|
|
239
|
-
|
|
240
|
-
Use this project when you want:
|
|
241
|
-
|
|
242
|
-
- explicit success/error modeling
|
|
243
|
-
- predictable FP-style composition
|
|
244
|
-
- visible control flow
|
|
245
|
-
- stronger type-guided result handling in TypeScript
|
|
246
|
-
- advanced refinement tools for typed variants and strict result matching
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## Documentation links
|
|
251
|
-
|
|
252
|
-
- [API entry (README)](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/README.md)
|
|
253
|
-
- [API entry (index)](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/index.md)
|
|
254
|
-
- [Modules](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/modules.md)
|
|
255
|
-
- [Constructors module](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/constructors/index.md)
|
|
256
|
-
- [Guards module](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/guards/index.md)
|
|
257
|
-
- [Methods module](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/methods/index.md)
|
|
258
|
-
- [Refiners module](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/refiners/index.md)
|
|
259
|
-
- [Type aliases module](https://github.com/resultsafe/monorepo/blob/main/packages/core/fp/result/docs/api/type-aliases/index.md)
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
Back to top: [@resultsafe/core-fp-result](#top)
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
## Author
|
|
266
|
-
|
|
267
|
-
Denis Savasteev
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
## License
|
|
272
|
-
|
|
273
|
-
[MIT](./LICENSE)
|
package/dist/README.ru.md
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
# @resultsafe/core-fp-result
|
|
2
|
-
|
|
3
|
-
<a id="top"></a>
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@resultsafe/core-fp-result)
|
|
6
|
-
[](https://www.npmjs.com/package/@resultsafe/core-fp-result)
|
|
7
|
-
[](./LICENSE)
|
|
8
|
-
[](https://www.typescriptlang.org/)
|
|
9
|
-
[](./docs/api/README.md)
|
|
10
|
-
[](./package.json)
|
|
11
|
-
[](https://github.com/resultsafe/monorepo)
|
|
12
|
-
|
|
13
|
-
Rust-inspired Result-пакет для явных, композиционных и типобезопасных API в TypeScript и JavaScript.
|
|
14
|
-
|
|
15
|
-
**Язык:** [English](./README.md) | Русский
|
|
16
|
-
|
|
17
|
-
**Документация:** [API index](./docs/api/README.md) · [Modules](./docs/api/modules.md)
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Содержание
|
|
22
|
-
|
|
23
|
-
- [@resultsafe/core-fp-result](#resultsafecore-fp-result)
|
|
24
|
-
- [Содержание](#содержание)
|
|
25
|
-
- [Зачем нужен этот пакет](#зачем-нужен-этот-пакет)
|
|
26
|
-
- [Контекст monorepo](#контекст-monorepo)
|
|
27
|
-
- [Ключевые возможности](#ключевые-возможности)
|
|
28
|
-
- [Пакет](#пакет)
|
|
29
|
-
- [`@resultsafe/core-fp-result`](#resultsafecore-fp-result-1)
|
|
30
|
-
- [Установка](#установка)
|
|
31
|
-
- [Пакет](#пакет-1)
|
|
32
|
-
- [Monorepo](#monorepo)
|
|
33
|
-
- [Быстрый старт](#быстрый-старт)
|
|
34
|
-
- [Базовый пример `Ok` / `Err`](#базовый-пример-ok--err)
|
|
35
|
-
- [Обзор основного API](#обзор-основного-api)
|
|
36
|
-
- [Constructors](#constructors)
|
|
37
|
-
- [Guards](#guards)
|
|
38
|
-
- [Methods](#methods)
|
|
39
|
-
- [Refiners](#refiners)
|
|
40
|
-
- [Type aliases](#type-aliases)
|
|
41
|
-
- [Форматы сборки и поставки](#форматы-сборки-и-поставки)
|
|
42
|
-
- [Структура monorepo и пакета](#структура-monorepo-и-пакета)
|
|
43
|
-
- [Когда использовать этот проект](#когда-использовать-этот-проект)
|
|
44
|
-
- [Ссылки на документацию](#ссылки-на-документацию)
|
|
45
|
-
- [License](#license)
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## Зачем нужен этот пакет
|
|
50
|
-
|
|
51
|
-
`@resultsafe/core-fp-result` предоставляет явные success/error flow вместо скрытых путей управления и exception-first ветвления.
|
|
52
|
-
|
|
53
|
-
Его основной пакет, [`@resultsafe/core-fp-result`](https://www.npmjs.com/package/@resultsafe/core-fp-result), предоставляет Rust-inspired `Result` API для TypeScript и JavaScript со следующими свойствами:
|
|
54
|
-
|
|
55
|
-
- явные `Ok` / `Err`
|
|
56
|
-
- предсказуемая функциональная композиция
|
|
57
|
-
- безопасное ветвление через guards и matching
|
|
58
|
-
- дисциплинированные API извлечения значений
|
|
59
|
-
- продвинутые refinement utilities для typed variants и strict matching
|
|
60
|
-
|
|
61
|
-
Цель проекта не в механическом копировании Rust, а в переносе той же ясности намерений в Node.js-библиотеки: явные значения, предсказуемое ветвление и API, организованные для долгосрочного сопровождения.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Контекст monorepo
|
|
66
|
-
|
|
67
|
-
`@resultsafe/core-fp-result` — это пакет TypeScript/JavaScript внутри мультиязычного `resultsafe/monorepo`.
|
|
68
|
-
|
|
69
|
-
Монорепозиторий переносит общие Rust-inspired концепции в отдельные language-specific пакеты. Текущий production-трек — TypeScript/JavaScript, а Python планируется как отдельный пакетный трек с той же концептуальной моделью.
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Ключевые возможности
|
|
74
|
-
|
|
75
|
-
- Rust-inspired модель `Result` для TypeScript и JavaScript.
|
|
76
|
-
- Явные конструкторы через `Ok` и `Err`.
|
|
77
|
-
- Композиционные трансформации через API, такие как `map`, `mapErr`, `andThen` и `orElse`.
|
|
78
|
-
- Безопасное ветвление через guards `isOk`, `isErr`, `isOkAnd`, `isErrAnd` и matching helpers.
|
|
79
|
-
- Контролируемое извлечение через `unwrap`, `unwrapOr`, `unwrapErr`, `expect` и `expectErr`.
|
|
80
|
-
- Продвинутый слой refiners для typed variants, strict matching и сужения результатов.
|
|
81
|
-
- Согласованная модульная структура вместо плоского набора утилит.
|
|
82
|
-
- Type output для TypeScript-пользователей для лучшего DX и более безопасных интеграций.
|
|
83
|
-
- Гибкие форматы поставки: Types, ESM, CJS и UMD.
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Пакет
|
|
88
|
-
|
|
89
|
-
### `@resultsafe/core-fp-result`
|
|
90
|
-
|
|
91
|
-
Фокусированная Result-библиотека для явной обработки ошибок и FP-style композиции.
|
|
92
|
-
|
|
93
|
-
Она рассчитана на разработчиков, которым нужны:
|
|
94
|
-
|
|
95
|
-
- ясное моделирование успеха/ошибки
|
|
96
|
-
- предсказуемые трансформации
|
|
97
|
-
- явное ветвление и извлечение значений
|
|
98
|
-
- лучшая читаемость в error-heavy flow
|
|
99
|
-
- структурированная Rust-inspired API surface в TypeScript/JavaScript
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Установка
|
|
104
|
-
|
|
105
|
-
### Пакет
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
pnpm add @resultsafe/core-fp-result
|
|
109
|
-
|
|
110
|
-
# Альтернатива
|
|
111
|
-
npm install @resultsafe/core-fp-result
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Monorepo
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
pnpm install
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## Быстрый старт
|
|
123
|
-
|
|
124
|
-
Типичный Result flow начинается с явных конструкторов и затем компонуется через функции, а не через неявные пути исключений.
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
import { Ok, map, unwrapOr } from '@resultsafe/core-fp-result';
|
|
128
|
-
|
|
129
|
-
const initial = Ok(21);
|
|
130
|
-
const doubled = map(initial, (value) => value * 2);
|
|
131
|
-
const finalValue = unwrapOr(doubled, 0);
|
|
132
|
-
|
|
133
|
-
console.log(finalValue); // 42
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Базовый пример `Ok` / `Err`
|
|
137
|
-
|
|
138
|
-
```ts
|
|
139
|
-
import { Ok, Err, match } from '@resultsafe/core-fp-result';
|
|
140
|
-
|
|
141
|
-
const parsePort = (input: string) => {
|
|
142
|
-
const port = Number(input);
|
|
143
|
-
return Number.isInteger(port) && port > 0 ? Ok(port) : Err('Invalid port');
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const result = parsePort('3000');
|
|
147
|
-
const message = match(
|
|
148
|
-
result,
|
|
149
|
-
(value) => `Port: ${value}`,
|
|
150
|
-
(error) => `Error: ${error}`,
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
console.log(message);
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## Обзор основного API
|
|
159
|
-
|
|
160
|
-
### Constructors
|
|
161
|
-
|
|
162
|
-
- `Ok`
|
|
163
|
-
- `Err`
|
|
164
|
-
|
|
165
|
-
### Guards
|
|
166
|
-
|
|
167
|
-
- `isOk`
|
|
168
|
-
- `isOkAnd`
|
|
169
|
-
- `isErr`
|
|
170
|
-
- `isErrAnd`
|
|
171
|
-
|
|
172
|
-
### Methods
|
|
173
|
-
|
|
174
|
-
- `andThen`
|
|
175
|
-
- `err`
|
|
176
|
-
- `expect`
|
|
177
|
-
- `expectErr`
|
|
178
|
-
- `flatten`
|
|
179
|
-
- `inspect`
|
|
180
|
-
- `inspectErr`
|
|
181
|
-
- `map`
|
|
182
|
-
- `mapErr`
|
|
183
|
-
- `match`
|
|
184
|
-
- `ok`
|
|
185
|
-
- `orElse`
|
|
186
|
-
- `tap`
|
|
187
|
-
- `tapErr`
|
|
188
|
-
- `transpose`
|
|
189
|
-
- `unwrap`
|
|
190
|
-
- `unwrapErr`
|
|
191
|
-
- `unwrapOr`
|
|
192
|
-
- `unwrapOrElse`
|
|
193
|
-
|
|
194
|
-
### Refiners
|
|
195
|
-
|
|
196
|
-
- `isTypedVariant`
|
|
197
|
-
- `isTypedVariantOf`
|
|
198
|
-
- `matchVariant`
|
|
199
|
-
- `matchVariantStrict`
|
|
200
|
-
- `refineAsyncResult`
|
|
201
|
-
- `refineAsyncResultU`
|
|
202
|
-
- `refineResult`
|
|
203
|
-
- `refineResultU`
|
|
204
|
-
- `refineVariantMap`
|
|
205
|
-
|
|
206
|
-
### Type aliases
|
|
207
|
-
|
|
208
|
-
- `Handler`
|
|
209
|
-
- `MatchBuilder`
|
|
210
|
-
- `Matcher`
|
|
211
|
-
- `SyncRefinedResult`
|
|
212
|
-
- `SyncRefinedResultUnion`
|
|
213
|
-
- `SyncValidatorMap`
|
|
214
|
-
- `UniversalAsyncRefinedResult`
|
|
215
|
-
- `UniversalRefinedResult`
|
|
216
|
-
- `VariantOf`
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## Форматы сборки и поставки
|
|
221
|
-
|
|
222
|
-
- Types: `build:types`
|
|
223
|
-
- ESM: `build:esm`
|
|
224
|
-
- CJS: `build:cjs`
|
|
225
|
-
- UMD: `build:umd`
|
|
226
|
-
|
|
227
|
-
Пакет публикует typed declarations и несколько runtime-форматов модулей для широкой совместимости.
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## Структура monorepo и пакета
|
|
232
|
-
|
|
233
|
-
```txt
|
|
234
|
-
src/
|
|
235
|
-
constructors/
|
|
236
|
-
guards/
|
|
237
|
-
methods/
|
|
238
|
-
refiners/
|
|
239
|
-
types/
|
|
240
|
-
utils/
|
|
241
|
-
internal/
|
|
242
|
-
index.ts
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## Когда использовать этот проект
|
|
248
|
-
|
|
249
|
-
Используйте проект, если вам нужны:
|
|
250
|
-
|
|
251
|
-
- явное моделирование успеха/ошибки
|
|
252
|
-
- предсказуемая FP-style композиция
|
|
253
|
-
- видимый control flow
|
|
254
|
-
- более сильная type-guided обработка результатов в TypeScript
|
|
255
|
-
- продвинутые refinement tools для typed variants и строгого result matching
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## Ссылки на документацию
|
|
260
|
-
|
|
261
|
-
- [API entry (README)](./docs/api/README.md)
|
|
262
|
-
- [API entry (index)](./docs/api/index.md)
|
|
263
|
-
- [Modules](./docs/api/modules.md)
|
|
264
|
-
- [Constructors module](./docs/api/constructors/index.md)
|
|
265
|
-
- [Guards module](./docs/api/guards/index.md)
|
|
266
|
-
- [Methods module](./docs/api/methods/index.md)
|
|
267
|
-
- [Refiners module](./docs/api/refiners/index.md)
|
|
268
|
-
- [Type aliases module](./docs/api/type-aliases/index.md)
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
Наверх: [@resultsafe/core-fp-result](#top)
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## License
|
|
277
|
-
|
|
278
|
-
[MIT](./LICENSE)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isErrAnd.js","sources":["../../../src/guards/isErrAnd.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from './isErr.js';\n\n/**\n * Проверяет, что `Result` завершился ошибкой и удовлетворяет предикату.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @param predicate - Предикат, применяемый к значению ошибки.\n * @returns `true` when the value is `Err` and the predicate returns `true`.\n * @since 0.1.0\n * @see {@link isErr} - Performs the base error check.\n * @example\n * ```ts\n * import { Err, isErrAnd } from '@resultsafe/core-fp-result';\n *\n * const result = Err({ code: 503 });\n * console.log(isErrAnd(result, (error) => error.code >= 500)); // true\n * ```\n * @public\n */\nexport const isErrAnd = <T, E>(\n result: Result<T, E>,\n predicate: (error: E) => boolean,\n): boolean => isErr(result) && predicate(result.error);\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAuBO,MAAM,WAAW,CACtB,QACA,cACYA,MAAAA,MAAM,MAAM,KAAK,UAAU,OAAO,KAAK;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isOkAnd.js","sources":["../../../src/guards/isOkAnd.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from './isOk.js';\n\n/**\n * Проверяет, что `Result` успешен и удовлетворяет предикату.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @param predicate - Предикат, применяемый к успешному значению.\n * @returns `true` when the value is `Ok` and the predicate returns `true`.\n * @since 0.1.0\n * @see {@link isOk} - Performs the base success check.\n * @example\n * ```ts\n * import { Ok, isOkAnd } from '@resultsafe/core-fp-result';\n *\n * const result = Ok(8);\n * console.log(isOkAnd(result, (value) => value % 2 === 0)); // true\n * ```\n * @public\n */\nexport const isOkAnd = <T, E>(\n result: Result<T, E>,\n predicate: (value: T) => boolean,\n): boolean => isOk(result) && predicate(result.value);\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAuBO,MAAM,UAAU,CACrB,QACA,cACYA,KAAAA,KAAK,MAAM,KAAK,UAAU,OAAO,KAAK;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"andThen.js","sources":["../../../src/methods/andThen.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Цепляет вычисление, которое возвращает другой `Result`.\n *\n * @typeParam T - The input success type.\n * @typeParam U - The output success type.\n * @typeParam E - Общий тип ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция, применяемая, когда `result` имеет `Ok`.\n * @returns Преобразованный `Result` или исходный `Err`.\n * @since 0.1.0\n * @see {@link map} - Преобразует только успешное значение.\n * @example\n * ```ts\n * import { Ok, Err, andThen } from '@resultsafe/core-fp-result';\n *\n * const parsed = andThen(Ok('12'), (value) => {\n * const n = Number(value);\n * return Number.isNaN(n) ? Err('invalid') : Ok(n);\n * });\n * console.log(parsed.ok); // true\n * ```\n * @public\n */\nexport const andThen = <T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => Result<U, E>,\n): Result<U, E> => (isOk(result) ? fn(result.value) : (result as Result<U, E>));\n\r\n\r\n"],"names":["isOk"],"mappings":";;AA2BO,MAAM,UAAU,CACrB,QACA,OACkBA,KAAAA,KAAK,MAAM,IAAI,GAAG,OAAO,KAAK,IAAK;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"err.js","sources":["../../../src/methods/err.ts"],"sourcesContent":["import { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\nimport { None, Some } from '../internal/option.js';\n\n/**\n * Извлекает ветку ошибки в виде `Option`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @returns `Some(error)` для `Err`, иначе `None`.\n * @since 0.1.0\n * @see {@link ok} - Извлекает ветку успеха.\n * @example\n * ```ts\n * import { Err, err } from '@resultsafe/core-fp-result';\n *\n * const value = err(Err('boom'));\n * console.log(value.some); // true\n * ```\n * @public\n */\nexport const err = <T, E>(result: Result<T, E>): Option<E> =>\n isErr(result) ? Some(result.error) : None;\n\r\n\r\n"],"names":["isErr","Some","None"],"mappings":";;;AAwBO,MAAM,MAAM,CAAO,WACxBA,YAAM,MAAM,IAAIC,YAAK,OAAO,KAAK,IAAIC,OAAAA;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sources":["../../../src/methods/expect.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Возвращает успешное значение или выбрасывает исключение с пользовательским сообщением.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param msg - Сообщение об ошибке, используемое когда `result` имеет `Err`.\n * @returns Распакованное успешное значение.\n * @throws Error - Выбрасывает исключение, когда `result` имеет `Err`.\n * @since 0.1.0\n * @see {@link expectErr} - Симметричный helper для ветки ошибки.\n * @example\n * ```ts\n * import { Ok, expect } from '@resultsafe/core-fp-result';\n *\n * const value = expect(Ok(5), 'must be ok');\n * console.log(value); // 5\n * ```\n * @public\n */\nexport const expect = <T, E>(result: Result<T, E>, msg: string): T => {\n if (isOk(result)) {\n return result.value;\n }\n throw new Error(msg);\n};\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAwBO,MAAM,SAAS,CAAO,QAAsB,QAAmB;AACpE,MAAIA,KAAAA,KAAK,MAAM,GAAG;AAChB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,GAAG;AACrB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expectErr.js","sources":["../../../src/methods/expectErr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Возвращает значение ошибки или выбрасывает исключение с пользовательским сообщением.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param msg - Сообщение об ошибке, используемое когда `result` имеет `Ok`.\n * @returns Распакованное значение ошибки.\n * @throws Error - Выбрасывает исключение, когда `result` имеет `Ok`.\n * @since 0.1.0\n * @see {@link expect} - Симметричный helper для ветки успеха.\n * @example\n * ```ts\n * import { Err, expectErr } from '@resultsafe/core-fp-result';\n *\n * const error = expectErr(Err('boom'), 'must be err');\n * console.log(error); // boom\n * ```\n * @public\n */\nexport const expectErr = <T, E>(result: Result<T, E>, msg: string): E => {\n if (isErr(result)) {\n return result.error;\n }\n throw new Error(msg);\n};\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAwBO,MAAM,YAAY,CAAO,QAAsB,QAAmB;AACvE,MAAIA,MAAAA,MAAM,MAAM,GAAG;AACjB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,GAAG;AACrB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.js","sources":["../../../src/methods/inspect.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Выполняет побочный эффект для успешного значения и возвращает исходный `Result`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция побочного эффекта для ветки успеха.\n * @returns Тот же экземпляр `Result`.\n * @since 0.1.0\n * @see {@link tap} - Эквивалентный helper для ветки успеха.\n * @example\n * ```ts\n * import { Ok, inspect } from '@resultsafe/core-fp-result';\n *\n * const result = inspect(Ok(1), (value) => console.log(value)); // 1\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const inspect = <T, E>(\n result: Result<T, E>,\n fn: (value: T) => void,\n): Result<T, E> => {\n if (isOk(result)) {\n fn(result.value);\n }\n return result;\n};\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAuBO,MAAM,UAAU,CACrB,QACA,OACiB;AACjB,MAAIA,KAAAA,KAAK,MAAM,GAAG;AAChB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inspectErr.js","sources":["../../../src/methods/inspectErr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Выполняет побочный эффект для значения ошибки и возвращает исходный `Result`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция побочного эффекта для ветки ошибки.\n * @returns Тот же экземпляр `Result`.\n * @since 0.1.0\n * @see {@link tapErr} - Эквивалентный helper для ветки ошибки.\n * @example\n * ```ts\n * import { Err, inspectErr } from '@resultsafe/core-fp-result';\n *\n * const result = inspectErr(Err('boom'), (error) => console.log(error)); // boom\n * console.log(result.ok); // false\n * ```\n * @public\n */\nexport const inspectErr = <T, E>(\n result: Result<T, E>,\n fn: (error: E) => void,\n): Result<T, E> => {\n if (isErr(result)) {\n fn(result.error);\n }\n return result;\n};\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAuBO,MAAM,aAAa,CACxB,QACA,OACiB;AACjB,MAAIA,MAAAA,MAAM,MAAM,GAAG;AACjB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sources":["../../../src/methods/map.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Преобразует успешное значение, сохраняя ветку ошибки.\n *\n * @typeParam T - Тип входного успешного значения.\n * @typeParam U - Тип выходного успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция преобразования успешного значения.\n * @returns Преобразованный `Ok` или исходный `Err`.\n * @since 0.1.0\n * @see {@link mapErr} - Преобразует ветку ошибки.\n * @example\n * ```ts\n * import { Ok, map } from '@resultsafe/core-fp-result';\n *\n * const result = map(Ok(2), (value) => value * 10);\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const map = <T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => U,\n): Result<U, E> =>\n isOk(result)\n ? { ok: true, value: fn(result.value) }\n : (result as Result<U, E>);\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAwBO,MAAM,MAAM,CACjB,QACA,OAEAA,KAAAA,KAAK,MAAM,IACP,EAAE,IAAI,MAAM,OAAO,GAAG,OAAO,KAAK,MACjC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapErr.js","sources":["../../../src/methods/mapErr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Преобразует значение ошибки, сохраняя ветку успеха.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип входного значения ошибки.\n * @typeParam F - Тип выходного значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция преобразования значения ошибки.\n * @returns Преобразованный `Err` или исходный `Ok`.\n * @since 0.1.0\n * @see {@link map} - Transforms the success branch.\n * @example\n * ```ts\n * import { Err, mapErr } from '@resultsafe/core-fp-result';\n *\n * const result = mapErr(Err('e1'), (error) => `mapped:${error}`);\n * console.log(result.ok); // false\n * ```\n * @public\n */\nexport const mapErr = <T, E, F>(\n result: Result<T, E>,\n fn: (error: E) => F,\n): Result<T, F> =>\n isErr(result)\n ? { ok: false, error: fn(result.error) }\n : (result as Result<T, F>);\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAwBO,MAAM,SAAS,CACpB,QACA,OAEAA,MAAAA,MAAM,MAAM,IACR,EAAE,IAAI,OAAO,OAAO,GAAG,OAAO,KAAK,MAClC;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ok.js","sources":["../../../src/methods/ok.ts"],"sourcesContent":["import { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\nimport { None, Some } from '../internal/option.js';\n\n/**\n * Извлекает успешную ветку в виде `Option`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @returns `Some(value)` для `Ok`, иначе `None`.\n * @since 0.1.0\n * @see {@link err} - Извлекает ветку ошибки.\n * @example\n * ```ts\n * import { Ok, ok } from '@resultsafe/core-fp-result';\n *\n * const value = ok(Ok(10));\n * console.log(value.some); // true\n * ```\n * @public\n */\nexport const ok = <T, E>(result: Result<T, E>): Option<T> =>\n isOk(result) ? Some(result.value) : None;\n\r\n\r\n"],"names":["isOk","Some","None"],"mappings":";;;AAwBO,MAAM,KAAK,CAAO,WACvBA,UAAK,MAAM,IAAIC,YAAK,OAAO,KAAK,IAAIC,OAAAA;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orElse.js","sources":["../../../src/methods/orElse.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Восстанавливается из ошибки, преобразуя `Err` в другой `Result`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип входного значения ошибки.\n * @typeParam F - Тип выходного значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция восстановления, применяемая для `Err`.\n * @returns Восстановленный `Result` или исходный `Ok`.\n * @since 0.1.0\n * @see {@link andThen} - Цепляет ветку успеха.\n * @example\n * ```ts\n * import { Err, Ok, orElse } from '@resultsafe/core-fp-result';\n *\n * const result = orElse(Err('network'), () => Ok('cached'));\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const orElse = <T, E, F>(\n result: Result<T, E>,\n fn: (error: E) => Result<T, F>,\n): Result<T, F> =>\n isErr(result) ? fn(result.error) : (result as Result<T, F>);\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAwBO,MAAM,SAAS,CACpB,QACA,OAEAA,MAAAA,MAAM,MAAM,IAAI,GAAG,OAAO,KAAK,IAAK;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tapErr.js","sources":["../../../src/methods/tapErr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Выполняет побочный эффект для значения `Err` и возвращает входной `Result`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Колбэк побочного эффекта для ветки ошибки.\n * @returns Неизмененный `Result`.\n * @since 0.1.0\n * @see {@link tap} - Executes a side effect for the success branch.\n * @example\n * ```ts\n * import { Err, tapErr } from '@resultsafe/core-fp-result';\n *\n * const result = tapErr(Err('boom'), (error) => console.log(error)); // boom\n * console.log(result.ok); // false\n * ```\n * @public\n */\nexport const tapErr = <T, E>(\n result: Result<T, E>,\n fn: (error: E) => void,\n): Result<T, E> => {\n if (isErr(result)) {\n fn(result.error);\n }\n return result;\n};\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAuBO,MAAM,SAAS,CACpB,QACA,OACiB;AACjB,MAAIA,MAAAA,MAAM,MAAM,GAAG;AACjB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transpose.js","sources":["../../../src/methods/transpose.ts"],"sourcesContent":["import { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.js';\n\nimport { None, Some } from '../internal/option.js';\n\n/**\n * Преобразует `Result<Option<T>, E>` в `Option<Result<T, E>>`.\n *\n * @typeParam T - The success value type inside `Option`.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`, содержащий `Option`.\n * @returns Транспонированный `Option<Result<T, E>>`.\n * @since 0.1.0\n * @see {@link flatten} - Collapses nested `Result` values.\n * @example\n * ```ts\n * import { Ok, transpose } from '@resultsafe/core-fp-result';\n *\n * const value = transpose(Ok({ some: true, value: 2 }));\n * console.log(value.some); // true\n * ```\n * @public\n */\nexport const transpose = <T, E>(\n result: Result<Option<T>, E>,\n): Option<Result<T, E>> => {\n if (result.ok) {\n return result.value.some === true\n ? Some({ ok: true, value: result.value.value })\n : None;\n }\n return Some({ ok: false, error: result.error });\n};\n\r\n\r\n"],"names":["Some","None"],"mappings":";;AAuBO,MAAM,YAAY,CACvB,WACyB;AACzB,MAAI,OAAO,IAAI;AACb,WAAO,OAAO,MAAM,SAAS,OACzBA,OAAAA,KAAK,EAAE,IAAI,MAAM,OAAO,OAAO,MAAM,MAAA,CAAO,IAC5CC,OAAAA;AAAAA,EACN;AACA,SAAOD,OAAAA,KAAK,EAAE,IAAI,OAAO,OAAO,OAAO,OAAO;AAChD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrap.js","sources":["../../../src/methods/unwrap.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Возвращает успешное значение или выбрасывает исключение, если результат `Err`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @returns Payload успеха.\n * @throws Error - Выбрасывает исключение при вызове на `Err`.\n * @since 0.1.0\n * @see {@link unwrapOr} - Возвращает fallback вместо выброса исключения.\n * @example\n * ```ts\n * import { Ok, unwrap } from '@resultsafe/core-fp-result';\n *\n * const value = unwrap(Ok(9));\n * console.log(value); // 9\n * ```\n * @public\n */\nexport const unwrap = <T, E>(result: Result<T, E>): T => {\n if (isOk(result)) {\n return result.value;\n }\n throw new Error('Called unwrap on an Err value');\n};\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAuBO,MAAM,SAAS,CAAO,WAA4B;AACvD,MAAIA,KAAAA,KAAK,MAAM,GAAG;AAChB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,+BAA+B;AACjD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapErr.js","sources":["../../../src/methods/unwrapErr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isErr } from '../guards/isErr.js';\n\n/**\n * Возвращает значение ошибки или выбрасывает исключение, если результат `Ok`.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @returns Payload ошибки.\n * @throws Error - Выбрасывает исключение при вызове на `Ok`.\n * @since 0.1.0\n * @see {@link unwrapOrElse} - Возвращает fallback успеха без выброса исключения.\n * @example\n * ```ts\n * import { Err, unwrapErr } from '@resultsafe/core-fp-result';\n *\n * const error = unwrapErr(Err('boom'));\n * console.log(error); // boom\n * ```\n * @public\n */\nexport const unwrapErr = <T, E>(result: Result<T, E>): E => {\n if (isErr(result)) {\n return result.error;\n }\n throw new Error('Called unwrapErr on an Ok value');\n};\n\r\n\r\n"],"names":["isErr"],"mappings":";;AAuBO,MAAM,YAAY,CAAO,WAA4B;AAC1D,MAAIA,MAAAA,MAAM,MAAM,GAAG;AACjB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,iCAAiC;AACnD;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapOr.js","sources":["../../../src/methods/unwrapOr.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\nimport { isOk } from '../guards/isOk.js';\n\n/**\n * Возвращает успешное значение или переданный fallback по умолчанию.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param defaultValue - Fallback-значение для `Err`.\n * @returns Payload успеха или `defaultValue`.\n * @since 0.1.0\n * @see {@link unwrapOrElse} - Вычисляет fallback лениво.\n * @example\n * ```ts\n * import { Err, unwrapOr } from '@resultsafe/core-fp-result';\n *\n * const value = unwrapOr(Err('boom'), 0);\n * console.log(value); // 0\n * ```\n * @public\n */\nexport const unwrapOr = <T, E>(result: Result<T, E>, defaultValue: T): T =>\n isOk(result) ? result.value : defaultValue;\n\r\n\r\n"],"names":["isOk"],"mappings":";;AAuBO,MAAM,WAAW,CAAO,QAAsB,iBACnDA,KAAAA,KAAK,MAAM,IAAI,OAAO,QAAQ;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refineAsyncResult.js","sources":["../../../src/refiners/refineAsyncResult.ts"],"sourcesContent":["import type {\n AsyncValidatorFn,\n PayloadKeys,\n VariantConfig,\n} from '../shared-types.js';\n\nimport { hasOwn, isObject } from '../internal/object.js';\nimport type { UniversalAsyncRefinedResult } from './types/index.js';\n\n/** Resolves payload keys from variant configuration. @internal */\nconst getPayloadKeys = <C extends VariantConfig>(\n config: C,\n): readonly PayloadKeys<C>[] => {\n const p = config.payload;\n if (p === 'never') return [];\n return (Array.isArray(p) ? p : [p]) as readonly PayloadKeys<C>[];\n};\n\n/**\n * Создает асинхронный refiner варианта с асинхронными валидаторами payload.\n *\n * @typeParam TMap - Тип карты конфигурации вариантов.\n * @param variantMap - Карта, описывающая допустимые варианты и поля payload.\n * @returns A curried async refiner factory bound to `variantMap`.\n * @since 0.1.0\n * @see {@link refineAsyncResultU} - Непосредственный (не-curry) вариант helper.\n * @example\n * ```ts\n * import { refineAsyncResult } from '@resultsafe/core-fp-result';\n *\n * const map = { ok: { payload: 'value' } } as const;\n * const refineOk = refineAsyncResult(map)('ok')({\n * value: async (x: unknown) => typeof x === 'number',\n * });\n *\n * console.log(await refineOk({ type: 'ok', value: 1 })); // { type: 'ok', value: 1 }\n * ```\n * @public\n */\nexport const refineAsyncResult =\n <TMap extends Record<string, VariantConfig>>(variantMap: TMap) =>\n <K extends keyof TMap & string>(variant: K) =>\n <TValidators extends Partial<Record<PayloadKeys<TMap[K]>, AsyncValidatorFn>>>(\n validators: TValidators,\n ) =>\n async (\n value: unknown,\n ): Promise<UniversalAsyncRefinedResult<K, TMap, TValidators> | null> => {\n if (!isObject(value)) return null;\n if (!hasOwn(value, 'type')) return null;\n\n const t = value['type'];\n if (t !== variant) return null;\n\n const config = variantMap[variant];\n if (!config) return null;\n\n const keys = getPayloadKeys(config);\n for (const key of keys) {\n const check = validators?.[key];\n if (!check) continue;\n\n const field = value[key as keyof typeof value];\n const isValid = await check(field); // ✅ Асинхронная валидация\n if (!isValid) return null;\n }\n\n return value as UniversalAsyncRefinedResult<K, TMap, TValidators>;\n };\n\n/**\n * Уточняет значение асинхронно в не-curry стиле вызова.\n *\n * @typeParam TMap - Тип карты конфигурации вариантов.\n * @typeParam K - Ключ целевого варианта.\n * @typeParam TValidators - Карта асинхронных валидаторов для полей payload.\n * @param value - Значение для валидации и уточнения.\n * @param variant - Ключ целевого варианта.\n * @param variantMap - Карта конфигурации вариантов.\n * @param validators - Асинхронные валидаторы payload.\n * @returns Промис с уточненным значением или `null`.\n * @remarks\n * This export is kept for compatibility. Prefer {@link refineAsyncResultU}\n * from `refineAsyncResultU.ts` как каноническую точку входа без curry.\n * @since 0.1.0\n * @example\n * ```ts\n * import { refineAsyncResultU } from '@resultsafe/core-fp-result/src/refiners/refineAsyncResult.js';\n *\n * const map = { ok: { payload: 'value' } } as const;\n * const out = await refineAsyncResultU({ type: 'ok', value: 1 }, 'ok', map, {\n * value: async (x: unknown) => typeof x === 'number',\n * });\n *\n * console.log(out?.type); // ok\n * ```\n * @internal\n */\nexport const refineAsyncResultU = <\n TMap extends Record<string, VariantConfig>,\n K extends keyof TMap & string,\n TValidators extends Partial<Record<PayloadKeys<TMap[K]>, AsyncValidatorFn>>,\n>(\n value: unknown,\n variant: K,\n variantMap: TMap,\n validators: TValidators,\n): Promise<UniversalAsyncRefinedResult<K, TMap, TValidators> | null> =>\n refineAsyncResult(variantMap)(variant)(validators)(value);\n\r\n\r\n"],"names":["isObject","hasOwn"],"mappings":";;AAUA,MAAM,iBAAiB,CACrB,WAC8B;AAC9B,QAAM,IAAI,OAAO;AACjB,MAAI,MAAM,QAAS,QAAO,CAAA;AAC1B,SAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACnC;AAuBO,MAAM,oBACX,CAA6C,eAC7C,CAAgC,YAChC,CACE,eAEF,OACE,UACsE;AACtE,MAAI,CAACA,OAAAA,SAAS,KAAK,EAAG,QAAO;AAC7B,MAAI,CAACC,OAAAA,OAAO,OAAO,MAAM,EAAG,QAAO;AAEnC,QAAM,IAAI,MAAM,MAAM;AACtB,MAAI,MAAM,QAAS,QAAO;AAE1B,QAAM,SAAS,WAAW,OAAO;AACjC,MAAI,CAAC,OAAQ,QAAO;AAEpB,QAAM,OAAO,eAAe,MAAM;AAClC,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,aAAa,GAAG;AAC9B,QAAI,CAAC,MAAO;AAEZ,UAAM,QAAQ,MAAM,GAAyB;AAC7C,UAAM,UAAU,MAAM,MAAM,KAAK;AACjC,QAAI,CAAC,QAAS,QAAO;AAAA,EACvB;AAEA,SAAO;AACT;;"}
|