Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

get-own-enumerable-keys

sindresorhus1.6mMIT1.0.0TypeScript support: included

Like Object.keys() but also includes symbols

object, own, enumerable, keys, key, property, properties, symbol, symbols

readme

get-own-enumerable-keys

Like Object.keys() but also includes symbols

Object.keys() returns the own enumerable keys of an object except symbols (for legacy reasons). This package includes symbols too.

Use Reflect.ownKeys() if you also want non-enumerable keys.

Install

npm install get-own-enumerable-keys

Usage

import getOwnEnumerableKeys from 'get-own-enumerable-keys';

const symbol = Symbol('x');

const object = {
    foo: true,
    [symbol]: true,
};

Object.keys(object);
// ['foo']

getOwnEnumerableKeys(object);
//=> ['foo', Symbol('x')]