Skip to content

Commit efc229b

Browse files
committed
docs: update API examples and improve code formatting
- Update API examples across multiple files to use correct function names and formatting - Improve code formatting in API documentation to match TypeScript conventions - Remove unused code examples and simplify existing ones - Update function signatures and return types in documentation
1 parent 834103f commit efc229b

File tree

18 files changed

+53
-131
lines changed

18 files changed

+53
-131
lines changed

docs/.vitepress/theme/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { EnhanceAppContext } from 'vitepress'
22
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
33
import Theme from 'vitepress/theme'
4-
54
import '@shikijs/vitepress-twoslash/style.css'
65

76
export default {

docs/api/browser/functions/getUrlParamsString.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ The URL to which parameters will be added, defaults to the current page URL
3030

3131
```ts twoslash
3232
import { getUrlParamsString } from '@ryanuo/utils'
33-
getUrlParamsString({ a: 1, b: 2 }) // '?a=1&b=2'
34-
getUrlParamsString({ a: 1, b: 2 }, 'https://www.example.com')
33+
getUrlParamsString({ a: '1', b: '2' }) // '?a=1&b=2'
34+
getUrlParamsString({ a: '1', b: '2', c: '3' }) // '?a=1&b=2&c=3'
3535
```

docs/api/browser/functions/manageClasses.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ function manageClasses(
3939

4040
```ts twoslash
4141
import { manageClasses } from '@ryanuo/utils'
42-
const el = document.getElementById('myElement')
42+
const el = document.getElementById('myElement') as HTMLElement
4343
manageClasses(el, 'add', ['class1', 'class2'])
44-
manageClasses(el, 'remove', ['class1', 'class2'])
45-
manageClasses(el, 'toggle', ['class1', 'class2'])
4644
```

docs/api/browser/functions/onceEventListener.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function onceEventListener(
3838
## Example
3939

4040
```ts twoslash
41-
import { once } from '@ryanuo/utils'
42-
once(document, 'click', (e) => {
41+
import { onceEventListener } from '@ryanuo/utils'
42+
onceEventListener(document, 'click', (e) => {
4343
console.log(e)
4444
})
4545
```

docs/api/browser/variables/safeStorage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A simple storage wrapper that uses localStorage and sessionStorage.
1010

1111
## Example
1212

13-
```
13+
```ts twoslash
1414
import { safeStorage } from '@ryanuo/utils'
1515
// Basic usage (localStorage)
1616
safeStorage.set('user', { name: 'John' })

docs/api/common/functions/debounce.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ Returns a new debounced function.
6363
import { debounce } from '@ryanuo/utils'
6464
const debouncedFn = debounce(() => {
6565
console.log('Debounced function executed')
66-
})
66+
}, 500, true)
6767
debouncedFn()
6868
```

docs/api/common/functions/safeJSONParse.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ A successfully parsed JSON object, or null if parsing fails
2525
## Example
2626

2727
```ts twoslash
28-
import { safeParseJSON } from '@ryanuo/utils'
28+
import { safeJSONParse } from '@ryanuo/utils'
2929
const json = '{"name": "John", "age": 30}'
30-
const obj = safeParseJSON(json)
30+
const obj = safeJSONParse(json)
3131
console.log(obj) // { name: 'John', age: 30 }
3232
```

docs/api/common/functions/throttle.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ Returns a new throttled function.
5555
### Returns
5656

5757
`void`
58+
59+
## Example
60+
61+
```ts twoslash
62+
import { throttle } from '@ryanuo/utils'
63+
throttle(() => console.log('Hello, world!'), 1000, true)
64+
throttle(() => console.log('Hello, world!'), 1000, false)
65+
```

docs/api/finance/classes/CalculatorChain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
## Example
1212

1313
```ts twoslash
14-
import { chain } from '@ryanuo/utils'
15-
chain(100)
14+
import { CalculatorChain } from '@ryanuo/utils'
15+
new CalculatorChain(100)
1616
.add(10)
1717
.sub(5)
1818
.mul(2)

docs/api/network/functions/getIndexedDBCache.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ IndexedDB 缓存对象
3737
## Example
3838

3939
```ts twoslash
40+
import { getIndexedDBCache } from '@ryanuo/utils';
4041
// 使用示例
4142
const cache = await getIndexedDBCache('api-cache', 'responses');
4243
await cache.set('users', [{ id: 1, name: 'Alice' }]);

0 commit comments

Comments
 (0)