open-index/open-npm huggingface dataset:
npm package: @subspace/jump-consistent-hash
Description: Jump consistent hash implementation in TypeScript
Author: Nazar Mokrynskyi
Latest version: 1.1.1

# Jump-consistent hash implementation
Read https://arxiv.org/abs/1406.2294 for details, this package works with 64-bit/8-byte inputs in form of `Uint8Array`s.

## How to install
```
npm install @subspace/jump-consistent-hash
```

NOTE: Requires Node.js v12+ or modern browser with BigInt support

## How to use
TypeScript:
```typescript
import {randomBytes} from 'crypto';
import {jumpConsistentHash} from '@subspace/jump-consistent-hash';

const bucket = jumpConsistentHash(randomBytes(8), 10);
```

## API
### jumpConsistentHash.jumpConsistentHash(key: Uint8Array, numBuckets: number): number
Takes a key and number of buckets and returns bucket from range `[0, numBuckets)`.

* `key` - 8 bytes key
* `numBuckets` - number of buckets to which keys should be distributed
npm package: @subspace/rendezvous-hash
Description: Rendezvous hash implementation in TypeScript
Author: Nazar Mokrynskyi
Latest version: 0.0.2

# Rendezvous hash implementation
Read https://en.wikipedia.org/wiki/Rendezvous_hashing for details, this package works with 64-bit/8-byte inputs in form of `Uint8Array`s.

## How to install
```
npm install @subspace/rendezvous-hash
```

## How to use
TypeScript:
```typescript
import {randomBytes} from 'crypto';
import {Destination, pickDestinations} from '@subspace/rendezvous-hash';

const destinations: Destination[] = [
    new Destination(randomBytes(8)),
    new Destination(randomBytes(8)),
];
const keys: Uint8Array[] = [
    randomBytes(8),
    randomBytes(8),
    randomBytes(8),
    randomBytes(8),
    randomBytes(8),
];

for (const key of keys) {
    const destination = pickDestinations(key, destinations)[0];
    console.log(destination.id)
}

```

## API
### rendezvousHash.pickDestinations(keyHash: Uint8Array, destinations: Destination[], k: number = 1): Uint8Array[]
Takes a key and an array of potential destinations and returns `k` closest destinations to that key.

* `keyHash` - 8 bytes hash of the key
* `destinations` - an array of destination objects that are potential candidates
* `k` - how many closest destinations for specified key to return

Returns an array of IDs of keys (first argument to `Destination` object below).

### rendezvousHash.Destination(readonly id: Uint8Array, readonly weight: number = 1)
Class that encapsulates information about particular destination.

`id` and `weight` are pubic readonly properties of resulting object
npm package: @subspace/sloth-permutation
Description: Sloth permutation (modular square root) for JavaScript (TypeScript) using WebAssembly, originally from https://github.com/randomchain/pysloth
Author: Nazar Mokrynskyi
Latest version: 0.1.0

# sloth-permutation
Sloth permutation (modular square root) for JavaScript (TypeScript) using WebAssembly, originally from https://github.com/randomchain/pysloth

### How to install
```bash
npm install @subspace/sloth-permutation
```

### How to use
```typescript
import {createHash} from "crypto";
import {SlothPermutation} from "@subspace/sloth-permutation";

(async () => {
    const blockSize = 64;
    const rounds = 5;
    const primeInput = createHash('sha512')
        .update('subspace')
        .digest();
    const dataBlock = createHash('sha512')
        .update('subspace-data')
        .digest();

    const data = Buffer.concat([dataBlock, dataBlock]);

    const encoderDecoder = await SlothPermutation.instantiate(primeInput, blockSize, rounds);

    console.log('Data:', data.toString('hex'));

    for (let i = 0; i < 5; ++i) {
        const encodedData = encoderDecoder.encode(data);
        console.log('Encoded data:', Buffer.from(encodedData).toString('hex'));

        const decodedData = encoderDecoder.decode(encodedData);
        console.log('Decoded data:', Buffer.from(decodedData).toString('hex'));
        console.log('Decoded correctly: ', data.join(',') === decodedData.join(','));
    }

    encoderDecoder.destroy();
})();
```

### License
MIT, see license.txt
npm package: @subsquid/apollo-server-core
Description: Core engine for Apollo GraphQL server
Author: Apollo
Latest version: 3.14.0

# apollo-server-core

[![npm version](https://badge.fury.io/js/apollo-server-core.svg)](https://badge.fury.io/js/apollo-server-core)
[![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apollo-server)

This package implements the core logic of Apollo Server. It exports a base version of `ApolloServer`. Typically you do not use this class directly but instead use an `ApolloServer` imported from the batteries-included `apollo-server` package or one of the integration packages like `apollo-server-express`.

It also exports a set of plugins such as `ApolloServerPluginUsageReporting` which you can provide to the `plugins` option to the `ApolloServer` constructor.

[Read the docs.](https://www.apollographql.com/docs/apollo-server/)
[Read the CHANGELOG.](https://github.com/apollographql/apollo-server/blob/main/CHANGELOG.md)
npm package: @subsquid/apollo-server-express
Description: Production-ready Node.js GraphQL server for Express
Author: Apollo
Latest version: 3.14.1

[![npm version](https://badge.fury.io/js/apollo-server-express.svg)](https://badge.fury.io/js/apollo-server-express)
[![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apollo-server)
[![Join the community forum](https://img.shields.io/badge/join%20the%20community-forum-blueviolet)](https://community.apollographql.com)
[![Read CHANGELOG](https://img.shields.io/badge/read-changelog-blue)](https://github.com/apollographql/apollo-server/blob/HEAD/CHANGELOG.md)


This is the Express integration of Apollo Server. Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. [Read the docs](https://www.apollographql.com/docs/apollo-server/). [Read the CHANGELOG.](https://github.com/apollographql/apollo-server/blob/main/CHANGELOG.md)


A full example of how to use `apollo-server-express` can be found in [the docs](https://www.apollographql.com/docs/apollo-server/integrations/middleware/#apollo-server-express).

Before Apollo Server 3, we officially supported using this package with `connect` as well. `connect` is an older framework that `express` evolved from. For now, we believe that this package is still compatible with `connect` and we even run tests against `connect`, but we may choose to break this compatibility at some point without a major version bump. If you rely on the ability to use Apollo Server with `connect`, you may wish to make your own integration.

## Principles

GraphQL Server is built with the following principles in mind:

* **By the community, for the community**: GraphQL Server's development is driven by the needs of developers
* **Simplicity**: by keeping things simple, GraphQL Server is easier to use, easier to contribute to, and more secure
* **Performance**: GraphQL Server is well-tested and production-ready - no modifications needed

Anyone is welcome to contribute to GraphQL Server, just read [CONTRIBUTING.md](https://github.com/apollographql/apollo-server/blob/main/CONTRIBUTING.md), take a look at the [roadmap](https://github.com/apollographql/apollo-server/blob/main/ROADMAP.md) and make your first PR!