Whoops! You need to install Pieces OS to run the Pieces Chrome Plugin

Checking for Pieces OS Connection

Pieces OS connected

Welcome to Pieces! Let's save a snippet

Hover over a code block to reveal the "Copy and Save" button. Once clicked, the snippet will automatically be saved to your Pieces micro-repo and copied to your clipboard.

Pro tip: You can also save via the right-click context menu.

Try below!

const deepClone = (obj: any) => {
	if (obj === null) return null;
  let clone = { ...obj };

  Object.keys(clone).forEach(
	  (key) =>
      (clone[key] = typeof obj[key] === "object" ? deepClone(obj[key]) : obj[key])
   );
	 return Array.isArray(obj) && obj.length
	   ? (clone.length = obj.length) && Array.from(clone)
	   : Array.isArray(obj)
     ? Array.from(obj)
     : clone;
};

Next