pairing
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Pairing

Number pairing functions with support for BigInt numbers.

Build Status npm version

Features

  • Simple API;
  • Works with plain numbers or BigInt;
  • Extensive tests;
  • Typescript support.

Installation

npm install pairing

Requirements

  • Node.js v.14+

Quick start

import { elegant } from 'pairing';

// encode bigint numbers
const z = elegant.encode(3037000499n, 2891526307n); // returns 9223372036854775807n

// decode bigint number
const [x, y] = elegant.decode(9223372036854775807n); // returns [3037000499n, 2891526307n]

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

Package Sidebar

Install

npm i pairing

Weekly Downloads

143

Version

0.1.1

License

MIT

Unpacked Size

16.3 kB

Total Files

12

Last publish

Collaborators

  • jmike
  • nikoskalogridis
  • dnlytras