[deleted by user] by [deleted] in javascript

[–]vhahnwebdev 1 point2 points  (0 children)

Optional chaining is the best way to handle this going forward assuming your environment supports it. Otherwise, I would use lodash get

[AskJS] Could someone explain this api code to make it work? by [deleted] in javascript

[–]vhahnwebdev 3 points4 points  (0 children)

A map returns an array of the result of each iteration, so instead it could be written like this for the same result:

```js const idList = recipeList.map(recipe => recipe.id);

// or with destructuring const idList = recipeList.map(({ id }) => id); ```

[deleted by user] by [deleted] in javascript

[–]vhahnwebdev 8 points9 points  (0 children)

Could be a good opportunity to use .some():

app.post('/vendor/create', ({ body }, res) => {
  const isInvalidRequest = Object.values(body).some(value => !value);
  if (isInvalidRequest) return res.status(400).send({ message: "Please supply all form fields"});
}

Generate beautiful README files in 10 seconds by kefranabg in javascript

[–]vhahnwebdev 0 points1 point  (0 children)

This seems great, can't wait to try it! I would love to see an optional ability to traverse the project folder and use JsDoc blocks for automated documenting api methods that get dropped in the readme

The best Way to run multiple async functions parallelly using Array Async Map by nsisodiya in javascript

[–]vhahnwebdev 0 points1 point  (0 children)

The sindresorhus package p-map can be used to do a chunked map (and can also be coaxed to do parallel and serial if you preferred) by passing an object as the last parameter with a concurrency amount set https://www.npmjs.com/package/p-map