open-index/open-npm huggingface dataset:
npm package: @packula/eslint-config
Description: The ESLint configuration used by Packula repositories
Author: Erin Millard
Latest version: 1.1.1

# Packula ESLint configuration

## Installation

- Available as NPM module `@packula/eslint-config`
- Needs lots of peer dependencies because of [an ESLint limitation]

## Usage

```js
// .eslintrc.js
module.exports = {
  extends: [
    '@packula',
  ],
}
```

<!-- References -->

[an eslint limitation]: https://github.com/eslint/eslint/issues/3458
npm package: @packula/jest-config
Description: The Jest configuration used by Packula repositories
Author: Erin Millard
Latest version: 1.0.1

# Packula Jest configuration

[![Current version][badge-version-image]][badge-version-link]

[badge-version-image]: https://img.shields.io/npm/v/@packula/jest-config?label=%40packula%2Fjest-config&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/jest-config

## Usage

```js
// jest.config.js
module.exports = require('@packula/jest-config')
```
npm package: @packula/regexp
Description: Utility functions for working with regular expressions
Author: Erin Millard
Latest version: 0.2.0

# Packula regular expression utilities

[![Current version][badge-version-image]][badge-version-link]
[![Bundle size][badge-bundle-image]][badge-bundle-link]
[![Build status][badge-build-image]][badge-build-link]
[![Test coverage][badge-coverage-image]][badge-coverage-link]

[badge-build-image]: https://img.shields.io/github/workflow/status/packula/regexp/CI?style=for-the-badge
[badge-build-link]: https://github.com/packula/regexp/actions/workflows/ci.yml
[badge-bundle-image]: https://img.shields.io/bundlephobia/minzip/@packula/regexp?style=for-the-badge
[badge-bundle-link]: https://bundlephobia.com/result?p=@packula/regexp
[badge-coverage-image]: https://img.shields.io/codecov/c/gh/packula/regexp?style=for-the-badge
[badge-coverage-link]: https://codecov.io/gh/packula/regexp
[badge-version-image]: https://img.shields.io/npm/v/@packula/regexp?label=%40packula%2Fregexp&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/regexp

## API

### `escape (literal: string) => string`

Returns an escaped version of a string for use in a regular expression.
npm package: @packula/rollup-config
Description: The Rollup configuration used by Packula repositories
Author: Erin Millard
Latest version: 1.1.1

# Packula Rollup configuration

[![Current version][badge-version-image]][badge-version-link]

[badge-version-image]: https://img.shields.io/npm/v/@packula/rollup-config?label=%40packula%2Frollup-config&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/rollup-config

## Usage

```js
// rollup.config.js
import {createConfig} from '@packula/rollup-config'
import packageJson from './package.json'

export default createConfig(packageJson)
```
npm package: @packula/router-path
Description: A simple, light-weight, type-safe router path implementation
Author: Erin Millard
Latest version: 0.2.1

# Packula router path

[![Current version][badge-version-image]][badge-version-link]
[![Bundle size][badge-bundle-image]][badge-bundle-link]
[![Build status][badge-build-image]][badge-build-link]
[![Test coverage][badge-coverage-image]][badge-coverage-link]

[badge-build-image]: https://img.shields.io/github/workflow/status/packula/router-path/CI?style=for-the-badge
[badge-build-link]: https://github.com/packula/router-path/actions/workflows/ci.yml
[badge-bundle-image]: https://img.shields.io/bundlephobia/minzip/@packula/router-path?style=for-the-badge
[badge-bundle-link]: https://bundlephobia.com/result?p=@packula/router-path
[badge-coverage-image]: https://img.shields.io/codecov/c/gh/packula/router-path?style=for-the-badge
[badge-coverage-link]: https://codecov.io/gh/packula/router-path
[badge-version-image]: https://img.shields.io/npm/v/@packula/router-path?label=%40packula%2Frouter-path&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/router-path
npm package: @packula/router-path-extras
Description: Additional parameter types for Packula router path
Author: Erin Millard
Latest version: 0.1.0

# Packula router path extras

[![Current version][badge-version-image]][badge-version-link]
[![Bundle size][badge-bundle-image]][badge-bundle-link]
[![Build status][badge-build-image]][badge-build-link]
[![Test coverage][badge-coverage-image]][badge-coverage-link]

[badge-build-image]: https://img.shields.io/github/workflow/status/packula/router-path-extras/CI?style=for-the-badge
[badge-build-link]: https://github.com/packula/router-path-extras/actions/workflows/ci.yml
[badge-bundle-image]: https://img.shields.io/bundlephobia/minzip/@packula/router-path-extras?style=for-the-badge
[badge-bundle-link]: https://bundlephobia.com/result?p=@packula/router-path-extras
[badge-coverage-image]: https://img.shields.io/codecov/c/gh/packula/router-path-extras?style=for-the-badge
[badge-coverage-link]: https://codecov.io/gh/packula/router-path-extras
[badge-version-image]: https://img.shields.io/npm/v/@packula/router-path-extras?label=%40packula%2Frouter-path-extras&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/router-path-extras
npm package: @packula/tsconfig
Description: The TypeScript configuration used by Packula repositories
Author: Erin Millard
Latest version: 1.0.2

# Packula TypeScript configuration

[![Current version][badge-version-image]][badge-version-link]

[badge-version-image]: https://img.shields.io/npm/v/@packula/tsconfig?label=%40packula%2Ftsconfig&logo=npm&style=for-the-badge
[badge-version-link]: https://npmjs.com/package/@packula/tsconfig

## Usage

```jsonc
// tsconfig.json
{
  "extends": "@packula/tsconfig"
}
```
npm package: @packy-tang/md2docx
Description: Markdown to docx command tool
Author: packy-tang
Latest version: 1.0.3

# md2docx


[![npm version](https://img.shields.io/npm/v/@packy-tang/md2docx.svg)](https://www.npmjs.com/package/@packy-tang/md2docx)
![](https://img.shields.io/node/v/@packy-tang/md2docx)
[![NPM downloads](http://img.shields.io/npm/dm/@packy-tang/md2docx.svg)](https://www.npmjs.com/package/@packy-tang/md2docx)

> Markdown to docx command tool

## Features

将Markdown格式文档转换为Word文档内容。转换过程是 `md-> html -> mhtm -> docx`。参考 [evidenceprime/html-docx-js](https://github.com/evidenceprime/html-docx-js) 思路进行设计。

## 安装（Install）

```sh
$ npm i -g @packy-tang/md2docx
```

## 使用（How to Use）

### 命令行

```sh
$ md2docx -h
Usage: md2docx [options] <string>

Markdown to docx command tool

Arguments:
  string                    Markdown File

Options:
  -v, --version             version
  -o, --outputDir <string>  output path
  -h, --help                display help for command
```

## 使用例子

```sh
$ md2docx test.md
# 在test.md同目录下生产产出 test.docx 文件

$ mkdir dist/
$ md2docx -o dist/ test.md
# 指定 dist/ 作为产出目录，test.docx 文件会在dist目录中
```

## 开发（Develop）

```sh
# 更新nodejs版本
$ npm run nvm

# 更改你的代码，运行下面代码进行转换测试
$ node src/example.js

# 运行下面代码进行命令行测试
$ npm link
$ md2docx test.md
```

## License

Copyright (c) packy-tang [<lpreterite@126.com>](https://github.com/lpreterite)

根据[MIT协议](./LICENSE)的开源软件.

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Flpreterite%2Fmd2docx.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Flpreterite%2Fmd2docx?ref=badge_large)
npm package: @packy-tang/qiniu-uploader
Description: 基于现代浏览器的七牛上传前端插件
Author: packy-tang
Latest version: 1.0.0

# qiniu-uploader

基于现代浏览器的七牛上传前端插件

- [x] 生成唯一名
- [x] 分片上传
- [x] 断点续传

## How to use

```js
//打开文件选择器
const token = "七牛上传授权token"
uploader.openFinder(async (files, uploader)=>{
    const fileKey = await uploader.getFileKey(file)
    uploader.upload(fileKey, files[0], { token })
});

//手动取消上传
uploader.cancel()
```

## 功能

```js
//初次化
uploader.init(options)
//打开文件选择框
uploader.openFinder((files,uploader)=>{})
//获得文件唯一名
uploader.getFileKey(file)
//上传文件
uploader.upload(fileKey, file, options)
//取消文件上传
uploader.cancel(fileKey)
//清除文件分片缓存
uploader.clean(fileKey)

// options
const options = {
    url: '',                         //上传地址
    blockSize: 1<<22,                //分块大小
    chunkSize: 1<<20,                //分片大小
    cookiePrefix: 'QINIU_UPLOAD::',  //缓存cookie前缀
    token: '',                       //上传凭证
    onValid({file, fileKey}, uploader)=>{ return [] },                                                   //文件检测钩子
    onBeforeUpload({file, fileKey}, uploader)=>{ return {file,fileKey} },                                //文件上传前钩子
    onUploadProgress({fileKey, loaded, total, progressStage, progressValue, blockIndex}, uploader)=>{},  //文件上传中钩子
    onUploaded({fileKey, result}, uploader)=>{},                                                         //文件上传成功钩子
    onFail((errors, { isCancel }, uploader)=>{})                                                                   //上传失败钩子
}
```

## 疑问与坑

1. 目前分片上传三接口（mkblock、bput、mkfile）均不能捕获错误码（具体原因是未查明，只知道xhr.status为0并提示链接请求错误，如：ERR_CONTENT_LENGTH_MISMATCH），遇到此类情况统一返回错误（信息头为000的错误信息）
2. 单个文件上传的文件名称不需要UrlsafeBase64处理
npm package: @packy-tang/vue-tinymce
Description: A simple vue-based tinymce component
Author: packy-tang
Latest version: 1.1.2


![vue-tinymce](docs/assets/vu-tinymce-logo.png)

# vue-tinymce

[![npm version](https://img.shields.io/npm/v/@packy-tang/vue-tinymce.svg)](https://www.npmjs.com/package/@packy-tang/vue-tinymce)
![vue](https://img.shields.io/github/package-json/dependency-version/lpreterite/vue-tinymce/vue)
![tinymce](https://img.shields.io/github/package-json/dependency-version/lpreterite/vue-tinymce/tinymce)
[![NPM downloads](http://img.shields.io/npm/dm/@packy-tang/vue-tinymce.svg)](https://www.npmjs.com/package/@packy-tang/vue-tinymce)

> 已支持**vue3**。`npm i @packy-tang/vue-tinymce@next` 就可使用vue3版本支持。

提供给 vue 开发者使用的 TinyMCE 组件

## 目的

为开发人员简单使用 TinyMCE 的 Vue 组件。提供非常简单易懂的源代码提供给开发人员作为参考，当然你也可以直接使用这个组件到你的项目。发现问题可以提到 issue，期望你的反馈 👏。

## 如何使用

### 安装组件

```sh
yarn add @packy-tang/vue-tinymce
# or
npm install @packy-tang/vue-tinymce
```

### 引入

```html
<template>
    <!-- 全局引入TinyMCE -->
    <script src="//unpkg.com/tinymce@5.1.5/tinymce.min.js"></script>
    <!-- App -->
    <div id="app">
        <vue-tinymce
            v-model="content"
            :setup="setup"
            :setting="setting" />
    </div>
</template>
<script>
    import Vue from "vue"
    import VueTinymce from "@packy-tang/vue-tinymce"

    //安装组件
    Vue.use(VueTinymce)

    new Vue({
        el: "#app",
        data: function() {
            return {
                content: "<p>html content</p>",
                setting: {
                    height: 500
                }
            }
        },
        methods: {
            setup(editor) {
                console.log(editor)
            }
        }
    })
</script>
```

### 其他使用例子

- vue-cli使用例子：[传送门](https://github.com/lpreterite/vue-tinymce-example/tree/master/vue)
- webpack使用例子：传送门(待补上)

## 属性

| 名称       | 描述                                                  |
| ---------- | ----------------------------------------------------- |
| `:content`   | 类型`String`，作为文本内容传入编辑器，可以使用`v-model`实现双向绑定 |
| `@change`   | 类型`Function`，编辑器中`Input` `Change` `Undo` `Redo` `ExecCommand` `KeyUp` `NodeChange`事件响应后触发的事件返回文本内容                  |
| `:setting` | 类型`Object`，编辑器的设置，`setup`不建议在这设置     |
|`:setup`| 类型`Function`, 常用与自定义编辑器处理，组件内部做了些处理，建议在这里添加自定义的代码 |

## 更多使用细节

想了解更多内容请移步至[使用细节](http://lpreterite.github.io/vue-tinymce/#/Example)
npm package: @pacote/array
Description: Extra Array functions.
Author: Luís Rodrigues
Latest version: 0.10.1

# @pacote/array

![version](https://badgen.net/npm/v/@pacote/array)
![minified](https://badgen.net/bundlephobia/min/@pacote/array)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/array)

Extra Array functions.

## Installation

```bash
yarn add @pacote/array
```

## Documentation

API documentation for [`@pacote/array`](https://pacotejs.github.io/pacote/modules/_pacote_array.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/bloom-search
Description: Document search using Bloom filters.
Author: Luís Rodrigues
Latest version: 0.18.1

# @pacote/bloom-search

![version](https://badgen.net/npm/v/@pacote/bloom-search)
![minified](https://badgen.net/bundlephobia/min/@pacote/bloom-search)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/bloom-search)

Document search using [Bloom filters](../bloom-filter/).

This module was created to support basic full-text search on static sites
where a backend-supported search feature isn't possible, and loading a
complete index on the client is too expensive.

Bloom filters are used because they trade result accuracy for space
efficiency. With them, false positive matches are possible, but false
negatives are not. That is to say, its responses are either a _certain miss_
or a _possible match_.

They allow building a simple document search index that is smaller than
inverted indices at the cost of occasionally returning matches for words that
are not present in any document. This error rate can be adjusted to improve
search quality.

Due to the limitations inherent in Bloom filters, only full, individual words
can be matched against indexed documents while searching. The absence of
partial matching can be remedied through the use of a custom stemmer
function, but more "advanced" features like suffix matching cannot be
performed at all.

See [how several client-side search engines compare against Bloom
Search](https://goblindegook.github.io/bloom-search-poc/).

## Installation

```bash
yarn add @pacote/bloom-search
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/buckwalter
Description: Buckwalter Arabic transliteration.
Author: Luís Rodrigues
Latest version: 0.1.1

# @pacote/buckwalter

![version](https://badgen.net/npm/v/@pacote/buckwalter)
![minified](https://badgen.net/bundlephobia/min/@pacote/buckwalter)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/buckwalter)

Buckwalter Arabic transliteration.

## Installation

```bash
npm install @pacote/buckwalter
```

## Documentation

API documentation for [`@pacote/buckwalter`](https://pacotejs.github.io/pacote/modules/_pacote_buckwalter.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/computus
Description: Determine the calendar date of the Easter holiday.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/computus

![version](https://badgen.net/npm/v/@pacote/computus)
![minified](https://badgen.net/bundlephobia/min/@pacote/computus)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/computus)

Determine the calendar date of the Easter holiday.

## Installation

```bash
yarn add @pacote/computus
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/disposable
Description: Create disposable resources for Explicit Resource Management.
Author: Luís Rodrigues
Latest version: 0.2.1

# @pacote/disposable

![version](https://badgen.net/npm/v/@pacote/disposable)
![minified](https://badgen.net/bundlephobia/min/@pacote/disposable)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/disposable)

Create disposable resources for [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management).

## Installation

```bash
yarn add @pacote/disposable
```

## Documentation

API documentation for [`@pacote/disposable`](https://pacotejs.github.io/pacote/modules/_pacote_disposable.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/emitter
Description: Minimalistic event emitter.
Author: Luís Rodrigues
Latest version: 3.0.1

# @pacote/emitter

![version](https://badgen.net/npm/v/@pacote/emitter)
![minified](https://badgen.net/bundlephobia/min/@pacote/emitter)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/emitter)

Minimalistic event emitter.

## Installation

```bash
yarn add @pacote/emitter
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/error
Description: Functional errors.
Author: Luís Rodrigues
Latest version: 4.0.0

# @pacote/error

![version](https://badgen.net/npm/v/@pacote/error)
![minified](https://badgen.net/bundlephobia/min/@pacote/error)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/error)

Custom error classes and utilities.

## Installation

```bash
yarn add @pacote/error
```

## Usage

### `BaseError`

`BaseError` is an error class which provides a convenience static `imprint()` method to get around [issues with extending the built-in JavaScript `Error` class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error). It's by no means a bullet-proof solution and full support is not available in older browsers (such as Internet Explorer up to version 10).

```typescript
import { BaseError } from '@pacote/error'

class StatusError extends BaseError {
  constructor(public readonly status: number, message?: string) {
    super(message)
    StatusError.imprint(this)
  }
}

const e = new StatusError(404, 'Not found')

e instanceOf Error       // true
e instanceOf BaseError   // true
e instanceOf StatusError // true
e.message                // 'Not found'
e.status                 // 404
e.stack                  // <defined>
```

### `ComplexError`

`ComplexError` aggregates multiple error objects so they can be thrown as one. Its primary use case is to support validation errors caused by multiple failing conditions.

```typescript
import { ComplexError } from '@pacote/error'

function doSomething() {
  throw new ComplexError('Could not do something', [
    new Error('one'),
    new Error('two'),
  ])
}

try {
  doSomething()
} catch (e) {
  e.causes.forEach(console.error) // Outputs Error('one'), Error('two')
}
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/get-style
Description: Get an element's computed style for the provided CSS property.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/get-style

![version](https://badgen.net/npm/v/@pacote/get-style)
![minified](https://badgen.net/bundlephobia/min/@pacote/get-style)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/get-style)

Get an element's computed style for the provided CSS property.

## Installation

```bash
yarn add @pacote/get-style
```

## Usage

```typescript
import { getStyle } from '@pacote/get-style'

// When the body element has `font-size: 20px`.
getStyle(document.body, 'fontSize') // => '20px'
```

### `getStyle(element: HTMLElement, property: string): string`

`getStyle()` takes an element and the CSS property to fetch and returns its
computed value.

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/iff
Description: Conditional expressions with Option support.
Author: Luís Rodrigues
Latest version: 4.0.1

# @pacote/iff

![version](https://badgen.net/npm/v/@pacote/iff)
![minified](https://badgen.net/bundlephobia/min/@pacote/iff)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/iff)

Conditional expressions with Option support.

## Installation

```bash
yarn add @pacote/iff
```

## Usage

```typescript
import { iff } from '@pacote/iff'

iff(
  true,
  () => 1,
  () => 0
) // => 1

iff(
  false,
  () => 1,
  () => 0
) // => 0

iff(
  true,
  () => 1,
  () => 'zero'
) // type error, branches are not the same type

iff(true, () => 1) // => Some(1)

iff(false, () => 1) // => None
```

### `iff(predicate: boolean, onConsequent: () => T, onAlternative?: () => T): T`

`iff()` evaluates a _predicate_ and returns the result of calling
_onConsequent()_ if the predicate is `true` or the result of _onAlternative()_
if the predicate is `false`.

_onConsequent_ and _onAlternative_ must be functions with the same return type.

### `iff(predicate: boolean, onConsequent: () => T): Option<T>`

If _onAlternative_ is not provided or is nullable, `iff()` will always return
an `Option<T>` data type: `Some<T>` if the predicate is `true`, or `None` if the
predicate is `false`.

## See also

- [`@pacote/option`](../option/)

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/immutable
Description: Immutable generic type.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/immutable

![version](https://badgen.net/npm/v/@pacote/immutable)
![minified](https://badgen.net/bundlephobia/min/@pacote/immutable)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/immutable)

Generic type for deeply immutable data.

## Installation

```bash
yarn add @pacote/immutable
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/interpolate
Description: Super simple microtemplating.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/interpolate

![version](https://badgen.net/npm/v/@pacote/interpolate)
![minified](https://badgen.net/bundlephobia/min/@pacote/interpolate)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/interpolate)

Super simple microtemplating.

## Installation

```bash
yarn add @pacote/interpolate
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/is-plain-object
Description: Checks whether the provided object is a plain JavaScript object.
Author: Luís Rodrigues
Latest version: 3.0.1

# @pacote/is-plain-object

![version](https://badgen.net/npm/v/@pacote/is-plain-object)
![minified](https://badgen.net/bundlephobia/min/@pacote/is-plain-object)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/is-plain-object)

Checks whether the provided value is a plain JavaScript object.

## Installation

```bash
yarn add @pacote/is-plain-object
```

## Usage

```typescript
import { isPlainObject } from '@pacote/is-plain-object'

// These return true:
isPlainObject({})
isPlainObject({ an: 'object' })

// All of these return false:
isPlainObject(undefined)
isPlainObject(null)
isPlainObject(false)
isPlainObject(true)
isPlainObject(NaN)
isPlainObject(Infinity)
isPlainObject(0)
isPlainObject('string')
isPlainObject([])
isPlainObject(new ArrayBuffer(0))
isPlainObject(new Date())
isPlainObject(new Map())
isPlainObject(new Promise())
isPlainObject(new Set())
isPlainObject(new WeakMap())
isPlainObject(new WeakSet())
```

### `isPlainObject(o: any): boolean`

`isPlainObject()` takes a single value and checks whether it is a plain object. May be used as a type guard.

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/jest-either
Description: Jest matcher for Either objects.
Author: Luís Rodrigues
Latest version: 6.0.1

# @pacote/jest-either

![version](https://badgen.net/npm/v/@pacote/jest-either)
![minified](https://badgen.net/bundlephobia/min/@pacote/jest-either)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/jest-either)

Additional matchers for [Jest](https://jestjs.io) making it easier to test `Either` objects.

## Installation

```bash
yarn add @pacote/jest-either
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/linked-list
Description: Immutable linked lists.
Author: Luís Rodrigues
Latest version: 0.8.1

# @pacote/linked-list

![version](https://badgen.net/npm/v/@pacote/linked-list)
![minified](https://badgen.net/bundlephobia/min/@pacote/linked-list)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/linked-list)

Immutable linked lists.

## Installation

```bash
yarn add @pacote/linked-list
```

## Example

```typescript
import { listOf, sort } from '@pacote/linked-list'

sort(listOf(3, 2, 1)) // => [1, [2, [3, undefined]]]
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/lru-cache
Description: Least-recently used cache.
Author: Luís Rodrigues
Latest version: 0.2.0

# @pacote/lru-cache

![version](https://badgen.net/npm/v/@pacote/lru-cache)
![minified](https://badgen.net/bundlephobia/min/@pacote/lru-cache)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/lru-cache)

Least-recently used cache.

## Installation

```bash
yarn add @pacote/lru-cache
```

## Documentation

API documentation for [`@pacote/lru-cache`](https://pacotejs.github.io/pacote/modules/_pacote_lru-cache.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/memoize
Description: Memoization function.
Author: Luís Rodrigues
Latest version: 3.0.1

# @pacote/memoize

![version](https://badgen.net/npm/v/@pacote/memoize)
![minified](https://badgen.net/bundlephobia/min/@pacote/memoize)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/memoize)

Speed up consecutive calls of the same function with the same arguments by caching its results.

## Installation

```bash
yarn add @pacote/memoize
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/non-empty-array
Description: Typed non-empty arrays.
Author: Luís Rodrigues
Latest version: 0.4.1

# @pacote/non-empty-array

![version](https://badgen.net/npm/v/@pacote/non-empty-array)
![minified](https://badgen.net/bundlephobia/min/@pacote/non-empty-array)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/non-empty-array)

An array type guaranteed to have at least one element.

The module consumes and returns plain JavaScript arrays, but is typed to prevent
the TypeScript compiler from handling arrays that might be empty.

One instance where non-empty arrays are useful is when combined with
[`@pacote/result`](../result/) to create a `Validation` data type that
accumulates multiple errors as `Result<T, NonEmptyArray<Error>>`. This is
because a failing computation _must_ have at least one error.

## Installation

```bash
yarn add @pacote/non-empty-array
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/option
Description: Option type inspired by Rust.
Author: Luís Rodrigues
Latest version: 5.0.1

# @pacote/option

![version](https://badgen.net/npm/v/@pacote/option)
![minified](https://badgen.net/bundlephobia/min/@pacote/option)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/option)

[Option](https://doc.rust-lang.org/std/option/enum.Option.html) type inspired by Rust. It represents an optional value, an `Option` is either `Some` concrete value or it is `None`.

## Installation

```bash
yarn add @pacote/option
```

## Usage

```typescript
import { None, Some, map } from '@pacote/option'

function divide(numerator: number, denominator: number): Option<number> {
  return denominator === 0 : None ? Some(numerator / denominator)
}

map(n => n + 1, divide(4, 2)) // => Some(3)
map(n => n + 1, divide(4, 0)) // => None
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/pipe
Description: Chain function calls with right-composition, improving readability when chaining several functions together.
Author: Luís Rodrigues
Latest version: 0.3.1

# @pacote/pipe

![version](https://badgen.net/npm/v/@pacote/pipe)
![minified](https://badgen.net/bundlephobia/min/@pacote/pipe)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/pipe)

Compose function calls, improving readability by declaring a sequence of
functions left-to-right in the order they are applied.

## Installation

```bash
yarn add @pacote/pipe
```

## Usage

```typescript
import { pipe } from '@pacote/pipe'

const doubleSay = (text: string) => text + ', ' + text
const capitalize = (text: string) => text[0].toUpperCase() + text.substring(1)
const exclaim = (text: string) => text + '!'

exclaim(capitalize(doubleSay('hello'))) // => 'Hello, hello!'

pipe('hello', doubleSay, capitalize, exclaim) // => 'Hello, hello!'
```

### `pipe(initial: unknown, ...fns: readonly Function[]): unknown`

`pipe()` allows you to pass a value into a sequence of functions chained
left-to-right.

It takes an argument of any type plus any number of functions that accept the
preceding result, then feeds the first argument into the first function, the
output of the first function into the second function, and so on until the
output of the last function is finally returned.

Given three functions `f`, `g`, and `h`:

```typescript
const result = pipe(x, f, g, h)
```

is equivalent to:

```typescript
const result = h(g(f(x)))
```

### `flow(...fns: readonly Function[]): Function`

`flow()` lets you chain functions left-to-right in a point-free manner.

It takes any number of functions that accept the preceding result, and returns
a composed function that takes an initial value and returns the last function
output after the initial value is chained through the intervening functions.

Given three functions `f`, `g`, and `h`:

```typescript
const fn = flow(f, g, h)
```

is equivalent to:

```typescript
const fn = (x) => h(g(f(x)))
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/pixels
Description: Converts CSS unit lengths to pixels.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/pixels

![version](https://badgen.net/npm/v/@pacote/pixels)
![minified](https://badgen.net/bundlephobia/min/@pacote/pixels)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/pixels)

Convert [CSS length values](https://developer.mozilla.org/en-US/docs/Web/CSS/length) to pixels.

## Installation

```bash
yarn add @pacote/pixels
```

## Usage

```typescript
import { pixels } from '@pacote/pixels'

// When the root element has `font-size: 16px`.
pixels('2rem') // => 32
```

### `pixels(value: string): number`

`pixels()` takes a CSS string with the value and unit and converts it to pixels.

Handles common font-relative units (`em`, `rem`, `vw`, `vh`, `vmin`, and `vmax`)
as well as most absolute units (`px`, `cm`, `mm`, `Q`, `in`, `pt`, and `pc`).

The function does not handle percentage lengths as resolution depends on the
relative sizes of specific properties of elements up the DOM tree. For example,
`font-size` is relative to the parent element's `font-size` but `max-height` is
relative to the containing element's `height`.

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/react-use-outside
Description: React hook to capture mouse or touch events outside a component.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/react-use-outside

![version](https://badgen.net/npm/v/@pacote/react-use-outside)
![minified](https://badgen.net/bundlephobia/min/@pacote/react-use-outside)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/react-use-outside)

Hook to handle events outside React components.

## Installation

```bash
yarn add @pacote/react-use-outside
```

## Usage

### `useOutside<T>(type: Array<keyof DocumentEventMap> | keyof DocumentEventMap, listener: EventListener): React.RefObject<T>`

Takes one or more event types to listen and an event listener function and returns a reference which can be applied to a DOM element. The provided function will be called for all listened events triggered outside the component.

```tsx
import React from 'react'
import { useOutside } from '@pacote/react-use-outside'

const Modal = () => {
  const ref = useOutside('click', () => {
    console.log('Clicked outside!')
  })

  return <div ref={ref}>Click outside to show console message.</div>
}
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/react-with-props
Description: Higher-order component to apply props to React components.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/react-with-props

![version](https://badgen.net/npm/v/@pacote/react-with-props)
![minified](https://badgen.net/bundlephobia/min/@pacote/react-with-props)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/react-with-props)

Enhance component with preset properties.

## Installation

```bash
yarn add @pacote/react-with-props
```

## Usage

### `withProps(props: {} | (outer: {}) => {}, component: Component | string)`

Creates a new component with the provided props applied to an existing component.

```tsx
import React from 'react'
import { withProps } from '@pacote/react-with-props'

type ComponentProps = {
  name: string
  value: string
}

const NameValue = (props: ComponentProps) => (
  <div>
    {props.name}: {props.value}
  </div>
)

// Enhance component:
const ExampleValue = withProps({ name: 'Example' }, NameValue)

render(<ExampleValue value="with props" />)
// => <div>Example: with props</div>

// Enhance component with function:
const FieldValue = withProps(
  ({ field = '' }) => ({ name: `[${field}]` }),
  NameValue
)

render(<FieldValue field="Example" value="with props" />)
// => <div>[Example]: with props</div>

// Enhance DOM component:
const PasswordInput = withProps({ type: 'password' }, 'input')

render(<PasswordInput name="secret" />)
// => <input type='password' name='secret' />
```

### `withDefaultProps(props: {}, component: Component | string)`

Like `withProps()`, but provided properties can be overridden.

```tsx
import React from 'react'
import { withDefaultProps } from '@pacote/react-with-props'

type ComponentProps = {
  name: string
  value: string
}

const NameValue = (props: ComponentProps) => (
  <div>
    {props.name}: {props.value}
  </div>
)

// Enhance component:
const Example = withDefaultProps(
  { name: 'Example', value: 'default value' },
  NameValue
)

render(<Example value="with props" />)
// => <div>Example: with props</div>

// Enhance DOM component:
const PasswordInput = withProps(
  { type: 'password', placeholder: 'Password' },
  'input'
)

render(<PasswordInput name="secret" placeholder="API Key" />)
// => <input type='password' name='secret' placeholder='API Key' />
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/result
Description: Result type inspired by Rust.
Author: Luís Rodrigues
Latest version: 5.0.1

# @pacote/result

![version](https://badgen.net/npm/v/@pacote/result)
![minified](https://badgen.net/bundlephobia/min/@pacote/result)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/result)

[Result](https://doc.rust-lang.org/std/result/enum.Result.html) type inspired by Rust. It represents either a success (`Ok`) or an error (`Err`).

## Installation

```bash
yarn add @pacote/result
```

## Example

```typescript
import { Ok, Err, map } from '@pacote/result'

function divide(numerator: number, denominator: number): Option<number> {
  return denominator === 0 : Err('division by zero') ? Ok(numerator / denominator)
}

map(n => n + 1, divide(4, 2)) // => Ok(3)
map(n => n + 1, divide(4, 0)) // => Err('division by zero')
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/retry
Description: Asynchronous retry handler with timeout and exponential backoff support.
Author: Luís Rodrigues
Latest version: 0.3.0

# @pacote/retry

![version](https://badgen.net/npm/v/@pacote/retry)
![minified](https://badgen.net/bundlephobia/min/@pacote/retry)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/retry)

Asynchronous retry handler with timeout and exponential backoff support.

## Installation

```bash
yarn add @pacote/retry
```

## Documentation

API documentation for [`@pacote/retry`](https://pacotejs.github.io/pacote/modules/_pacote_retry.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/shuffle
Description: An implementation of the Durstenfeld algorithm for shuffling collections.
Author: Luís Rodrigues
Latest version: 3.0.0

# @pacote/shuffle

![version](https://badgen.net/npm/v/@pacote/shuffle)
![minified](https://badgen.net/bundlephobia/min/@pacote/shuffle)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/shuffle)

An implementation of the Durstenfeld algorithm for shuffling collections.

## Installation

```bash
yarn add @pacote/shuffle
```

## Usage

```typescript
import { shuffle } from '@pacote/shuffle'

shuffle([1, 2, 3])
```

### `shuffle<T>(items: T[]): T[]`

`shuffle()` takes an item sequence and returns a randomly permutated sequence
of its elements.

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/task
Description: Asynchronous computations that never fail.
Author: Luís Rodrigues
Latest version: 0.2.0

# @pacote/task

![version](https://badgen.net/npm/v/@pacote/task)
![minified](https://badgen.net/bundlephobia/min/@pacote/task)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/task)

Asynchronous computations that never fail.

## Installation

```bash
npm install @pacote/task
```

## Documentation

API documentation for [`@pacote/task`](https://pacotejs.github.io/pacote/modules/_pacote_task.html).

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/throttle
Description: A tiny throttler.
Author: Luís Rodrigues
Latest version: 3.0.1

# @pacote/throttle

![version](https://badgen.net/npm/v/@pacote/throttle)
![minified](https://badgen.net/bundlephobia/min/@pacote/throttle)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/throttle)

A tiny throttler.

## Installation

```bash
yarn add @pacote/throttle
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/validation
Description: ![version](https://badgen.net/npm/v/@pacote/validation) ![minified](https://badgen.net/bundlephobia/min/@pacote/validation) ![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/validation)
Author: Luís Rodrigues
Latest version: 0.4.1

# @pacote/validation

![version](https://badgen.net/npm/v/@pacote/validation)
![minified](https://badgen.net/bundlephobia/min/@pacote/validation)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/validation)

The `Validation<T, E>` data type is a `Result` that accumulates multiple
errors.

## Installation

```bash
yarn add @pacote/validation
```

## Example

```typescript
import { validation, lift } from '@pacote/validation'
import { Ok, Err } from '@pacote/result'

const hasLetter = lift((s: string) =>
  s.match(/[a-z]/i) ? Ok(s) : Err('no letters')
)
const hasDigit = lift((s: string) =>
  s.match(/[0-9]/) ? Ok(s) : Err('no digits')
)

const validate = validation(hasLetter, hasDigit)

validate('-') // => Err(['no letters', 'no digits'])
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/windowed
Description: Returns a snapshot array of a window sliding along an array.
Author: Luís Rodrigues
Latest version: 0.1.0
Deprecated: Package functionality moved to @pacote/array.

# @pacote/windowed

![version](https://badgen.net/npm/v/@pacote/windowed)
![minified](https://badgen.net/bundlephobia/min/@pacote/windowed)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/windowed)

Returns a snapshot array of a window sliding along an array, inspired by
Kotlin's [`windowed`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/windowed.html) method.

## Installation

```bash
yarn add @pacote/windowed
```

## Usage

```typescript
import { windowed } from '@pacote/windowed'

const array = [1, 2, 3, 4]

windowed(2, array)    // => [[1, 2], [2, 3], [3, 4]]
windowed(3, array)    // => [[1, 2, 3], [2, 3, 4]]
windowed(2, 2, array) // => [[1, 2], [3, 4]]
```

### `windowed<T>(size: number, step: number = 1, collection: T[]): T[][]`

`windowed()` returns a snapshot array of a window of the provided `size` sliding
along the provided array with the provided `step`.

Both size and step must be positive and can be greater than the number of
elements in this collection.

#### Arguments

- `size`: the number of elements to take in each window.
- `step`: the number of elements to move the window forward by on an each step, by default `1`.
- `collection`: the array the window slides along.

## License

MIT © [Luís Rodrigues](https://goblindegook.com).
npm package: @pacote/xxhash
Description: Fast non-cryptographic hashing algorithm.
Author: Luís Rodrigues
Latest version: 0.5.1

# @pacote/xxhash

![version](https://badgen.net/npm/v/@pacote/xxhash)
![minified](https://badgen.net/bundlephobia/min/@pacote/xxhash)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/xxhash)

Fast non-cryptographic hashing algorithm.

## Installation

```bash
yarn add @pacote/xxhash
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).