1 | export function hasKeys(o: {}) {
|
2 | for (const k in o) {
|
3 | if (o.hasOwnProperty(k)) {
|
4 | return true;
|
5 | }
|
6 | }
|
7 | return false;
|
8 | }
|
9 |
|
10 | export const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export function stripQuotation(str: string) {
|
17 | return str.replace(/^['"](.*?)['"]$/g, '$1');
|
18 | }
|
19 |
|
20 | export function filename2varname(filename: string) {
|
21 | return string2varname(filename.replace(/(?=.*)\.\w+$/, '').replace(/\.st$/, ''));
|
22 | }
|
23 |
|
24 | export function string2varname(str: string) {
|
25 | return str.replace(/[^0-9a-zA-Z_]/gm, '').replace(/^[^a-zA-Z_]+/gm, '');
|
26 | }
|
27 |
|
28 | const deprecatedCache: { [id: string]: boolean } = {};
|
29 | export function deprecated(staticMessage: string) {
|
30 | if (!deprecatedCache[staticMessage]) {
|
31 | deprecatedCache[staticMessage] = true;
|
32 | try {
|
33 | console.warn('DEPRECATED: ' + staticMessage);
|
34 | } catch {
|
35 |
|
36 | }
|
37 | }
|
38 | }
|