Commit 3231989
committed
Add Torque.get_many_defaults/3 for 0.1.9
Variant of get_many_nil/2 that takes %{path => default} and returns
%{path => value_or_default}. Saves callers from the awkward two-call
pattern:
paths = Map.keys(defaults)
values = Torque.get_many_nil(doc, paths)
Enum.zip(paths, values)
|> Map.new(fn {p, nil} -> {p, Map.get(defaults, p)}; pv -> pv end)
Now a single call:
Torque.get_many_defaults(doc, %{
"/user/id" => 0,
"/user/name" => "anonymous",
"/created_at" => nil
})
Returns a same-shape map with parsed values, falling back to the
provided defaults for missing/null fields. Same nil/missing
indistinguishability semantics as get_many_nil/2.
Pure-Elixir wrapper around the existing NIF (get_many_nil/2); no
new Rust code, no NIF dispatch overhead beyond the one
get_many_nil call. Has an embedded doctest exercised by the test
suite.
D1's two other plan items resolved on inspection:
- 'aarch64 baseline variant in release matrix' -- aarch64 v8 is
universal across consumer CPUs, no v2 distinction needed. The
matrix already ships aarch64-apple-darwin + aarch64-linux-gnu.
- 'property test for float round-trip precision' -- already
covered by test/property_test.exs (35 properties, 626 lines)
with a json_scalar generator that includes float(-1000..1000),
encoded/decoded through the round-trip suite.
README and mix.exs version both bumped to 0.1.9.1 parent 7632c15 commit 3231989
3 files changed
Lines changed: 43 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
301 | 342 | | |
302 | 343 | | |
303 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments