open-index/open-npm huggingface dataset:
npm package: @repit/lambda-cache
Description: Short-term, in-memory caching for AWS Lambda.
Author: Ion Suman
Latest version: 1.0.3


# Lambda Cache

Short-term, in-memory caching for AWS Lambda.

## Installation

```bash
$ npm install @repit/lambda-cache --save
```

## Usage

```js
'use strict'

// Load the Cache class.
const Cache = require('@repit/lambda-cache')

// Create a Cache object.
const cache = new Cache()

exports.handler = (event, context, callback) => {
  // Used for cache invalidation.
  cache.validate(event)

  // Get the number of items in the cache.
  cache.size() // 0 ... n

  // Check if cache is empty.
  cache.empty() // true || false

  // Add a new item to cache.
  // Note: When `ttl` is not provided item will not expire.
  cache.set(key, value, ttl)

  // Get an item from cache.
  // Note: Returns `undefined` when item is not found or it is expired.
  cache.get(key)

  // Check if an item is in cache and it is not expired.
  cache.has(key) // true || false

  // Remove an item from cache.
  cache.remove(key)

  // Remove all items from cache.
  cache.clear()
}
```

## Cache invalidation.

Cache invalidation is done by comparing a saved cache token with a given cache token.
If they don't match then cache token is updated with the last one and cache is cleared.

To check if cache should be invalidated call `cache.validate(event)`
at the top of your lambda function handler.

**Cache tokens are expected to be found as follows:**

```json
{
  "cacheToken": "TOKEN_VALUE",
  "queryStringParameters": {
    "tkn": "TOKEN_VALUE"
  }
}
```

## Notes

- Each instance of `Cache` class has it's own cache store.
- Cache will be kept as long as your lambda function is warm.

## Testing

```bash
$ npm test
```

## License

MIT
npm package: @repit/lambda-ip
Description: Determine IP address of the client in AWS Lambda.
Author: Ion Suman
Latest version: 1.0.0


# AWS Lambda IP

Determine IP address of the client in AWS Lambda.

## Requirements

There are several requirements in order to be able to determine the IP address:

- You should use **API Gateway**.
- **Integration Type** should be **Lambda Function**.
- **Use Lambda Proxy Integration** should be enabled.

## Installation

```bash
$ npm install @repit/lambda-ip --save
```

## Usage

```js
'use strict'

const ip = require('@repit/lambda-ip')

module.handler = (event, context, callback) => {
  callback(null, {
    statusCode: 200,
    body: JSON.stringify({
      ip: ip(event)
    })
  })
}
```

## Returned Values

Possible return values are:

- A valid *public* IPv4 address.
- A valid *public* IPv6 address.
- `null`.

## Security

In the modern web, it is very likely that a request to your app
will hit at least one proxy before your code will be executed and
it is almost impossible to be 100% sure that we get the *real* IP address
of the client as at any moment headers may be spoofed, but we do as much as
we can to determine a valid *public* IP address,
which is *probably* the *real* IP address of the client.

## License

MIT
npm package: @repit/lambda-localize
Description: AWS Lambda response localization.
Author: Ion Suman
Latest version: 1.0.6


# Lambda Localize

AWS Lambda response localization.

## Installation

```bash
$ npm install @repit/lambda-localize --save
```

## Usage

```js
'use strict'

// Load the Localize class.
const Localize = require('@repit/lambda-localize')

exports.handler = (event, context, callback) => {
  // Create a new Localize object.
  const localize = new Localize(callback)

  // Send a localized response with default structure.
  localize.send(200, 'Message:UserCreated', 'fr')

  // Send a localized response with custom structure.
  localize.send(200, 'Message:UserCreated', 'fr', message => ({
    message,
    userId: 1000000,
  }))
}
```

## Localization

Localization is done using [@repit/lambda-query](https://www.npmjs.com/package/@repit/lambda-query) package.
For details about how it works see the package page.

## Response Structure

Responses are sent using [@repit/lambda-send](https://www.npmjs.com/package/@repit/lambda-send) package.
Details about how response is formatted can be found on the package page.

## Caching

By default `Localize` class does not do any caching, but it can internally forward the `Cache (@repit/lambda-cache)` object to the `Query (@repit/lambda-query)` object and all localization queries will be cached.

*Here is a basic example on how to use caching:*

```js
'use strict'

const Localize = require('@repit/lambda-localize')
const Cache = require('@repit/lambda-cache')

const cache = new Cache()

exports.handler (event, context, callback) => {
  const localize = new Localize(callback, cache)
}
```

> For more details about caching see [@repit/lambda-cache](https://www.npmjs.com/package/@repit/lambda-cache) package.

## License

MIT
npm package: @repit/lambda-param
Description: Parse parameters in AWS Lambda.
Author: Ion Suman
Latest version: 1.0.1


# Lambda Param

Parse parameters in AWS Lambda.

## Installation

```bash
$ npm install @repit/lambda-param --save
```

## Usage

```js
'use strict'

const param = require('@repit/lambda-param')

exports.handler = (event, context, callback) => {
  // Parse `foo` from `queryStringParameters`.
  param(event, 'foo') // value || null

  // Parse `foo` from `pathParameters`.
  param.path(event, 'foo') // value || null

  // Parse `foo` from `headers`.
  param.headers(event, 'foo') // value || null

  // Parse `foo` from `queryStringParameters`,
  // and test it against a given regexp.
  param(event, 'foo', /^[A-Z]{2}$/) // value || null

  // Parse `foo` from `queryStringParameters`,
  // and make sure it is contained in a given object.
  param(event, 'foo', null, { foo: true }) // value || null

  // Parse `foo` from `queryStringParameters`,
  // and make sure it is contained in a given array.
  param(event, 'foo', null, ['foo']) // value || null
}
```

## License

MIT
npm package: @repit/lambda-query
Description: Simple & Opinionated DynamoDB Query API for AWS Lambda.
Author: Ion Suman
Latest version: 1.0.0


# Lambda Query

Simple & Opinionated DynamoDB Query API for AWS Lambda.

## Installation

```bash
$ npm install @repit/lambda-query --save
```

## Usage

```js
'use strict'

// Load the Query class.
const Query = require('@repit/lambda-query')

// Create a new Query object.
const query = new Query()

// Configure AWS DynamoDB.
// Note: This is not required if you add proper IAM roles.
query.configure({
  region: '',
  accessKeyId: '',
  secretAccessKey: ''
})

// Change default table name.
// Note: Default table name is `Store`.
query.tableName('')

// Get current instance of `DocumentClient`.
query.client()

// Read a single item from DynamoDB which match: { Type: 'Error', Name: 'InvalidUser' },
// and include all attributes.
query.resolve('Error:InvalidUser:*') // Promise

// Read a single item from DynamoDB which match: { Type: 'Error', Name: 'InvalidUser' },
// and include only `en,fr,de` attributes.
query.resolve('Error:InvalidUser:en,fr,de') // Promise

// Read many items from DynamoDB which match: { Type: 'Error' },
// and include all attributes.
query.resolve('Error:*:*') // Promise

// Read many items from DynamoDB which match: { Type: 'Error' },
// and include only `en,fr,de` attributes.
query.resolve('Error:*:en,fr,de') // Promise

// Read many items from DynamoDB which match:
// { Type: 'Error', Name: 'InvalidUser' } and { Type: 'Error', Name: 'InvalidEmail' },
// and include only `en,fr,de` attributes.
query.resolve([
  'Error:InvalidUser:en',
  'Error:InvalidEmail:fr,de'
]) // Promise
```

## Caching

This package requires [@repit/lambda-cache](https://www.npmjs.com/package/@repit/lambda-cache) to cache queries.

**Usage is pretty simple:**

```js
'use strict'

const Query = require('@repit/lambda-query')
const Cache = require('@repit/lambda-cache')

const cache = new Cache()

exports.handler = (event, context, callback) => {
  const query = new Query(cache)
}
```

> To learn how to invalidate cache visit:
  [@repit/lambda-cache](https://www.npmjs.com/package/@repit/lambda-cache)

## Table Structure

Default table name is `Store`, which can be changed with `query.tableName(name)`.

Primary key requirements:

- **Partition Key** should be `Type (String)`;
- **Sort Key** should be `Name (String)`;

## License

MIT
npm package: @repit/lambda-send
Description: AWS Lambda responses simplified.
Author: Ion Suman
Latest version: 2.0.1


# Lambda Send

AWS Lambda responses simplified.

## Installation

```bash
$ npm install @repit/lambda-send --save
```

## Usage

```js
'use strict'

const send = require('@repit/lambda-send')

exports.handler = (event, context, callback) => {
  // Send a default success response.
  send(callback, 200)

  // Send a custom success message.
  send(callback, 200, 'All right.')

  // Send a custom success message.
  send(callback, 200, {
    countryCode: 'US'
  })

  // Send a default error response.
  send(callback, 400)

  // Send a custom error response.
  send(callback, 400, 'Something went wrong.')

  // Send a custom error response.
  send(callback, 400, {
    reason: 'Something went wrong.'
  })

  // Disable CORS.
  send(callback, 200, null, {
    cors: false // Default: true.
  })

  // Send custom headers.
  send(callback, 200, null, {
    headers: {
      //
    }
  })

  // Add properties to the response body.
  send(callback, 200, null, {
    body: {
      //
    }
  })
}
```


## Response Structure

- Success response:

```js
{
  "ok": true, // statusCode === 200
  "payload": null || <user defined payload>,
  <user defined property name>: <user defined property value>
}
```

- Error response:

```js
{
  "ok": false, // statusCode !== 200
  "code": <user defined status code>,
  "payload": "Resource is not available." || <user defined payload>,
  <user defined property name>: <user defined property value>
}
```

## Testing

```bash
$ npm test
```

## License

MIT
npm package: @repit/q
Description: A better way to write AWS Lambda functions.
Author: Ion Suman
Latest version: 0.0.2

# Repit Q

A better way to write AWS Lambda functions.

## Installation

```bash
$ npm install @repit/q --save
```

## Usage

```js
'use strict'

const q = require('@repit/q')()

// Define a basic middleware.
q((req, res) => {
  // Do something and stop.
})

// Define a basic middleware.
q((req, res, next) => {
  // Do something and continue.
  next()
})

// Define a middleware which sends an error.
q((req, res, next) => {
  // Do something and send an error to error handlers.
  next(new Error('Something went wrong.'))
})

// Define an error handler middleware.
q((err, req, res, next) => {
  // Do something with the error and continue.
  next()
})

// Define an error handler middleware.
q((err, req, res, next) => {
  // Do something with the error and stop.
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-cache
Description: R/Q Middleware for short-term caching in AWS Lambda.
Author: Ion Suman
Latest version: 0.0.2


# Repit Q-Cache

R/Q Middleware for short-term caching in AWS Lambda.

## About

This module is a wrapper for [@repit/lambda-cache](https://www.npmjs.com/package/@repit/lambda-cache).

## Installation

```bash
$ npm install @repit/q-cache --save
```

## Usage

```js
'use strict'

const q = require('@repit/q')()
const cache = require('@repit/q-cache')

q(cache({
  // Specify if cache should be invalidated.
  invalidate: true, // Default: true

  // Set a custom cache key.
  key: 'cache' // Default: 'cache'
}))

q((req, res) => {
  req.cache // The Cache object.
  res.cache // The Cache object.
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-db
Description: R/Q Middleware to query DynamoDB in AWS Lambda.
Author: Ion Suman
Latest version: 0.0.1


# Repit Q-Db

R/Q Middleware to query DynamoDB in AWS Lambda.

## About

This module is a wrapper for [@repit/lambda-query](https://www.npmjs.com/package/@repit/lambda-query).

## Installation

```bash
$ npm install @repit/q-db --save
```

## Usage

```js
'use strict'

const q = require('@repit/q')()
const db = require('@repit/q-db')

q(db({
  // Use caching.
  cache: true // Default: false
}))

q((req, res) => {
  // The database object.
  req.db('')
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-locales
Description: R/Q Middleware to determine locale in AWS Lambda.
Author: Ion Suman
Latest version: 0.0.2

# Repit Q-Locales

R/Q Middleware to determine locale in AWS Lambda.

## Installation

```bash
$ npm install @repit/q-locales --save
```

## Requirements

- [@repit/q-param](https://www.npmjs.com/package/@repit/q-param)

## Usage

```js
'use strict'

const q = require('@repit/q')()
const locales = require('@repit/q-locales')

q(locales())

q((req, res) => {
  // Set the default locale.
  req.defaultLocale('fr') // Default: 'en'

  // Get the default locale.
  req.defaultLocale() // fr

  // Set availalbe locales.
  req.availableLocales([ 'fr', 'de', 'es' ]) // Default: []

  // Get available locales.
  req.availableLocales() // [ 'fr', 'de', 'es' ]

  // Get current locale.
  // Returns a value matched from query string `?hl=locale`,
  // or the default locale.
  req.locale() // locale || req.defaultLocale()

  // Get current accepted locales.
  req.locales() // [ req.locale(), req.defaultLocale() ]
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-localize
Description: R/Q Middleware for AWS Lambda localization.
Author: Ion Suman
Latest version: 0.0.1


# Repit Q-Localize

R/Q Middleware for AWS Lambda localization.

## About

This module is a wrapper for [@repit/lambda-localize](https://www.npmjs.com/package/@repit/lambda-localize).

## Installation

```bash
$ npm install @repit/q-localize --save
```

## Requirements

- [@repit/q-locales](https://www.npmjs.com/package/@repit/q-locales)
- [@repit/q-cache](https://www.npmjs.com/package/@repit/q-cache)

## Usage

```js
'use strict'

const q = require('@repit/q')()
const localize = require('@repit/q-localize')

q(localize({
  // Use caching.
  cache: true // Default: false
}))

q((req, res) => {
  // Send a success message.
  res.localize('Message:UserCreated')

  // Send an error message.
  res.code(400).localize('Error:InvalidUserName')
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-param
Description: R/Q Middleware to parse parameters in AWS Lambda.
Author: Ion Suman
Latest version: 0.0.3


# Repit Q-Param

R/Q Middleware to parse parameters in AWS Lambda.

## About

This module is a wrapper for [@repit/lambda-param](https://www.npmjs.com/package/@repit/lambda-param).

## Installation

```bash
$ npm install @repit/q-param --save
```

## Usage

```js
'use strict'

const q = require('@repit/q')()
const param = require('@repit/q-param')

q(param())

q((req, res) => {
  // Return a single query string parameter value.
  req.query(key, rule, contains)

  // Return all query string parameters as an object.
  req.query.all()

  // Return a single path parameter value.
  req.path(key, rule, contains)

  // Return all path parameters as an object.
  req.path.all()

  // Return a single header value.
  req.header(key, rule, contains)

  // Return all headers as an object.
  req.header.all()

  // Return a single header value.
  req.headers(key, rule, contains)

  // Return all headers as an object.
  req.headers.all()
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/q-send
Description: R/Q Middleware to simplify AWS Lambda responses.
Author: Ion Suman
Latest version: 0.0.1


# Repit Q-Send

R/Q Middleware to simplify AWS Lambda responses.

## About

This module is a wrapper for [@repit/lambda-send](https://www.npmjs.com/package/@repit/lambda-send).

## Installation

```bash
$ npm install @repit/q-send --save
```

## Usage

```js
'use strict'

const q = require('@repit/q')()
const send = require('@repit/q-send')

q(send())

q((req, res) => {
  // Set the HTTP status code of the response.
  res.code(statusCode)

  // Enable / Disable CORS.
  res.cors(enabled) // Default: true.

  // Set custom headers of the response.
  res.headers({})

  // Set custom response body fields.
  res.body({})

  // Send the response.
  res.send(payload)
})

exports.handler = q.handler
```

## License

MIT
npm package: @repit/zipper
Description: Simple & powerful CLI tool that will archive any directory.
Author: Ion Suman
Latest version: 1.1.0


# Zipper

Simple & powerful CLI tool that will archive any directory.

## Installation

```bash
$ npm install @repit/zipper --global
```

## Usage

Navigate to the desired directory and execute:

```bash
$ zipper
```

> Note: It will create an archive of all files in that directory including all files from all subdirectories.

## The `.zipignore` file

By default, Zipper reads all files from a directory and all files from all subdirectories and archives them, but you can specify custom files/directories/patterns which will be ignored by Zipper.

**By default, Zipper ignores the following files/directories:**

- `.DS_Store`
- `.git`

> Note: If you want to include `.git` files/folders in your archive, execute Zipper with the `--git` flag.

To add custom ignore rules create a `.zipignore` file in the directory from where you run `zipper` command.

**`.zipignore` file structure:**


```
# All lines which start with a `#` are considered comments.

# The following rule will ignore the `node_modules` file/directory from the base directory.
# NOTE: This rule will not ignore `node_modules` files/directories from subdirectories.
/node_modules

# The following rule will ignore the `node_modules` file/directory
# from the base directory and subdirectories.
node_modules

# The following rule will ignore all files/directories which start with `foo`.
# NOTE: It will ignore: `foo`, `foobar`, `foobar/baz.js` and so on.
foo*
```

## The Archive

There are some hard-coded defaults:

- Zipper creates the archive in the same directory where Zipper runs.
- The name of created archive is always `zipper.zip`.
- `.DS_Store` files can not be included in the created archive.

## License

MIT
npm package: @repl1307/zephyr-ui
Description: A frontend library that simplifies working with vanilla JS, while retaining flexibility and speed.
Author: repl1307
Latest version: 1.1.4

# Zephyr UI
## Table of Contents

> 1. [Introduction](#introduction)
> 2. [Installation](#installation)
> 3. [Usage](#usage)

## Introduction
Zephyr UI is a framework intended to simplify working with the DOM. Zephyr UI was developed with three key goals in mind: readability, flexibility, and performance. These goals are achieved by embracing the OOP paradigm and adhering closely to vanilla JavaScript, while simultaneously streamlining and removing unnecessary complexities.

## Installation
Before installing, make sure to have your project set up with a bundler. [Vite](https://vite.dev/guide/), [Webpack](https://webpack.js.org/guides/getting-started/), and [Rollup](https://rollupjs.org/tutorial/) are some popular options.

[vite]: https://github.com/vitejs/vite
[webpack]: https://github.com/webpack/webpack
[rollup]: https://github.com/rollup/rollup
Using NPM:
~~~
npm install @repl1307/zephyr-ui
~~~
Using Yarn:
~~~
yarn add @repl1307/zephyr-ui
~~~
## Usage

See the docs folder for detailed examples of various use cases.
npm package: @replace-me/sdk
Description: An SDK for building applications on top of Replace.
Latest version: 1.0.2

# Replace SDK

Forked from the [Uniswap SDK](https://github.com/Uniswap/uniswap-v2-sdk/commit/a88048e9c4198a5bdaea00883ca00c8c8e582605).

You can refer to the Uniswap SDK documentation [uniswap.org](https://uniswap.org/docs/v2/SDK/getting-started/).

## Running tests

To run the tests, follow these steps. You must have at least node v10 and [yarn](https://yarnpkg.com/) installed.

First clone the repository:

```sh
git clone https://github.com/replace-me/replace-sdk.git
```

Move into the replace-sdk working directory

```sh
cd replace-sdk/
```

Install dependencies

```sh
yarn install
```

Run tests

```sh
yarn test
```

You should see output like the following:

```sh
yarn run v1.22.4
$ tsdx test
 PASS  test/constants.test.ts
 PASS  test/pair.test.ts
 PASS  test/fraction.test.ts
 PASS  test/miscellaneous.test.ts
 PASS  test/entities.test.ts
 PASS  test/trade.test.ts

Test Suites: 1 skipped, 6 passed, 6 of 7 total
Tests:       3 skipped, 82 passed, 85 total
Snapshots:   0 total
Time:        5.091s
Ran all test suites.
✨  Done in 6.61s.
```
npm package: @replace-me/uikit
Description: Set of UI components for replace projects
Latest version: 0.18.0

# 🥞 Pancake UIkit

[![Version](https://img.shields.io/npm/v/@pancakeswap-libs/uikit)](https://www.npmjs.com/package/@pancakeswap-libs/uikit) [![Size](https://img.shields.io/bundlephobia/min/@pancakeswap-libs/uikit)](https://www.npmjs.com/package/@pancakeswap-libs/uikit)

Pancake UIkit is a set of React components and hooks used to build pages on Pancake's apps. It also contains a theme file for dark and light mode.

## Install

`yarn add @replace-me/uikit`

## Setup

### Theme

Before using Pancake UIkit, you need to provide the theme file to styled-component.

```
import { ThemeProvider } from 'styled-components'
import { light, dark } from '@replace-me/uikit'
...
<ThemeProvider theme={isDark}>...</ThemeProvider>
```

### Reset

A reset CSS is available as a global styled component.

```
import { ResetCSS } from '@replace-me/uikit'
...
<ResetCSS />
```

### Types

This project is built with Typescript and export all the relevant types.

## How to use the UIkit

If you want to use components from the UIkit, check the [Storybook documentation](https://pancakeswap.github.io/pancake-uikit/)
npm package: @replace5/app-builder-bin
Description: app-builder precompiled binaries
Latest version: 3.5.9
Deprecated: false

# app-builder

Generic helper tool to build app in a distributable formats.
Used by [electron-builder](http://github.com/electron-userland/electron-builder) but applicable not only for building Electron applications.

```
usage: app-builder [<flags>] <command> [<args> ...]

app-builder

Flags:
  --help     Show context-sensitive help (also try --help-long and --help-man).
  --version  Show application version.

Commands:
  help [<command>...]
    Show help.


  blockmap --input=INPUT [<flags>]
    Generates file block map for differential update using content defined
    chunking (that is robust to insertions, deletions, and changes to input
    file)

    -i, --input=INPUT       input file
    -o, --output=OUTPUT     output file
    -c, --compression=gzip  compression, one of: gzip, deflate

  download --url=URL --output=OUTPUT [<flags>]
    Download file.

    -u, --url=URL        The URL.
    -o, --output=OUTPUT  The output file.
        --sha512=SHA512  The expected sha512 of file.

  download-artifact --name=NAME --url=URL [<flags>]
    Download, unpack and cache artifact from GitHub.

    -n, --name=NAME      The artifact name.
    -u, --url=URL        The artifact URL.
        --sha512=SHA512  The expected sha512 of file.

  copy --from=FROM --to=TO [<flags>]
    Copy file or dir.

    -f, --from=FROM
    -t, --to=TO
        --hard-link  Whether to use hard-links if possible

  appimage --app=APP --stage=STAGE --output=OUTPUT [<flags>]
    Build AppImage.

    -a, --app=APP                  The app dir.
    -s, --stage=STAGE              The stage dir.
    -o, --output=OUTPUT            The output file.
        --arch=x64                 The arch.
        --compression=COMPRESSION  The compression.
        --remove-stage             Whether to remove stage after build.

  snap --app=APP --stage=STAGE --output=OUTPUT [<flags>]
    Build snap.

    -t, --template=TEMPLATE  The template file.
    -u, --template-url=TEMPLATE-URL
                             The template archive URL.
        --template-sha512=TEMPLATE-SHA512
                             The expected sha512 of template archive.
    -a, --app=APP            The app dir.
    -s, --stage=STAGE        The stage dir.
        --icon=ICON          The path to the icon.
        --hooks=HOOKS        The hooks dir.
        --arch=amd64         The arch.
    -o, --output=OUTPUT      The output file.
        --docker-image="snapcore/snapcraft:latest"
                             The docker image.
        --docker             Whether to use Docker.
        --remove-stage       Whether to remove stage after build.

  icon --input=INPUT --format=FORMAT --out=OUT [<flags>]
    create ICNS or ICO or icon set from PNG files

    -i, --input=INPUT ...  input directory or file
    -f, --format=FORMAT    output format
        --out=OUT          output directory
    -r, --root=ROOT ...    base directory to resolve relative path

  dmg --volume=VOLUME [<flags>]
    Build dmg.

    --volume=VOLUME
    --icon=ICON
    --background=BACKGROUND
```
npm package: @replace5/electron-is-dev
Description: Check if Electron is running in development
Author: feng524822
Latest version: 2.0.0
Deprecated: false

# electron-is-dev

> Check if [Electron](https://electronjs.org) is running in development

Useful for enabling debug features only during development.

This package must be used from the Electron main process.

## Install

```
$ npm install electron-is-dev
```

*Requires Electron 3 or later.*

## Usage

```js
const isDev = require('electron-is-dev');

if (isDev) {
	console.log('Running in development');
} else {
	console.log('Running in production');
}
```

You can force development mode by setting the `ELECTRON_IS_DEV` environment variable to `1`.

## Related

- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app
npm package: @replace5/keyboardevent-from-electron-accelerator
Description: Transform an Electron Accelerator string into a DOM KeyboardEvent.
Author: feng524822
Latest version: 1.1.0

# keyboardevent-from-electron-accelerator

[![Travis Build Status](https://img.shields.io/travis/parro-it/keyboardevent-from-electron-accelerator/master.svg)](http://travis-ci.org/parro-it/keyboardevent-from-electron-accelerator)
[![NPM downloads](https://img.shields.io/npm/dt/keyboardevent-from-electron-accelerator.svg)](https://npmjs.org/package/keyboardevent-from-electron-accelerator)
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/l1qdd90e7xagkgq7/branch/master?svg=true)](https://ci.appveyor.com/project/parro-it/keyboardevent-from-electron-accelerator/branch/master)

> Transform an Electron Accelerator string into a DOM KeyboardEvent.

This module export a function that take an Electron Accelerator as input
and return a corresponding KeyboardEvent object.

E.g. `'Ctrl+Alt+C' => {code: 'c', ctrlKey: true, altKey: true}`

## Usage

This example convert a string containing an Electron Accelerator to a corresponding KeyboardEvent object. Returned object is the keyevent that would be emitted if that key combination was pressed.

```js
const {toKeyEvent} = require('keyboardevent-from-electron-accelerator');
console.log(toKeyEvent('Shift+Delete'));
```

This will output

    {key: 'Delete', shiftKey: true}

## Context and motivation for this module.

This module is part of an ongoing effort to make [electron-localshortcut](https://github.com/parro-it/electron-localshortcut) less error prone, using keyboard DOM listener instead of 'globalShortcut' method to trigger shortcuts handlers.

`electron-localshortcut` will listen for DOM `keydown` and `keyup` events, and will
trigger shortcuts handlers if emitted DOM events match the Accelerator.

This module wrap the core logic of that match operation.

You can help by testing the module on [runkit](https://npm.runkit.com/keyboardevent-from-electron-accelerator) and [opening an issue](https://github.com/parro-it/keyboardevent-from-electron-accelerator/issues/new) if you found some wrong
result.


## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### toKeyEvent

This function transform an Electron Accelerator string into
a DOM KeyboardEvent object.

**Parameters**

-   `accelerator` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** an Electron Accelerator string, e.g. `Ctrl+C` or `Shift+Space`.

Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** a DOM KeyboardEvent object derivate from the `accelerator` argument.

## Install

With [npm](https://npmjs.org/) installed, run

    $ npm install keyboardevent-from-electron-accelerator

## See Also

-   [`noffle/common-readme`](https://github.com/noffle/common-readme)

## License

MIT