open-index/open-npm huggingface dataset:
npm package: @jondotsoy/simplerpc
Description: Make a RPC with typescript easily
Latest version: 0.1.2

# SimpleRPC

SimpleRPC is a lightweight RPC (Remote Procedure Call) framework written in TypeScript. It allows you to expose services over HTTP and establish communication between different applications.

> **Note:** This project is designed to work with TypeScript projects. If you need to connect between other languages, please consider using gRCP or other RPC options.

## Features

* Expose services over HTTP using `create-http-serve`
* Establish client connections using `create-http-client`

## Getting Started

To get started with SimpleRPC, follow these steps:

1. Install the required dependencies: `npm install @jondotsoy/simplerpc`
2. Create a new TypeScript file to define your services (e.g., `my-services.ts`)
3. Use the `create-http-serve` function to expose your services over HTTP
4. On the client side, use the `create-http-client` function to connect to the exposed service

## Example Usage

Here's an example of how to use SimpleRPC:

**Server Side (exposing a service)**

```ts
import { createHTTPServer } from "@jondotsoy/simplerpc";
import * as MyServices from "./my-services.js"; 

const router = await createHTTPServer(MyServices);

serve({
  port: 3000,
  fetch: async (r) => (await router.fetch(r)) ?? new Response(null, { status: 404 }),
});
```

**Client Side (connecting to a service)**

```ts
import { createHTTPClient } from "@jondotsoy/simplerpc"; 

const MyServices = await createHTTPClient<typeof import("./my-services.js")>('http://localhost:3000');
```

## License

SimpleRPC is released under the MIT license. Please see [LICENSE](./LICENSE) for more information.
npm package: @jondotsoy/splitg
Description: Splits a string into an array of strings, handling spaces and quotes correctly.
Latest version: 0.6.0

# splitg

Splits a string into an array of strings, handling spaces and quotes correctly.

```ts
splitg(`abc def g`); // => [`abc`, `def`, `g`]
splitg(`run -c "command to run"`); // => [`run`, `-c`, `"command to run"`]
splitg(`this is a json { "name": "ok" } with a property name`); // => [`this`, `is`, `a`, `json`, `{ "name": "ok" }`, `with`, `a`, `property`, `name`]

// Complex sample:
splitg(
  `{ "name": "freed" }\n[ "name", "freed" ]\n[ [ "name", "freed" ],\n[ "age", 44 ] ]`,
  "\n",
);
// => [
//   '{ "name": "freed" }',
//   '[ "name", "freed" ]',
//   '[ [ "name", "freed" ],\n[ "age", 44 ] ]',
// ]
```

Try it here [https://jondotsoy.github.io/splitg/](https://jondotsoy.github.io/splitg/)

## Usage

Install the package [@jondotsoy/splitg](https://www.npmjs.com/package/@jondotsoy/splitg):

```bash
npm i @jondotsoy/splitg
```

### Custom Delimiters

You can specify a custom delimiter to use when splitting the string. This allows you to split strings based on characters other than spaces. The delimiter can be a single character or a string. Quoted strings are still handled correctly, even if they contain the delimiter.

If you pass a delimiter, the function will split the string using that delimiter instead of spaces.

**Example:**

```ts
splitg(`abc~def~g`, "~"); // => [`abc`, `def`, `g`]
```

### Custom Brackets

**Example:**

```ts
splitg(`abc <def ghi> [jkl mno]`, {
  brackets: [["<", ">"]],
}); // => [`abc`, `<def ghi>`, `[jkl`, `mno]`]
```

### Multiple splitters

**Example:**

```ts
splitg(`abc~def ghi jkl~mno`, {
  splitters: ["~", " "],
}); // => [`abc`, `def`, `ghi`, `jkl`, `mno]`]
```

## License

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