1.0.4 • Published 9 years ago

joldem v1.0.4

Weekly downloads
-
License
BSD-2-Clause
Repository
-
Last release
9 years ago

Joldem: Holdem range parser and tokenizer in Javascript


Joldem parses and tokenizes ranges in the commonly known formats as you would see in forums or twoplustwo.

Parsing

joldem.parse("22") === ["2h2s", "2h2c", "2h2d", "2s2c", "2s2d", "2c2d"]
joldem.parse("a2s") === ["ah2h", "as2s", "ac2c", "ad2d"]

joldem.parse("aq+") === [
  "ahqh", "asqs", "acqc", "adqd", "ahqs", "ahqc", "ahqd", "asqh", "asqc", "asqd", "acqh", 
  "acqs", "acqd", "adqh", "adqs", "adqc", "ahkh", "asks", "ackc", "adkd", "ahks", "ahkc", 
  "ahkd", "askh", "askc", "askd", "ackh", "acks", "ackd", "adkh", "adks", "adkc"]

By default parse will decompose a range into it's lowest parts. But sometimes we may want to keep a range in a higher form.

Ranges are represented by 3 levels of accuracy:

  • Level 1: The exact holecards in the form AcKc or 9s9h
  • Level 2: Combos in the form AKs, AKo, AK or 99
  • Level 3: Ranges of combos in the form AQo+ or 22-77

When parsing level 1 is the default. But we can override this to keep the range in a higher form.

joldem.parse("aq+", 2) === ["aqs", "aqo", "aks", "ako"]
joldem.parse("aq+", 3) === ["aq", "ak"]

Tokenizing

If we want to bring holecards back to a range we tokenize.

  joldem.tokenize(["aq", "ak"]) === "AQ+"
  joldem.tokenize(["ajs", "aq", "ak"]) === "AQ+ AJs"

Similarly as with parsing the 3 ranges come into effect. The default is to parse into the highest possible form or level 3. But we can override this

  joldem.tokenize(["ajs", "aq", "ak"], 2) === "AJs AQ AK"

Installing, Using the library.

NPM

npm install joldem
var joldem = require("joldem");

Webpage

download https://raw.githubusercontent.com/npiv/joldem/master/joldem.min.js

<script src="joldem.min.js"></script>

joldem will then register itself as joldem and can be used in the form joldem.parse, joldem.tokenize

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.5

9 years ago

0.1.2

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago