open-index/open-npm huggingface dataset:
npm package: @konfirm/expressionist
Description: Prepare strings for use in RegExp objects
Author: Rogier Spieker
Latest version: 1.0.7

# Expressionist
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fa6e844754f24c208f28522f9bb9fe1b)](https://www.codacy.com/app/konfirm/node-expressionist?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=konfirm/node-expressionist&amp;utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/konfirm/node-expressionist.svg?branch=master)](https://travis-ci.org/konfirm/node-expressionist)

Simple helper to perform basic preparations on strings to use them in Regular Expressions.

## Getting started

### Installation

```
$ npm install --save @konfirm/expressionist
```

### Usage

```
const Expressionist = require('@konfirm/expressionist');
```

#### `Expressionist.ungroup`
Replace potential capture groups with non-capture groups, while leaving existing non-capture groups (`(?:...)`) and lookaheads (positive (`(?=...)`) and negative (`(?!...)`)) intact.

```
const ungrouped = Expressionist.ungroup('(hello(world))');

console.log(ungrouped);  //  '(?:hello(?:world))
```

#### `Expressionist.escape`
Escape all characters with a special meaning in Regular Expressions so that these can be matched exactly

```
const escaped = Expressionist.escape('john.doe+label@example.com');

console.log(escaped);  //  'john\.doe\+label@example\.com'
```


## Licence

MIT License

Copyright (c) 2017 Konfirm

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
npm package: @konfirm/kontract
Description: Class extender contracts
Author: Rogier Spieker
Latest version: 1.0.0

# Kontract

Register, verify and compose "contracts" (classes) to allow for contract checks with class compositions.

## Installation

As Kontract is a scoped package, the scope needs to be provided for both the installation and usage

```
$ npm install --save @konfirm/kontract
```

## Usage

The Kontract component exposes three functions; `register`, `compose` and `has`.

### `register(...extenders)`

Register a class extender as Kontract, this is a required step to be able to determine the implementation later on using `has`

```js
const { register } = require('@konfirm/kontract');

const Foo = register(
	(superclass) =>
		class extends superclass {
			get foo() {
				return 'I am foo';
			}
		}
);
const Bar = register(
	(superclass) =>
		class extends superclass {
			get bar() {
				return 'I am bar';
			}
		}
);
```

### `compose(...extenders)`

Compose a new class using class extender functions, if these are `register`ed before, they will be detectable. If the very first argument is a class (instead of an extender function) that class will be used as base class.

```js
const { compose } = require('@konfirm/kontract');

//  assuming Foo and Bar from the register example
const FooBar = compose(
	Foo,
	Bar
);
```

### `has(target, ...extenders)`

Has determines whether the provided target (which can be both a class or an instance) was extended by _all_ of the provided extenders.

```js
const { has } = require('@konfirm/kontract');

//  assuming Foo and Bar from the register example
//  assuming FooBar from the compose example
const foobar = new FooBar();

console.log(has(FooBar, Foo)); //  true
console.log(has(FooBar, Bar)); //  true
console.log(has(FooBar, Foo, Bar)); //  true

if (has(foobar, Foo)) {
	console.log(foobar.foo); //  'I am foo'
}
if (has(foobar, Bar)) {
	console.log(foobar.bar); //  'I am bar'
}
```

# License

MIT License Copyright (c) 2019 Rogier Spieker (Konfirm)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
npm package: @konfirm/reference
Description: Easily work with multi-/singleton instances
Author: Rogier Spieker
Latest version: 1.0.0

# Reference

Working with guaranteed unique but reusable (singletons) can be somehwat of a hassle, as there's always the risk of accidentally creating a memory leak and the logic to keep track of references using [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) is highly repetative (as in, the same for most references).

# Installation

```
$ npm install --save @konfirm/reference
```

# Usage

In itself Reference doesn't do anything other than providing the static factory method `for`, so it has to be extended in order to provide meaningful purpose.

```js
const Reference = require('@konfirm/reference');

class Proof extends Reference {
	constructor(name) {
		super();

		this.name = name;
		this.date = new Date();
	}
}

const target = {};
const proof = Proof.for(target, 'Exhibit A');
```

## API

The API of the Reference class consists of just the `for` method, which provides an instance of the Reference (extend). If an instance does not exist (yet or anymore) it will be created.

All references are stored using [WeakMaps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and because of that unused references are removed from memory.

### `Reference.for(<object> target [, ...arguments])`

Obtains a Reference (extend) instance for the provided target object, if no instance exists it will be created.

## License

MIT License Copyright (c) 2019 Rogier Spieker (Konfirm)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
npm package: @konforti/react-truncate
Description: Long text truncation
Author: Raz Konforti
Latest version: 1.1.0

# ✂️ React Truncate

> React wrapper for [@konforti/truncate](https://github.com/konforti/truncate)

## ✨ Features

-   Truncate text by number of lines.
-   Truncate form end, start or middle.
-   Responsive truncation.
-   Get notified if a text has been truncated or not.
-   Custom ellipsis.

## 🔧 Installation

```bash
npm i -S @konforti/react-truncate
```

```bash
yarn add @konforti/react-truncate
```

## 🔧 Usage

```js
import Truncate from '@konforti/react-truncate';
```

## 🔦 Examples

```js
<Truncate truncFrom="middle">{text}</Truncate>
```

```js
<Truncate lines={3}>{text}</Truncate>
```

```js
<Truncate ellipsis=">>> " truncFrom="start">
    {text}
</Truncate>
```

```js
<Truncate
    onTruncate={truncated => {
        if (truncated) {
            setState({ truncated: true });
        }
    }}
>
    {text}
</Truncate>
```
npm package: @konforti/truncate
Description: Long text truncation
Author: Raz Konforti
Latest version: 1.0.1

# ✂️ Truncate long texts by number of lines

## ✨ Features

-   Truncate text by number of lines.
-   Truncate form end, start or middle.
-   Custom ellipsis.

## 🔧 Installation

```bash
npm i -S @konforti/truncate
```

```bash
yarn add @konforti/truncate
```

## ✏️ Usage

```js
import truncate from '@konforti/truncate';

const res = truncate(
    longTextWrapper,
    longText, // default "".
    lines, // default 1.
    truncFrom, // default "end".
    ellipsis, // default "...".
    wrapperOffset // default 5
);
```

## 🔖 Types Definition

```js
function truncate(
    longTextWrapper: HTMLElement,
    longText: string
    lines: number
    truncFrom: 'start' | 'middle' | 'end'
    ellipsis:  string
    wrapperOffset:  number
): {text: string, truncated: boolean} {}
```
npm package: @konforti/wasm-truncate
Description: truncate texts on the web using wasm-bindgen
Author: Raz Konforti
Latest version: 0.0.3

# wasm truncate

> truncate texts by number of lines using [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen).

## Installation

```bash
    npm i -S @konforti/wasm-truncate
```

## Usage

```js
const truncate = async (elementId: string, lines: number) => {
    const module = await import('@konforti/wasm-truncate');
    module.run(elementId, lines);
};

truncate('long-text', 1);
```

## Development

```bash
# Once
rustup target add wasm32-unknown-unknown
cargo +nightly install wasm-bindgen-cli
```

```bash
# Run example
npm start
```
npm package: @konforti/worker
Description: <!-- <div align="center">   <img   width="1000"   src="examples/worker.png" alt="worker"> </div> -->
Author: Raz Konforti
Latest version: 1.0.3

<!-- <div align="center">
  <img
  width="1000"
  src="examples/worker.png" alt="worker">
</div> -->

# ⚙️ Worker

## ✨ Features:

-   Move a function into a web worker.
-   Supports async function.
-   Accept any [structured clone types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#Supported_types.) as arguments.
-   Accept **functions** as arguments.

See [Non blocking example](https://codesandbox.io/s/8x82oz2vz2)

## 🔧 Installation

```bash
    npm i -S @konforti/worker
```

```bash
    yarn add @konforti/worker
```

## ✏️ Usage

```js
import worker from '@konforti/worker';
```

## 🔦 Usage examples

```js
// Function in worker

function fibo(n) {
    return n > 1 ? fibo(n - 1) + fibo(n - 2) : 1;
}

const run = worker(fibo);
run(333).then(res => console.log(res));
```

```js
// Async function in worker

const run = worker(async username => {
    const url = `https://api.github.com/users/${username}/repos`;
    const res = await fetch(url);
    const repos = await res.json();
    return repos.map(r => r.full_name);
});

run('konforti').then(res => console.log(res));
```

```js
// Pass a callback function as argument

const fn = callback => `First we take Manhattan, ${callback()}`;
const run = worker(fn);
run(() => 'Then we take Berlin.').then(res => console.log(res));
```

```js
// Inject imported function into worker scope

import mathModule from './math.js';

const calc = (sum, times) => {
    const a = sum(2, 3);
    const b = times(4, 5);
    return sum(a, b);
};

const run = worker(calc);
run(mathModule.sum, mathModule.times).then(res => console.log(res));
```

## 🔏 Limitations

The function and any argument passes cannot rely on its surrounding scope, since it is executed in an isolated context.