UNPKG

@bithomp/xrpl-api

Version:

A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger

20 lines (19 loc) 672 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getConstructorName = void 0; function getConstructorName(object) { if (object.constructor.name) { return object.constructor.name; } const constructorString = object.constructor.toString(); const functionConstructor = constructorString.match(/^function\s+([^(]*)/); const classConstructor = constructorString.match(/^class\s([^\s]*)/); if (functionConstructor) { return functionConstructor[1]; } else if (classConstructor) { return classConstructor[1]; } return undefined; } exports.getConstructorName = getConstructorName;