mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 17:20:10 +08:00
34 lines
964 B
JavaScript
34 lines
964 B
JavaScript
'use strict'
|
|
|
|
function getObjectKeys (obj, excludeListItemAccessorsBelowLength) {
|
|
const keys = []
|
|
let size = 0
|
|
|
|
// Sort property names, they should never be order-sensitive
|
|
const nameCandidates = Object.getOwnPropertyNames(obj).sort()
|
|
// Comparators should verify symbols in an order-insensitive manner if
|
|
// possible.
|
|
const symbolCandidates = Object.getOwnPropertySymbols(obj)
|
|
|
|
for (const name of nameCandidates) {
|
|
let accept = true
|
|
if (excludeListItemAccessorsBelowLength > 0) {
|
|
const index = Number(name)
|
|
accept = !Number.isInteger(index) || index < 0 || index >= excludeListItemAccessorsBelowLength
|
|
}
|
|
|
|
if (accept && Object.getOwnPropertyDescriptor(obj, name).enumerable) {
|
|
keys[size++] = name
|
|
}
|
|
}
|
|
|
|
for (const symbol of symbolCandidates) {
|
|
if (Object.getOwnPropertyDescriptor(obj, symbol).enumerable) {
|
|
keys[size++] = symbol
|
|
}
|
|
}
|
|
|
|
return { keys, size }
|
|
}
|
|
module.exports = getObjectKeys
|