open-index/open-npm huggingface dataset:
npm package: @staryea/network-env
Description: staryea-network-env
Author: jiangweiye
Latest version: 0.1.5

# @staryea/network-env

环境变量

## 安装

### with pnpm

```sh
pnpm add @staryea/network-env
```

### with yarn

```sh
yarn add @staryea/network-env
```

### with npm

```sh
npm install @staryea/network-env
```

## 模块

-   SYSTEM
    1. portal
    2. portal-plugins
    3. alarm
    4. busmange
    5. ipran
    6. jobplan
    7. judege
    8. napm
    9. ponems
    10. rtree
-   GATEWAY
    1. portal
    2. portal-plugins
    3. alarm
    4. busmange
    5. ipran
    6. jobplan
    7. judege
    8. napm
    9. ponems
    10. rtree

## 使用

```typescript
import { Env } from '@staryea/network-env';
const system_portal = Env.Portal.SYSTEM;
const gateway_portal = Env.Portal.GATEWAY;

const system_portal_plugin = Env.PortalPlugins.SYSTEM;
const gateway_portal_plugin = Env.PortalPlugins.GATEWAY;

const system_napm = Env.Napm.SYSTEM;
const gateway_napm = Env.Napm.GATEWAY;
```
npm package: @staryea/network-request
Description: staryea-network-request
Author: jiangweiye
Latest version: 0.1.3

# @staryea/network-ajax 网络数据产品部门 ajax 请求库

## 接口

**Response**

```typescript
/**
 * @description 接口响应体
 * @interface Response
 * @template D
 * @property {string} result_code 响应码
 * @property {D} data 响应数据
 * @property {string} result_msg 响应信息
 * @property {number} [recordsTotal] 总条数
 * @example
 * {
 *    "result_code": "0",
 *    "data": {
 *      "id": 1,
 *      "name": "张三"
 *     },
 *    "result_msg": "请求成功"
 * }
 */
interface Response<D = any> {
    result_code: string;
    data: D;
    result_msg: string;
    recordsTotal?: number;
}
```

**AXIOS_DEFAULT_CONFIG**

```typescript
/**
 * @description 默认配置
 * @type {AxiosRequestConfig}
 * @property {number} timeout 超时时间
 * @property {string} baseURL 基础路径
 * @property {string} responseType 响应数据类型
 */
declare const AXIOS_DEFAULT_CONFIG: AxiosRequestConfig;
```

**IPostConfig**

```typescript
/**
 * @description post默认请求配置类型
 */
type IPostConfig = Pick<AxiosRequestConfig, 'data' | 'params' | 'headers'>;
```

**DEFAULT_POST_CONFIG**

```typescript
/**
 * @description post默认请求参数
 */
declare const DEFAULT_POST_CONFIG: IPostConfig;
```

### 函数

**$post**

```typescript
/**
 * @description post请求
 * @param url 请求地址
 * @param config 请求配置
 * @returns {Promise<R>}
 * @example
 * $post('/xx/xx', { data: { a: 1 }, params: { b: 2 }, headers: { c: 1 } }).then(res => {
 *     console.log(res.data, `res.data`);
 *     console.log(res.result_code, `res.result_code`);
 *     console.log(res.result_msg, `res.result_msg`);
 * });
 */
declare const $post: <R = Response<any>>(url: string, config?: IPostConfig) => Promise<R>;
```

**$postForm**

```typescript
/**
 * @description post请求
 * @param url 请求地址
 * @param config 请求配置
 * @returns {Promise<R>}
 * @example
 * $postForm('/xx/xx', { data: { a: 1 }, params: { b: 2 }, headers: { c: 1 } }).then(res => {
 *     console.log(res.data, `res.data`);
 *     console.log(res.result_code, `res.result_code`);
 *     console.log(res.result_msg, `res.result_msg`);
 * });
 */
declare const $postForm: <R = Response<any>>(url: string, config?: IPostConfig) => Promise<R>;
```

**$get**

```typescript
/**
 * @description get请求
 * @param url 请求地址
 * @param config 请求配置
 * @returns {Promise<R>}
 * @example
 * $get('/xx/xx', { data: { a: 1 }, params: { b: 2 }, headers: { c: 1 } }).then(res => {
 *     console.log(res.data, `res.data`);
 *     console.log(res.result_code, `res.result_code`);
 *     console.log(res.result_msg, `res.result_msg`);
 * });
 */
declare const $get: <R = Response<any>>(url: string, config?: IPostConfig) => Promise<R>;
```

**$download**

```typescript
/**
 * @description 下载
 * @param url 请求地址
 * @param config 请求配置
 * @returns {Promise<R>}
 * @example
 * $download('/xx/xx', { params: { b: 2 } }).then(res => {
 *     console.log(res.data, `res.data`);
 *     console.log(res.result_code, `res.result_code`);
 *     console.log(res.result_msg, `res.result_msg`);
 * });
 */
declare const $download: (url: string, config?: Pick<IPostConfig, 'params'>) => void;
```
npm package: @staryea/network-shared
Description: staryea-network-shared
Author: jiangweiye
Latest version: 0.1.6

# @staryea/network-shared

工具包

## 安装

### with pnpm

```sh
pnpm add @staryea/network-shared
```

### with yarn

```sh
yarn add @staryea/network-shared
```

### with npm

```sh
npm install @staryea/network-shared
```

## apis

### **getQueryString**

#### 获取 url 中的参数

| 字段名 | 类型          | 描述           | 必传 |
| ------ | ------------- | -------------- | ---- |
| query  | string        | 要获取的参数名 | 是   |
| href   | string \|null | 地址           | 否   |

#### 类型

```typescript
declare const getQueryString: (query: string, href?: string) => string | null;
```

#### 示例

```typescript
import { getQueryString } from '@staryea/network-shared';
const url = 'http://example.com/?test=123&foo=bar';
const query = getQueryString('test');
console.log(query);
// 123
```

### debounce

#### **防抖**

| 字段名    | 类型                    | 描述           | 必传 |
| --------- | ----------------------- | -------------- | ---- |
| func      | (...args: any[]) => any | 需要防抖的函数 | 是   |
| duration  | number                  | 毫秒           | 否   |
| immediate | boolean                 | 是否立即执行   | 否   |

#### 类型

```typescript
declare const debounce: <F extends (...args: any[]) => any>(
    func: F,
    duration?: number,
    immediate?: boolean
) => (...args: Parameters<F>) => ReturnType<F>;
```

#### 示例

```typescript
import { debounce } from '@staryea/network-shared';
const fn = debounce(() => {
    console.log('debounce');
}, 300);
fn();
```

### throttle

#### **节流**

| 字段名   | 类型                    | 描述     | 必传 |
| -------- | ----------------------- | -------- | ---- |
| func     | (...args: any[]) => any | 节流函数 | 是   |
| duration | number                  | 毫秒     | 否   |

#### 类型

```typescript
declare const throttle: <F extends (...args: any[]) => any>(func: F, duration?: number) => (...args: Parameters<F>) => ReturnType<F>;
```

#### 示例

```typescript
import { throttle } from '@staryea/network-shared';
const fn = throttle(() => {
    console.log('throttle');
}, 1000);
fn();
```

---

### deepCopy

#### **深拷贝**

| 字段名 | 类型                                        | 描述         | 必传 |
| ------ | ------------------------------------------- | ------------ | ---- |
| data   | Array<any> \| Record<string \| symbol, any> | 要拷贝的数据 | 是   |

#### 类型

```typescript
declare const deepCopy: <T extends Array<T> | Record<string | symbol, any>>(data: T) => T;
```

#### 示例

```typescript
import { deepCopy } from '@staryea/network-shared';
const obj = { a: 1, b: 2 };
const copyObj = deepCopy(obj);
console.log(copyObj);
```