For very complex reasons, I am studying to better understand Node.JS internals and discovered two functions of an unknown purpose.
These are functions and ways to access them.
process.binding('util').setHiddenValue process.binding('util').getHiddenValue
From their own code declarations , it is clear that they wrap the following V8 functions:
v8::Object::SetPrivate v8::Object::GetPrivate
I also made a small snippet that shows what they can do.
'use strict'; var binding = process.binding('util'); var o = {}; binding.setHiddenValue(o, 7, 'testing123'); console.log(binding.getHiddenValue(o, 7));
However, I could not find the documentation of what the so-called "hidden values" are for, or otherwise determine why they are needed in Node or in V8.
Can anyone shed light on their true purpose?
For reference, these are apparently the only valid values ββthat can be used to bind data (with an excess of 7):
alpn_buffer_private_symbol: 0, arrow_message_private_symbol: 1, contextify_context_private_symbol: 2, contextify_global_private_symbol: 3, decorated_private_symbol: 4, npn_buffer_private_symbol: 5, processed_private_symbol: 6, selected_npn_buffer_private_symbol: 7,