open-index/open-npm huggingface dataset:
npm package: @js-nerds/batch-collector
Description: Lightweight TypeScript batch collector with delayed flush and optional persistence.
Latest version: 0.1.1

# @js-nerds/batch-collector

[![npm version](https://img.shields.io/npm/v/@js-nerds/batch-collector)](https://www.npmjs.com/package/@js-nerds/batch-collector)
[![npm downloads](https://img.shields.io/npm/dm/@js-nerds/batch-collector)](https://www.npmjs.com/package/@js-nerds/batch-collector)
[![tests](https://github.com/js-nerds/batch-collector/actions/workflows/build-test.yml/badge.svg?branch=main&label=tests)](https://github.com/js-nerds/batch-collector/actions/workflows/build-test.yml)
[![coverage](https://codecov.io/gh/js-nerds/batch-collector/branch/main/graph/badge.svg)](https://codecov.io/gh/js-nerds/batch-collector)

Lightweight TypeScript batch collector with delayed flush, optional timer reset, and local/session storage persistence.

## Install

```bash
npm install @js-nerds/batch-collector
```

```bash
pnpm add @js-nerds/batch-collector
```

```bash
yarn add @js-nerds/batch-collector
```

## Usage

```ts
import { BATCH_FLUSH_EVENT, BatchCollector } from "@js-nerds/batch-collector";

const collector = new BatchCollector<{ action: string; id: string }>({
	delayMs: 5000,
	resetTimerOnPush: true,
	storageType: "localStorage",
	storageKey: "my-app-log-batch"
});

collector.subscribe(BATCH_FLUSH_EVENT, (items) => {
	console.log("Flush:", items);
});

collector.push({ action: "button_click", id: "submit-btn" });
collector.push({ action: "menu_open", id: "profile" });
```

## API

### `new BatchCollector(config)`

Creates a collector instance.

**Config**
- `delayMs: number` — delay before flush.
- `resetTimerOnPush?: boolean` — reset timer on every push (default `true`).
- `storageType?: "memory" | "localStorage" | "sessionStorage"` — where to keep pending batch (default `"memory"`).
- `storageKey?: string` — key for local/session storage (default `"batch-collector-pending"`).
- `autoClear?: boolean` — clear after timer flush (default `true`).

### `subscribe(event, callback)`

Subscribes to collector events.

**Params**
- `event: string` — use `BATCH_FLUSH_EVENT` (`"flush"`).
- `callback: (items: T[]) => void`

**Returns**
- `() => void` — unsubscribe function.

### `push(item)`

Adds item to batch and schedules flush.

### `items()`

Returns a shallow copy of current batch.

### `clear()`

Clears timer, in-memory batch, and persisted batch.

## License

MIT

## Changelog

See `CHANGELOG.md`.
npm package: @js-nerds/browser-csv-txt-downloader
Description: Client-side TypeScript utility to download CSV and TXT files in the browser
Latest version: 0.1.0

# @js-nerds/browser-csv-txt-downloader

[![npm version](https://img.shields.io/npm/v/@js-nerds/browser-csv-txt-downloader)](https://www.npmjs.com/package/@js-nerds/browser-csv-txt-downloader)
[![npm downloads](https://img.shields.io/npm/dm/@js-nerds/browser-csv-txt-downloader)](https://www.npmjs.com/package/@js-nerds/browser-csv-txt-downloader)
[![tests](https://github.com/js-nerds/browser-csv-txt-downloader/actions/workflows/build-test.yml/badge.svg?branch=main&label=tests)](https://github.com/js-nerds/browser-csv-txt-downloader/actions/workflows/build-test.yml)
[![coverage](https://codecov.io/gh/js-nerds/browser-csv-txt-downloader/branch/main/graph/badge.svg)](https://codecov.io/gh/js-nerds/browser-csv-txt-downloader)

Client-side TypeScript utility to download CSV and TXT files in the browser.

## Install

```bash
npm install @js-nerds/browser-csv-txt-downloader
```

```bash
pnpm add @js-nerds/browser-csv-txt-downloader
```

```bash
yarn add @js-nerds/browser-csv-txt-downloader
```

## Usage

```ts
import { downloadCsvFile, downloadTextFile } from "@js-nerds/browser-csv-txt-downloader";

downloadCsvFile(
  [
    { name: "Alice", age: 30 },
    { name: "Bob", age: 25 }
  ],
  {
    fileName: "users.csv",
    columns: [
      { key: "name", header: "Name" },
      { key: "age", header: "Age" }
    ]
  }
);

downloadTextFile({
  fileName: "note.txt",
  content: "Hello from browser"
});
```

## API

### `downloadFile(options)`

Downloads file by selected format (`csv` or `txt`).
This package is browser-only. In non-browser environments (SSR/Node.js), the function returns `false`.

**BOM defaults (`includeBom`)**
- CSV: default is `true` (BOM is included unless `includeBom: false` is passed).
- TXT: default is `false` (BOM is included only when `includeBom: true` is passed).
- You can always override the default per call via `includeBom`.

Examples:

```ts
downloadCsvFile(rows, {
  fileName: "users.csv",
  columns,
  includeBom: false
});

downloadTextFile({
  fileName: "note.txt",
  content: "Hello",
  includeBom: true
});
```

**Returns**
- `boolean` — `true` if download started, `false` when browser APIs are unavailable.

### `downloadCsvFile(rows, options)`

Compatibility wrapper for CSV export.

### `downloadTextFile(options)`

Convenience wrapper for TXT export.

## License

MIT

## Changelog

See `CHANGELOG.md`.
npm package: @js-nerds/version-compare
Description: Tiny utility to compare version strings.
Latest version: 0.1.0

# @js-nerds/version-compare

[![npm version](https://img.shields.io/npm/v/@js-nerds/version-compare)](https://www.npmjs.com/package/@js-nerds/version-compare)
[![npm downloads](https://img.shields.io/npm/dm/@js-nerds/version-compare)](https://www.npmjs.com/package/@js-nerds/version-compare)
[![tests](https://github.com/js-nerds/version-compare/actions/workflows/build-test.yml/badge.svg?branch=main&label=tests)](https://github.com/js-nerds/version-compare/actions/workflows/build-test.yml)
[![coverage](https://codecov.io/gh/js-nerds/version-compare/branch/main/graph/badge.svg)](https://codecov.io/gh/js-nerds/version-compare)

Tiny utility to compare version strings.

## Install

```bash
npm install @js-nerds/version-compare
```

```bash
pnpm add @js-nerds/version-compare
```

```bash
yarn add @js-nerds/version-compare
```

## Usage

```ts
import { isVersionLessThanOrEqual, toVersionParts } from "@js-nerds/version-compare";

isVersionLessThanOrEqual("25.2.1", "25.2.1"); // true
isVersionLessThanOrEqual("25.2.2", "25.2.1"); // false
toVersionParts("1.2.3"); // [1, 2, 3]
```

## API

### `isVersionLessThanOrEqual(version, threshold)`

Compares two version strings and returns `true` when `version` is less than or equal to `threshold`.
Missing or invalid versions are treated as old.

**Params**
- `version: string | null` — version to check
- `threshold: string` — minimum supported version

**Returns**
- `boolean`

### `toVersionParts(value)`

Converts a version string into numeric parts.
Invalid segments are returned as `-1`.

**Params**
- `value: string` — version string

**Returns**
- `number[]`

## License

MIT

## Changelog

See `CHANGELOG.md`.
npm package: @js-next/json-rpc
Description: 前端json-rpc
Author: 19040733
Latest version: 1.1.3

## 使用

具体查看DEMO [点击预览](https://unpkg.com/@js-next/json-rpc@1.1.3/demo/server.html)
### 原生方案
```html
<!-- 注意： 不要在files:// 打开 建议在localhost:// 打开 -->
<!-- server.html -->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf8" />
    <title>server</title>
    <script src="https://unpkg.com/@js-next/json-rpc@1.1.3/dist/json-rpc.umd.min.js"></script>
  </head>
  <body>
    server： 打印请看控制台
    <iframe id="iframe" src="./client.html" width="800" height="600"></iframe>
    <script>
      const { RPCServer } = window.jsonRPC
      RPCServer.export({ // 添加函数，可以提交已有函数
        foo(id){
          console.log('foo call', id)
          return id + 2
        },
        bar(name, id) {
          console.log('bar call', name, id)
          return name + id + 'bar call'
        }
      }).listen()
    </script>
  </body>
</html>
<!-- 客户端-->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf8" />
    <title>client</title>
    <script src="https://unpkg.com/@js-next/json-rpc@1.1.3/dist/json-rpc.umd.min.js"></script>
  </head>
  <body>
    client： 打印请看控制台
    <script>
      (async () => {
        const { RPCClient }  = window.jsonRPC
        const rpcClient = new RPCClient(parent)
        const r1 = await rpcClient.foo(1)
        console.log(r1)
        const r2 = await rpcClient.bar('xxx', 'yyy')
        console.log(r2)
      })()
    </script>
  </body>
</html>

```
具体查看DEMO [点击预览](https://unpkg.com/@js-next/json-rpc@1.1.3/demo/server.html)

### npm方式
#### 安装扩展
```shell
npm install -S @js-next/json-rpc
```
#### 代码调用
```javascript
  // server.js
  import { RPCServer } from '@js-next/json-rpc'
  RPCServer.export({ // 添加函数，可以提交已有函数
    foo(id: number){
      console.log('foo call', id)
      return id + 2
    },
    bar(name: string, id: string) {
      console.log('bar call', name, id)
      return name + id + 'bar call'
    }
  }).listen()

  // client.js
  import { RPCClient } from '@js-next/json-rpc'
  const rpcClient = new RPCClient(parent) as any
  const r1 = await rpcClient.foo(1)
  console.log(r1)
  const r2 = await rpcClient.bar('xxx', 'yyy')
  console.log(r2)
  
```
npm package: @js-ni/sony-android-tv-control
Description: Sony Android TV Control
Author: Paulo McNally
Latest version: 0.0.2

# Sony Android TV Control

BRAVIA™ Professional DisplayKnowledge Center.

NodeJS client for REST API over HTTP.

Not official.

https://pro-bravia.sony.net/develop/integrate/rest-api/spec/

# Preparation

https://pro-bravia.sony.net/develop/integrate/rest-api/spec/getting-started/

# API List
- [ ] getApplicationList
- [ ] getApplicationStatusList
- [ ] getCurrentExternalInputsStatus
- [ ] getCurrentTime
- [ ] getInterfaceInformation
- [ ] getLEDIndicatorStatus
- [ ] getNetworkSettings
- [ ] getPlayingContentInfo
- [ ] getPowerSavingMode
- [ ] getPowerStatus
- [ ] getPublicKey
- [ ] getRemoteControllerInfo
- [ ] getRemoteDeviceSettings
- [ ] getSpeakerSettings
- [ ] getSupportedApiInfo
- [ ] getSystemInformation
- [ ] getSystemSupportedFunction
- [ ] getTextForm
- [ ] getVolumeInformation
- [ ] getWebAppStatus
- [ ] getWolMode
- [ ] requestReboot
- [ ] setActiveApp
- [x] [setAudioMute](examples/setAudioMute.js)
- [x] [setAudioVolume](examples/setAudioVolume.js)
- [ ] setLEDIndicatorStatus
- [ ] setPlayContent
- [ ] setPowerSavingMode
- [x] [setPowerStatus](examples/setPowerStatus.js)
- [ ] setSceneSetting
- [ ] setSoundSettings
- [ ] setSpeakerSettings
- [ ] setTextForm
- [ ] setWolMode
- [ ] terminateApps
npm package: @js-ninja/dom-class
Description: A library for simplified manipulation of DOM classes in JavaScript.
Latest version: 1.0.52

# DomClass Library

## README.md

-   ru [Русский](readme/README.ru.md)

## Description

The DomClass library provides a class for managing CSS classes of elements. With it, you can easily add, remove, and modify classes of elements on your web page.

## Installation

You can install the DomClass library using npm or yarn by executing the following command:

```bash
npm install @js-ninja/dom-class
```

or

```bash
yarn add @js-ninja/dom-class
```

## Usage

To use the DomClass library, you need to import the `DomClass` class and use its methods. Here's an example of importing and using each method of the class:

```javascript
import DomClass from "dom-class";

// Adding CSS classes to an element
DomClass.add(element, "class1", "class2");

// Adding CSS classes to all immediate child elements of a parent element
DomClass.addChild(parentElement, "class1", "class2");

// Adding CSS classes to elements matching the specified selector
DomClass.addBySelector(".selector", "class1", "class2");

// Removing CSS classes from an element
DomClass.remove(element, "class1", "class2");

// Removing CSS classes from all immediate child elements of a parent element
DomClass.removeChild(parentElement, "class1", "class2");

// Removing CSS classes from elements matching the specified selector
DomClass.removeBySelector(".selector", "class1", "class2");

// Removing all CSS classes from an element
DomClass.removeAll(element);

// Toggling a CSS class on an element
DomClass.toggle(element, "class", true);

// Toggling CSS classes on all immediate child elements of a parent element
DomClass.toggleChild(parentElement, "class", true);

// Toggling CSS classes on elements matching the specified selector
DomClass.toggleBySelector(".selector", "class", true);

// Checking if an element has a CSS class
const containsClass = DomClass.contains(element, "class");

// Checking if all elements matching the specified selector have all the CSS classes
const containsAllClasses = DomClass.containsAll(".selector", "class");

// Replacing one CSS class with another on an element
DomClass.replace(element, "oldClass", "newClass");

// Replacing one CSS class with another on all elements matching the specified selector
DomClass.replaceBySelector(".selector", "oldClass", "newClass");
```

## License

The DomClass library is licensed under the [MIT License](/LICENSE).
npm package: @js-ninja/list
Description: A library for simplified work with arrays and DOM collections in JavaScript.
Latest version: 1.0.18

# List Library

The List Library provides a class for managing an array or a DOM collection.

## README.md

-   ru [Русский](readme/README.ru.md)

## Installation

You can install the List Library using npm or yarn by executing the following command:

```bash
npm install @js-ninja/list
```

or

```bash
yarn add @js-ninja/list
```

## Usage

To use the library, you need to import the List class. Here's an example import statement:

```javascript
import List from "list-library";
```

### The `each` method

The `each` method allows you to efficiently iterate over an array or a DOM collection. It takes the following parameters:

-   `arr` - an array, NodeList, or HTMLCollection to iterate over.
-   `cb` - a function that is called for each element. It takes the following parameters:
    -   `item` - the list item.
    -   `index` - the index of the item.
    -   `arr` - the list.
-   `breakOn` (optional) - the index at which the function will stop execution.

Example usage of the `each` method:

```javascript
const arr = [1, 2, 3, 4, 5];

List.each(arr, (item, index) => {
    console.log(item); // Outputs each element of the array
});
```

### The `filter` method

The `filter` method allows you to efficiently filter an array or a DOM collection. It takes the following parameters:

-   `arr` - an array, NodeList, or HTMLCollection to filter.
-   `cb` - a function that is called for each element. It takes the following parameters:
    -   `item` - the list item.
    -   `index` - the index of the item.
    -   `arr` - the list.
-   Returns the filtered array.

Example usage of the `filter` method:

```javascript
const arr = [1, 2, 3, 4, 5];

const filtered = List.filter(arr, (item) => item % 2 === 0);

console.log(filtered); // Outputs [2, 4]
```

### The `map` method

The `map` method allows you to efficiently transform an array or a DOM collection. It takes the following parameters:

-   `arr` - an array, NodeList, or HTMLCollection to transform.
-   `cb` - a transformation function for each element. It takes the following parameters:
    -   `item` - the item from the original list.
    -   `index` - the index of the item.
    -   `array` - the original list.
-   Returns the resulting array.

Example usage of the `map` method:

```javascript
const arr = [1, 2, 3, 4, 5];

const doubled = List.map(arr, (item) => item * 2);

console.log(doubled); // Outputs [2, 4, 6, 8, 10]
```

## License

The List Library is distributed under the [MIT License](/LICENSE).
npm package: @js-ninja/map-storage
Description: Efficient TypeScript key-value storage using Map.
Latest version: 1.0.9

# MapStorage Library

## README.md

-   ru [Русский](readme/README.ru.md)

## Description

The MapStorage library provides a class for storing key-value data using Map.

## Installation

You can install the MapStorage library using npm or yarn by executing the following command:

```bash
npm install @js-ninja/map-storage
```

or

```bash
yarn add @js-ninja/map-storage
```

## Usage

To use the MapStorage library, you need to import the class and each method of the class:

```javascript
import MapStorage from "@js-ninja/map-storage";

const storage = new MapStorage();

// Get a value by key
const value = storage.get(key);

// Set a value for a key
storage.set(key, value);

// Update a value by key
storage.update(key, updater);

// Merge values from an array
storage.mergeArray(arr);

// Merge values from another MapStorage instance
storage.mergeMapStorage(otherStorage);

// Clear the storage
storage.clear();

// Delete a value by key
storage.delete(key);

// Check if a value exists for a key
const hasValue = storage.has(key);

// Get the keys in the storage
const keys = storage.keys();

// Get the values in the storage
const values = storage.values();

// Get the entries in the storage as an array [key, value]
const entries = storage.toArray();

// Get the number of entries in the storage
const size = storage.size();

// Create a copy of the current MapStorage instance
const clone = storage.clone();

// Execute a function for each entry in the storage
storage.each(callback);

// Get a new MapStorage instance containing only the entries that satisfy the predicate
const filteredStorage = storage.filter(predicate);

// Get a new MapStorage instance containing the results of applying the mapper function to each entry
const mappedStorage = storage.map(mapper);
```

## License

The MapStorage library is distributed under the [MIT License](/LICENSE).