Quirk - JSON.stringify removes empty properties.

Thursday, January 19th 2023

Problem

I noticed that when I was upserting docs in mongodb the fields where not getting reset because the value coming in was undefined instead of null.

Solution

Pass a custom replacer function to to JSON.stringify() so when a value is undefined, we use null instead.

const user = { name: 'Quirky', phone: undefined }; const replacer = (key, value) => (typeof value === 'undefined' ? null : value); const stringified = JSON.stringify(user, replacer); // -> "{\"name\":\"Quirky\",\"phone\":null}"

react-markdown

Sunday, January 22nd 2023

How to Setup React Markdown

Install npm dependencies:

$ yarn install react-markdown remark-gfm react-frontmatter

Pass in the 2 plugins.

import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import remarkFrontmatter from 'remark-frontmatter'; const markdown = `Just a link: https://reactjs.com.\n# Ola beaches.\n`; <ReactMarkdown remarkPlugins={[remarkGfm, remarkFrontmatter]}>{markdown}</ReactMarkdown>;

Markdown Test Unit

Sunday, January 22nd 2023

A paragraph with emphasis and strong importance.

Ola ola ola

Ola ola ola

Ola ola ola

Ola ola ola

Ola ola ola
Ola ola ola

Javascript Codeblock

import fake from 'some-npm'; console.log('Test JavaScript CodeBlock.');

A block quote with strikethrough and a URL: https://reactjs.org.

Bacon ipsum dolor amet doner chislic cow ham hock andouille. Alcatra pork chuck, short loin pastrami meatloaf sirloin bacon capicola. Filet mignon shank jowl, tongue shankle ham hock meatloaf tail buffalo tenderloin capicola. Kevin flank ham hock, tongue andouille venison leberkas chicken beef sirloin. Turducken filet mignon porchetta cupim pancetta. Leberkas pork tenderloin doner.


Unordered List

  • List Item
  • List Item
  • List Item
    • List Item
      • List Item
      • List Item

Ordered List

  1. first list item
  2. second list item
  3. third list item
    1. sub item
    2. sub item

Checklist

  • todo
  • done

A Table:

ab
test first columntest second column
againtest again

Scalable Vector Graphics

Test 1 https://node.suayan.com/

Test 2 https://node.suayan.com/