open-index/open-npm huggingface dataset:
npm package: @micham/sftp-mock-server
Description: Implementation sftp server on node to use in tests
Latest version: 0.0.6

# sftp-mock-server

![license](https://img.shields.io/github/license/MollardMichael/sftp-mock-server.svg)
[![codecov](https://codecov.io/gh/MollardMichael/sftp-mock-server/branch/master/graph/badge.svg?token=OI6LKGG1R7)](https://codecov.io/gh/MollardMichael/sftp-mock-server)
![Build Status](https://github.com/MollardMichael/sftp-mock-server/actions/workflows/push.yml/badge.svg)

This repository is aimed to provide you with the means to setup and interact with a small sftp server that you can use to run end to end tests in an application using [ssh2-sftp-client](https://www.npmjs.com/package/ssh2-sftp-client) or another node based sftp client. The package is mostly tested against ssh2-sftp-client.

You can check out the API reference [here](https://mollardmichael.github.io/sftp-mock-server/)

## Why should I use this library?

- Written in typescript (fully typed) for seamless integration in typescript based applications and libraries
- Will allow you to run e2e tests using your favorite test framework without the need to setup a real sftp server in your local and CI infrastructure

## Use cases

Mostly e2e tests but you could also run the server as a standalone service in a dev cluster. Just know that the files will be kept in memory so try not to go overboard

## Installation

### Using NPM

```shell
npm install --save-dev @micham/sftp-mock-server
```

### Using Yarn

```shell
yarn add -D @micham/sftp-mock-server
```

## API

### Usage

#### Create a new SFTP server

```typescript
const mockServer = await createSftpMockServer({
  port: '9999',
  hostname: '127.0.0.1',
  debug: (msg: string) => logger.debug(msg),
});
```

#### Connect using a private key

```typescript
const mockServer = await createSftpMockServer({
  port: '9999',
  hostname: '127.0.0.1',
  debug: (msg: string) => logger.debug(msg),
  users: {
    alice: {
      publicKey: clientPublicKey,
    },
  },
});

await data.client.connect({
  host: '127.0.0.1',
  port: 9999,
  username: 'test',
  privateKey: clientPrivateKey,
});
```

#### Write/Read a file to the SFTP server

```typescript
import Client from 'ssh2-sftp-client';

const mockServer = await createSftpMockServer({
  port: '9999',
  hostname: '127.0.0.1',
  debug: (msg: string) => logger.debug(msg),
  users: {
    alice: {
      password: 'password',
      publicKey: clientPublicKey,
    },
  },
});

const client = new Client();
await client.connect({
  host: '127.0.0.1',
  port: 9999,
  username: 'test',
  password: 'test',
});

await client.put(Buffer.from('File content'), 'tmp/data.txt');
const content = await client.get('tmp/data.txt');
```
npm package: @micham/trie-ts
Description: Implementation of trie with search and hasPrefix
Latest version: 0.0.2

# trie-ts

This repository is yet another implementation of a trie in full typescript with a functional approach.
This implementation favor time complexity over space complexity by storing a bit more information than necessary in each node.

A Trie is a Tree Data structure that usually store characters arrays in a way that makes it easy to perform prefix searches.

Example of a trie taken from [Wikipedia](https://en.wikipedia.org/wiki/Trie)

![picture of trie](https://upload.wikimedia.org/wikipedia/commons/b/be/Trie_example.svg)

## Use cases

Here are some use cases in which this library can help you

- You need to check that a word is present in a list of words (Though you could do that with a simple dict)
- You need to check is a word is a prefix of a known word in a dictionary
- You need to check if a given word start with a prefix that is amongst a list of known prefix
- You want to create a custom autocomplete

Using this library, you'll be able to gain performance that will outshine a simple .map on a list of word.

## Installation

### Using NPM

```shell
npm install @micham/trie-ts
```

### Using Yarn

```shell
yarn add @micham/trie-ts
```

## API

This library expose two APIs.

### Base API

The first one is available [here](https://mollardmichael.github.io/trie-ts/modules/index.html) and consist of the following functions

```typescript
/**
 * Create a Trie from a list of words
 */
type MakeTrieFromList = (words: string[]) => Trie;
/**
 * Create a Trie from function argument list
 */
type TrieOfWords = (...words: string[]) => Trie;
/**
 * Add word to Trie
 */
type AddToTrie = (word: string, trie: Trie) => Trie;
/**
 * Remove word from Trie
 */
type RemoveFromTrie = (word: string, trie: Trie) => Trie;
/**
 * Check if word is already in Trie
 */
type HasWord = (word: string, trie: Trie) => boolean;
/**
 * Check all the words that match the query prefix
 */
type SearchPrefix = (query: string, trie: Trie) => string[];
/**
 * Check that the Trie contains at least one prefix of word
 */
type HasPrefix = (word: string, trie: Trie) => boolean;
```

### Pipe-able API

If you are using a library such as fp-ts or any other that allow you to use a "pipe" util, you'll be able to use the second version of the api with a syntax that looks like that

```typescript
import { add, emptyTrie } from '@micham/trie-ts/lib/pipeable';

pipe(
  emptyTrie,
  add('word'),
  add('word1'),
  add('word2'),
  add('word3'),
  add('word4'),
  add('word5'),
  add('word6')
);
```
npm package: @michel005/myux-library
Description: My UX library for NextJS
Author: Michel Douglas Grigoli
Latest version: 2.0.175

# MyUX
## A simple and lightweight UI library for building user interfaces in JavaScript.
[![Node.js Package](https://github.com/michel005/myux/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/michel005/myux/actions/workflows/npm-publish.yml)
npm package: @micheldever/attempt
Description: Simple try-catch-finally code block handler
Latest version: 1.1.0

<div align="center">
  <h1>
    <br />
    <div>@micheldever/attempt</div>
    <br />
  </h1>
  <div>Simple try-catch-finally code block handler</div>
  <br /><br />
  <pre>git clone https://mtsweb@dev.azure.com/mtsweb/oss/_git/attempt</pre>
</div>

## Installation

This package is distributed via npm. You can install it as a dependency in your project by running:

```bash
yarn add @micheldever/attempt
```

## Usage

You can use either the synchronous or asynchronous method to remove any regular `try-catch` calls
within your codebase. Both method return a tuple containing an error object and a result. If the
asserted callback does not throw an error then the `error` index will be `null`. Equally, if an
error is thrown then the `result` index will be `null` instead.

### Synchronous

```typescript
import { attempt } from '@micheldever/attempt';

const [error, result] = attempt(() => myThrowableMethod());
```

### Asynchronous

```typescript
import { attemptAsync } from '@micheldever/attempt';

const [error, result] = await attemptAsync(() => myAsyncThrowableMethod());
```

#### Custom Error Handler

Both methods can also take an optional error handler as a second parameter. This handler will only
be called if the asserted callback throws an error.

```typescript
function customErrorHandler(error: Error) {
  console.log(error);
}

const [error, result] = attempt(() => myThrowableMethod(), customErrorHandler);
const [error, result] = await attemptAsync(() => myAsyncThrowableMethod(), customErrorHandler);
```

### Using `Confirm`

If you need to assert that a condition is true, and throw and error if it is not, you can use the
`confirm` utility function to do so. This accepts a boolean condition as its first parameter and
either a basic `string` error message, or a custom error object as its second.

When providing just a basic error message the resulting error will be thrown as a `TypeError`.

```typescript
import { confirm } from '@micheldever/attempt';

const creature = {
  name: 'dragon',
  type: 'fire',
};

confirm(creature.name === 'dragon', 'creature must be a dragon');
confirm(creature.name === 'dragon', new MyCustomError('creature must be a dragon'));
```

When using the `confirm` method in a TypeScript environment, it also provides the additional
benefit of automatically narrowing the type of a given variable.

```typescript
const value: string | number = await fetchSomeDynamicValue();
// TypeScript thinks `value` could be either a string or a number

confirm(typeof value === 'string', 'value must be a string');
// TypeScript knows `value` must be a string
```
npm package: @micheldever/eslint-config
Description: Micheldever standard style guide ESLint config
Latest version: 1.2.4

<div align="center">
  <h1>
    <br />
    <div>@micheldever/eslint-config</div>
    <br />
  </h1>
  <div>Micheldever standard style guide ESLint config</div>
  <br /><br />
  <pre>git clone https://mtsweb@dev.azure.com/mtsweb/oss/_git/eslint-config</pre>
</div>

## Installation

This package is distributed via npm. You can install it as a devDependency in your project by running:

```bash
yarn add @micheldever/eslint-config --dev
```

## Usage

Once installed, you can use this configuration by extending it in your `.eslintrc.json` file:

```json
{
  "extends": ["@micheldever/eslint-config"]
}
```

If you are using React, you can extend the React configuration:

```json
{
  "extends": ["@micheldever/eslint-config/react"]
}
```
npm package: @micheldever/fetch
Description: Data fetching utility class with simple caching support
Latest version: 1.0.4

<div align="center">
  <h1>
    <br />
    <div>@micheldever/fetch</div>
    <br />
  </h1>
  <div>Data fetching utility class with simple caching support</div>
  <br /><br />
  <pre>git clone https://mtsweb@dev.azure.com/mtsweb/oss/_git/fetch</pre>
</div>

## Installation

This package is distributed via npm. You can install it as a dependency in your project by running:

```bash
yarn add @micheldever/fetch
```

## Usage

After creating a new instance of the `FetchClient`, you can fetch data using the `fetch` method:

```typescript
import { FetchClient } from '@micheldever/fetch';

const client = new FetchClient();
const data = await client.fetch('https://api.example.com/data');
```

The `fetch` method returns a Promise that resolves with the fetched data.

### Caching Responses

`FetchClient` can cache responses to avoid unnecessary network requests. To enable caching, you
need to provide a `StorageEntity` when creating the `FetchClient`:

```typescript
import { FetchClient } from '@micheldever/fetch';
import { MemoryStorageAdapter } from '@micheldever/storage/adapters';
import { StorageEntity } from '@micheldever/storage';

const client = new FetchClient(new StorageEntity(new MemoryStorageAdapter()));
const data = await client.fetch('https://api.example.com/data', { key: ['query'], ttl: 3600000 });
```

In this example, the response will be cached for 3600000 milliseconds (1 hour). If you fetch the
same URL with the same query key within this time, `FetchClient` will return the cached response
instead of making a new network request.

### Invalidating the Cache

You can invalidate a cached response using the `invalidateCache` method:

```typescript
await client.invalidateCache(['query']);
```

### Static `fetch`

For simple data fetching that doesn't require caching you can use the static `fetch` method:

```typescript
const data = FetchClient.fetch('https://api.example.com/data');
```
npm package: @micheldever/mapper
Description: Versatile multi-type mapping utility class
Latest version: 1.0.0

<div align="center">
  <h1>
    <br />
    <div>@micheldever/mapper</div>
    <br />
  </h1>
  <div>Versatile multi-type mapping utility class</div>
  <br /><br />
  <pre>git clone https://mtsweb@dev.azure.com/mtsweb/oss/_git/mapper</pre>
</div>

## Installation

This package is distributed via npm. You can install it as a dependency in your project by running:

```bash
yarn add @micheldever/mapper
```

## Usage

After defining your mapping profiles and creating a new instance of the `Mapper`, you can start mapping your data using either the `map` or `mapMany` methods:

```typescript
import { Mapper } from '@micheldever/mapper';

const profiles = [
  {
    egress: 'number',
    ingress: 'string',
    map: (value: string) => Number.parseInt(value),
  },
];

const mapper = new Mapper(profiles);

// Map a single ingress value
mapper.map('string', '1', 'number');

// Map multiple ingress values
mapper.mapMany('string', ['1', '2'], 'number');
```

### TypeScript

`Mapper` works best with TypeScript. For type safety when using mapping methods, pass the type of your profiles array as a generic argument when creating a new `Mapper` instance. Ensure the profiles array is a `readonly` array that conforms to the `Profile[]` interface.

Please note that the [satisfies](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) operator requires Typescript v4.9+.

```typescript
import { Mapper } from '@micheldever/mapper';
import type { Profile } from '@micheldever/mapper';

const profiles = [
  {
    egress: 'number',
    ingress: 'string',
    map: (value: string) => Number.parseInt(value),
  },
] as const satisfies Profile[];

const mapper = new Mapper<typeof profiles>(profiles);

// Argument of type "string" is not assignable to parameter of type "number"
mapper.map('string', '1', 'string');
```
npm package: @micheldever/storage
Description: Standard storage provider for storing web data
Latest version: 1.0.4

<div align="center">
  <h1>
    <br />
    <div>@micheldever/storage</div>
    <br />
  </h1>
  <div>Standard storage provider for storing web data</div>
  <br /><br />
  <pre>git clone https://mtsweb@dev.azure.com/mtsweb/oss/_git/storage</pre>
</div>

## Installation

This package is distributed via npm. You can install it as a dependency in your project by running:

```bash
yarn add @micheldever/storage
```

## Usage

Create a new `StorageEntity` instance and use it to interact with your storage entries:

```typescript
import { StorageEntity, createStorageEntry } from '@micheldever/storage';
import { MemoryStorageAdapter } from '@micheldever/storage/adapters';

const entity = new StorageEntity(new MemoryStorageAdapter());
```

You can attach one or more storage adapters to your storage instance during initialization.
Alternatively, you can attach additional adapters at any time using the `addAdapter` method.

```typescript
entity.addAdapter(new MemoryStorageAdapter());
```

### Set a value

```typescript
await entity.set('testKey', createStorageEntry('testValue', 10000));
```

Entries stored within a `StorageEntity` can define their own `ttl` in milliseconds. After this time
has elapsed, the next time the value is accessed you will get `undefined` instead. Entries with
a `ttl` of `Infinity` will never expire and will be available indefinitely.

### Retrieve a value

```typescript
const value = await entity.get('testKey');
```

### Delete a value

```typescript
await entity.del('testKey');
```

## Adapters

This package comes preconfigured with two adapters. Additional adapters can be created by
implementing the `StorageAdapter` interface.

- [BrowserStorageAdapter](https://dev.azure.com/mtsweb/oss/_git/storage?path=/src/adapters/browser.ts)
- [MemoryStorageAdapter](https://dev.azure.com/mtsweb/oss/_git/storage?path=/src/adapters/memory.ts)