Pairing
Number pairing functions with support for BigInt numbers.
Features
- Simple API;
- Works with plain numbers or BigInt;
- Extensive tests;
- Typescript support.
Installation
npm install pairing
Requirements
Quick start
import { elegant } from 'pairing';
const z = elegant.encode(3037000499n, 2891526307n);
const [x, y] = elegant.decode(9223372036854775807n);
Supported pairing functions
Motivation
Pairing functions are magic. They encode two natural numbers into a derivative natural. This can be useful in various use-cases, such as optimizing compound numeric indices.
At the time of writing, none of the existing libraries in npm supported BigInt calculations. Types were also missing.
We are hiring
Causaly is building the world's largest biomedical knowledge platform, using technologies such as TypeScript, React and Node.js. Find out more about our openings at https://apply.workable.com/causaly/.
License
MIT