From e765fcc08df54b5acd872acfbc19678be548d6f9 Mon Sep 17 00:00:00 2001 From: Koichi Kiyokawa Date: Sun, 7 Aug 2022 13:51:33 +0900 Subject: [PATCH] docs: add comparison table --- README.md | 23 ++++++----------------- docs/index.md | 2 ++ docs/parts/comparison.md | 8 ++++++++ scripts/generate_doc.mjs | 8 ++++++++ 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 docs/parts/comparison.md diff --git a/README.md b/README.md index 025cda64..3a7aa696 100644 --- a/README.md +++ b/README.md @@ -67,20 +67,9 @@ You can see utility methods document [here](https://rhodash.vercel.app/). ## Comparison -### [Lodash](https://github.com/lodash/lodash) - -As you know, Lodash is the most popular utility library in npm, but it's size is huge(see [here](https://bundlephobia.com/result?p=lodash)). So, Lodash is not suitable for frontend development. - -### [just](https://github.com/angus-c/just) - -just is alternative to lodash. The philosophy of just is "just one thing". Therefore, if you want to use the functions, you need to install the corresponding packages one by one. It will increase the number of lines in package.json. - -### [rambda]() - -rambda is "faster and smaller alternative to Ramda". It includes type definittion, treeshakable and minimal size. However, some of the functions have a different API than Lodash's. For example, the argument for `pick` is the opposite of Lodash. This is confusing. In addition, since rambda is designed for functional programming, it has many extra functions for those who do not need functional programming. - -## Run tests - -```sh -pnpm run test -``` +|   | [rhodash](https://github.com/KoichiKiyokawa/rhodash) | [Lodash](https://github.com/lodash/lodash) | [just](https://github.com/angus-c/just) | [rambda](https://github.com/selfrefactor/rambda) | +| ----------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ️📦️ Size of whole the package | ![](https://badgen.net/bundlephobia/minzip/rhodash?cache=300) | ![](https://badgen.net/bundlephobia/minzip/lodash?cache=300) | -
You should install each packages one by one. | ![](https://badgen.net/bundlephobia/minzip/rambda?cache=300) | +| 📚 Easy-to-understand JSDoc | ✅
(It has both description and example) | ❌ | ❌ | :warning:
(It only has description) | +| 🦘 Ease of jumping to the original source | 👍 | 🤔
(You can, but it is complex) | ❌ | ❌ | +| :pencil2: Remarks | This library | Most popular, but huge. | You need to install the corresponding packages one by one. It will increase the number of lines in package.json. | Designed for functional programming, so it has many extra functions for those who do not need functional programming. In addition, some of the functions have a different API than Lodash's | diff --git a/docs/index.md b/docs/index.md index 6d69ffc2..0dbca6cc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,3 +10,5 @@ Lodash is huge. It is not suitable for frontend development. npm install rhodash # or yarn add rhodash ``` + + diff --git a/docs/parts/comparison.md b/docs/parts/comparison.md new file mode 100644 index 00000000..9111c175 --- /dev/null +++ b/docs/parts/comparison.md @@ -0,0 +1,8 @@ +## Comparison + +|   | [rhodash](https://github.com/KoichiKiyokawa/rhodash) | [Lodash](https://github.com/lodash/lodash) | [just](https://github.com/angus-c/just) | [rambda](https://github.com/selfrefactor/rambda) | +| ----------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ️📦️ Size of whole the package | ![](https://badgen.net/bundlephobia/minzip/rhodash?cache=300) | ![](https://badgen.net/bundlephobia/minzip/lodash?cache=300) | -
You should install each packages one by one. | ![](https://badgen.net/bundlephobia/minzip/rambda?cache=300) | +| 📚 Easy-to-understand JSDoc | ✅
(It has both description and example) | ❌ | ❌ | :warning:
(It only has description) | +| 🦘 Ease of jumping to the original source | 👍 | 🤔
(You can, but it is complex) | ❌ | ❌ | +| :pencil2: Remarks | This library | Most popular, but huge. | You need to install the corresponding packages one by one. It will increase the number of lines in package.json. | Designed for functional programming, so it has many extra functions for those who do not need functional programming. In addition, some of the functions have a different API than Lodash's | diff --git a/scripts/generate_doc.mjs b/scripts/generate_doc.mjs index c134bab7..2460b8f4 100644 --- a/scripts/generate_doc.mjs +++ b/scripts/generate_doc.mjs @@ -1,5 +1,6 @@ import { fs, globby } from 'zx' +// generate functions doc const functionsNames = globby .globbySync('src/*.ts', { ignore: ['src/index.ts'] }) .map((file) => file.replace(/^src\/(.+)\.ts/, '$1')) @@ -7,6 +8,13 @@ functionsNames.forEach((fn) => { fs.writeFileSync(`docs/${fn}.md`, getDocumentFromFunctionName(fn)) }) +// generate comparison table +const readme = fs.readFileSync('README.md') +const comparisonTable = String(readme).match(/(#+ Comparison[\s\S]+)/)?.[1] +fs.writeFileSync('docs/parts/comparison.md', comparisonTable) + +$`pnpm prettier --write docs` + /** * @param {string} name e.g. 'chunk' * @return {string} Markdown string