morgan-utils

1.0.2 • Public • Published

morgan-utils

Utitlity library

npm star

安全取值: 安全取出对象中的某个属性
在获取对象一个深层的属性时,必须保证它的上一级不为undefined;
为了不让程序崩溃,抽象出一个安全取值的方法;

常规:
props.user &&
props.user.posts &&
props.user.posts.comments

使用utils:
import { safeGet } from 'morgan-utils';

safeGet(data: Object, pathValue: ?string)

Readme

Keywords

Package Sidebar

Install

npm i morgan-utils

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

5.12 kB

Total Files

7

Last publish

Collaborators

  • markyun