
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
enum-values
Advanced tools
Library for getting the names and values of typescript enum
npm install enum-values --save
import { EnumValues } from 'enum-values';
// Suppose we have an numeric and a string valued enum
enum NumericEnum {
VALUE1,
VALUE2,
VALUE3
}
enum StringEnum {
VALUE4 = 'V4',
VALUE5 = 'V5'
}
// names will be equal to: ['VALUE1', 'VALUE2', 'VALUE3']
var names1 = EnumValues.getNames(NumericEnum);
// names will be equal to: ['VALUE4', 'VALUE5']
var names2 = EnumValues.getNames(StringEnum);
// values will be equal to: [0, 1, 2]
var values1 = EnumValues.getValues(NumericEnum);
// values will be equal to: ['V4', 'V5']
var values2 = EnumValues.getValues(StringEnum);
// namesAndValues will be equal to:
// [
// { name: 'VALUE1', value: 0 },
// { name: 'VALUE2', value: 1 },
// { name: 'VALUE3', value: 2 }
// ]
var namesAndValues1 = EnumValues.getNamesAndValues(NumericEnum);
// namesAndValues will be equal to:
// [
// { name: 'VALUE4', value: 'V4' },
// { name: 'VALUE5', value: 'V5' }
// ]
var namesAndValues2 = EnumValues.getNamesAndValues(StringEnum);
Currently the library does not support mixing string and numeric enums.
// This enum will not work:
enum MixedEnum {
A = 'A',
1 = 2,
3 = 'B',
C = 4
}
FAQs
Library for getting the names and values of typescript enum
The npm package enum-values receives a total of 8,944 weekly downloads. As such, enum-values popularity was classified as popular.
We found that enum-values demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.