|
1 | | -# Flipper TypeScript |
| 1 | +# @flippercloud/flipper |
2 | 2 |
|
3 | | -A TypeScript implementation of [Flipper](https://github.com/flippercloud/flipper) - a feature flagging library. |
| 3 | +A TypeScript/JavaScript implementation of [Flipper](https://github.com/flippercloud/flipper) - a feature flagging library for controlling features and behavior. |
4 | 4 |
|
5 | 5 | ## Installation |
6 | 6 |
|
7 | 7 | ```bash |
8 | | -bun add flipper-typescript |
| 8 | +bun add @flippercloud/flipper |
9 | 9 | ``` |
10 | 10 |
|
11 | | -## Development |
| 11 | +## Quick usage |
12 | 12 |
|
13 | | -### Prerequisites |
| 13 | +```typescript |
| 14 | +import Flipper from '@flippercloud/flipper' |
| 15 | +import { MemoryAdapter } from '@flippercloud/flipper' |
14 | 16 |
|
15 | | -- Node.js >= 18.0.0 |
16 | | -- Bun >= 1.3.2 |
| 17 | +const adapter = new MemoryAdapter() |
| 18 | +const flipper = new Flipper(adapter) |
17 | 19 |
|
18 | | -### Setup |
| 20 | +// Enable a feature |
| 21 | +await flipper.enable('new-ui') |
19 | 22 |
|
20 | | -```bash |
21 | | -bun install |
| 23 | +// Check if a feature is enabled |
| 24 | +const isEnabled = await flipper.isEnabled('new-ui') |
| 25 | +console.log(isEnabled) // true |
| 26 | + |
| 27 | +// Enable for specific actors |
| 28 | +await flipper.enableActor('premium-feature', 'user-123') |
| 29 | + |
| 30 | +// Check if enabled for a specific actor |
| 31 | +const isPremiumEnabled = await flipper.isEnabledFor('premium-feature', 'user-123') |
| 32 | +console.log(isPremiumEnabled) // true |
22 | 33 | ``` |
23 | 34 |
|
24 | | -### Scripts |
25 | | - |
26 | | -- `bun run build` - Build the TypeScript source |
27 | | -- `bun test` - Run tests |
28 | | -- `bun run test:watch` - Run tests in watch mode |
29 | | -- `bun run test:coverage` - Run tests with coverage |
30 | | -- `bun run lint` - Lint code with ESLint |
31 | | -- `bun run lint:fix` - Lint and auto-fix issues |
32 | | -- `bun run type-check` - Check TypeScript types |
33 | | -- `bun run format` - Format code with Prettier |
34 | | -- `bun run format:check` - Check code formatting |
35 | | -- `bun run clean` - Remove build artifacts |
| 35 | +## Docs |
| 36 | + |
| 37 | +Looking for configuration, adapters, advanced usage, and best practices? See the full guide: [Flipper documentation](../../docs/README.md). |
36 | 38 |
|
37 | 39 | ## License |
38 | 40 |
|
|
0 commit comments