open-index/open-npm huggingface dataset:
npm package: @j-o-r/filesocket
Description: A simple implementation of a Unix domain socket server and client.
Author: Jorrit Duin
Latest version: 1.0.1

## README.md

# FileSocket

FileSocket is a simple implementation of a Unix domain socket server and client using Node.js. 
This project demonstrates how to create a basic inter-process communication (IPC) mechanism using Unix domain sockets. 
The server listens for incoming connections and processes messages, while the client sends messages to the server and handles responses.

## Features

- Simple and lightweight Unix domain socket server and client.
- Asynchronous communication using Promises.
- Error handling and cleanup mechanisms.

## Prerequisites

- Node.js (version 20 or higher)

## Installation


```bash
npm i @j-o-r/filesocket --save
```


## Usage

### Server

The server listens on a Unix domain socket file and processes incoming messages. It uses a custom handler function to process the messages and send responses.

#### Example

```javascript
import FS from '@j-o-r/filesocket';

const socketFile = '/path/to/socket/file.sock';

const server = new FS.server(socketFile, (message) => {
    console.log('Received message:', message);
    server.write(`${message}: Response from server`);
});

// To close the server
// server.close();
```

### Client

The client connects to the Unix domain socket file and sends messages to the server. It waits for the server's response and handles it accordingly.

#### Example

```javascript
import FS from '@j-o-r/filesocket';

const socketFile = '/path/to/socket/file.sock';

const client = new FS.client(socketFile);

client.write('Hello, server!')
    .then(response => {
        console.log('Received response:', response);
    })
    .catch(error => {
        console.error('Error:', error);
    });
```

### Running Tests

The project includes test cases using the `uvu` test framework. To run the tests, use the following command:

```bash
npm test
```

The tests are defined in the `socket.js` file and verify the basic functionality of the server and client.

## File Structure

- `lib/FSClient.js`: Defines the `FSClient` class for the client.
- `lib/FSServer.js`: Defines the `FSServer` class for the server.
- `lib/FileSocket.js`: Imports and exports the `FSServer` and `FSClient` classes.
- `scenarios/socket.js`: Contains test cases for the server and client.

## License

This project is licensed under the APACHE 2.0 License. See the LICENSE file for details.
npm package: @j-o-r/jsonext
Description: Extended JSON, keep typed arrays in their orginal form, backwards compatible with original JSON
Author: Jorrit Duin
Latest version: 1.0.1

# JSONEXT

JSONEXT is an extension to JSON that preserves the data type of typed arrays and BigInts.

## Installation
```bash
npm i @j-o-r/jsonext --save
```

## Usage
### Stringify
To stringify an object with typed arrays:
```javascript
import JSONEXT from '@j-o-r/jsonext'
const typedArray = new Float32Array([1.1, 2.2, 3.3]);
const jsonString = JSONEXT.stringify({ array: typedArray });
console.log(jsonString); // Output: {"array":{"_dT_":"f32a","_dA_":[1.1,2.2,3.3]}}
```

### Parse
To parse a JSON string back into its original form:
```javascript
const parsedObject = JSONEXT.parse(jsonString);
console.log(parsedObject.array instanceof Float32Array); // true
```

## Features
- **Typed Arrays**: Preserves the type of arrays like `Float32Array`, `Int8Array`, etc.
- **BigInt**: Converts BigInt to string representation for JSON compatibility.
- **Compatibility**: Works with standard JSON methods but extends functionality.

## Limitations and Notes:
- Ensure that the `_dT_` and `_dA_` keys do not conflict with your data keys.
- Performance might be impacted for large objects due to type checking.
- Default handling for handling known types in parsing.

## License

This project is licensed under the APACHE 2.0 License. See the LICENSE file for details.
npm package: @j-o-r/toolset
Description: Register and execute Function calls / tools
Author: Jorrit Duin
Latest version: 0.0.4

# ToolSet

A simple JavaScript library for registering and managing function calls/tools. This library can be used stand-alone or in combination with AI functions/calls tools.

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)

## Features

- Register tools/commands/functions with descriptions and parameters.
- Validate tool names.
- List all registered tools.
- Execute registered tools asynchronously.
- Configurable tool choice options (`auto`, `none`, `required`).

## Installation

To install the ToolSet library, you can use npm:

```bash
npm install @j-o-r/toolset --save
```

## Usage

Here is a basic example of how to use the ToolSet library:

```javascript
import ToolSet from 'toolset';

const tools = new ToolSet('auto');

const parameters = {
  type: 'object',
  properties: {
    location: {
      type: 'string',
      description: 'The city and state, e.g. San Francisco, CA'
    },
    unit: {
      type: 'string',
      enum: ["celsius", "fahrenheit"]
    }
  },
  required: ["location"]
};

tools.add(
  'get_current_weather',
  'Get the current weather in a given location',
  parameters,
  async (params) => {
    const res = {
      location: params.location,
      temperature: 24,
      unit: params.unit
    };
    return res;
  }
);

const weather = await tools.call('get_current_weather', { location: 'Den Haag' });
console.log(weather); // { location: 'Den Haag', temperature: 24, unit: undefined }
```

## API

### ToolSet

#### `constructor(choice)`

- `choice` (optional): A string that can be `auto`, `none`, or `required`. Default is `auto`.

#### `add(name, description, parameters, method)`

- `name`: The name of the tool.
- `description`: A brief description of what the tool does.
- `parameters`: A schema object describing the tool's input parameters.
- `method`: An asynchronous function to be called when the tool is executed.

#### `has(name)`

- `name`: The name of the tool.
- Returns `true` if the tool is registered, otherwise `false`.

#### `list()`

- Returns a list of all registered tools.

#### `call(name, params)`

- `name`: The name of the tool to be executed.
- `params`: An object containing the parameters for the tool.
- Returns a promise that resolves with the tool's output.

## License

This project is licensed under the APACHE 2.0 License. See the LICENSE file for details.
npm package: @j-o-r/vdb
Description: In-memory vector embeddings database using embeddings for efficient querying text documents
Author: Jorrit Duin
Latest version: 0.1.0

# In-Memory Vector Embeddings Database

# BETA 

This project provides an in-memory vector embeddings database using embeddings for efficient querying and searching of text documents.

## Description

The project allows you to create, query, and manage an in-memory vector embeddings database. It uses embeddings to represent text documents as vectors, enabling efficient similarity searches.

## Installation

To install the package, use the following command:

```bash
npm install @j-o-r/vdb
```

## Usage

Here is an example of how to use the `Vdb` class to create a database, perform searches, and manage the database:

```javascript
import path from 'path';
import Vdb from '@j-o-r/vdb';

const db = new Vdb('path/to/storage');

// Create a database from a text document
// You only have to do this ones.
// It may take some time
if (!db.list().includes('readme')) {
  const file = path.resolve('README.md');
  await db.create(file, 'readme');
}
// Perform a search in the database
let str = await db.search('readme', 'How to create a database', { treshhold: 0.86,  results: 4, preRead: 1, postRead: 10 });
console.log(str);

// -- Delete a database
// db.delete('readme');
```

## API

### Vdb Class

#### Constructor

```javascript
new Vdb(storagePath)
```

- `storagePath` (string): Path to the storage folder.

#### Methods

- `list()`: Returns a list of available databases.
- `delete(dbName)`: Deletes the specified database.
  - `dbName` (string): Name of the database to delete.
- `create(file, dbName, batchSize)`: Creates or overwrites an embeddings database from a text document.
  - `file` (string): Path to the text document.
  - `dbName` (string): Name of the database.
  - `batchSize` (number, optional): Batch size for processing (default is 256).
- `search(dbName, query, selector)`: Searches the database and returns formatted results.
  - `dbName` (string): Name of the database.
  - `query` (string): Search query.
  - `selector` (object, optional): Selector options.
    - `results` (number): Number of results to return.
    - `preRead` (number): Number of lines to return before the found index.
    - `postRead` (number): Number of lines to return after the found index.
- `getResult(dbName, query, results)`: Gets raw search results from the database.
  - `dbName` (string): Name of the database.
  - `query` (string): Search query.
  - `results` (number, optional): Number of results to return (default is 5).


## License

This project is licensed under the APACHE 2.0 License. See the LICENSE file for details.
npm package: @j-o-r/websocket
Description: A simple implementation of an insecure websocket server and client.
Author: Jorrit Duin
Latest version: 1.0.0

## README.md
# WebSocket

A simple WebSocket server and client library for Node.js.

## Features

- Runs on localhost for local use
- Supports sending and receiving text messages
- Provides a simple API for creating a WebSocket server and client

## Installation

To install the library, use npm:

```bash
npm install @j-o-r/websocket
```

## Usage

### Creating a WebSocket Server

```javascript
import { WebSocket } from '@j-o-r/websocket';

const server = new WebSocket.server(8080, (message) => {
  console.log('Received message:', message);
  server.write('Server response: ' + message);
});
```

### Creating a WebSocket Client

```javascript
import { WebSocket } from '@j-o-r/websocket';

const client = new WebSocket.client(8080);
client.write('Hello, server!').then((response) => {
  console.log('Server response:', response);
});
```

## API

### `WebSocket.server`

- `port`: The port number for the WebSocket server (default: 8080)
- `outhandler`: A function that handles incoming messages from clients

### `WebSocket.client`

- `port`: The port number for the WebSocket server

## Examples

You can find examples in the `scenarios` directory of the repository.


## License

This project is licensed under the [Apache License 2.0](LICENSE).

## License

This project is licensed under the APACHE 2.0 License. See the LICENSE file for details.