open-index/open-npm huggingface dataset:
npm package: @rapa/prettier-config
Description: rapa's base Prettier config
Latest version: 0.1.0

# prettier-config

ppu's base Prettier config.

## Installation

```sh
yarn add --dev @rapa/prettier-config
```

## Usage

After installing, update your project's `prettier.config.js` file to import the rule sets you want:

```js
module.exports = {
  ...require('@rapa/prettier-config'),
  // your overrides here
};
```

---

Read the [Prettier config docs](https://prettier.io) for more information.
npm package: @rapal/optimaze-viewer
Description: Library for viewing Optimaze floor plan. Based on Leaflet.
Author: Rapal Oy
Latest version: 0.4.1

# optimaze-viewer

This is a library for rendering and manipulating floor plans from the Optimaze real estate management software by [Rapal](http://www.rapal.com/). It makes it easier to use the data provided by the Optimaze API in third-party applications. It is built on top of the [Leaflet](http://leafletjs.com/) interactive map library.

The library currently provides the following features:

1. Render space vector graphics
2. Show graphics tile layers
3. Select spaces and other elements

## Usage

### With npm

To install using npm, run:

```console
npm install @rapal/optimaze-viewer
```

You can then import the library:

```js
import { Viewer, Space, Element } from "@rapal/optimaze-viewer";
var viewer = new Viewer(...);
```

Remember to also include the Leaflet CSS file:

```js
import "leaflet/dist/leaflet.css";
```

### With script tags

To include the library as a global script, download the UMD bundle `optimaze-viewer.js` from the `dist` directory and include it in your HTML. You also need to include Leaflet JavaScript and CSS files.

```html
<script src="leaflet.js"></script>
<script src="optimaze-viewer.js"></script>
<link rel="stylesheet" href="leaflet.css" />
```

You can then use the library as a global module:

```js
var viewer = new optimazeViewer.Viewer(...);
```

## Documentation

See the files in the `types` directory for documentation.

There is also an [example application](https://github.com/rapal/optimaze-viewer-example) that shows how you can use the library.

### Notes

The `FixedCircle` class can be used instead of `L.Circle` to prevent circle radius rounding errors.

## Development

### Requirements

- [Yarn](https://yarnpkg.com/) package manager

### Workflow

1. Pull master branch
2. Create feature branch
3. Run `yarn` to install dependencies
4. Run `yarn test` to run unit tests
5. Run `yarn build` to build and generate type declarations
6. Create pull request and squash merge to master
7. Run `yarn publish --access public` to increment version and publish to npm registry
8. Push version increase and tag to master
9. Create GitHub release

### Directories

- `src` TypeScript source files
- `types` TypeScript declaration files
- `dist` UMD bundle for use in browser
npm package: @raph9213/discord-rpc
Description: A simple RPC client for Discord
Author: Raph9213
Latest version: 4.1.1

# Discord.js RPC Extension, forked

This fork is manly used to add the new fields from the Activity Object: https://discord.com/developers/docs/events/gateway-events#activity-object

### [Documentation](https://discord.js.org/#/docs/rpc/)

### [Rich Presence Example](https://github.com/discordjs/RPC/blob/master/example)

### __Browser__ Example

```javascript
const clientId = '287406016902594560';
const scopes = ['rpc', 'rpc.api', 'messages.read'];

const client = new RPC.Client({ transport: 'websocket' });

client.on('ready', () => {
  console.log('Logged in as', client.application.name);
  console.log('Authed for user', client.user.username);

  client.selectVoiceChannel('81384788862181376');
});

// Log in to RPC with client id
client.login({ clientId, scopes });
```
npm package: @raphaabreu/message-batcher
Description: Message batcher
Author: Raphael Lorenzeto de Abreu
Latest version: 1.0.1

# MessageBatcher

The `MessageBatcher` class is a utility that helps you batch messages and process them in groups. It is useful when you want to reduce the number of operations or API calls by aggregating messages and processing them together.

## Features

- Add messages to a queue.
- Flush messages in batch when the queue reaches a certain size.
- Start an interval timer to flush messages periodically.
- Stop the interval timer.
- Stop the interval timer and flush remaining messages.

## Usage

First, install the package:

```bash
npm i @raphaabreu/message-batcher
```

Then import the `MessageBatcher` class:

```typescript
import { MessageBatcher } from '@raphaabreu/message-batcher';
```

### Creating a MessageBatcher instance

To create a new MessageBatcher instance, you need to specify the batchSize and a callback function. The batchSize determines the maximum number of messages that can be processed in one batch. The callback function is called with an array of messages when the batch is ready to be processed.

```typescript
const batchSize = 5;
const callback = async (messages: string[]) => {
  // Process messages here
};

const messageBatcher = new MessageBatcher<string>(batchSize, callback);
```

### Adding messages

You can add messages to the queue using the `add` method:

```typescript
messageBatcher.add('message1');
messageBatcher.add(['message2', 'message3']);
```

The `add` method accepts a single message or an array of messages.

### Starting the interval timer

To start the interval timer, call the `start` method and pass the `maxBatchIntervalMs` parameter:

```typescript
const maxBatchIntervalMs = 10000; // 10 seconds
messageBatcher.start(maxBatchIntervalMs);
```

The `maxBatchIntervalMs` determines the maximum interval between message batch processing.

### Stopping the interval timer

To stop the interval timer, call the `stop` method:

```typescript
messageBatcher.stop();
```

### Stopping the interval timer and flushing remaining messages

To stop the interval timer and flush any remaining messages in the queue, call the `stopAndFlush` method:

```typescript
await messageBatcher.stopAndFlush();
```

### Flushing messages manually

You can also manually flush messages using the `flush` method:

```typescript
await messageBatcher.flush();
```

This can be useful if you want to process messages immediately, without waiting for the interval timer to trigger.

## Tests

To run the provided unit tests just execute `npm run tests`.

## License

MIT License

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Support

If you have any issues or questions, please open an issue on the project repository.
npm package: @raphaabreu/nestjs-sync-cqrs
Description: Synchronous event bus for @nestjs/cqrs — awaits all event handlers before returning
Author: Raphael Lorenzeto de Abreu
Latest version: 1.0.0

# @raphaabreu/nestjs-sync-cqrs

Synchronous event bus for `@nestjs/cqrs` — awaits all event handlers before returning, instead of the default fire-and-forget behavior.

## Why?

The default `EventBus` from `@nestjs/cqrs` dispatches events asynchronously via RxJS Subjects. This means the publisher has no way to know when handlers have finished (or failed). `SyncEventBus` overrides `publish()` to await all handlers using `Promise.allSettled`, so:

- Handlers run and complete before the publisher continues.
- Errors in individual handlers are logged but do not prevent other handlers from running.
- You can rely on side-effects being complete after `publish()` resolves.

## Installation

```bash
npm install @raphaabreu/nestjs-sync-cqrs
```

## Usage

Replace `CqrsModule` with `SyncCqrsModule` in your application module:

```typescript
import { Module } from '@nestjs/common';
import { SyncCqrsModule } from '@raphaabreu/nestjs-sync-cqrs';

@Module({
  imports: [SyncCqrsModule],
})
export class AppModule {}
```

That's it. All your existing `@EventsHandler()` decorated classes will now be invoked synchronously when events are published. Commands and queries continue to work exactly as before.

### Using EventBus directly

Since `SyncCqrsModule` provides `SyncEventBus` as both itself and as the `EventBus` token, you can inject either:

```typescript
import { Injectable } from '@nestjs/common';
import { EventBus } from '@nestjs/cqrs';

@Injectable()
export class OrderService {
  constructor(private readonly eventBus: EventBus) {}

  async placeOrder(order: Order) {
    // ... business logic ...

    // All handlers will complete before this resolves
    await this.eventBus.publish(new OrderPlacedEvent(order.id));
  }
}
```

## How it works

`SyncEventBus` extends the `EventBus` from `@nestjs/cqrs` and overrides two methods:

- **`bind()`** — Builds a direct map from event classes to handler instances using `Reflect` metadata, supporting multiple handlers per event type.
- **`publish()`** — Looks up handlers by event constructor, runs them all with `Promise.allSettled`, and logs any rejections.

## License

MIT
npm package: @raphaabreu/promise-collector
Description: Promise Collector is a utility class for managing and tracking a collection of promises
Author: Raphael Lorenzeto de Abreu
Latest version: 1.0.0

# Promise Collector

Promise Collector is a utility class for managing and tracking a collection of promises. It allows you to easily add promises, wrap functions returning promises, and wait for all pending promises to resolve.

## Installation

First, install the package:

```bash
npm i @raphaabreu/promise-collector
```

Then import the `PromiseCollector` class:

```typescript
import { PromiseCollector } from '@raphaabreu/promise-collector';
```

## Usage

Here's an example of how to use the `PromiseCollector` class:

```typescript
const promiseCollector = new PromiseCollector();

// Add a promise to the collection
const promise = new Promise<void>((resolve) => setTimeout(resolve, 100));
promiseCollector.add(promise);

// Wrap a function returning a promise
const asyncFn = async (value: number) => value \* 2;
const wrappedFn = promiseCollector.wrap(asyncFn);

// Execute the wrapped function
const resultPromise = wrappedFn(5);
const result = await resultPromise; // result should be 10

// Wait for all pending promises to resolve
await promiseCollector.pending();
```

## API

`add(promise: Promise<unknown>): void`
Adds a promise to the promises set. The promise will be removed from the set once it's settled (either resolved or rejected).

`wrap<TArgs extends any[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>): (...args: TArgs) => Promise<TReturn>`
Wraps a function that returns a promise, so when the wrapped function is called, its promise is automatically added to the promises set. The promise will be removed from the set once it's settled (either resolved or rejected).

`pending(): Promise<void>`
Returns a promise that resolves when all promises in the promises set have resolved. If there are no pending promises, it resolves immediately.

## Tests

To run the provided unit tests just execute `npm run tests`.

## License

MIT License

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Support

If you have any issues or questions, please open an issue on the project repository.
npm package: @raphaabreu/sns-helper
Description: A utility class that simplifies common SNS related tasks.
Author: Raphael Lorenzeto de Abreu
Latest version: 1.0.0

# SNS Helper

A utility module that simplifies the process of publishing batches of messages to AWS SNS topics with error handling.

## Installation

```bash
npm i @raphaabreu/sns-helper
```

## Usage

First, import the `SNSHelper` class and AWS SDK.

```typescript
import { SNSHelper } from '@raphaabreu/sns-helper';
import * as AWS from 'aws-sdk';
```

Next, create an instance of `SNSHelper`, providing an instance of `AWS.SNS` and optionally an instance of a `StructuredLogger`:

```typescript
import { StructuredLogger } from '@raphaabreu/nestjs-opensearch-structured-logger';

const awsSns = new AWS.SNS();
const logger = new StructuredLogger();
const snsHelper = new SNSHelper(awsSns, logger);
```

### Publish Batch Ignoring Errors

To publish a batch of messages to an SNS topic, use the `publishBatchIgnoringErrors` method:

```typescript
const messages = [{ key: 'value1' }, { key: 'value2' }];
const publishBatchRequestEntries = snsHelper.stringifyBatch(messages);

const params: AWS.SNS.PublishBatchInput = {
  TopicArn: 'arn:aws:sns:us-east-1:123456789012:myTopic',
  PublishBatchRequestEntries: publishBatchRequestEntries,
};

const results = await snsHelper.publishBatchIgnoringErrors(params);
```

### Stringify Batch

To convert an array of objects to an array of `AWS.SNS.PublishBatchRequestEntry`:

```typescript
const batch = [{ key: 'value1' }, { key: 'value2' }];
const publishBatchRequestEntries = snsHelper.stringifyBatch(batch);
```

## Tests

To run the provided unit tests just execute `npm run tests`.

## License

MIT License

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## Support

If you have any issues or questions, please open an issue on the project repository.
npm package: @raphael-08/cli
Description: A CLI tool to generate UI components for your project
Author: raphael-08
Latest version: 1.0.2

# shadcn-Extension

A CLI for adding components to your project, making it easier to integrate and manage UI components within your codebase.

## Installation

To get started with the `shadcn-Extension` CLI, ensure you have `npx` installed. This tool allows you to run packages directly from npm without globally installing them.

## Usage

### Initializing a New Project

Use the `init` command to initialize dependencies for a new project. This command sets up everything you need, including installing necessary dependencies, adding the `cn` utility, configuring `tailwind.config.js`, and setting up CSS variables.

1. **Initialize Dependencies**

   Run the following command to initialize the project:

   ```bash
   npx shadcn-ui init
   ```

2. **Initialize shadcn-Extension CLI**

   Next, set up your project with the shadcn-extension CLI:

   ```bash
   npx @raphael-08/cli init
   ```

### Adding Components

Use the `add` command to add components to your project. This command installs the required dependencies and integrates the specified component into your project.

1. **Add a Specific Component**

   To add a specific component, specify the component name:

   ```bash
   npx @raphael-08/cli add [component]
   ```

   **Example:**

   Adding a `tree-view` component:

   ```bash
   npx @raphael-08/cli add tree-view
   ```

2. **View Available Components**

   If you want to see a list of all available components, run the `add` command without any arguments:

   ```bash
   npx @raphael-08/cli add
   ```

   This will display a list of components that you can add to your project.

## Full Documentation

For detailed documentation, including installation guides, component usage, and more, visit the [shadcn-Extension Documentation](https://shadcn-extension.vercel.app/docs/installation).

## License

This project is licensed under the [MIT license](https://github.com/BelkacemYerfa/shadcn-extension/blob/master/packages/cli/LICENSE.md).

## Contributing

Contributions are welcome! If you have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/BelkacemYerfa/shadcn-extension).