https://github.com/chuckterry/enumjs
Enum Implementation in Javascript
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (5.5%) to scientific vocabulary
Repository
Enum Implementation in Javascript
Basic Info
- Host: GitHub
- Owner: ChuckTerry
- License: agpl-3.0
- Language: JavaScript
- Default Branch: main
- Size: 22.5 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
EnumJS
Enum Implementation in Javascript with ability to lock and unlock.
Version: 1.2.1
Usage
Instantiation
```javascript // The Starting Value will always be the first vaue passed to the constructor new Enum(/Array of States/, /Surpress Errors/ [optional]); const myEnum = new Enum(['OFF', 'LOW', 'MID', 'HIGH'], false);
// Or use the static from() method const myEnum = Enum.from('OFF', 'LOW', 'MID', 'HIGH']); ```
Check if object is Enum
javascript
Enum.isEnum(myEnum) // --> True
Get Current State
```javascript const currentState = myEnum.getState(); // --> 'OFF'
// Or use the accessor const currentState = myEnum.state; // --> 'OFF' ```
Set Current State
```javascript myEnum.setState('MID'); // --> 'MID'
// Or use the accessor myEnum.state = 'MID'; // --> 'MID' ```
Get Number of Valid States
javascript
myEnum.length; // --> 4
Get All Valid States
javascript
myEnum.getValidStates(); // --> ['OFF', 'LOW', 'MID', 'HIGH']
Test if State is Valid
javascript
myEnum.isValidState('MAX'); // --> false
Locking
```javascript // Locking an Enum will return a key (Symbol) used to unlock it again const myKey = myEnum.lock();
myEnum.setState('LOW'); // Throws an error (Or nothing if surpressed);
myEnum.unlock(myKey); myEnum.setState('LOW'); // Succeeds
// Locking Enum with a "true" parameter locks it permanently and returns true myEnum.lock(true); // --> true ```
Checking Lock Status
javascript
myEnum.isLocked(); // --> true
Owner
- Name: Chuck Terry
- Login: ChuckTerry
- Kind: user
- Location: Ellenboro, North Carolina, USA
- Company: Ex @surge-ai
- Website: https://ChuckTerry.me
- Repositories: 16
- Profile: https://github.com/ChuckTerry
Jack of all trades, master of JavaScript. Unless you ask StackOverflow, in which case: Slightly above average at JavaScript, prophet of Home Improvement.
GitHub Events
Total
Last Year
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Chuck Terry | c****m@g****m | 10 |
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0