-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
47 lines (37 loc) · 1003 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
export const extend = Object.assign;
export const isObject = (value) => {
return value !== null && typeof value === "object";
};
export const hasChange = (value, newValue) => {
return !Object.is(value, newValue);
};
export function hasOwn(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
export function isArray(value) {
return Array.isArray(value);
}
// foo-add => fooAdd
export const camelize = (str: string) => {
return str.replace(/-(\w)/g, (_, p: string) => {
return p ? p.toUpperCase() : "";
});
};
export const capitalize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};
// fooAdd => onFooAdd
export const handleEventName = (name: string) => {
return name ? "on" + capitalize(name) : "";
};
export function warn(...args) {
console.warn(...args);
}
export const EMPTY_OBJ = {};
export function def(obj, key, value) {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
value,
});
}