open-index/open-npm huggingface dataset:
npm package: @imshann/database
Description: a frontend database management library
Author: Shann
Latest version: 0.1.2

# introduction

a frontend database management library

## install

```sh
pnpm add @imshann/database
```

## usage

### initialize

```js
import Database from "@imshann/database";

const db = new Database({
  // database name
  name: "minesee",
  // database directory
  path: "/path/to/directory",
});
```

### insert

```js
db.table("user").insert({ id: 1, name: "shann" });
```

then

```json
{
  "data": [{ "id": 1, "name": "shann" }],
  "primaryKey": "id",
  "increment": 2
}
```

### query

```js
db.table("user").queryAll();
//=> [{ "id": 1, "name": "shann" }]

db.table("user").where({ id: 1 }).queryOne();
//=> { "id": 1, "name": "shann" }
```

### update

```js
db.table("user").update({ id: 1, name: "ping" });
//=> { "id": 1, "name": "ping" }
```

### delete

```js
db.table("user").delete(1);
```

then:

```json
{
  "data": [],
  "primaryKey": "id",
  "increment": 2
}
```

### empty

```js
db.table("user").empty();
```

then:

```json
{
  "data": [],
  "primaryKey": "id",
  "increment": 1
}
```
npm package: @imshann/editor
Description: a simple code editor
Latest version: 0.3.2

# introduction

a frontend editor

## import

```js
import Editor from "@imshann/editor";
```

## usage

```js
const editor = new Editor(document.querySelector("#editor"), {
  // input
  content: "Please enter some code",
  // output
  onChange(value) {},
});
```

## onLineNumberChange()

```js
new Editor(document.querySelector("#editor"), {
  // It will be called when the line number is updated
  onLineNumberChange(value) {},
});
```
npm package: @imshann/event
Description: event handler
Latest version: 0.5.3

# @imshann/event

a event library.

## import

```js
import { watchEvent, EventName } from "@imshann/event";
```

## TextSelectStart

```js
watchEvent(
  EventName.TextSelectStart,
  document.querySelector("#box"),
  (event) => {
    console.log(event.getSelectedText());
  }
);
```

## TextSelectOver

```js
watchEvent(
  EventName.TextSelectOver,
  document.querySelector("#box"),
  (event) => {
    console.log(event.getPosition()); // => { x: 11, y:22 }
  }
);
```

## TextSelectEnd

```js
watchEvent(EventName.TextSelectEnd, document.querySelector("#box"), (event) => {
  console.log(event.getSelectedText()); // => abc
});
```

## paste

```js
watchEvent(EventName.Paste, document.querySelector("#editor"), (event) => {
  console.log(event.getClipboardData());
  event.preventDefault();
});
```

## input

The following callback function will be called when the user enter the "a-zA-Z0-9~`!@#$^%&\*()\_-+={}[]\|:;"'<,>./?" range character.

```js
watchEvent(EventName.Input, window, (event) => {});
```

## compositionstart

```js
watchEvent(
  EventName.CompositionStart,
  document.querySelector("#input"),
  (event) => {}
);
```

## compositionend

listen for chinese input events.This event function is called after inputting chinese.

```js
watchEvent(
  EventName.CompositionEnd,
  document.querySelector("#input"),
  (event) => {
    // get the input chinese text
    event.getData();
  }
);
```