Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Nov 1, 2024
1 parent 0507979 commit 279640c
Show file tree
Hide file tree
Showing 66 changed files with 610 additions and 275 deletions.
18 changes: 9 additions & 9 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
functionItems,
collectionItems,
mathItems,
elementItems,
utilItems,
fileItems,
} from './items'

Expand Down Expand Up @@ -69,14 +69,14 @@ export default defineConfig({
text: '函数',
items: withI18n(functionItems, 'zh'),
},
{
text: '元素',
items: withI18n(elementItems, 'zh'),
},
{
text: '文件',
items: withI18n(fileItems, 'zh'),
},
{
text: '工具',
items: withI18n(utilItems, 'zh'),
},
],

docFooter: {
Expand Down Expand Up @@ -131,14 +131,14 @@ export default defineConfig({
text: 'Function',
items: functionItems,
},
{
text: 'Element',
items: elementItems,
},
{
text: 'File',
items: fileItems,
},
{
text: 'Util',
items: utilItems,
},
],

socialLinks: [{ icon: 'github', link: 'https://github.com/varletjs/rattail' }],
Expand Down
2 changes: 2 additions & 0 deletions docs/.vitepress/items/collection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const collectionItems = [
{ text: 'cloneDeep', link: '/collection/clone-deep' },
{ text: 'cloneDeepWith', link: '/collection/clone-deep-with' },
{ text: 'merge', link: '/collection/merge' },
{ text: 'mergeWith', link: '/collection/merge-with' },
]
16 changes: 0 additions & 16 deletions docs/.vitepress/items/element.ts

This file was deleted.

2 changes: 1 addition & 1 deletion docs/.vitepress/items/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const fileItems = [
{ text: 'toDataURL', link: '/file/to-data-url' },
{ text: 'toText', link: '/file/to-text' },
{ text: 'toDataURL', link: '/file/to-data-url' },
{ text: 'toArrayBuffer', link: '/file/to-array-buffer' },
]
5 changes: 5 additions & 0 deletions docs/.vitepress/items/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const generalItems = [
{ text: 'isSet', link: '/general/is-set' },
{ text: 'isMap', link: '/general/is-map' },
{ text: 'isSymbol', link: '/general/is-symbol' },
{ text: 'isWeakMap', link: '/general/is-weak-map' },
{ text: 'isWeakSet', link: '/general/is-weak-set' },
{ text: 'isArrayBuffer', link: '/general/is-array-buffer' },
{ text: 'isTypedArray', link: '/general/is-typed-array' },
{ text: 'isDataView', link: '/general/is-data-view' },
{ text: 'isWindow', link: '/general/is-window' },
{ text: 'isRegExp', link: '/general/is-reg-exp' },
{ text: 'isEmpty', link: '/general/is-empty' },
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/items/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export * from './array'
export * from './collection'
export * from './function'
export * from './math'
export * from './element'
export * from './util'
export * from './file'
16 changes: 16 additions & 0 deletions docs/.vitepress/items/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const utilItems = [
{ text: 'classes', link: '/util/classes' },
{ text: 'createNamespaceFn', link: '/util/create-namespace-fn' },
{ text: 'raf', link: '/util/raf' },
{ text: 'doubleRaf', link: '/util/double-raf' },
{ text: 'requestAnimationFrame', link: '/util/request-animation-frame' },
{ text: 'cancelAnimationFrame', link: '/util/cancel-animation-frame' },
{ text: 'inViewport', link: '/util/in-viewport' },
{ text: 'preventDefault', link: '/util/prevent-default' },
{ text: 'getStyle', link: '/util/get-style' },
{ text: 'getRect', link: '/util/get-rect' },
{ text: 'getScrollTop', link: '/util/get-scroll-top' },
{ text: 'getScrollLeft', link: '/util/get-scroll-left' },
{ text: 'getParentScroller', link: '/util/get-parent-scroller' },
{ text: 'getAllParentScroller', link: '/util/get-all-parent-scroller' },
]
30 changes: 30 additions & 0 deletions docs/collection/clone-deep-with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# cloneDeepWith

Create a deep clone of a value, applying a custom function for cloning on each value. The function will process objects with various types.

### Usage

```ts
import { isNumber, cloneDeepWith } from 'rattail'

const original = { a: 1, b: { c: 2 } }
const value = cloneDeepWith(original, (val) => {
if (isNumber(val)) {
return val * 2
}
})
// value is { a: 2, b: { c: 4 } }
```

### Arguments

| Arg | Type | Defaults |
| ------- | :-------------------: | -------: |
| `value` | `any` | |
| `fn` | `(value: any) => any` | |

### Return

| Type |
| :---: |
| `any` |
25 changes: 25 additions & 0 deletions docs/collection/clone-deep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# cloneDeep

Create a deep clone of a value.

### Usage

```ts
import { cloneDeep } from 'rattail'

const original = { a: 1, b: { c: 2 } }
const value = cloneDeep(original)
// value is { a: 1, b: { c: 2 } }
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :---: |
| `any` |
10 changes: 5 additions & 5 deletions docs/collection/merge-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ mergeWith({ a: [1, 2] }, { a: [3, 4] }, (objValue, srcValue) => [...objValue, ..

### Arguments

| Arg | Type | Defaults |
| ---------- | --------------------------------------------------------------------------------- | -------- |
| `object` | `object` | |
| `source` | `object` | |
| `callback` | `(objValue: any, srcValue: any, key: any, object: object, source: object) => any` | |
| Arg | Type | Defaults |
| -------- | --------------------------------------------------------------------------------- | -------- |
| `object` | `object` | |
| `source` | `object` | |
| `fn` | `(objValue: any, srcValue: any, key: any, object: object, source: object) => any` | |

### Return

Expand Down
23 changes: 0 additions & 23 deletions docs/element/classes.md

This file was deleted.

6 changes: 2 additions & 4 deletions docs/file/to-array-buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ Converts a `File` object to an `ArrayBuffer`.
```ts
import { toArrayBuffer } from 'rattail'

const file = new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' })
toArrayBuffer(file).then((arrayBuffer) => {
console.log(arrayBuffer)
})
await toArrayBuffer(new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' }))
// return ArrayBuffer
```

### Arguments
Expand Down
6 changes: 2 additions & 4 deletions docs/file/to-data-url.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ Converts a `File` object to a Data URL string.
```ts
import { toDataURL } from 'rattail'

const file = new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' })
toDataURL(file).then((dataUrl) => {
console.log(dataUrl)
})
await toDataURL(new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' }))
// return 'data:text/plain;base64,SGVsbG8sIHdvcmxkIQ=='
```

### Arguments
Expand Down
6 changes: 2 additions & 4 deletions docs/file/to-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ Converts a `File` object to a text string.
```ts
import { toText } from 'rattail'

const file = new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' })
toText(file).then((text) => {
console.log(text)
})
await toText(new File(['Hello, world!'], 'hello.txt', { type: 'text/plain' }))
// return 'Hello, world!'
```

### Arguments
Expand Down
23 changes: 23 additions & 0 deletions docs/general/is-array-buffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isArrayBuffer

Determine whether the input value is a `ArrayBuffer`.

### Usage

```ts
import { isArrayBuffer } from 'rattail'

isArrayBuffer(new ArrayBuffer(8)) // return true
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :-------: |
| `boolean` |
23 changes: 23 additions & 0 deletions docs/general/is-data-view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isDataView

Determine whether the input value is a `DataView`.

### Usage

```ts
import { isDataView } from 'rattail'

isDataView(new DataView(new ArrayBuffer(1))) // return true
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :-------: |
| `boolean` |
23 changes: 23 additions & 0 deletions docs/general/is-typed-array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isTypedArray

Determine whether the input value is a `TypedArray`.

### Usage

```ts
import { isTypedArray } from 'rattail'

isTypedArray(new Int8Array(8)) // return true
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :-------: |
| `boolean` |
23 changes: 23 additions & 0 deletions docs/general/is-weak-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isWeakMap

Determine whether the input value is a `WeakMap`.

### Usage

```ts
import { isWeakMap } from 'rattail'

isWeakMap(new WeakMap()) // return true
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :-------: |
| `boolean` |
23 changes: 23 additions & 0 deletions docs/general/is-weak-set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# isWeakSet

Determine whether the input value is a `WeakSet`.

### Usage

```ts
import { WeakSet } from 'rattail'

isWeakMap(new WeakSet()) // return true
```

### Arguments

| Arg | Type | Defaults |
| ------- | :---: | -------: |
| `value` | `any` | |

### Return

| Type |
| :-------: |
| `boolean` |
File renamed without changes.
26 changes: 26 additions & 0 deletions docs/util/classes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# classes

Generates a list of class names based on a given condition or directly returns class names.

### Usage

```ts
import { classes } from 'rattail'

classes('a', [true, 'b', 'c'])
// return ['a', 'b']
classes('a', [false, 'b', 'c'])
// return ['a', 'c']
```

### Arguments

| Arg | Type | Defaults |
| --------- | ----------------- | -------- |
| `...args` | `string \| Array` | |

### Return

| Type |
| ------- |
| `any[]` |
Loading

0 comments on commit 279640c

Please sign in to comment.