• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alovajs / alova / #183

13 Jun 2024 08:41AM UTC coverage: 97.363% (+0.005%) from 97.358%
#183

push

github

web-flow
fix: remove slash at the end when sending with empty url(#384)

524 of 547 branches covered (95.8%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 1 file covered. (100.0%)

2688 of 2752 relevant lines covered (97.67%)

149.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.48
/src/utils/variables.ts
1
import { GeneralFn } from './helper';
1✔
2

1✔
3
const undefStr = 'undefined';
1✔
4
// 以下为减少编译代码量而添加的统一处理函数或变量
1✔
5
export const PromiseCls = Promise as typeof Promise<any>,
1✔
6
  promiseResolve = <T>(value: T) => PromiseCls.resolve(value),
1✔
7
  promiseReject = <T>(value: T) => PromiseCls.reject(value),
1✔
8
  ObjectCls = Object,
1✔
9
  undefinedValue = undefined,
1✔
10
  nullValue = null,
1✔
11
  trueValue = true,
1✔
12
  falseValue = false,
1✔
13
  promiseThen = <T, TResult1 = T, TResult2 = never>(
1✔
14
    promise: Promise<T>,
780✔
15
    onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
780✔
16
    onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null
780✔
17
  ): Promise<TResult1 | TResult2> => promise.then(onFulfilled, onrejected),
1✔
18
  promiseCatch = <T, TResult = never>(
1✔
19
    promise: Promise<T>,
273✔
20
    onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null
273✔
21
  ) => promise.catch(onrejected),
1✔
22
  promiseFinally = <T>(promise: Promise<T>, onfinally?: (() => void) | undefined | null) => promise.finally(onfinally),
1✔
23
  JSONStringify = <T>(value: T) => JSON.stringify(value),
1✔
24
  JSONParse = (value: string) => JSON.parse(value),
1✔
25
  setTimeoutFn = (fn: GeneralFn, delay = 0) => setTimeout(fn, delay),
1✔
26
  clearTimeoutTimer = (timer: NodeJS.Timeout | string | number) => clearTimeout(timer),
1✔
27
  objectKeys = (obj: object) => ObjectCls.keys(obj),
1✔
28
  forEach = <T>(ary: T[], fn: (item: T, index: number, ary: T[]) => void) => ary.forEach(fn),
1✔
29
  pushItem = <T>(ary: T[], ...item: T[]) => ary.push(...item),
1✔
30
  mapItem = <T, R>(ary: T[], callbackfn: (value: T, index: number, array: T[]) => R) => ary.map(callbackfn),
1✔
31
  filterItem = <T>(ary: T[], predicate: (value: T, index: number, array: T[]) => unknown) => ary.filter(predicate),
1✔
32
  slice = <T>(ary: T[], start?: number, end?: number) => ary.slice(start, end),
1✔
33
  len = (data: any[] | Uint8Array | string) => data.length,
1✔
34
  isArray = (arg: any): arg is any[] => Array.isArray(arg),
1✔
35
  deleteAttr = <T extends Record<any, any>>(arg: T, attr: keyof T) => delete arg[attr],
1✔
36
  typeOf = (arg: any) => typeof arg,
1✔
37
  /** 三种缓存模式 */
1✔
38
  // 只在内存中缓存,默认是此选项
1✔
39
  MEMORY = 'memory',
1✔
40
  // 缓存会持久化,但当内存中没有缓存时,持久化缓存只会作为响应数据的占位符,且还会发送请求更新缓存
1✔
41

1✔
42
  STORAGE_PLACEHOLDER = 'placeholder',
1✔
43
  // 缓存会持久化,且每次刷新会读取持久化缓存到内存中,这意味着内存一直会有缓存
1✔
44
  STORAGE_RESTORE = 'restore',
1✔
45
  noBrowserWin = typeof window === undefStr || !window.location,
1✔
46
  // 是否为服务端运行,为了兼容浏览器以及非web客户端环境(如小程序),需要再判断一下process
1✔
47
  isSSR = noBrowserWin && typeof process !== undefStr;
1!
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc