progress
This commit is contained in:
parent
6446da7e76
commit
6f86377685
18 changed files with 274 additions and 107 deletions
|
@ -1,13 +1,3 @@
|
|||
export {};
|
||||
|
||||
declare global {
|
||||
interface Array<T> {
|
||||
// @strict: The parameter is determined whether the arrays must be exactly the same in content and order of this relationship or simply follow the same requirements.
|
||||
equals(array: Array<T>, strict: boolean): boolean;
|
||||
lastElement(): T | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export const ArrayExtensions = () => {
|
||||
if ([].equals === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
|
@ -42,4 +32,10 @@ export const ArrayExtensions = () => {
|
|||
}
|
||||
};
|
||||
}
|
||||
if ([].isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
Array.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
import { ArrayExtensions } from "./array";
|
||||
import { StringExtensions } from "./string";
|
||||
|
||||
export const extensions = () =>{
|
||||
ArrayExtensions()
|
||||
declare global {
|
||||
interface Array<T> {
|
||||
// @strict: The parameter is determined whether the arrays must be exactly the same in content and order of this relationship or simply follow the same requirements.
|
||||
equals(array: Array<T>, strict: boolean): boolean;
|
||||
lastElement(): T | undefined;
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
interface String {
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export const extensions = () => {
|
||||
ArrayExtensions();
|
||||
StringExtensions();
|
||||
};
|
||||
|
|
8
ui/src/core/extensions/string.ts
Normal file
8
ui/src/core/extensions/string.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export const StringExtensions = () => {
|
||||
if ("".isEmpty === undefined) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.isEmpty = function () {
|
||||
return this.length === 0;
|
||||
};
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue