@strong-roots-capital/parse-int-base-ten
v3.0.0
Published
Use the Maybe monady to parse a base-10 integer
Downloads
8
Readme
parse-int-base-ten
Use the Maybe monady to parse a base-10 integer
Install
npm install @strong-roots-capital/parse-int-base-ten
Use
import { parseIntBase10 } from '@strong-roots-capital/parse-int-base-ten'
import { Maybe } from 'purify-ts/Maybe'
const answer = Maybe.fromNullable(process.env['WHAT_IS_THE_NUMERIC_ANSWER'])
.chain(parseIntBase10)
.orDefault(42)
console.log(answer)
//=>42
Related
Index
Functions
Functions
parseIntBase10
▸ parseIntBase10(value: string
): Maybe
<number
>
Defined in parse-int-base-ten.ts:18
Parse base-ten integer out of value
if possible.
Parameters:
| Name | Type | Description |
| ------ | ------ | ------ |
| value | string
| String representation of a number |
Returns: Maybe
<number
>
Number represented by value