Repository navigation
Conversation
Coverage Summary> ramda@0.32.0 coverage:summary
> BABEL_ENV=cjs nyc --reporter=text-summary mocha -- --reporter=min --require @babel/register
�[2J�[1;3H
1234 passing (1s)
=============================== Coverage summary ===============================
Statements : 94.09% ( 2565/2726 )
Branches : 85.95% ( 1009/1174 )
Functions : 93.39% ( 565/605 )
Lines : 94.35% ( 2406/2550 )
================================================================================ |
|
Creating objects with a non-callable IMO Ramda should not care about LLM models or humans who produce such code. We should allow such code to crash, so the author learns something about JavaScript |
|
Thanks for the feedback. There is also an ordinary-object case, with no overridden const a = {a: 1};
const b = {b: 2};
R.toString(new Set([a, b])); // 'new Set([{"a": 1}, {"b": 2}])'
R.toString(new Set([b, a])); // 'new Set([{"b": 2}, {"a": 1}])'Both objects coerce to Null-prototype objects are another case: |
Problem
R.toStringthrows when a Set contains ordinary objects with a non-callabletoStringdata property:Each object can be rendered individually. The failure comes from sorting the raw Set members before rendering them. Null-prototype dictionaries fail for the same reason. Other objects compare as the same native
"[object Object]"string, so their rendered order depends on insertion order.Solution
Render the members recursively, then sort their rendered strings and assemble the Set representation. This preserves circular-reference handling and custom representations while avoiding an extra native coercion step. The ordering of heterogeneous Set representations may change because sorting now uses the rendered values.
This follows the sorting rationale in the original Set support: #2624 review discussion.
Validation on Node.js 24.19.0:
npm test: 1,234 passing, including the full lint check.npm test: 1,239 passing, including full lint.npm run build,coverage:summaryandcoverage:detailspassed.git diff --checkpassed.AI assistance was used to prepare the implementation and regression tests.
ChangeLog
Fix Set stringification for objects that cannot be coerced to primitive strings, and sort object members by their rendered representation.