Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

winoteam-archives/rescript-big

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

89 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

rescript-big

Actions Status

Zero-cost bindings to Big.js library.

In this version only these methods are supported: toFixed, plus, minus, div, times, valueOf, round, eq, gt, gte, lt and lte

It also have some converters and shortcuts for converting an existing value or making a Big value, such as: fromFloator toFloat.

It's accompanied with an Operators module which override some operators like +., *., /. and -.

๐Ÿ“ฆ Installation

Run the following command:

$ yarn add rescript-big

Then add rescript-big to your bsconfig.json's dependencies:

 {
   "bs-dependencies": [
+    "rescript-big"
   ]
 }

๐Ÿ’ป Usage

open! Big.Operators

let a = 201.57512->Big.fromFloat
Js.log(a->Big.toFixed(2)) // 201.58

// Compiler error: 1. is a float, wanted Big.t
let c = a *. 1.

// OK
let b = 1.->Big.fromFloat
let c = a *. b
Js.log(Big.valueOf(c)) // 201.57512

๐Ÿ•บ Contribute

๐Ÿš€ Want to hack on rescript-big? Follow the next instructions

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Install dependencies using Yarn: yarn
  3. Ensure that the tests are passing using yarn test
  4. Send a pull request ๐Ÿ™Œ

Remember to add tests for your change if possible.

๐Ÿ‘‹ Questions

If you have any questions, feel free to open an issue. Please check the Big.js docs before submitting an issue.