Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-lang-exception

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-lang-exception - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

30

dist/js-lang-exception.js

@@ -13,3 +13,3 @@ /*

*
* @version 1.0.0
* @version 1.0.1
*

@@ -46,5 +46,7 @@ * @author Richard King <richrdkng@gmail.com> [GitHub]{@link https://github.com/richrdkng}

*
* @property {string} raw
* @property {string} formatted
* @property {Array} args
* @property {string} raw - The source/raw string with the unfilled '{}'.
* This string is used to format the "formatted" string.
*
* @property {string} formatted - The formatted string filled with arguments.
* @property {Array} args - The arguments to fill the string with.
*/

@@ -57,4 +59,4 @@

* A custom message can be used for the Exception, with easy message formatting capabilities similar to Python's
* **'{}'.format()** function by using a string message containing '{}' and providing additional data to fill the
* string with.
* '{}'.format() function by using a string message containing '{}' and providing additional data
* to fill the string with.
*

@@ -68,6 +70,4 @@ * A custom ID and also additional, custom data can be set with the exception for further identification and usage.

* @param {string|Array|null} [message] - The custom message of the exception.
*
* If it is a string, no additional formatting will be applied to
* the custom message.
*
* If it is an array, the first element of the array will be used as the

@@ -77,3 +77,2 @@ * source message, that will be used for additional formatting.

* custom source message. To index custom arguments, use '{}' or '{#}'.
*
* To leave the message with the default value or in case of

@@ -83,3 +82,2 @@ * inheritance (extending the Exception), unchanged, set it to **null**.

* @param {int|null} [id] - A custom ID for the Exception.
*
* To leave the message with the default value or in case of inheritance

@@ -90,3 +88,2 @@ * (extending the Exception), unchanged, set it to **null**.

* it will be skipped and will not be stored.
*
* To leave the message with the default value or in case of inheritance

@@ -98,3 +95,2 @@ * (extending the Exception), unchanged, set it to **null**.

* thrown after instantiation.
*
* **This option is mostly used for unit testing and

@@ -148,2 +144,12 @@ * debugging purposes.**

* @example
* // custom message + custom data - ignoring custom ID by passing **null** as an argument for the ID
* throw new Exception('With a message.', null, {custom : 'data'});
*
* // custom ID + custom data - ignoring custom message by passing **null** as an argument for the message
* throw new Exception(null, 1984, {custom : 'data'});
*
* // custom data - ignoring both custom message and custom ID
* throw new Exception(null, null, {custom : 'data'});
*
* @example
* // subclassing - ES5

@@ -150,0 +156,0 @@ * function CustomException() {

2

dist/js-lang-exception.min.js

@@ -1,2 +0,2 @@

/*! js-lang-exception v1.0.0 | MIT License | (c) Richard King - richrdkng@gmail.com */
/*! js-lang-exception v1.0.1 | MIT License | (c) Richard King - richrdkng@gmail.com */
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.js_lang_exception=e()}(this,function(){"use strict";function t(t,e,r,o){var s={raw:"",formatted:"",args:[]},n=null,a=null,i=!0;"string"==typeof t?s.raw=t:"[object Array]"===Object.prototype.toString.call(t)&&(s.raw=t[0],s.args=t.splice(1)),"number"==typeof e&&e===e&&e>-(1/0)&&e<1/0&&(n=e),null!==r&&"undefined"!=typeof r&&(a=r),this._message=s,this._id=n,this._data=a,o===!1&&(i=!1),i&&this["throw"]()}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.hasMessage=function(){return""!==this._message.formatted},t.prototype.getMessage=function(){return this._message.formatted},t.prototype.hasID=function(){return null!==this._id},t.prototype.getID=function(){return this._id},t.prototype.hasData=function(){return null!==this._data},t.prototype.getData=function(){return this._data},t.prototype["throw"]=function(){var t=this._message;t.formatted=this.format(t.raw,t.args),this.hasMessage()&&(this.hasID()?this.stack=new Error(this.getMessage(),this.getID()).stack:this.stack=new Error(this.getMessage()).stack),this.stack=(new Error).stack},t.prototype.format=function(t,e){var r=/(\{)(\d*)(\})/g,o=0;return t.replace(r,function(t,r,s,n){return"{"===r&&"}"===n?""!==s?e[s]:e[o++]:t})},t});
{
"name": "js-lang-exception",
"version": "1.0.0",
"description": "An extendable, testable and intuitively usable error-handling Exception class built on the standard, built-in Error object.",
"version": "1.0.1",
"description": "An extendable, testable and intuitively usable error-handling Exception class built and based on the standard, built-in Error object.",
"main": "dist/js-lang-exception.js",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -13,3 +13,3 @@ # js-lang-exception

An extendable, testable and intuitively usable **error-handling Exception class** built on the standard,
An extendable, testable and intuitively usable **error-handling Exception class** built and based on the standard,
built-in Error object. Written in [UMD][umd-link].

@@ -102,2 +102,11 @@

});
// custom message + custom data - ignoring custom ID by passing **null** as an argument for the ID
throw new Exception('With a message.', null, {custom : 'data'});
// custom ID + custom data - ignoring custom message by passing **null** as an argument for the message
throw new Exception(null, 1984, {custom : 'data'});
// custom data - ignoring both custom message and custom ID
throw new Exception(null, null, {custom : 'data'});
```

@@ -104,0 +113,0 @@

@@ -13,3 +13,3 @@ /*

*
* @version 1.0.0
* @version 1.0.1
*

@@ -46,5 +46,7 @@ * @author Richard King <richrdkng@gmail.com> [GitHub]{@link https://github.com/richrdkng}

*
* @property {string} raw
* @property {string} formatted
* @property {Array} args
* @property {string} raw - The source/raw string with the unfilled '{}'.
* This string is used to format the "formatted" string.
*
* @property {string} formatted - The formatted string filled with arguments.
* @property {Array} args - The arguments to fill the string with.
*/

@@ -57,4 +59,4 @@

* A custom message can be used for the Exception, with easy message formatting capabilities similar to Python's
* **'{}'.format()** function by using a string message containing '{}' and providing additional data to fill the
* string with.
* '{}'.format() function by using a string message containing '{}' and providing additional data
* to fill the string with.
*

@@ -68,6 +70,4 @@ * A custom ID and also additional, custom data can be set with the exception for further identification and usage.

* @param {string|Array|null} [message] - The custom message of the exception.
*
* If it is a string, no additional formatting will be applied to
* the custom message.
*
* If it is an array, the first element of the array will be used as the

@@ -77,3 +77,2 @@ * source message, that will be used for additional formatting.

* custom source message. To index custom arguments, use '{}' or '{#}'.
*
* To leave the message with the default value or in case of

@@ -83,3 +82,2 @@ * inheritance (extending the Exception), unchanged, set it to **null**.

* @param {int|null} [id] - A custom ID for the Exception.
*
* To leave the message with the default value or in case of inheritance

@@ -90,3 +88,2 @@ * (extending the Exception), unchanged, set it to **null**.

* it will be skipped and will not be stored.
*
* To leave the message with the default value or in case of inheritance

@@ -98,3 +95,2 @@ * (extending the Exception), unchanged, set it to **null**.

* thrown after instantiation.
*
* **This option is mostly used for unit testing and

@@ -148,2 +144,12 @@ * debugging purposes.**

* @example
* // custom message + custom data - ignoring custom ID by passing **null** as an argument for the ID
* throw new Exception('With a message.', null, {custom : 'data'});
*
* // custom ID + custom data - ignoring custom message by passing **null** as an argument for the message
* throw new Exception(null, 1984, {custom : 'data'});
*
* // custom data - ignoring both custom message and custom ID
* throw new Exception(null, null, {custom : 'data'});
*
* @example
* // subclassing - ES5

@@ -150,0 +156,0 @@ * function CustomException() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc