From 8c7fd852a545748c7667014ea04f7b90a65ed1da Mon Sep 17 00:00:00 2001 From: Roc Date: Tue, 16 Apr 2024 09:05:07 +0800 Subject: [PATCH] docs: improve demo --- __tests__/pagination.test.js | 4 ++++ docs/methods/csvArray.md | 8 ++------ docs/methods/dateRange.md | 2 +- docs/methods/ensure.md | 2 +- docs/methods/isTrue.md | 2 +- docs/methods/pagination.md | 6 +++++- docs/methods/parseUrl.md | 2 +- docs/methods/toPercent.md | 2 +- docs/methods/toPlaceholder.md | 2 +- package.json | 1 + pnpm-lock.yaml | 8 ++++---- 11 files changed, 22 insertions(+), 17 deletions(-) diff --git a/__tests__/pagination.test.js b/__tests__/pagination.test.js index 2fd6d6b..8c54711 100644 --- a/__tests__/pagination.test.js +++ b/__tests__/pagination.test.js @@ -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]); }) diff --git a/docs/methods/csvArray.md b/docs/methods/csvArray.md index 5bb13b6..98b8dd1 100644 --- a/docs/methods/csvArray.md +++ b/docs/methods/csvArray.md @@ -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('输入空数组应该返回空数组', () => { @@ -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('输入空数组应该返回空数组', () => { diff --git a/docs/methods/dateRange.md b/docs/methods/dateRange.md index 13584d4..07b7ee8 100644 --- a/docs/methods/dateRange.md +++ b/docs/methods/dateRange.md @@ -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( diff --git a/docs/methods/ensure.md b/docs/methods/ensure.md index 854e349..11c9e95 100644 --- a/docs/methods/ensure.md +++ b/docs/methods/ensure.md @@ -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); diff --git a/docs/methods/isTrue.md b/docs/methods/isTrue.md index 01bc8a3..9349d41 100644 --- a/docs/methods/isTrue.md +++ b/docs/methods/isTrue.md @@ -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(); diff --git a/docs/methods/pagination.md b/docs/methods/pagination.md index 31fc027..c0c00e1 100644 --- a/docs/methods/pagination.md +++ b/docs/methods/pagination.md @@ -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]); }) diff --git a/docs/methods/parseUrl.md b/docs/methods/parseUrl.md index d21a6db..f9d6ce9 100644 --- a/docs/methods/parseUrl.md +++ b/docs/methods/parseUrl.md @@ -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'; diff --git a/docs/methods/toPercent.md b/docs/methods/toPercent.md index d926f7c..b819f9d 100644 --- a/docs/methods/toPercent.md +++ b/docs/methods/toPercent.md @@ -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%'); diff --git a/docs/methods/toPlaceholder.md b/docs/methods/toPlaceholder.md index ee5d3a4..20362be 100644 --- a/docs/methods/toPlaceholder.md +++ b/docs/methods/toPlaceholder.md @@ -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); diff --git a/package.json b/package.json index 8e60200..ee4a2f1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c9a3b4..7d58df6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -213,7 +213,7 @@ packages: '@babel/helper-validator-option': 7.21.0 browserslist: 4.21.5 lru-cache: 5.1.1 - semver: 6.3.0 + semver: 6.3.1 dev: true /@babel/helper-compilation-targets@7.23.6: @@ -5891,7 +5891,7 @@ packages: engines: {node: '>=0.8'} dependencies: errlop: 2.2.0 - semver: 6.3.0 + semver: 6.3.1 dev: true /electron-to-chromium@1.4.352: @@ -8506,7 +8506,7 @@ packages: '@babel/parser': 7.21.4 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.0 - semver: 6.3.0 + semver: 6.3.1 transitivePeerDependencies: - supports-color dev: true @@ -9593,7 +9593,7 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} dependencies: - semver: 6.3.0 + semver: 6.3.1 dev: true /make-fetch-happen@2.6.0: