-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: improve iterator inspect output
1) So far extra keys on an (Set|Map)Iterator were ignored. Those will now be visible. 2) Improve the performance of showing (Set|Map)Iterator by using the cloned iterator instead of copying all entries first. 3) So far the output was strictly limited to up to 100 entries. The limit will now depend on `maxArrayLength` instead (that default is set to 100 as well) and the output indicates that more entries exist than visible. PR-URL: #19259 Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
4 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
'use strict'; | ||
|
||
function take(it, n) { | ||
const result = []; | ||
for (const e of it) { | ||
if (--n < 0) | ||
break; | ||
result.push(e); | ||
} | ||
return result; | ||
} | ||
// This file provides access to some of V8's native runtime functions. See | ||
// https://github.com/v8/v8/wiki/Built-in-functions for further information | ||
// about their implementation. | ||
// They have to be loaded before anything else to make sure we deactivate them | ||
// before executing any other code. Gaining access is achieved by using a | ||
// specific flag that is used internally in the startup phase. | ||
|
||
function previewMapIterator(it, n) { | ||
return take(%MapIteratorClone(it), n); | ||
// Clone the provided Map Iterator. | ||
function previewMapIterator(it) { | ||
return %MapIteratorClone(it); | ||
} | ||
|
||
function previewSetIterator(it, n) { | ||
return take(%SetIteratorClone(it), n); | ||
// Clone the provided Set Iterator. | ||
function previewSetIterator(it) { | ||
return %SetIteratorClone(it); | ||
} | ||
|
||
module.exports = { previewMapIterator, previewSetIterator }; | ||
module.exports = { | ||
previewMapIterator, | ||
previewSetIterator | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters