@cedx/enum
Advanced tools
Comparing version 9.0.1 to 9.1.0
@@ -0,45 +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<Enum<T> & 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<Enum<T> & T>; | ||
/** | ||
* Provides methods for inspecting an enumeration. | ||
*/ | ||
export type Enum<T extends object> = { | ||
/** | ||
* Returns the specified value if it exists in the specified enumeration, otherwise throws an error. | ||
*/ | ||
assert: (value: any) => T[keyof T]; | ||
/** | ||
* Returns the specified value if it exists in the specified 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 the specified enumeration. | ||
*/ | ||
entries: () => Map<string, T[keyof T]>; | ||
/** | ||
* Gets the name of the constant in the specified enumeration that has the specified value. | ||
*/ | ||
getName: (value: any) => string; | ||
/** | ||
* Gets a value indicating whether a constant with the specified name exists in the specified enumeration. | ||
*/ | ||
has: (name: string) => boolean; | ||
/** | ||
* Gets a value indicating whether a constant with the specified value exists in the specified enumeration. | ||
*/ | ||
hasValue: (value: any) => value is T[keyof T]; | ||
/** | ||
* Gets an array of the names of the constants in the specified enumeration. | ||
*/ | ||
keys: () => string[]; | ||
/** | ||
* Gets an array of the values of the constants in the specified enumeration. | ||
*/ | ||
values: () => T[keyof T][]; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,3 +9,3 @@ { | ||
"type": "module", | ||
"version": "9.0.1", | ||
"version": "9.1.0", | ||
"author": { | ||
@@ -17,11 +17,10 @@ "email": "cedric@belin.io", | ||
"devDependencies": { | ||
"@babel/eslint-parser": "^7.24.7", | ||
"@babel/plugin-syntax-import-attributes": "^7.24.7", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/gulp": "^4.0.17", | ||
"@types/node": "^20.14.2", | ||
"@types/node": "^20.14.12", | ||
"del": "^7.1.0", | ||
"eslint": "^9.5.0", | ||
"execa": "^9.2.0", | ||
"execa": "^9.3.0", | ||
"gulp": "^5.0.0", | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.5.4", | ||
"typescript-eslint": "^8.0.0-alpha.54" | ||
}, | ||
@@ -33,3 +32,3 @@ "engines": { | ||
"types": "./lib/index.d.ts", | ||
"default": "./src/index.js" | ||
"default": "./lib/index.js" | ||
}, | ||
@@ -48,4 +47,4 @@ "files": [ | ||
"prepack": "gulp", | ||
"test": "node --test --test-reporter=spec" | ||
"test": "gulp build && node --test --test-reporter=spec" | ||
} | ||
} |
{ | ||
"extends": "../tsconfig.json", | ||
"include": ["**/*.js"], | ||
"include": ["**/*.ts"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"incremental": true, | ||
"noEmit": false, | ||
"outDir": "../lib", | ||
"rootDir": ".", | ||
"tsBuildInfoFile": "../var/tsbuildinfo.json" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21873
8
16
359