# quick-js-tools

> 前端工具库,基础工具库

Latest version **0.1.2** (published 2022-01-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install quick-js-tools
pnpm add quick-js-tools
yarn add quick-js-tools
bun add quick-js-tools
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2022-01-27 |
| First published | 2022-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 158.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | liuwei2016 |
| Maintainers | liuwei2016 |
| Keywords | quick-js-tools, js tools |

## Links

- npm: https://www.npmjs.com/package/quick-js-tools
- Repository: https://github.com/liuwei2016/quick-js-tools
- Homepage: https://github.com/liuwei2016/quick-js-tools#readme
- Issues: https://github.com/liuwei2016/quick-js-tools/issues
- npm.io page: https://npm.io/package/quick-js-tools

## Dependencies (3)

- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.15
- [@types/lodash-es](https://npm.io/package/@types/lodash-es.md) ^4.17.3
- [@liuwei2016/quick-js-tools](https://npm.io/package/@liuwei2016/quick-js-tools.md) 0.1.0

## Recent versions

- 0.1.2 (latest) — 2022-01-27
- 0.1.1 — 2022-01-27
- 0.1.0 — 2022-01-27

## README

# quick-js-tools

前端工具库

## API

- chunk                数组分块
- hex2rgb              十六进制颜色转十进制颜色
- isColor              判断是否是十六进制颜色值
- isPlainObject        判断是否是对象类型
- rgb2hex              十进制颜色转十六进制颜色
- stairStepAccessTable 阶梯访问表

## 本地开发

``` javascript
npm start
```

## 打包

``` javascript
npm run build
```

## 安装

``` javascript
npm i 'quick-js-tools'
```

## 使用

``` javascript
import { 
  chunk,
  hex2rgb,
  isColor,
  isPlainObject,
  rgb2hex,
  stairStepAccessTable,
} from 'quick-js-tools';

console.log('chunked array:', chunk('7bc96f', 2)); // [['7', 'b'], ['c', '9'], ['6', 'f']]
console.log('rgb:', hex2rgb('#7bc96f')); // rgb(123, 201, 111)
console.log('isColor(#7bc96f):', isColor('#7bc96f')); // true
console.log('isColor(#7bc9):', isColor('#7bc9')); // false
console.log('isPlainObject:', isPlainObject({ '6': '#7bc96f' }));
const rgb = [12, 48, 120];
console.log('hex:', rgb2hex(...rgb));

// 案例1
/**
 * 规则：
 * 0: '#ebedf0'
 * 1-3: '#c6e48b'
 * 4-6: '#7bc96f'
 * 7-9: '#239a3b'
 * >=10: '#196127'
 *  */
const contributionNum = 7;
const contributionRangeArray = [ 0, 3, 6, 9, 10 ];
const colorArray = [ '#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127' ];
const color = stairStepAccessTable(contributionNum, contributionRangeArray, colorArray);
console.log('color:', color); // '#239a3b'

// 案例2（来自《代码大全》）
const studentScore = 88;
const rangeLimit = [ 50.0, 65.0, 75.0, 90.0, 100.0 ];
const grade = [ 'F', 'D', 'C', 'B', 'A' ];
const score = stairStepAccessTable(studentScore, rangeLimit, grade);
console.log('score:', score); // B
```

## 示例

```
cd demo
anywhere
```

浏览器访问

[http://127.0.0.1:8000/](http://127.0.0.1:8000/)


### node js 调试
 node --inspect-brk  myPromiseOk.js

---
_Source: https://npm.io/package/quick-js-tools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
