Skip to content

eguneys/bdu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Utility functions for constructing and keeping references of objects. Useful for Ease of comparison with reference equality ===.

Usage

Let's say you have these types:

type Color = 'w' | 'b';
type Role = 'b' | 'n' | 'k' | 'q';

type Piece = {
  color: Color,
  role: Role
}

let colors = ['w', 'b'];
let roles = ['b', 'n', 'k', 'q'];

You have a constructor function

const piece = (color: Color, role: Role): Piece => ({
  color,
  role
});

You want to construct and reference any possible piece like this:

let pieces = bd.DB2<Color, Role, Piece>(piece, colors, roles);

pieces.get('w', 'n') === pieces.get('w', 'n'); // true

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published