How to use the @uform/types.isPlainObj 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
return (obj: any, path: Path, value?: any): any => {
    let ast = null

    if (!cache.get(path)) {
      ast = parseDesturctPath(path)
      cache.set(path, ast)
    } else {
      ast = cache.get(path)
    }
    if (!isArr(ast.destruct) && !isPlainObj(ast.destruct)) {
      return get(obj, path, value)
    }
    return mapReduce(ast.destruct, (mapPath, key) => {
      return get(obj, ast.startPath.concat(key[key.length - 1]))
    })
  }
}
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
destructKey(key, readyReplace) {
      if (!key) {
        return
      }
      token = key
      if (readyReplace) {
        realKey = key
        lastDestruct = destruct
        return
      }
      if (isArr(destruct)) {
        ;(destruct as string[]).push(key)
      } else if (isPlainObj(destruct)) {
        destruct[realKey && lastDestruct === destruct ? realKey : key] = key
      }
      realKey = ''
      lastDestruct = destruct
    },
    destructArrayStart() {
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
return map(internalObj, (item: any, key: string) => {
      const newPath = path.concat(key)
      if (isArr(item) || isPlainObj(item)) {
        return internalTraverse(item, newPath)
      } else {
        return callback(
          newPath,
          newPath.slice(0, newPath.length - 1).concat(item)
        )
      }
    })
  }
github alibaba / uform / packages / utils / src / accessor.ts View on Github external
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
destructArrayStart() {
      if (!destruct) {
        root = []
        destruct = root
      } else {
        destruct = []
      }
      const tail = stack[stack.length - 1]
      if (isPlainObj(tail)) {
        tail[token] = destruct
      } else if (isArr(tail)) {
        tail.push(destruct)
      }
      stack.push(destruct)
    },
    destructObjectStart() {

@uform/types

> UForm数据校验工具

MIT
Latest version published 5 years ago

Package Health Score

68 / 100
Full package analysis

Similar packages