Sfoglia il codice sorgente

add some base utilities

axolotle 3 anni fa
parent
commit
a7a3971fcb
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      src/helpers/common.js

+ 10 - 0
src/helpers/common.js

@@ -0,0 +1,10 @@
+export function trim (str) {
+  if (!str) return str
+  return str.replace(/^\s+|\s+$/g, '')
+}
+
+
+export function toCommaList (arr, key = 'name') {
+  if (!arr) return
+  return arr.map(item => item[key]).join(', ')
+}