open-index/open-npm huggingface dataset:
npm package: @omtanke/react-use-event-outside
Description: Detect event outside
Author: semihraifgurel
Latest version: 1.0.1

# react-use-event-outside

## Installation

Install with [Yarn](https://yarnpkg.com/):

```sh
yarn add @omtanke/react-use-event-outside
```

Or with [NPM](https://www.npmjs.com/):

```sh
npm i @omtanke/react-use-event-outside
```

Import into your component like so:

```javascript
import useEventOutside from '@omtanke/react-use-event-outside';
```

## Usage

```javascript
useEventOutside(REF, EVENT_NAME, FUNCTION);
```
**REF**: Outside which element you want to trigger.

**EVENT_NAME**: You want to listen to the event (Ex: 'mousedown', 'touchstart', etc.).

**FUNCTION**: The function you want to run when triggered.

### Example

[CodeSandbox](https://codesandbox.io/s/useeventoutside-6gfby?file=/src/App.js)

or

```javascript
const App = () => {
    const ref = useRef(null);
    const [isOpen, setIsOpen] = useState(false);
    
    const closeMenu = useCallback(() => {
        setIsOpen(false);
    }, []);
    
    useEventOutside(ref, 'mousedown', closeMenu);
    
    return (
        <nav className="dropdown" ref={ref}>
            <button onClick={() => setIsOpen(!isOpen)}>Toggle</button>
            {isOpen &&
                <ul className='dropdown-menu'>
                    <li className='dropdown-item'>Item</li>
                    <li className='dropdown-item'>Item</li>
                </ul>    
            }
        </nav>
    );
};
```
npm package: @omts/counting-sort
Description: A simple and efficient implementation of the Counting Sort algorithm in TypeScript. This package provides a stable and linear-time sorting utility that can be used in both Node.js and browser environments.
Latest version: 0.0.4


# @omts/counting-sort 🚀

A simple and efficient implementation of the Counting Sort algorithm in TypeScript. This package provides a stable and linear-time sorting utility that can be used in both Node.js and browser environments.

## Installation 📦

You can install the package via npm or pnpm:

```bash
npm install @omts/counting-sort
```

## Usage ✨

This package exports a `countingSort` function that sorts an array of non-negative integers using the Counting Sort algorithm. Below is an example of how to use it:

```typescript
import { countingSort } from '@omts/counting-sort';

// Example usage
const unsortedArray = [3, 6, 8, 10, 1, 2, 1];
const sortedArray = countingSort(unsortedArray);

console.log(sortedArray); // Output: [1, 1, 2, 3, 6, 8, 10]
```

### Complexity 📊

- **Time Complexity**:
  - **Best, Average, and Worst Case**: O(n + k), where `n` is the number of elements in the input array and `k` is the range of the input.
- **Space Complexity**:
  - **O(n + k)** due to the auxiliary arrays used for counting and output.

## Development 🛠️

- **`dev`**: Cleans and builds the package in watch mode using Bun.

- **`build`**: Runs a clean build by generating multiple module formats (CJS, ESM, UMD) and type declarations.

- **`build:esm`**: Builds the TypeScript source to ES Module (ESM) format.

- **`build:cjs`**: Builds the TypeScript source to CommonJS (CJS) format.

- **`build:umd`**: Builds the TypeScript source to UMD format with a global name `OmtsCountingSort`.

- **`build:types`**: Generates type declaration files using the TypeScript compiler.

- **`test`**: Runs all test cases using Bun. 

## Contributing 🤝

Contributions are welcome! If you have any improvements or suggestions, please feel free to open an issue or submit a pull request.

## License ⚖️

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
npm package: @omts/dag-sort
Description: A lightweight, TypeScript-based utility for performing **topological sorting** on **Directed Acyclic Graphs (DAGs)**. This package allows you to efficiently sort nodes of a DAG, detecting any cycles that might prevent a valid sort.
Latest version: 0.0.1

 # @omts/dag-sort 🚀

A lightweight, TypeScript-based utility for performing **topological sorting** on **Directed Acyclic Graphs (DAGs)**. This package allows you to efficiently sort nodes of a DAG, detecting any cycles that might prevent a valid sort.

## Installation 📦

Install the package via npm or pnpm:

```bash
npm install @omts/dag-sort
```

or

```bash
pnpm add @omts/dag-sort
```

## Usage ✨

This package exports a `topologicalSort` function, which takes a **DAG** represented as an adjacency list and returns a valid topological order. If the graph contains cycles, an error is thrown.

### Example

```typescript
import { topologicalSort } from '@omts/dag-sort';

// Define a directed acyclic graph (DAG)
const graph = new Map<string, string[]>([
    ['A', ['C']],
    ['B', ['C', 'D']],
    ['C', ['E']],
    ['D', ['F']],
    ['E', ['F']],
    ['F', []]
]);

// Perform topological sort
const sorted = topologicalSort(graph);
console.log(sorted); // Output: [ 'B', 'A', 'D', 'C', 'E', 'F' ]
```

### Handling Cycles

If the graph contains a cycle, the `topologicalSort` function will throw an error. This ensures that only valid DAGs are processed.

```typescript
const cyclicGraph = new Map<string, string[]>([
    ['A', ['B']],
    ['B', ['C']],
    ['C', ['A']] // Cycle exists: A -> B -> C -> A
]);

try {
    topologicalSort(cyclicGraph);
} catch (error) {
    console.error(error.message); // Output: Graph has a cycle, topological sort is not possible!
}
```

## API Documentation 📚

### `topologicalSort(graph: Map<string, string[]>): string[]`

- **Parameters**:
  - `graph`: A directed acyclic graph represented as an adjacency list using a `Map<string, string[]>`. Each key represents a node, and its corresponding value is an array of nodes it points to.
  
- **Returns**: An array of nodes in topologically sorted order.

- **Throws**: If a cycle is detected, an error is thrown with the message `"Graph has a cycle, topological sort is not possible!"`.

### Key Features ✨

- **Topological Sorting**: Efficiently sorts DAG nodes in a valid linear order.
- **Cycle Detection**: Automatically detects and throws an error if a cycle is found.
- **TypeScript Support**: Built with TypeScript, ensuring strong typing and type safety.
- **Simple API**: Provides a minimal, easy-to-use API for topological sorting.

## Development 🛠️

### Install dependencies:

```bash
pnpm install
```

### Run tests:

```bash
pnpm run test
```

### Build the project:

```bash
pnpm run build
```

## License ⚖️

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
npm package: @omts/date-utils
Description: A lightweight and efficient utility library for formatting dates and times with optional time zone support in TypeScript. This package simplifies working with date and time formats, allowing customizable formats and automatic time zone detection.
Latest version: 0.0.2

 # @omts/date-utils 🚀

A lightweight and efficient utility library for formatting dates and times with optional time zone support in TypeScript. This package simplifies working with date and time formats, allowing customizable formats and automatic time zone detection.

## Installation 📦

Install the package via npm or pnpm:

```bash
npm install @omts/date-utils
```

or

```bash
pnpm add @omts/date-utils
```

## Usage ✨

This package provides a `formatDateTime` function that allows you to format date strings or `Date` objects into customizable formats with support for time zones.

### Example

```typescript
import { formatDateTime } from '@omts/date-utils';

// Format a date string with the default format
const result = formatDateTime('2024-09-01T12:00:00');
console.log(result); // Output: "2024-09-01 12:00:00"

// Format a Date object with a custom format and time zone
const customResult = formatDateTime(new Date(), { format: 'DD/MM/YYYY', timezone: 'America/New_York' });
console.log(customResult); // Output: "01/09/2024" (in New York timezone)
```

### Options

- **`formatDateTime(input: string | Date, options?: FormatOptions): string`**
  - `input`: The date string or `Date` object to format.
  - `options`: Optional object with formatting options:
    - `format`: The format string (default: `'YYYY-MM-DD HH:mm:ss'`).
    - `timezone`: The time zone (default: user's local time zone).
  - **Returns**: A formatted date string.

### API Documentation 📚

- **`formatDateTime(input, options)`**: Formats a date string or `Date` object to the specified format and time zone.
  - `input`: The date or time string to format.
  - `options`: Optional formatting options, including:
    - `format`: The date format string (default: `'YYYY-MM-DD HH:mm:ss'`).
    - `timezone`: The time zone (default: auto-detected local time zone).
  - **Returns**: The formatted date string.

### Key Features ✨

- **Customizable Format**: Easily format dates and times using customizable format strings.
- **Timezone Support**: Automatically detect or specify time zones when formatting dates.
- **Type Safety**: Designed with TypeScript for strong type safety and reliability.

## Development 🛠️

### Install dependencies:

```bash
pnpm install
```

### Run tests:

```bash
pnpm run test
```

### Build the project:

```bash
pnpm run build
```

## License ⚖️

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
npm package: @omts/quick-sort
Description: A simple and efficient implementation of the Quick Sort algorithm in TypeScript. This package provides a flexible and fast sorting utility that can be used in both Node.js and browser environments.
Latest version: 0.0.4


# @omts/quick-sort 🚀

A simple and efficient implementation of the Quick Sort algorithm in TypeScript. This package provides a flexible and fast sorting utility that can be used in both Node.js and browser environments.

## Installation 📦

You can install the package via npm or pnpm:

```bash
npm install @omts/quick-sort
```

## Usage ✨

This package exports a `quickSort` function that sorts an array of numbers using the Quick Sort algorithm. Below are some examples of how to use it:

```typescript
import { quickSort } from '@omts/quick-sort';

// Example usage
const unsortedArray = [3, 6, 8, 10, 1, 2, 1];
const sortedArray = quickSort(unsortedArray);

console.log(sortedArray); // Output: [1, 1, 2, 3, 6, 8, 10]
```

### Complexity 📊

- **Time Complexity**:
  - **Average Case**: O(n log n)
  - **Worst Case**: O(n^2) - This occurs when the pivot selection is poor (e.g., always choosing the largest or smallest element as pivot in a sorted array).
- **Space Complexity**:
  - **O(log n)** due to the recursion stack in the average case.

## Development 🛠️

- **`dev`**: Cleans and builds the package in watch mode using Bun.

- **`build`**: Runs a clean build by generating multiple module formats (CJS, ESM, UMD) and type declarations.

- **`build:esm`**: Builds the TypeScript source to ES Module (ESM) format.

- **`build:cjs`**: Builds the TypeScript source to CommonJS (CJS) format.

- **`build:umd`**: Builds the TypeScript source to UMD format with a global name `OmtsQuickSort`.

- **`build:types`**: Generates type declaration files using the TypeScript compiler.

- **`test`**: Runs all test cases using Bun. 

## Contributing 🤝

Contributions are welcome! If you have any improvements or suggestions, please feel free to open an issue or submit a pull request.

## License ⚖️

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.