open-index/open-npm huggingface dataset:
npm package: @socket.io/aws-sqs-adapter
Description: The Socket.IO adapter for AWS Simple Queue Service (SQS), allowing to broadcast events between several Socket.IO servers
Latest version: 0.1.1

# Socket.IO AWS SQS adapter

The `@socket.io/aws-sqs-adapter` package allows broadcasting packets between multiple Socket.IO servers.

Unlike the existing [`socket.io-sqs`](https://github.com/thinkalpha/socket.io-sqs) package, this package supports binary payloads and dynamic namespaces.

**Table of contents**

- [Supported features](#supported-features)
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options)
- [License](#license)

## Supported features

| Feature                         | `socket.io` version | Support                                        |
|---------------------------------|---------------------|------------------------------------------------|
| Socket management               | `4.0.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Inter-server communication      | `4.1.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Broadcast with acknowledgements | `4.5.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Connection state recovery       | `4.6.0`             | :x: NO                                         |

## Installation

```
npm install @socket.io/aws-sqs-adapter
```

## Usage

```js
import { SNS } from "@aws-sdk/client-sns";
import { SQS } from "@aws-sdk/client-sqs";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/aws-sqs-adapter";

const snsClient = new SNS();
const sqsClient = new SQS();

const io = new Server({
  adapter: createAdapter(snsClient, sqsClient)
});

// wait for the creation of the SQS queue
await io.of("/").adapter.init();

io.listen(3000);
```

## Options

| Name                | Description                                                        | Default value |
|---------------------|--------------------------------------------------------------------|---------------|
| `topicName`         | The name of the SNS topic.                                         | `socket.io`   |
| `topicTags`         | The tags to apply to the new SNS topic.                            | `-`           |
| `queuePrefix`       | The prefix of the SQS queue.                                       | `socket.io`   |
| `queueTags`         | The tags to apply to the new SQS queue.                            | `-`           |
| `heartbeatInterval` | The number of ms between two heartbeats.                           | `5_000`       |
| `heartbeatTimeout`  | The number of ms without heartbeat before we consider a node down. | `10_000`      |

## License

[MIT](LICENSE)
npm package: @socket.io/base64-arraybuffer
Description: Encode/decode base64 data into ArrayBuffers
Author: Niklas von Hertzen
Latest version: 1.0.2

# base64-arraybuffer

![CI](https://github.com/niklasvh/base64-arraybuffer/workflows/CI/badge.svg?branch=master)
[![NPM Downloads](https://img.shields.io/npm/dm/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)
[![NPM Version](https://img.shields.io/npm/v/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)

Forked from https://github.com/niklasvh/base64-arraybuffer

Encode/decode base64 data into ArrayBuffers

### Installing
You can install the module via npm:

    npm install base64-arraybuffer
  
## API
The library encodes and decodes base64 to and from ArrayBuffers

 - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string
 - __decode(str)__ - Decodes base64 string to `ArrayBuffer`

### Testing
You can run the test suite with:

    npm test

## License
Copyright (c) 2012 Niklas von Hertzen
Licensed under the MIT license.
npm package: @socket.io/cluster-adapter
Description: The Socket.IO cluster adapter, allowing to broadcast events between several Socket.IO servers
Latest version: 0.3.0

# Socket.IO cluster adapter

The `@socket.io/cluster-adapter` package allows broadcasting packets between multiple Socket.IO servers.

![Adapter diagram](./assets/adapter.png)

It can be used in conjunction with [`@socket.io/sticky`](https://github.com/socketio/socket.io-sticky) to broadcast packets between the workers of the same Node.js [cluster](https://nodejs.org/api/cluster.html).

Supported features:

- [broadcasting](https://socket.io/docs/v4/broadcasting-events/)
- [utility methods](https://socket.io/docs/v4/server-instance/#Utility-methods)
  - [`socketsJoin`](https://socket.io/docs/v4/server-instance/#socketsJoin)
  - [`socketsLeave`](https://socket.io/docs/v4/server-instance/#socketsLeave)
  - [`disconnectSockets`](https://socket.io/docs/v4/server-instance/#disconnectSockets)
  - [`fetchSockets`](https://socket.io/docs/v4/server-instance/#fetchSockets)
  - [`serverSideEmit`](https://socket.io/docs/v4/server-instance/#serverSideEmit)

Related packages:

- Postgres adapter: https://github.com/socketio/socket.io-postgres-adapter/
- Redis adapter: https://github.com/socketio/socket.io-redis-adapter/
- MongoDB adapter: https://github.com/socketio/socket.io-mongo-adapter/

**Table of contents**

- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## Installation

```
npm install @socket.io/cluster-adapter
```

## Usage

```js
const cluster = require("cluster");
const http = require("http");
const { Server } = require("socket.io");
const numCPUs = require("os").cpus().length;
const { setupMaster, setupWorker } = require("@socket.io/sticky");
const { createAdapter, setupPrimary } = require("@socket.io/cluster-adapter");

if (cluster.isMaster) {
  console.log(`Master ${process.pid} is running`);

  const httpServer = http.createServer();

  // setup sticky sessions
  setupMaster(httpServer, {
    loadBalancingMethod: "least-connection",
  });

  // setup connections between the workers
  setupPrimary();

  // needed for packets containing buffers (you can ignore it if you only send plaintext objects)
  // Node.js < 16.0.0
  cluster.setupMaster({
    serialization: "advanced",
  });
  // Node.js > 16.0.0
  // cluster.setupPrimary({
  //   serialization: "advanced",
  // });

  httpServer.listen(3000);

  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on("exit", (worker) => {
    console.log(`Worker ${worker.process.pid} died`);
    cluster.fork();
  });
} else {
  console.log(`Worker ${process.pid} started`);

  const httpServer = http.createServer();
  const io = new Server(httpServer);

  // use the cluster adapter
  io.adapter(createAdapter());

  // setup connection with the primary process
  setupWorker(io);

  io.on("connection", (socket) => {
    /* ... */
  });
}
```

## License

[MIT](LICENSE)
npm package: @socket.io/component-emitter
Description: Event emitter
Latest version: 3.1.2

# `@socket.io/component-emitter`

  Event emitter component.

This project is a fork of the [`component-emitter`](https://github.com/sindresorhus/component-emitter) project, with [Socket.IO](https://socket.io/)-specific TypeScript typings.

## Installation

```
$ npm i @socket.io/component-emitter
```

## API

### Emitter(obj)

  The `Emitter` may also be used as a mixin. For example
  a "plain" object may become an emitter, or you may
  extend an existing prototype.

  As an `Emitter` instance:

```js
import { Emitter } from '@socket.io/component-emitter';

var emitter = new Emitter;
emitter.emit('something');
```

  As a mixin:

```js
import { Emitter } from '@socket.io/component-emitter';

var user = { name: 'tobi' };
Emitter(user);

user.emit('im a user');
```

  As a prototype mixin:

```js
import { Emitter } from '@socket.io/component-emitter';

Emitter(User.prototype);
```

### Emitter#on(event, fn)

  Register an `event` handler `fn`.

### Emitter#once(event, fn)

  Register a single-shot `event` handler `fn`,
  removed immediately after it is invoked the
  first time.

### Emitter#off(event, fn)

  * Pass `event` and `fn` to remove a listener.
  * Pass `event` to remove all listeners on that event.
  * Pass nothing to remove all listeners on all events.

### Emitter#emit(event, ...)

  Emit an `event` with variable option args.

### Emitter#listeners(event)

  Return an array of callbacks, or an empty array.

### Emitter#hasListeners(event)

  Check if this emitter has `event` handlers.

## License

MIT
npm package: @socket.io/devalue-parser
Description: Socket.IO parser based on devalue
Latest version: 0.1.0


# socket.io-parser

[![Build Status](https://github.com/socketio/socket.io-devalue-parser/workflows/CI/badge.svg)](https://github.com/socketio/socket.io-devalue-parser/actions)

A fork of the default socket.io encoder and decoder, which uses
[devalue](https://github.com/Rich-Harris/devalue) over the vanilla
[JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) object,
for stringifying and parsing JavaScript objects.
This offers many improvements over the default parser, such as support for
dates, maps, sets, regular expressions, `undefined`, custom classes and more.
Check out [devalue](https://github.com/Rich-Harris/devalue) for details.

## Usage

### Server

```js
import * as parser from "@socket.io/devalue-parser";
import { Server } from "socket.io";

const io = new Server({
  parser
});
```

### Client

```js
import * as parser from "@socket.io/devalue-parser";
import { io } from "socket.io-client";

const socket = io({
  parser
});
```

## License

[MIT](LICENSE)
npm package: @socket.io/gcp-pubsub-adapter
Description: The Socket.IO adapter for Google Cloud pub/sub, allowing to broadcast events between several Socket.IO servers
Latest version: 0.1.0

# Socket.IO Google Cloud pub/sub adapter

The `@socket.io/gcp-pubsub-adapter` package allows broadcasting packets between multiple Socket.IO servers.

**Table of contents**

- [Supported features](#supported-features)
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options)
- [License](#license)

## Supported features

| Feature                         | `socket.io` version | Support                                        |
|---------------------------------|---------------------|------------------------------------------------|
| Socket management               | `4.0.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Inter-server communication      | `4.1.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Broadcast with acknowledgements | `4.5.0`             | :white_check_mark: YES (since version `0.1.0`) |
| Connection state recovery       | `4.6.0`             | :x: NO                                         |

## Installation

```
npm install @socket.io/gcp-pubsub-adapter
```

## Usage

```js
import { PubSub } from "@google-cloud/pubsub";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/gcp-pubsub-adapter";

const pubsub = new PubSub({
  projectId: "your-project-id"
});

const topic = pubsub.topic(topicNameOrId);

const io = new Server({
  adapter: createAdapter(topic)
});

// wait for the creation of the pub/sub subscription
await io.of("/").adapter.init();

io.listen(3000);
```

## Options

| Name                  | Description                                                                                                       | Default value  |
|-----------------------|-------------------------------------------------------------------------------------------------------------------|----------------|
| `subscriptionPrefix`  | The prefix for the new subscription to create.                                                                    | `socket.io`    |
| `subscriptionOptions` | The options used to create the subscription.                                                                      | `-`            |
| `heartbeatInterval`   | The number of ms between two heartbeats.                                                                          | `5_000`        |
| `heartbeatTimeout`    | The number of ms without heartbeat before we consider a node down.                                                | `10_000`       |

## License

[MIT](LICENSE)
npm package: @socket.io/sticky
Description: An alternative to the sticky-session package (https://github.com/indutny/sticky-session)
Author: Damien Arrachequesne
Latest version: 1.0.4

# Sticky sessions for Socket.IO

A simple and performant way to use [Socket.IO](https://socket.io/) within a [cluster](http://nodejs.org/docs/latest/api/cluster.html).

Unlike other packages like [sticky-session](https://github.com/indutny/sticky-session), the routing is based on the session ID (the `sid` query parameter).

![Cluster diagram](./assets/socket.io-cluster.png)

See also:

- [sticky-session](https://github.com/indutny/sticky-session) (routing based on `connection.remoteAddress`)
- [socketio-sticky-session](https://github.com/wzrdtales/socket-io-sticky-session) (routing based on the `x-forwarded-for` header)

**Table of contents**

- [Installation](#installation)
- [Usage](#usage)
- [How it works](#how-it-works)
- [Notes](#notes)
- [License](#license)

## Installation

```
npm install @socket.io/sticky
```

## Usage

```js
const cluster = require("cluster");
const http = require("http");
const { Server } = require("socket.io");
const numCPUs = require("os").cpus().length;
const { setupMaster, setupWorker } = require("@socket.io/sticky");
const { createAdapter, setupPrimary } = require("@socket.io/cluster-adapter");

if (cluster.isMaster) {
  console.log(`Master ${process.pid} is running`);

  const httpServer = http.createServer();

  setupMaster(httpServer, {
    loadBalancingMethod: "least-connection", // either "random", "round-robin" or "least-connection"
  });

  setupPrimary();

  httpServer.listen(3000);

  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on("exit", (worker) => {
    console.log(`Worker ${worker.process.pid} died`);
    cluster.fork();
  });
} else {
  console.log(`Worker ${process.pid} started`);

  const httpServer = http.createServer();
  const io = new Server(httpServer);
  io.adapter(createAdapter());
  setupWorker(io);

  io.on("connection", (socket) => {
    /* ... */
  });
}
```

## How it works

The first HTTP request (without `sid` query parameter) is forwarded to a random worker (based on the `loadBalancingMethod` option).

The underlying Engine.IO server creates a new session and emits a `connection` event with the session ID. The worker sends this session ID to the master, which stores the relationship between the worker ID and the session ID.

For subsequent requests, the `sid` query parameter is extracted by the master process, which then forwards the handle to the right worker.

## Notes

- this package is not needed if you only use WebSockets (which might be a sensible choice as of 2021)

```js
// client-side
const socket = io({
  transports: ["websocket"] // HTTP long-polling is disabled
});
```

- in a multi-server setup, you will need to use another adapter, like the [Redis adapter](https://socket.io/docs/v4/redis-adapter/)

![Cluster diagram with Redis](./assets/socket.io-cluster-redis.png)

- this module is not compatible with an HTTPS server

For more information, please see [this issue](https://github.com/socketio/socket.io-sticky/issues/3).

## License

MIT
npm package: @socket.tech/dl-common
Description: common utilities for socket data layer.
Author: akash
Latest version: 1.0.20

# dl-batcher-service

to start server locally,
`npm run start`

to deploy complete service to dev,
`npm run deploy`

to deploy a sepific function (for example if change in apis, can only deploy routeHandler. Similarly if only change in cron timings, can deploy only cronHandler) -
`sls deploy -f cronHandler`

to check logs locally in terminal -
`sls logs -f <function>`

for publishing -
`yarn lint`
`yarn run build`
`npm publish`
npm package: @socket.tech/socket-v2-sdk
Description: -> [Docs](https://socketdottech.github.io/socket-v2-sdk-docs/) <-
Author: rugamoto
Latest version: 1.24.2

# Socket v2 SDK

-> [Docs](https://socketdottech.github.io/socket-v2-sdk-docs/) <-

## Install

- `yarn add @socket.tech/socket-v2-sdk`

  or

- `npm i @socket.tech/socket-v2-sdk`

## Usage

In summary:

- Initialise the sdk:
  ```ts
  const socket = new Socket({ apiKey: API_KEY });
  ```
- Retrieve the token lists

  ```ts
  const tokenList = await socket.getTokenList({
    fromChainId: 1,
    toChainId: 137,
  });

  // tokenList.from has list of from tokens
  // tokenList.to has list of to tokens
  ```

- Create a path
  ```ts
  const path = new Path({ fromToken, toToken });
  ```
- Get quote
  ```ts
  const quote = await socket.getBestQuote({
    path,
    amount,
    address,
  }, { ... Any quote preferences here })
  ```
- You have 2 options for executing a quote. Managing the steps yourself or connecting a web3 provider.

- Connecting web3 provider:
  ```ts
  const provider = new ethers.providers.Web3Provider(window.ethereum); // Or use wallet provider like onboard, web3modal, web3react etc.
  const connectedSocket = socket.connect(provider);
  await connectedSocket.start(quote, {
    onTx: (tx) => {
      console.log('Executing transaction', tx);
      return (tx) => {
        console.log('Done transaction', tx);
      }
    }
    ... // Other callbacks
  });
  ```
- Handle the steps manually

  ```ts
  const execute = await socket.start(quote);
  let next = await execute.next();

  while (!next.done && next.value) {
    const tx = next.value;
    const approvalTxData = await tx.getApproveTransaction();
    // ... if there is approval send the approve and wait

    const sendTxData = await tx.getSendTransaction();
    // ... send the tx and execute next

    next = await execute.next(sendTx.hash);
  }
  ```

### Direct api communication

All api functions are available through the typescript client

```ts
const socket = new Socket(API_KEY);
const activeRoute = await socket.client.routes.getActiveRoute({ activeRouteId: 1234 });
```

## Test

- USDC Polygon to BSC
  `PRIVATE_KEY="<YOUR_PRIVATE_KEY_WITH_GT_15_USDC>" npx ts-node examples/1_usdc_poly_to_bsc.ts`

Other examples [here](/examples/)