@cedx/enum
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -1,9 +0,45 @@ | ||
import type { Enum } from "./interface.js"; | ||
export * from "./interface.js"; | ||
/** | ||
* Creates an enumeration from the specified type definition. | ||
* @param typedef A plain object defining the shape of the enumerated type. | ||
* @returns The newly created enumeration. | ||
* @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. | ||
*/ | ||
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 |
{ | ||
"bugs": "https://github.com/cedx/enum.js/issues", | ||
"description": "A simple implementation of enumerated types.", | ||
"homepage": "https://docs.belin.io/enum.js", | ||
"homepage": "https://github.com/cedx/enum.js", | ||
"license": "MIT", | ||
@@ -9,3 +9,3 @@ "name": "@cedx/enum", | ||
"type": "module", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"author": { | ||
@@ -17,19 +17,18 @@ "email": "cedric@belin.io", | ||
"devDependencies": { | ||
"@types/eslint__js": "^8.42.3", | ||
"@babel/eslint-parser": "^7.24.7", | ||
"@babel/plugin-syntax-import-attributes": "^7.24.7", | ||
"@types/gulp": "^4.0.17", | ||
"@types/node": "^20.12.2", | ||
"@types/node": "^20.14.2", | ||
"del": "^7.1.0", | ||
"eslint": "^8.57.0", | ||
"execa": "^8.0.1", | ||
"eslint": "^9.5.0", | ||
"execa": "^9.2.0", | ||
"gulp": "^5.0.0", | ||
"typedoc": "^0.25.12", | ||
"typescript": "^5.4.3", | ||
"typescript-eslint": "^7.4.0" | ||
"typescript": "^5.4.5" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
"node": ">=22.0.0" | ||
}, | ||
"exports": { | ||
"types": "./lib/index.d.ts", | ||
"import": "./lib/index.js" | ||
"default": "./src/index.js" | ||
}, | ||
@@ -48,4 +47,4 @@ "files": [ | ||
"prepack": "gulp", | ||
"test": "gulp build && node --test --test-reporter=spec" | ||
"test": "node --test --test-reporter=spec" | ||
} | ||
} |
@@ -7,8 +7,7 @@ # Enums for JS | ||
## Documentation | ||
- [User guide](https://docs.belin.io/enum.js) | ||
- [API reference](https://docs.belin.io/enum.js/api) | ||
- [User guide](https://github.com/cedx/enum.js/wiki) | ||
- [Examples](https://github.com/cedx/enum.js/tree/main/example) | ||
## Development | ||
- [Git repository](https://github.com/cedx/enum.js) | ||
- [npm package](https://www.npmjs.com/package/@cedx/enum) | ||
- [Submit an issue](https://github.com/cedx/enum.js/issues) | ||
@@ -15,0 +14,0 @@ |
{ | ||
"extends": "../tsconfig", | ||
"include": ["index.ts"], | ||
"extends": "../tsconfig.json", | ||
"include": ["**/*.js"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"incremental": true, | ||
"noEmit": false, | ||
"outDir": "../lib" | ||
"outDir": "../lib", | ||
"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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
9
0
14721
10
237
16
1