open-index/open-npm huggingface dataset:
npm package: @nkcmr/bool
Description: cast damn near anything to a logical boolean
Author: Nick Comer
Latest version: 1.1.0

### bool
cast truthy stuff to a boolean value
```javascript
var bool = require('@nkcmr/bool')
bool('true') // => true
bool('yes') // => true
bool('no') // => false
bool('false') // => false
bool(0) // => false
bool(1) // => true
bool(-1) // => false
bool({}) // => false
bool({ foo: 'bar' }) // => true
```
theres more, check the code. it is pretty brief, but handy.
npm package: @nkduy/babel-helper-fixtures
Description: Helper function to support fixtures
Author: NKDuy
Latest version: 6.22.0

# @nkduy/babel-helper-fixtures

**NOTE:** This is an internal Babel module and may not work outside. Use at your own risk.

## Usage

```javascript
import getFixtures from "@nkduy/babel-helper-fixtures";

type TestFile = {
  loc: string;
  code: string;
  filename: string;
};

type Test = {
  title: string;
  disabled: boolean;
  options: Object;
  exec: TestFile;
  actual: TestFile;
  expected: TestFile;
};

type Suite = {
  options: Object;
  tests: Array<Test>;
  title: string;
  filename: string;
};

let fixtures: Array<Suite> = getFixtures("/User/nkduy/Projects/babel-something/test/fixtures");
```
npm package: @nkduy/babel-helper-transform-fixture-test-runner
Description: Transform test runner for babel-helper-fixtures module
Author: NKDuy
Latest version: 6.24.1

# @nkduy/babel-helper-transform-fixture-test-runner

**NOTE:** This is an internal Babel module and may not work outside. Use at your own risk.

## Usage

```javascript
import runFixtures from "@nkduy/babel-helper-transform-fixture-test-runner";
import getFixtures from "@nkduy/babel-helper-fixtures";

runFixtures(getFixtures("/User/nkduy/Projects/babel-something/test/fixtures"));
```
npm package: @nkduy/babel-helpers
Description: Collection of helper functions used by Babel transforms.
Author: NKDuy
Latest version: 6.22.0

# @nkduy/babel-helpers

> Collection of helper functions used by Babel transforms.

## Install

```sh
npm install --save-dev @nkduy/babel-helpers
```

## Usage

```js
import * as helpers from '@nkduy/babel-helpers';
import * as t from '@nkduy/babel-types';

const typeofHelper = helpers.get('typeof');

t.isExpressionStatement(typeofHelper);
// true
```
npm package: @nkduy/babel-messages
Description: Collection of debug messages used by Babel.
Author: NKDuy
Latest version: 6.23.0

# @nkduy/babel-messages

> Collection of debug messages used by Babel.

## Install

```sh
npm install --save-dev @nkduy/babel-messages
```

## Usage

```js
import * as messages from '@nkduy/babel-messages';

messages.get('tailCallReassignmentDeopt');
// > "Function reference has been..."
```
npm package: @nkduy/babel-plugin-transform-regenerator
Description: Explode async and generator functions into a state machine.
Author: NKDuy
Latest version: 6.22.0

# @nkduy/babel-plugin-transform-regenerator

> Transform async/generator functions with [regenerator](https://github.com/khanhduy1407/regenerator)

## Example

**In**

```javascript
function* a() {
  yield 1;
}
```

**Out**

```javascript
var _marked = [a].map(regeneratorRuntime.mark);

function a() {
  return regeneratorRuntime.wrap(function a$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return 1;

        case 2:
        case "end":
          return _context.stop();
      }
    }
  }, _marked[0], this);
}
```

[Try in REPL](http://babeljs.io/repl/#?evaluate=true&lineWrap=true&presets=es2015%2Ces2015-loose%2Creact&experimental=false&loose=false&spec=false&code=function%20*range(max%2C%20step)%20%7B%0A%20%20var%20count%20%3D%200%3B%0A%20%20step%20%3D%20step%20%7C%7C%201%3B%0A%20%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20max%3B%20i%20%2B%3D%20step)%20%7B%0A%20%20%20%20count%2B%2B%3B%0A%20%20%20%20yield%20i%3B%0A%20%20%7D%0A%20%0A%20%20return%20count%3B%0A%7D%0A%20%0Avar%20gen%20%3D%20range(20%2C%203)%2C%20info%3B%0A%20%0Awhile%20(!(info%20%3D%20gen.next()).done)%20%7B%0A%20%20console.log(info.value)%3B%0A%7D%0A%20%0Aconsole.log(%22steps%20taken%3A%20%22%20%2B%20info.value)%3B&playground=true)

## Installation

```sh
npm install --save-dev @nkduy/babel-plugin-transform-regenerator
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```js
// without options
{
  "plugins": ["transform-regenerator"]
}
// with options
{
  "plugins": [
    ["transform-regenerator", {
      asyncGenerators: false, // true by default
      generators: false, // true by default
      async: false // true by default
    }]
  ]
}
```

### Via CLI

```sh
babel --plugins transform-regenerator script.js
```

### Via Node API

```javascript
require("@nkduy/babel-core").transform("code", {
  plugins: ["transform-regenerator"]
});
```
npm package: @nkduy/babel-preset-app
Description: babel-preset-app for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/babel-preset-app

This is the default Babel preset used in all Kdu CLI projects. **Note: this preset is meant to be used exclusively in projects created via Kdu CLI and does not consider external use cases.**
npm package: @nkduy/babel-preset-es2015
Description: Babel preset for all es2015 plugins.
Author: NKDuy
Latest version: 6.22.0

# @nkduy/babel-preset-es2015

> Babel preset for all es2015 plugins.

## Install

```sh
npm install --save-dev @nkduy/babel-preset-es2015
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "presets": ["es2015"]
}
```

### Via CLI

```sh
babel script.js --presets es2015
```

### Via Node API

```javascript
require("@nkduy/babel-core").transform("code", {
  presets: ["es2015"]
});
```

## Options

* `loose` - Enable "loose" transformations for any plugins in this preset that allow them (Disabled by default).
* `modules` - Enable transformation of ES6 module syntax to another module type (Enabled by default to `"commonjs"`).
  * Can be `false` to not transform modules, or one of `["amd", "umd", "systemjs", "commonjs"]`
* `spec` - Enable "spec" transformations for any plugins in this preset that allow them (Disabled by default)

```js
{
  presets: [
    ["es2015", { "loose": true }]
  ]
}
{
  presets: [
    ["es2015", { "modules": false }]
  ]
}
{
  presets: [
    ["es2015", { "loose": true, "modules": false }]
  ]
}
{
  presets: [
    ["es2015", { "spec": true }]
  ]
}
```
npm package: @nkduy/babel-register
Description: babel require hook
Author: NKDuy
Latest version: 6.24.2

# @nkduy/babel-register

> The require hook will bind itself to node's require and automatically compile files on the fly.

One of the ways you can use Babel is through the require hook. The require hook
will bind itself to node's `require` and automatically compile files on the
fly. This is equivalent to CoffeeScript's
[coffee-script/register](http://coffeescript.org/documentation/docs/register.html).

## Install

```sh
npm install @nkduy/babel-register --save-dev
```

## Usage

```js
require("@nkduy/babel-register");
```

All subsequent files required by node with the extensions `.es6`, `.es`, `.jsx`
and `.js` will be transformed by Babel.

<blockquote class="babel-callout babel-callout-info">
  <h4>Polyfill not included</h4>
  <p>
    You must include the <a href="https://babeljs.io/docs/usage/polyfill/">polyfill</a> separately
    when using features that require it, like generators.
  </p>
</blockquote>

### Ignores `node_modules` by default

**NOTE:** By default all requires to `node_modules` will be ignored. You can
override this by passing an ignore regex via:

```js
require("@nkduy/babel-register")({
  // This will override `node_modules` ignoring - you can alternatively pass
  // an array of strings to be explicitly matched or a regex / glob
  ignore: false
});
```

## Specifying options

```javascript
require("@nkduy/babel-register")({
  // Optional ignore regex - if any filenames **do** match this regex then they
  // aren't compiled.
  ignore: /regex/,

  // Ignore can also be specified as a function.
  ignore: function(filename) {
    if (filename === "/path/to/es6-file.js") {
      return false;
    } else {
      return true;
    }
  },

  // Optional only regex - if any filenames **don't** match this regex then they
  // aren't compiled
  only: /my_es6_folder/,

  // Setting this will remove the currently hooked extensions of .es6, `.es`, `.jsx`
  // and .js so you'll have to add them back if you want them to be used again.
  extensions: [".es6", ".es", ".jsx", ".js"]
});
```

You can pass in all other [options](https://babeljs.io/docs/usage/api/#options) as well,
including `plugins` and `presets`. But note that the closest [`.babelrc`](https://babeljs.io/docs/usage/babelrc/)
to each file still applies, and takes precedence over any options you pass in here.

## Environment variables

By default `@nkduy/babel-node` and `@nkduy/babel-register` will save to a json cache in your
temporary directory.

This will heavily improve with the startup and compilation of your files. There
are however scenarios where you want to change this behaviour and there are
environment variables exposed to allow you to do this.

### BABEL_CACHE_PATH

Specify a different cache location.

```sh
BABEL_CACHE_PATH=/foo/my-cache.json @nkduy/babel-node script.js
```

### BABEL_DISABLE_CACHE

Disable the cache.

```sh
BABEL_DISABLE_CACHE=1 @nkduy/babel-node script.js
```
npm package: @nkduy/babel-template
Description: Generate an AST from a string template.
Author: NKDuy
Latest version: 6.24.1

# @nkduy/babel-template

> Generate an AST from a string template.

In computer science, this is known as an implementation of quasiquotes.

## Install

```sh
npm install --save-dev @nkduy/babel-template
```

## Usage

```js
import template from "@nkduy/babel-template";
import generate from "@nkduy/babel-generator";
import * as t from "@nkduy/babel-types";

const buildRequire = template(`
  var IMPORT_NAME = require(SOURCE);
`);

const ast = buildRequire({
  IMPORT_NAME: t.identifier("myModule"),
  SOURCE: t.stringLiteral("my-module")
});

console.log(generate(ast).code);
```

```js
const myModule = require("my-module");
```

## API

### `template(code, [opts])`

#### code

Type: `string`

#### options

`@nkduy/babel-template` accepts all of the options from [babylon], and specifies
some defaults of its own:

* `allowReturnOutsideFunction` is set to `true` by default.
* `allowSuperOutsideMethod` is set to `true` by default.

##### preserveComments

Type: `boolean`
Default: `false`

Set this to `true` to preserve any comments from the `code` parameter.

#### Return value

`@nkduy/babel-template` returns a `function` which is invoked with an optional object
of replacements. See the usage section for an example.

[babylon]: https://github.com/khanhduy1407/babylon#options
npm package: @nkduy/cli-plugin-babel
Description: babel plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-babel

> babel plugin for nkduy-cli

## Configuration

Uses Babel 7 + `babel-loader` + [@nkduy/babel-preset-app](https://github.com/khanhduy1407/kdu-cli/tree/dev/packages/%40nkduy/babel-preset-app) by default, but can be configured via `babel.config.js` to use any other Babel presets or plugins.

By default, `babel-loader` excludes files inside `node_modules` dependencies. If you wish to explicitly transpile a dependency module, you will need to add it to the `transpileDependencies` option in `kdu.config.js`:

``` js
module.exports = {
  transpileDependencies: [
    // can be string or regex
    'my-dep',
    /other-dep/
  ]
}
```

## Caching

[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/babel-loader`.

## Parallelization

[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `kdu.config.js`.

`parallel` should be set to `false` when using Babel in combination with non-serializable loader options, such as regexes, dates and functions. These options would not be passed correctly to `babel-loader` which may lead to unexpected errors.

## Installing in an Already Created Project

``` sh
kdu add babel
```

## Injected webpack-chain Rules

- `config.rule('js')`
- `config.rule('js').use('babel-loader')`
- `config.rule('js').use('cache-loader')`
npm package: @nkduy/cli-plugin-e2e-cypress
Description: e2e-cypress plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-e2e-cypress

> e2e-cypress plugin for kdu-cli

This adds E2E testing support using [Cypress](https://www.cypress.io/).

Cypress offers a rich interactive interface for running E2E tests, but currently only supports running the tests in Chromium. If you have a hard requirement on E2E testing in multiple browsers, consider using the Selenium-based [@nkduy/cli-plugin-e2e-nightwatch](https://github.com/khanhduy1407/kdu-cli/tree/dev/packages/%40nkduy/cli-plugin-e2e-nightwatch).

## Injected Commands

- **`kdu-cli-service test:e2e`**

  Run e2e tests with `cypress run`.

  By default it launches Cypress in interactive mode with a GUI. If you want to run the tests in headless mode (e.g. for CI), you can do so with the `--headless` option.

  The command automatically starts a server in production mode to run the e2e tests against. If you want to run the tests multiple times without having to restart the server every time, you can start the server with `kdu-cli-service serve --mode production` in one terminal, and then run e2e tests against that server using the `--url` option.

  Options:

  ```
  --headless run in headless mode without GUI
  --mode     specify the mode the dev server should run in. (default: production)
  --url      run e2e tests against given url instead of auto-starting dev server
  -s, --spec (headless only) runs a specific spec file. defaults to "all"
  ```

  Additionally:

  - In GUI mode, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open);
  - In `--headless` mode, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).

  Examples :
  - Run Cypress in headless mode for a specific file: `kdu-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js`

## Configuration

We've pre-configured Cypress to place most of the e2e testing related files under `<projectRoot>/tests/e2e`. You can also check out [how to configure Cypress via `cypress.json`](https://docs.cypress.io/guides/references/configuration.html#Options).

## Environment Variables

Cypress doesn't load .env files for your test files the same way as `kdu-cli` does for your application code. Cypress supports a few ways to [define env variables](https://docs.cypress.io/guides/guides/environment-variables.html#) but the easiest one is to use .json files (either `cypress.json` or `cypress.env.json`) to define environment variables. Keep in mind those variables are accessible via `Cypress.env` function instead of regular `process.env` object.

## Installing in an Already Created Project

``` sh
kdu add e2e-cypress
```
npm package: @nkduy/cli-plugin-e2e-webdriverio
Description: e2e-webdriverio plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-e2e-webdriverio

> e2e-webdriverio plugin for kdu-cli

## Injected Commands

- **`kdu-cli-service test:e2e`**

  Run end-to-end tests with [WebdriverIO](https://webdriver.io/).

  Options:

  ```
  --remote          Run tests remotely on SauceLabs

  All WebdriverIO CLI options are also supported.

  ```

  Additionally, all [WebdriverIO CLI options](https://webdriver.io/docs/clioptions.html) are also supported.
  E.g.: `--baseUrl`, `--bail` etc.


## Project Structure

The following structure will be generated when installing this plugin:

```
tests/e2e/
  ├── pageobjects/
  |   └── app.page.js
  ├── specs/
  |   ├── app.spec.js
  └── .eslintrc.js
```

In addition to that there will be 3 configuration files generated:

- `wdio.shared.conf.js`: a shared configuration with all options defined for all environments
- `wdio.local.conf.js`: a local configuration for local testing
- `wdio.sauce.conf.js`: a remote configuration for testing on a cloud provider like [Sauce Labs](https://saucelabs.com/)

The directories contain:

#### `pageobjects`
Contains an example for an page object. Read more on using [PageObjects](https://webdriver.io/docs/pageobjects.html) with WebdriverIO.

#### `specs`
Your e2e tests.

## Installing in an Already Created Project

``` sh
kdu add e2e-webdriverio
```

For users with older CLI versions you may need to run `kdu add @nkduy/e2e-webdriverio`.

## Running Tests

By default, all tests inside the `specs` folder will be run using Chrome. If you'd like to run end-to-end tests against Chrome (or Firefox) in headless mode, simply pass the `--headless` argument. Tests will be automatically run in parallel when executed in the cloud.

```sh
$ kdu-cli-service test:e2e
```

**Running a single test**

To run a single test supply the filename path. E.g.:

```sh
$ kdu-cli-service test:e2e --spec tests/e2e/specs/test.js
```

**Skip Dev server auto-start**

If the development server is already running and you want to skip starting it automatically, pass the `--url` argument:

```sh
$ kdu-cli-service test:e2e --baseUrl=http://localhost:8080/
```
npm package: @nkduy/cli-plugin-eslint
Description: eslint plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-eslint

> eslint plugin for kdu-cli

## Injected Commands

- **`kdu-cli-service lint`**

  ```
  Usage: kdu-cli-service lint [options] [...files]

  Options:

    --format [formatter] specify formatter (default: codeframe)
    --no-fix             do not fix errors
    --max-errors         specify number of errors to make build failed (default: 0)
    --max-warnings       specify number of warnings to make build failed (default: Infinity)
  ```

  Lints and fixes files. If no specific files are given, it lints all files in `src` and `tests`.

  Other [ESLint CLI options](https://eslint.org/docs/user-guide/command-line-interface#options) are also supported.

## Configuration

ESLint can be configured via `.eslintrc` or the `eslintConfig` field in `package.json`. See the [ESLint configuration docs](https://eslint.org/docs/user-guide/configuring) for more detail.

::: tip
The following option is under the section of `kdu.config.js`. It is respected only when `@nkduy/cli-plugin-eslint` is installed.
:::

Lint-on-save during development with `eslint-loader` is enabled by default. It can be disabled with the `lintOnSave` option in `kdu.config.js`:

``` js
module.exports = {
  lintOnSave: false
}
```

When set to `true`, `eslint-loader` will emit lint errors as warnings. By default, warnings are only logged to the terminal and does not fail the compilation.

To make lint errors show up in the browser overlay, you can use `lintOnSave: 'error'`. This will force `eslint-loader` to always emit errors. this also means lint errors will now cause the compilation to fail.

Alternatively, you can configure the overlay to display both warnings and errors:

``` js
// kdu.config.js
module.exports = {
  devServer: {
    overlay: {
      warnings: true,
      errors: true
    }
  }
}
```

When `lintOnSave` is a truthy value, `eslint-loader` will be applied in both development and production. If you want to disable `eslint-loader` during production build, you can use the following config:

``` js
// kdu.config.js
module.exports = {
  lintOnSave: process.env.NODE_ENV !== 'production'
}
```

## Installing in an Already Created Project

``` sh
kdu add eslint
```

## Injected webpack-chain Rules

- `config.module.rule('eslint')`
- `config.module.rule('eslint').use('eslint-loader')`
npm package: @nkduy/cli-plugin-typescript
Description: typescript plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-typescript

> typescript plugin for kdu-cli

Uses TypeScript + `ts-loader` + [fork-ts-checker-webpack-plugin](https://github.com/Realytics/fork-ts-checker-webpack-plugin) for faster off-thread type checking.

## Configuration

TypeScript can be configured via `tsconfig.json`.

Since `3.0.0-rc.6`, `typescript` is now a peer dependency of this package, so you can use a specific version of TypeScript by updating your project's `package.json`.

This plugin can be used alongside `@nkduy/cli-plugin-babel`. When used with Babel, this plugin will output ES2015 and delegate the rest to Babel for auto polyfill based on browser targets.

## Injected Commands

If opted to use [TSLint](https://palantir.github.io/tslint/) during project creation, `kdu-cli-service lint` will be injected.

## Caching

[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/ts-loader`.

## Parallelization

[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `kdu.config.js`.

`parallel` should be set to `false` when using Typescript in combination with non-serializable loader options, such as regexes, dates and functions. These options would not be passed correctly to `ts-loader` which may lead to unexpected errors.

## Installing in an Already Created Project

``` sh
kdu add typescript
```

## Injected webpack-chain Rules

- `config.rule('ts')`
- `config.rule('ts').use('ts-loader')`
- `config.rule('ts').use('babel-loader')` (when used alongside `@nkduy/cli-plugin-babel`)
- `config.rule('ts').use('cache-loader')`
- `config.plugin('fork-ts-checker')`
npm package: @nkduy/cli-plugin-unit-jest
Description: unit-jest plugin for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-plugin-unit-jest

> unit-jest plugin for kdu-cli

## Injected Commands

- **`kdu-cli-service test:unit`**

  Run unit tests with Jest. Default `testMatch` is `<rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))` which matches:

  - Any files in `tests/unit` that end in `.spec.(js|jsx|ts|tsx)`;
  - Any js(x)/ts(x) files inside `__tests__` directories.

  Usage: `kdu-cli-service test:unit [options] <regexForTestFiles>`

  All [Jest command line options](https://facebook.github.io/jest/docs/en/cli.html) are also supported.

## Debugging Tests

Note that directly running `jest` will fail because the Babel preset requires hints to make your code work in Node.js, so you must run your tests with `kdu-cli-service test:unit`.

If you want to debug your tests via the Node inspector, you can run the following:

```sh
# macOS or linux
node --inspect-brk ./node_modules/.bin/kdu-cli-service test:unit --runInBand

# Windows
node --inspect-brk ./node_modules/@nkduy/cli-service/bin/kdu-cli-service.js test:unit --runInBand
```

## Configuration

Jest can be configured via `jest.config.js` in your project root, or the `jest` field in `package.json`.

## Installing in an Already Created Project

```sh
kdu add unit-jest
```

## Transform dependencies from `/node_modules`

By default, jest doesn't transform anything from `/node_modules`.

Since jest runs in node, we also don't have to transpile anything that uses modern ECMAScript features as Node >=8 already supports these features, so it's a sensible default. cli-plugin-jest also doesn't respect the `transpileDependencies` option in `kdu.config.js` for the same reason.

However, we have (at least) three cases where we do need to transpile code from `/node_modules` in jest:

1. Usage of ES6 `import`/`export` statements, which have to be compiled to commonjs `module.exports`
2. Single File Components (`.kdu` files) which have to be run through `kdu-jest`
3. Typescript code

To do this, we need to add an exception to the `transformIgnorePatterns` option of jest. This is its default value:

```javascript
transformIgnorePatterns: ['/node_modules/']
```

We have to add exceptions to this pattern with a RegExp negative lookahead:

```javascript
transformIgnorePatterns: ['/node_modules/(?!name-of-lib-o-transform)']
```

To exclude multiple libraries:

```javascript
transformIgnorePatterns: ['/node_modules/(?!lib-to-transform|other-lib)']
```
npm package: @nkduy/cli-plugin-unit-mocha
Description: mocha unit testing plugin for kdu-cli
Author: Evan You
Latest version: 4.5.15

# @nkduy/cli-plugin-unit-mocha

> unit-mocha plugin for kdu-cli

## Injected Commands

- **`kdu-cli-service test:unit`**

  Run unit tests with [mochapack](https://github.com/sysgears/mochapack) + [chai](http://chaijs.com/).

  **Note the tests are run inside Node.js with browser environment simulated with JSDOM.**

  ```
  Usage: kdu-cli-service test:unit [options] [...files]

  Options:

    --watch, -w   run in watch mode
    --grep, -g    only run tests matching <pattern>
    --slow, -s    "slow" test threshold in milliseconds
    --timeout, -t timeout threshold in milliseconds
    --bail, -b    bail after first test failure
    --require, -r require the given module before running tests
    --include     include the given module into test bundle
    --inspect-brk Enable inspector to debug the tests
  ```

  Default files matches are: any files in `tests/unit` that end in `.spec.(ts|js)`.

  All [mochapack command line options](https://sysgears.github.io/mochapack/docs/installation/cli-usage.html) are also supported.

## Installing in an Already Created Project

``` sh
kdu add unit-mocha
```
npm package: @nkduy/cli-service-global
Description: kdu-cli-service global addon for kdu-cli
Author: NKDuy
Latest version: 4.5.15

# @nkduy/cli-service-global

Installing this package globally allows you to run `kdu serve` and `kdu build` directly without any local dependencies:

``` sh
npm install -g @nkduy/cli-service-global
echo '<template><h1>Hello!</h1></template>' > App.kdu
kdu serve
```
npm package: @nkduy/cli-ui
Description: ### Local development
Author: Guillaume Chau
Latest version: 4.5.15-beta.0

# @nkduy/cli-ui

### Local development

Before starting a local cli-ui instance,
in order to download all required dependencies of kdu-cli's packages.

Just after, you should build once then serve `@nkduy/cli-ui-addon-webpack` by running:
```bash
cd ../cli-ui-addon-webpack
yarn build # just do once
yarn serve
```

Then you start the ui server (based on Apollo):

```
cd ../cli-ui
yarn run apollo
```

And then in another terminal, you should serve the ui web app:

```
yarn run serve
```

This will open a new [Cypress](https://www.cypress.io/) window.
You can now run all or specific integration tests.
npm package: @nkduy/cli-ui-addon-widgets
Description: ## Project setup ``` yarn install ```
Latest version: 4.5.15

# cli-ui-addon-widgets

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn run serve
```

### Compiles and minifies for production
```
yarn run build
```

### Lints and fixes files
```
yarn run lint
```
npm package: @nkduy/codemirror
Description: Full-featured in-browser code editor
Author: Marijn Haverbeke
Latest version: 5.62.3-beta.0

# CodeMirror

[![Build Status](https://github.com/codemirror/codemirror/workflows/main/badge.svg)](https://github.com/codemirror/codemirror/actions)
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)

CodeMirror is a versatile text editor implemented in JavaScript for
the browser. It is specialized for editing code, and comes with over
100 language modes and various addons that implement more advanced
editing functionality. Every language comes with fully-featured code
and syntax highlighting to help with reading and editing complex code.

A rich programming API and a CSS theming system are available for
customizing CodeMirror to fit your application, and extending it with
new functionality.

You can find more information (and the
[manual](https://codemirror.net/doc/manual.html)) on the [project
page](https://codemirror.net). For questions and discussion, use the
[discussion forum](https://discuss.codemirror.net/).

See
[CONTRIBUTING.md](https://github.com/codemirror/CodeMirror/blob/master/CONTRIBUTING.md)
for contributing guidelines.

The CodeMirror community aims to be welcoming to everybody. We use the
[Contributor Covenant
(1.1)](http://contributor-covenant.org/version/1/1/0/) as our code of
conduct.

### Installation

Either get the [zip file](https://codemirror.net/codemirror.zip) with
the latest version, or make sure you have [Node](https://nodejs.org/)
installed and run:

    npm install codemirror

**NOTE**: This is the source repository for the library, and not the
distribution channel. Cloning it is not the recommended way to install
the library, and will in fact not work unless you also run the build
step.

### Quickstart

To build the project, make sure you have Node.js installed (at least version 6)
and then `npm install`. To run, just open `index.html` in your
browser (you don't need to run a webserver). Run the tests with `npm test`.
npm package: @nkduy/eslint-config-airbnb
Description: eslint-config-airbnb for Kdu CLI
Author: NKDuy
Latest version: 5.0.2

# @nkduy/eslint-config-airbnb

> eslint-config-airbnb for Kdu CLI

This config is specifically designed to be used by Kdu CLI setups
and is not meant for outside use (it can be used but some adaptations
on the user side might be needed - for details see the config file).

A part of its design is that this config may implicitly depend on
other parts of Kdu CLI setups, such as `eslint-plugin-kdu` being
extended in the same resulting config.
npm package: @nkduy/eslint-config-prettier
Description: eslint-config-prettier for Kdu CLI
Author: NKDuy
Latest version: 6.0.0

# @nkduy/eslint-config-prettier

> eslint-config-prettier for Kdu CLI

This config is specifically designed to be used by Kdu CLI setups
and is not meant for outside use (it can be used but some adaptations
on the user side might be needed - for details see the config file).

A part of its design is that this config may implicitly depend on
other parts of Kdu CLI setups, such as `eslint-plugin-kdu` being
extended in the same resulting config.
npm package: @nkduy/eslint-config-standard
Description: eslint-config-standard for Kdu CLI
Author: NKDuy
Latest version: 5.1.2

# @nkduy/eslint-config-standard

> eslint-config-standard for Kdu CLI

This config is specifically designed to be used by Kdu CLI setups
and is not meant for outside use (it can be used but some adaptations
on the user side might be needed - for details see the config file).

A part of its design is that this config may implicitly depend on
other parts of Kdu CLI setups, such as `eslint-plugin-kdu` being
extended in the same resulting config.
npm package: @nkduy/eslint-config-typescript
Description: eslint-config-typescript for Kdu CLI
Author: NKDuy
Latest version: 7.0.0

# @nkduy/eslint-config-typescript

> eslint-config-typescript for Kdu CLI

This config is specifically designed to be used by Kdu CLI setups
and is not meant for outside use (it can be used but some adaptations
on the user side might be needed - for details see the config file).

A part of its design is that this config may implicitly depend on
other parts of Kdu CLI setups, such as `eslint-plugin-kdu` being
extended in the same resulting config.

## Installation

This config requires several peer dependencies. So it's recommended to use the `install-peerdeps` command:

```sh
npx install-peerdeps --dev @nkduy/eslint-config-typescript
```

## Usage

This package comes with 2 rulesets.

### `@nkduy/eslint-config-typescript`

This ruleset is the base configuration for Kdu-TypeScript projects.
Besides setting the parser and plugin options, it also turns off several conflicting rules in the `eslint:recommended` ruleset.
So when used alongside other sharable configs, this config should be placed at the end of the `extends` array.

An example `.eslintrc.js`:

```js
module.exports = {
  extends: [
    'plugin:kdu/essential',
    'eslint:recommended',
    '@nkduy/typescript'
  ]
}
```

### `@nkduy/eslint-config-typescript/recommended`

This is extended from the `@typescript-eslint/recommended` ruleset, which is an **_opinionated_** ruleset.
See the [originial documentation](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/configs#recommended) for more information.

Some of its rules, however, might conflict with `prettier`.
So when used alongside other sharable configs, this config should be placed after all other configs except for the `prettier` ones in the `extends` array.
And make sure to also include the `@typescript-eslint` sub ruleset of the `prettier` config.

An example `.eslintrc.js`:

```js
module.exports = {
  extends: [
    'plugin:kdu/essential',
    '@nkduy/airbnb',
    '@nkduy/typescript/recommended',

    '@nkduy/prettier',
    '@nkduy/prettier/@typescript-eslint'
  ]
}
```
npm package: @nkduy/kdu-to-react
Description: Turn a Kdu component into a React component.
Author: NKDuy
Latest version: 1.0.0

# kdu-to-react

This works for both Kdu 2 and Kdu 3.

## Install

```bash
# npm
npm install @nkduy/kdu-to-react
# or yarn
yarn add @nkduy/kdu-to-react
```

## Usage

```js
import React from 'react'
import { render } from 'react-dom'
import toReact from '@nkduy/kdu-to-react'

const KduComponent = {
  data() {
    return {
      count: 0
    }
  },

  render(h) {
    return h(
      'button',
      {
        on: {
          click: () => this.count++
        }
      },
      [this.count]
    )
  }
}

const ReactComponent = toReact(KduComponent)

render(<ReactComponent />, document.getElementById('app'))
```

### Passing Props

By default we pass all props from React to Kdu:

```js
const Counter = toReact({
  props: ['initialCount'],
  render(h) {
    return h('button', {}, [this.initialCount])
  }
})

const App = <Counter initialCount={0} />
```

However you can customize how the props are passed to Kdu with the `passProps` option:

```js
toReact(KduComponent, {
  // Only pass `initialCount` prop
  passProps: props => ({ initialCount: props.initialCount }),
  // Or disable props
  passProps: false
})
```

## License

[MIT](./LICENSE) License.
npm package: @nkduy/magic-string
Description: This library aims to provide codegen helpers and data structure for Kdu language plugin API v1.x that does not depend on Kocan runtime.
Latest version: 0.2.2

This library aims to provide codegen helpers and data structure for Kdu language plugin API v1.x that does not depend on Kocan runtime.

## Usage

```html
<script>problems = 99</script>

<more-script lang="js">console.log( answer )</more-script>
```

```ts
import {
  toString,
  replace,
} from '@nkduy/magic-string';

/** @type {import('@kocan/kdu-language-core').KduLanguagePlugin} */
const plugin = () => {
	return {
		name: 'example-kdu-language-plugin',
		version: 1,
		resolveEmbeddedFile(fileName, sfc, embeddedFile) {
			if (embeddedFile.fileName.replace(fileName, '').match(/^\.(js|ts|jsx|tsx)$/)) {

        const s = embeddedFile.content;
        toString(s); // 'problems = 99'

				replace(s, 'problems', 'answer');
        toString(s); // 'answer = 99'

				replace(s, '99', '42');
        toString(s); // 'answer = 42'

        // add string by Array method directly
        s.unshift('var ');
        s.push(';');
        toString(s); // 'var answer = 42;'

        for (const block of sfc.customBlocks) {
          if (block.type === 'more-script') {
            s.push([
              block.content, // text to add
              block.name, // source
              0, // content offset in source
              {
                 // language capabilities to enable in this segment
                hover: true,
                references: true,
                definition: true,
                diagnostic: true,
                rename: true,
                completion: true,
                semanticTokens: true,
              },
            ]);
            toString(s); // 'var answer = 42;console.log( answer )'
          }
        }
      }
    }
  };
};
module.exports = plugin;
```
npm package: @nkduy/markdown
Description: markdown for kdupress
Author: NKDuy
Latest version: 1.5.1

# @nkduy/markdown

> markdown library for KduPress

## Public API

### PLUGINS

A map [constant](./lib/constant.js) containing the names of all built-in markdown-it plugins.

### isRequiredPlugin(pluginName: string)

- **Usage**:

```js
const { isRequiredPlugin } = require('@nkduy/markdown')
console.log(isRequiredPlugin(PLUGINS.COMPONENT)) // true
console.log(isRequiredPlugin(PLUGINS.HIGHLIGHT_LINES)) // false
```

### removePlugin(config: chainMarkdown, pluginName: string)

Remove the specified built-in markdown-it plugin in KduPress.

- **Usage**:

```js
// Your KduPress Plugin or site config.
const { removePlugin } = require('@nkduy/markdown')
module.exports = {
  chainMarkdown (config) {
    removePlugin(config, PLUGINS.HIGHLIGHT_LINES)
  }
}
```

> Note that `PLUGINS.COMPONENT` and `PLUGINS.ANCHOR` are required in KduPress, It is forbidden to delete them!

### removeAllBuiltInPlugins(config: chainMarkdown)

Remove all built-in but not 100% necessary markdown-it plugins in KduPress.

- **Usage**:

```js
// Your KduPress Plugin or site config.
module.exports = {
  chainMarkdown (config) {
    require('@nkduy/markdown').removeAllBuiltInPlugins(config)
  }
}
```
npm package: @nkduy/markdown-loader
Description: markdown-loader for kdupress
Author: NKDuy
Latest version: 1.5.1

# @nkduy/markdown-loader

> markdown-loader for KduPress

## Usage

```js
const rule = config.module
    .rule('markdown')
      .test(/\.md$/)

rule
  .use('kdu-loader')
    .loader('kdu-loader')
    .options({ /* ... */ })

rule
  .use('markdown-loader')
    .loader(require.resolve('@nkduy/markdown-loader'))
    .options({
       markdown: /* instance created by @nkduy/markdown */,
       sourceDir: /* root source directory of your docs */,
    })
```
npm package: @nkduy/molangjs
Description: MoLang Parser for Javascript
Author: NKDuy
Latest version: 1.6.1

# MolangJS

MoLang parser for Javascript

---

## Installation

`npm install @nkduy/molangjs -s`

## Usage
### Parser
To calculate the result of a MoLang expression, use Molang#parse()

```javascript
const MolangParser = new Molang();
MolangParser.parse(expression, variables);
```

* [string] **expression:** MoLang expression.
* [object] **variables:** (Optional) Object of variables to pass to the parser. Each variable can be a number or another expression.

### Options
* [object] **Molang#global_variables:** Object of global variables. If no matching variable is passed along, these variables will be used.
* [boolean] **Molang#cache_enabled:** Whether to use caching to make the processing of expressions faster. Default: `true`.
* [boolean] **Molang#use_radians:** Use radians instead of degrees for rotations in trigonometric functions. Default: `false`.
* [function] **Molang#variableHandler:** Custom handler for unrecognized variables. Default: undefined.

## Example
```javascript
import Molang from '@nkduy/molangjs';

const MolangParser = new Molang();

let result = MolangParser.parse('query.has_rider ? Math.sin(query.anim_time) : -44 * 3', {
    'query.has_rider': 1,
    'query.anim_time': '11 + 5'
});
```
npm package: @nkduy/ni
Description: Use the right package manager
Author: NKDuy
Latest version: 0.16.2-rc.0

# ni

~~*`npm i` in a yarn project, again? F\*\*k!*~~

**ni** - use the right package manager

<br>

<pre>
npm i -g <b>@nkduy/ni</b>

<b>ni</b>
</pre>

<a href='https://docs.npmjs.com/cli/v6/commands/npm'>npm</a> · <a href='https://yarnpkg.com'>yarn</a> · <a href='https://pnpm.js.org/en/'>pnpm</a>


<br>


### `ni` - install

```bash
ni

# npm install
# yarn install
# pnpm install
```

```bash
ni axios

# npm i axios
# yarn add axios
# pnpm add axios
```

```bash
ni @types/node -D

# npm i @types/node -D
# yarn add @types/node -D
# pnpm add -D @types/node
```

```bash
ni --frozen

# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfile
```

```bash
ni -g iroiro

# npm i -g iroiro
# yarn global add iroiro
# pnpm add -g iroiro

# this uses default agent, regardless your current working directory
```

<br>

### `nr` - run

```bash
nr dev --port=3000

# npm run dev -- --port=3000
# yarn run dev --port=3000
# pnpm run dev -- --port=3000
```

```bash
nr

# interactively select the script to run
# supports https://www.npmjs.com/package/npm-scripts-info convention
```

```bash
nr -

# rerun the last command
```

<br>

### `nx` - execute

```bash
nx jest

# npx jest
# yarn dlx jest
# pnpm dlx jest
```

<br>

### `nu` - upgrade

```bash
nu

# npm upgrade
# yarn upgrade
# pnpm update
```

```bash
nu -i

# (not available for npm)
# yarn upgrade-interactive
# pnpm update -i
```

<br>

### `nun` - uninstall

```bash
nun axios

# npm uninstall axios
# yarn remove axios
# pnpm remove axios
```

```bash
nun @types/node -D

# npm uninstall @types/node -D
# yarn remove @types/node -D
# pnpm remove -D @types/node
```

```bash
nun -g eslint

# npm uninstall -g eslint
# yarn global remove eslint
# pnpm remove -g eslint
```

<br>

### `nci` - clean install

```bash
nci

# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfile
```

if the corresponding node manager is not present, this command will install it globally along the way.

<br>

### `na` - agent alias

```bash
na

# npm
# yarn
# pnpm
```

```bash
na run foo

# npm run foo
# yarn run foo
# pnpm run foo
```

<br>

### Change Directory

```bash
ni -C packages/foo vite
nr -C playground dev
```

<br>

### Config

```ini
; ~/.nirc

; fallback when no lock found
defaultAgent=npm # default "prompt"

; for global installs
globalAgent=npm
```

```bash
# ~/.bashrc

# custom configuration file path
export NI_CONFIG_FILE="$HOME/.config/ni/nirc"
```

<br>
npm package: @nkduy/plugin-kdu
Description: Note: requires `@kdu/compiler-sfc` as peer dependency. This is largely a port of `rollup-plugin-kdu` with some vite-specific tweaks.
Author: NKDuy
Latest version: 1.1.0

# @nkduy/plugin-kdu

Note: requires `@kdu/compiler-sfc` as peer dependency. This is largely a port of `rollup-plugin-kdu` with some vite-specific tweaks.

```js
// vite.config.js
import kdu from '@nkduy/plugin-kdu'

export default {
  plugins: [kdu()]
}
```

## Options

```ts
export interface Options {
  include?: string | RegExp | (string | RegExp)[]
  exclude?: string | RegExp | (string | RegExp)[]

  ssr?: boolean
  isProduction?: boolean

  // options to pass on to @nkduy/compiler-sfc
  script?: Partial<SFCScriptCompileOptions>
  template?: Partial<SFCTemplateCompileOptions>
  style?: Partial<SFCStyleCompileOptions>
}
```

## Example for passing options to `@nkduy/compiler-dom`:

```ts
import kdu from '@nkduy/plugin-kdu'

export default {
  plugins: [
    kdu({
      template: {
        compilerOptions: {
          // ...
        }
      }
    })
  ]
}
```

## Example for transforming custom blocks

```ts
import kdu from '@nkduy/plugin-kdu'

const kduI18nPlugin = {
  name: 'kdu-i18n',
  transform(code, id) {
    if (!/kdu&type=i18n/.test(id)) {
      return
    }
    if (/\.ya?ml$/.test(id)) {
      code = JSON.stringify(require('js-yaml').safeLoad(code.trim()))
    }
    return `export default Comp => {
      Comp.i18n = ${code}
    }`
  }
}

export default {
  plugins: [kdu(), kduI18nPlugin]
}
```

## License

MIT
npm package: @nkduy/plugin-kdu-jsx
Description: Provides Kdu 3 JSX & TSX support with HMR.
Author: NKDuy
Latest version: 1.0.2

# @nkduy/plugin-kdu-jsx

Provides Kdu 3 JSX & TSX support with HMR.

```js
// vite.config.js
import kduJsx from '@nkduy/plugin-kdu-jsx'

export default {
  plugins: [
    kduJsx({
      // options
    })
  ]
}
```

## HMR Detection

This plugin supports HMR of Kdu JSX components. The detection requirements are:

- The component must be exported.
- The component must be declared by calling `defineComponent` via a root-level statement, either variable declaration or export declaration.

### Supported patterns

```jsx
import { defineComponent } from 'kdu'

// named exports w/ variable declaration: ok
export const Foo = defineComponent(...)

// named exports referencing variable declaration: ok
const Bar = defineComponent(...)
export { Bar }

// default export call: ok
export default defineComponent(...)

// default export referencing variable declaration: ok
const Baz = defineComponent(...)
export default Baz
```

### Non-supported patterns

```jsx
// not using `defineComponent` call
export const Bar = { ... }

// not exported
const Foo = defineComponent(...)
```
npm package: @nkduy/react-to-kdu
Description: Turn a React component into a Kdu component.
Author: NKDuy
Latest version: 1.0.0

# react-to-kdu

## Install

```bash
npm i @nkduy/react-to-kdu
```

## Usage

```js
import { createApp, h } from 'kdu'
import React from 'react'
import toKdu from '@nkduy/react-to-kdu'

const ReactComponent = () => {
  const [count, setCount] = React.useState(0)
  return <button onClick={() => setCount(count + 1)}>{count}</button>
}

const KduComponent = toKdu(ReactComponent)

createApp({
  render: () => h(KduComponent),
}).mount('#app')
```

## License

[MIT](./LICENSE) License.
npm package: @nkduy/reactivity
Description: @nkduy/reactivity
Author: NKDuy
Latest version: 3.0.11

# @nkduy/reactivity

## Usage Note

This package is inlined into Global & Browser ESM builds of user-facing renderers (e.g. `@nkduy/runtime-dom`), but also published as a package that can be used standalone. The standalone build should not be used alongside a pre-bundled build of a user-facing renderer, as they will have different internal storage for reactivity connections. A user-facing renderer should re-export all APIs from this package.

For full exposed APIs, see `src/index.ts`. You can also run `yarn build reactivity --types` from repo root, which will generate an API report at `temp/reactivity.api.md`.

## Credits

The implementation of this module is inspired by the following prior art in the JavaScript ecosystem:

- [Meteor Tracker](https://docs.meteor.com/api/tracker.html)
- [nx-js/observer-util](https://github.com/nx-js/observer-util)
- [salesforce/observable-membrane](https://github.com/salesforce/observable-membrane)

## Caveats

- Built-in objects are not observed except for `Array`, `Map`, `WeakMap`, `Set` and `WeakSet`.
npm package: @nkduy/runtime-core
Description: @nkduy/runtime-core
Author: NKDuy
Latest version: 3.0.11

# @nkduy/runtime-core

> This package is published only for typing and building custom renderers. It is NOT meant to be used in applications.

For full exposed APIs, see `src/index.ts`. You can also run `yarn build runtime-core --types` from repo root, which will generate an API report at `temp/runtime-core.api.md`.

## Building a Custom Renderer

``` ts
import { createRenderer } from '@nkduy/runtime-core'

const { render, createApp } = createRenderer({
  patchProp,
  insert,
  remove,
  createElement,
  // ...
})

// `render` is the low-level API
// `createApp` returns an app instance with configurable context shared
// by the entire app tree.
export { render, createApp }

export * from '@nkduy/runtime-core'
```

See `@nkduy/runtime-dom` for how a DOM-targeting renderer is implemented.
npm package: @nkduy/runtime-dom
Description: @nkduy/runtime-dom
Author: NKDuy
Latest version: 3.0.11

# @nkduy/runtime-dom

``` js
import { h, createApp } from '@nkduy/runtime-dom'

const RootComponent = {
  render() {
    return h('div', 'hello world')
  }
}

createApp(RootComponent).mount('#app')
```