| 5916 | * @since 3.10.0 |
| 5917 | */ |
| 5918 | export class DurationFromNanos extends transformOrFail( |
| 5919 | NonNegativeBigIntFromSelf.annotations({ description: "a bigint to be decoded into a Duration" }), |
| 5920 | DurationFromSelf.pipe(filter((duration) => duration_.isFinite(duration), { description: "a finite duration" })), |
| 5921 | { |
| 5922 | strict: true, |
| 5923 | decode: (i) => ParseResult.succeed(duration_.nanos(i)), |
| 5924 | encode: (a, _, ast) => |
| 5925 | option_.match(duration_.toNanos(a), { |
| 5926 | onNone: () => ParseResult.fail(new ParseResult.Type(ast, a, `Unable to encode ${a} into a bigint`)), |
| 5927 | onSome: (nanos) => ParseResult.succeed(nanos) |
| 5928 | }) |
| 5929 | } |
| 5930 | ).annotations({ identifier: "DurationFromNanos" }) {} |
| 5931 | |
| 5932 | /** |
| 5933 | * A non-negative integer. +Infinity is excluded. |
nothing calls this directly
no test coverage detected