puzzle-lib 1.7.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +50 -38
- package/build/src/Braille/braille.d.ts +20 -0
- package/build/src/Braille/braille.js +127 -0
- package/build/src/Braille/braille.js.map +1 -0
- package/build/src/Cipher/cipher.d.ts +33 -0
- package/build/src/Cipher/cipher.js +161 -0
- package/build/src/Cipher/cipher.js.map +1 -0
- package/build/src/Conversion/CharacterEncoding.d.ts +5 -5
- package/build/src/Conversion/characterConversion.d.ts +17 -0
- package/build/src/Conversion/characterConversion.js +63 -0
- package/build/src/Conversion/characterConversion.js.map +1 -0
- package/build/src/Conversion/conversion.d.ts +19 -0
- package/build/src/Conversion/conversion.js +130 -0
- package/build/src/Conversion/conversion.js.map +1 -0
- package/build/src/Conversion/significantFigures.d.ts +12 -0
- package/build/src/Conversion/significantFigures.js +62 -0
- package/build/src/Conversion/significantFigures.js.map +1 -0
- package/build/src/Morse/MorseEncoding.js.map +1 -1
- package/build/src/Morse/morse.d.ts +36 -0
- package/build/src/Morse/morse.js +232 -0
- package/build/src/Morse/morse.js.map +1 -0
- package/build/src/Nato/nato.d.ts +3 -0
- package/build/src/Nato/nato.js +37 -0
- package/build/src/Nato/nato.js.map +1 -0
- package/build/src/NavalFlags/navalFlags.d.ts +3 -0
- package/build/src/NavalFlags/{NavalFlags.js → navalFlags.js} +33 -46
- package/build/src/NavalFlags/navalFlags.js.map +1 -0
- package/build/src/Resistor/resistor.d.ts +17 -0
- package/build/src/Resistor/resistor.js +109 -0
- package/build/src/Resistor/resistor.js.map +1 -0
- package/build/src/Semaphore/semaphore.d.ts +40 -0
- package/build/src/Semaphore/semaphore.js +182 -0
- package/build/src/Semaphore/semaphore.js.map +1 -0
- package/build/src/WordSearch/wordSearch.d.ts +16 -0
- package/build/src/WordSearch/wordSearch.js +189 -0
- package/build/src/WordSearch/wordSearch.js.map +1 -0
- package/build/src/index.d.ts +14 -20
- package/build/src/index.js +70 -42
- package/build/src/index.js.map +1 -1
- package/package.json +40 -40
- package/src/Braille/braille.ts +179 -0
- package/src/Cipher/cipher.ts +177 -0
- package/src/Conversion/characterConversion.ts +73 -0
- package/src/Conversion/conversion.ts +155 -0
- package/src/Conversion/significantFigures.ts +65 -0
- package/src/Morse/morse.ts +312 -0
- package/src/Nato/nato.ts +38 -0
- package/src/NavalFlags/LICENSE +6 -6
- package/src/NavalFlags/{NavalFlags.ts → navalFlags.ts} +188 -201
- package/src/Resistor/resistor.ts +113 -0
- package/src/Semaphore/semaphore.ts +214 -0
- package/src/WordSearch/wordSearch.ts +264 -0
- package/src/index.ts +72 -21
- package/build/src/Braille/BrailleCharacter.d.ts +0 -15
- package/build/src/Braille/BrailleCharacter.js +0 -40
- package/build/src/Braille/BrailleCharacter.js.map +0 -1
- package/build/src/Braille/BrailleData.d.ts +0 -6
- package/build/src/Braille/BrailleData.js +0 -66
- package/build/src/Braille/BrailleData.js.map +0 -1
- package/build/src/Braille/BrailleStream.d.ts +0 -18
- package/build/src/Braille/BrailleStream.js +0 -76
- package/build/src/Braille/BrailleStream.js.map +0 -1
- package/build/src/Cipher/AutoKeyString.d.ts +0 -4
- package/build/src/Cipher/AutoKeyString.js +0 -35
- package/build/src/Cipher/AutoKeyString.js.map +0 -1
- package/build/src/Cipher/CaesarString.d.ts +0 -8
- package/build/src/Cipher/CaesarString.js +0 -33
- package/build/src/Cipher/CaesarString.js.map +0 -1
- package/build/src/Cipher/CaesarUtils.d.ts +0 -13
- package/build/src/Cipher/CaesarUtils.js +0 -58
- package/build/src/Cipher/CaesarUtils.js.map +0 -1
- package/build/src/Cipher/KeyedCipherStringBase.d.ts +0 -12
- package/build/src/Cipher/KeyedCipherStringBase.js +0 -31
- package/build/src/Cipher/KeyedCipherStringBase.js.map +0 -1
- package/build/src/Cipher/VigenereString.d.ts +0 -4
- package/build/src/Cipher/VigenereString.js +0 -22
- package/build/src/Cipher/VigenereString.js.map +0 -1
- package/build/src/Common/EncodingCharacterBase.d.ts +0 -23
- package/build/src/Common/EncodingCharacterBase.js +0 -55
- package/build/src/Common/EncodingCharacterBase.js.map +0 -1
- package/build/src/Common/EncodingDataBase.d.ts +0 -7
- package/build/src/Common/EncodingDataBase.js +0 -28
- package/build/src/Common/EncodingDataBase.js.map +0 -1
- package/build/src/Common/Helpers.d.ts +0 -4
- package/build/src/Common/Helpers.js +0 -17
- package/build/src/Common/Helpers.js.map +0 -1
- package/build/src/Conversion/CharacterAutoConvert.d.ts +0 -10
- package/build/src/Conversion/CharacterAutoConvert.js +0 -89
- package/build/src/Conversion/CharacterAutoConvert.js.map +0 -1
- package/build/src/Conversion/CharacterConversion.d.ts +0 -8
- package/build/src/Conversion/CharacterConversion.js +0 -51
- package/build/src/Conversion/CharacterConversion.js.map +0 -1
- package/build/src/Conversion/SignificantFigures.d.ts +0 -7
- package/build/src/Conversion/SignificantFigures.js +0 -51
- package/build/src/Conversion/SignificantFigures.js.map +0 -1
- package/build/src/Conversion/StringAutoConvert.d.ts +0 -6
- package/build/src/Conversion/StringAutoConvert.js +0 -47
- package/build/src/Conversion/StringAutoConvert.js.map +0 -1
- package/build/src/Morse/MorseCharacter.d.ts +0 -22
- package/build/src/Morse/MorseCharacter.js +0 -98
- package/build/src/Morse/MorseCharacter.js.map +0 -1
- package/build/src/Morse/MorseData.d.ts +0 -6
- package/build/src/Morse/MorseData.js +0 -71
- package/build/src/Morse/MorseData.js.map +0 -1
- package/build/src/Morse/MorseString.d.ts +0 -10
- package/build/src/Morse/MorseString.js +0 -68
- package/build/src/Morse/MorseString.js.map +0 -1
- package/build/src/Nato/NatoData.d.ts +0 -7
- package/build/src/Nato/NatoData.js +0 -50
- package/build/src/Nato/NatoData.js.map +0 -1
- package/build/src/NavalFlags/NavalFlags.d.ts +0 -7
- package/build/src/NavalFlags/NavalFlags.js.map +0 -1
- package/build/src/Resistor/Resistor.d.ts +0 -24
- package/build/src/Resistor/Resistor.js +0 -87
- package/build/src/Resistor/Resistor.js.map +0 -1
- package/build/src/Resistor/ResistorColorEntry.d.ts +0 -12
- package/build/src/Resistor/ResistorColorEntry.js +0 -37
- package/build/src/Resistor/ResistorColorEntry.js.map +0 -1
- package/build/src/Semaphore/SemaphoreCharacter.d.ts +0 -20
- package/build/src/Semaphore/SemaphoreCharacter.js +0 -76
- package/build/src/Semaphore/SemaphoreCharacter.js.map +0 -1
- package/build/src/Semaphore/SemaphoreData.d.ts +0 -6
- package/build/src/Semaphore/SemaphoreData.js +0 -54
- package/build/src/Semaphore/SemaphoreData.js.map +0 -1
- package/build/src/Semaphore/SemaphoreDegrees.d.ts +0 -5
- package/build/src/Semaphore/SemaphoreDegrees.js +0 -27
- package/build/src/Semaphore/SemaphoreDegrees.js.map +0 -1
- package/build/src/Semaphore/SemaphoreStream.d.ts +0 -17
- package/build/src/Semaphore/SemaphoreStream.js +0 -74
- package/build/src/Semaphore/SemaphoreStream.js.map +0 -1
- package/build/src/WordSearch/WordSearchSolver.d.ts +0 -27
- package/build/src/WordSearch/WordSearchSolver.js +0 -233
- package/build/src/WordSearch/WordSearchSolver.js.map +0 -1
- package/src/Braille/BrailleCharacter.ts +0 -49
- package/src/Braille/BrailleData.ts +0 -131
- package/src/Braille/BrailleStream.ts +0 -87
- package/src/Cipher/AutoKeyString.ts +0 -35
- package/src/Cipher/CaesarString.ts +0 -38
- package/src/Cipher/CaesarUtils.ts +0 -69
- package/src/Cipher/KeyedCipherStringBase.ts +0 -35
- package/src/Cipher/VigenereString.ts +0 -21
- package/src/Common/EncodingCharacterBase.ts +0 -72
- package/src/Common/EncodingDataBase.ts +0 -31
- package/src/Common/Helpers.ts +0 -13
- package/src/Conversion/CharacterAutoConvert.ts +0 -108
- package/src/Conversion/CharacterConversion.ts +0 -89
- package/src/Conversion/SignificantFigures.ts +0 -55
- package/src/Conversion/StringAutoConvert.ts +0 -56
- package/src/Morse/MorseCharacter.ts +0 -112
- package/src/Morse/MorseData.ts +0 -143
- package/src/Morse/MorseString.ts +0 -106
- package/src/Nato/NatoData.ts +0 -49
- package/src/Resistor/Resistor.ts +0 -135
- package/src/Resistor/ResistorColorEntry.ts +0 -43
- package/src/Semaphore/SemaphoreCharacter.ts +0 -107
- package/src/Semaphore/SemaphoreData.ts +0 -58
- package/src/Semaphore/SemaphoreDegrees.ts +0 -26
- package/src/Semaphore/SemaphoreStream.ts +0 -89
- package/src/WordSearch/WordSearchSolver.ts +0 -271
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Kyle Farnung
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Kyle Farnung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,38 +1,50 @@
|
|
|
1
|
-
# puzzle-lib
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
[](https://www.npmjs.com/package/puzzle-lib)
|
|
5
|
-
|
|
6
|
-
Library of puzzle-solving algorithms
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
```console
|
|
11
|
-
$ npm install --save puzzle-lib
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
$
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
# puzzle-lib
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://www.npmjs.com/package/puzzle-lib)
|
|
5
|
+
|
|
6
|
+
Library of puzzle-solving algorithms
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```console
|
|
11
|
+
$ npm install --save puzzle-lib
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { decodeMorse, caesarRotations, vigenereEncrypt } from 'puzzle-lib';
|
|
16
|
+
|
|
17
|
+
// Decode morse code
|
|
18
|
+
decodeMorse('.----/..---/...--'); // '123'
|
|
19
|
+
|
|
20
|
+
// Get all Caesar cipher rotations
|
|
21
|
+
caesarRotations('hello');
|
|
22
|
+
|
|
23
|
+
// Vigenère encrypt
|
|
24
|
+
vigenereEncrypt('hello', 'key');
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
The library and tests are written in TypeScript. Tests use
|
|
30
|
+
[Vitest](https://vitest.dev/).
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
$ git clone https://github.com/puzztool/puzzle-lib.git
|
|
34
|
+
$ cd puzzle-lib
|
|
35
|
+
$ npm install
|
|
36
|
+
$ npm test
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To lint:
|
|
40
|
+
|
|
41
|
+
```console
|
|
42
|
+
$ npm run lint
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
To use local changes in another project:
|
|
46
|
+
|
|
47
|
+
```console
|
|
48
|
+
$ cd <path to other project>
|
|
49
|
+
$ npm link <path to puzzle-lib>
|
|
50
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EncodingCategory } from '../Common/EncodingCategory';
|
|
2
|
+
import { EncodingLookupResult } from '../Common/EncodingLookupResult';
|
|
3
|
+
import { BrailleDot } from './BrailleDot';
|
|
4
|
+
import { BrailleEncoding } from './BrailleEncoding';
|
|
5
|
+
/**
|
|
6
|
+
* Looks up a braille encoding in the data table.
|
|
7
|
+
*/
|
|
8
|
+
export declare function lookupBrailleEncoding(encoding: BrailleEncoding, category?: EncodingCategory): EncodingLookupResult<BrailleEncoding>;
|
|
9
|
+
/**
|
|
10
|
+
* Toggles a dot (or encoding bitmask) on/off, returns the new encoding.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toggleBrailleDot(encoding: BrailleEncoding, dot: BrailleDot | BrailleEncoding): BrailleEncoding;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a dot (or encoding bitmask) is set.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getBrailleDot(encoding: BrailleEncoding, dot: BrailleDot | BrailleEncoding): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Decodes an array of braille encodings to a string, handling number mode.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeBrailleStream(encodings: BrailleEncoding[]): string;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lookupBrailleEncoding = lookupBrailleEncoding;
|
|
4
|
+
exports.toggleBrailleDot = toggleBrailleDot;
|
|
5
|
+
exports.getBrailleDot = getBrailleDot;
|
|
6
|
+
exports.decodeBrailleStream = decodeBrailleStream;
|
|
7
|
+
const EncodingCategory_1 = require("../Common/EncodingCategory");
|
|
8
|
+
const EncodingEntry_1 = require("../Common/EncodingEntry");
|
|
9
|
+
const EncodingLookupResult_1 = require("../Common/EncodingLookupResult");
|
|
10
|
+
const BrailleEncoding_1 = require("./BrailleEncoding");
|
|
11
|
+
// Build the lookup table once
|
|
12
|
+
const BRAILLE_ENTRIES = [];
|
|
13
|
+
function addEntry(encoding, category, display) {
|
|
14
|
+
BRAILLE_ENTRIES.push(new EncodingEntry_1.EncodingEntry(encoding, category, display));
|
|
15
|
+
}
|
|
16
|
+
// Letters
|
|
17
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterA, EncodingCategory_1.EncodingCategory.Letter, 'A');
|
|
18
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterB, EncodingCategory_1.EncodingCategory.Letter, 'B');
|
|
19
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterC, EncodingCategory_1.EncodingCategory.Letter, 'C');
|
|
20
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterD, EncodingCategory_1.EncodingCategory.Letter, 'D');
|
|
21
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterE, EncodingCategory_1.EncodingCategory.Letter, 'E');
|
|
22
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterF, EncodingCategory_1.EncodingCategory.Letter, 'F');
|
|
23
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterG, EncodingCategory_1.EncodingCategory.Letter, 'G');
|
|
24
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterH, EncodingCategory_1.EncodingCategory.Letter, 'H');
|
|
25
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterI, EncodingCategory_1.EncodingCategory.Letter, 'I');
|
|
26
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterJ, EncodingCategory_1.EncodingCategory.Letter, 'J');
|
|
27
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterK, EncodingCategory_1.EncodingCategory.Letter, 'K');
|
|
28
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterL, EncodingCategory_1.EncodingCategory.Letter, 'L');
|
|
29
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterM, EncodingCategory_1.EncodingCategory.Letter, 'M');
|
|
30
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterN, EncodingCategory_1.EncodingCategory.Letter, 'N');
|
|
31
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterO, EncodingCategory_1.EncodingCategory.Letter, 'O');
|
|
32
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterP, EncodingCategory_1.EncodingCategory.Letter, 'P');
|
|
33
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterQ, EncodingCategory_1.EncodingCategory.Letter, 'Q');
|
|
34
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterR, EncodingCategory_1.EncodingCategory.Letter, 'R');
|
|
35
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterS, EncodingCategory_1.EncodingCategory.Letter, 'S');
|
|
36
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterT, EncodingCategory_1.EncodingCategory.Letter, 'T');
|
|
37
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterU, EncodingCategory_1.EncodingCategory.Letter, 'U');
|
|
38
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterV, EncodingCategory_1.EncodingCategory.Letter, 'V');
|
|
39
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterW, EncodingCategory_1.EncodingCategory.Letter, 'W');
|
|
40
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterX, EncodingCategory_1.EncodingCategory.Letter, 'X');
|
|
41
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterY, EncodingCategory_1.EncodingCategory.Letter, 'Y');
|
|
42
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.LetterZ, EncodingCategory_1.EncodingCategory.Letter, 'Z');
|
|
43
|
+
// Numbers
|
|
44
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number0, EncodingCategory_1.EncodingCategory.Number, '0');
|
|
45
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number1, EncodingCategory_1.EncodingCategory.Number, '1');
|
|
46
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number2, EncodingCategory_1.EncodingCategory.Number, '2');
|
|
47
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number3, EncodingCategory_1.EncodingCategory.Number, '3');
|
|
48
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number4, EncodingCategory_1.EncodingCategory.Number, '4');
|
|
49
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number5, EncodingCategory_1.EncodingCategory.Number, '5');
|
|
50
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number6, EncodingCategory_1.EncodingCategory.Number, '6');
|
|
51
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number7, EncodingCategory_1.EncodingCategory.Number, '7');
|
|
52
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number8, EncodingCategory_1.EncodingCategory.Number, '8');
|
|
53
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.Number9, EncodingCategory_1.EncodingCategory.Number, '9');
|
|
54
|
+
// Formatting
|
|
55
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.FormattingNumber, EncodingCategory_1.EncodingCategory.Formatting, '#');
|
|
56
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.FormattingCapital, EncodingCategory_1.EncodingCategory.Formatting, '^');
|
|
57
|
+
// Punctuation
|
|
58
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationComma, EncodingCategory_1.EncodingCategory.Punctuation, ',');
|
|
59
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationSemicolon, EncodingCategory_1.EncodingCategory.Punctuation, ';');
|
|
60
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationApostrophe, EncodingCategory_1.EncodingCategory.Punctuation, "'");
|
|
61
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationColon, EncodingCategory_1.EncodingCategory.Punctuation, ':');
|
|
62
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationHyphen, EncodingCategory_1.EncodingCategory.Punctuation, '-');
|
|
63
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationDecimalPoint, EncodingCategory_1.EncodingCategory.Punctuation, '.');
|
|
64
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationFullStop, EncodingCategory_1.EncodingCategory.Punctuation, '.');
|
|
65
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationExclamationPoint, EncodingCategory_1.EncodingCategory.Punctuation, '!');
|
|
66
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationOpenQuote, EncodingCategory_1.EncodingCategory.Punctuation, '"');
|
|
67
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationQuestionMark, EncodingCategory_1.EncodingCategory.Punctuation, '?');
|
|
68
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationCloseQuote, EncodingCategory_1.EncodingCategory.Punctuation, '"');
|
|
69
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationBracket, EncodingCategory_1.EncodingCategory.Punctuation, '(');
|
|
70
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationBracket, EncodingCategory_1.EncodingCategory.Punctuation, ')');
|
|
71
|
+
addEntry(BrailleEncoding_1.BrailleEncoding.PunctuationSlash, EncodingCategory_1.EncodingCategory.Punctuation, '/');
|
|
72
|
+
/**
|
|
73
|
+
* Looks up a braille encoding in the data table.
|
|
74
|
+
*/
|
|
75
|
+
function lookupBrailleEncoding(encoding, category = EncodingCategory_1.EncodingCategory.All) {
|
|
76
|
+
const result = new EncodingLookupResult_1.EncodingLookupResult();
|
|
77
|
+
for (const entry of BRAILLE_ENTRIES) {
|
|
78
|
+
if ((entry.category & category) !== 0) {
|
|
79
|
+
if (entry.encoding === encoding) {
|
|
80
|
+
result.exact.push(entry);
|
|
81
|
+
}
|
|
82
|
+
else if ((entry.encoding & encoding) === encoding) {
|
|
83
|
+
result.partial.push(entry);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Toggles a dot (or encoding bitmask) on/off, returns the new encoding.
|
|
91
|
+
*/
|
|
92
|
+
function toggleBrailleDot(encoding, dot) {
|
|
93
|
+
return encoding ^ dot;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Checks if a dot (or encoding bitmask) is set.
|
|
97
|
+
*/
|
|
98
|
+
function getBrailleDot(encoding, dot) {
|
|
99
|
+
return (encoding & dot) === dot;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Decodes an array of braille encodings to a string, handling number mode.
|
|
103
|
+
*/
|
|
104
|
+
function decodeBrailleStream(encodings) {
|
|
105
|
+
let result = '';
|
|
106
|
+
let numberMode = false;
|
|
107
|
+
for (const ch of encodings) {
|
|
108
|
+
if (ch === BrailleEncoding_1.BrailleEncoding.None) {
|
|
109
|
+
numberMode = false;
|
|
110
|
+
result += ' ';
|
|
111
|
+
}
|
|
112
|
+
else if (ch === BrailleEncoding_1.BrailleEncoding.FormattingNumber) {
|
|
113
|
+
numberMode = true;
|
|
114
|
+
result += '#';
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const category = EncodingCategory_1.EncodingCategory.Punctuation |
|
|
118
|
+
(numberMode ? EncodingCategory_1.EncodingCategory.Number : EncodingCategory_1.EncodingCategory.Letter);
|
|
119
|
+
const lookup = lookupBrailleEncoding(ch, category);
|
|
120
|
+
if (lookup.exact.length > 0) {
|
|
121
|
+
result += lookup.exact[0].toString();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=braille.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braille.js","sourceRoot":"","sources":["../../../src/Braille/braille.ts"],"names":[],"mappings":";;AAgHA,sDAiBC;AAKD,4CAKC;AAKD,sCAKC;AAKD,kDAwBC;AAlLD,iEAA4D;AAC5D,2DAAsD;AACtD,y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AC;YACnD,UAAU,GAAG,IAAI,CAAC;YAClB,MAAM,IAAI,GAAG,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GACZ,mCAAgB,CAAC,WAAW;gBAC5B,CAAC,UAAU,CAAC,CAAC,CAAC,mCAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,mCAAgB,CAAC,MAAM,CAAC,CAAC;YACnE,MAAM,MAAM,GAAG,qBAAqB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAEnD,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the character is an ASCII letter (A-Z or a-z).
|
|
3
|
+
*/
|
|
4
|
+
export declare function isAlpha(ch: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Rotates a single letter by the given amount, preserving case.
|
|
7
|
+
* Non-alpha characters are returned unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rotateLetter(ch: string, rot: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Applies a Caesar rotation to every character in the text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function caesarRotate(text: string, rotation: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns all 26 Caesar rotations of the text.
|
|
16
|
+
*/
|
|
17
|
+
export declare function caesarRotations(text: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Encrypts text using the Vigenère cipher with the given key.
|
|
20
|
+
*/
|
|
21
|
+
export declare function vigenereEncrypt(text: string, key: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Decrypts text using the Vigenère cipher with the given key.
|
|
24
|
+
*/
|
|
25
|
+
export declare function vigenereDecrypt(text: string, key: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Encrypts text using the Autokey cipher with the given key.
|
|
28
|
+
*/
|
|
29
|
+
export declare function autokeyEncrypt(text: string, key: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Decrypts text using the Autokey cipher with the given key.
|
|
32
|
+
*/
|
|
33
|
+
export declare function autokeyDecrypt(text: string, key: string): string;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAlpha = isAlpha;
|
|
4
|
+
exports.rotateLetter = rotateLetter;
|
|
5
|
+
exports.caesarRotate = caesarRotate;
|
|
6
|
+
exports.caesarRotations = caesarRotations;
|
|
7
|
+
exports.vigenereEncrypt = vigenereEncrypt;
|
|
8
|
+
exports.vigenereDecrypt = vigenereDecrypt;
|
|
9
|
+
exports.autokeyEncrypt = autokeyEncrypt;
|
|
10
|
+
exports.autokeyDecrypt = autokeyDecrypt;
|
|
11
|
+
const characterConversion_1 = require("../Conversion/characterConversion");
|
|
12
|
+
const UPPER_A = 'A'.charCodeAt(0);
|
|
13
|
+
const UPPER_Z = 'Z'.charCodeAt(0);
|
|
14
|
+
const LOWER_A = 'a'.charCodeAt(0);
|
|
15
|
+
const LOWER_Z = 'z'.charCodeAt(0);
|
|
16
|
+
const ALPHA_LENGTH = 26;
|
|
17
|
+
function isUpperAlpha(code) {
|
|
18
|
+
return code >= UPPER_A && code <= UPPER_Z;
|
|
19
|
+
}
|
|
20
|
+
function isLowerAlpha(code) {
|
|
21
|
+
return code >= LOWER_A && code <= LOWER_Z;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the character is an ASCII letter (A-Z or a-z).
|
|
25
|
+
*/
|
|
26
|
+
function isAlpha(ch) {
|
|
27
|
+
const code = ch.charCodeAt(0);
|
|
28
|
+
return isUpperAlpha(code) || isLowerAlpha(code);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Rotates a single letter by the given amount, preserving case.
|
|
32
|
+
* Non-alpha characters are returned unchanged.
|
|
33
|
+
*/
|
|
34
|
+
function rotateLetter(ch, rot) {
|
|
35
|
+
if (ch.length !== 1) {
|
|
36
|
+
throw new Error('Expected a single character');
|
|
37
|
+
}
|
|
38
|
+
rot %= ALPHA_LENGTH;
|
|
39
|
+
if (rot < 0) {
|
|
40
|
+
rot += ALPHA_LENGTH;
|
|
41
|
+
}
|
|
42
|
+
const code = ch.charCodeAt(0);
|
|
43
|
+
let base = 0;
|
|
44
|
+
if (isLowerAlpha(code)) {
|
|
45
|
+
base = LOWER_A;
|
|
46
|
+
}
|
|
47
|
+
else if (isUpperAlpha(code)) {
|
|
48
|
+
base = UPPER_A;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return ch;
|
|
52
|
+
}
|
|
53
|
+
return String.fromCharCode(((code - base + rot) % ALPHA_LENGTH) + base);
|
|
54
|
+
}
|
|
55
|
+
function rotateLetterWithKey(ch, key, keyIndex, decrypt) {
|
|
56
|
+
if (key.length === 0) {
|
|
57
|
+
return ch;
|
|
58
|
+
}
|
|
59
|
+
const keyCh = key.charAt(keyIndex % key.length);
|
|
60
|
+
let rot = (0, characterConversion_1.toOrdinal)(keyCh) - 1;
|
|
61
|
+
if (decrypt) {
|
|
62
|
+
rot = -rot;
|
|
63
|
+
}
|
|
64
|
+
return rotateLetter(ch, rot);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Applies a Caesar rotation to every character in the text.
|
|
68
|
+
*/
|
|
69
|
+
function caesarRotate(text, rotation) {
|
|
70
|
+
const result = [];
|
|
71
|
+
for (const ch of text) {
|
|
72
|
+
result.push(rotateLetter(ch, rotation));
|
|
73
|
+
}
|
|
74
|
+
return result.join('');
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns all 26 Caesar rotations of the text.
|
|
78
|
+
*/
|
|
79
|
+
function caesarRotations(text) {
|
|
80
|
+
const rotations = [];
|
|
81
|
+
for (let i = 0; i < ALPHA_LENGTH; i++) {
|
|
82
|
+
rotations.push(caesarRotate(text, i));
|
|
83
|
+
}
|
|
84
|
+
return rotations;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Encrypts text using the Vigenère cipher with the given key.
|
|
88
|
+
*/
|
|
89
|
+
function vigenereEncrypt(text, key) {
|
|
90
|
+
const result = [];
|
|
91
|
+
let keyIndex = 0;
|
|
92
|
+
for (const ch of text) {
|
|
93
|
+
if (isAlpha(ch)) {
|
|
94
|
+
result.push(rotateLetterWithKey(ch, key, keyIndex++, false));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
result.push(ch);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result.join('');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decrypts text using the Vigenère cipher with the given key.
|
|
104
|
+
*/
|
|
105
|
+
function vigenereDecrypt(text, key) {
|
|
106
|
+
const result = [];
|
|
107
|
+
let keyIndex = 0;
|
|
108
|
+
for (const ch of text) {
|
|
109
|
+
if (isAlpha(ch)) {
|
|
110
|
+
result.push(rotateLetterWithKey(ch, key, keyIndex++, true));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
result.push(ch);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result.join('');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Encrypts text using the Autokey cipher with the given key.
|
|
120
|
+
*/
|
|
121
|
+
function autokeyEncrypt(text, key) {
|
|
122
|
+
if (key.length < 1) {
|
|
123
|
+
return text;
|
|
124
|
+
}
|
|
125
|
+
const result = [];
|
|
126
|
+
let keyIndex = 0;
|
|
127
|
+
let fullKey = key;
|
|
128
|
+
for (const ch of text) {
|
|
129
|
+
if (isAlpha(ch)) {
|
|
130
|
+
result.push(rotateLetterWithKey(ch, fullKey, keyIndex++, false));
|
|
131
|
+
fullKey += ch;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
result.push(ch);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result.join('');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Decrypts text using the Autokey cipher with the given key.
|
|
141
|
+
*/
|
|
142
|
+
function autokeyDecrypt(text, key) {
|
|
143
|
+
if (key.length < 1) {
|
|
144
|
+
return text;
|
|
145
|
+
}
|
|
146
|
+
const result = [];
|
|
147
|
+
let keyIndex = 0;
|
|
148
|
+
let fullKey = key;
|
|
149
|
+
for (const ch of text) {
|
|
150
|
+
if (isAlpha(ch)) {
|
|
151
|
+
const currentLetter = rotateLetterWithKey(ch, fullKey, keyIndex++, true);
|
|
152
|
+
result.push(currentLetter);
|
|
153
|
+
fullKey += currentLetter;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
result.push(ch);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return result.join('');
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=cipher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../../src/Cipher/cipher.ts"],"names":[],"mappings":";;AAmBA,0BAGC;AAMD,oCAqBC;AAyBD,oCAMC;AAKD,0CAMC;AAKD,0CAaC;AAKD,0CAaC;AAKD,wCAmBC;AAKD,wCAoBC;AAhLD,2EAA4D;AAE5D,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClC,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI,IAAI,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AAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;YAChB,MAAM,aAAa,GAAG,mBAAmB,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;YACzE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,IAAI,aAAa,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare enum CharacterEncoding {
|
|
2
2
|
None = 0,
|
|
3
|
-
Latin = 1,
|
|
4
|
-
Ordinal = 2,
|
|
5
|
-
FiveBitBinary = 3,
|
|
6
|
-
EightBitBinary = 4,
|
|
7
|
-
Ascii = 5,
|
|
3
|
+
Latin = 1,// A = A, B = B
|
|
4
|
+
Ordinal = 2,// A = 1, B = 2
|
|
5
|
+
FiveBitBinary = 3,// 00001 = A, 00010 = B
|
|
6
|
+
EightBitBinary = 4,// 01100001 = A, 01100010 = B
|
|
7
|
+
Ascii = 5,// 65 = A, 66 = B
|
|
8
8
|
Ternary = 6
|
|
9
9
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CharacterTableEntry } from './CharacterTableEntry';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the ASCII code for a single character (0-127), or -1 if out of range.
|
|
4
|
+
*/
|
|
5
|
+
export declare function toAscii(ch: string): number;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the ordinal value of a letter (A=1, Z=26), or -1 if not a letter.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toOrdinal(ch: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a table of ASCII characters with their representations in various bases.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getAsciiTable(): CharacterTableEntry[];
|
|
14
|
+
/**
|
|
15
|
+
* Returns a table of letters with their ordinal representations in various bases.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getOrdinalTable(): CharacterTableEntry[];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toAscii = toAscii;
|
|
4
|
+
exports.toOrdinal = toOrdinal;
|
|
5
|
+
exports.getAsciiTable = getAsciiTable;
|
|
6
|
+
exports.getOrdinalTable = getOrdinalTable;
|
|
7
|
+
const CharacterTableEntry_1 = require("./CharacterTableEntry");
|
|
8
|
+
function addAsciiRange(array, start, end, conversion, maxValue) {
|
|
9
|
+
for (let i = start; i <= end; i++) {
|
|
10
|
+
const letter = String.fromCharCode(i);
|
|
11
|
+
array.push(new CharacterTableEntry_1.CharacterTableEntry(letter, conversion(letter), maxValue));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the ASCII code for a single character (0-127), or -1 if out of range.
|
|
16
|
+
*/
|
|
17
|
+
function toAscii(ch) {
|
|
18
|
+
if (typeof ch !== 'string' || ch.length !== 1) {
|
|
19
|
+
throw new Error('A single character is required');
|
|
20
|
+
}
|
|
21
|
+
const ascii = ch.charCodeAt(0);
|
|
22
|
+
if (ascii >= 0 && ascii <= 127) {
|
|
23
|
+
return ascii;
|
|
24
|
+
}
|
|
25
|
+
return -1;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns the ordinal value of a letter (A=1, Z=26), or -1 if not a letter.
|
|
29
|
+
*/
|
|
30
|
+
function toOrdinal(ch) {
|
|
31
|
+
if (typeof ch !== 'string' || ch.length !== 1) {
|
|
32
|
+
throw new Error('A single character is required');
|
|
33
|
+
}
|
|
34
|
+
const chCode = ch.charCodeAt(0);
|
|
35
|
+
let ordinalCode = chCode - 'a'.charCodeAt(0);
|
|
36
|
+
if (ordinalCode >= 0 && ordinalCode < 26) {
|
|
37
|
+
return ordinalCode + 1;
|
|
38
|
+
}
|
|
39
|
+
ordinalCode = chCode - 'A'.charCodeAt(0);
|
|
40
|
+
if (ordinalCode >= 0 && ordinalCode < 26) {
|
|
41
|
+
return ordinalCode + 1;
|
|
42
|
+
}
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns a table of ASCII characters with their representations in various bases.
|
|
47
|
+
*/
|
|
48
|
+
function getAsciiTable() {
|
|
49
|
+
const retVal = [];
|
|
50
|
+
addAsciiRange(retVal, 48, 57, toAscii, 127);
|
|
51
|
+
addAsciiRange(retVal, 65, 90, toAscii, 127);
|
|
52
|
+
addAsciiRange(retVal, 97, 122, toAscii, 127);
|
|
53
|
+
return retVal;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns a table of letters with their ordinal representations in various bases.
|
|
57
|
+
*/
|
|
58
|
+
function getOrdinalTable() {
|
|
59
|
+
const retVal = [];
|
|
60
|
+
addAsciiRange(retVal, 65, 90, toOrdinal, 26);
|
|
61
|
+
return retVal;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=characterConversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterConversion.js","sourceRoot":"","sources":["../../../src/Conversion/characterConversion.ts"],"names":[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I,WAAW,GAAG,EAAE,EAAE,CAAC;QACzC,OAAO,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,WAAW,GAAG,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,WAAW,IAAI,CAAC,IAAI,WAAW,GAAG,EAAE,EAAE,CAAC;QACzC,OAAO,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CharacterEncoding } from './CharacterEncoding';
|
|
2
|
+
/**
|
|
3
|
+
* Determines the character encoding of a single input token.
|
|
4
|
+
*/
|
|
5
|
+
export declare function determineCharacterEncoding(input: string): CharacterEncoding;
|
|
6
|
+
/**
|
|
7
|
+
* Converts a single token to a character based on its encoding.
|
|
8
|
+
* Optionally forces a specific encoding.
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertCharacter(input: string, forcedCharacterEncoding?: CharacterEncoding): string;
|
|
11
|
+
/**
|
|
12
|
+
* Determines the most common encoding across all tokens in a string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function determineStringEncoding(input: string): CharacterEncoding;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a space-separated string by auto-detecting encoding.
|
|
17
|
+
* If homogeneous is true, all tokens use the same detected encoding.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertString(input: string, homogeneous: boolean): string;
|