Num.Odd
Num / Odd
Import
typescript
import { Num } from '@wollybeard/kit'
// Access via namespace
Num.Odd.someFunction()
typescript
import * as Num from '@wollybeard/kit/num'
// Access via namespace
Num.Odd.someFunction()
Functions
[F]
is
typescript
(value: unknown): boolean
Type predicate to check if value is odd. Returns Odd & Int when the value is an odd integer.
[F]
from
typescript
(value: number): number & { [OddBrand]: true; } & { [IntBrand]: true; }
Construct an Odd integer. Throws if the value is not an odd integer.
[F]
tryFrom
typescript
(value: number): (number & { [OddBrand]: true; } & { [IntBrand]: true; }) | null
Try to construct an Odd integer. Returns null if the value is not an odd integer.
[F]
next
typescript
(value: number): number & { [OddBrand]: true; } & { [IntBrand]: true; }
Get the next odd number (rounds up if even).
[F]
prev
typescript
(value: number): number & { [OddBrand]: true; } & { [IntBrand]: true; }
Get the previous odd number (rounds down if even).
Types
[∩]
Odd
typescript
type Odd = number & { [OddBrand]: true }
Odd integer. Note: This stacks with Int brand to allow Int & Odd.