open-index/open-npm huggingface dataset:
npm package: @mistakster/readable-stream-tokenizer
Description: Promise based tokenizer for a ReadableStream
Author: Vladimir Kuznetsov
Latest version: 1.3.3

# readable-stream-tokenizer

## Description

This module provides a `Tokenizer` class that facilitates the reading of binary data from a ReadableStream.
It allows for reading various types of data such as Uint32 and Uint8Array from the stream asynchronously.

## Usage

To use this module, first, import it into your project:

```javascript
import { Tokenizer } from '@mistakster/readable-stream-tokenizer';
```

Then, you can create an instance of the `Tokenizer` class by passing a ReadableStream as a parameter:

```javascript
const tokenizer = new Tokenizer(stream);
```

## Methods

### `readUint32()`

Reads an Uint32 value from the stream and returns a Promise resolving to the read Uint32 value.

### `readUint8Array(length)`

Reads a Uint8Array of specified length from the stream and returns a Promise resolving to the read Uint8Array.

* `length`: The length of the Uint8Array to read. 

## Example

```javascript
import { Tokenizer } from '@mistakster/readable-stream-tokenizer';

async function readUrl(url, abortController) {
  const res = await fetch(url, {
    signal: abortController.signal
  });

  const tokenizer = new Tokenizer(res.body);

  try {
    const uint32Value = await tokenizer.readUint32();
    console.log("Read Uint32 value:", uint32Value);

    const uint8Array = await tokenizer.readUint8Array(10);
    console.log("Read Uint8Array:", uint8Array);
  } catch (error) {
    console.error("Error occurred:", error);
  }
}
```

## Error Handling

Errors that may occur during reading from the stream are handled within the module.
If the stream is finished before the expected data is read, a `FinishedStreamError` is thrown.

## Note

Ensure that the environment supports ES modules (`import/export` syntax) for using this module.

## License

MIT
npm package: @mistakster/rxjs-mongodb
Description: A helper which creates an Observable from MongoDB connection
Author: Vladimir Kuznetsov
Latest version: 2.0.0

# rxjs-mongodb

It's the proper way to get a MongoDB Client as an Observable. 

## Motivation

It’s quite tricky to convert a connection to a MongoDB server to an Observable. A stream should meet the following requirements:

1. It must emit an event with the instance only once.
2. It must emit any errors.
3. It must wait until the disconnection.

Also, the client must disconnect from the server if no subscription currently exists.

## Usage

```javascript

const client$ = connectMongoDb(MONGODB_URL, MONGODB_OPTS);

const data$ = client$.pipe(
  map(client => client.db(MONGODB_DATABASE)),
  map(db => db.collection('items')),
  map(items => items.find({ value: { $gte: 0.5 } })),
  map(cursor => cursor.transformStream()),
  mergeMap(streamToRx)
);

data$.subscribe(datum => {
  console.log(datum._id);
});
```

## License

MIT
npm package: @mistakster/text-search
Description: A library to filter an array of objects by text content
Author: Vladimir Kuznetsov
Latest version: 2.0.1

# text-search

## Overview

This code contains a simple search library that allows you to create a search function
to find items in a list based on specific fields and perform a ranked search based
on a query string.

Prepare your data as a list of objects, where each object represents an item you want
to search through. Each object should have properties corresponding to the fields you
want to use for search.

The search function will return a list of items that match the query, sorted by relevance.
The relevance is determined based on the position of the query tokens in the items' fields.

The display field is used to determine the order of items with equal relevance scores.
It ensures that the search results are consistently ordered, and if no display field
is provided, the first field specified in the field parameter will be used instead.
The display field can be handy when you want to give priority to certain fields for
sorting purposes in cases where multiple items have the same relevance to the query.

## Example

```ts
import { createSearch } from '@mistakster/text-search';

const indexer = createSearch('title'); // ['title', 'description']

const search = indexer([
  {
    title: 'Star Wars: Episode IV - A New Hope',
    description: `Luke Skywalker joins forces with a Jedi Knight,
      a cocky pilot, a Wookiee and two droids to save the galaxy from
      the Empire's world-destroying battle station, while also attempting
      to rescue Princess Leia from the mysterious Darth Vader.`
  },
  {
    title: 'Star Wars: Episode V - The Empire Strikes Back',
    description: `After the Rebels are brutally overpowered by
      the Empire on the ice planet Hoth, Luke Skywalker begins Jedi
      training with Yoda, while his friends are pursued by Darth Vader
      and a bounty hunter named Boba Fett all over the galaxy.`
  },
  {
    title: 'Star Wars: Episode VI - Return of the Jedi',
    description: `After a daring mission to rescue Han Solo from Jabba the Hutt,
      the Rebels dispatch to Endor to destroy the second Death Star. Meanwhile,
      Luke struggles to help Darth Vader back from the dark side without falling
      into the Emperor's trap.`
  }
]);

const results = search('Jedi');
```
npm package: @mistcash/crypto
Description: MIST Cryptographic Operations
Latest version: 0.2.2
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @mistcash/crypto

MIST Cryptographic Operations

## Installation

```sh
pnpm add @mistcash/crypto
```

## Usage

```js
import { txSecret, txHash } from '@mistcash/crypto';

// read tx from secret
const asset = await contract.read_tx(await txSecret(valKey, valTo))

// tx hash for merkle stuff
const tx_hash = await txHash(valKey, valTo, tokenAddr, amount)
```

## Contributing

Head over to https://github.com/mistcash/sdk for details.

## License

MIT
npm package: @mistenkt/use-rest-api
Description: A customizable REST Api and data manager hook for your React application
Author: mistenkt
Latest version: 1.0.12

# use-rest-api
A customizable REST Api and data manager hook for your React application

## Installation
`yarn add @mistenkt/use-rest-api`

## Usage

1. Initialize the `ApiProvider` in your `App.js` file and provide the required params.

    ````jsx harmony
   import React from 'react';
   import {ApiProvider} from '@mistenkt/use-rest-api';
   
   const apiResources = {
       users: {
           endpoint: '/user'
       },
       posts: {
           endpoint: '/post',
       }
   };
   
   const App = () => {
       return (
           <ApiProvider
               baseUrl="https://locahost/api"
               resources={apiResources}
           >
               {/* The rest of your app*/}
           </ApiProvider>
       )
   };
   
   export default App;
    ````
    
2. Use the `useApi` hook inside your containers/components that want to consume api data

    ````jsx harmony
   import React from 'react';
   import {useApi} from '@mistenkt/use-rest-api';
   
   const UserIndex = () => {
       const [users, loading, update, reset] = useApi('users.list');
       
       if(loading) return (
           <div>Loading...</div>
       )
       
       if(!users && !loading) return (
           <div>No users</div>
       )
   
       return (
           <ul>
               {users.map(user => (
                   <li key={user.id}>{user.name}</li>
               ))}
           </ul>
       )   
   }
   
   export default UserIndex;
   ````
   
3. To send create/update request to the api use the `useProducer` hook.

    ````jsx harmony
   import React from 'react';
   import {useApi, useProducer} from '@mistenkt/use-rest-api';
   
   const UserIndex = () => {
       const [users, loading] = useApi('users.list');
       const [produce, produceLoading, validationErrors] = useProducer({
           onSuccess: data => console.log('Success callback', data),
           onFail: err => console.log('Fail callback', data),
           onValidationError: errors => console.log('Validation error callback', errors)
       });
   
       const createUser = () => {
           produce('users.create', {
               name: 'foo'
           })
       };
       
       if(loading) return (
           <div>Loading...</div>
       )
       
       if(!users && !loading) return (
           <div>No users</div>
       )
   
       return (
           <>
               <ul>
                   {users.map(user => (
                       <li key={user.id}>{user.name}</li>
                   ))}
               </ul>
               <button onClick={createUser}>Create user</button>
           </>
       )   
   }
   
   export default UserIndex;
   ````
   
## Api Documentation

Ful api documentation coming soon.

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)