unity-template / onex-utils Goto Github PK
View Code? Open in Web Editor NEWWeb business development general tool library 通用业务工具库 🥷
Home Page: https://unity-template.github.io/onex-utils/index.html
License: MIT License
Web business development general tool library 通用业务工具库 🥷
Home Page: https://unity-template.github.io/onex-utils/index.html
License: MIT License
lodash中存在curry和curryRight的实现:https://lodash.com/docs/4.17.15#curry
interface InsertOptions {
type: ScriptType;
src?: string;
content?: string;
extOptions?: Record<string, string>;
/**
* 脚本超时等待时间,单位毫秒
* @defaultValue 3000
*/
loadTimeout?: number;
containerNode?: Element;
}
interface InsertScript {
(options: ): Promise<void>;
}
测试用例应该包含如下:T
测试用例应该包含如下:T
export function removeFlag<T extends number>(flag: T, remove: T & {}): T {
return ((flag ^ remove) & flag) as T;
}
export function hasAllFlags(flags: number, check: number): boolean {
return (flags & check) === check;
}
export function hasAnyFlag(flags: number, check: number): boolean {
return (flags & check) !== 0;
}
// 结合形成一组类型
const commonFlags = ts.SymbolFlags.Transient |
ts.SymbolFlags.Assignment |
ts.SymbolFlags.Optional |
ts.SymbolFlags.Prototype
测试用例应该包含如下:T
UUID: 通用唯一标识符 ( Universally Unique Identifier ),对于所有的UUID它可以保证在空间和时间上的唯一性,也称为GUID,全称为:Universally Unique IDentifier ,它是通过MAC地址,时间戳,命名空间,随机数,伪随机数来保证生成ID的唯一性。有着固定的大小( 128 bit位 ),通常由 32 字节的字符串(十六进制)表示。
特性:它的唯一性和一致性特点,使得可以无需注册过程就能够产生一个新的UUID;UUID可以被用作多种用途, 既可以用来短时间内标记一个对象,也可以可靠的辨别网络中的持久性对象。
interface GenUUID {
(): string;
}
测试用例应该包含如下:
将tsconfig.json
中targte
修改为ES5
,运行测试命令npm run test
,输出
TypeError: Constructor Map requires 'new'
支持仓库构建到ES5
Booster
utils 中 dom 工具方法中pageLock、unLockPage需要添加测试用例
无
测试用例应该包含如下:T
测试用例应该包含如下:T
通过装饰器针对参数GET进行拦截,如果conditions返回为True,执行自定义operation函数
type Options<I> = [conditions: (v: I) => boolean, operation: (target: Object, propertyKey: string | symbol) => void];
export interface handleDescriptor<T> {
(target: Object, propertyKey: string | symbol, options: Options<T>): void;
}
测试用例应该包含如下:T
image-size: https://github.com/image-size/image-size
针对服务端数据进行统一校验&转化,主要是针对组件使用过程中进行转化和封装,主要支持以下三种场景
export class DataDto {
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizCode: string;
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizName: string;
@Rule(RuleType.number())
@addAlarm // 报警装饰
note?: string;
}
@ValidateComponentProps(DataDto)
class Node extends Component<DataDto> {
IRender() {
console.log(this.props.bizCode, this.props.bizName, this.props.note);
}
}
new Node({
bizCode: '你好',
bizName: '世界',
}).IRender();
/**
* output:
* Debugger attached.
* DataDto.note: 参数告警
* test-你好 test-世界 undefined
*/
2.函数组件的props
export class DataDto {
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizCode: string;
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizName: string;
@Rule(RuleType.number())
@addAlarm // 报警装饰
note?: string;
}
class Node extends Component<DataDto> {
IRender() {
console.log(this.props.bizCode, this.props.bizName, this.props.note);
}
}
const INode = ValidateComponentPropsHoc(DataDto)(Node)
new INode({
bizCode: '你好',
bizName: '世界',
}).IRender();
/**
* output:
* Debugger attached.
* DataDto.note: 参数告警
* test-你好 test-世界 undefined
*/
3.服务端的数据的转化
export class DataDto {
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizCode: string;
@Rule(RuleType.string().required())
@addPre('test') // 添加前缀
bizName: string;
@Rule(RuleType.number())
@addAlarm // 报警装饰
note?: string;
}
const result = validateInterfaceData(DataDto)({
bizCode: '你好',
bizName: '世界',
note: '213',
});
console.log(result.bizCode, result.bizCode, result.note);
// console.log test-你好 test-你好 213
每次发布,动态计算出每个函数的支持版本,不需要通过注释标记:
semver -r ^0.12.0 0.12.0 0.13.0 0.13.1
输出0.12.0
^指明的版本范围,只要不修改 [major, minor, patch] 三元组中,最左侧的第一个非0位,都是可以的。也就是说,要确定 ^版本包含的范围,先要找到 最左侧的第一个非0位 ,只有在这一位右侧的变动,才被包含在这个 ^ 指定的范围内,需要发布大版本号1.0.0 或者 0.0.1
无
无
编写typedoc插件,简化url地址
无
无
针对这个问题是够可以和Typedoc进行一些共建,不需要做成单点的功能,首先需要Typedoc的issue中找下,看下有没有相似的问题
参考:关于前端大管家 package.json,你知道多少?完善项目的package.json
添加对javascript等基础数据类型的判断
测试用例应该包含如下:T
前端 e2e 测试而言,cypress 与 puppeteer 无疑是最流行的框架
测试用例应该包含如下:T
针对此bug新增测试用例如下:
针对此bug新增测试用例如下:
针对time.createDayjs添加文档link
Links can point to a URL: {@link https://day.js.org/ | dayjs}
根据LBS定位计算两点之间的距离
interface GetDistance {
(lng1: number, lat1: number, lng2: number, lat2: number): number;
}
目前文档内容的呈现存在一定的问题,需要新增定制模板,更好的体现整个工具库的层面关系
测试用例应该包含如下:T
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.