
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
ts-enum-helpers
Advanced tools
A small collection of utility methods to help parse typescript enums into objects, keys and values
A small collection of utility methods to help parse typescript enums into objects, keys and values.
Install using yarn or npm
yarn add ts-enum-helpers
npm install ts-enum-helpers --save
Given the following enums:
enum StringEnum {
ONE = "one",
TWO = "two",
THREE = "three"
}
enum NumberEnum {
ONE,
TWO,
THREE
}
parseEnum
- convert an enum to an object
import {parseEnum} from "ts-enum-helpers"
const stringEnum = parseEnum(StringEnum);
const numericEnum = parseEnum(NumberEnum);
console.log(stringEnum)
console.log(numericEnum)
> {"ONE": "one", "TWO": "two", "THREE": "three"}
> {"ONE": 0, "TWO": 1, "THREE": 2}
getEnumNames
- convert an enum to an array of its keys
import {getEnumNames} from "ts-enum-helpers"
const stringEnum = getEnumNames(StringEnum);
const numericEnum = getEnumNames(NumberEnum);
console.log(stringEnum)
console.log(numericEnum)
> ["ONE", "TWO", "THREE"]
> ["ONE", "TWO", "THREE"]
getEnumValues
- convert an enum to an array of its values
import {getEnumValues} from "ts-enum-helpers"
const stringEnum = getEnumValues(StringEnum);
const numericEnum = getEnumValues(NumberEnum);
console.log(stringEnum)
console.log(numericEnum)
> ["one", "two", "three"]
> [0, 1, 2]
getEnumNamesAndValues
- convert an enum to an array of ({name: string, value: T extends (number | string)})
import {getEnumNamesAndValues} from "ts-enum-helpers"
const stringEnum = getEnumNamesAndValues(StringEnum);
const numericEnum = getEnumNamesAndValues(NumberEnum);
console.log(stringEnum)
console.log(numericEnum)
> [
{"name": "ONE", "value": "one"},
{"name": "TWO", "value": "two"},
{"name": "THREE", "value": "three"}
]
> [
{"name": "ONE", "value": 0},
{"name": "TWO", "value": 1},
{"name": "THREE", "value": 2}
]
FAQs
A small collection of utility methods to help parse typescript enums into objects, keys and values
The npm package ts-enum-helpers receives a total of 0 weekly downloads. As such, ts-enum-helpers popularity was classified as not popular.
We found that ts-enum-helpers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.