Skip to content

Instantly share code, notes, and snippets.

@SamVerschueren
Created November 23, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamVerschueren/233d48892f6ba88be4a8768dc4fc5886 to your computer and use it in GitHub Desktop.
Save SamVerschueren/233d48892f6ba88be4a8768dc4fc5886 to your computer and use it in GitHub Desktop.
Mangling Name
class FooError extends Error {
constructor(message) {
super(message);
}
}
console.log(FooError.name);
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var FooError = function (_Error) {
_inherits(FooError, _Error);
function FooError(message) {
_classCallCheck(this, FooError);
return _possibleConstructorReturn(this, (FooError.__proto__ || Object.getPrototypeOf(FooError)).call(this, message));
}
return FooError;
} (Error);
console.log(FooError.name);
"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var n=function(n){function r(o){return t(this,r),e(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,o))}return o(r,n),r}(Error);console.log(n.name);
@SamVerschueren
Copy link
Author

If you run node output.js, it will print r as name of the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment