Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roziscoding/wise-bit
Bitwise flag manager written in TypeScript.
https://github.com/roziscoding/wise-bit
Last synced: about 18 hours ago
JSON representation
Bitwise flag manager written in TypeScript.
- Host: GitHub
- URL: https://github.com/roziscoding/wise-bit
- Owner: roziscoding
- License: mit
- Created: 2023-11-15T14:27:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-15T14:43:15.000Z (about 1 year ago)
- Last Synced: 2025-01-06T02:12:10.054Z (6 days ago)
- Language: TypeScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wise Bit
## Description
This project provides a TypeScript class `Flags` that allows you to manage a set of flags.
Flags can be enabled, disabled, and checked if they are enabled.
The class also provides a map of the flags and their current states, and the value of the flags.## Usage
First, import the `Flags` class from `mod.ts`.
```typescript
import { Flags } from './mod.ts';
```Then, you can create a new instance of `Flags` with your known flags.
```typescript
const knownFlags = { flag1: 1, flag2: 2, flag3: 4 };
const flags = new Flags(knownFlags);
```You can enable and disable flags using the `enable` and `disable` methods.
```typescript
flags.enable(knownFlags.flag1);
flags.disable(knownFlags.flag2);
```You can check if a flag is enabled using the `isEnabled` method.
```typescript
console.log(flags.isEnabled(knownFlags.flag1)); // true
console.log(flags.isEnabled(knownFlags.flag2)); // false
```You can get a map of the flags and their current states using the `map` getter.
```typescript
console.log(flags.map); // { flag1: true, flag2: false, flag3: false }
```You can get the value of the flags using the `value` getter.
```typescript
console.log(flags.value); // 1
```## Contributing
Instructions on how to contribute to your project.
## License
See [LICENSE](LICENSE).