Skip to the content

Jarajara documentation

Jarajara API: every export

Every export of every entry point, each with its own page. This page keeps the addresses the old one-page reference had.

@johnmorrisdotca/jarajara/awase

AWASE_CHALLENGESconstant

AWASE WITH RULES YOU CHOOSE: options a game may be given (hints, shuffles and undo given, limited or taken away) and the challenges worth playing a deal for.

AWASE_CHECK_REASONSconstant

Why checkAwase will not take a solve, as a stable code and the English sentence it says.

AWASE_SAME_BLOCKconstant

THE SEEDS OF THE IDENTICAL RULE, a block no other seed of this puzzle uses: a kept run is found by its seed, so the seed is what can say which rule a deal was made under without a column of its own (as a Futago's does).

AwaseChecktype

What a check of a finished game says: cleared, or the first reason it is not, in English (reason) and as a stable code (AWASE_CHECK_REASONS).

AwaseDealtype

A deal of Awase: its layout's size, its level and seed, the tiles where they lie, and one way to clear them.

AwaseLeveltype

How hard a deal of Awase is: the easiest of a seed's candidate deals to clear, the middle one, or the hardest.

awaseRefusalfunction

A refusal: { ok: false }, the English reason and the code.

AwaseRulestype

What a game is played by, worked out from its options and its challenge.

AwaseRuntype

A game of Awase, and what the challenge it is played as asks of it.

AwaseRunReadingtype

The game as it stands, for a page to read: how the clock, the goal and the hunt are going, without working them out again.

bonusRuleOfSeedfunction

The native matching rule encoded by a seed: identical bonuses in the reserved block, grouped bonuses otherwise.

checkAwasefunction

Whether a solve clears a Mahjong deal: the check the browser makes to say "cleared" and the server makes before it pays.

clearRatefunction

How often a player taking any free pair at random clears this deal, out of times.

dailyAwasefunction

THE DAY'S GAME, the same for everybody on the same date: a layout, a level, a seed and a challenge worked out from the date alone (2026-10-01, or a Date, in UTC), so no server need hold it.

freshAwaseSeedfunction

A new seed for a deal under this rule: inside AWASE_SAME_BLOCK for the identical rule, anywhere else from 1 to SEED_MOST for the usual one.

generateAwasefunction

A deal of this layout at this level, made from this seed.

PURGE_GROUPSconstant

The groups a purge may name, each a set of tiles a layout is likely to hold plenty of.

runHintfunction

Ask for a hint: the new game with it counted and the pair named, or null where none is left to use or no pair can be taken.

runMarkedfunction

The tiles of the group the game is hunting for, as slots: the gold face, the purge's group, or nothing.

runMovesfunction

A game's moves written as encodeMoves writes them, with its seed, so it can be replayed on the deal.

runPairsfunction

Every pair that may be taken now: none once the game is over.

runRemainingfunction

How much time the game has left at at, in milliseconds; null for a game with no clock.

runShufflefunction

Shuffle what is left, which is for when no pair can be taken: the new game, or null where it may not be (a pair can still be taken, none is left to use, or no shuffle would help).

runStartfunction

Start the clock, if the game has one and it has not started.

runTakefunction

Take a pair at at: the new game, or null where the rules do not allow it (the game is over, or the two are not a pair that may be taken).

runTickfunction

The game as it stands at at: lost, if its time has run out.

runUndofunction

Take the last move back, where the rules allow undo: the new game, or null.

SEED_MOSTconstant

The most a seed can be: it travels in an address as a plain integer.

startRunfunction

Start a game of a deal.

@johnmorrisdotca/jarajara/table

AwaseSeattype

Who sits in a seat: a name typed on the device, or a computer.

AwaseTabletype

A GAME AT THE TABLE, as it is kept: the deal, who sits where, and every pair taken, in order.

AwaseTaketype

One pair taken, as the table remembers it.

computerPairfunction

The pair a computer in the seat to move takes, or null when there is nothing to take.

decodeTablefunction

A kept table read back, its shape checked and every pair played again; null for anything that is not one.

encodeTablefunction

As kept in the browser: the table as JSON, its takes as slot pairs.

playAtTablefunction

The player to move takes this pair: the table and where it now stands, or null where the rules do not allow it.

readTablefunction

WHERE THE GAME STANDS, played again from its pairs: null for a deal that is not one, or a pair the rules would not have allowed.

SEAT_WINDSconstant

The four seats' winds, east first, as a mahjong table seats its players.

seatNamefunction

What a seat is called: its name, "Computer 2", or its wind.

startTablefunction

A new game at the table: the deal made from the seed, these seats, and nothing taken.

tablePairsfunction

The pairs the player to move may take: none once the game is over.

tablePlayersAskedfunction

A players count from an address, or 1 (the solitaire) for anything that is not two to four.

takeAtTablefunction

The table after the player to move takes this pair, or null where the rules do not allow it.

tidySeatNamefunction

A name as kept: trimmed, one line, and no longer than a line holds.

undoAtTablefunction

The table with its last pair given back: the undo a table agrees to.

@johnmorrisdotca/jarajara/faces

backBasefunction

The colour of a back's plate, which is also the colour of the tile's thickness seen from the back: a built-in back's own base (with the caller's colour), a design's body, or null for a name with no back here.

blockColoursfunction

The colours of a design's blocks, from its own: the back plate is colours.body (the green of most real tiles unless the design says another, or the caller's body), the ivory layer a shade of the face, and the seam round the face is the design's rim if it stands out from the face, otherwise a line that does: darker on a light face, lighter on a dark one.

BlockDirectiontype

Which way a view lifts the layers and shows the thickness: x is 1 when each layer is lifted to the right (and the thickness shows on the left), -1 the other way round; y is 1 when it is lifted upward (thickness below), -1 downward.

blockSvgfunction

The block drawn behind a face: the back plate and the ivory layer in steps from the far side to the face, and the shading of the sides (the side the light falls on lighter, the other darker).

Clothtype

A cloth's name.

CLOTHSconstant

The cloths, in the order the family lists them.

clothVarsfunction

A cloth as CSS custom properties (--jarajara-felt, --jarajara-felt-deep, --jarajara-felt-ink); nothing for a name that is not a cloth.

faceEdgeSvgfunction

The outline and the raised edge laid over a face, in the face's own units.

faceWordsfunction

What a face is called, in English: "3 of characters", "east wind", "red dragon", "plum (flower)".

isBuiltInBackfunction

Whether a name is one of the five backs drawn here.

isClothfunction

Whether a text names a cloth.

JARAJARA_CLOTHSconstant

THE CLOTHS A TABLE MAY BE LAID IN: the same five the whole family offers, and itsutsu.com's boards: green (the family's own), blue, red, black, and wood.

jarajaraDesignfunction

Jarajara's own design as a design, made the first time it is asked for: the 42 faces, its jade back and the plain ivory tile.

layoutBoxfunction

The drawing's width and height for a layout's size, room left for the thickness and the layers.

layoutFramefunction

THE TILES' DRAWN EXTENT, plus an even margin: the smallest box that holds every tile of a layout as it is drawn, with its thickness and its layer offsets, in whichever view (mirror) puts them.

LayoutFrametype

The drawing's viewBox: where it starts and how large it is, in the face's units.

layoutSvgfunction

The whole layout as one <svg>, the tiles in cells where they lie (a face letter a slot, "." for one taken).

LayoutSvgOptionstype

Native tile, highlight, artwork, cloth and layout-view choices for SVG rendering.

RED_FIVE_CODESconstant

The codes of the fives of characters, circles and bamboo: the tiles a set may make red.

shadowSvgfunction

The shadow a tile casts on what lies under it: soft, in three widening layers, falling the way the thickness shows and reaching further the higher the tile (layer 0 is a tile on the table: a tight contact shadow).

TILE_BACKSconstant

THE BACKS OF THE TILES, drawn as SVG in the tile's own 30 by 40: what a tile lying face down shows.

TILE_BODYconstant

The tile itself: its ivory face, the rim round it, the bone of its side (the sliver a flat picture shows) and the green of the back plate its thickness is drawn in.

TILE_BOXconstant

The box a solid tile is drawn in, in the face's units: the face, its thickness down and to the left, and a margin for the outlines.

TILE_DEPTHconstant

How thick a tile is, and so how far each layer is lifted, in the face's units.

TILE_FONTconstant

The fonts the characters are drawn in, Japanese serif first; a page may load its own and name it here.

TILE_INKconstant

The inks a face is drawn in.

TILE_MARKSconstant

The marks a page may put on tiles: the one chosen, ones hinted, the matches Find lights, and a wash over the blocked.

TILE_MIRRORSconstant

The ways a board may be looked at: as it is, turned left to right, turned top to bottom, or both.

TILE_SIZEconstant

THE FACES OF THE TILES, as SVG text: a Japanese-style set in the plainest strokes that still read at thirty pixels.

tileAtfunction

Where a slot's tile face is drawn, raised by its layer along the thickness's direction.

tileBackDrawingfunction

The back of a tile in a design, plate and pattern, fitted to the tile's 30 by 40.

tileBackFacefunction

A back's plate and pattern in the tile's 30 by 40, without the sliver of side or the <svg>: the inside of a <symbol>, or the back an element puts behind a tile it turns over.

TileBackNametype

A back's name: one of the five drawn here, or a design's own (riichi, riichi-black).

tileBackSvgfunction

One tile's back on its own, as a whole <svg> in the same box as tileSvg: the back plate over a solid block, its thickness showing on two sides (the back plate's own colour, with the ivory layer beyond it).

tileBodySvgfunction

The tile's own plate in a design, fitted to the tile's 30 by 40; null for a design that draws the plain rounded rectangle.

tileColoursfunction

The colours of a tile's rim and thickness: a design's, or Jarajara's own ivory and jade.

TileDesigntype

A SET OF DRAWN TILES, a design: how the tile itself is drawn, its back, and each face's picture.

tileFaceSvgfunction

One face's drawing, in the tile's own 30 by 40, with no tile under it: the inside of a <symbol> or a <g>, for a board that draws its own tiles.

tileFaceSymbolsfunction

Every face as a <symbol> in one <defs>, ids <prefix>-<code>, so a board of 144 tiles draws 42 pictures and places each with a <use>.

tileSvgfunction

One tile on its own, as a whole <svg>: a solid block, the face on its ivory over a back plate whose thickness shows on two sides, named for a screen reader.

@johnmorrisdotca/jarajara/element

Allowancetype

How many of a thing a game allows: a number, or no limit at all.

allowanceOffunction

Read an allowance from an attribute: nothing or unlimited is no limit, off or 0 is none, a number is that many.

defineRackfunction

Register a rack under its standard tag or a host's own tag.

ELEMENT_SIZESconstant

The sizes every element takes, as a tile's width in pixels.

followLanguagefunction

Redraw an element when the page changes its language (<html lang>), as a language chooser does, until the function returned is called.

hintPairfunction

What a hint is: the free pair that leaves the stacks lowest after it, so a hint never digs a tile deeper than it must.

JarajaraGroupclass

A GROUP OF TILES, SHOWN: <jarajara-group group="winds">, the four winds with their names and how many of each the set holds.

JarajaraLayoutclass

A GAME OF AWASE ON ANY PAGE: <jarajara-layout size="15">, a stacked layout of tiles drawn on a cloth, with the rules of the solitaire in it: tap a free tile, then its match, and the pair goes.

JarajaraRackclass

A RACK OF TILES ON ANY PAGE, lined up in front of you: <jarajara-rack tiles="123m456p789s1112z">.

JarajaraSetclass

THE WHOLE SET, SHOWN: <jarajara-set>, all 42 faces by suit with how many of each the 144 tiles hold, or, with tiles, what a hand or a wall holds of it: each face as have/total, faces it has none of dimmed.

JarajaraTableclass

AWASE AT A TABLE, ON ANY PAGE: <jarajara-table players="3">, two to four players round one layout, each taking a free pair in turn: the seats with their winds and scores, the layout on a cloth, and computers playing the seats that are not people's.

JarajaraTileclass

ONE TILE ON ANY PAGE: <jarajara-tile code="F">, in any design and with any back, face up or face down, turned over by a tap when it has flip.

JarajaraViewerclass

A TILE LOOKED UP BY ITS CODE, NAME OR KEY: <jarajara-viewer query="east"> shows the tile big, with what it is called in English and in Japanese, its code, suit and rank, how many the set holds, what a pair of them scores at the table, and how a hand writes it.

languageOffunction

The language an element speaks: its own lang, or the nearest one above it, or the page's; Japanese for anything that starts ja.

MOST_SOUNDINGconstant

The most clicks sounding at one moment, across every element on the page.

RackDetailtype

How the rack lies, for the page to hear of: what is turned, raised and marked (by place in tiles), and how the tiles are put in order.

RackPlacetype

One tile's place: across and down in tile widths from where the rack starts.

rackPlacesfunction

Where each of count tiles lies, in order: the first at x 0, each a step on, groups set apart, raised tiles lifted.

rackWidthfunction

How wide a rack is, in tile widths: the last tile's place and the tile itself.

setPageSoundsfunction

Give every element on the page another player for its sounds: a page's own, or a test's stand-in that only records what was asked.

STRINGSconstant

THE WORDS THE ELEMENTS SAY, to a screen reader and in their own captions, in the two languages the family speaks.

TileReftype

Tiles as a method is given them: a number is the place of one tile in the rack as it was written (tiles), from 0; a letter or a name ("F", "east", "3p") is every tile of that face; a list is each of its parts.

@johnmorrisdotca/jarajara/element/define

@johnmorrisdotca/jarajara/designs/riichi

RIICHIconstant

The regular riichi tiles, drawn in a box 300 by 400.

@johnmorrisdotca/jarajara/designs/riichi-black

RIICHI_BLACKconstant

The black riichi tiles, drawn in a box 300 by 400.

@johnmorrisdotca/jarajara/tile-sounds

MOST_SOUNDS_AT_ONCEconstant

As many sounds as one call plays: thirteen tiles set down are eight clicks, not a wall of noise.

soundTimesfunction

When each of count sounds starts, in milliseconds from the first: one every gap, and no more than MOST_SOUNDS_AT_ONCE, spread over the same time.

TileSoundDatatype

The recordings, by name (deal-2), as base64 AAC.

TileSoundKindtype

One kind of sound: pick a tile lifted, place one set down, flip one turned over, pair two knocked together, shuffle the tiles washed, win a clatter of tiles.

TileSoundstype

A table's sounds: play one, mute and unmute, change the volume, close when the table goes.

TileSoundWindowtype

The parts of a window the sounds use: an audio context and atob.

@johnmorrisdotca/jarajara/sounds

TILE_SOUND_DATAconstant

The tile sounds, recorded: a tile picked up, set down, turned over, a pair knocked, the tiles shuffled and a clatter for a win, as base64 AAC (.m4a).

TileSoundFiletype

The name of one recording: its kind of sound and a number, such as pick-1.

@johnmorrisdotca/jarajara

ALL_LAYOUTSconstant

Every layout there is: the five above, which itsutsu.com's kept games are made on and which never change, then Jarajara's own more (layouts-more.ts), each of a width none of the others has.

arrangeIndexesfunction

The places the tiles take in an order, as the numbers of the tiles in the order they come: [2, 0, 1] has the third tile first.

arrangeTilesfunction

The tiles in an order, as a new list; see arrangeIndexes for what each order is.

AwaseChecktype

What a check of a finished game says: cleared, or the first reason it is not, in English (reason) and as a stable code (AWASE_CHECK_REASONS).

AwaseDealtype

A deal of Awase: its layout's size, its level and seed, the tiles where they lie, and one way to clear them.

AwaseLeveltype

How hard a deal of Awase is: the easiest of a seed's candidate deals to clear, the middle one, or the hardest.

blockedByfunction

Why a tile cannot be taken now: covered by a tile on it, or held on both sides.

bonusRuleOffunction

The deal's rule, read from the deal itself: a bonus tile dealt twice can only be the Identical rule, since the usual one deals each flower and season once.

canTakefunction

Whether these two slots are a pair that may be taken now.

copiesOffunction

How many of a face the set holds: four of every ordinary face, one of each flower and season.

countTilesfunction

How many of each face a list of tiles holds, by code; faces it holds none of are left out.

dealFitsfunction

Whether a deal is written right for a layout: one face a slot, nothing empty.

decodeMovesfunction

The moves a string holds, each slot below slots; null for anything else.

describeSlotfunction

Where a slot is, in tiles: across and down from the layout's corner (halves where a tile sits between two), and which layer, from 1.

EMPTY_SLOTconstant

The cell marker for a tile already removed from the layout.

encodeMovesfunction

Write pair takes and shuffles as the native compact move record.

faceOffunction

The face a letter stands for, or null for anything that is not one.

faceWordsfunction

What a face is called, in English: "3 of characters", "east wind", "red dragon", "plum (flower)".

faceWordsJafunction

What a face is called in Japanese: 三萬, 五筒, 七索, 東, 中, 梅, 春.

findFacefunction

The tile a text names, or null.

findFacesfunction

Every tile a text names: the one face findFace finds, or, for the name of a group (winds, honours, circles), all of its faces.

freePairsfunction

Every pair that could be taken now, each once, lower slot first, in slot order.

geometryOffunction

What lies on and beside each slot, worked out once for a layout and kept.

groupFacesfunction

The faces of a group, in the set's order.

groupStartsfunction

The places in a list, already in order, where a new group starts: every place whose tile is of another suit (or kind) than the one before it.

groupTilesfunction

The tiles split into the runs a gap is drawn between: by suit or by kind, each run in the set's order.

groupWordsfunction

What a group is called, in English and in Japanese.

hashTextfunction

A 32-bit FNV-1a hash of a string: the seed a shuffle is drawn from, so the same tiles shuffled the same time come out the same.

Hinttype

A hint: the pair to show (the chosen tile first, for a match) and what kind of answer it is.

hintForfunction

A HINT, WHICH LOOKS FIRST FOR THE CHOSEN TILE'S MATCH.

HintKindtype

What a hint found: a pair with the chosen tile in it (match), another pair because the chosen tile has no free match (other), a pair when no tile was chosen (any), or no pair at all (none).

isBonusfunction

A flower or a season: one of a kind in the set, and matched by its group under the usual rule.

isClearedfunction

Whether every tile has been taken.

isFaceCodefunction

Whether a single character names a supported tile face.

isFreefunction

Whether the tile in this slot is free.

isFreeAmongfunction

Whether a slot's tile could be taken now, among the slots present says are still filled.

isNotationfunction

Whether a text is written as hand notation, 123m456p: nothing but digit runs each closed by a suit letter.

kindOffunction

The kind of a tile: 0 numbers (characters, circles, bamboo), 1 honours (winds, dragons), 2 bonus tiles (flowers, seasons); 3 for a letter that is none.

Laidtype

A deal laid out and the order it can be cleared in, pair by pair.

layoutExtentfunction

The layout's extent in half units: how far right and down its tiles reach, and how many layers.

layoutForfunction

The layout a size names, or null for one there is not.

layPairsfunction

Lay these pairs of tiles into the slots present names, or null when no attempt reached the end.

MAHJONG_FACESconstant

The forty-two tile faces in stable code order, including bonus tiles.

MAHJONG_LAYOUTSconstant

The built-in native layouts in supported size order.

MahjongCellstype

The tiles as they lie: a face code for each slot of the layout, "." where the tile has been taken.

MahjongFacetype

One face of the set: its suit and its rank within it (1–9 for a suit, 1–4 or 1–3 for the rest).

MahjongGeometrytype

What stands on and beside each slot, worked out once per layout: the slots over it (any higher layer overlapping it), and the slots touching its left and right sides on its own layer.

MahjongLayouttype

A stacked layout: its slots in reading order (layer by layer, row by row), which is the order a deal is written in.

MahjongMovetype

One move of a solve: a pair taken, by its two slots, or a shuffle of what is left.

MahjongSlottype

A place in a layout: a tile's top-left corner in half-tile units across and down, and its layer.

MahjongSuittype

The suits and honours of a mahjong set, and the two kinds of bonus tile.

matchesOffunction

EVERY TILE THAT MATCHES A SLOT'S, under the bonus rule in play, told apart by whether it could be taken with it now.

MatchesOftype

Which tile Find would show for a slot: the ones that could be taken with it now, and the ones that match but are held.

MEGA_LAYOUTSconstant

The large native stacked layouts and their supported size identifiers.

mixTilesfunction

The same tiles in another order, at random, or the same order for the same seed; never the order they were in unless there is only one to be in.

MORE_LAYOUTSconstant

The additional native stacked layouts and their supported size identifiers.

overlapsOnLayerfunction

Whether two slots of one layer overlap, which no layout may have: a tile cannot share a place.

pairGoesAgainfunction

Whether taking this pair gives its taker another turn at the table: a flower or season pair.

pairPointsfunction

WHAT A PAIR IS WORTH AT THE TABLE (table.ts): the plain suit tiles one, the ones and nines two, the winds three and the dragons four — the honours and terminals are the tiles a mahjong hand prizes — and a flower or season pair two, with another turn, as a bonus tile draws again in the full game.

pairsLeftfunction

The tiles left on a layout as pairs that match, each pair's tiles together: what a shuffle lays again.

playSolvefunction

PLAY THE MOVES ON THE DEAL, refusing the first that the rules do not allow: a pair that is not two free tiles that match, or a shuffle while a pair could still be taken (Shuffle is for when you are stuck), or one that cannot help.

Randomtype

A number in [0, 1), like Math.random, from a stream a seed fixes.

readNotationfunction

The tiles a hand's notation writes, as codes in the order written; null when the text is not notation or names a tile there is not (8z).

readSlotKeysfunction

The keys a text names, "z y x", "x,-z", in order; anything that is no axis is dropped.

readTilesfunction

A LIST OF TILES AS TEXT, read the forgiving way: each word is a tile's name (east, red-dragon, 3p) or a run of one-letter codes (abcF), and hand notation (123m456p) is read as it is written.

Replayedtype

Where a solve stands after its moves: the tiles, and how many shuffles it has had.

seededRandomfunction

A stream of numbers in [0, 1) fixed by a seed.

setInventoryfunction

The whole set as an inventory: each of the 42 faces and how many of it the 144 tiles hold.

setPairsfunction

EVERY PAIR THE SET HOLDS, 72 of them: each ordinary face twice (four copies), and the eight bonus tiles as four pairs — two flowers and two seasons, split at random under the usual rule, or four faces drawn twice each under the Identical rule.

SHUFFLE_MARKconstant

A SOLVE AS IT IS WRITTEN: every move in order, a pair as its two slots in two base-36 characters each ("0a1c"), a shuffle as "*".

shuffledfunction

A copy of the list in a random order (Fisher–Yates); the list given is left alone.

shuffleTilesfunction

SHUFFLE: the tiles left, laid again in the slots they fill, so that play can go on.

SlotAxistype

What a layout's slots are put in order by: where a tile is across (x), down (y), and how high (z).

SlotSortKeytype

One key of a sort: an axis, and - before it for the other way round (-z, the highest first).

sortSlotsfunction

The slots of a layout, as their numbers, put in order by the keys: ["z", "y", "x"] is layer by layer, row by row, across (the layout's own order), ["x"] lines them up from the left, ["-z"] has the top of the stacks first.

SUIT_WORDSconstant

What a suit or group is called, in English and in Japanese.

takePairfunction

The tiles with a pair taken.

TILE_GROUPSconstant

THE GROUPS A SET FALLS INTO, for a viewer: each suit, and the bigger families people name them by: honours (winds and dragons), bonus (flowers and seasons), the numbers (the three suits), and the terminals (the ones and nines) and simples (two to eight) a hand is judged by.

TILE_ORDERSconstant

The orders, in the order a list offers them.

TileGroupingtype

How tiles are grouped, with a gap between groups: by suit (circles with circles), or by kind (numbers, honours, bonus tiles).

tileNamefunction

A tile's name in a language, from its code; the code itself for a letter that is no face.

TileOrdertype

How a hand is put in order: as dealt, by suit then rank, by rank across the suits, by kind, or by the letters.

tilesLeftfunction

How many tiles are still on the layout.

tilesMatchfunction

Whether two tile face codes match under the selected bonus rule.

VERSIONconstant

The package's version.

writeNotationfunction

Tiles written the way hands are: digits then a suit letter, 123m456p789s1112z.

writeTilesfunction

Tiles as their one-letter codes run together, abcF: what readTiles reads and a layout's cells are written in.