Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
33 lines (27 sloc) 964 Bytes
'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