Browse Source

add some base utilities

axolotle 3 years ago
parent
commit
a7a3971fcb
1 changed files with 10 additions and 0 deletions
  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(', ')
+}