0.0.29 • Published 1 year ago

@sincerecloud/sc-utils v0.0.29

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
1 year 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

1 year ago

0.0.28

1 year ago

0.0.27

2 years ago

0.0.25

2 years ago

0.0.26

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago