Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
safely-convert-enum
Advanced tools
Small TypeScript utility to convert between compatible enum values
Tiny utility function that can be used to safely convert between string-based enums with identical values.
const sourceEnum = SourceEnum.SomeValue;
const convertedEnum: TargetEnum = safelyConvertEnum(sourceEnum);
This will produce an error in the event that SourceEnum
and TargetEnum
are incompatible by
value, or are not string
-based enums.
The error it produces is unfortunately a little cryptic. Given an incompatible set of enums, the
error will present on the sourceEnum
variable where it is passed into the function, and the error
will be similar to:
Argument of type '...' is not assignable to parameter of type 'never'.ts(2345)
You should use this only when you are dealing with two enums that are meaningfully equivalent. This means both that they have the same values today, and that they (by design) should always represent the same set of values. You should not use this to convert between enums that are coincidentally equivalent.
FAQs
Small TypeScript utility to convert between compatible enum values
The npm package safely-convert-enum receives a total of 1 weekly downloads. As such, safely-convert-enum popularity was classified as not popular.
We found that safely-convert-enum 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.