@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: CONTEXT
|
|
3
|
+
uuid: 3143ad43-830e-4a51-9795-c484204e0e00
|
|
4
|
+
title: "@resultsafe/core-fp-result — Package Context"
|
|
5
|
+
status: canonical
|
|
6
|
+
layer: authored
|
|
7
|
+
lang: en
|
|
8
|
+
scope: package
|
|
9
|
+
package: "@resultsafe/core-fp-result"
|
|
10
|
+
owner: Denis
|
|
11
|
+
created: 2026-03-26
|
|
12
|
+
updated: 2026-03-26
|
|
13
|
+
links: []
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# @resultsafe/core-fp-result — Package Context
|
|
17
|
+
|
|
18
|
+
<!-- AGENT: update only when this package's purpose or scope changes -->
|
|
19
|
+
|
|
20
|
+
## What this package does
|
|
21
|
+
|
|
22
|
+
Provides the Result type implementation for handling operations that can succeed or fail.
|
|
23
|
+
The Result type represents either a success value (Ok) or an error value (Err),
|
|
24
|
+
offering a type-safe alternative to exception-based error handling.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Why it exists as a separate package
|
|
29
|
+
|
|
30
|
+
This package isolates the Result type implementation, allowing other packages
|
|
31
|
+
to depend on it without requiring the entire resultsafe runtime.
|
|
32
|
+
It is the core error handling primitive for the functional programming ecosystem.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Public API surface
|
|
37
|
+
|
|
38
|
+
[Key exported symbols — derive from `src/index.ts`]
|
|
39
|
+
|
|
40
|
+
| Symbol | Category | Description |
|
|
41
|
+
|--------|----------|-------------|
|
|
42
|
+
| `Result` | type | The Result type union |
|
|
43
|
+
| `Ok` | constructor | Constructs an Ok variant |
|
|
44
|
+
| `Err` | constructor | Constructs an Err variant |
|
|
45
|
+
| `isOk` | guard | Type guard for Ok |
|
|
46
|
+
| `isErr` | guard | Type guard for Err |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Dependencies on other resultsafe packages
|
|
51
|
+
|
|
52
|
+
| Package | Why |
|
|
53
|
+
|---------|-----|
|
|
54
|
+
| `@resultsafe/core-fp-result-shared` | Shared utilities |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Contracts implemented
|
|
59
|
+
|
|
60
|
+
| Contract | Symbol | Impl SPEC |
|
|
61
|
+
|----------|--------|-----------|
|
|
62
|
+
| [SPEC-010](../../../../docs/specs/contracts/SPEC-010-result-type-contract.md) | `Result` | [SPEC-001](specs/SPEC-001-result-implementation.md) |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Related root docs
|
|
67
|
+
|
|
68
|
+
- [Monorepo context](../../../../docs/core/CONTEXT.md)
|
|
69
|
+
- [Architecture](../../../../docs/core/ARCHITECTURE.md)
|
|
70
|
+
- [Domain glossary](../../../../docs/core/DOMAIN.md)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: MANIFEST
|
|
3
|
+
uuid: 971ffb6b-68db-4465-b286-21659fca5c17
|
|
4
|
+
title: "@resultsafe/core-fp-result — Documentation Map"
|
|
5
|
+
status: canonical
|
|
6
|
+
layer: authored
|
|
7
|
+
lang: en
|
|
8
|
+
scope: package
|
|
9
|
+
package: "@resultsafe/core-fp-result"
|
|
10
|
+
owner: Denis
|
|
11
|
+
created: 2026-03-26
|
|
12
|
+
updated: 2026-03-26
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# @resultsafe/core-fp-result — Documentation Map
|
|
16
|
+
|
|
17
|
+
> Package: `packages/core/fp/result`
|
|
18
|
+
> Monorepo map: [docs/MANIFEST.md](../../../../docs/MANIFEST.md)
|
|
19
|
+
|
|
20
|
+
## What this package does
|
|
21
|
+
|
|
22
|
+
Provides the Result type implementation for functional error handling in the resultsafe monorepo.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Agent reading chain
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Package task → this MANIFEST → CONTEXT.md → targeted files
|
|
30
|
+
For cross-cutting context → ../../../../docs/MANIFEST.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Package documents
|
|
36
|
+
|
|
37
|
+
| File | Role | Status | Updated |
|
|
38
|
+
|------|------|--------|---------|
|
|
39
|
+
| [CONTEXT.md](CONTEXT.md) | Why this package exists | canonical | 2026-03-26 |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Generated (not committed)
|
|
44
|
+
|
|
45
|
+
| Folder | What | Command |
|
|
46
|
+
|--------|------|---------|
|
|
47
|
+
| `../api/` | TypeDoc API docs | `pnpm docs:api` |
|
|
48
|
+
| `../examples/` | Example docs | `pnpm docs:examples` |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Related root docs
|
|
53
|
+
|
|
54
|
+
- [Monorepo context](../../../../docs/core/CONTEXT.md)
|
|
55
|
+
- [Architecture](../../../../docs/core/ARCHITECTURE.md)
|
|
56
|
+
- [Domain glossary](../../../../docs/core/DOMAIN.md)
|
|
57
|
+
- [This package in registry](../../../../docs/registry/PACKAGES.md)
|
|
58
|
+
- [Contracts](../../../../docs/specs/contracts/)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: COUNTERS
|
|
3
|
+
uuid: 95199988-2bae-4ad9-8040-8a1aa86b803a
|
|
4
|
+
title: "@resultsafe/core-fp-result — Local ID Counters"
|
|
5
|
+
status: canonical
|
|
6
|
+
layer: authored
|
|
7
|
+
lang: en
|
|
8
|
+
scope: package
|
|
9
|
+
package: "@resultsafe/core-fp-result"
|
|
10
|
+
owner: Denis
|
|
11
|
+
created: 2026-03-26
|
|
12
|
+
updated: 2026-03-26
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# @resultsafe/core-fp-result — Local ID Counters
|
|
16
|
+
|
|
17
|
+
> Package-local counters. Independent from root and from other packages.
|
|
18
|
+
> SPEC-001 here is a different document from SPEC-001 in another package.
|
|
19
|
+
> Update in the same commit as the new file.
|
|
20
|
+
> Next ID = value in the table. After creation — increment.
|
|
21
|
+
|
|
22
|
+
| Prefix | Next number | Last created |
|
|
23
|
+
|--------|-------------|--------------|
|
|
24
|
+
| SPEC | 001 | — |
|
|
25
|
+
| ADR | 001 | — |
|
|
26
|
+
| TASK | 001 | — |
|
|
27
|
+
| CONCEPT | 001 | — |
|
|
28
|
+
| RB | 001 | — |
|
|
29
|
+
| NOTE | 001 | — |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ENTITIES
|
|
3
|
+
uuid: a02a4468-3a62-442e-827a-c9a40fbeaaa2
|
|
4
|
+
title: "@resultsafe/core-fp-result — Package Entities"
|
|
5
|
+
status: canonical
|
|
6
|
+
layer: authored
|
|
7
|
+
lang: en
|
|
8
|
+
scope: package
|
|
9
|
+
package: "@resultsafe/core-fp-result"
|
|
10
|
+
owner: Denis
|
|
11
|
+
created: 2026-03-26
|
|
12
|
+
updated: 2026-03-26
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# @resultsafe/core-fp-result — Package Entities
|
|
16
|
+
|
|
17
|
+
> Cross-cutting entities that involve this package.
|
|
18
|
+
> Links to root `docs/registry/ENTITIES.md` for shared entities.
|
|
19
|
+
|
|
20
|
+
## Entities
|
|
21
|
+
|
|
22
|
+
| Entity | Description | Related Specs |
|
|
23
|
+
|--------|-------------|---------------|
|
|
24
|
+
| — | — | — |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Related root entities
|
|
29
|
+
|
|
30
|
+
- [Root Entities](../../../../docs/registry/ENTITIES.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Err.js","sources":["../../../src/constructors/Err.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Создает ошибочное значение `Result` из переданного payload ошибки.\n *\n * @typeParam E - Тип значения ошибки.\n * @typeParam T - The success type for the resulting `Result`.\n * @param error - Payload ошибки для обёртки.\n * @returns A `Result` with `ok: false` and the provided `error`.\n * @since 0.1.0\n * @see {@link Ok} - Creates a successful `Result`.\n * @example\n * ```ts\n * import { Err } from '@resultsafe/core-fp-result';\n *\n * const result = Err<string, number>('boom');\n * console.log(result.ok); // false\n * ```\n * @public\n */\nexport const Err = <E, T = never>(error: E): Result<T, E> =>\n ({ ok: false, error }) as const;\n
|
|
1
|
+
{"version":3,"file":"Err.js","sources":["../../../src/constructors/Err.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Создает ошибочное значение `Result` из переданного payload ошибки.\n *\n * @typeParam E - Тип значения ошибки.\n * @typeParam T - The success type for the resulting `Result`.\n * @param error - Payload ошибки для обёртки.\n * @returns A `Result` with `ok: false` and the provided `error`.\n * @since 0.1.0\n * @see {@link Ok} - Creates a successful `Result`.\n * @example\n * ```ts\n * import { Err } from '@resultsafe/core-fp-result';\n *\n * const result = Err<string, number>('boom');\n * console.log(result.ok); // false\n * ```\n * @public\n */\nexport const Err = <E, T = never>(error: E): Result<T, E> =>\n ({ ok: false, error }) as const;\n"],"names":[],"mappings":";;AAoBO,MAAM,MAAM,wBAAe,WAC/B,EAAE,IAAI,OAAO,MAAA,IADG;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ok.js","sources":["../../../src/constructors/Ok.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Создает успешное значение `Result` из переданного payload.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - The error type for the resulting `Result`.\n * @param value - Payload успеха для обёртки.\n * @returns A `Result` with `ok: true` and the provided `value`.\n * @since 0.1.0\n * @see {@link Err} - Creates an error `Result`.\n * @example\n * ```ts\n * import { Ok } from '@resultsafe/core-fp-result';\n *\n * const result = Ok<number, string>(42);\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const Ok = <T, E = never>(value: T): Result<T, E> =>\n ({ ok: true, value }) as const;\n
|
|
1
|
+
{"version":3,"file":"Ok.js","sources":["../../../src/constructors/Ok.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Создает успешное значение `Result` из переданного payload.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - The error type for the resulting `Result`.\n * @param value - Payload успеха для обёртки.\n * @returns A `Result` with `ok: true` and the provided `value`.\n * @since 0.1.0\n * @see {@link Err} - Creates an error `Result`.\n * @example\n * ```ts\n * import { Ok } from '@resultsafe/core-fp-result';\n *\n * const result = Ok<number, string>(42);\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const Ok = <T, E = never>(value: T): Result<T, E> =>\n ({ ok: true, value }) as const;\n"],"names":[],"mappings":";;AAoBO,MAAM,KAAK,wBAAe,WAC9B,EAAE,IAAI,MAAM,MAAA,IADG;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isErr.js","sources":["../../../src/guards/isErr.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Проверяет, находится ли `Result` в ветке ошибки.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @returns `true` when `result.ok` equals `false`.\n * @since 0.1.0\n * @see {@link isOk} - Checks the success branch.\n * @example\n * ```ts\n * import { Err, isErr } from '@resultsafe/core-fp-result';\n *\n * const result = Err('boom');\n * console.log(isErr(result)); // true\n * ```\n * @public\n */\nexport const isErr = <T, E>(\n result: Result<T, E>,\n): result is { ok: false; error: E } => result.ok === false;\n
|
|
1
|
+
{"version":3,"file":"isErr.js","sources":["../../../src/guards/isErr.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Проверяет, находится ли `Result` в ветке ошибки.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @returns `true` when `result.ok` equals `false`.\n * @since 0.1.0\n * @see {@link isOk} - Checks the success branch.\n * @example\n * ```ts\n * import { Err, isErr } from '@resultsafe/core-fp-result';\n *\n * const result = Err('boom');\n * console.log(isErr(result)); // true\n * ```\n * @public\n */\nexport const isErr = <T, E>(\n result: Result<T, E>,\n): result is { ok: false; error: E } => result.ok === false;\n"],"names":[],"mappings":";;AAoBO,MAAM,QAAQ,wBACnB,WACsC,OAAO,OAAO,OAFjC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrAnd.js","sources":["../../../src/guards/isErrAnd.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\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"],"names":[],"mappings":";;;AAsBO,MAAM,WAAW,wBACtB,QACA,cACY,MAAM,MAAM,KAAK,UAAU,OAAO,KAAK,GAH7B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isOk.js","sources":["../../../src/guards/isOk.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Проверяет, находится ли `Result` в ветке успеха.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @returns `true` when `result.ok` equals `true`.\n * @since 0.1.0\n * @see {@link isErr} - Checks the error branch.\n * @example\n * ```ts\n * import { Ok, isOk } from '@resultsafe/core-fp-result';\n *\n * const result = Ok(10);\n * console.log(isOk(result)); // true\n * ```\n * @public\n */\nexport const isOk = <T, E>(\n result: Result<T, E>,\n): result is { ok: true; value: T } => result.ok === true;\n
|
|
1
|
+
{"version":3,"file":"isOk.js","sources":["../../../src/guards/isOk.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Проверяет, находится ли `Result` в ветке успеха.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - `Result` для проверки.\n * @returns `true` when `result.ok` equals `true`.\n * @since 0.1.0\n * @see {@link isErr} - Checks the error branch.\n * @example\n * ```ts\n * import { Ok, isOk } from '@resultsafe/core-fp-result';\n *\n * const result = Ok(10);\n * console.log(isOk(result)); // true\n * ```\n * @public\n */\nexport const isOk = <T, E>(\n result: Result<T, E>,\n): result is { ok: true; value: T } => result.ok === true;\n"],"names":[],"mappings":";;AAoBO,MAAM,OAAO,wBAClB,WACqC,OAAO,OAAO,MAFjC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isOkAnd.js","sources":["../../../src/guards/isOkAnd.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\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"],"names":[],"mappings":";;;AAsBO,MAAM,UAAU,wBACrB,QACA,cACY,KAAK,MAAM,KAAK,UAAU,OAAO,KAAK,GAH7B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"andThen.js","sources":["../../../src/methods/andThen.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AA0BO,MAAM,UAAU,wBACrB,QACA,OACkB,KAAK,MAAM,IAAI,GAAG,OAAO,KAAK,IAAK,QAHhC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"err.js","sources":["../../../src/methods/err.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { None, Some } from '../internal/option.js';\nimport { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;;AAuBO,MAAM,MAAM,wBAAO,WACxB,MAAM,MAAM,IAAI,KAAK,OAAO,KAAK,IAAI,MADpB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expect.js","sources":["../../../src/methods/expect.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAuBO,MAAM,SAAS,wBAAO,QAAsB,QAAmB;AACpE,MAAI,KAAK,MAAM,GAAG;AAChB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,GAAG;AACrB,GALsB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectErr.js","sources":["../../../src/methods/expectErr.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAuBO,MAAM,YAAY,wBAAO,QAAsB,QAAmB;AACvE,MAAI,MAAM,MAAM,GAAG;AACjB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,GAAG;AACrB,GALyB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatten.js","sources":["../../../src/methods/flatten.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Схлопывает вложенный `Result<Result<T, E>, E>` на один уровень.\n *\n * @typeParam T - The inner success value type.\n * @typeParam E - The shared error value type.\n * @param result - Вложенный `Result` для схлопывания.\n * @returns A single-layer `Result<T, E>`.\n * @since 0.1.0\n * @see {@link andThen} - Chains computations that already return `Result`.\n * @example\n * ```ts\n * import { Ok, flatten } from '@resultsafe/core-fp-result';\n *\n * const value = flatten(Ok(Ok(3)));\n * console.log(value.ok); // true\n * ```\n * @public\n */\nexport const flatten = <T, E>(result: Result<Result<T, E>, E>): Result<T, E> =>\n result.ok ? result.value : { ok: false, error: result.error };\n
|
|
1
|
+
{"version":3,"file":"flatten.js","sources":["../../../src/methods/flatten.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Схлопывает вложенный `Result<Result<T, E>, E>` на один уровень.\n *\n * @typeParam T - The inner success value type.\n * @typeParam E - The shared error value type.\n * @param result - Вложенный `Result` для схлопывания.\n * @returns A single-layer `Result<T, E>`.\n * @since 0.1.0\n * @see {@link andThen} - Chains computations that already return `Result`.\n * @example\n * ```ts\n * import { Ok, flatten } from '@resultsafe/core-fp-result';\n *\n * const value = flatten(Ok(Ok(3)));\n * console.log(value.ok); // true\n * ```\n * @public\n */\nexport const flatten = <T, E>(result: Result<Result<T, E>, E>): Result<T, E> =>\n result.ok ? result.value : { ok: false, error: result.error };\n"],"names":[],"mappings":";;AAoBO,MAAM,UAAU,wBAAO,WAC5B,OAAO,KAAK,OAAO,QAAQ,EAAE,IAAI,OAAO,OAAO,OAAO,MAAA,GADjC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sources":["../../../src/methods/inspect.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,UAAU,wBACrB,QACA,OACiB;AACjB,MAAI,KAAK,MAAM,GAAG;AAChB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT,GARuB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectErr.js","sources":["../../../src/methods/inspectErr.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,aAAa,wBACxB,QACA,OACiB;AACjB,MAAI,MAAM,MAAM,GAAG;AACjB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT,GAR0B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sources":["../../../src/methods/map.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAuBO,MAAM,MAAM,wBACjB,QACA,OAEA,KAAK,MAAM,IACP,EAAE,IAAI,MAAM,OAAO,GAAG,OAAO,KAAK,MACjC,QANY;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapErr.js","sources":["../../../src/methods/mapErr.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAuBO,MAAM,SAAS,wBACpB,QACA,OAEA,MAAM,MAAM,IACR,EAAE,IAAI,OAAO,OAAO,GAAG,OAAO,KAAK,MAClC,QANe;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.js","sources":["../../../src/methods/match.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Выполняет сопоставление `Result` в единое выходное значение.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @typeParam U - The output type returned by both handlers.\n * @param result - Исходный `Result`.\n * @param okFn - Обработчик для ветки успеха.\n * @param errFn - Обработчик для ветки ошибки.\n * @returns Выходное значение, полученное от выбранного обработчика.\n * @since 0.1.0\n * @see {@link unwrapOrElse} - Similar shape with default fallback semantics.\n * @example\n * ```ts\n * import { Ok, match } from '@resultsafe/core-fp-result';\n *\n * const value = match(Ok(3), (x) => `ok:${x}`, (e) => `err:${e}`);\n * console.log(value); // ok:3\n * ```\n * @public\n */\nexport const match = <T, E, U>(\n result: Result<T, E>,\n okFn: (value: T) => U,\n errFn: (error: E) => U,\n): U => {\n if (result.ok) {\n return okFn(result.value);\n } else {\n const { error } = result;\n return errFn(error);\n }\n};\n
|
|
1
|
+
{"version":3,"file":"match.js","sources":["../../../src/methods/match.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Выполняет сопоставление `Result` в единое выходное значение.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @typeParam U - The output type returned by both handlers.\n * @param result - Исходный `Result`.\n * @param okFn - Обработчик для ветки успеха.\n * @param errFn - Обработчик для ветки ошибки.\n * @returns Выходное значение, полученное от выбранного обработчика.\n * @since 0.1.0\n * @see {@link unwrapOrElse} - Similar shape with default fallback semantics.\n * @example\n * ```ts\n * import { Ok, match } from '@resultsafe/core-fp-result';\n *\n * const value = match(Ok(3), (x) => `ok:${x}`, (e) => `err:${e}`);\n * console.log(value); // ok:3\n * ```\n * @public\n */\nexport const match = <T, E, U>(\n result: Result<T, E>,\n okFn: (value: T) => U,\n errFn: (error: E) => U,\n): U => {\n if (result.ok) {\n return okFn(result.value);\n } else {\n const { error } = result;\n return errFn(error);\n }\n};\n"],"names":[],"mappings":";;AAuBO,MAAM,QAAQ,wBACnB,QACA,MACA,UACM;AACN,MAAI,OAAO,IAAI;AACb,WAAO,KAAK,OAAO,KAAK;AAAA,EAC1B,OAAO;AACL,UAAM,EAAE,UAAU;AAClB,WAAO,MAAM,KAAK;AAAA,EACpB;AACF,GAXqB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ok.js","sources":["../../../src/methods/ok.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { None, Some } from '../internal/option.js';\nimport { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;;AAuBO,MAAM,KAAK,wBAAO,WACvB,KAAK,MAAM,IAAI,KAAK,OAAO,KAAK,IAAI,MADpB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orElse.js","sources":["../../../src/methods/orElse.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAuBO,MAAM,SAAS,wBACpB,QACA,OAEA,MAAM,MAAM,IAAI,GAAG,OAAO,KAAK,IAAK,QAJhB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.js","sources":["../../../src/methods/tap.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Выполняет побочный эффект для значения `Ok` и возвращает входной `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} - Executes a side effect for the error branch.\n * @example\n * ```ts\n * import { Ok, tap } from '@resultsafe/core-fp-result';\n *\n * const result = tap(Ok(1), (value) => console.log(value)); // 1\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const tap = <T, E>(\n result: Result<T, E>,\n fn: (value: T) => void,\n): Result<T, E> => {\n if (result.ok) {\n fn(result.value);\n }\n return result;\n};\n
|
|
1
|
+
{"version":3,"file":"tap.js","sources":["../../../src/methods/tap.ts"],"sourcesContent":["import type { Result } from '../shared-types.js';\n\n/**\n * Выполняет побочный эффект для значения `Ok` и возвращает входной `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} - Executes a side effect for the error branch.\n * @example\n * ```ts\n * import { Ok, tap } from '@resultsafe/core-fp-result';\n *\n * const result = tap(Ok(1), (value) => console.log(value)); // 1\n * console.log(result.ok); // true\n * ```\n * @public\n */\nexport const tap = <T, E>(\n result: Result<T, E>,\n fn: (value: T) => void,\n): Result<T, E> => {\n if (result.ok) {\n fn(result.value);\n }\n return result;\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,MAAM,wBACjB,QACA,OACiB;AACjB,MAAI,OAAO,IAAI;AACb,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT,GARmB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tapErr.js","sources":["../../../src/methods/tapErr.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,SAAS,wBACpB,QACA,OACiB;AACjB,MAAI,MAAM,MAAM,GAAG;AACjB,OAAG,OAAO,KAAK;AAAA,EACjB;AACA,SAAO;AACT,GARsB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpose.js","sources":["../../../src/methods/transpose.ts"],"sourcesContent":["import { None, Some } from '../internal/option.js';\nimport { type Option } from '../shared-types.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,YAAY,wBACvB,WACyB;AACzB,MAAI,OAAO,IAAI;AACb,WAAO,OAAO,MAAM,SAAS,OACzB,KAAK,EAAE,IAAI,MAAM,OAAO,OAAO,MAAM,MAAA,CAAO,IAC5C;AAAA,EACN;AACA,SAAO,KAAK,EAAE,IAAI,OAAO,OAAO,OAAO,OAAO;AAChD,GATyB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwrap.js","sources":["../../../src/methods/unwrap.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,SAAS,wBAAO,WAA4B;AACvD,MAAI,KAAK,MAAM,GAAG;AAChB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,+BAA+B;AACjD,GALsB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwrapErr.js","sources":["../../../src/methods/unwrapErr.ts"],"sourcesContent":["import { isErr } from '../guards/isErr.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,YAAY,wBAAO,WAA4B;AAC1D,MAAI,MAAM,MAAM,GAAG;AACjB,WAAO,OAAO;AAAA,EAChB;AACA,QAAM,IAAI,MAAM,iCAAiC;AACnD,GALyB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwrapOr.js","sources":["../../../src/methods/unwrapOr.ts"],"sourcesContent":["import { isOk } from '../guards/isOk.js';\nimport { type Result } from '../shared-types.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"],"names":[],"mappings":";;;AAsBO,MAAM,WAAW,wBAAO,QAAsB,iBACnD,KAAK,MAAM,IAAI,OAAO,QAAQ,cADR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapOrElse.js","sources":["../../../src/methods/unwrapOrElse.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Возвращает успешное значение или вычисляет fallback из ошибки.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция-поставщик fallback для `Err`.\n * @returns Payload успеха или вычисленный fallback.\n * @since 0.1.0\n * @see {@link unwrapOr} - Использует eager fallback-значение.\n * @example\n * ```ts\n * import { Err, unwrapOrElse } from '@resultsafe/core-fp-result';\n *\n * const value = unwrapOrElse(Err('fatal'), (error) => error.length);\n * console.log(value); // 5\n * ```\n * @public\n */\nexport const unwrapOrElse = <T, E>(\n result: Result<T, E>,\n fn: (error: E) => T,\n): T => {\n if (result.ok) {\n return result.value;\n } else {\n return fn(result.error);\n }\n};\n
|
|
1
|
+
{"version":3,"file":"unwrapOrElse.js","sources":["../../../src/methods/unwrapOrElse.ts"],"sourcesContent":["import { type Result } from '../shared-types.js';\n\n/**\n * Возвращает успешное значение или вычисляет fallback из ошибки.\n *\n * @typeParam T - Тип успешного значения.\n * @typeParam E - Тип значения ошибки.\n * @param result - Исходный `Result`.\n * @param fn - Функция-поставщик fallback для `Err`.\n * @returns Payload успеха или вычисленный fallback.\n * @since 0.1.0\n * @see {@link unwrapOr} - Использует eager fallback-значение.\n * @example\n * ```ts\n * import { Err, unwrapOrElse } from '@resultsafe/core-fp-result';\n *\n * const value = unwrapOrElse(Err('fatal'), (error) => error.length);\n * console.log(value); // 5\n * ```\n * @public\n */\nexport const unwrapOrElse = <T, E>(\n result: Result<T, E>,\n fn: (error: E) => T,\n): T => {\n if (result.ok) {\n return result.value;\n } else {\n return fn(result.error);\n }\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,eAAe,wBAC1B,QACA,OACM;AACN,MAAI,OAAO,IAAI;AACb,WAAO,OAAO;AAAA,EAChB,OAAO;AACL,WAAO,GAAG,OAAO,KAAK;AAAA,EACxB;AACF,GAT4B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refineAsyncResult.js","sources":["../../../src/refiners/refineAsyncResult.ts"],"sourcesContent":["import { hasOwn, isObject } from '../internal/object.js';\nimport type {\n AsyncValidatorFn,\n PayloadKeys,\n VariantConfig,\n} from '../shared-types.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"],"names":[],"mappings":";;;AASA,MAAM,iBAAiB,wBACrB,WAC8B;AAC9B,QAAM,IAAI,OAAO;AACjB,MAAI,MAAM,QAAS,QAAO,CAAA;AAC1B,SAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACnC,GANuB;AA6BhB,MAAM,oBACX,wBAA6C,eAC7C,CAAgC,YAChC,CACE,eAEF,OACE,UACsE;AACtE,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,MAAI,CAAC,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,GA5BA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refineAsyncResultU.js","sources":["../../../src/refiners/refineAsyncResultU.ts"],"sourcesContent":["import { hasOwn, isObject } from '../internal/object.js';\nimport type {\n AsyncValidatorFn,\n PayloadKeys,\n VariantConfig,\n} from '../shared-types.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 * Уточняет значение асинхронно в не-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 * @since 0.1.0\n * @see {@link refineAsyncResult} - Curry-конструктор асинхронного refiner.\n * @example\n * ```ts\n * import { refineAsyncResultU } from '@resultsafe/core-fp-result';\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 * @public\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 // Императивный стиль с early returns (как в Rust)\n return (async () => {\n // Rust-style early returns с Option-like поведением\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 // Payload validation с асинхронными валидаторами\n const keys = getPayloadKeys(config);\n for (const key of keys) {\n const check = validators[key as keyof TValidators];\n if (!check) continue;\n\n const field = value[key as string];\n // Type-safe async validation\n const isValid = await (check as AsyncValidatorFn)(field);\n if (!isValid) return null;\n }\n\n // Safe cast после всех проверок\n return value as UniversalAsyncRefinedResult<K, TMap, TValidators>;\n })();\n};\n"],"names":[],"mappings":";;;AASA,MAAM,iBAAiB,wBACrB,WAC8B;AAC9B,QAAM,IAAI,OAAO;AACjB,MAAI,MAAM,QAAS,QAAO,CAAA;AAC1B,SAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACnC,GANuB;AAkChB,MAAM,qBAAqB,wBAKhC,OACA,SACA,YACA,eACsE;AAEtE,UAAQ,YAAY;AAElB,QAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,QAAI,CAAC,OAAO,OAAO,MAAM,EAAG,QAAO;AAEnC,UAAM,IAAI,MAAM,MAAM;AACtB,QAAI,MAAM,QAAS,QAAO;AAE1B,UAAM,SAAS,WAAW,OAAO;AACjC,QAAI,CAAC,OAAQ,QAAO;AAGpB,UAAM,OAAO,eAAe,MAAM;AAClC,eAAW,OAAO,MAAM;AACtB,YAAM,QAAQ,WAAW,GAAwB;AACjD,UAAI,CAAC,MAAO;AAEZ,YAAM,QAAQ,MAAM,GAAa;AAEjC,YAAM,UAAU,MAAO,MAA2B,KAAK;AACvD,UAAI,CAAC,QAAS,QAAO;AAAA,IACvB;AAGA,WAAO;AAAA,EACT,GAAA;AACF,GArCkC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refineResult.js","sources":["../../../src/refiners/refineResult.ts"],"sourcesContent":["import { hasOwn, isObject } from '../internal/object.js';\nimport type {\n PayloadKeys,\n ValidatorFn,\n VariantConfig,\n} from '../shared-types.js';\nimport type { UniversalRefinedResult } from './types/index.js';\nimport { getPayloadKeys } from './utils/index.js';\n\n/**\n * Создает синхронный refiner варианта с валидаторами payload.\n *\n * @typeParam TMap - Тип карты конфигурации вариантов.\n * @param variantMap - Карта, описывающая допустимые варианты и поля payload.\n * @returns A curried refiner factory bound to `variantMap`.\n * @since 0.1.0\n * @see {@link refineResultU} - Непосредственный (не-curry) вариант helper.\n * @example\n * ```ts\n * import { refineResult } from '@resultsafe/core-fp-result';\n *\n * const map = { ok: { payload: 'value' } } as const;\n * const refineOk = refineResult(map)('ok')({\n * value: (x: unknown): x is number => typeof x === 'number',\n * });\n *\n * console.log(refineOk({ type: 'ok', value: 1 })); // { type: 'ok', value: 1 }\n * ```\n * @public\n */\nexport const refineResult =\n <TMap extends Record<string, VariantConfig>>(variantMap: TMap) =>\n <K extends keyof TMap & string>(variant: K) =>\n <TValidators extends Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>>(\n validators: TValidators,\n ) =>\n (value: unknown): UniversalRefinedResult<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 if (!check(field)) return null;\n }\n\n return value as UniversalRefinedResult<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 * Этот экспорт сохранен для совместимости. Предпочитайте {@link refineResultU} из\n * `refineResultU.ts` как каноническую точку входа без curry.\n * @since 0.1.0\n * @example\n * ```ts\n * import { refineResultU } from '@resultsafe/core-fp-result/src/refiners/refineResult.js';\n *\n * const map = { ok: { payload: 'value' } } as const;\n * const out = refineResultU({ type: 'ok', value: 1 }, 'ok', map, {\n * value: (x: unknown): x is number => typeof x === 'number',\n * });\n *\n * console.log(out?.type); // ok\n * ```\n * @internal\n */\nexport const refineResultU = <\n TMap extends Record<string, VariantConfig>,\n K extends keyof TMap & string,\n TValidators extends Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>,\n>(\n value: unknown,\n variant: K,\n variantMap: TMap,\n validators: TValidators,\n): UniversalRefinedResult<K, TMap, TValidators> | null =>\n refineResult(variantMap)(variant)(validators)(value);\n"],"names":[],"mappings":";;;;AA8BO,MAAM,eACX,wBAA6C,eAC7C,CAAgC,YAChC,CACE,eAEF,CAAC,UAAwE;AACvE,MAAI,CAAC,SAAS,KAAK,EAAG,QAAO;AAC7B,MAAI,CAAC,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,QAAI,CAAC,MAAM,KAAK,EAAG,QAAO;AAAA,EAC5B;AAEA,SAAO;AACT,GAzBA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refineResultU.js","sources":["../../../src/refiners/refineResultU.ts"],"sourcesContent":["import type {\n PayloadKeys,\n ValidatorFn,\n VariantConfig,\n} from '../shared-types.js';\nimport { refineResult } from './refineResult.js';\nimport type { SyncRefinedResult } from './types/index.js';\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 * @since 0.1.0\n * @see {@link refineResult} - Curry-конструктор refiner.\n * @example\n * ```ts\n * import { refineResultU } from '@resultsafe/core-fp-result';\n *\n * const map = { ok: { payload: 'value' } } as const;\n * const out = refineResultU({ type: 'ok', value: 1 }, 'ok', map, {\n * value: (x: unknown): x is number => typeof x === 'number',\n * });\n *\n * console.log(out?.type); // ok\n * ```\n * @public\n */\nexport const refineResultU = <\n TMap extends Record<string, VariantConfig>,\n K extends keyof TMap & string,\n TValidators extends Partial<Record<PayloadKeys<TMap[K]>, ValidatorFn>>,\n>(\n value: unknown,\n variant: K,\n variantMap: TMap,\n validators: TValidators,\n): SyncRefinedResult<K, TMap, TValidators> | null =>\n refineResult(variantMap)(variant)(validators)(value);\n"],"names":[],"mappings":";;;AAkCO,MAAM,gBAAgB,wBAK3B,OACA,SACA,YACA,eAEA,aAAa,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,GAVxB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refineVariantMap.js","sources":["../../../src/refiners/refineVariantMap.ts"],"sourcesContent":["import type {\n PayloadKeys,\n ValidatorFn,\n VariantConfig,\n} from '../shared-types.js';\nimport type { SyncRefinedResultUnion } from './types/SyncRefinedResultUnion.js';\nimport type { SyncValidatorMap } from './types/SyncValidatorMap.js';\n\n/**\n * Уточняет значение дискриминированного объединения по полной карте вариантов.\n *\n * @typeParam TMap - Тип карты конфигурации вариантов.\n * @typeParam TValidators - Тип карты валидаторов по вариантам.\n * @param value - Значение для валидации и уточнения.\n * @param variantMap - Полная карта конфигурации вариантов.\n * @param validators - Валидаторы, сгруппированные по ключу варианта.\n * @returns Уточненный элемент объединения или `null`.\n * @since 0.1.0\n * @see {@link refineResult} - Refines one concrete variant key.\n * @example\n * ```ts\n * import { refineVariantMap } from '@resultsafe/core-fp-result';\n *\n * const map = {\n * created: { payload: 'id' },\n * failed: { payload: 'reason' },\n * } as const;\n *\n * const out = refineVariantMap({ type: 'created', id: '1' }, map, {\n * created: { id: (x: unknown): x is string => typeof x === 'string' },\n * failed: { reason: (x: unknown): x is string => typeof x === 'string' },\n * });\n *\n * console.log(out?.type); // created\n * ```\n * @public\n */\nexport function refineVariantMap<\n TMap extends Record<string, VariantConfig>,\n TValidators extends SyncValidatorMap<TMap>,\n>(\n value: unknown,\n variantMap: TMap,\n validators: TValidators,\n): SyncRefinedResultUnion<TMap, TValidators> | null {\n if (typeof value !== 'object' || value === null || !('type' in value)) {\n return null;\n }\n\n const rawType = (value as { type?: unknown }).type;\n if (typeof rawType !== 'string' || !(rawType in variantMap)) return null;\n\n // фиксируем конкретный ключ варианта\n type K = Extract<keyof TMap, string>;\n const k = rawType as K;\n\n const config = variantMap[k];\n if (!config) return null;\n\n // ключи payload для конкретного K\n const payload = config.payload;\n const keys = (\n payload === 'never' ? [] : Array.isArray(payload) ? payload : [payload]\n ) as readonly PayloadKeys<TMap[typeof k]>[];\n\n // валидаторы, согласованные с конкретным K\n const vvs = validators[k] as\n | Partial<Record<PayloadKeys<TMap[typeof k]>, ValidatorFn>>\n | undefined;\n\n if (vvs) {\n const obj = value as Record<string, unknown>;\n for (const key of keys) {\n const check = vvs[key];\n if (!check) continue;\n if (!check(obj[key as string])) return null;\n }\n }\n\n return value as SyncRefinedResultUnion<TMap, TValidators>;\n}\n"],"names":[],"mappings":";;AAqCO,SAAS,iBAId,OACA,YACA,YACkD;AAClD,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,UAAU,QAAQ;AACrE,WAAO;AAAA,EACT;AAEA,QAAM,UAAW,MAA6B;AAC9C,MAAI,OAAO,YAAY,YAAY,EAAE,WAAW,YAAa,QAAO;AAIpE,QAAM,IAAI;AAEV,QAAM,SAAS,WAAW,CAAC;AAC3B,MAAI,CAAC,OAAQ,QAAO;AAGpB,QAAM,UAAU,OAAO;AACvB,QAAM,OACJ,YAAY,UAAU,KAAK,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAIxE,QAAM,MAAM,WAAW,CAAC;AAIxB,MAAI,KAAK;AACP,UAAM,MAAM;AACZ,eAAW,OAAO,MAAM;AACtB,YAAM,QAAQ,IAAI,GAAG;AACrB,UAAI,CAAC,MAAO;AACZ,UAAI,CAAC,MAAM,IAAI,GAAa,CAAC,EAAG,QAAO;AAAA,IACzC;AAAA,EACF;AAEA,SAAO;AACT;AA3CgB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPayloadKeys.js","sources":["../../../../src/refiners/utils/getPayloadKeys.ts"],"sourcesContent":["import type { PayloadKeys, VariantConfig } from '../../shared-types.js';\n\n/**\n * Нормализует конфигурацию payload варианта в список ключей.\n *\n * @typeParam C - Тип конфигурации варианта.\n * @param config - Конфигурация варианта с определением payload.\n * @returns Ключи payload как readonly-массив.\n * @since 0.1.0\n * @example\n * ```ts\n * import { getPayloadKeys } from '@resultsafe/core-fp-result/src/refiners/utils/getPayloadKeys.js';\n *\n * const keys = getPayloadKeys({ payload: ['id', 'meta'] } as const);\n * console.log(keys.length); // 2\n * ```\n * @internal\n */\nexport const 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"],"names":[],"mappings":";;AAkBO,MAAM,iBAAiB,wBAC5B,WAC8B;AAC9B,QAAM,IAAI,OAAO;AACjB,MAAI,MAAM,QAAS,QAAO,CAAA;AAC1B,SAAQ,MAAM,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;AACnC,GAN8B;"}
|
package/package.json
CHANGED
|
@@ -1,68 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resultsafe/core-fp-result",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"author": "Denis Savasteev",
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "0.1.8",
|
|
6
4
|
"type": "module",
|
|
7
5
|
"sideEffects": false,
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=20.10.0",
|
|
15
|
-
"pnpm": ">=10.0.0"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"clean:dist": "rimraf dist .tsbuildinfo",
|
|
19
|
-
"build:types": "tsc -b ./config/tsconfig.build.types.json --force",
|
|
20
|
-
"build:esm": "vite build --config ./config/vite.config.build.esm.ts",
|
|
21
|
-
"build:cjs": "vite build --config ./config/vite.config.build.cjs.ts && node ./__scripts__/build/write-cjs-package-json.mjs",
|
|
22
|
-
"build:umd": "vite build --config ./config/vite.config.build.umd.ts",
|
|
23
|
-
"prepare:dist:publish": "node ./__scripts__/build/prepare-dist-publish.mjs",
|
|
24
|
-
"check:release:artifacts": "node ./__scripts__/build/validate-release-artifacts.mjs",
|
|
25
|
-
"check:release:pack": "npm pack --dry-run ./dist",
|
|
26
|
-
"build:all": "pnpm run clean:dist && pnpm run build:esm && pnpm run build:cjs && pnpm run build:umd && pnpm run build:types",
|
|
27
|
-
"build:release": "pnpm run build:all && pnpm run prepare:dist:publish",
|
|
28
|
-
"verify:release": "pnpm run build:release && pnpm run check:release:artifacts && pnpm run test && pnpm run check:release:pack",
|
|
29
|
-
"docs:api:clean": "rimraf docs/api",
|
|
30
|
-
"docs:api:generate": "typedoc --options typedoc.json --out docs/api",
|
|
31
|
-
"docs:api:mirror": "node ./__scripts__/docs/mirror-typedoc-api.mjs",
|
|
32
|
-
"docs:api": "pnpm run docs:api:generate && pnpm run docs:api:mirror",
|
|
33
|
-
"docs:api:check": "typedoc --options typedoc.json --emit none",
|
|
34
|
-
"docs:api:all": "pnpm run docs:api:clean && pnpm run docs:api && pnpm run docs:api:check && pnpm run test",
|
|
35
|
-
"test": "vitest run --config ./config/vitest.config.ts",
|
|
36
|
-
"test:coverage": "vitest run --config ./config/vitest.config.ts --coverage",
|
|
37
|
-
"lint": "eslint . --ext .ts,.tsx --config config/eslint.config.mjs",
|
|
38
|
-
"lint:fix": "eslint . --ext .ts,.tsx --config config/eslint.config.mjs --fix",
|
|
39
|
-
"prepublishOnly": "pnpm run verify:release",
|
|
40
|
-
"npm:publish:dry": "pnpm run verify:release && npm publish ./dist --dry-run --access public",
|
|
41
|
-
"npm:publish:public": "npm publish ./dist --access public --provenance"
|
|
42
|
-
},
|
|
43
|
-
"main": "dist/cjs/index.js",
|
|
44
|
-
"module": "dist/esm/index.js",
|
|
45
|
-
"browser": "dist/umd/resultsafe-monorepo-core-fp-result.umd.js",
|
|
46
|
-
"types": "dist/types/index.d.ts",
|
|
6
|
+
"main": "./cjs/index.js",
|
|
7
|
+
"module": "./esm/index.js",
|
|
8
|
+
"browser": "./umd/resultsafe-monorepo-core-fp-result.umd.js",
|
|
9
|
+
"types": "./types/index.d.ts",
|
|
47
10
|
"exports": {
|
|
48
11
|
".": {
|
|
49
|
-
"types": "./
|
|
50
|
-
"import": "./
|
|
51
|
-
"require": "./
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
13
|
+
"import": "./esm/index.js",
|
|
14
|
+
"require": "./cjs/index.js"
|
|
52
15
|
},
|
|
53
16
|
"./Ok": {
|
|
54
|
-
"types": "./
|
|
55
|
-
"import": "./
|
|
56
|
-
"require": "./
|
|
17
|
+
"types": "./types/constructors/Ok.d.ts",
|
|
18
|
+
"import": "./esm/constructors/Ok.js",
|
|
19
|
+
"require": "./cjs/constructors/Ok.js"
|
|
57
20
|
},
|
|
58
21
|
"./Err": {
|
|
59
|
-
"types": "./
|
|
60
|
-
"import": "./
|
|
61
|
-
"require": "./
|
|
22
|
+
"types": "./types/constructors/Err.d.ts",
|
|
23
|
+
"import": "./esm/constructors/Err.js",
|
|
24
|
+
"require": "./cjs/constructors/Err.js"
|
|
62
25
|
}
|
|
63
26
|
},
|
|
64
27
|
"files": [
|
|
65
|
-
"
|
|
28
|
+
"cjs",
|
|
29
|
+
"esm",
|
|
30
|
+
"types",
|
|
31
|
+
"umd",
|
|
66
32
|
"docs",
|
|
67
33
|
"README.md",
|
|
68
34
|
"README.ru.md",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isErrAnd.d.ts","sourceRoot":"","sources":["../../../src/guards/isErrAnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"isErrAnd.d.ts","sourceRoot":"","sources":["../../../src/guards/isErrAnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,CAAC,EAC3B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,KAC/B,OAAmD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isOkAnd.d.ts","sourceRoot":"","sources":["../../../src/guards/isOkAnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"isOkAnd.d.ts","sourceRoot":"","sources":["../../../src/guards/isOkAnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAC1B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,WAAW,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,KAC/B,OAAkD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"andThen.d.ts","sourceRoot":"","sources":["../../../src/methods/andThen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"andThen.d.ts","sourceRoot":"","sources":["../../../src/methods/andThen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC7B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAiE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"err.d.ts","sourceRoot":"","sources":["../../../src/methods/err.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"err.d.ts","sourceRoot":"","sources":["../../../src/methods/err.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../src/methods/expect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,MAAM,KAAG,CAKhE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectErr.d.ts","sourceRoot":"","sources":["../../../src/methods/expectErr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,MAAM,KAAG,CAKnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../src/methods/inspect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../../src/methods/inspect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,CAAC,EAC1B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACrB,MAAM,CAAC,CAAC,EAAE,CAAC,CAKb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspectErr.d.ts","sourceRoot":"","sources":["../../../src/methods/inspectErr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inspectErr.d.ts","sourceRoot":"","sources":["../../../src/methods/inspectErr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAC7B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACrB,MAAM,CAAC,CAAC,EAAE,CAAC,CAKb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/methods/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/methods/map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAClB,MAAM,CAAC,CAAC,EAAE,CAAC,CAGgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapErr.d.ts","sourceRoot":"","sources":["../../../src/methods/mapErr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapErr.d.ts","sourceRoot":"","sources":["../../../src/methods/mapErr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC5B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAClB,MAAM,CAAC,CAAC,EAAE,CAAC,CAGgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ok.d.ts","sourceRoot":"","sources":["../../../src/methods/ok.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ok.d.ts","sourceRoot":"","sources":["../../../src/methods/ok.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,CACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orElse.d.ts","sourceRoot":"","sources":["../../../src/methods/orElse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orElse.d.ts","sourceRoot":"","sources":["../../../src/methods/orElse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC5B,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,CAAC,EAAE,CAAC,CAC+C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tapErr.d.ts","sourceRoot":"","sources":["../../../src/methods/tapErr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tapErr.d.ts","sourceRoot":"","sources":["../../../src/methods/tapErr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EACzB,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACrB,MAAM,CAAC,CAAC,EAAE,CAAC,CAKb,CAAC"}
|