@interstellar-tools/temporal 0.49.0 → 0.51.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.
@@ -1,5 +1,5 @@
1
1
  import { JULIAN_YEAR_SECONDS, SECONDS_PER_DAY } from '@interstellar-tools/constants';
2
- import { normalizeTemporalUnit } from './normalize-temporal-unit';
2
+ import { normalizeTemporalUnit } from './normalize-temporal-unit.js';
3
3
  /**
4
4
  * Seconds-per-unit lookup for all canonical {@link TemporalUnitType} symbols.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"convert-temporal-unit.js","sourceRoot":"","sources":["../src/convert-temporal-unit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAqC;IAC3D,yBAAyB;IACzB,CAAC,EAAE,CAAC;IACJ,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IAET,0BAA0B;IAC1B,GAAG,EAAE,EAAE;IACP,CAAC,EAAE,EAAE,GAAG,EAAE;IACV,CAAC,EAAE,eAAe;IAElB,kCAAkC;IAClC,EAAE,EAAE,mBAAmB;IACvB,GAAG,EAAE,mBAAmB,GAAG,GAAG;IAC9B,GAAG,EAAE,mBAAmB,GAAG,GAAG;IAC9B,GAAG,EAAE,mBAAmB,GAAG,GAAG;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAAuB,EAC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ACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAAuB,EACvB,UAA4B,EACT,EAAE;IACrB,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC/D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC7B,2BAA2B;IAC3B,MAAM,SAAS,GAAG,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,4BAA4B;IAC5B,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAErE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;AAC/D,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './convert-temporal-unit';
2
- export * from './normalize-temporal-unit';
1
+ export * from './convert-temporal-unit.js';
2
+ export * from './normalize-temporal-unit.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AAExC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAE3C,cAAc,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './convert-temporal-unit';
2
- export * from './normalize-temporal-unit';
1
+ export * from './convert-temporal-unit.js';
2
+ export * from './normalize-temporal-unit.js';
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AAExC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAE3C,cAAc,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interstellar-tools/temporal",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "description": "Time and epoch utilities for space applications (e.g., building blocks toward Julian dates, conversions, and ephemeris-friendly time handling).",
5
5
  "keywords": [
6
6
  "temporal",
@@ -111,8 +111,8 @@
111
111
  "test:ci": "glob-bin -c \"node --import tsx --test --no-warnings --experimental-test-coverage --test-reporter=cobertura --test-reporter-destination=coverage/cobertura-coverage.xml --test-reporter=spec --test-reporter-destination=stdout\" \"**/__tests__/**/*.spec.ts\""
112
112
  },
113
113
  "dependencies": {
114
- "@interstellar-tools/constants": "^0.5.0",
115
- "@interstellar-tools/types": "^0.5.0"
114
+ "@interstellar-tools/constants": "^0.51.0",
115
+ "@interstellar-tools/types": "^0.51.0"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@types/node": "^25.9.0",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=convert-temporal-unit.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-temporal-unit.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/convert-temporal-unit.spec.ts"],"names":[],"mappings":""}
@@ -1,93 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test, { describe } from 'node:test';
3
- import { convertTemporalUnit } from '../convert-temporal-unit';
4
- import { JULIAN_YEAR_SECONDS, SECONDS_PER_DAY } from '@interstellar-tools/constants';
5
- // Helpers
6
- const EPS_ABS = 1e-9;
7
- const EPS_REL = 1e-12;
8
- const approxEqual = (a, b, msg) => {
9
- const diff = Math.abs(a - b);
10
- const scale = Math.max(1, Math.abs(a), Math.abs(b));
11
- assert.ok(diff <= Math.max(EPS_ABS, EPS_REL * scale), msg ?? `expected ~${b}, got ${a}`);
12
- };
13
- const conv = (value, unit, target) => {
14
- return convertTemporalUnit({ value, unit }, target);
15
- };
16
- const CANONICAL = [
17
- 's',
18
- 'ms',
19
- 'μs',
20
- 'ns',
21
- 'ps',
22
- 'fs',
23
- 'as',
24
- 'zs',
25
- 'ys',
26
- 'min',
27
- 'h',
28
- 'd',
29
- 'yr',
30
- 'kyr',
31
- 'Myr',
32
- 'Gyr'
33
- ];
34
- const roundTo3 = (v) => Math.round(v * 1000) / 1000;
35
- describe('convert-temporal-unit', () => {
36
- test('identity: all canonical units map to themselves', () => {
37
- for (const u of CANONICAL) {
38
- const out = conv(123.456, u, u);
39
- assert.equal(out.unit, u);
40
- assert.equal(roundTo3(out.value), 123.456);
41
- }
42
- });
43
- test('SI submultiples: seconds ↔ ms/μs/ns', () => {
44
- assert.equal(conv(2, 's', 'ms').value, 2000);
45
- assert.equal(conv(2, 's', 'μs').value, 2000000);
46
- approxEqual(conv(2, 's', 'ns').value, 2000000000);
47
- approxEqual(conv(500, 'ms', 's').value, 0.5);
48
- approxEqual(conv(250000, 'μs', 's').value, 0.25);
49
- });
50
- test('minutes/hours/days basics', () => {
51
- assert.equal(conv(90, 'min', 'h').value, 1.5);
52
- assert.equal(conv(2, 'h', 'min').value, 120);
53
- assert.equal(conv(1, 'd', 'h').value, 24);
54
- assert.equal(conv(0.5, 'd', 's').value, SECONDS_PER_DAY / 2);
55
- });
56
- test('Julian year family: yr ↔ d, kyr/Myr/Gyr scaling', () => {
57
- // 1 yr = 365.25 d
58
- approxEqual(conv(1, 'yr', 'd').value, 365.25);
59
- approxEqual(conv(365.25, 'd', 'yr').value, 1);
60
- // Scaling
61
- assert.equal(conv(3, 'Myr', 'kyr').value, 3000);
62
- assert.equal(conv(2, 'Gyr', 'yr').value, 2000000000);
63
- // Seconds linkage
64
- approxEqual(conv(1, 'Myr', 's').value, JULIAN_YEAR_SECONDS * 1e6);
65
- approxEqual(conv(1e3, 'yr', 's').value, JULIAN_YEAR_SECONDS * 1e3);
66
- });
67
- test('extremes: yoctoseconds ↔ seconds round-trip', () => {
68
- const s = conv(1, 'ys', 's').value;
69
- approxEqual(s, 1e-24);
70
- const back = conv(s, 's', 'ys').value;
71
- approxEqual(back, 1);
72
- });
73
- test('round-trip property across units', () => {
74
- const pairs = [
75
- ['h', 's', 2.75],
76
- ['d', 'min', 0.125],
77
- ['yr', 'd', 3.5],
78
- ['kyr', 'yr', 1.234],
79
- ['Myr', 'kyr', 0.00042],
80
- ['Gyr', 'yr', 0.009]
81
- ];
82
- for (const [from, mid, val] of pairs) {
83
- const midVal = conv(val, from, mid).value;
84
- const back = conv(midVal, mid, from).value;
85
- approxEqual(back, val, `round-trip failed for ${from}↔${mid}`);
86
- }
87
- });
88
- test('unit labels in output are canonical', () => {
89
- const out = conv(42, 'h', 'min');
90
- assert.equal(out.unit, 'min');
91
- });
92
- });
93
- //# sourceMappingURL=convert-temporal-unit.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-temporal-unit.spec.js","sourceRoot":"","sources":["../../src/__tests__/convert-temporal-unit.spec.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,UAAU;AACV,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,GAAY,EAAE,EAAE;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC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,OAAO,CAAC;YACvB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;SACrB,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC;YAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC;YAC3C,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,yBAAyB,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=normalize-temporal-units.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-temporal-units.spec.d.ts","sourceRoot":"","sources":["../../src/__tests__/normalize-temporal-units.spec.ts"],"names":[],"mappings":""}
@@ -1,86 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import test, { describe } from 'node:test';
3
- import { normalizeTemporalUnit } from '../normalize-temporal-unit';
4
- const canonical = [
5
- 's',
6
- 'ms',
7
- 'μs',
8
- 'ns',
9
- 'ps',
10
- 'fs',
11
- 'as',
12
- 'zs',
13
- 'ys',
14
- 'min',
15
- 'h',
16
- 'd',
17
- 'yr',
18
- 'kyr',
19
- 'Myr',
20
- 'Gyr'
21
- ];
22
- const aliasPairs = [
23
- // seconds & submultiples
24
- ['second', 's'],
25
- ['seconds', 's'],
26
- ['millisecond', 'ms'],
27
- ['milliseconds', 'ms'],
28
- ['microsecond', 'μs'],
29
- ['microseconds', 'μs'],
30
- ['us', 'μs'],
31
- // clock units
32
- ['minute', 'min'],
33
- ['minutes', 'min'],
34
- ['hour', 'h'],
35
- ['hours', 'h'],
36
- ['day', 'd'],
37
- ['days', 'd'],
38
- // years & multiples (Julian-year-based)
39
- ['year', 'yr'],
40
- ['years', 'yr'],
41
- ['yr', 'yr'],
42
- ['yrs', 'yr'],
43
- ['kiloyear', 'kyr'],
44
- ['kiloyears', 'kyr'],
45
- ['kyr', 'kyr'],
46
- // million years (geology/astro spellings)
47
- ['megayear', 'Myr'],
48
- ['megayears', 'Myr'],
49
- ['megaannum', 'Myr'],
50
- ['megaannums', 'Myr'],
51
- ['Myr', 'Myr'],
52
- ['Ma', 'Myr'],
53
- // billion years
54
- ['gigayear', 'Gyr'],
55
- ['gigayears', 'Gyr'],
56
- ['gigaannum', 'Gyr'],
57
- ['gigaannums', 'Gyr'],
58
- ['Gyr', 'Gyr'],
59
- ['Ga', 'Gyr']
60
- ];
61
- describe('normalizeTemporalUnit', () => {
62
- test('canonical units map to themselves', () => {
63
- for (const u of canonical) {
64
- assert.equal(normalizeTemporalUnit(u), u, `expected '${u}' → '${u}'`);
65
- }
66
- });
67
- test('aliases map to canonical symbols', () => {
68
- for (const [input, expected] of aliasPairs) {
69
- assert.equal(normalizeTemporalUnit(input), expected, `expected '${input}' → '${expected}'`);
70
- }
71
- });
72
- test('trims surrounding whitespace', () => {
73
- assert.equal(normalizeTemporalUnit(' seconds '), 's');
74
- assert.equal(normalizeTemporalUnit('\tus\n'), 'μs');
75
- });
76
- test('case-sensitive matching', () => {
77
- assert.throws(() => normalizeTemporalUnit('Seconds'), /Unsupported unit: Seconds/, 'capitalized alias should be rejected');
78
- assert.throws(() => normalizeTemporalUnit('US'), /Unsupported unit: US/, 'uppercase "US" should not be treated as microseconds');
79
- });
80
- test('rejects unknown or empty inputs', () => {
81
- assert.throws(() => normalizeTemporalUnit(''), /Unsupported unit:/);
82
- assert.throws(() => normalizeTemporalUnit(' '), /Unsupported unit:\s+/);
83
- assert.throws(() => normalizeTemporalUnit('lightyear'), /Unsupported unit:/);
84
- });
85
- });
86
- //# sourceMappingURL=normalize-temporal-units.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-temporal-units.spec.js","sourceRoot":"","sources":["../../src/__tests__/normalize-temporal-units.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,SAAS,GAAG;IAChB,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,GAAG;IACH,GAAG;IACH,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC;AAEF,MAAM,UAAU,GAAG;IACjB,yBAAyB;IACzB,CAAC,QAAQ,EAAE,GAAG,CAAC;IACf,CAAC,SAAS,EAAE,GAAG,CAAC;IAChB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,IAAI,EAAE,IAAI,CAAC;IAEZ,cAAc;IACd,CAAC,QAAQ,EAAE,KAAK,CAAC;IACjB,CAAC,SAAS,EAAE,KAAK,CAAC;IAClB,CAAC,MAAM,EAAE,GAAG,CAAC;IACb,CAAC,OAAO,EAAE,GAAG,CAAC;IACd,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,MAAM,EAAE,GAAG,CAAC;IAEb,wCAAwC;IACxC,CAAC,MAAM,EA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