open-index/open-npm huggingface dataset:
npm package: @orange-ember/easy-flags-sdk
Description: Official TypeScript SDK for Easy Flags management platform.
Author: Seobryn
Latest version: 1.0.0

# Easy Flags SDK

Official TypeScript SDK for the **Easy Flags** feature flag management platform. Manage features toggles, rollouts, and targeting rules with ease in your Node.js or Browser applications.

## Key Features

- 🚀 **Universal Support**: Works seamlessly in Node.js, Browsers, and Edge environments.
- 🛡️ **Strongly Typed**: Full TypeScript support with generics for flag values.
- 📉 **Smart Context**: Automatically optimizes requests (GET/POST) based on context size.
- 🔇 **Silent Fail**: Never breaks your app – returns user-defined defaults if the service is unavailable.
- 📦 **Modern Bundle**: Shipped in ESM and CommonJS formats.

## Installation

```bash
npm install @orange-ember/easy-flags-sdk
# or
yarn add @orange-ember/easy-flags-sdk
# pnpm
pnpm add @orange-ember/easy-flags-sdk
```

## Quick Start

### 1. Initialize the Client

```typescript
import { EasyFlagsClient } from "@orange-ember/easy-flags-sdk";

const client = new EasyFlagsClient({
  apiKey: "your-api-key",
  spaceId: "your-space-id",
  environmentId: "your-environment-id",
});
```

### 2. Evaluate a Flag

```typescript
// Basic boolean toggle
const isFeatureEnabled = await client.evaluate("new-ui-v2", {
  defaultValue: false,
});

if (isFeatureEnabled) {
  renderNewUI();
}
```

### 3. Using Smart Context & Generics

Pass a `userId` and a custom `context` for advanced targeting and deterministic rollouts.

```typescript
const buttonColor = await client.evaluate<string>("signup-btn-color", {
  defaultValue: "#000000",
  userId: "user_123",
  context: {
    plan: "premium",
    country: "US",
  },
});
```

## Advanced Configuration

| Option          | Type      | Default      | Description                                      |
| --------------- | --------- | ------------ | ------------------------------------------------ |
| `apiKey`        | `string`  | **Required** | Your Easy Flags API Key.                         |
| `spaceId`       | `string`  | **Required** | The ID of your Space.                            |
| `environmentId` | `string`  | **Required** | The ID of the environment (e.g., prod, staging). |
| `baseUrl`       | `string`  | `https://`   | Custom API base URL.                             |
| `debug`         | `boolean` | `false`      | Enable console logging for debugging.            |

## Error Handling

The SDK implements a "Silent Fail" strategy. If a network request fails or the service returns an error, the `evaluate` method catch the error and return the `defaultValue` provided in the options.

```typescript
const flag = await client.evaluate("my-flag", {
  defaultValue: "safe-value",
});
// result is always 'safe-value' if something goes wrong
```

## License

Apache-2.0 © Orange Ember Studios