open-index/open-npm huggingface dataset:
npm package: @kartikrao/sls-dynamodb-client
Description: Creates a local/production dynamodb client with options
Author: Kartik Rao
Latest version: 0.3.0

sls-dynamodb-client
=================================

[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)

A module to make dynamodb client creation environment agnostic.

* Use the same DynamoDB client code for local development and on AWS Lambda.
* Pass options to DynamoDB or DocumentClient
* Use a custom endpoint for dynamodb-local

## Dependencies

*  [serverless-offline](https://github.com/dherault/serverless-offline) - Required to detect offline/online status
*  [serverless-dynamodb-local](https://github.com/99xt/serverless-dynamodb-local) - Required to run dynamodb locally during development

## Installation

`npm install --save sls-dynamodb-client`

## Usage

```
const ddb = require('sls-dynamodb-client')();

// Get a DocumentClient - AWS.DynamoDB.DocumentClient()
let docClient = ddb.getDocumentClient();

// Get the low level client - AWS.DynamoDB()
let dynamodb = ddb.getClient();

```

## Custom local endpoint
```
const ddb = require('sls-dynamodb-client')("customregion", "http://customhost:customport/");

// DocumentClient requests will go to "customhost:customport"
let docClient = ddb.getDocumentClient();

// DynamoDB client requests will go to "customhost:customport"
let dynamodb = ddb.getClient();
```

## Passing Options
```
const ddb = require('sls-dynamodb-client')("customregion", "http://customhost:customport/");
let options = {"convertEmptyValues": true};
let docClient = ddb.getDocumentClient(options);
```

## References
* [Dynamodb Documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html)
npm package: @kartjim/chook
Description: reack hook library
Latest version: 0.2.9

# chook

> reack hook library

[![NPM version](https://img.shields.io/npm/v/@kartjim/chook.svg?style=flat)](https://npmjs.org/package/@kartjim/chook)
[![NPM downloads](http://img.shields.io/npm/dm/@kartjim/chook.svg?style=flat)](https://npmjs.org/package/@kartjim/chook)

```bash
npm i @kartjim/chook
```
or 
```bash
yarn add @kartjim/chook
```
## 📃 Documentation
- ✍️ state
  - [`useSetState`](https://kartjim.cn/chook/components/usesetstate) 管理 `object` 类型 `state` 的 `Hooks`
  - [`useBoolean`](https://kartjim.cn/chook/components/useboolean) 更好管理 `Boolean` 的 `Hook`
  - [`usePrevious`](https://kartjim.cn/chook/components/useprevious) 保存上一次渲染时 `state` 的值。
  - [`useSafeState`](https://kartjim.cn/chook/components/usesafestate) 用法与 `React.useState` 完全一样，避免因组件卸载后更新状态而导致的内存泄漏。
  - [`useDebounce`](https://kartjim.cn/chook/components/usedebounce) 用于防抖的 `Hook` 函数
  - [`useThrottle`](https://kartjim.cn/chook/components/usethrottle) 用于节流的 `Hook` 函数 
  - [`useSet`](https://kartjim.cn/chook/components/useset) 用于操作 `Set` 数据类型的 `Hook`
  - [`useMap`](https://kartjim.cn/chook/components/usemap) 用于操作 `Map` 数据类型的 `Hook`
  - [`useClippy`](https://kartjim.cn/chook/components/useclippy) 用于读取和写入用户的剪贴板的 `Hook`
  - [`useFirstMountState`](https://kartjim.cn/chook/components/usefirstmountstate) 判断组件是否是首次渲染的 `Hook`
  - [`useLatest`](https://kartjim.cn/chook/components/uselatest) 对 `useRef` 进行封装，保证每次拿到最新的值，避免你闭包问题。
- 🔔 effect
  - [`useUpdate`](https://kartjim.cn/chook/components/useupdate) 实现组件的强制更新。
  - [`useTimeout`](https://kartjim.cn/chook/components/usetimeout) 在函数组件里可使用 `setTimeout` 一样使用 `useTimeout` 。
  - [`useInterval`](https://kartjim.cn/chook/components/useinterval) 在函数组件里可使用 `setInterval` 一样使用 `useInterval` 。
  - [`useUpdateEffect`](https://kartjim.cn/chook/components/useupdateeffect) 更新后立即调用，但是首次渲染不会执行此方法。
- 🔯 lifecycle
  - [`useMount`](https://kartjim.cn/chook/components/usemount) 实现类似于 `class` 组件中的 `componentDidMount` 生命周期钩子
  - [`useUnmount`](https://kartjim.cn/chook/components/useunmount) 实现类似于 `class` 组件中的 `componentWillUnmount` 生命周期钩子。
  - [`useUnmountedRef`](https://kartjim.cn/chook/components/useunmountedref) 获取当前组件是否已经卸载的 Hook。
- 🪢 dom
  - [`useTitle`](https://kartjim.cn/chook/components/usetitle) 自定义页面title
  - [`useFavicon`](https://kartjim.cn/chook/components/usefavicon) 设置页面 `favicon` 的 `Hook`
  - [`useActive`](https://kartjim.cn/chook/components/useactive) 监控点击事件
  - [`useClickOutside`](https://kartjim.cn/chook/components/useclickoutside) 监听目标元素外的点击事件
  - [`useFocus`](https://kartjim.cn/chook/components/usefocus) 监控是否拥有焦点
  - [`useHover`](https://kartjim.cn/chook/components/usehover) 监控鼠标是否移入
  - [`useMousePosition`](https://kartjim.cn/chook/components/usemouseposition) 获取鼠标的 `offsetX` 和 `offsetY` 值
- 🦴 optimize
  - [`useClosure`](https://kartjim.cn/chook/components/useclosure) 替代 `useCallback` ，避免闭包陷阱。

## LICENSE
MIT

<!-- pnpm dp -->
<!-- npm publish --access=public -->
npm package: @kartjim/heap
Description: MinHeap, MaxHeap and heapSort implementation in JavaScript
Author: can-dy-jack
Latest version: 1.1.1

# heap

> `堆` 在大部分编程语言中，都已经有内置方法实现它，但似乎JS并没有。
>
> 最大堆和最小堆：用于高效快速地取得当前数据集中最大或者最小的元素

> The default initial size of heap is 0.  

<!-- 
插入：找到第一个空子节点，插入，然后与父节点不断替换，直到符合特点
删除：找到最后一个子节点，放到根上，然后与子节点不断替换，直到符合特点

0 处为个数
父节点：n/2
左节点：n*2
右节点：n*1+1
叶子节点个数：索引大于 n/2 的都是 
 -->

## install
```sh
npm i @kartjim/heap
```
## require
```js
const {
    MaxHeap,
    MinHeap,
    minHeapSort,
    maxHeapSort
} = require('@kartjim/heap');
```

## import 
```js
import {
    MaxHeap,
    MinHeap,
    minHeapSort,
    maxHeapSort
} from '@kartjim/heap';
```

## HeapSort
### maxHeapSort
> sort the array using MaxHeap (from maximum to minimum).

```js
const arr = [12, 668, 1, 0, 4, 67];
maxHeapSort(arr) // [668, 67, 12, 4, 1, 0]
```
### minHeapSort
> sort the array using MaxHeap (from minimum to maximum).

```js
const arr = [12, 668, 1, 0, 4, 67];
minHeapSort(arr) // [0, 1, 4, 12, 67, 668]
```

## MaxHeap API
### use
constructor 

时间复杂度： $O(N)$    
空间复杂度： $O(N)$  
```js
const heap = new MaxHeap(4);
```

### push
> add a new element to the MaxHeap.  

时间复杂度： $O(log N)$  
空间复杂度： $O(1)$
```js
heap.push(1);
heap.push(2);
heap.push(3);
```

### peek
> return the max element in the MaxHeap.  

时间复杂度： $O(1)$。  
空间复杂度： $O(1)$。
```js
heap.peek() // 3
```

### pop
> remove the max element in the MaxHeap.  

时间复杂度： $O(log N)$      
空间复杂度： $O(1)$
```js
heap.pop() // 3
```

### getSize
> return the size of the MaxHeap.

```js
heap.getSize() // 2
```
### isEmpty
> check if the MaxHeap is empty

```js
heap.isEmpty() // false
```
### MaxHeap.heapify
> create a MaxHeap from a Array.

```js
const t = MaxHeap.heapify([1, 2, 3, 4]);
t.peek() // 4
```

## MinHeap API
### use
constructor 

时间复杂度： $O(N)$    
空间复杂度： $O(N)$  
```js
const heap = new MinHeap(4);
```

### push
> add a new element to the MinHeap.  

时间复杂度： $O(log N)$  
空间复杂度： $O(1)$
```js
heap.push(1);
heap.push(2);
heap.push(3);
```

### peek
> return the max element in the MinHeap.  

时间复杂度： $O(1)$。  
空间复杂度： $O(1)$。
```js
heap.peek() // 1
```

### pop
> remove the max element in the MinHeap.  

时间复杂度： $O(log N)$      
空间复杂度： $O(1)$
```js
heap.pop() // 1
```

### getSize
> return the size of the MinHeap.

```js
heap.getSize() // 2
```
### isEmpty
> check if the MinHeap is empty

```js
heap.isEmpty() // false
```
### MaxHeap.heapify
> create a MinHeap from a Array.

```js
const t = MaxHeap.heapify([1, 2, 3, 4]);
t.peek() // 1
```
npm package: @kartjim/js-binary-search
Description: JavaScript binary search implementation.
Author: can-dy-jack
Latest version: 1.0.2

# binary search ![npm version](https://img.shields.io/npm/v/@kartjim/js-binary-search?style=flat-square) [![Node.js CI](https://github.com/can-dy-jack/js-binary-search/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/can-dy-jack/js-binary-search/actions/workflows/test.yml)

JavaScript binary search implementation.

> 仿 `Python` `bisect`二分函数模块；

## install
```sh
npm i @kartjim/js-binary-search
```

## import
```js
const { 
    bisect_left, 
    bisect_right 
} = require('@kartjim/js-binary-search');
```

or use CDN:
```js
<script src="https://cdn.jsdelivr.net/npm/@kartjim/js-binary-search@1.0.2/js-binary-search.min.js"></script>
```

## use
```js
bisect_left([1, 2, 4, 5], 3)     // 2
bisect_left([1, 2, 3, 4, 5], 3)  // 2

bisect_right([1, 2, 4, 5], 3)    // 2
bisect_right([1, 2, 3, 4, 5], 3) // 3
```

## API
```ts
export type bisect_left = (
    arr: [], 
    val: number, 
    left: number = 0, 
    right: number = arr.length
) => number;
export type bisect_right = (
    arr: [], 
    val: number, 
    left: number = 0, 
    right: number = arr.length
) => number;
```
npm package: @kartjim/priority-queue
Description: Priority queue implementation in JavaScript
Author: can-dy-jack
Latest version: 1.0.3

# priority-queue ![npm version](https://img.shields.io/npm/v/@kartjim/priority-queue?style=flat-square) ![Node.js CI](https://github.com/can-dy-jack/priority-queue/actions/workflows/test.yml/badge.svg)
> Priority queue(优先队列) implementation in JavaScript

## install
```sh
npm i @kartjim/priority-queue
```

## import
```js
import PriorityQueue from '@kartjim/priority-queue';
```

or use CDN:
```js
<script src="https://cdn.jsdelivr.net/npm/@kartjim/priority-queue@1.0.2/priorityqueue.min.js"></script>
```

## use
```js
const data = [];
for (let i = 0; i < 50; i++) {
    data.push(~~(50 * Math.random()));
}

const sorted = data.slice().sort((a, b) => a - b);

const heap = new PriorityQueue();
for (let i = 0; i < data.length; i++) {
    heap.push(data[i]);
}

heap.peek() === sorted[0] // true

let ans = [];
while (!heap.isEmpty()) {
    ans.push(heap.pop());
}

ans == sorted // deeply equal
```


## API
- constructor
  - `constructor(data?: T[],compare?: (a: T, b: T) => number);`
- `push(val: T) : void;`
  - push an element into PriorityQueue
- `peek() : T | undefined;`
  - get the top element
- `pop() : T | undefined;`
  - pop an element, and return it
- `isEmpty() : boolean;`
  - check if the PriorityQueue is empty
npm package: @kartjim/queue
Description: Queue implementation in JavaScript (based on Array)
Author: can-dy-jack
Latest version: 1.0.0

# queue
Queue implementation in JavaScript (based on Array)

> 队列：先入先出  
## install
```sh
npm i @kartjim/queue
```

## export
```js
const { Queue } = require('@kartjim/queue');
```

or ESM :
```js
import { Queue } from "@kartjim/queue";
```
## Queue API
```ts
export class Queue<A> {
    constructor(arr?: T[]);
    isEmpty(): boolean;
    size(): number;
    front(): A;
    end(): A;
    push(val: A): Queue<A>;
    pop(): A;
    toArray(): A[];
    clear(): void;
}
```
### constructor
create a Queue from an Array.

```js
const queue = new Queue();
// or
// new Queue([1, 2, 3]);
```

### isEmpty
Checks if the Queue is empty.  
```js
console.log(stack.isEmpty()) // true
queue.push(1);
console.log(queue.isEmpty()) // false
```

### size
return the number of elements in the queue.  
```js
console.log(queue.size()) // 1
```
### push
push an element to the top of the queue.  
```js
queue.push(2)
console.log(stack.front()) // 1
console.log(stack.end()) // 2
```
### front
return the element at the front of the queue.  
```js
queue.push(5);
console.log(stack.front()) // 1
```

### end 
return the element at the end of the queue.  
```js
queue.push(6);
console.log(stack.end()) // 6
console.log(stack.size()) // 4
```

### pop
remove and return the top element in the queue.  
```js
console.log(queue.pop()) // 1
console.log(queue.pop()) // 2
console.log(queue.pop()) // 5
console.log(queue.pop()) // 6
console.log(queue.pop()) // undefined
```
### toArray
return an array of elements in the queue.   
```js
queue.push(8).push(9).push(11);
console.log(queue.toArray()) // [8, 9, 11]
```
### clear
remove all elements from the queue.  
```js
queue.clear();
console.log(queue.size()) // 0
console.log(queue.isEmpty()) // true
```
## Coverage
`🚀 grunt coverage`：

```sh
===================== Coverage summary =====================
Statements   : 100% ( 80/80 )
Branches     : 100% ( 6/6 )
Functions    : 100% ( 9/9 )
Lines        : 100% ( 80/80 )
============================================================
```
npm package: @kartjim/stack
Description: stack implementation in JavaScript (based on Array)
Author: can-dy-jack
Latest version: 1.0.0

# stack
stack implementation in JavaScript

> 后入先出 - LIFO (last-in-first-out)  
> 栈用于解决进制转换、回文、DFS算法、模拟递归等问题

<!-- 栈 Stack - 底层：数组 -->
## install
```sh
npm i @kartjim/stack
```

## export
```js
const { Stack } = require('@kartjim/stack');
```

or ESM :
```js
import { Stack } from "@kartjim/stack";
```

## Stack API
```ts
export class Stack<T> {
    constructor(arr?: T[]);
    isEmpty(): boolean;
    size(): number;
    peek(): T;
    push(item: T): Stack<T>;
    pop(): T;
}
```
### constructor
create a Stack from an Array.

```js
new Stack();
// or
// new Stack([1, 2, 3]);
```
### isEmpty
Checks if the stack is empty.  
```js
console.log(stack.isEmpty()) // true
stack.push(5);
stack.push(3);
console.log(stack.isEmpty()) // false
```

### size
return the number of elements in the stack.  
```js
console.log(stack.size()) // 2
```
### peek
return the top element in the stack.  
```js
console.log(stack.peek()) // 3
stack.pop();
stack.pop();
console.log(stack.peek()) // undefined
```
### push
push an element to the top of the stack.  
```js
stack.push(5);
stack.push(7)
console.log(stack.peek()) // 7
console.log(stack.size()) // 2
```
### pop
remove and return the top element in the stack.  
```js
console.log(stack.pop()) // 7
console.log(stack.size()) // 1
stack.pop();
console.log(stack.pop()) // undefined
```

## Coverage
`🚀 grunt coverage` :

```sh
============= Coverage summary =============
Statements   : 100% ( 56/56 )
Branches     : 100% ( 6/6 )
Functions    : 100% ( 6/6 )
Lines        : 100% ( 55/55 )
============================================
```
npm package: @kartore/spritore
Description: Generate sprites for maps.
Author: NEKOYASAN
Latest version: 0.0.1

## spritore

### What's this?
This is a library that allows you to create sprites for Vector Tile maps with fewer settings than spritezero or spritesmith.
Even svg files and other image files that cannot be converted properly by spritezero can be converted to Sprite (with some force).

### Usage
```js
const { generate } = require("@kartore/spritore")
const path = require("path")

generate({
  inputPath: path.join(__dirname, "input"),
  outputPath: path.join(__dirname, "output"),
  outputFileName: "sprite"
  
})
```

### Installation

Requires [nodejs](http://nodejs.org/) v14.0.0 or greater.

```bash
$ npm install @kartore/spritore
```