1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.request = exports.toArray = exports.stringify = exports.clone = exports.values = exports.deprecate = exports.info = exports.error = exports.warn = exports.debug = void 0;
|
19 | const Debug = require("debug");
|
20 | const https = require("https");
|
21 | const name = 'actions-on-google';
|
22 |
|
23 | exports.debug = Debug(`${name}:debug`);
|
24 |
|
25 | exports.warn = Debug(`${name}:warn`);
|
26 |
|
27 |
|
28 | exports.error = console.error.bind(console);
|
29 |
|
30 |
|
31 | exports.info = console.log.bind(console);
|
32 | exports.warn.log = exports.error;
|
33 | exports.debug.log = exports.info;
|
34 |
|
35 | const deprecate = (feature, alternative) => exports.info(`${feature} is *DEPRECATED*: ${alternative}`);
|
36 | exports.deprecate = deprecate;
|
37 |
|
38 | const values = (o) => Object.keys(o).map(k => o[k]);
|
39 | exports.values = values;
|
40 |
|
41 | const clone = (o) => JSON.parse(JSON.stringify(o));
|
42 | exports.clone = clone;
|
43 |
|
44 |
|
45 | const stringify = (root, ...exclude) => {
|
46 | const excluded = new Set(exclude);
|
47 | const filtered = Object.keys(root).reduce((o, k) => {
|
48 | if (excluded.has(k)) {
|
49 | o[k] = '[Excluded]';
|
50 | return o;
|
51 | }
|
52 | const value = root[k];
|
53 | try {
|
54 | JSON.stringify(value);
|
55 | o[k] = value;
|
56 | return o;
|
57 | }
|
58 | catch (e) {
|
59 | const { message = '' } = e;
|
60 | o[k] = message.includes('Converting circular structure to JSON')
|
61 | ? '[Circular]'
|
62 | : `[Stringify Error] ${e}`;
|
63 | return o;
|
64 | }
|
65 | }, {});
|
66 | return JSON.stringify(filtered, null, 2);
|
67 | };
|
68 | exports.stringify = stringify;
|
69 |
|
70 | const toArray = (a) => (Array.isArray(a) ? a : [a]);
|
71 | exports.toArray = toArray;
|
72 |
|
73 |
|
74 | exports.request = https.request.bind(https);
|
75 |
|
\ | No newline at end of file |