Skip to content

Commit

Permalink
docs: add comparison table
Browse files Browse the repository at this point in the history
  • Loading branch information
KoichiKiyokawa committed Aug 7, 2022
1 parent d1dfac2 commit e765fcc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | -<br>You should install each packages one by one. | ![](https://badgen.net/bundlephobia/minzip/rambda?cache=300) |
| 📚 Easy-to-understand JSDoc | ✅ <br>(It has both description and example) ||| :warning: <br>(It only has description) |
| 🦘 Ease of jumping to the original source | 👍 | 🤔<br>(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 |
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Lodash is huge. It is not suitable for frontend development.
npm install rhodash
# or yarn add rhodash
```

<!--@include: ./parts/comparison.md-->
8 changes: 8 additions & 0 deletions docs/parts/comparison.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Comparison

| &nbsp; | [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) | -<br>You should install each packages one by one. | ![](https://badgen.net/bundlephobia/minzip/rambda?cache=300) |
| 📚 Easy-to-understand JSDoc | ✅ <br>(It has both description and example) ||| :warning: <br>(It only has description) |
| 🦘 Ease of jumping to the original source | 👍 | 🤔<br>(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 |
8 changes: 8 additions & 0 deletions scripts/generate_doc.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
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'))
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
Expand Down

1 comment on commit e765fcc

@vercel
Copy link

@vercel vercel bot commented on e765fcc Aug 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rhodash – ./

rhodash.vercel.app
rhodash-git-main-koichikiyokawa.vercel.app
rhodash-koichikiyokawa.vercel.app

Please sign in to comment.