Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
34522ff
parse: begin stdlib-compliant parse refactor
Fang- Jun 2, 2025
d50fb46
tests: add `@n` and `@f` parsing tests
Fang- Jun 2, 2025
4ee5073
render: begin stdlib-compliant render refactor
Fang- Jun 2, 2025
b2e7b53
render: fix rendering zero `@uw`
Fang- Jun 2, 2025
7bae0a3
render: support text auras: tas, ta, t
Fang- Jun 2, 2025
b8a907c
parse: support escaped text in `@t`
Fang- Jun 5, 2025
4a4a480
render: fix `@da` rendering
Fang- Jun 6, 2025
a956bba
render: fix `@q` rendering
Fang- Jun 10, 2025
33e6962
render: support character aura: c
Fang- Jun 10, 2025
6478dd0
parse: improved da support
Fang- Jun 10, 2025
6022fa8
parse: support %blob and %many coins
Fang- Jun 13, 2025
42feb58
parse: refactor integer regexes
Fang- Jun 13, 2025
5219efb
render: fix signed atom rendering, add tests
Fang- Jun 13, 2025
1aadd88
parse: add signed atom tests
Fang- Jun 13, 2025
1e30add
tests: add fuzz tests
Fang- Jun 13, 2025
3d2cac0
parse: better utf-32 codepoint parsing support
Fang- Jun 13, 2025
c1187c0
parse: no bytes should give 0n bigint
Fang- Jun 13, 2025
679f435
render: support %blob coins
Fang- Jun 13, 2025
f0122b2
types: consolidate
Fang- Jun 13, 2025
b99b9f0
tests: consolidate static test atoms
Fang- Jun 13, 2025
d41c615
various: minor cleanup
Fang- Jun 13, 2025
0c58221
tests: additional parse failure tests
Fang- Jun 13, 2025
71ce7fa
parse: local uv/uw parsing implementation
Fang- Jun 13, 2025
e20bae9
parse: make q implementation pass tests
Fang- Sep 16, 2025
fb88a4c
various: remove unused files and utilities
Fang- Sep 17, 2025
c57e071
lib: refine exports
Fang- Sep 17, 2025
85fa061
parse: add tryParse alias for slaw
Fang- Oct 3, 2025
7e517f6
tests: fix imports
Fang- Oct 3, 2025
6692f25
parse: conform `@q` behavior to old tests
Fang- Oct 3, 2025
8ef8cc1
parse: add valid() syntax tester
Fang- Oct 3, 2025
e360468
parse: comment touch-ups
Fang- Oct 3, 2025
65364f9
tests: fuzz test portability (for ci)
Fang- Oct 3, 2025
0b596fd
ci: remove size-limit check
Fang- Oct 3, 2025
820888d
parse, render: support float auras, r*
Fang- Oct 12, 2025
6ed9422
parse, render: simplify p and q modules
Fang- Oct 17, 2025
084b9d5
lib: move code around, do renamings
Fang- Oct 17, 2025
88785ea
lib: remove jsverify dependency
Fang- Oct 17, 2025
6f26b87
lib: update export shape, readme
Fang- Oct 17, 2025
4837b43
parse: unify r-parsing counter
Fang- Oct 17, 2025
a642f98
tests: correct long `@q` rendering
Fang- Oct 17, 2025
61a4c06
tests: note about `@r` aura fuzzing
Fang- Oct 17, 2025
7b8eac8
lib: consistently note `@uc` as unsupported
Fang- Oct 17, 2025
b07fc48
parse: support `@if`, `@is`
Fang- Oct 19, 2025
77c4a12
render: support `@if`, `@is`
Fang- Oct 19, 2025
359d11c
tests: improve fuzz tests
Fang- Oct 20, 2025
a2d272c
parse: support `@dr`
Fang- Oct 25, 2025
f9c0acf
render: support `@dr`
Fang- Oct 25, 2025
c7a03a0
lib: add some `@dr` utilities
Fang- Oct 25, 2025
79bfaaf
lib: rename da.ts to d.ts
Fang- Oct 25, 2025
d1efc74
parse: support UIP-135 style dates
Fang- Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/size.yml

This file was deleted.

35 changes: 24 additions & 11 deletions src/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,20 @@ export function year(det: Dat) {
* @return {bigint} x The urbit date as bigint
*/
export function parseDa(x: string): bigint {
const [date, time, ms] = x.split('..');
const [yer, month, day] = date.slice(1).split('.');
let pos = true;
let [date, time, ms] = x.split('..');
time = time || '0.0.0';
ms = ms || '0000';
let [yer, month, day] = date.slice(1).split('.');
if (yer.at(-1) === '-') {
yer = yer.slice(0, -1);
pos = false;
}
const [hour, minute, sec] = time.split('.');
const millis = ms.split('.').map((m) => BigInt('0x'+m));

return year({
pos: true,
pos: pos,
year: BigInt(yer),
month: BigInt(month),
time: {
Expand All @@ -117,10 +124,12 @@ function yell(x: bigint): Tarp {
const milliMask = BigInt('0xffffffffffffffff');
const millis = milliMask & x;
const ms = millis
.toString(16)
.match(/.{1,4}/g)!
.filter((x) => x !== '0000')
.toString(16).padStart(16, '0')
.match(/.{4}/g)!
.map((x) => BigInt('0x'+x));
while (ms.at(-1) === 0n) {
ms.pop();
}
let day = sec / DAY_YO;
sec = sec % DAY_YO;
let hor = sec / HOR_YO;
Expand Down Expand Up @@ -203,11 +212,15 @@ export function formatDa(x: bigint | string) {
if (typeof x === 'string') {
x = BigInt(x);
}
const { year, month, time } = yore(x);

return `~${year}.${month}.${time.day}..${time.hour}.${time.minute}.${
time.second
}..${time.ms.map((x) => x.toString(16).padStart(4, '0')).join('.')}`;
const { pos, year, month, time } = yore(x);
let out = `~${year}${pos ? '' : '-'}.${month}.${time.day}`;
if (time.hour !== 0n || time.minute !== 0n || time.second !== 0n || time.ms.length !== 0) {
out = out + `..${time.hour.toString().padStart(2, '0')}.${time.minute.toString().padStart(2, '0')}.${time.second.toString().padStart(2, '0')}`
if (time.ms.length !== 0) {
out = out + `..${time.ms.map((x) => x.toString(16).padStart(4, '0')).join('.')}`;
}
}
return out;
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from './da';
export * from './p';
export * from './q';
export * from './ud';
export * from './uv';
export * from './uw';
export * from './ux';
// main
export * from './types';
export { parse, tryParse, valid, slav, slaw, nuck } from './parse';
export { render, scot, rend } from './render'; //TODO expose encodeString() ?

// atom utils
export { daToUnix, unixToDa } from './da';
export { cite, deSig, preSig } from './p'; //TODO remove deSig, preSig
3 changes: 3 additions & 0 deletions src/p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
} from './hoon';
import ob from './hoon/ob';

//NOTE the logic in this file has not yet been updated for the latest broader
// aura-js implementation style. but We Make It Work™.

/**
* Convert a hex-encoded string to a @p-encoded string.
*
Expand Down
Loading