1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.toString = exports.bindAll = void 0;
|
4 | exports.bindAll = (object) => {
|
5 | const protoKeys = Object.getOwnPropertyNames(Object.getPrototypeOf(object));
|
6 | protoKeys.forEach(key => {
|
7 | const maybeFn = object[key];
|
8 | if (typeof maybeFn === 'function' && key !== 'constructor') {
|
9 | object[key] = maybeFn.bind(object);
|
10 | }
|
11 | });
|
12 | return object;
|
13 | };
|
14 | function toString(value, deep = true) {
|
15 | if (Array.isArray(value) && value.length && deep) {
|
16 | return toString(value[0], false);
|
17 | }
|
18 | else if (value instanceof Date) {
|
19 | return value.toISOString();
|
20 | }
|
21 | else if (value && typeof value === 'object' && value.toString) {
|
22 | if (typeof value.toString !== 'function') {
|
23 | return Object.getPrototypeOf(value).toString.call(value);
|
24 | }
|
25 | return value.toString();
|
26 | }
|
27 | else if (value == null || (isNaN(value) && !value.length)) {
|
28 | return '';
|
29 | }
|
30 | return String(value);
|
31 | }
|
32 | exports.toString = toString;
|