@jarenjs/core 0.9.2 → 0.34.2

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.
Files changed (121) hide show
  1. package/ARCHITECTURE.md +229 -26
  2. package/README.md +64 -10
  3. package/dist/types/array.d.ts +13 -0
  4. package/dist/types/cache.d.ts +166 -0
  5. package/dist/types/chunk.d.ts +102 -0
  6. package/dist/types/color.d.ts +64 -0
  7. package/dist/types/convert/convert.d.ts +33 -0
  8. package/dist/types/convert/currency.d.ts +47 -0
  9. package/dist/types/convert/index.d.ts +9 -0
  10. package/dist/types/convert/registry.d.ts +55 -0
  11. package/dist/types/dates/civil.d.ts +146 -0
  12. package/dist/types/dates/duration.d.ts +83 -0
  13. package/dist/types/dates/format.d.ts +59 -0
  14. package/dist/types/dates/index.d.ts +4 -0
  15. package/dist/types/{dates.d.ts → dates/rfc3339.d.ts} +57 -3
  16. package/dist/types/errors.d.ts +77 -0
  17. package/dist/types/finance/amortization.d.ts +51 -0
  18. package/dist/types/finance/bond.d.ts +45 -0
  19. package/dist/types/finance/cashflow.d.ts +44 -0
  20. package/dist/types/finance/depreciation.d.ts +26 -0
  21. package/dist/types/finance/index.d.ts +16 -0
  22. package/dist/types/finance/indicators.d.ts +76 -0
  23. package/dist/types/finance/interest.d.ts +44 -0
  24. package/dist/types/finance/returns.d.ts +43 -0
  25. package/dist/types/finance/tvm.d.ts +50 -0
  26. package/dist/types/geo/angle.d.ts +4 -0
  27. package/dist/types/geo/bbox.d.ts +32 -0
  28. package/dist/types/geo/distance.d.ts +67 -0
  29. package/dist/types/geo/geohash.d.ts +63 -0
  30. package/dist/types/geo/geojson.d.ts +108 -0
  31. package/dist/types/geo/index-tree.d.ts +52 -0
  32. package/dist/types/geo/index.d.ts +11 -0
  33. package/dist/types/geo/mercator.d.ts +57 -0
  34. package/dist/types/geo/predicates.d.ts +44 -0
  35. package/dist/types/geo/ring.d.ts +80 -0
  36. package/dist/types/geo/simplify.d.ts +31 -0
  37. package/dist/types/geo/valid.d.ts +24 -0
  38. package/dist/types/geo/wkt.d.ts +16 -0
  39. package/dist/types/math/float64.d.ts +126 -3
  40. package/dist/types/math/format.d.ts +58 -0
  41. package/dist/types/math/index.d.ts +5 -0
  42. package/dist/types/math/mat4.d.ts +60 -0
  43. package/dist/types/math/project.d.ts +54 -0
  44. package/dist/types/math/solve.d.ts +67 -0
  45. package/dist/types/math/word.d.ts +82 -0
  46. package/dist/types/message.d.ts +52 -0
  47. package/dist/types/object.d.ts +151 -0
  48. package/dist/types/scan.d.ts +30 -0
  49. package/dist/types/schema.d.ts +24 -0
  50. package/dist/types/string.d.ts +96 -0
  51. package/dist/types/text/base64.d.ts +6 -4
  52. package/dist/types/text/email.d.ts +0 -1
  53. package/dist/types/text/host.d.ts +39 -8
  54. package/dist/types/text/i18n.d.ts +13 -1
  55. package/dist/types/text/index.d.ts +1 -0
  56. package/dist/types/text/misc.d.ts +15 -1
  57. package/dist/types/text/punycode.d.ts +45 -85
  58. package/docs/CONVERT.md +45 -0
  59. package/docs/DATES.md +78 -0
  60. package/docs/FINANCE.md +59 -0
  61. package/docs/GEO.md +114 -0
  62. package/docs/MATH.md +75 -0
  63. package/package.json +57 -4
  64. package/src/array.js +16 -0
  65. package/src/cache.js +206 -0
  66. package/src/chunk.js +159 -0
  67. package/src/color.js +125 -0
  68. package/src/convert/convert.js +59 -0
  69. package/src/convert/currency.js +74 -0
  70. package/src/convert/index.js +11 -0
  71. package/src/convert/registry.js +213 -0
  72. package/src/dates/civil.js +360 -0
  73. package/src/dates/duration.js +225 -0
  74. package/src/dates/format.js +238 -0
  75. package/src/dates/index.js +30 -0
  76. package/src/dates/rfc3339.js +621 -0
  77. package/src/errors.js +102 -0
  78. package/src/finance/amortization.js +50 -0
  79. package/src/finance/bond.js +100 -0
  80. package/src/finance/cashflow.js +122 -0
  81. package/src/finance/depreciation.js +54 -0
  82. package/src/finance/index.js +27 -0
  83. package/src/finance/indicators.js +207 -0
  84. package/src/finance/interest.js +63 -0
  85. package/src/finance/returns.js +90 -0
  86. package/src/finance/tvm.js +94 -0
  87. package/src/function.js +0 -2
  88. package/src/geo/angle.js +12 -0
  89. package/src/geo/bbox.js +80 -0
  90. package/src/geo/distance.js +155 -0
  91. package/src/geo/geohash.js +224 -0
  92. package/src/geo/geojson.js +361 -0
  93. package/src/geo/index-tree.js +294 -0
  94. package/src/geo/index.js +52 -0
  95. package/src/geo/mercator.js +124 -0
  96. package/src/geo/predicates.js +313 -0
  97. package/src/geo/ring.js +182 -0
  98. package/src/geo/simplify.js +130 -0
  99. package/src/geo/valid.js +142 -0
  100. package/src/geo/wkt.js +262 -0
  101. package/src/math/float64.js +228 -11
  102. package/src/math/format.js +157 -0
  103. package/src/math/index.js +5 -0
  104. package/src/math/mat4.js +131 -0
  105. package/src/math/project.js +49 -0
  106. package/src/math/solve.js +112 -0
  107. package/src/math/word.js +177 -0
  108. package/src/message.js +119 -0
  109. package/src/object.js +329 -0
  110. package/src/scan.js +42 -0
  111. package/src/schema.js +37 -0
  112. package/src/string.js +189 -0
  113. package/src/text/base64.js +15 -52
  114. package/src/text/email.js +0 -5
  115. package/src/text/host.js +515 -140
  116. package/src/text/i18n.js +13 -6
  117. package/src/text/identifiers.js +1 -1
  118. package/src/text/index.js +1 -0
  119. package/src/text/misc.js +81 -5
  120. package/src/text/punycode.js +235 -323
  121. package/src/dates.js +0 -371
@@ -24,12 +24,163 @@ export declare function equalsDeep(target: any, source: any): boolean;
24
24
  * @returns {boolean}
25
25
  */
26
26
  export declare function equalsJson(a: any, b: any): boolean;
27
+ /**
28
+ * Ordering of two JSON values per RFC 9535 section 2.3.5.2.2 — the
29
+ * ordering half of the comparison family whose equality half is
30
+ * `equalsJson`.
31
+ *
32
+ * Only two numbers or two strings order at all: numbers by value,
33
+ * strings by Unicode scalar values (`compareCodePoints`, not the native
34
+ * `<`). Every other pair — mismatched types, objects, arrays, booleans,
35
+ * null — is simply `false` in both directions, never an error.
36
+ *
37
+ * @param {any} a
38
+ * @param {any} b
39
+ * @param {boolean} [orEqual] when true test `<=` instead of `<`
40
+ * @returns {boolean}
41
+ */
42
+ export declare function compareJsonScalarLt(a: any, b: any, orEqual?: boolean): boolean;
27
43
  /**
28
44
  * Check if all items in an array are unique using deep equality
29
45
  * @param {any[]} arr - The array to check
30
46
  * @returns {boolean} True if all items are unique
31
47
  */
32
48
  export declare function isUniqueDeepArray(arr: any[]): boolean;
49
+ /**
50
+ * Deterministic JSON text for plain data: like `JSON.stringify`, but
51
+ * object keys are emitted in sorted order at every depth, so two
52
+ * structurally equal values always produce the same string (a stable
53
+ * cache/memo/fingerprint key regardless of key insertion order).
54
+ * Non-JSON values follow `JSON.stringify` semantics (undefined members
55
+ * are dropped, undefined roots return undefined).
56
+ *
57
+ * That leniency is what makes it a memo key and not an interchange
58
+ * format: dropping a member changes the document. For output that is
59
+ * hashed or signed, use `canonicalizeJson` (`@jarenjs/json/canonical`,
60
+ * RFC 8785), which rejects every non-JSON input instead of coercing it.
61
+ * @param {*} value - The value to serialize
62
+ * @returns {string|undefined} Deterministic JSON text
63
+ */
64
+ export declare function stableStringify(value: any): string | undefined;
65
+ /**
66
+ * The suite's one MEMO-GRADE content key: `hashContent(stableStringify
67
+ * (value) ?? '')`. Two structurally equal plain-JSON values produce the
68
+ * same key regardless of property insertion order — which is exactly
69
+ * what a reconciliation key wants and exactly what `JSON.stringify`-based
70
+ * keys get wrong.
71
+ *
72
+ * **This is a 32-bit FINGERPRINT, never an identity.** Distinct values
73
+ * DO share a key — the birthday bound puts the first collision around
74
+ * 65k documents, and one turns up after ~113k trivially different query
75
+ * documents in practice. So it is sound for a vnode `key`, a DOM id, a
76
+ * bucket index or a diagnostic label, and WRONG as the sole identity of
77
+ * anything whose reuse changes a result: a compiled query, a query plan,
78
+ * a registered SQL function body, a memoized render. For those use
79
+ * {@link semanticKey}, which compares the whole serialization.
80
+ *
81
+ * Two further properties a caller must know, inherited from
82
+ * `stableStringify`: **`undefined` members are dropped** (two values
83
+ * differing only in an `undefined` member share a key) and there is
84
+ * **no cycle guard** (a cyclic value overflows the stack). Both are fine
85
+ * for a fingerprint and wrong for a checksum — for anything hashed,
86
+ * signed or recorded, use `canonicalizeJson`
87
+ * (`@jarenjs/json/canonical`, RFC 8785) instead. Do not conflate the
88
+ * three.
89
+ * @param {*} value - The value to derive a fingerprint for
90
+ * @returns {string} base-36 content hash of the stable serialization
91
+ */
92
+ export declare function contentKey(value: any): string;
93
+ /**
94
+ * The suite's one COLLISION-FREE semantic key: the COMPLETE
95
+ * deterministic serialization of a plain-data value. Two values share a
96
+ * key exactly when they are structurally equal, so a cache keyed by it
97
+ * can never serve one document's compiled semantics for another —
98
+ * which a hash-only key inevitably does (see {@link contentKey}).
99
+ *
100
+ * Use it wherever reuse changes a RESULT: compiled queries, query
101
+ * plans, load specifications, safe profiles, registered SQL function
102
+ * bodies, memoized renders. The key is longer than a fingerprint; for a
103
+ * bounded cache of a few hundred entries that cost is a few kilobytes
104
+ * and the alternative is wrong data.
105
+ *
106
+ * Injective over plain data, and STRICT about the rest: it distinguishes
107
+ * `-0` from `0`, `NaN`/`±Infinity` from `null` and from each other, and
108
+ * a present-but-`undefined` member from an absent one — every case
109
+ * `stableStringify` silently folds together. Values that cannot be
110
+ * keyed injectively are REFUSED with a `TypeError` rather than folded:
111
+ * functions, symbols, cycles, and non-plain objects (a `Date`, `Map`,
112
+ * `RegExp` or class instance, all of which serialize to `{}`), plus the
113
+ * two members a serialization cannot show — a symbol key, and an own
114
+ * array property past the last element. A caller that may hold such a
115
+ * value must treat the refusal as "not cacheable" and compute afresh —
116
+ * never as "reuse whatever shares the key".
117
+ *
118
+ * The identity covers OWN ENUMERABLE string-keyed properties, the same
119
+ * surface JSON reads. Two values differing only in a non-enumerable
120
+ * member are one value to this key, as they are to `JSON.stringify`.
121
+ * @param {*} value - The value to derive an identity for
122
+ * @returns {string} the complete deterministic serialization
123
+ * @throws {TypeError} When the value cannot be keyed injectively
124
+ */
125
+ export declare function semanticKey(value: any): string;
126
+ /**
127
+ * True for a JSON object — a non-null object that is not an array.
128
+ *
129
+ * This is the JSON data-model predicate, deliberately distinct from
130
+ * `isObjectType`: it treats `Map`, `Set`, `Date` and every other class
131
+ * instance as an object too, because at the JSON layer such a value has
132
+ * already been rejected or serialized before it gets here, and the only
133
+ * distinction that matters is object-vs-array.
134
+ *
135
+ * @param {any} value
136
+ * @returns {boolean}
137
+ */
138
+ export declare function isJsonObject(value: any): boolean;
139
+ /**
140
+ * Assign a member so that a key named `__proto__` becomes an own data
141
+ * property instead of reassigning the object's prototype. Every builder
142
+ * that turns untrusted names into members must go through this — a plain
143
+ * `out[name] = value` is a prototype-pollution hole for that one name.
144
+ *
145
+ * @param {Object} out target object
146
+ * @param {string} name member name, possibly attacker-controlled
147
+ * @param {any} value
148
+ */
149
+ export declare function setObjectMember(out: Object, name: string, value: any): void;
150
+ /**
151
+ * Whether a value can hold JSON members: an object or an array, not null.
152
+ * The complement of a JSON scalar.
153
+ * @param {any} value
154
+ * @returns {boolean}
155
+ */
156
+ export declare function isJsonContainer(value: any): boolean;
157
+ /**
158
+ * Copy one JSON container one level deep, preserving member order. Object
159
+ * spread copies an own `__proto__` data property as an own property
160
+ * (CreateDataProperty semantics), so this is pollution-safe.
161
+ * @template T
162
+ * @param {T} value - The container to copy
163
+ * @returns {T} A shallow copy; scalars are returned unchanged
164
+ */
165
+ export declare function shallowCloneJson<T>(value: T): T;
166
+ /**
167
+ * Deep-copy a JSON value. Scalars are returned as-is; containers are
168
+ * rebuilt so no part of the result is shared with the input.
169
+ * @template T
170
+ * @param {T} value - The JSON value to copy
171
+ * @returns {T} A deep copy sharing no container with the input
172
+ */
173
+ export declare function cloneJson<T>(value: T): T;
174
+ /**
175
+ * Recursively `Object.freeze` a value and everything reachable from it,
176
+ * returning the value. Scalars pass through untouched. Assumes an acyclic
177
+ * structure (a JSON value); a cycle would recurse forever.
178
+ *
179
+ * @template T
180
+ * @param {T} value
181
+ * @returns {T} the same value, deeply frozen
182
+ */
183
+ export declare function deepFreeze<T>(value: T): T;
33
184
  /**
34
185
  *
35
186
  * @param {Map<any, any>} map
@@ -12,6 +12,7 @@ export declare const CC_SQUOTE = 39;
12
12
  export declare const CC_LPAREN = 40;
13
13
  export declare const CC_RPAREN = 41;
14
14
  export declare const CC_STAR = 42;
15
+ export declare const CC_PLUS = 43;
15
16
  export declare const CC_COMMA = 44;
16
17
  export declare const CC_MINUS = 45;
17
18
  export declare const CC_DOT = 46;
@@ -29,8 +30,14 @@ export declare const CC_LBRACKET = 91;
29
30
  export declare const CC_BACKSLASH = 92;
30
31
  export declare const CC_RBRACKET = 93;
31
32
  export declare const CC_UNDERSCORE = 95;
33
+ export declare const CC_LOWER_B = 98;
34
+ export declare const CC_LOWER_O = 111;
35
+ export declare const CC_LOWER_X = 120;
36
+ export declare const CC_LBRACE = 123;
32
37
  export declare const CC_PIPE = 124;
38
+ export declare const CC_RBRACE = 125;
33
39
  export declare const CC_TILDE = 126;
40
+ export declare const CC_DEL = 127;
34
41
  /**
35
42
  * Checks if a char code is an ASCII digit (0-9).
36
43
  * @param {number} c - The char code
@@ -43,6 +50,23 @@ export declare function isDigitCode(c: number): boolean;
43
50
  * @returns {boolean}
44
51
  */
45
52
  export declare function isHexDigitCode(c: number): boolean;
53
+ /**
54
+ * Checks if a char code may start an unquoted name: an ASCII letter,
55
+ * `_`, or any non-ASCII code unit. Non-ASCII is admitted wholesale rather
56
+ * than by Unicode category, which is what the RFC 9535 shorthand member
57
+ * name and the XML Name productions both settle for in practice.
58
+ * @param {number} c - The char code
59
+ * @returns {boolean}
60
+ */
61
+ export declare function isNameStartCode(c: number): boolean;
62
+ /**
63
+ * Checks if a char code may continue an unquoted name: a name start or an
64
+ * ASCII digit. Grammars that also admit `-`/`.` inside names (XML Name,
65
+ * for one) test those separately on top of this.
66
+ * @param {number} c - The char code
67
+ * @returns {boolean}
68
+ */
69
+ export declare function isNameCharCode(c: number): boolean;
46
70
  /**
47
71
  * Checks if a char code is blank space per RFC 9535 (space, tab,
48
72
  * line feed or carriage return).
@@ -62,3 +86,9 @@ export declare function isAsciiLowerCode(c: number): boolean;
62
86
  * @returns {boolean}
63
87
  */
64
88
  export declare function isAsciiUpperCode(c: number): boolean;
89
+ /**
90
+ * Checks if a char code is an ASCII letter (A-Z or a-z).
91
+ * @param {number} c - The char code
92
+ * @returns {boolean}
93
+ */
94
+ export declare function isAsciiLetterCode(c: number): boolean;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file The JSON Schema constraint-keyword vocabulary, grouped by the
3
+ * value family each keyword constrains. Before this file the same
4
+ * keyword lists were spelled four times (forms' constraint extraction,
5
+ * emit's dropped-constraint table, the validator's `$data` dispatch
6
+ * order and its `$ref`-sibling detection) — and a keyword added to one
7
+ * list silently missed the others. Each site composes the list it wants
8
+ * from these groups and appends its own extras; the loops stay where
9
+ * they are, because the drift risk was always in the data, not the
10
+ * code.
11
+ *
12
+ * ORDER IS PART OF THE CONTRACT: the validator's `$data` dispatch
13
+ * applies keywords in list order and its error order is observable
14
+ * behaviour, so the internal order of each group is fixed. Membership
15
+ * consumers are order-insensitive by construction.
16
+ */
17
+ /** Keywords constraining numeric values, in dispatch order. */
18
+ export declare const NUMERIC_CONSTRAINTS: readonly string[];
19
+ /** Keywords constraining string values, in dispatch order. */
20
+ export declare const STRING_CONSTRAINTS: readonly string[];
21
+ /** Keywords constraining array values, in dispatch order. */
22
+ export declare const ARRAY_CONSTRAINTS: readonly string[];
23
+ /** Keywords constraining object values, in dispatch order. */
24
+ export declare const OBJECT_CONSTRAINTS: readonly string[];
@@ -45,6 +45,15 @@ export declare function isAsciiString(str: string): boolean;
45
45
  * @returns {number}
46
46
  */
47
47
  export declare function getStringLength(str: string, useGrapheme?: boolean): number;
48
+ /**
49
+ * Count occurrences of a UTF-16 code unit in a slice of a string.
50
+ * @param {string} str - The string to scan
51
+ * @param {number} code - The char code to count
52
+ * @param {number} [start] - Inclusive start offset (defaults to 0)
53
+ * @param {number} [end] - Exclusive end offset (defaults to full length)
54
+ * @returns {number} Number of occurrences in [start, end)
55
+ */
56
+ export declare function countCharCode(str: string, code: number, start?: number, end?: number): number;
48
57
  /**
49
58
  * Count the Unicode code points of a string (surrogate-pair aware;
50
59
  * a lone surrogate counts as one code point).
@@ -52,6 +61,28 @@ export declare function getStringLength(str: string, useGrapheme?: boolean): num
52
61
  * @returns {number}
53
62
  */
54
63
  export declare function countCodePoints(str: string): number;
64
+ /**
65
+ * Decode a string into its Unicode code points (surrogate-pair aware).
66
+ *
67
+ * `Array.from(str).map(c => c.codePointAt(0))` computes the same thing
68
+ * but allocates a string per character on the way; this reads the code
69
+ * units directly. An unpaired surrogate is kept as its own code point
70
+ * rather than replaced, so the result round-trips through
71
+ * {@link fromCodePoints} and a caller validating text can see the lone
72
+ * surrogate and reject it.
73
+ *
74
+ * @param {string} str - The string to decode
75
+ * @returns {number[]} The code points, in order
76
+ */
77
+ export declare function toCodePoints(str: string): number[];
78
+ /**
79
+ * Build a string from Unicode code points - the inverse of
80
+ * {@link toCodePoints}.
81
+ *
82
+ * @param {number[]} codePoints - The code points to encode
83
+ * @returns {string} The resulting string
84
+ */
85
+ export declare function fromCodePoints(codePoints: number[]): string;
55
86
  /**
56
87
  * Compare two strings by Unicode scalar values (code points), per
57
88
  * RFC 9535 section 2.3.5.2.2. This differs from JavaScript's native
@@ -63,3 +94,68 @@ export declare function countCodePoints(str: string): number;
63
94
  * @returns {number} -1 when a < b, 0 when equal, 1 when a > b
64
95
  */
65
96
  export declare function compareCodePoints(a: string, b: string): number;
97
+ /** FNV-1a 32-bit offset basis — the seed a fresh hash starts from. */
98
+ export declare const FNV1A_OFFSET_BASIS = 2166136261;
99
+ /**
100
+ * FNV-1a 32-bit hash of a string, as an unsigned 32-bit number. Not
101
+ * cryptographic — a stable, fast content fingerprint.
102
+ *
103
+ * Pass `seed` to continue an existing hash, which is what lets a caller
104
+ * fold a chunk stream or walk a tree without concatenating the pieces
105
+ * first: `fnv1a(b, fnv1a(a))` equals `fnv1a(a + b)`. Callers that just want
106
+ * a fingerprint string should use {@link hashContent} instead, so the whole
107
+ * suite agrees on one encoding.
108
+ *
109
+ * @param {string} str
110
+ * @param {number} [seed] running hash to continue, unsigned 32-bit
111
+ * @returns {number} unsigned 32-bit hash
112
+ */
113
+ export declare function fnv1a(str: string, seed?: number): number;
114
+ /**
115
+ * FNV-1a 32-bit hash of a string, returned as an unsigned base-36 string
116
+ * (at most 7 chars). Not cryptographic — a stable, fast content
117
+ * fingerprint for cache keys and reconciliation keys. The suite's single
118
+ * content-hash primitive: equal content produces the same fingerprint
119
+ * (and therefore the same vnode `key`/memo key) everywhere downstream, so
120
+ * do NOT invent a second hash — {@link fnv1a} is the one mixing step.
121
+ *
122
+ * @param {string} str
123
+ * @returns {string}
124
+ */
125
+ export declare function hashContent(str: string): string;
126
+ /**
127
+ * Convert a camelCase identifier to kebab-case by inserting a hyphen
128
+ * before each ASCII uppercase letter and lower-casing it
129
+ * (`fontFamily` → `font-family`). Leaves already-hyphenated or
130
+ * all-lowercase input unchanged.
131
+ *
132
+ * @param {string} s
133
+ * @returns {string}
134
+ */
135
+ export declare function kebabCase(s: string): string;
136
+ /**
137
+ * Convert heading text into a URL fragment the way GitHub does, so one
138
+ * committed document anchors identically on GitHub, in an editor preview
139
+ * and in a renderer that uses this: lower-case, drop punctuation and
140
+ * symbols, and turn each whitespace character into a hyphen.
141
+ *
142
+ * `-` and `_` survive, as do non-ASCII letters and digits
143
+ * (`Ünicode Wörks` → `ünicode-wörks`); a `§` or an em dash does not,
144
+ * because it is a symbol rather than a letter. Text that reduces to
145
+ * nothing (`***`) yields `''` — what an empty slug means is the caller's
146
+ * decision, not this function's.
147
+ *
148
+ * This is the suite's ONLY slug implementation: a second one would drift
149
+ * from the first and break the promise above. Whitespace is converted one
150
+ * character at a time, not per run, because that is what GitHub does and
151
+ * the resulting `--` is part of the fragment a reader may already have
152
+ * bookmarked.
153
+ *
154
+ * @example
155
+ * slugify('Hello, World!'); // 'hello-world'
156
+ * slugify('§ 3.1 — Setup'); // '-31--setup'
157
+ *
158
+ * @param {string} text
159
+ * @returns {string}
160
+ */
161
+ export declare function slugify(text: string): string;
@@ -1,4 +1,6 @@
1
- export declare function isValidBase64Full(str: any): boolean;
2
- export declare function isValidBase64Old(str: any): boolean;
3
- export declare function isValidBase64(str: any): boolean;
4
- export declare function isValidBase64Fast(str: any): boolean;
1
+ /**
2
+ * Validate a Base64-encoded string (RFC 4648).
3
+ * @param {string} str - The candidate encoding
4
+ * @returns {boolean} True when the string is well-formed Base64
5
+ */
6
+ export declare function isValidBase64(str: string): boolean;
@@ -1,3 +1,2 @@
1
1
  export declare function isValidEmail(str: any): boolean;
2
- export declare function isValidEmailFull(str: any): boolean;
3
2
  export declare function isValidIdnEmail(str: any): boolean;
@@ -3,12 +3,43 @@ export declare function isValidIPv4(str: any): boolean;
3
3
  export declare function isValidIPv6(str: any): boolean;
4
4
  export declare function isValidHostname(str: any): boolean;
5
5
  export declare function isValidIdnHostname(str: any): boolean;
6
- export declare function isValidUrl(str: any): boolean;
7
- export declare function isValidUrlFull(str: any): boolean;
8
- export declare function isValidUri(str: any): boolean;
9
- export declare function isValidUriFull(str: any): boolean;
10
- export declare function isValidUriRef(str: any): boolean;
11
- export declare function isValidUriRefFull(str: any): boolean;
12
6
  export declare function isValidUriTemplate(str: any): boolean;
13
- export declare function isValidIRI(str: any): boolean;
14
- export declare function isValidIRIRef(str: any): boolean;
7
+ /**
8
+ * Validate an absolute URI (RFC 3986 section 3) - a scheme followed by a
9
+ * hierarchical part, with an optional query and fragment.
10
+ * @param {string} str - The candidate URI
11
+ * @returns {boolean} True for a well-formed URI
12
+ */
13
+ export declare function isValidUri(str: string): boolean;
14
+ /**
15
+ * Validate a URI reference (RFC 3986 section 4.1) - a URI or a relative
16
+ * reference resolved against a base.
17
+ * @param {string} str - The candidate URI reference
18
+ * @returns {boolean} True for a well-formed URI reference
19
+ */
20
+ export declare function isValidUriRef(str: string): boolean;
21
+ /**
22
+ * Validate an absolute IRI (RFC 3987 section 2.2) - a URI whose
23
+ * unreserved characters extend into the `ucschar` ranges.
24
+ * @param {string} str - The candidate IRI
25
+ * @returns {boolean} True for a well-formed IRI
26
+ */
27
+ export declare function isValidIRI(str: string): boolean;
28
+ /**
29
+ * Validate an IRI reference (RFC 3987 section 2.2) - an IRI or a
30
+ * relative reference resolved against a base.
31
+ * @param {string} str - The candidate IRI reference
32
+ * @returns {boolean} True for a well-formed IRI reference
33
+ */
34
+ export declare function isValidIRIRef(str: string): boolean;
35
+ /**
36
+ * Validate a URL: a URI carrying one of the web schemes and an
37
+ * authority. The grammar is RFC 3986's - a URL is a narrower thing than
38
+ * a URI, not a looser one - so `http://x/a|b` is no more a URL than it
39
+ * is a URI, while `http://localhost:8080` and `http://127.0.0.1/` are
40
+ * both perfectly good ones.
41
+ *
42
+ * @param {string} str - The candidate URL
43
+ * @returns {boolean} True for a well-formed http or https URL
44
+ */
45
+ export declare function isValidUrl(str: string): boolean;
@@ -8,6 +8,18 @@ export declare function isArabicIndicDigit(code: any): boolean;
8
8
  export declare function isExtendedArabicIndicDigit(code: any): boolean;
9
9
  export declare function isVirama(code: any): boolean;
10
10
  export declare function isCombiningMark(code: any): boolean;
11
- export declare function checkContextualRules(label: any): boolean;
11
+ /**
12
+ * Check the IDNA contextual rules for a label (RFC 5892 appendix A):
13
+ * the characters that are only permitted next to particular scripts.
14
+ *
15
+ * Takes the label's code points rather than the label, matching
16
+ * `checkDigitMixing` - callers validating a label have already decoded
17
+ * it, and decoding it a second time here was the only reason this
18
+ * needed the string at all.
19
+ *
20
+ * @param {number[]} codes - The label's Unicode code points
21
+ * @returns {boolean} True when every contextual rule holds
22
+ */
23
+ export declare function checkContextualRules(codes: number[]): boolean;
12
24
  export declare function checkDigitMixing(codes: any): boolean;
13
25
  export declare function isValidIdnChar(code: any): boolean;
@@ -6,3 +6,4 @@ export * from './i18n.js';
6
6
  export * from './identifiers.js';
7
7
  export * from './iregexp.js';
8
8
  export * from './misc.js';
9
+ export * from './punycode.js';
@@ -1,4 +1,18 @@
1
1
  export declare function isValidISBN10(str: any): boolean;
2
2
  export declare function isValidISBN13(str: any): boolean;
3
3
  export declare function isValidCountryAlpha2(str: any): boolean;
4
- export declare function isValidIBAN(str: any): boolean;
4
+ /**
5
+ * Validate an International Bank Account Number (ISO 13616).
6
+ *
7
+ * Three independent things have to hold, and a string that satisfies only
8
+ * the first two is the common counterfeit: the country's registered
9
+ * length, the alphanumeric body shape, and the ISO 7064 MOD 97-10 check
10
+ * digits. Both written forms are accepted - the compact electronic format
11
+ * (`NL91ABNA0417164300`) and the ISO 13616-2 print format, which groups
12
+ * into fours with single spaces (`NL91 ABNA 0417 1643 00`). Lowercase is
13
+ * accepted for the same reason the other testers here accept it.
14
+ *
15
+ * @param {string} str - The candidate IBAN
16
+ * @returns {boolean} True when the string is a well-formed IBAN
17
+ */
18
+ export declare function isValidIBAN(str: string): boolean;
@@ -1,86 +1,46 @@
1
- export declare const punycodeVersion = "2.1.0";
2
1
  /**
3
- * Creates an array containing the numeric code points of each Unicode
4
- * character in the string. While JavaScript uses UCS-2 internally,
5
- * this function will convert a pair of surrogate halves (each of which
6
- * UCS-2 exposes as separate characters) into a single code point,
7
- * matching UTF-16.
8
- * @see `punycode.ucs2.encode`
9
- * @see <https://mathiasbynens.be/notes/javascript-encoding>
10
- * @memberOf punycode.ucs2
11
- * @name decode
12
- * @param {String} string The Unicode input string (UCS-2).
13
- * @returns {Array} The new array of code points.
14
- */
15
- export declare function ucs2decode(string: string): any[];
16
- /**
17
- * Creates a string based on an array of numeric code points.
18
- * @see `punycode.ucs2.decode`
19
- * @memberOf punycode.ucs2
20
- * @name encode
21
- * @param {Array} codePoints The array of numeric code points.
22
- * @returns {String} The new Unicode string (UCS-2).
23
- */
24
- export declare const ucs2encode: (array: any) => string;
25
- /**
26
- * Converts a basic code point into a digit/integer.
27
- * @see `digitToBasic()`
28
- * @private
29
- * @param {Number} codePoint The basic numeric code point value.
30
- * @returns {Number} The numeric value of a basic code point (for use in
31
- * representing integers) in the range `0` to `base - 1`, or `base` if
32
- * the code point does not represent a value.
33
- */
34
- export declare function basicToDigit(codePoint: number): number;
35
- /**
36
- * Converts a digit/integer into a basic code point.
37
- * @see `basicToDigit()`
38
- * @private
39
- * @param {Number} digit The numeric value of a basic code point.
40
- * @returns {Number} The basic code point whose value (when used for
41
- * representing integers) is `digit`, which needs to be in the range
42
- * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
43
- * used; else, the lowercase form is used. The behavior is undefined
44
- * if `flag` is non-zero and `digit` has no uppercase form.
45
- */
46
- export declare function digitToBasic(digit: number, flag: any): number;
47
- /**
48
- * Converts a Punycode string of ASCII-only symbols to a string of Unicode
49
- * symbols.
50
- * @memberOf punycode
51
- * @param {String} input The Punycode string of ASCII-only symbols.
52
- * @returns {String} The resulting string of Unicode symbols.
53
- */
54
- export declare function decode(input: string): string;
55
- /**
56
- * Converts a string of Unicode symbols (e.g. a domain name label) to a
57
- * Punycode string of ASCII-only symbols.
58
- * @memberOf punycode
59
- * @param {String} input The string of Unicode symbols.
60
- * @returns {String} The resulting Punycode string of ASCII-only symbols.
61
- */
62
- export declare function encode(str: any): string;
63
- /**
64
- * Converts a Punycode string representing a domain name or an email address
65
- * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
66
- * it doesn't matter if you call it on a string that has already been
67
- * converted to Unicode.
68
- * @memberOf punycode
69
- * @param {String} input The Punycoded domain name or email address to
70
- * convert to Unicode.
71
- * @returns {String} The Unicode representation of the given Punycode
72
- * string.
73
- */
74
- export declare function toUnicode(input: string): string;
75
- /**
76
- * Converts a Unicode string representing a domain name or an email address to
77
- * Punycode. Only the non-ASCII parts of the domain name will be converted,
78
- * i.e. it doesn't matter if you call it with a domain that's already in
79
- * ASCII.
80
- * @memberOf punycode
81
- * @param {String} input The domain name or email address to convert, as a
82
- * Unicode string.
83
- * @returns {String} The Punycode representation of the given domain name or
84
- * email address.
85
- */
86
- export declare function toASCII(input: string): string;
2
+ * Decode a Punycode string to Unicode. The input is a bare encoded
3
+ * label - the `xn--` prefix, if any, belongs to the caller.
4
+ *
5
+ * @param {string} input - The Punycode-encoded text
6
+ * @returns {string} The decoded Unicode text
7
+ * @throws {RangeError} On a non-basic input character, a truncated digit
8
+ * sequence, or an integer overflow
9
+ * @example
10
+ * punycodeDecode('bcher-kva'); // 'bücher'
11
+ */
12
+ export declare function punycodeDecode(input: string): string;
13
+ /**
14
+ * Encode Unicode text as Punycode. The result is a bare encoded label -
15
+ * prefixing it with `xn--` is the caller's job.
16
+ *
17
+ * @param {string} str - The Unicode text
18
+ * @returns {string} The Punycode-encoded text
19
+ * @throws {RangeError} On an integer overflow
20
+ * @example
21
+ * punycodeEncode('bücher'); // 'bcher-kva'
22
+ */
23
+ export declare function punycodeEncode(str: string): string;
24
+ /**
25
+ * Convert a domain name or email address to its Unicode form, decoding
26
+ * every `xn--` label. Labels that are not encoded are left alone, so
27
+ * calling this on an already-Unicode name is harmless.
28
+ *
29
+ * @param {string} input - The domain name or email address
30
+ * @returns {string} The Unicode form
31
+ * @example
32
+ * domainToUnicode('xn--bcher-kva.example'); // 'bücher.example'
33
+ */
34
+ export declare function domainToUnicode(input: string): string;
35
+ /**
36
+ * Convert a domain name or email address to its ASCII (ACE) form,
37
+ * encoding every label that carries non-ASCII characters. Labels that
38
+ * are already ASCII are left alone, so calling this on an ASCII name is
39
+ * harmless.
40
+ *
41
+ * @param {string} input - The domain name or email address
42
+ * @returns {string} The ACE form
43
+ * @example
44
+ * domainToASCII('bücher.example'); // 'xn--bcher-kva.example'
45
+ */
46
+ export declare function domainToASCII(input: string): string;
@@ -0,0 +1,45 @@
1
+ # `@jarenjs/core/convert`
2
+
3
+ A tiny, data-driven engine for **pure, deterministic** quantity
4
+ conversion. Zero dependencies. Import the barrel (`@jarenjs/core/convert`)
5
+ or a single module.
6
+
7
+ ## Static dimensional conversion — `registry.js` + `convert.js`
8
+
9
+ `convert(value, fromId, toId)` converts within a dimension, affine through
10
+ the dimension's base unit:
11
+
12
+ ```
13
+ base = value * factor + offset
14
+ target = (base - offset') / factor'
15
+ ```
16
+
17
+ Most dimensions are linear (`offset` absent); **temperature** is affine
18
+ (°C/°F/K/°R). Digital storage ships both **binary** (KiB/MiB, 1024) and
19
+ **decimal** (KB/MB, 1000) prefixes. Dimensions: length, area, volume,
20
+ mass, temperature, time, speed, pressure, energy, power, data, datarate,
21
+ frequency, angle.
22
+
23
+ Helpers: `unitsOf(dimension)`, `dimensions()`, `dimensionOf(unitId)`.
24
+ Cross-dimension conversion throws a clear `RangeError`.
25
+
26
+ ## Currency — `currency.js`
27
+
28
+ `convertCurrency(value, from, to, rateTable)` — the pure rate-table
29
+ primitive. Deterministic, side-effect free, and it **never fetches**: the
30
+ caller supplies the `{ code: rate }` table (or a `{ base, rates, at }`
31
+ envelope). It lives in core because the dividing line is **purity**, not
32
+ constant-vs-variable factors — this function is as pure as the fixed-factor
33
+ path, it just receives its factors as an argument. Only *fetching* the
34
+ table is impure, and that stays in the app component (see `@jarenjs/calc`).
35
+
36
+ Rate convention: `rate[code]` is the value of one unit of `code` in the
37
+ table's base currency, so `result = value * rate[from] / rate[to]`.
38
+ `currenciesOf(rateTable)` lists the codes.
39
+
40
+ ## Not here
41
+
42
+ Number-base conversion (HEX/DEC/OCT/BIN) is `@jarenjs/core/math/word.js`
43
+ (`toBase`/`fromBase`), standalone — base is a notation, not a dimension,
44
+ so the converter has no "base" category.
45
+ Fuel-economy (mpg ↔ L/100km) is non-affine and outside this model.