0.0.29 • Published 3 months ago

@sincerecloud/sc-utils v0.0.29

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 months ago

@sincerecloud/sc-utils

  • 包含HighAxios 类,对axios 二次封装,处理预定状态码
  • 常用object处理方法
  • 中英翻译查询方法
  • 常用正则表达式

安装

npm install axios
npm install @sincerecloud/sc-utils

具体文档请使用 yarn dev 查看

初始化

初始化baseHttp工厂函数

import { HighAxios, getAxios } from '@sincerecloud/sc-utils'

// getAxios 初始化 工厂函数
const baseHttp = getAxios(config)
// or 通过HigAxios 初始化 工厂函数
// const getAxios = HighAxios(config)
// const baseHttp = getAxios(config)

object

查找方法

/**
 * @param {Object} obj 对象
 * @param {String} prototype 属性名
 * @returns Boolean
 */
export const hasOwn = (obj: Object, prototype: string) => {
  return Object.hasOwnProperty.call(obj, prototype);
};

/**
 * 深度获取对象的值
 * @param collection Data source
 * @param keyPath Key path array
 * @param notSetValue Default value for not found
 */
export const getObjectIn = (collection: Object, keyPath: string[], notSetValue:unknown = null) => {
  return keyPath.reduce((rlt: any, keyIndex: string) => {
    return (rlt && rlt[keyIndex] ? rlt[keyIndex] : null)
  }, collection) || notSetValue
}
0.0.29

3 months ago

0.0.28

4 months ago

0.0.27

5 months ago

0.0.25

5 months ago

0.0.26

5 months ago

0.0.24

5 months ago

0.0.23

5 months ago

0.0.22

5 months ago

0.0.20

5 months ago

0.0.21

5 months ago

0.0.17

5 months ago

0.0.18

5 months ago

0.0.19

5 months ago

0.0.16

5 months ago

0.0.15

5 months ago

0.0.14

6 months ago

0.0.13

6 months ago

0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago