Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@cedx/enum
Advanced tools
Yet another implementation of enumerated types for JavaScript.
This implementation does not try to reproduce the semantics of traditional enumerations, like the ones found in C# or Java languages. It just gives a set of static methods to ease working with the values of an object literal representing an enumerated type.
The latest Node.js and npm versions. If you plan to play with the sources, you will also need the latest Gulp.js version.
From a command prompt, run:
$ npm install --save @cedx/enum
Just use the Enum.create()
method with an object literal containing scalar values:
const {Enum} = require('@cedx/enum');
/**
* Specifies the day of the week.
* @type {object}
*/
const DayOfWeek = Enum.create({
SUNDAY: 0,
MONDAY: 1,
TUESDAY: 2,
WEDNESDAY: 3,
THURSDAY: 4,
FRIDAY: 5,
SATURDAY: 6
});
The Enum.create()
method creates an anonymous class from the specified object. This class has the same values as the provided object, and some additional helper methods.
The created class has a constructor throwing a TypeError
: it prohibits its instantiation. This class is also freezed to prevent any attempt at modifying its shape.
Check whether a value is defined among the enumerated type:
DayOfWeek.isDefined(DayOfWeek.TUESDAY); // true
DayOfWeek.isDefined('Foo'); // false
Get the name associated to an enumerated value:
DayOfWeek.getName(DayOfWeek.TUESDAY); // "TUESDAY"
DayOfWeek.getName('Bar'); // "" (empty)
Get information about the enumerated type:
DayOfWeek.getNames();
// ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"]
DayOfWeek.getValues();
// [0, 1, 2, 3, 4, 5, 6]
Enums for JS is distributed under the Apache License, version 2.0.
FAQs
A simple implementation of enumerated types.
The npm package @cedx/enum receives a total of 16 weekly downloads. As such, @cedx/enum popularity was classified as not popular.
We found that @cedx/enum demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.