Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cedx/enum

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cedx/enum - npm Package Compare versions

Comparing version 8.0.1 to 8.1.0

lib/implementation.d.ts

47

lib/index.d.ts

@@ -0,46 +1,9 @@

export * from "./interface.js";
import type { Enum } from "./interface.js";
/**
* Creates an enumeration from the specified type definition.
* @template {object} T
* @param {T} typedef A plain object defining the shape of the enumerated type.
* @returns {Readonly<T & EnumMixin<T>>} The newly created enumeration.
* @param typedef A plain object defining the shape of the enumerated type.
* @returns The newly created enumeration.
*/
export default function createEnum<T extends object>(typedef: T): Readonly<T & EnumMixin<T>>;
export * from "./enum.js";
/**
* Provides methods for inspecting an enumeration.
*/
export type EnumMixin<T extends object> = {
/**
* Returns the specified value if it exists in this enumeration, otherwise throws an error.
*/
assert: (value: any) => T[keyof T];
/**
* Returns the specified value if it exists in this enumeration, otherwise returns the given default value.
*/
coerce: (value: any, defaultValue: T[keyof T]) => T[keyof T];
/**
* Gets a map of the names and values of the constants in this enumeration.
*/
getEntries: () => Map<string, T[keyof T]>;
/**
* Gets the zero-based position of the constant in this enumeration that has the specified value.
*/
getIndex: (value: any) => number;
/**
* Gets the name of the constant in this enumeration that has the specified value.
*/
getName: (value: any) => string;
/**
* Gets an array of the names of the constants in this enumeration.
*/
getNames: () => string[];
/**
* Gets an array of the values of the constants in this enumeration.
*/
getValues: () => Array<T[keyof T]>;
/**
* Gets a value indicating whether a constant with a specified value exists in this enumeration.
*/
isDefined: (value: any) => value is T[keyof T];
};
export default function createEnum<T extends object>(typedef: T): Readonly<Enum<T> & T>;
//# sourceMappingURL=index.d.ts.map
# MIT License
Copyright &copy; 2016-2022 Cédric Belin
Copyright (c) Cédric Belin

@@ -4,0 +4,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -7,5 +7,5 @@ {

"name": "@cedx/enum",
"repository": "github:cedx/enum.js",
"repository": "cedx/enum.js",
"type": "module",
"version": "8.0.1",
"version": "8.1.0",
"author": {

@@ -17,20 +17,15 @@ "email": "cedric@belin.io",

"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-syntax-import-assertions": "^7.18.6",
"@types/gulp": "^4.0.9",
"@types/node": "^18.7.23",
"c8": "^7.12.0",
"del": "^7.0.0",
"eslint": "^8.24.0",
"execa": "^6.1.0",
"gulp": "^4.0.2",
"typedoc": "^0.23.15",
"typescript": "^4.8.4"
"@types/node": "^20.11.6",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"eslint": "^8.56.0",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
},
"exports": {
"types": "./lib/index.d.ts",
"import": "./src/index.js"
"import": "./lib/index.js"
},

@@ -41,2 +36,8 @@ "files": [

],
"imports": {
"#enum": {
"types": "./lib/index.d.ts",
"import": "./lib/index.js"
}
},
"keywords": [

@@ -49,5 +50,11 @@ "enum",

"scripts": {
"prepack": "gulp",
"test": "c8 --all --include=src/**/*.js --report-dir=var --reporter=lcovonly node --test"
"build": "tsc --project src/tsconfig.json",
"clean": "node tool/clean.js",
"doc": "typedoc --options etc/typedoc.js && node tool/doc.js",
"dist": "npm run clean && npm run build",
"lint": "tsc --project tsconfig.json && eslint --config=etc/eslint.cjs example src test tool",
"postpublish": "node tool/publish.js",
"prepack": "npm run dist",
"test": "npm run build && node --test --test-reporter=spec"
}
}
# Enums for JS
![Runtime](https://badgen.net/npm/node/@cedx/enum) ![Release](https://badgen.net/npm/v/@cedx/enum) ![License](https://badgen.net/npm/license/@cedx/enum) ![Downloads](https://badgen.net/npm/dt/@cedx/enum) ![Coverage](https://badgen.net/codecov/c/github/cedx/enum.js)
![Node.js](https://badgen.net/npm/node/@cedx/enum) ![npm](https://badgen.net/npm/v/@cedx/enum) ![License](https://badgen.net/npm/license/@cedx/enum) ![Downloads](https://badgen.net/npm/dt/@cedx/enum)

@@ -7,4 +7,4 @@ Yet another implementation of enumerated types for [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript).

## Documentation
- [User guide](https://github.com/cedx/enum.js/wiki)
- [API reference](https://cedx.github.io/enum.js)
- [User guide](https://cedx.github.io/enum.js)
- [API reference](https://cedx.github.io/enum.js/api)

@@ -11,0 +11,0 @@ ## Development

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc