WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { unflatten } from 'flat'
 
export function isObject(obj) {
  return obj !== null && typeof obj === 'object'
}
 
export function hasChildPaths(path, paths) {
  if (!path) {
    return false
  }
 
  const localeMessages = unflatten(
    paths.reduce((val, path) => {
      val[path] = ''
      return val
    }, {})
  )
  const splits = path.split('.')
 
  // TODO: should be more strogly checking ...
  let p = null
  let data = localeMessages
  while ((p = splits.shift())) {
    data = data[p]
  }
  return data !== undefined
}