@lp-labs/tap-code 0.0.0-stage → 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Libin Prasanth
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,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # @lp-labs/tap-code
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Five-by-five tap coordinate text with documented C/K conflation.
4
+
5
+ Original, standalone MIT TypeScript implementation with **zero runtime or peer dependencies**. ESM/CommonJS exports and separate declarations; Node18+ and compatible ES2022 browsers. No service, filesystem, network, clock or browser globals accessed on import. Compiler/formatter dependencies are development-only.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @lp-labs/tap-code
11
+ ```
12
+
13
+ ## Working example
14
+
15
+ ```js
16
+ import { encodeTap, decodeTap } from '@lp-labs/tap-code';
17
+ if (decodeTap(encodeTap('CODE')) !== 'CODE') throw new Error('Tap');
18
+ ```
19
+
20
+ CommonJS: `const api = require('@lp-labs/tap-code')`.
21
+
22
+ ## Behavior, customization and limits
23
+
24
+ encodeTap accepts0..16384 uppercase ASCII letters,no spaces; K maps to C. Square rows ABCDE,FGHIJ,LMNOP,QRSTU,VWXYZ. Output two digits1..5 per letter,separated by a single space. decodeTap accepts exactly that canonical grammar<=49151 chars and produces uppercase text; empty allowed. Educational notation,not secret communication security. O(n)time/storage; K cannot be recovered.
25
+
26
+ Use the explicit function arguments and public types below to customize the documented behavior. There are no hidden environment settings or sibling-library requirements. Array inputs must be dense; sparse entries are invalid. Inputs are validated before a successful result is returned. Outputs do not mutate caller-owned inputs. Hostile proxies/getters and concurrent mutation are outside the contract.
27
+
28
+ ## Errors and integration
29
+
30
+ Invalid data never produces an empty success-shaped substitute. TypeError reports incompatible runtime types/nonfinite numbers; RangeError reports unsupported ranges, invalid syntax, inconsistent states and exceeded budgets. Functions that explicitly return null, false or empty arrays describe those legitimate outcomes above. Errors propagate to callers; UI applications should catch at their boundary and visibly notify users. Numerical calculations use JavaScript IEEE754 unless the API explicitly uses bigint; compare approximate numerical results with application-appropriate tolerances.
31
+
32
+ ## Complete public API
33
+
34
+ ```ts
35
+ export declare function encodeTap(text: string): string;
36
+ export declare function decodeTap(text: string): string;
37
+ ```
38
+
39
+ ## Performance and portability
40
+
41
+ Complexity and resource ceilings are specified above. Buffered synchronous algorithms do not create workers or timers; callers can move expensive work to their own worker. Limits are enforced, not silently truncated. No runtime imports from any other library. No compatibility or completeness claims beyond the stated scope.
42
+
43
+ ## Support
44
+
45
+ If this library is useful to you, consider supporting its maintenance with a [donation via PayPal](https://www.paypal.me/LibinPrasanth).
46
+
47
+ ## Author
48
+
49
+ Created by [Libin Prasanth](https://www.linkedin.com/in/libinprasanth/). Connect on LinkedIn for updates and discussion.
@@ -0,0 +1,2 @@
1
+ export declare function encodeTap(text: string): string;
2
+ export declare function decodeTap(text: string): string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeTap = encodeTap;
4
+ exports.decodeTap = decodeTap;
5
+ function strictText(value, max = 16384) {
6
+ if (typeof value !== 'string')
7
+ throw new TypeError('Expected string');
8
+ if (value.length > max)
9
+ throw new RangeError('Text length budget exceeded');
10
+ }
11
+ function letters(text) {
12
+ strictText(text);
13
+ if (!/^[A-Z]*$/.test(text))
14
+ throw new RangeError('Uppercase ASCII letters required');
15
+ }
16
+ const square = 'ABCDEFGHIJLMNOPQRSTUVWXYZ';
17
+ function encodeTap(text) {
18
+ letters(text);
19
+ return Array.from(text, (c) => {
20
+ const i = square.indexOf(c === 'K' ? 'C' : c);
21
+ return String(Math.floor(i / 5) + 1) + String((i % 5) + 1);
22
+ }).join(' ');
23
+ }
24
+ function decodeTap(text) {
25
+ strictText(text, 49151);
26
+ if (!text)
27
+ return '';
28
+ if (!/^[1-5]{2}(?: [1-5]{2})*$/.test(text))
29
+ throw new RangeError('Canonical tap pairs required');
30
+ return text
31
+ .split(' ')
32
+ .map((t) => square[(Number(t[0]) - 1) * 5 + Number(t[1]) - 1])
33
+ .join('');
34
+ }
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,2 @@
1
+ export declare function encodeTap(text: string): string;
2
+ export declare function decodeTap(text: string): string;
@@ -0,0 +1,30 @@
1
+ function strictText(value, max = 16384) {
2
+ if (typeof value !== 'string')
3
+ throw new TypeError('Expected string');
4
+ if (value.length > max)
5
+ throw new RangeError('Text length budget exceeded');
6
+ }
7
+ function letters(text) {
8
+ strictText(text);
9
+ if (!/^[A-Z]*$/.test(text))
10
+ throw new RangeError('Uppercase ASCII letters required');
11
+ }
12
+ const square = 'ABCDEFGHIJLMNOPQRSTUVWXYZ';
13
+ export function encodeTap(text) {
14
+ letters(text);
15
+ return Array.from(text, (c) => {
16
+ const i = square.indexOf(c === 'K' ? 'C' : c);
17
+ return String(Math.floor(i / 5) + 1) + String((i % 5) + 1);
18
+ }).join(' ');
19
+ }
20
+ export function decodeTap(text) {
21
+ strictText(text, 49151);
22
+ if (!text)
23
+ return '';
24
+ if (!/^[1-5]{2}(?: [1-5]{2})*$/.test(text))
25
+ throw new RangeError('Canonical tap pairs required');
26
+ return text
27
+ .split(' ')
28
+ .map((t) => square[(Number(t[0]) - 1) * 5 + Number(t[1]) - 1])
29
+ .join('');
30
+ }
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@lp-labs/tap-code",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Five-by-five tap coordinate text with documented C/K conflation.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/cjs/index.js",
8
+ "module": "./dist/esm/index.js",
9
+ "types": "./dist/esm/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/esm/index.d.ts",
14
+ "default": "./dist/esm/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/cjs/index.d.ts",
18
+ "default": "./dist/cjs/index.js"
19
+ }
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "sideEffects": false,
29
+ "engines": {
30
+ "node": ">=18"
31
+ },
32
+ "scripts": {
33
+ "build": "node scripts/build.mjs",
34
+ "typecheck": "npm run build && node scripts/check-types.mjs",
35
+ "test": "npm run build && node --test tests/*.test.mjs",
36
+ "format": "prettier --write src scripts tests *.json README.md",
37
+ "format:check": "prettier --check src scripts tests *.json README.md",
38
+ "prepack": "npm run build"
39
+ },
40
+ "devDependencies": {
41
+ "typescript": "^5.9.3",
42
+ "prettier": "^3.6.2"
43
+ },
44
+ "prettier": {
45
+ "singleQuote": true,
46
+ "semi": true,
47
+ "trailingComma": "all",
48
+ "printWidth": 100,
49
+ "endOfLine": "lf"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "author": {
56
+ "name": "Libin Prasanth",
57
+ "url": "https://www.linkedin.com/in/libinprasanth/"
58
+ },
59
+ "funding": {
60
+ "type": "paypal",
61
+ "url": "https://www.paypal.me/LibinPrasanth"
62
+ }
63
+ }