-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The version list should be sorted by name #45630
Comments
Any easy ways to sort this macro in #define NODE_VERSIONS_KEYS(V) \
NODE_VERSIONS_KEYS_BASE(V) \
NODE_VERSIONS_KEY_CRYPTO(V) \
NODE_VERSIONS_KEY_INTL(V) \
NODE_VERSIONS_KEY_QUIC(V) |
Object.keys(process.versions).sort().reduce((r, k) => (r[k] = process.versions[k], r), {}); or Object.fromEntries(Object.entries(process.versions).sort((a,b)=>a<b?-1:1)) |
Sorry. This is not JS. I was in an expectation like, Editing the above comment. |
No, unfortunately. What you could do instead is:
(1) is kind of fragile and a maintenance drag. (2) feels meh. (3) increases total build time, possibly by a lot. A Sufficiently Smart Compiler would do the sorting in (2) at compile time. Unlikely, though. The runtime version string munging in src/node_metata.cc is pretty inefficient. Likely doesn't matter because we usually deserialize from snapshot but if it ran every time, that'd be a good argument for going with (3). |
@MrJithil: Good point! |
node/src/node_process_object.cc Lines 112 to 118 in 71ff89f
|
I think we could do here before it becomes a read-only object Subject: [PATCH] src: sort versions
---
Index: src/node_process_object.cc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/node_process_object.cc b/src/node_process_object.cc
--- a/src/node_process_object.cc (revision 2a29df64645a70bbb833298423a29206c4ec6a2e)
+++ b/src/node_process_object.cc (date 1675098681432)
@@ -107,7 +107,6 @@
// process.versions
Local<Object> versions = Object::New(isolate);
- READONLY_PROPERTY(process, "versions", versions);
#define V(key) \
if (!per_process::metadata.versions.key.empty()) { \
@@ -116,6 +115,9 @@
}
NODE_VERSIONS_KEYS(V)
#undef V
+ // todo: sort the keys except node
+
+ READONLY_PROPERTY(process, "versions", versions);
// process.arch
READONLY_STRING_PROPERTY(process, "arch", per_process::metadata.arch);
|
See #46428 |
Co-authored-by: James M Snell <[email protected]> Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #46428 Fixes: #45630 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Co-authored-by: James M Snell <[email protected]> Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #46428 Fixes: #45630 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Co-authored-by: James M Snell <[email protected]> Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #46428 Fixes: #45630 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Co-authored-by: James M Snell <[email protected]> Co-authored-by: Anna Henningsen <[email protected]> PR-URL: nodejs#46428 Fixes: nodejs#45630 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Co-authored-by: James M Snell <[email protected]> Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #46428 Fixes: #45630 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
The version list should be sorted.
Current Behaviour:
Problem with the current order:
Since the current version list is not sorted, it's hard to compare with the source code (mainly the
deps
folder).Solution:
Except the
node
, sort all other versions by name.Eg:
The text was updated successfully, but these errors were encountered: