-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
repl: tab auto complete big arrays #22408
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,7 +366,6 @@ function isInsideNodeModules() { | |
return false; | ||
} | ||
|
||
|
||
module.exports = { | ||
assertCrypto, | ||
cachedResult, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,12 @@ const { | |
isRegExp, | ||
isSet | ||
} = internalBinding('types'); | ||
const { getOwnNonIndexProperties } = process.binding('util'); | ||
const { | ||
getOwnNonIndexProperties, | ||
propertyFilter: { | ||
ONLY_ENUMERABLE | ||
} | ||
} = process.binding('util'); | ||
|
||
const ReflectApply = Reflect.apply; | ||
|
||
|
@@ -118,8 +123,9 @@ function strictDeepEqual(val1, val2, memos) { | |
if (val1.length !== val2.length) { | ||
return false; | ||
} | ||
const keys1 = getOwnNonIndexProperties(val1); | ||
if (keys1.length !== getOwnNonIndexProperties(val2).length) { | ||
const keys1 = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE); | ||
const keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE); | ||
if (keys1.length !== keys2.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason for needing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already spoke to @littledan and I am writing the proposal at the moment. It's almost done. |
||
return false; | ||
} | ||
return keyCheck(val1, val2, kStrict, memos, kIsArray, keys1); | ||
|
@@ -150,8 +156,9 @@ function strictDeepEqual(val1, val2, memos) { | |
// Buffer.compare returns true, so val1.length === val2.length. If they both | ||
// only contain numeric keys, we don't need to exam further than checking | ||
// the symbols. | ||
const keys1 = getOwnNonIndexProperties(val1); | ||
if (keys1.length !== getOwnNonIndexProperties(val2).length) { | ||
const keys1 = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE); | ||
const keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE); | ||
if (keys1.length !== keys2.length) { | ||
return false; | ||
} | ||
return keyCheck(val1, val2, kStrict, memos, kNoIterator, keys1); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,12 +393,6 @@ testMe.complete('obj.', common.mustCall((error, data) => { | |
assert(data[0].includes('obj.key')); | ||
})); | ||
|
||
// tab completion for large buffer | ||
const warningRegEx = new RegExp( | ||
'\\(node:\\d+\\) REPLWarning: The current array, Buffer or TypedArray has ' + | ||
'too many entries\\. Certain properties may be missing from completion ' + | ||
'output\\.'); | ||
|
||
[ | ||
Array, | ||
Buffer, | ||
|
@@ -428,11 +422,7 @@ const warningRegEx = new RegExp( | |
putIn.run([`var ele = new ${type.name}(1e6 + 1); ele.biu = 1;`]); | ||
} | ||
|
||
common.hijackStderr(common.mustCall((err) => { | ||
process.nextTick(() => { | ||
assert.ok(warningRegEx.test(err)); | ||
}); | ||
})); | ||
common.hijackStderr(common.mustNotCall()); | ||
testMe.complete('ele.', common.mustCall((err, data) => { | ||
common.restoreStderr(); | ||
assert.ifError(err); | ||
|
@@ -443,13 +433,12 @@ const warningRegEx = new RegExp( | |
Buffer.alloc(0) : | ||
new type(0)); | ||
|
||
assert.strictEqual(data[0].includes('ele.biu'), true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to have tests that specify the behaviour for long arrays better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is specifically for long arrays. Since this value shows up, we can be certain that it works. I would not know what to improve. Do you have a suggestion? |
||
|
||
data[0].forEach((key) => { | ||
if (!key) return; | ||
if (!key || key === 'ele.biu') return; | ||
assert.notStrictEqual(ele[key.substr(4)], undefined); | ||
}); | ||
|
||
// no `biu` | ||
assert.strictEqual(data.includes('ele.biu'), false); | ||
})); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated optimization idea: would it make sense to return only the length from V8 rather than the properties themselves in the case of keys2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already spoke with @nodejs/v8 to implement a API that does exactly that. Until that exists, I would rather keep it as is.