@strong-roots-capital/parse-int-base-ten
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

parse-int-base-ten Build status npm version codecov

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


Package Sidebar

Install

npm i @strong-roots-capital/parse-int-base-ten

Weekly Downloads

1

Version

3.0.0

License

ISC

Unpacked Size

7 kB

Total Files

6

Last publish

Collaborators

  • amchelle
  • hamroctopus