Skip to content

Commit

Permalink
docs: improve demo
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlitusun committed Apr 16, 2024
1 parent 5c18c90 commit 8c7fd85
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 17 deletions.
4 changes: 4 additions & 0 deletions __tests__/pagination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const pagination = require('../dist/cjs/pagination').default;
test('is pagination', () => {
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

expect(pagination([])).toEqual([]);
expect(pagination(arr)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
expect(pagination(arr, 1)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
expect(pagination(arr, 1, 5)).toEqual([1, 2, 3, 4, 5]);
expect(pagination(arr, 2, 8)).toEqual([9, 10]);
expect(pagination(arr, 3, 3)).toEqual([7, 8, 9]);
})
8 changes: 2 additions & 6 deletions docs/methods/csvArray.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ order: 1
### Examples

```js
const {
csvArrayToObjects,
} = require('../dist/cjs/csv-array');
import { csvArrayToObjects } from '@dz-web/o-orange';

describe('函数csvArrayToObjects', () => {
test('输入空数组应该返回空数组', () => {
Expand Down Expand Up @@ -91,9 +89,7 @@ describe('函数csvArrayToObjects', () => {
### Exampless

```js
const {
csvArrayWithoutKeysToObjects,
} = require('../dist/cjs/csv-array');
import { csvArrayWithoutKeysToObjects } from '@dz-web/o-orange';

describe('函数csvArrayWithoutKeysToObjects', () => {
test('输入空数组应该返回空数组', () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/methods/dateRange.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Generate an ordered time interval array
## Examples

```js
import { dateRange } from '../es';
import { dateRange } from '@dz-web/o-orange';

test('dateRange', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion docs/methods/ensure.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ order: 1
## Examples

```js
import { ensure, isTrue } from '../es';
import { ensure, isTrue } from '@dz-web/o-orange';

test('ensure', () => {
expect(ensure(1)).toEqual(1);
Expand Down
2 changes: 1 addition & 1 deletion docs/methods/isTrue.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ order: 2
## Examples

```js
const isTrue = require('../dist/cjs/isTrue').default;
import { isTrue } from '@dz-web/o-orange'

test('is false not zero', () => {
expect(isTrue(0)).toBeTruthy();
Expand Down
6 changes: 5 additions & 1 deletion docs/methods/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ order: 2
## Exampless

```js
import { pagination } from '../es';
import { pagination } from '@dz-web/o-orange';

test('is pagination', () => {
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

expect(pagination([])).toEqual([]);
expect(pagination(arr)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
expect(pagination(arr, 1)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
expect(pagination(arr, 1, 5)).toEqual([1, 2, 3, 4, 5]);
expect(pagination(arr, 2, 8)).toEqual([9, 10]);
expect(pagination(arr, 3, 3)).toEqual([7, 8, 9]);
})
Expand Down
2 changes: 1 addition & 1 deletion docs/methods/parseUrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ order: 100
## Examples

```js
import parseUrl, { parseUrlByHash, parseUrlBySearch } from 'o-orange/lib/parseUrl';
import parseUrl, { parseUrlByHash, parseUrlBySearch } from '@dz-web/o-orange/lib/parseUrl';

const url = 'http://localhost:8080/?key=3';

Expand Down
2 changes: 1 addition & 1 deletion docs/methods/toPercent.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ order: 3
## Examples

```js
import { toPercent } from '../es';
import { toPercent } from '@dz-web/o-orange';

test('toPercent', () => {
expect(toPercent(0.6515, { multiply: 100, precision: 2 })).toBe('65.15%');
Expand Down
2 changes: 1 addition & 1 deletion docs/methods/toPlaceholder.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ order: 6
## Examples

```js
import { toPlaceholder } from '../es';
import { toPlaceholder } from '@dz-web/o-orange';

test('toPlaceholder', () => {
expect(toPlaceholder(0)).toBe(0);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"coveralls": "^3.1.0",
"dumi": "^2.2.17",
"father": "^4.1.7",
"gh-pages": "^6.1.1",
"jest": "^29.5.0",
"jest-coverage-badges": "^1.1.2",
"tslint": "^6.1.3",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c7fd85

Please sign in to comment.