UNPKG

@bxjs/base

Version:

45 lines (39 loc) 2.32 kB
import * as __F__ from 'lodash' import { MomentInput, Moment } from 'moment' declare function __bxjs_lodash_pluck__<T>(items: T[], keys: (keyof T)[]): T[] declare function __bxjs_lodash_pick__<T>(item: T, keys: (keyof T)[]): T declare global { // 函数式编程基础类库全局导出(已经在业务框架上内置集成) // 使用文档:https://www.lodashjs.com/docs/latest const F: Omit<__F__.__, 'pick'> & { pluck: typeof __bxjs_lodash_pluck__ pick: typeof __bxjs_lodash_pick__ } // 时间处理类库的统一封装(底层基于moment使用) 使用文档:http://momentjs.cn/docs/ // moment 是可变的。 调用任何一种操作方法都会改变原始的 moment。 // 如果要创建副本并对其进行操作,则应在操作 moment 之前使用 moment#clone function xdate(input?: MomentInput): Moment // 对于数组嵌套回调函数的nodejs异步处理方法的统一封装 // https://blog.csdn.net/sam976/article/details/52330424 // 异步方法中map、forEach和for循环中带来的异步执行问题 // https://blog.csdn.net/fangjian1204/article/details/50585073 // node.js在遇到“循环+异步”时的注意事项 function xmap<T>(values: T[], callack: (v: T) => Promise<any>): Promise<any[]> // 基础方法 // 配置参数获取 function xconfig<T>(key: string, defaultValue?: T): any // 深度拷贝功能(替代Object.assign解决目前不支持深度拷贝缺陷) // 最后一个参数如果为boolean表示是否数组合并,默认值为false数组不合并直接覆盖。 function xassign(target, source, ...args): any function xuuid(): string function xsleep(ms): Promise<void> // function xsql(text): Promise<void> function xcall<T>(func: T, msg?: string | ((err: Error) => Promise<void> | void), callback?: ((err: Error) => Promise<void> | void) | string): Promise<T> namespace xcontext { // run为内部方法仅仅在框架层面上使用(请求上下文、会话上下文、数据库链接上下文、事务上下文、等等) // function run(callback: () => Promise<void>): Promise<void> function get(key: string, defaultValue?): any function set(key: string, value: any): void } }