Skip to content

Commit

Permalink
docs(kitify): Enhance README, add DOM, Object, Type docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinerer committed Dec 24, 2024
1 parent 5de2dc3 commit 797a3c6
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 26 deletions.
58 changes: 47 additions & 11 deletions libs/kitify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,62 @@ npm install kitify
## Usage

```js
import { isType, isObject, isFunction } from 'kitify'
// or
import { isType, isObject, isFunction } from 'kitify/type'
import { isType, isObject } from 'kitify'

isObject({}) // true
isFunction(() => {})) // true
isType(123) // number
isType(123) // 'number'
isType('hello', 'string') // true
```

## API

### type
### [Type](./docs/type.md)

```js
import { isType } from 'kitify/type'
Provides some methods for interpreting data types.

console.log(isType({})) // object
console.log(isType([], 'array')) // true
```
一些判断数据类型的方法。

| Method | Description |
| ------------- | -------------------------------------------- |
| `isType` | Check if the value is of the specified type. |
| `isObject` | Check if the value is an object. |
| `isFunction` | Check if the value is a function. |
| `isString` | Check if the value is a string. |
| `isNumber` | Check if the value is a number. |
| `isBoolean` | Check if the value is a boolean. |
| `isArray` | Check if the value is an array. |
| `isSymbol` | Check if the value is a symbol. |
| `isUndefined` | Check if the value is undefined. |
| `isNull` | Check if the value is null. |
| `isBigInt` | Check if the value is a BigInt. |
| `isNil` | Check if the value is null or undefined. |
| `isEmpty` | Check if the value is empty. |
| `isInvalid` | Check if the value is invalid. |

### [Object](./docs/object.md)

Object related utility functions

对象相关的工具函数。

| Method | Description |
| -------- | -------------------------------- |
| `assign` | Merge objects into a new object. |
| `clone` | Clone an object. |

### Function

### String

### [DOM](./docs/dom.md)

DOM related utility functions

DOM元素相关工具函数。

| Method | Description |
| ---------------------- | ------------------------------------ |
| `detectMouseDirection` | Detect the mouse movement direction. |

## License

Expand Down
25 changes: 22 additions & 3 deletions libs/kitify/docs/dom.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# DOM

```bash
DOM related utility functions

DOM元素相关工具函数。

## usage

```ts
import { detectMouseDirection } from 'kitify'

import detectMouseDirection from 'kitify/detectMouseDirection'
```

## detectMouseDirection
## API

Detect the direction of mouseenter and mouseleave when the mouse moves over element.
### detectMouseDirection

Detect the direction of `mouseenter` and `mouseleave` when the mouse moves over element.

检测鼠标移动到指定元素时的移入和移出方向。

Expand All @@ -24,3 +34,12 @@ Callback = (
) => void
*/
```

#### arguments
- `element` - The element to detect the mouse direction.
- `onEnter` - The callback function when the mouse enters the element.
- `onLeave` - The callback function when the mouse leaves the element.

#### returns
- `() => void` - The function to remove the event listeners.

38 changes: 38 additions & 0 deletions libs/kitify/docs/object.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Object

Object related utility functions

对象相关的工具函数。

## usage

```ts
import { assign } from 'kitify'

import assign from 'kitify/assign'
```

## API

### assign

Assigns enumerable properties of source objects to the target object.

将源对象的属性分配到目标对象上。

```ts
assign(target: object, ...sources: object[]): object
```

#### arguments

| Name | Type | Description |
| ------- | ---------- | ------------------- |
| target | `object` | The target object. |
| sources | `object[]` | The source objects. |

#### example

```js
assign({ a: 1 }, { b: 2 }, { b: 3 })
```
53 changes: 41 additions & 12 deletions libs/kitify/docs/type.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# type
# Type

Provides some methods for interpreting data types.

提供一些判读数据类型的方法。
一些判断数据类型的方法。

## Usage

```ts
import { isType, isObject, isFunction } from 'kitify'
Expand All @@ -11,21 +13,48 @@ import { isType, isObject, isFunction } from 'kitify/type'

isObject({}) // true
isFunction(() => {})) // true
isType(123) // number
isType(123) // 'number'
isType('hello', 'string') // true
```

## isType
## API

```ts
function isType(value: any, type?: string): string | boolean
```
### `isType(value: any, type?: string): string | boolean;`

**examples:**
Get/Determine the value type.

```ts
isType(123) // number
isType(new Date()) // date
获取/判断 数据类型。

```js
import isType from 'kitify/isType'

isType(123) // 'number'
isType(new Date()) // 'date'
isType('hello', 'string') // true
isType('hello', 'number') // false
```

### `isString: (value: any) => boolean`

### `isNumber: (value: any) => boolean`

### `isBoolean: (value: any) => boolean`

### `isArray: (value: any) => boolean`

### `isFunction: (value: any) => boolean`

### `isUndefined: (value: any) => boolean`

### `isNull: (value: any) => boolean`

### `isSymbol: (value: any) => boolean`

### `isBigInt: (value: any) => boolean`

### `isObject: (value: any) => boolean`

### `isNil: (value: any) => boolean`

### `isEmpty: (value: any) => boolean`

### `isInvalid: (value: any) => boolean`

0 comments on commit 797a3c6

Please sign in to comment.