open-index/open-npm huggingface dataset:
npm package: @jdcrensh/react-intl-webpack-plugin
Description: ReactIntlPlugin for webpack
Author: Jon Crenshaw
Latest version: 0.1.5

# @jdcrensh/react-intl-webpack-plugin

This plugin helps when using react-intl for internationalization of react apps.

This fork changes the format of the resulting JSON file to be a simple key-value object.

## Workflow

1. Use `<FormattedMessage id="newItem" defaultMessage="Add item" />` for adding text in your react components.
2. Use the babel plugin `babel-plugin-react-intl` to extract them from your source code.
3. Use `react-intl-webpack-plugin` to combine them into one message file called `reactIntlMessages.json` and put this file into the webpack output path.
4. Use CAT (Computer Aided Translation) tools (like the cloud based memsource.com or okapi) to translate this file into the translated file. These tools use a concept called Translation Memory (TM) . This is a separate file where all translations are stored and with this file all translations can be reapplied to a newly generated `reactIntlMessages.json` file.
5. Save the TM file and the translated json file in a separate directory of your source code.
6. Use `reactIntlJson-loader` to load the translated files and convert them to messages.

## Installation

`npm install @jdcrensh/react-intl-webpack-plugin --save-dev`

- this works only with babel-loader >= 6.4.0
- you will need also the babel plugin `babel-plugin-react-intl`

webpack.config.js:
- add the plugin
```
var ReactIntlPlugin=require('react-intl-webpack-plugin');
...
plugins: [
         ...
          new ReactIntlPlugin()
         ],
```
- modify your babel-loader to contain the `metadataSubscribers` option
```
module: {
        loaders: [
                  ...
            {
                test: /\.js?$/, loader: 'babel-loader',
                query: {
                    "cacheDirectory": true,
                    "metadataSubscribers":[ReactIntlPlugin.metadataContextFunctionName],
                    "plugins": ["transform-runtime",
                        ["react-intl", {
                            "enforceDescriptions": false
                        }]],
                    "presets": ['react', "es2015", "stage-1"]
                }
            },
```

- the generated file is called `reactIntlMessages.json`

## Options

`collapseWhitespace` (boolean): If true, collapses all inner whitespace and newlines. Useful for ES6 multiline template literals.

## Notes

- Keep in mind that as long as you use webpack-dev-server all assets are generated in memory. To access those assets use either:
    - the browser an check http://localhost:devServerPort/reactIntlMessages.json
    - or, add a script to package.json like `"trans:refreshJsonDEV": "curl localhost:3100/reactIntlMessages.json >./dist/reactIntlMessages.json"`
    - or start your webpack build to generate the assets into the build directory.

- If no messages are generated it could be helpful to cleanup the `cacheDirectory` of the babel-loader, or set `"cacheDirectory": false` temporarily

## License

MIT (http://www.opensource.org/licenses/mit-license.php)
npm package: @jdcrensh/react-scripts
Description: Configuration and scripts for Create React App.
Latest version: 5.0.2-0

# react-scripts

This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation:

- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.

# Configuration & Plugin Support (unofficial)

This is an unofficial fork that extends Create React App with an interface for plugins and custom config.

If a `cra.config.js` plugin doesn't exist, there's no difference than if you were using the official package.

## Configuration

An ES5 module exported by `cra.config.js` at the app's root is used for configuration. Each property is optional.

| Property  | Type                  | Description                                |
| --------- | --------------------- | ------------------------------------------ |
| [plugins] | <code>array</code>    | plugin references or names. default: `[]`  |
| [apply]   | <code>function</code> | webpack config. default: identity function |
| [babel]   | <code>function</code> | babel config. default: identity function   |

### Example

```js
module.exports = {
  // Load plugins by name and/or by reference. Loading plugins by name is for
  // convenience, eg. `'css-modules'` is the same as `require('react-scripts-plugin-css-modules')`
  plugins: ['no-minify', require('./my-internal-plugin')],

  // Webpack configuration
  apply: (config, { env, paths }) => {
    return config;
  },

  // Babel configuration
  babel: (config, { env, paths }) => {
    return config;
  },
};
```

## Plugins

A plugin is simply an exported custom config _without_ the `plugins` property.

## Available Plugins

- [react-scripts-plugin-babelrc](https://www.npmjs.com/package/react-scripts-plugin-babelrc)
- [react-scripts-plugin-no-hashes](https://www.npmjs.com/package/react-scripts-plugin-no-hashes)
- [react-scripts-plugin-no-minify](https://www.npmjs.com/package/react-scripts-plugin-no-minify)
- [react-scripts-plugin-sentry](https://www.npmjs.com/package/react-scripts-plugin-sentry)
npm package: @jddf/jddf
Description: A JavaScript implementation of JSON Data Definition Format
Author: Ulysse Carion
Latest version: 0.1.6

# jddf.js [![npm](https://img.shields.io/npm/v/@jddf/jddf.svg)](https://www.npmjs.com/package/@jddf/jddf)

This package is a JavaScript implementation of **JSON Data Definition Format**.
You can use it to:

1. Validate input data is valid against a schema,
2. Get a list of validation errors with that input data, or
3. Build your own custom tooling on top of JSON Data Definition Format.

This package is written in TypeScript, and works in browsers and Node.js alike.

## Usage

Here's how you can use this package to validate inputted data:

```typescript
import { compileSchema, Validator } from "@jddf/jddf";

// compileSchema does basic validation on your schema, to make sure it's sane.
// Plus, if you're using TypeScript, it will give you basic typechecking.
const schema = compileSchema({
  properties: {
    name: { type: "string" },
    age: { type: "number" },
    phones: {
      elements: {
        type: "string",
      },
    },
  },
});

// Once you've registered all your schemas, you can efficiently validate as many
// inputs as desired.
const validator = new Validator();

// Validator.validate returns an array of validation errors. By default, all
// errors are returned, but you can also configure Validator to limit how many
// errors it produces.
const errorsOk = validator.validate({
  name: "John Doe",
  age: 43,
  phones: ["+44 1234567", "+44 2345678"],
});

// We're not expecting any errors here.
console.log(errorsOk); // []

// Each returned error holds paths to the bad part of the input, as well as the
// part of the schema which rejected it.
const errorsBad = validator.validate({
  age: "43",
  phones: ["+44 1234567", 442345678],
});

// "name" is required
console.log(errorsBad[0].instancePath.toString()); // ""
console.log(errorsBad[0].schemaPath.toString()); // "/properties/name"

// "age" has the wrong type
console.log(errorsBad[1].instancePath.toString()); // "/age"
console.log(errorsBad[1].schemaPath.toString()); // "/properties/age/type"

// "phones[1]" has the wrong type
console.log(errorsBad[2].instancePath.toString()); // "/phones/1"
console.log(errorsBad[2].schemaPath.toString()); // "/properties/phones/elements/type"
```

In the example above, those errors are standardized; every implementation of
JDDF would have produced the exact same errors, so you can reliably transmit
these errors to any other system that uses JDDF.
npm package: @jddudc/babel-plugin-import
Description: 按需加载 @jddudc/jdd-design 的组件，减小打包体积
Author: chenjiahao@jd.com
Latest version: 0.0.3

# @jddudc/babel-plugin-import

按需引入 `@jddudc/jdd-design` 组件

## 安装

```bash
npm i -D @jddudc/babel-plugin-import
```

## 使用

> style 选项值为 "css" 时加载组件对应的css文件，为 "scss" 时加载对应的scss文件。无style选项时，不自动加载样式文件。

配置 `.babelrc` 文件

```javascript
{
  "plugins": [
    ["@jddudc/babel-plugin-import", {
      "style": "css"
    }]
  ]
}
```
npm package: @jddudc/jdd-design
Description: 提供完整的前中台设计效率解决方案
Author: jddudc
Latest version: 2.12.2

<p align=center>
    <img width="168" src="//storage.360buyimg.com/fin-desgin/logo.png"/>
</p>

# jdd-design [![jdd-design](https://img.shields.io/npm/v/@jddudc/jdd-design.svg?style=flat-square)](https://www.npmjs.org/package/@jddudc/jdd-design) [![NPM downloads](https://img.shields.io/npm/dt/@jddudc/jdd-design.svg?style=flat-square)](https://npmjs.org/package/@jddudc/jdd-design) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

> 提供完整的前中台设计效率解决方案。

## 主页

[查看主页](https://findesign.jd.com)

## 更新日志

[CHANGELOG](CHANGELOG.md)

## 安装

```bash
$ npm install @jddudc/jdd-design --save
```

## 快速开始

```javascript
import JDD from '@jddudc/jdd-design'
import '@jddudc/jdd-design/styles/index.css'

Vue.use(JDD)

// or
import { Button } from '@jddudc/jdd-design'

Vue.component(Button.name, Button)
```

[更多详细内容](https://findesign.jd.com/#/components/start)

## 建议或意见

[如果您有任何建议或意见，请点击这里](https://git.jd.com/art-fe/jdd-design/issues)

## 贡献

- [陈嘉豪&lt;chenjiahao@jd.com&gt;](https://github.com/ChenJiaH)

- [孙超&lt;sunchao5@jd.com&gt;](https://github.com/sun2dan)

- [郑晓雪&lt;zhengxiaoxue3@jd.com&gt;](https://github.com/)

- 如果您也想参与进来，请遵循[开发原则](CONTRIBUTE.md)

## 协议

[MIT](LICENSE)
npm package: @jddudc/scsdk-koa
Description: 服务管控HTTP鉴权 Node.js SDK
Author: McChen
Latest version: 1.2.1

# 服务管控SDK

## 安装

```shell
npm install @jddudc/scsdk-koa --save
```

## 使用

参考[test.js](test/index.js)

## 验证

放开 test.js 内各场景下使用方式逐步验证。

## 注意点

1. 服务管控侧 http 和 https 是两个规则，只在 http(s):// 后做通配，需要两个都支持，需要在bpass组件市场配两条，且 koa 启动两个服务，通过 protocol 配置协议头

2. 会优先取 header 内的参数
npm package: @jdecristi/color
Description: A minimal library for using an manipulating colors in Javascript and Typescript
Author: jdecristi
Latest version: 0.0.7

# Color

### A minimal library for using an manipulating colors in Javascript and Typescript

- Zero runtime depenecies
- Lightweight


## Usage
```ts
const color = new Color("#0F0");

// Supports Hex
color.toHex()    // "#00FF00FF"

// Supports RGB
color.toRgb()    // "rgba(255, 255, 255, 1)"
color.red        // 255
color.green      // 255
color.blue       // 255

// Supports HSL
color.toHsl()    // "hsla(120, 100%, 50%, 1)"
color.hue        // 120
color.saturation // 1
color.lightness  // 0.5

// Opacity defaulted to "opaque"
color.opacity    // 1

```

## Installation
npm
``` bash
npm install @jdecristi/color
```

yarn
``` bash
yarn add @jdecristi/color
```

pnpm
``` bash
pnpm add @jdecristi/color
```

bun
``` bash
bun add @jdecristi/color
```
npm package: @jdefting/react-pixi
Description: Write PixiJS applications using React declarative style.
Author: Patrick Brouwer
Latest version: 6.8.2

<p align="center">
  <img src="https://user-images.githubusercontent.com/232559/142733492-3c106f68-8b8e-459c-95f9-aca77561d438.png" alt="react-pixi" width="310" />
</p>

<h1 align="center">
  React Pixi
</h1>

<p align="center">
  <strong>Simply the best way to write PIXI applications in React</strong>
  <br />
  <sub>Write <a href="http://www.pixijs.com/">PIXI</a> applications using React declarative style 👌</sub>
</p>

<br />

<p align="center">
  <img src="https://img.shields.io/github/v/release/inlet/react-pixi" alt="release" />
  <img src="https://img.shields.io/npm/dm/@inlet/react-pixi" alt="downloads" />
  <img src="https://img.shields.io/circleci/project/github/inlet/react-pixi/master.svg" alt="ci tests" />
  <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="license" />
  <img src="https://img.shields.io/badge/react-latest-ff69b4.svg" alt="react version" />
  <img src="https://img.shields.io/badge/pixi-v6+-ff69b4.svg" alt="pixi version" />
</p>

<br />

ReactPixi is an open-source, production-ready library to render high performant PIXI applications in React.

## Get started

### Quick start

```
npm install pixi.js @inlet/react-pixi
```

```jsx
import { Stage, Container, Sprite } from '@inlet/react-pixi'

export const MyComponent = () => (
  <Stage>
    <Sprite image="./my-image.png" x={100} y={100} />

    <Container x={500}>
      <Text text="Hello World" filter={[blurFilter]} />
    </Container>
  </Stage>
)
```

### Docs

Check out [our documentation](https://reactpixi.org) for guides and a full API reference.

Or checkout [our examples](https://codepen.io/collection/XPpGdb) on codepen for inspiration.

## Contribute

Want to contribute to ReactPixi? Our [contributing guide](CONTRIBUTING.md) has you covered.

## License

ReactPixi is MIT licensed.

## Meet fellow developers

You have an amazing feature in mind or just want to get in touch with other developers? Feel free to join our Slack channel.

[Join us on Slack](https://join.slack.com/t/reactpixi/shared_invite/enQtODk5NjQ2ODQ4MTI5LWVjNzlkZTJjYmI4NDcxYzljNDM4MmYwMzZkYWFlM2VkNmFhNDBmYzg3OGE5YzBiY2NmZTIwZDY0MTA4ZjA4OGM)
npm package: @jdeighan/browser
Description: browser utilities
Author: John Deighan
Latest version: 1.0.3

How to use this library
=======================

This library provides these functions:

inBrowser() - returns true if running in a browser
beep(volume, freq, duration) - emit a beep
	defaults are (100, 520, 200) and are optional
localStorageAvailable() - tests availability of localStorage
getLocalStore(key, defVal={}) - converts using JSON.stringify()
setLocalStore(key, value) - converts using JSON.stringify()
npm package: @jdeighan/cielo
Description: command to process *.cielo and *.starbucks files
Author: John Deighan
Latest version: 9.0.1

The **cielo** command
=====================

To get help:

```text
cielo -h
```

Usage:

```text
cielo [ <dir> ]
   -h help
   -n process files, don't watch for changes
   -d turn on debugging (a lot of output!)
<dir> defaults to current working directory
```
npm package: @jdeighan/env
Description: enhanced syntax for .env files
Author: John Deighan
Latest version: 9.1.24
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

README
======

SYNOPSIS (CoffeeScript)
-----------------------

import {mydir} from '@jdeighan/coffee-utils/fs'
import {loadEnvFrom} from '@jdeighan/env'

dir = mydir(`import.meta.url`)
loadEnvFrom(dir)
npm package: @jdeighan/llutils
Description: JavaScript utilities, including CoffeeScript and Peggy
Author: John Deighan
Latest version: 5.0.1

Use package llutils
===================

NOTE: Always execute the following:

```bash
$ npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
```

To stop using CMD.exe for new shells

docs go here
npm package: @jdeighan/mapper
Description: A class to help parse text files
Author: John Deighan
Latest version: 32.0.14

@jdeighan/mapper
================

This npm package provides the following libraries:

/taml:
------

	isTAML(block) - returns true if 1st line of block is '---'
	taml(block) - returns data structure that block represents
	slurpTAML(path) - returns data structure text in file represents

/markdown:
----------

	convertMarkdown(flag) - if false, markdownify just returns 1st arg
	markdownify(block) - convert markdown to HTML

NOTE: Since one or more '#' characters introduce a comment, don't do this:

```markdown
# A title
```

but, instead, do this:

```markdown
A title
=======
```

replace '=' characters with '-' characters for a level 2 heading

/sass:
------

	convertSASS(flag) - if false, sassify() just returns block
	sassify(block) - returns equivalent CSS

/builtins:
----------

	isBuiltin(name) - tells you whether the name is a JavaScript reserved
		name. The list is VERY incomplete and should probably not be
		used from outside this package.

/mapper:
--------------

This library provides 4 classes of increasing complexity:

1. [LineFetcher](./LineFetcher.md)
2. [Mapper](./Mapper.md)
3. [CieloMapper](./CieloMapper.md)

/get:
-----

	class Getter(lItems) with methods:
		- get()
		- unget(item)
		- peek()
		- skip()
		- eof()
/heredoc:
---------

	doDebug(flag) - turns on HEREDOC debugging if flag = true
	mapHereDoc(block) - interprets a HEREDOC block and returns result
	addHereDocType(obj) - add a new HEREDOC type by passing a class
		that implements methods myName(), isMyHereDoc(block) and map(block)

/func:
------

Provides class FuncHereDoc, which can be used to add a new HEREDOC
type via addHereDocType() in /heredoc

/tree:
--------------

Provides:

- [TreeMapper](./TreeMapper.md)

/walker:
--------

Implements these 3 classes:

1. [TreeWalker](./TreeWalker.md)
2. [ASTWalker](./ASTWalker.md)
3. [TreeStringifier](./TreeStringifier.md)

/symbols:
---------

Includes functions:

- `getNeededSymbols(coffeeCode, hOptions)`
- `addImports(coffeeCode, rootDir, hOptions)`
- `buildImportBlock(lNeededSymbols, rootDir, hOptions)`
- `buildImportList(lNeededSymbols, rootDir, hOptions)`
- `getAvailSymbols(rootDir, hOptions)`

/coffee:
--------

Includes functions:

- `convertCoffee(flag)`
- `coffeeExprToJS(coffeeExpr, force)`
- `coffeeCodeToJS(code, hOptions)`
- `coffeeFileToJS(srcPath, destPath, hOptions)`
- `coffeeEvalFunc(lParmNames, strBody)` - use with FuncHereDoc

/cielo:
-------

	convertCielo(flag) - if false, cieloCodeToJS() just returns block
	cieloCodeToJS(block)
	addImports()
	cieloFileToJS()
npm package: @jdeighan/svelte-utils
Description: A collection of svelte utility functions
Author: John Deighan
Latest version: 3.0.0

Svelte Utils
============

This package includes the following libraries:

`@jdeighan/preprocessors`
------------------

A function named `coffeePreProcessor` that can be
used to enable `<script>` blocks in Svelte code
containing CoffeeScript code using `lang="coffee"` as
the `<script>` attribute.

`@jdeighan/translator`
------------------

A class named `MSTranslator` that uses the Microsoft
language translator (you must set environment variables
TRANSLATE_URL, TRANSLATE_KEY AND TRANSLATE_LOCATION to
use it). It has method translateStr(str, from, to) where
str is the string to translate and from/to are language
codes. If you translate the same string a second time,
it will fetch the translation from a cache rather then
use the Microsoft service.

`@jdeighan/stores`
------------------

Some utility Svelte data stores
npm package: @jderjs/core
Description: A standard response builder
Author: Alpheus
Latest version: 0.3.0

# JDER Core

A standard response builder.

This package includes different response builders based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jder-std/spec). With the builders, various kinds of responses can be created easily instead of sending plain text responses.

## Quick Start

To create a JSON response, use the following code:

```ts
import { createJsonResponse } from "@jderjs/core";

const route = (): Response => {
    return createJsonResponse();
}
```

And the response will be shown as below:

```json
{
    "success": true
}
```

## License

This project is licensed under the terms of the MIT license.
npm package: @jderjs/hono
Description: A response builder for Hono
Author: Alpheus
Latest version: 0.5.0

# JDER Hono

A response builder for Hono.

This package includes different response builders based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jder-std/spec). With the builders, various kinds of responses can be created easily instead of sending plain text responses.

## Quick Start

To create a JSON response, use the following code:

```ts
import { createJsonResponse } from "@jderjs/hono";

const route = (): Response => {
    return createJsonResponse();
}
```

And the response will be shown as below:

```json
{
    "success": true
}
```

## License

This project is licensed under the terms of the MIT license.
npm package: @jderjs/hono-zod-validator
Description: A Zod validator for Hono
Author: Alpheus
Latest version: 0.5.0

# JDER Hono Zod Validator

A Zod validator for Hono.

This package includes a Zod validator based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jder-std/spec). With the validator, various kinds of requests can be validated easily and send JSON responses instead of plain text responses.

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/core
Description: A standard response builder
Author: Alpheus
Latest version: 0.5.0

# JDER Core

A standard response builder.

This package includes different response builders based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jderstd/spec). With the builders, various kinds of responses can be created easily instead of sending plain text responses.

## Quick Start

To create a JSON response, use the following code:

```ts
import { createJsonResponse } from "@jderstd/core";

const route = (): Response => {
    return createJsonResponse();
}
```

And the response will be shown as below:

```json
{
    "success": true,
    "data": null,
    "errors": []
}
```

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/express
Description: A response builder for Express
Author: Alpheus
Latest version: 0.2.0

# JDER Express

A response builder for Express.

This package includes different response builders based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jder-std/spec). With the builders, various kinds of responses can be created easily instead of sending plain text responses.

## Quick Start

To create a JSON response, use the following code:

```ts
import type { Request, Response } from "express";

import { createJsonResponse } from "@jderstd/express";

const route = (req: Request, res: Response): Response => {
    return createJsonResponse(res);
}
```

And the response will be shown as below:

```json
{
    "success": true,
    "data": null,
    "errors": []
}
```

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/hono
Description: A response builder for Hono
Author: Alpheus
Latest version: 0.8.2

# JDER Hono

A response builder for Hono.

This package includes different response builders based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jderstd/spec). With the builders, various kinds of responses can be created easily instead of sending plain text responses.

## Quick Start

To create a JSON response, use the following code:

```ts
import { createJsonResponse } from "@jderstd/hono/response";

const route = (): Response => {
    return createJsonResponse();
}
```

And the response will be shown as below:

```json
{
    "success": true,
    "data": null,
    "errors": []
}
```

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/hono-openapi
Description: An OpenAPI helper for Hono
Author: Alpheus
Latest version: 0.2.0

# JDER Hono OpenAPI

An OpenAPI helper for Hono.

This package includes OpenAPI helper based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jderstd/spec). With the helper, various kinds of JSON responses can be sent instead of plain text responses.

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/hono-standard-validator
Description: A standard validator for Hono
Author: Alpheus
Latest version: 0.3.0

# JDER Hono Standard Validator

A standard validator for Hono.

This package includes a standard validator based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jderstd/spec). With the validator, various kinds of requests can be validated easily and send JSON responses instead of plain text responses.

## License

This project is licensed under the terms of the MIT license.
npm package: @jderstd/hono-zod-validator
Description: A Zod validator for Hono
Author: Alpheus
Latest version: 0.8.0

# JDER Hono Zod Validator

A Zod validator for Hono.

This package includes a Zod validator based on the JSON response structure specified in [JSON Data Errors Response (JDER)](https://github.com/jderstd/spec). With the validator, various kinds of requests can be validated easily and send JSON responses instead of plain text responses.

## License

This project is licensed under the terms of the MIT license.
npm package: @jdes/catcher
Description: Functional errors interceptions
Author: Jean Desravines
Latest version: 2.0.3
Deprecated: No longer maintained

# Catcher

[![Build Status](https://travis-ci.org/jeandesravines/catcher.svg)](https://travis-ci.org/jeandesravines/catcher)
[![Coverage Status](https://coveralls.io/repos/github/jeandesravines/catcher/badge.svg?branch=master)](https://coveralls.io/github/jeandesravines/catcher?branch=master)

Functional errors interceptions

## Table of contents

* [Setup](#setup)
* [Usage](#usage)
* [Examples](#examples)
 

## Setup

This module can then be installed with npm:
```shell
npm install @jdes/catcher
```


## Usage

Import module:

```javascript
/**
 * @type {function}
 */
const Catcher = require('@jdes/catcher');
```

## API

### Methods

#### resolve(fn: function: * [, defaults: * = undefined]): *

* `fn`: The function to execute and which can throws an Error.
* `direction`: The defaults value to return if `fn` fails

Execute the function `fn` surrounding with try/catch block. 
If all is ok, `catcher` returns the value returned by `fn`.


#### reject(error: Error = new Error())

* `error`: The error to throw

Throws the error give in arguments.


## Examples

### Resolves with "fs" package

```javascript
const fs = require('fs');
const promisify = require('@jdes/promisify');
const Catcher = require('@jdes/catcher');

// Call fs.accessSync which throws an error with unknown path
const filename = './unknown';
const exists = Catcher.resolve(() => fs.accessSync(filename)) ? true : false;

if (exists) {
  promisify(fs.readFile)(filename)
    .then((data) => console.log(data))
    .catch((error) => console.error(error));
}
```

### Resolve with default value

```javascript
const Catcher = require('@jdes/catcher');

// Check if the argument is equal to "jimmy" (after transform it to lower case).
// If it is not, it throws an Error.
// The Error is catched by the catcher and returns the default value : false
const isJimmy = (name) => {
  if (name.toLowerCase() !== 'jimmmy') {
    throw new Error();
  }
  
  return true;
};

if (Catcher.resolve(() => isJimmy('Toto'), false)) {
  console.log('Hello Jimmy');
} else {
  console.error('Who are you?');
}
```

### Reject functionally

```javascript
const Catcher = require('@jdes/catcher');

// Returns true if name equals "jimmy" or throws an Error
const isJimmy = (name) => {
	return name.toLowerCase() === 'jimmy' || Catcher.reject(new Error());
};

try {
  if (isJimmy('Toto')) {
  	console.log('Hello Jimmy');
  }
} catch (error) {
	console.error('Who are you?');
}
```
npm package: @jdes/env-cleaner
Description: Environment cleaner for NPM
Author: Jean Desravines
Latest version: 1.0.0
Deprecated: No longer maintained

# Environment Cleaner

[![Build Status](https://travis-ci.org/jeandesravines/env-cleaner.svg)](https://travis-ci.org/jeandesravines/env-cleaner)
[![Coverage Status](https://coveralls.io/repos/github/jeandesravines/env-cleaner/badge.svg?branch=master)](https://coveralls.io/github/jeandesravines/env-cleaner?branch=master)

Environment cleaner for Node.js and Mocha.  
Can be used to clean `process.env` and `require.cache` between each tests.


## Table of contents

* [Setup](#setup)
* [Usage](#usage)
* [API](#api)
  * [Methods](#methods) 
* [Example](#example)
 

## Setup

This module can then be installed with npm:
```shell
npm install @jdes/env-cleaner
```


## Usage

Import module:

```javascript
/**
 * @class {EnvCleaner}
 */
const EnvCleaner = require('@jdes/env-cleaner');
```


## API

### Methods

#### EnvCleaner.register(name: string): undefined

* `name`: Module's name or path

Register a module to clean.

Example:

```javascript
const EnvCleaner = require('@jdes/env-cleaner');

EnvCleaner.register(require.resolve('../modules/module-one'));
EnvCleaner.register(require.resolve('../modules/module-two'));
```

#### EnvCleaner.clean(): undefined

Clean `process.env` and `require.cache`.

Example:

```javascript
const EnvCleaner = require('@jdes/env-cleaner');

EnvCleaner.clean();
```


## Example

This example comes from the `index.js` file of the `@jdes/gpio` module tests.  
It cleans the cache before and after each Mocha test

```javascript
// /test/index.js

const {before, beforeEach, afterEach} = require('mocha');
const EnvCleaner = require('@jdes/env-cleaner');

/* ********************************** */

before('Register modules to clean', () => {
  // Register the configuration file by default because it depends on process.env
  // which can be override by any test
  EnvCleaner.register(require.resolve('../lib/configuration/configuration'));
});

beforeEach('Clean require.cache', EnvCleaner.clean);
afterEach('Clean require.cache', EnvCleaner.clean);
```
npm package: @jdes/homebridge-tost-corp-somfy-rts-web
Description: A Homebridge plugin to easily control your Somfy blinds using the TOST Corp box for Somfy RTS
Author: Jean Desravines
Latest version: 2.2.0

# Homebridge TOST Corp Somfy RTS Web

[![Verified by Homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
[![Version](https://badgen.net/npm/v/@jdes/homebridge-tost-corp-somfy-rts-web/latest?icon=npm&label)](https://www.npmjs.com/package/@jdes/homebridge-tost-corp-somfy-rts-web)
[![Downloads](https://badgen.net/npm/dt/@jdes/homebridge-tost-corp-somfy-rts-web/latest?label=downloads)](https://www.npmjs.com/package/@jdes/homebridge-tost-corp-somfy-rts-web)

An Homebridge plugin (**very unofficial**) to easily control your Somfy blinds using the TOST Corp box for Somfy RTS.

## Requirements

- A [TOST Corp box for Somfy RTS](https://www.tostcorp.com/boxsomfyrts)
- A running instance of an Homebridge server

## Installation

```bash
sudo npm install -g @jdes/homebridge-tost-corp-somfy-rts-web
```

## Configuration

### TOST Corp configuration

This plugin uses the TOST Corp's configuration to work.  
So, you have to complete [the TOST Corp's tutorial](https://www.tostcorp.com/plug-and-play) and specify all your Somfy devices with their topics and names.

### Homebridge Configuration

In the Homebridge's `config.json` file, add a new `TOSTCorpSomfyRTSWeb` platform (in the existing `platforms` node) to specify your TOST Corp Device ID (with the key named `id`) and your devices.

```json
{
  "platforms": [
    {
      "platform": "TOSTCorpSomfyRTSWeb",
      "id": "<your_tost_corp_device_id>",
      "devices": [
        {
          "topic": "<topic_room_1_blind_1>",
          "name": "Room 1 - Blind 1",
          "duration": 10000
        },
        {
          "topic": "<topic_room_1_blind_2>"
        }
      ]
    }
  ]
}
```

**Warning**: After saving the configuration, you have to restart the Homebridge server to let the plugin automatically discover all your Somfy devices.

### Configuration Parameters

- `platform`:
  - type: `"TOSTCorpSomfyRTSWeb"`
  - required: `true`
- `id`:
  - type: `string`
  - required: `true`
  - Description: TOST Corp device's ID
- `devices`:
  - type: `array`
  - required: `true`
  - description: Accessories to customize
  - items:
    - `topic`:
      - type: `string`
      - required: `true`
      - description: Accessory's topic
    - `name`:
      - type: `string`
      - required: `false`
      - description: Accessory's name
    - `duration`:
      - type: `number`
      - required: `false`
      - description: Duration (in milliseconds) of the total opening/closing phase
      - default: `20000`

## Contributors

A big thank you to [TheAbstractDev](https://github.com/TheAbstractDev) for initiating the contribution to this repository

## Special thanks

A special thanks to [TOST Corp](https://www.tostcorp.com/boxsomfyrts) for this incredible device and to [Homebridge](https://github.com/homebridge/homebridge) for making this possible.
npm package: @jdes/jest-sandbox
Description: A Sinon's sandbox like for Jest
Author: Jean Desravines
Latest version: 2.0.0
Deprecated: No longer maintained

# Jest Sandbox

[![Build Status](https://travis-ci.org/jeandesravines/jest-sandbox.svg)](https://travis-ci.org/jeandesravines/jest-sandbox)
[![Coverage Status](https://coveralls.io/repos/github/jeandesravines/jest-sandbox/badge.svg)](https://coveralls.io/github/jeandesravines/jest-sandbox)

A Sinon's sandbox like for Jest Edit

## Table of contents

* [Setup](#setup)
* [API](#api)
* [Examples](#examples)


## Setup

```shell
npm install --save-dev @jdes/jest-sandbox
```

## API

### spyOn(target: Object, property: string, create: ?boolean): Function 

This method works like `jest.spyOn` with the only difference that 
if the property to mocks does not exist and the parameters `create` is `true`, it will be created.

```javascript
  const object = {};
  const spy = sandbox.spyOn(object, "add", true)
    .mockImplmentation((a, b) => a + b);
    
  expect(object.add(20, 22)).toBe(42);
```

### restoreAllMocks(): void

Calls `.mockRestore()` on all spies in the sandbox.  

```javascript
  afterEach(() => {
    sandbox.restoreAllMocks();
  });
```

## Examples

```javascript
import Sandbox from "@jdes/jest-sandbox"

describe("Readme's examples", () => {
  const sandbox = new Sandbox();

  afterEach(() => {
    sandbox.restoreAllMocks();
  });

  test("should calls API", () => {
    const service = {
      callApi: () => Promise.reject()
    };

    const spyLog = sandbox.spyOn(service, "log", true)
      .mockImplementation((log) => log);

    const spyCallApi = sandbox.spyOn(service, "callApi")
      .mockImplementation((path) => {
        service.log(`GET ${path}`);
        return Promise.resolve('Hello');
      });

    return service.callApi('/')
      .then((response) => {
        expect(spyCallApi).toHaveBeenCalled();
        expect(spyLog).toHaveBeenCalledWith('GET /');
        expect(response).toBe("Hello");
      });
  });
});
```
npm package: @jdes/mutex
Description: Asynchronous, synchronous and delayed Mutex with Promises.
Author: Jean Desravines
Latest version: 1.2.0
Deprecated: No longer maintained

# Mutex

Asynchronous, synchronous and delayed Mutex with ES6 and Promises.


## Table of contents

* [Setup](#setup)
* [Usage](#usage)
* [API](#api)
  * [Properties](#properties) 
  * [Methods](#methods) 


## Setup

This module can then be installed with yarn:
```shell
yarn add @jdes/mutex
```

## Usage

Import module:

```javascript
/**
 * @class {Mutex}
 */
const Mutex = require('@jdes/mutex');
```

Instantiate:

```javascript
/**
 * @type {Mutex}
 */
const mutex = new Mutex();
```

Example:

```javascript
// Instantiate
const mutex = new Mutex();
let name = null;
let iterations = 0;

// Lock and perform and unlock asynchronously
mutex.asynchronous()
  .then((unlock) => {
    name = 'Jean Desravines';
    unlock();
  })
  .catch(() => {
    console.error('Mutex is locked');
  });

// Lock, perform and unlock asynchronously with delay.
// This section try to lock every 100ms but the delay accept to be locked every 200ms.
const interval = setInterval(() => {
  mutex.delayed(200)
    .then(() => iterations++)
    .then(() => {
      if (iterations === 5) {
        clearInterval(interval);
      } else {
        console.log(iterations);
      }
    });
}, 100);
```


## API

### Properties

#### locked: boolean

Indicate if the mutex is locked

Example:

```javascript
console.log(mutex.locked ? 'Locked' : 'Unlocked');
```

### Methods

#### lock(): boolean

* returns true if the mutex success to lock

Try to lock synchronously the mutex and return true if it success

Example:

```javascript
if (mutex.lock()) {
  console.log('Success');
} else {
  console.error('Error');
}
```

#### unlock(): Promise

* returns a resolved Promise

Unlock the mutex

Example:

```javascript
mutex.unlock()
  .then(() => {
    console.log('Unlocked');
  });
```

#### asynchronous(): Promise

* return a Promise resolved with the unlock callback if the mutex success to lock.

Try to lock the mutex and resolve the promise

Example:

```javascript
mutex.asynchronous()
  .then((unlock) => {
    // Unlock after 1s
    setTimeout(unlock, 1000);
  });
```

#### delayed(delay: number): Promise

* `delay` the delay in ms
* return a Promise resolved with tLOCKEDhe unlock callback if the mutex success to lock.

Try to lock the mutex and resolve the promise.
The mutex can be unlocked only in a interval of `delay` ms.

The interval is computed when the method is called so you can unlock the mutex before the end of the interval with
`mutex.unlock()` or
invoke an othe `mutex.delay(delay: number)` with a lesser delay.

You should have a mutex for every feature and not reuse a mutex for others.
It is useful to keep performance on polling functions.

Example:

```javascript
let iterations = 0;
const interval = setInterval(() => {
  mutex.delayed(200)
    .then(() => {
      if (iterations++ === 5) {
        clearInterval(interval);
      } else {
        console.log(iterations);
      }
    });
}, 100);
```
npm package: @jdes/promisify
Description: Promisify Node.js's callback functions and modules
Author: Jean Desravines
Latest version: 1.1.61
Deprecated: You should use utils/promisify instead

# Promisify

[![Build Status](https://travis-ci.org/jeandesravines/promisify.svg)](https://travis-ci.org/jeandesravines/promisify)
[![Coverage Status](https://coveralls.io/repos/github/jeandesravines/promisify/badge.svg)](https://coveralls.io/github/jeandesravines/promisify)

Promisify Node.js's callback functions and modules


## Table of contents

* [Setup](#setup)
* [Usage](#usage)
  * [Import module](#import-module)
  * [Promisify a module by name](#promisify-a-module-by-name)
  * [Promisify a function](#promisify-a-function)
* [API](#api)
* [Example](#example)


## Setup

This module can then be installed with npm:

```shell
npm install @jdes/promisify
```

## Usage

### Import module

```javascript
/**
 * @type {Function}
 */
const promisify = require('@jdes/promisify');
```

### Promisify a module by name

```javascript
/**
* @type {Object}
*/
const fs = promisify('fs');
```

### Promisify a function

```javascript
/**
 * @type {Object}
 */
const fs = require('fs');

/**
 * @type {Object}
 */
const promisify = require('@jdes/promisify');

/**
 * @type {function}
 */
const readFile = promisify(fs.readFile);
```

## API

### promisify(data: Object | string | function): function(...[*]): Promise

## Example

```javascript
// Import the modue
const promisify = require('@jdes/promisify');

// Promisify by module name
const fs = promisify('fs');

// read file
fs.readFile('/dev/null')
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.error(error);
  });
```