How to use the @uform/types.isStr function in @uform/types

To help you get started, we’ve selected a few @uform/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alibaba / uform / packages / utils / src / accessor.ts View on Github external
export function getPathSegments(path: Path): ArrayPath {
  if (isArr(path)) {
    return path as string[]
  }
  if (isStr(path) && path) {
    const cached = PathCache.get(path)
    if (cached) {
      return cached
    }
    const pathArr = (path as string).split('.')
    const parts = []

    for (let i = 0; i < pathArr.length; i++) {
      let p = pathArr[i]

      while (p[p.length - 1] === '\\' && pathArr[i + 1] !== undefined) {
        p = p.slice(0, -1) + '.'
        p += pathArr[++i]
      }

      parts.push(p)
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
function toString(val: Path | null) {
  if (!val) {
    return ''
  }
  if (isArr(val)) {
    return (val as string[]).join('.')
  }
  return isStr(val) ? val : ''
}
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
const internalTraverse = (internalObj: any, path: string[]) => {
    if (isStr(internalObj)) {
      return callback(internalObj, internalObj)
    }
    each(internalObj, (item: any, key: string) => {
      const newPath = path.concat(key)
      if (isArr(item) || isPlainObj(item)) {
        internalTraverse(item, newPath)
      } else {
        callback(newPath, item)
      }
    })
  }
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
const parseDestruct = (str: PathNode) => {
  if (!isStr(str)) {
    return str
  }

  let destruct: Destruct
  const stack = []
  let token = ''
  let realKey = ''
  let lastDestruct: Destruct
  let root: Destruct

  new DestructTokenizer(str as string, {
    name(key: string) {
      root = key
    },
    destructKey(key, readyReplace) {
      if (!key) {

@uform/types

> UForm数据校验工具

MIT
Latest version published 5 years ago

Package Health Score

68 / 100
Full package analysis

Similar packages