Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 regels
444 B

  1. import isEmpty from './isEmpty'
  2. interface Stringify {
  3. (v: any): string,
  4. }
  5. const stringify: Stringify = v => {
  6. if (isEmpty(v)) {
  7. return ''
  8. }
  9. if (Array.isArray(v)) {
  10. return v
  11. .filter(v => !isEmpty(v))
  12. .map(v => stringify(v))
  13. .join(',')
  14. }
  15. const rawStringified = String(v)
  16. if (rawStringified === '[object Object]') {
  17. return JSON.stringify(v)
  18. }
  19. return rawStringified
  20. }
  21. export default stringify