open-index/open-npm huggingface dataset:
npm package: @leizl/binary
Description: JavaScript 10进制数的原码，反码，补码
Latest version: 0.0.4

# JavaScript 10 进制数的 原码，反码，补码

## 原码, 反码, 补码的基础概念和计算方法

在探求为何机器要使用补码之前, 让我们先了解原码, 反码和补码的概念.对于一个数, 计算机要使用一定的编码方式进行存储. 原码, 反码, 补码是机器存储一个具体数字的编码方式.

### 原码

原码就是符号位加上真值的绝对值, 即用第一位表示符号, 其余位表示值. 比如如果是 8 位二进制:

```javascript
[+1]原 = 0000 0001

[-1]原 = 1000 0001
```

### 反码

反码的表示方法是:

正数的反码是其本身。

负数的反码是在其原码的基础上, 符号位不变，其余各个位取反。

```javascript
[+1] = [00000001]原 = [00000001]反

[-1] = [10000001]原 = [11111110]反
```

可见如果一个反码表示的是负数, 人脑无法直观的看出来它的数值. 通常要将其转换成原码再计算.

### 补码

补码的表示方法是:

正数的补码就是其本身

负数的补码是在其原码的基础上, 符号位不变, 其余各位取反, 最后+1. (即在反码的基础上+1)

```javascript
[+1] = [00000001]原 = [00000001]反 = [00000001]补

[-1] = [10000001]原 = [11111110]反 = [11111111]补
```

对于负数, 补码表示方式也是人脑无法直观看出其数值的. 通常也需要转换成原码在计算其数值.

## 使用简易教程

### 安装

```javascript
 yarn add @leizl/binary
```

### 使用范例

```javascript
import Binary from '@leizl/binary';

// 原码
Binary.trueForm(123); // 00000000000000000000000001111011​​​
Binary.trueForm(-123); // ​​​10000000000000000000000001111011​​​

// 反码
Binary.inverse(123); // ​​​00000000000000000000000001111011​​​
Binary.inverse(-123); // ​​​10000000000000000000000001111011​​​

// 补码
Binary.complement(123); // ​​​​​​00000000000000000000000001111011​​​​
Binary.complement(-123); // ​​​11111111111111111111111110000101​​​
```
npm package: @leizm/accuracy-time
Description: 高精度时间相关模块
Author: Zongmin Lei
Latest version: 1.0.2

# @leizm/accuracy-time

高精度时间相关模块

## 安装

```bash
npm install @leizm/accuracy-time --save
```

## 使用方法

```typescript
import {
  waitSecond,
  waitUntilTime,
  setIntervalInSecond,
  getTime,
  addTime,
  subtractTimeString,
  addTimeString
} from "@leizm/accuracy-time";

async function main() {
  // 从当前时刻开始等待第N个整秒后返回
  await waitSecond(5);

  // 等到到当天指定时间后返回
  await waitUntilTime("12:34:56");

  // 每隔指定的整秒执行一次回调
  const stop = setIntervalInSecond(1, n => {
    console.log("第%s此执行", n);
  });
  // 5秒后停止
  await waitSecond(5);
  stop();

  // 返回当天指定时间的毫秒时间戳
  const a = getTime("12:34:56");

  // 从当前时刻开始，返回增加指定时间后的毫秒时间戳
  const b = addTime("00:12:34");

  // 时间相加
  addTimeString("01:45:50", "00:27:34");
  // => [2, 13, 24]

  // 时间相减
  subtractTimeString("02:13:24", "01:45:50");
  // => [0, 27, 34]
}
```

## License

```text
MIT License

Copyright (c) 2018 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/async-cache-getter
Description: 异步获得数据，保证同一时间多个相同的请求只会实际执行一个
Author: Zongmin Lei
Latest version: 1.0.0

# @leizm/async-cache-getter
异步获得数据，保证同一时间多个相同的请求只会实际执行一个

## 安装

```bash
npm install @leizm/async-cache-getter --save
```

## 使用

```typescript
import AsyncCacheGetter from "@leizm/async-cache-getter";

const cache = new AsyncCacheGetter({ timeout: 10000 });

// xxxx 用于区别不同的请求操作，相同的请求其名称应该一致
const ret = await cache.get("xxxx", async () => {
  return 123456;
});
// 返回结果：123456
```

## 性能

```
------------------------------------------------------------------------
@leizm/async-throttle Benchmark
------------------------------------------------------------------------

Platform info:
- Darwin 18.5.0 x64
- Node.JS: 10.15.3
- V8: 6.8.275.32-node.51
  Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz × 8


1 tests success:
┌──────┬──────────┬────────┬────────┐
│ test │ rps      │ ns/op  │ spent  │
├──────┼──────────┼────────┼────────┤
│ #get │ 527589.5 │ 1895.4 │ 2.066s │
└──────┴──────────┴────────┴────────┘
```

## License

```
MIT License

Copyright (c) 2019 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/async-throttle
Description: 异步操作限流
Author: Zongmin Lei
Latest version: 1.2.0

# @leizm/async-throttle
异步操作限流

## 安装

```bash
npm install @leizm/async-throttle --save
```

## 使用

```typescript
const t = new AsyncThrottle({
  concurrent: 10, // 并发
  tps: 1000,      // 每秒最多可处理的请求数
  timeout: 1000,  // 超时时间
});

// 执行异步任务
const ret = await t.run(async () => {
  return 12345;
});
// 返回结果：12345

// 获得当前运行状态信息
const stats = t.stat();
// 返回结果：{ running: 1, waitting: 0, tps: 1 }
```

## 性能

```
------------------------------------------------------------------------
@leizm/async-throttle Benchmark
------------------------------------------------------------------------

Platform info:
- Darwin 18.5.0 x64
- Node.JS: 10.15.3
- V8: 6.8.275.32-node.51
  Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz × 8


3 tests success:
┌───────────────────────┬──────────┬─────────┬────────┐
│ test                  │ rps      │ ns/op   │ spent  │
├───────────────────────┼──────────┼─────────┼────────┤
│ #run concurrent=100   │ 53252.1  │ 18778.6 │ 2.221s │
├───────────────────────┼──────────┼─────────┼────────┤
│ #run concurrent=1000  │ 143878.0 │ 6950.3  │ 2.099s │
├───────────────────────┼──────────┼─────────┼────────┤
│ #run concurrent=10000 │ 136674.3 │ 7316.7  │ 2.195s │
└───────────────────────┴──────────┴─────────┴────────┘
```

说明：当 `capacity` 不受限制时，执行 `setTimeout(fn, 0)` 异步任务可以达到 13 万次每秒，即性能损害基本可忽略不计。

## License

```
MIT License

Copyright (c) 2019 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/benchmark
Description: 简单性能测试框架
Author: Zongmin Lei
Latest version: 2.0.1

# @leizm/benchmark

简单性能测试框架，支持预热和多进程执行（针对异步任务）。

## 安装

```bash
npm i @leizm/benchmark -S
```

## 用法

```typescript
import Benchmark from "@leizm/benchmark";

const b = new Benchmark({ title: "Benchmark Example" });
b.addAsync("async task", async () => await sleep(0))
  .addCallback("callback task", done => sleep(0).then(done))
  .addSync("sync task", () => 1 + 1)
  .addSyncFaster("sync faster task", count => {
    for (let i = 0; i < count; i++) {
      // ... 针对性能损坏极小的同步任务，使用 for 来循环 count 次
    }
  })
  .runAndPrint();

function sleep(ms: number): Promise<number> {
  return new Promise(resolve => {
    setTimeout(resolve, ms);
  });
}
```

**注意：`addAsync()` 和 `addCallback()` 中的任务必须是真正的异步函数，否则可能造成进程卡死**

## 选项

```typescript
export interface Options {
  /** 标题 */
  title: string;
  /** 每个任务执行时长（秒） */
  seconds: number;
  /** 并发数量（异步任务时有效） */
  concurrent: number;
  /** 每个任务间隔（秒） */
  delay: number;
  /** 预热时间（秒） */
  preheat: number;
  /** 是否开启多进程，默认不开启 */
  clusterMode: boolean;
  /** 子进程数量，默认为CPU总数 */
  clusterCount: number;
}
```

## License

```text
MIT License

Copyright (c) 2018 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/distributed-events
Description: 分布式事件监听触发模块
Author: Zongmin Lei
Latest version: 1.0.5

# 分布式事件监听触发模块 @leizm/distributed-events

## 安装

```bash
npm install @leizm/distributed-events --save
```

## 使用

```typescript
import EventEmitter from "@leizm/distributed-events";

async function main() {
  // 创建实例
  const e = new EventEmitter({
    // Redis连接配置
    redis: {
      host: "127.0.0.1",
      port: 6379,
      password: "",
      db: 0
    },
    // 键前缀，默认空
    keyPrefix: "",
    // 频道名称，默认为"events"，如果设置了前缀则会加上前缀
    channelKey: "events"
  });

  // 等待初始化完成
  await e.ready();

  // 注册事件监听
  e.on("say hello", function(msg) {
    console.log("say: %s", msg);
  });

  // 触发事件
  e.emit("say hello", "hahahahaha");

  // 监听私人消息
  e.onPrivate(function(senderId, msg) {
    console.log("from %s: %s", senderId, msg);
  });

  // 发送私人消息
  e.sendPrivate(id, msg);
}
```

## License

```text
MIT License

Copyright (c) 2018 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/distributed-shared-data
Description: 分布式共享数据表
Author: Zongmin Lei
Latest version: 1.1.2

# 分布式数据共享同步模块 @leizm/distributed-shared-data

## 安装

```bash
npm install @leizm/distributed-shared-data --save
```

## 使用

```typescript
import SharedData from "@leizm/distributed-shared-data";

async function main() {
  // 创建实例
  const data = new SharedData({
    // Redis连接配置
    redis: {
      host: "127.0.0.1",
      port: 6379,
      password: "",
      db: 0
    },
    // 键前缀，默认空
    keyPrefix: "",
    // 频道名称，默认为":sync"，如果设置了前缀则会加上前缀
    channelKey: ":sync"
  });

  // 等待初始化完成
  await data.ready();

  // 设置值
  await data.set("a", 123);

  // 获取最新值
  const a = await data.get("a");

  // 获取当前缓存的值（如果值有变化，会自动同步，但可能在短时间内不一致）
  const b = data.getSync("b");

  // 删除值
  await data.delete("a");

  // 值增减
  const c = await data.incr("c");
  const d = await data.decr("d");

  // 当有更新数据时，会触发update事件
  data.on("update", (key, value) => {
    console.log("update: %s = %s", key, value);
  });

  // 获取原始redis实例，通过 key() 和 stripKeyPrefix() 来添加删除键前缀
  const keys = (await data.redis.keys(data.key("*"))).map(k =>
    data.stripKeyPredix(k)
  );
}
```

## License

```text
MIT License

Copyright (c) 2018 Zongmin Lei <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/fuser
Description: Find the Process That is Using a File in Linux
Author: LEI Zongmin
Latest version: 1.0.2

# fuser
Find the Process That is Using a File in Linux

## Installation

```bash
npm i @leizm/fuser -S
```

## Usage

### Build open files and pid map data

```js
const fuser = require('@leizm/fuser');

const data = await fuser.buildMap();
console.log(data);
```

 Outputs like this:

 ```
 {
  '/dev/null': [
        1, 11547,  1163,  1163,
     1181, 11856, 12283, 12290,
    12298, 12431, 13220, 13245,
    21131, 22466, 22525, 23318,
    31545, 31546, 31563,  3196,
     3222,  6370,     7
  ],
  'pipe:[104532]': [ 1, 7 ],
  'pipe:[104533]': [ 1, 7 ],
  'pipe:[334229]': [ 10976 ],
  'pipe:[334230]': [ 10976 ],
  'pipe:[334231]': [ 10976 ],
  ...
}
```

### Gets a list of Pids for which the file is currently being opened

```js
const fuser = require('@leizm/fuser');

// update the cache firstly
await fuser.update();

const pids = fuser.getPath('/dev/null');
console.log(pids);
```

Outputs like this:

```
[ 1, 7 ]
```

or:

```
null
```

### Filter file path when buildMap or update

```js
await fuser.update({ filter: (path) => true });
await fuser.buildMap({ filter: (path) => true })
```


## License

```
MIT License

Copyright (c) 2023 LEI Zongmin <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/hhh-cli
Description: hhh框架命令工具
Author: Zongmin Lei
Latest version: 1.1.3

# leizm-hhh-cli

hhh框架命令工具

## 安装

```bash
npm install -g @leizm/hhh-cli
```

## 使用方法

```text
  Usage: hhh <cmd> [options] [path]


  Options:

    -V, --version  output the version number
    -h, --help     output usage information


  Commands:

    init [path]             初始化项目
    dev [path]              本地开发模式
    test [path]             运行单元测试
    run [options] [path]    启动项目
    start [options] [path]  启动服务
    stop [path]             停止服务
    restart [path]          重启服务
    delete [path]           删除服务
    logs [path]             查看日志
    status [path]           查看服务状态
    help                    显示帮助信息
```

## 授权协议

```text
MIT License

Copyright (c) 2017 老雷 <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/logger
Description: 简单日志记录器
Author: Zongmin Lei
Latest version: 1.1.0

# @leizm/logger

简单日志记录器

## 安装

```bash
npm install @leizm/logger --save
```

## 使用方法

```typescript
import log from "@leizm/logger";

log.debug('hello, world: %s', process.version);
log.info('hello, world');
log.warn('hello, world');
log.error('hello, world');
log.fatal('hello, world'); // 输出信息并结束进程
```

## 授权协议

```text
MIT License

Copyright (c) 2017 老雷 <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
npm package: @leizm/params
Description: 参数解析基础库
Author: Zongmin Lei
Latest version: 1.1.0

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[![npm license][license-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/@leizm/params.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@leizm/params
[travis-image]: https://img.shields.io/travis/leizongmin/leizm-params.svg?style=flat-square
[travis-url]: https://travis-ci.org/leizongmin/leizm-params
[coveralls-image]: https://img.shields.io/coveralls/leizongmin/leizm-params.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/leizongmin/leizm-params?branch=master
[david-image]: https://img.shields.io/david/leizongmin/leizm-params.svg?style=flat-square
[david-url]: https://david-dm.org/leizongmin/leizm-params
[node-image]: https://img.shields.io/badge/node.js-%3E=_6.0-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/@leizm/params.svg?style=flat-square
[download-url]: https://npmjs.org/package/@leizm/params
[license-image]: https://img.shields.io/npm/l/@leizm/params.svg

# @leizm/params

参数解析基础库

## 安装

```bash
npm install @leizm/params --save
```

## 使用方法

```typescript
import { NumberParam } from '@leizm/params';

const a = new NumberParam('age', '123');
console.log(a.ok, a.fail, a.message, a.value);
// => true false OK 123

const b = new NumberParam('age', 'xyz');
console.log(b.value);
// => throws ParamError: [age] failed to parse number value: xyz
```

## 授权协议

```text
MIT License

Copyright (c) 2017 老雷 <leizongmin@gmail.com>

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```