ts-custom-error
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -0,1 +1,8 @@ | ||
# [3.2.0](https://github.com/adriengibrat/ts-custom-error/compare/v3.1.1...v3.2.0) (2020-08-24) | ||
### Features | ||
* **name:** Allow to redefine error name property ([94efde0](https://github.com/adriengibrat/ts-custom-error/commit/94efde0a70b62eea191bc9ff204b43101f367da8)) | ||
## [3.1.1](https://github.com/adriengibrat/ts-custom-error/compare/v3.1.0...v3.1.1) (2019-07-03) | ||
@@ -2,0 +9,0 @@ |
@@ -0,0 +0,0 @@ export declare class CustomError extends Error { |
@@ -1,85 +0,104 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
function fixProto(target, prototype) { | ||
var setPrototypeOf = Object.setPrototypeOf; | ||
setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype; | ||
} | ||
function fixStack(target, fn) { | ||
if (fn === void 0) { | ||
fn = target.constructor; | ||
} | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
var captureStackTrace = Error.captureStackTrace; | ||
captureStackTrace && captureStackTrace(target, fn); | ||
} | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var __extends = undefined && undefined.__extends || function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function (d, b) { | ||
d.__proto__ = b; | ||
} || function (d, b) { | ||
for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } | ||
}; | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
}; | ||
}(); | ||
function fixProto(target, prototype) { | ||
var setPrototypeOf = Object.setPrototypeOf; | ||
setPrototypeOf ? setPrototypeOf(target, prototype) : (target.__proto__ = prototype); | ||
} | ||
var CustomError = function (_super) { | ||
__extends(CustomError, _super); | ||
function fixStack(target, fn) { | ||
if (fn === void 0) { | ||
fn = target.constructor; | ||
} | ||
var captureStackTrace = Error.captureStackTrace; | ||
captureStackTrace && captureStackTrace(target, fn); | ||
} | ||
function CustomError(message) { | ||
var _newTarget = this.constructor; | ||
var CustomError = (function (_super) { | ||
__extends(CustomError, _super); | ||
function CustomError(message) { | ||
var _newTarget = this.constructor; | ||
var _this = _super.call(this, message) || this; | ||
Object.defineProperty(_this, 'name', { | ||
value: _newTarget.name, | ||
enumerable: false | ||
}); | ||
fixProto(_this, _newTarget.prototype); | ||
fixStack(_this); | ||
return _this; | ||
} | ||
return CustomError; | ||
})(Error); | ||
var _this = _super.call(this, message) || this; | ||
Object.defineProperty(_this, 'name', { | ||
value: _newTarget.name, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
fixProto(_this, _newTarget.prototype); | ||
fixStack(_this); | ||
return _this; | ||
} | ||
return CustomError; | ||
}(Error); | ||
var __spreadArrays = undefined && undefined.__spreadArrays || function () { | ||
var arguments$1 = arguments; | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) { s += arguments$1[i].length; } | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) { for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) { r[k] = a[j]; } } | ||
return r; | ||
}; | ||
function customErrorFactory(fn, parent) { | ||
if (parent === void 0) { | ||
parent = Error; | ||
if (parent === void 0) { | ||
parent = Error; | ||
} | ||
function CustomError() { | ||
var arguments$1 = arguments; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments$1[_i]; | ||
} | ||
function CustomError() { | ||
var args = []; | ||
for (var _i = 0;_i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
if (!(this instanceof CustomError)) { return new (CustomError.bind.apply(CustomError, __spreadArrays([void 0], args)))(); } | ||
parent.apply(this, args); | ||
Object.defineProperty(this, 'name', { | ||
value: fn.name || parent.name, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
fn.apply(this, args); | ||
fixStack(this, CustomError); | ||
} | ||
return Object.defineProperties(CustomError, { | ||
prototype: { | ||
value: Object.create(parent.prototype, { | ||
constructor: { | ||
value: CustomError, | ||
writable: true, | ||
configurable: true | ||
} | ||
if (!(this instanceof CustomError)) | ||
return new (CustomError.bind.apply(CustomError, [void 0].concat(args)))(); | ||
parent.apply(this, args); | ||
fn.apply(this, args); | ||
this.name = fn.name || parent.name; | ||
fixStack(this, CustomError); | ||
}) | ||
} | ||
return Object.defineProperties(CustomError, { | ||
prototype: { | ||
value: Object.create(parent.prototype, { | ||
constructor: { | ||
value: CustomError, | ||
writable: true, | ||
configurable: true | ||
} | ||
}) | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -86,0 +105,0 @@ |
@@ -0,0 +0,0 @@ export declare class CustomError extends Error { |
@@ -1,109 +0,1 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.tsCustomError = {}))); | ||
}(this, (function (exports) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
function fixProto(target, prototype) { | ||
var setPrototypeOf = Object.setPrototypeOf; | ||
setPrototypeOf ? setPrototypeOf(target, prototype) : (target.__proto__ = prototype); | ||
} | ||
function fixStack(target, fn) { | ||
if (fn === void 0) { | ||
fn = target.constructor; | ||
} | ||
var captureStackTrace = Error.captureStackTrace; | ||
captureStackTrace && captureStackTrace(target, fn); | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInV0aWxzLnRzKG9yaWdpbmFsKSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLFNBQVMsU0FBUyxNQUFRLEVBQUEsV0FBVztJQUN4QyxHQUFBLENBQUksaUJBQWlCLE1BQUEsQ0FBTztJQUM1QixjQUFBLEdBQ00sY0FBQSxDQUFlLFFBQVEsY0FDdEIsTUFB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omError(message) { | ||
var _newTarget = this.constructor; | ||
var _this = _super.call(this, message) || this; | ||
Object.defineProperty(_this, 'name', { | ||
value: _newTarget.name, | ||
enumerable: false | ||
}); | ||
fixProto(_this, _newTarget.prototype); | ||
fixStack(_this); | ||
return _this; | ||
} | ||
return CustomError; | ||
})(Error); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImN1c3RvbS1lcnJvci50cyhvcmlnaW5hbCkiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsWUFBWSxhQUFhO0FBQ3pCLFFBQVMsVUFBVSxlQUFnQjtBQUNuQyxHQUFBLENBQUksZUFBZSxVQUFVLFFBQVE7SUFDakMsT0FBQSxDQUFRLFNBQVIsQ0FBa0IsYUFBYTtJQUMvQixTQUFTLFlBQVksU0FBUztRQUMxQixHQUFBLENBQUksYUFBYSxJQUFBLENBQUs7UUFDdEIsR0FBQSxDQUFJLFFBQVEsTUFBQSxDQUFPLElBQVAsQ0FBWSxNQUFNLFFBQWxCLENBQUEsRUFBQSxDQUE4QjtRQUMxQyxNQUFBLENBQU8sY0FBUCxDQUFzQixPQUFPLFFBQVE7WUFDakMsT0FBTyxVQUFBLENBQVcsSUFEZSxDQUFBO1lBRWpDLFlBQVk7O1FBRWhCLFFBQUEsQ0FBUyxPQUFPLFVBQUEsQ0FBVztRQUMzQixRQUFBLENBQVM7UUFDVCxPQUFPO0lBQ2Y7O0lBQ0ksT0FBTztBQUNYLEVBZG1CLENBY2pCO0FBQ0YsT0FBQSxDQUFTO0FBakJUIiwiZmlsZSI6ImN1c3RvbS1lcnJvci50cyhvcmlnaW5hbCkiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgKiBhcyB0c2xpYl8xIGZyb20gXCJ0c2xpYlwiO1xyXG5pbXBvcnQgeyBmaXhQcm90bywgZml4U3RhY2sgfSBmcm9tICcuL3V0aWxzJztcclxudmFyIEN1c3RvbUVycm9yID0gKGZ1bmN0aW9uIChfc3VwZXIpIHtcclxuICAgIHRzbGliXzEuX19leHRlbmRzKEN1c3RvbUVycm9yLCBfc3VwZXIpO1xyXG4gICAgZnVuY3Rpb24gQ3VzdG9tRXJyb3IobWVzc2FnZSkge1xyXG4gICAgICAgIHZhciBfbmV3VGFyZ2V0ID0gdGhpcy5jb25zdHJ1Y3RvcjtcclxuICAgICAgICB2YXIgX3RoaXMgPSBfc3VwZXIuY2FsbCh0aGlzLCBtZXNzYWdlKSB8fCB0aGlzO1xyXG4gICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShfdGhpcywgJ25hbWUnLCB7XHJcbiAgICAgICAgICAgIHZhbHVlOiBfbmV3VGFyZ2V0Lm5hbWUsXHJcbiAgICAgICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIGZpeFByb3RvKF90aGlzLCBfbmV3VGFyZ2V0LnByb3RvdHlwZSk7XHJcbiAgICAgICAgZml4U3RhY2soX3RoaXMpO1xyXG4gICAgICAgIHJldHVybiBfdGhpcztcclxuICAgIH1cclxuICAgIHJldHVybiBDdXN0b21FcnJvcjtcclxufShFcnJvcikpO1xyXG5leHBvcnQgeyBDdXN0b21FcnJvciB9O1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1jdXN0b20tZXJyb3IuanMubWFwIl19 | ||
function customErrorFactory(fn, parent) { | ||
if (parent === void 0) { | ||
parent = Error; | ||
} | ||
function CustomError() { | ||
var args = []; | ||
for (var _i = 0;_i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (!(this instanceof CustomError)) | ||
return new (CustomError.bind.apply(CustomError, [void 0].concat(args)))(); | ||
parent.apply(this, args); | ||
fn.apply(this, args); | ||
this.name = fn.name || parent.name; | ||
fixStack(this, CustomError); | ||
} | ||
return Object.defineProperties(CustomError, { | ||
prototype: { | ||
value: Object.create(parent.prototype, { | ||
constructor: { | ||
value: CustomError, | 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gICBwcm90b3R5cGU6IHtcclxuICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUocGFyZW50LnByb3RvdHlwZSwge1xyXG4gICAgICAgICAgICAgICAgY29uc3RydWN0b3I6IHtcclxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogQ3VzdG9tRXJyb3IsXHJcbiAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsXHJcbiAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxyXG4gICAgICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgfSksXHJcbiAgICAgICAgfSxcclxuICAgIH0pO1xyXG59XHJcbi8vIyBzb3VyY2VNYXBwaW5nVVJMPWZhY3RvcnkuanMubWFwIl19 | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzKG9yaWdpbmFsKSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGdCQUFBO0FBQ2QsY0FBYyxXQUFBO0FBRGQiLCJmaWxlIjoiaW5kZXgudHMob3JpZ2luYWwpIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9jdXN0b20tZXJyb3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2ZhY3RvcnknO1xyXG4vLyMgc291cmNlTWFwcGluZ1VSTD1pbmRleC5qcy5tYXAiXX0= | ||
exports.CustomError = CustomError; | ||
exports.customErrorFactory = customErrorFactory; | ||
}))); | ||
//# sourceMappingURL=custom-error.umd.js.map | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global.tsCustomError={})}(this,function(exports){function fixStack(target,fn){void 0===fn&&(fn=target.constructor);var captureStackTrace=Error.captureStackTrace;captureStackTrace&&captureStackTrace(target,fn)}var extendStatics,__extends=(extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)},function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}),CustomError=function(_super){function CustomError(message){var target,prototype,setPrototypeOf,_newTarget=this.constructor,_this=_super.call(this,message)||this;return Object.defineProperty(_this,"name",{value:_newTarget.name,enumerable:!1,configurable:!0}),target=_this,prototype=_newTarget.prototype,(setPrototypeOf=Object.setPrototypeOf)?setPrototypeOf(target,prototype):target.__proto__=prototype,fixStack(_this),_this}return __extends(CustomError,_super),CustomError}(Error),__spreadArrays=function(){for(var arguments$1=arguments,s=0,i=0,il=arguments.length;i<il;i++)s+=arguments$1[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r};exports.CustomError=CustomError,exports.customErrorFactory=function(fn,parent){function CustomError(){for(var arguments$1=arguments,args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments$1[_i];if(!(this instanceof CustomError))return new(CustomError.bind.apply(CustomError,__spreadArrays([void 0],args)));parent.apply(this,args),Object.defineProperty(this,"name",{value:fn.name||parent.name,enumerable:!1,configurable:!0}),fn.apply(this,args),fixStack(this,CustomError)}return void 0===parent&&(parent=Error),Object.defineProperties(CustomError,{prototype:{value:Object.create(parent.prototype,{constructor:{value:CustomError,writable:!0,configurable:!0}})}})}}); |
{ | ||
"name": "ts-custom-error", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Extend native Error to create custom errors", | ||
@@ -16,6 +16,4 @@ "repository": "github:adriengibrat/ts-custom-error", | ||
"module": "dist/custom-error.mjs", | ||
"browser": "dist/custom-error.umd.js", | ||
"browser:min": "dist/custom-error.umd.min.js", | ||
"unpkg": "dist/custom-error.umd.js", | ||
"types": "dist/custom-error.d.ts", | ||
"source": "src/index.ts", | ||
"engines": { | ||
@@ -27,4 +25,7 @@ "node": ">=8.0.0" | ||
"prebuild": "rm --recursive --force dist", | ||
"build": "microbundle --compress false", | ||
"postbuild": "uglifyjs --compress --output $npm_package_browser_min -- $npm_package_browser && cat dist/factory.d.ts >> dist/custom-error.d.ts && rm --recursive --force dist/example dist/factory.d.ts dist/utils.d.ts dist/index.d.ts dist/**spec.* && cat dist/custom-error.d.ts > dist/custom-error.umd.d.ts && cat dist/custom-error.d.ts > dist/custom-error.umd.min.d.ts", | ||
"build": "tsc --build tsconfig.json && microbundle build --no-compress --entry dist/src/index.js", | ||
"postbuild": "npm run minify:umd && npm run types:concat && npm run dist:cleanup", | ||
"minify:umd": "uglifyjs --compress --output $npm_package_unpkg -- $npm_package_unpkg", | ||
"types:concat": "cat dist/src/factory.d.ts >> dist/src/custom-error.d.ts && cat dist/src/custom-error.d.ts > dist/custom-error.d.ts && cat dist/custom-error.d.ts > dist/custom-error.umd.d.ts", | ||
"dist:cleanup": "rm --recursive --force dist/src", | ||
"test": "jest", | ||
@@ -36,22 +37,25 @@ "coverage": "jest --coverage", | ||
"devDependencies": { | ||
"@semantic-release/changelog": "^3.0.1", | ||
"@semantic-release/git": "^7.0.6", | ||
"@types/jest": "^24.0.0", | ||
"@types/node": "^12.0.0", | ||
"commitizen": "^3.0.5", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"jest": "^23.6.0", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@types/jest": "^25.2.3", | ||
"@types/node": "^14.0.4", | ||
"commitizen": "^4.1.2", | ||
"cz-conventional-changelog": "^3.2.0", | ||
"jest": "^26.0.1", | ||
"jest-tap-reporter": "^1.9.0", | ||
"lint-staged": "^8.1.0", | ||
"microbundle": "^0.6.0", | ||
"prettier": "^1.15.3", | ||
"semantic-release": "^15.13.1", | ||
"tap-notify": "^1.0.0", | ||
"lint-staged": "^10.2.4", | ||
"microbundle": "^0.11.0", | ||
"prettier": "^2.0.5", | ||
"semantic-release": "^17.0.7", | ||
"travis-deploy-once": "^5.0.11", | ||
"ts-jest": "^24.0.0", | ||
"tslint": "^5.12.0", | ||
"tslint-config-prettier": "^1.17.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"typescript": "^3.2.2" | ||
"ts-jest": "^26.0.0", | ||
"tslint": "^6.1.2", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-config-standard": "^9.0.0", | ||
"typescript": "^3.9.3", | ||
"uglifyjs": "^2.4.11" | ||
}, | ||
"mangle": { | ||
"regex": "^(?!CustomError\b).*" | ||
}, | ||
"config": { | ||
@@ -107,4 +111,28 @@ "commitizen": { | ||
{ | ||
"path": "dist/custom-error.umd.min.js", | ||
"label": "Minified UMD" | ||
"path": "dist/custom-error.d.ts", | ||
"label": "Typescript typings" | ||
}, | ||
{ | ||
"path": "dist/custom-error.js", | ||
"label": "Common JS" | ||
}, | ||
{ | ||
"path": "dist/custom-error.js.map", | ||
"label": "Common JS - sourcemap" | ||
}, | ||
{ | ||
"path": "dist/custom-error.mjs", | ||
"label": "ES module" | ||
}, | ||
{ | ||
"path": "dist/custom-error.mjs.map", | ||
"label": "ES module - sourcemap" | ||
}, | ||
{ | ||
"path": "dist/custom-error.umd.js", | ||
"label": "UMD (minified, CDN ready)" | ||
}, | ||
{ | ||
"path": "dist/custom-error.umd.js.map", | ||
"label": "UMD - sourcemap" | ||
} | ||
@@ -111,0 +139,0 @@ ] |
@@ -10,8 +10,9 @@ # Typescript Custom Error | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/eb4eb956bc028c49f7aa/test_coverage)](https://codeclimate.com/github/adriengibrat/ts-custom-error/test_coverage) | ||
[![Greenkeeper enabled](https://badges.greenkeeper.io/adriengibrat/ts-custom-error.svg)](https://greenkeeper.io) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![Install size](https://badgen.net/packagephobia/install/ts-custom-error)](https://packagephobia.now.sh/result?p=ts-custom-error) | ||
[![Bundle size](https://badgen.net/bundlephobia/minzip/ts-custom-error?color=green)](https://bundlephobia.com/result?p=ts-custom-error) | ||
## Extend native Error to create custom errors | ||
`ts-custom-error` is a tiny (~500 bytes of minified & gzipped Javascript) package providing a `CustomError` class and a `customErrorFactory` function to easyly extends native Error in node and evergreen browsers. | ||
`ts-custom-error` is a tiny (~500 bytes of minified & gzipped Javascript) package providing a `CustomError` class and a `customErrorFactory` function to easily extends native Error in node and evergreen browsers. | ||
@@ -105,3 +106,3 @@ It's written in Typescript and try to offer the best development and debug experiences: bundled in Javascript with Typescript definition files, map files and bundled js files for various environments: transpiled to es5 with commonjs, module and umd exports, the umd bundle is also available minified for easy import in browsers. | ||
// Set name explicitly as minification can mangle class names | ||
this.name = 'MyError' | ||
Object.defineProperty(this, 'name', { value: 'MyError' }) | ||
} | ||
@@ -116,3 +117,3 @@ } | ||
// Set name explicitly as minification can remove function expression names | ||
this.name = 'MyError' | ||
Object.defineProperty(this, 'name', { value: 'MyError' }) | ||
}) | ||
@@ -148,5 +149,5 @@ ``` | ||
- automatic code formating with [prettier](https://github.com/prettier/prettier) | ||
- code quality analysis by [codeclimate](https://codeclimate.com/github/adriengibrat/ts-custom-error) & [bithound](https://www.bithound.io/github/adriengibrat/ts-custom-error) | ||
- code quality analysis by [codeclimate](https://codeclimate.com/github/adriengibrat/ts-custom-error)~~, [bithound](https://www.bithound.io/github/adriengibrat/ts-custom-error)~~ & [bettercodehub](https://bettercodehub.com/results/adriengibrat/ts-custom-error) | ||
- automated continuous integration on [travis](https://travis-ci.org/adriengibrat/ts-custom-error) | ||
- automated semantic versioning with [changelog](CHANGELOG.md) generation and release depoyment on [npm](https://www.npmjs.com/package/ts-custom-error) and [github](https://github.com/adriengibrat/ts-custom-error/releases) thanks to [semantic-release](https://github.com/semantic-release/semantic-release) | ||
- automated semantic versioning with [changelog](CHANGELOG.md) generation and release deployment on [npm](https://www.npmjs.com/package/ts-custom-error) and [github](https://github.com/adriengibrat/ts-custom-error/releases) thanks to [semantic-release](https://github.com/semantic-release/semantic-release) | ||
@@ -153,0 +154,0 @@ ## Licence |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
165
42605
12
209
1