@caldwell619/durable-parse-float
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

GitHub Slugger

Fork of durable-parse-float written in TS

NPM NPM

Getting Started

yarn add @caldwell619/durable-parse-float

Quick Example

import { durableParseFloat, parseFloatStrict } from '@caldwell619/durable-parse-float'

durableParseFloat('1.34') // 1.34
durableParseFloat('#REF!') // null
parseFloatStrict('1') // 1
parseFloatStrict('1.34') // 1.34
parseFloatStrict('') // error thrown
parseFloatStrict(undefined) // error thrown

Differences

durableParseFloat is a flexible function that will return null or a number or float.

parseFloatStrict is a light wrapper around durableParseFloat that will throw if the input is invalid.

There are 2 separate functions, mainly to ensure that data stays consistent. If you cannot have a number be null, whether that's from TypeScript types, or some schema, etc, you have a way to ensure that your input will be a number, or die trying.

Readme

Keywords

none

Package Sidebar

Install

npm i @caldwell619/durable-parse-float

Weekly Downloads

17

Version

0.0.1

License

MIT

Unpacked Size

9.24 kB

Total Files

13

Last publish

Collaborators

  • caldwell619