open-index/open-npm huggingface dataset:
npm package: @mrlhumphreys/jbackgammon
Description: Backgammon game state and move validation
Author: Mark Humphreys
Latest version: 1.2.5

# JBackgammon

A backgammon game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jbackgammon

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jbackgammon').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jbackgammon'
```

Initialize a new match object:

```javascript 
  var match = new Match({
    id: 1,
    game_state: {
      bar: {
        pieces: []
      },
      current_player_number: 1,
      current_phase: 'move',
      dice: [
        { number: null },
        { number: null }
      ],
      off_board: {
        pieces: []
      }
      points: [
        { number: 1, pieces: [ { player_number: 1 }, { player_number: 1 } ] },
        { number: 2, pieces: [ ] },
        ...
      ]
    },
    players: [
      { player_number: 1, name: 'aaa' },
      { player_number: 2, name: 'bbb' }
    ],
    winner: null
  });
```

Serialize match

```javascript
  match.asJson;
```

See if player can pass

```javascript
  playerNumber = 1;
  match.passable(playerNumber); 
```

Roll Dice

```javascript
  playerNumber = 1;
  match.touchDice(playerNumber);
```

Make a move

```javascript
  match.touchPoint(4, 1); // select point 4 for player 1
  match.touchPoint(6, 1); // select point 6 for player 1
```

Pass turn

```javascript
  playerNumber = 1;
  match.touchPass(playerNumber);
```

Get winner

```javascript
  match.winner;
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jbackgammon. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jboardgame
Description: Board Game utility classes and functions
Author: Mark Humphreys
Latest version: 2.0.12

# JBoardgame

Useful utility functions for board games

## Install via npm:

  $ npm install @mrlhumphreys/jboardgame

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jboardgame').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jboardgame'
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jboardgame. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jcheckers
Description: Checkers game state and move validation
Author: Mark Humphreys
Latest version: 1.0.2

# JCheckers

A checkers game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jcheckers

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jcheckers').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jcheckers'
```

Initialize a new match object:

```javascript 
  var match = new Match({
    id: 1,
    game_state: {
      current_player_number: 1,
      squares: [
        { 
          id: 1, 
          x: 1, 
          y: 0, 
          piece: {
            id: 1, 
            player_number: 1, 
            king: false
          }
        },
        ...
      ] 
    },
    players: [
      { player_number: 1, name: 'aaa' },
      { player_number: 2, name: 'bbb' }
    ],
    winner: null
  });
```

Serialize match object:

```javascript
  match.asJson;
```

Make a move

```javascript
  match.touchSquare(12, 1); // select square 12 for player 1 
  match.touchSquare(16, 1); // move to square 16 for player 1 
```

Get winner

```javascript
  match.winner;
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jcheckers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jchess
Description: Chess game state and move validation
Author: Mark Humphreys
Latest version: 1.0.7

# JChess

A chess game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jchess

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jchess').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jchess'
```

Initialize a new match object:

```javascript 
  var match = new Match({
    id: 1,
    game_state: {
      current_player_number: 1,
      last_double_step_pawn_id: null,
      squares: [
        { 
          id: 'a8', 
          x: 0, 
          y: 0, 
          piece: {
            id: 1, 
            player_number: 1, 
            type: 'pawn' 
          }
        },
        ...
      ] 
    },
    players: [
      { player_number: 1, name: 'aaa' },
      { player_number: 2, name: 'bbb' }
    ],
    winner: null
  });
```

Serialize match

```javascript
  match.asJson;
```

Make Move

```javascript
  playerNumber = 1;
  match.touchSquare('e2', playerNumber); // select piece at e2
  match.touchSquare('e4', playerNumber); // move piece to e4 
```

Select Piece Type to Promote

```javascript
  playerNumber = 1;
  match.touchSquare('e7', playerNumber); // select piece at e7
  match.touchSquare('e8', playerNumber); // move piece to e8 
  match.touchPromotionPiece('queen', playerNumber); // promote to queen
```

Get winner

```javascript
  match.winner
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jchess. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jgo
Description: Go game state and move validation
Author: Mark Humphreys
Latest version: 1.0.0

# JGo

A go game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jgo

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jgo').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jgo'
```

Initialize a new match object:

```javascript 
  var match = new Match({
  });
```

Serialize match object:

```javascript
  match.asJson;
```

Make a move

```javascript
  match.touchPoint(19, 1); // place a stone at point 19 for player 1
```

Pass the turn

```javascript
  match.touchPass(1); // pass the turn for player 1
```

Get winner

```javascript
  match.winner;
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jgo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jshogi
Description: Shogi game state and move validation
Author: Mark Humphreys
Latest version: 0.1.4

# JShogi

A shogi game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jshogi

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jshogi').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jshogi'
```

Initialize a new match object:

```javascript 
  var match = new Match({
    id: 1,
    game_state: {
      current_player_number: 1,
      squares: [
        { 
          id: 'a8', 
          x: 0, 
          y: 0, 
          piece: {
            id: 1, 
            player_number: 1, 
            type: 'fuhyou' 
          }
        },
        ...
      ],
      hands: [
        { player_number: 1, pieces: [] },
        { player_number: 2, pieces: [] },
      ]
    },
    players: [
      { player_number: 1, name: 'aaa' },
      { player_number: 2, name: 'bbb' }
    ],
    winner: null
  });
```

Serialize match

```javascript
  match.asJson;
```

Make Move

```javascript
  playerNumber = 1;
  match.touchSquare('44', playerNumber); // select piece at 44 
  match.touchSquare('54', playerNumber); // move piece to 54 
```

Drop a piece from one in hand

```javascript
  playerNumber = 1;
  match.touchSquare(23, playerNumber); // select piece with id 23 
  match.touchSquare('54', playerNumber); // drop piece on square 54 
```

Select Piece Type to Promote

```javascript
  playerNumber = 1;
  match.touchSquare('57', playerNumber); // select piece at 57
  match.touchSquare('58', playerNumber); // move piece to 58 
  match.touchPromotionOption(true, playerNumber); // promote the moved piece 
```

Get winner

```javascript
  match.winner
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jshogi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrlhumphreys/jxiangqi
Description: Xiangqi game state and move validation
Author: Mark Humphreys
Latest version: 0.1.0

# JXiangqi

A xiangqi game state and validation library written in Javascript.

## Installation

Install via npm:

  $ npm install @mrlhumphreys/jxiangqi

## Usage

ES5:

```javascript
  var Match = require('@mrlhumphreys/jxiangqi').Match;
```

ES6:

```javascript
  import { Match } from '@mrlhumphreys/jxiangqi'
```

Initialize a new match object:

```javascript 
  var match = new Match({
    id: 1,
    game_state: {
      current_player_number: 1,
      squares: [
        { 
          id: 'a10', 
          x: 0, 
          y: 0, 
          piece: {
            id: 1, 
            player_number: 2, 
            type: 'ju' 
          }
        },
        ...
      ]
    },
    players: [
      { player_number: 1, name: 'aaa' },
      { player_number: 2, name: 'bbb' }
    ],
    winner: null
  });
```

Serialize match

```javascript
  match.asJson;
```

Make Move

```javascript
  playerNumber = 1;
  match.touchSquare('a10', playerNumber); // select piece at a9 
  match.touchSquare('a9', playerNumber); // move piece to a10 
```

Get winner

```javascript
  match.winner
```

## Development

After checkout out the repo, run `npm install` to install dependencies. Run `npm build` to transpile ES6 to ES5 into the lib directory. Run `npm test` to run the tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mrlhumphreys/jxiangqi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
npm package: @mrli-utils/asyncpool
Description: 异步请求并发控制函数，限制同一时间发起的请求量
Author: 1471363285@qq.com
Latest version: 2.0.0

# @mrli-utils/asyncpool

适用于浏览器、Nodejs 的javascript 的并发控制函数

## 1. Installation

```bash
# npm
npm install @mrli-utils/asyncpool --save

# yarn
yarn add  @mrli-utils/asyncpool

# pnpm
pnpm install  @mrli-utils/asyncpool
```

## Attribute

asyncPool(limit, paramsArray, serviceFn, [useAllSettled])

asyncPool函数接收四个参数

`limit`

- 类型：Number
- 描述：同一时间发请求的最大数量

`paramsArray`

- 类型：any[][]： 二维数组，
- 描述：若serviceFn接受n个参数， 那么内层的每一个数组都应该有n项元素，n项元素将依次作为serviceFn函数入参的每一项

`serviceFn`

- 类型：Function
- 描述：真正的异步请求函数
**若请求函数内部需要绑定this, 需要用bind进行绑定后再传入**

`useAllSettled`(可选)

- 类型：Boolean
- 描述：asyncPool内部默认使用 `Promise.all`处理批量请求, 若`useAllSettled`为`true`, 则内部使用`Promise.allSettled`处理异步请求,**注意: useAllSettled为true时候, 即使serviceFn函数抛出异常, 也不会终止整个asyncPool,直到所有参数都由servicerFn处理完成后才会有最终的返回结果**

## 3. Usage

### 按需引入

```js
/* Nodejs */
const { asyncPool } = require("@mrli-utils/asyncpool");

/* 浏览器 */
import { asyncPool } from '@mrli-utils/asyncpool'
```

### 使用示例

```js
// 真是的请求函数
function getPageList(filter, page) {
 return axios.get('/xxxxx',{
    method:'GET',
    params:{ filter, page }
 })
}

// 每次请求的参数， 有个数组元素就会发出几次请求， 这里是5次
let paramsArray = [
  [{name:'xxx'}, {pageSize:100, pageNum: 1}],
  [{name:'xxx'}, {pageSize:100, pageNum: 2}],
  [{name:'xxx'}, {pageSize:100, pageNum: 3}],
  [{name:'xxx'}, {pageSize:100, pageNum: 4}],
  [{name:'xxx'}, {pageSize:100, pageNum: 5}]
];

// 若请求函数内部需要绑定this, 需要用bind进行绑定后使用
const serviceName = getPageList.bind(this) // 伪代码


// 请求示例， 2表示同一时间内最多2个请求
asyncPool(2, paramsArray, serviceName)
  .then(result => {
    console.log("请求结果数组", result); // result是每个请求返回的结果
    const data = [];  // 最终的结果
    result.forEach(res=>{
      // 将请求结果取出来放到同一个数组内
      data.push(res.xxxxx)
    })

    // ... 对请求结果的后续操作

  })
  .catch(e => {
    // 只要paramsArray.length个请求中有一个出错了， 就会进入catch
    console.log("出错了", e);
  });
```