UNPKG

@freeword/meta

Version:

Meta package for Freeword: exports all core types, constants, and utilities from the src/ directory.

102 lines 8.41 kB
import type * as TY from '../types.ts'; /** Which letters in A are missing from B? | `A - B` | Wordbits | Difference | `A & ~B & WordbitMask` | */ export declare function aMinusB(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters in A are missing from B? | `A - B` | Wordbits | Difference | `A & ~B & WordbitMask` | */ export declare function aMinusAll(aBits: TY.WordbitsT, ...bBitses: readonly TY.WordbitsT[]): TY.WordbitsT; /** Which letters in A are missing from B? | `A - B` | Wordbits | Difference | `A & ~B & WordbitMask` | */ export declare function subtract(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters appear in either A or B (or both)? | `A ∪ B` | Wordbits | Union | `A \| B` | */ export declare function union(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters appear in any of the given sets? | `A ∪ B ∪ C` | Wordbits | Union | `A \| B \| C` | */ export declare function unions(...bitses: TY.WordbitsT[]): TY.WordbitsT; /** Which letters appear in either A or B (or both)? | `A ∪ B` | Wordbits | Union | `A \| B` | */ export declare function inEither(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters do both A and B have in common? | `A ∩ B` | Wordbits | Intersection | `A & B` | */ export declare function intersection(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters appear in all of the given sets? | `A ∩ B ∩ C` | Wordbits | Intersection | `A & B & C` | */ export declare function intersections(...bitses: TY.WordbitsT[]): TY.WordbitsT; /** Which letters do both A and B have in common? | `A ∩ B` | Wordbits | Intersection | `A & B` | */ export declare function inBoth(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters are in A, or in B, but not in both? | `A ∆ B` | Wordbits | Symmetric Difference | `A ^ B` | */ export declare function inEitherNotBoth(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Which letters are in A, or in B, but not in both? | `A ∆ B` | Wordbits | Symmetric Difference | `A ^ B` | */ export declare function xor(aBits: TY.WordbitsT, bBits: TY.WordbitsT): TY.WordbitsT; /** Do A and B share any letters at all? | `A ∩ B ≠ ∅` | boolean | Overlap | `(A & B) !== 0` | */ export declare function overlaps(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Do A and B have no letters in common? | `A ∩ B = ∅` | boolean | Disjoint | `(A & B) === 0` | */ export declare function hasNoOverlap(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Do A and B have no letters in common? | `A ∩ B = ∅` | boolean | Disjoint | `(A & B) === 0` | */ export declare function disjoint(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Do A and B use exactly the same letters? | `A = B` | boolean | Equality | `A === B` | */ export declare function equals(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; export declare function missingLtrs(wordbits: TY.WordbitsT): TY.MissingBits; /** Does A include *all* of the letters in B? | `A ⊆ B` | boolean | Subset | `(A & B) === A` | */ export declare function contains(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Does A include *all* of the letters in B? | `A ⊆ B` | boolean | Subset | `(A & B) === A` | */ export declare function aHasAllOfB(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Does A include all the letters in B *and more*? | `A ⊊ B` | boolean | Strict Subset | `(A & B) === A && A !== B` | */ export declare function aHasAllAndMoreB(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Does A include all the letters in B *and more*? | `A ⊊ B` | boolean | Strict Subset | `(A & B) === A && A !== B` | */ export declare function strictlyContains(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Is at least one letter in A missing from B? | `A ⊄ B` | boolean | Not Subset | `(A & B) !== A` | */ export declare function aHasMissingFromB(aBits: TY.WordbitsT, bBits: TY.WordbitsT): boolean; /** Which letters are *not* in A? | `¬A` | Wordbits | Complement | `~A & WordbitMask` | */ export declare function missingFrom(aBits: TY.WordbitsT): TY.WordbitsT; /** @returns the wordbit mask for a single letter */ export declare function wordbitForLtr(ltr: TY.AtoZlo): number; export declare function countBits14Magic(wordbits: bigint | number): number; /** count bits in a 7-bit number */ export declare function countBits7Magic(wordbitso: number): number; /** count bits in a 32-bit number */ export declare function countBits32(wordbitso: number): number; /** @returns the number of bits set in the bitfield */ export declare function countUniqLtrs(wordbits: TY.WordbitsT): number; export declare const countBits28: typeof countUniqLtrs; /** @returns a string of only lowercase letters; given nil, returns '' */ export declare function normalizeWord(str: TY.StringMaybe): TY.Word; /** @returns the wordbits encoding for a word: * bit 0 (least significant / rightmost) is set if the word has an 'a', * bit 1 is set if the word has a 'b', etc. * ... * bit 25 (most significant / leftmost) is set if the word has a 'z' */ export declare function wordbitsForWord(word: TY.Word | TY.Letter[]): TY.WordbitsT; /** @returns the wordbits encoding for a word. @see {wordbitsForWord} */ export declare function wordbitsForWordSafe(str: TY.StringMaybe): TY.WordbitsT; export declare function missingWordbits(wordbits: TY.WordbitsT): TY.WordbitsT; /** ROT-13: trivially obscure/decode a string: a->n, b->o, ..., m->z, n->a, ..., z->m. * Installation is the reverse of removal. * @see {UF.rot13Word} */ export declare function rot13Wordbits(wordbits: TY.WordbitsT): TY.WordbitsT; /** ROT-n: trivially obscure/decode a string: a->n, b->o, ..., m->z, n->a, ..., z->m. * Installation is the reverse of removal. * @see {rotNWord} */ export declare function rotNWordbits(wordbits: TY.WordbitsT, by: number): TY.WordbitsT; /** @returns the unique letters in the word, in alphabetical order */ export declare function ltrsForWordbits(wordbits: TY.WordbitsT): TY.Shingle; /** @returns a fixed-width string of the wordbits, eg 0b00_0000_0100_1001_0001_1000_0100 for 'chimps' */ export declare function prettyWordbits(wordbits: TY.WordbitsT): string; export declare function prettyBinary53(val: number, num?: number): string; export declare function prettyBinary32(val: number): string; export declare function prettyBinaries(vals: (number | bigint)[], num?: number | undefined): string; export type DigestedWord = { /** the original word */ word: TY.Word; /** array of the word's letters, sorted */ ltrs: TY.AtoZlo[]; /** the first letter in the word */ beg: TY.AtoZlo; /** the last letter in the word */ end: TY.AtoZlo; /** wordbits of word's unique letters */ wordbits: TY.WordbitsT; /** wordbits of letters absent from word */ missbits: TY.WordbitsT; /** wordbit mask of the initial letter */ begbit: TY.WordbitsT; /** wordbit mask of the final letter */ endbit: TY.WordbitsT; /** uniq letters, sorted and joined */ uniqarr: TY.AtoZlo[]; /** duplicated letters, in alphabetic order; the first occurrence goes in uniqstr, * all remaining occurrences go in dupearr. `uniqstr.length + dupearr.length === word.length` * @example for 'minimises', uniqstr: 'eimns', dupestr: 'iims' * @example for 'mines', uniqstr: 'eimns', dupestr: '' * */ dupearr: TY.AtoZlo[]; }; /** @returns {DigestedWord} a summary of the wordbits encoding for a word * @see {DigestedWord} */ export declare function digestWord(word: TY.Word): DigestedWord; //# sourceMappingURL=Wordbits.d.ts.map