Skip to content

Commit de116b3

Browse files
committed
lib: refine exports
Export selectively, only exposing what we actually want outside callers to use. We continue exposing some odd utilities for the time being (preSig, deSig primarily) but plan to eventually remove those.
1 parent fb88a4c commit de116b3

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
export * from './da';
2-
export * from './p';
3-
export * from './q';
4-
export * from './ud';
5-
export * from './uv';
6-
export * from './uw';
7-
export * from './ux';
1+
// main
2+
export * from './types';
3+
export { parse, slaw, slav, nuck } from './parse';
4+
export { render, scot, rend } from './render';
5+
6+
// atom utils
7+
export { daToUnix, unixToDa } from './da';
8+
export { cite, deSig, preSig } from './p'; //TODO remove deSig, preSig

src/parse.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ export const regex: { [key in aura]: RegExp } = {
4343
'ux': integerRegex('0x', '[1-9a-f]', '[0-9a-f]', 4),
4444
};
4545

46-
// parse(): slaw()
47-
// slaw(): parse string as specific aura, null if that fails
46+
// parse(): slav()
47+
// slav(): slaw() but throwing on failure
4848
//
49-
export const parse = slaw;
49+
export const parse = slav;
5050
export default parse;
51+
export function slav(aura: aura, str: string): bigint {
52+
const out = slaw(aura, str);
53+
if (!out) {
54+
throw new Error('slav: failed to parse @' + aura + ' from string: ' + str);
55+
}
56+
return out;
57+
}
58+
59+
// slaw(): parse string as specific aura, null if that fails
60+
//
5161
export function slaw(aura: aura, str: string): bigint | null {
5262
// if the aura has a regex, test with that first
5363
//TODO does double work with checks in nuck?
@@ -67,16 +77,6 @@ export function slaw(aura: aura, str: string): bigint | null {
6777
}
6878
}
6979

70-
// slav(): slaw() but throwing on failure
71-
//
72-
export function slav(aura: aura, str: string): bigint {
73-
const out = slaw(aura, str);
74-
if (!out) {
75-
throw new Error('slav: failed to parse @' + aura + ' from string: ' + str);
76-
}
77-
return out;
78-
}
79-
8080
// nuck(): parse string into coin, or null if that fails
8181
//
8282
export function nuck(str: string): coin | null {
@@ -209,7 +209,7 @@ export function nuck(str: string): coin | null {
209209

210210
// bisk(): parse string into dime of integer aura, or null if that fails
211211
//
212-
export function bisk(str: string): dime | null {
212+
function bisk(str: string): dime | null {
213213
switch (str.slice(0, 2)) {
214214
case '0b': // "bay"
215215
if (regex['ub'].test(str)) {

0 commit comments

Comments
 (0)