satori icon indicating copy to clipboard operation
satori copied to clipboard

chore: remove isString, isNumber

Open dimaMachina opened this issue 2 years ago • 7 comments

don't need dummy functions, native ts type narrowing works great

dimaMachina avatar May 30 '23 22:05 dimaMachina

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
satori-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2023 10:04pm

vercel[bot] avatar May 30 '23 22:05 vercel[bot]

Are these changes really necessary? 🤔️ I still think that isNumber(xxx) is more concise and straightforward compared to typeof xxx === 'number'.

LuciNyan avatar Jun 01 '23 02:06 LuciNyan

What’s the benefit isNumber and isString against typeof?

Downsides:

  1. Sometimes these functions are used in code bases but in most cases not
  2. Unneeded function call

dimaMachina avatar Jun 01 '23 08:06 dimaMachina

What’s the benefit isNumber and isString against typeof?

Concise and straightforward.

2. Unneeded function call

It looks more concise, so I don't think this is unnecessary. Apart from your subjective view of it being unnecessary, are there any risks? 🤔️

LuciNyan avatar Jun 01 '23 08:06 LuciNyan

They don’t look concise, they look like Monkey business code

They are just aliases for typeof

dimaMachina avatar Jun 01 '23 08:06 dimaMachina

They don’t look concise, they look like Monkey business code

I beg to differ, but don’t mean to knock your coding tastes. It seems pointless to continue the discussion. You do you, as long as you’re content.

LuciNyan avatar Jun 01 '23 08:06 LuciNyan

I think different people have different code tastes, i am saying here not for isNumber or typeof:

  1. bench image

i run the bench in my machine, and it looks like there is little performance enhancement, or even worse?

  1. isNumber is more straightforward
  2. someone like me like reading commit to dig into this repo, non-sense commit just make commits' history noisy.
  3. no offense, but we should prompt more necessary change.

conclusion:

i think we should not make some pure code taste change, and should think is this pr really make this code better? and prove it. If just code taste change, maybe the code will change endlessly.😂

P.S: I perfer isNumber :see_no_evil:

Jackie1210 avatar Jun 01 '23 12:06 Jackie1210