cloudfunctions/ClearingRedundantFolders/node_modules/make-error/README.md

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

# make-error

[![Package Version](https://badgen.net/npm/v/make-error)](https://npmjs.org/package/make-error) [![Build Status](https://travis-ci.org/JsCommunity/make-error.png?branch=master)](https://travis-ci.org/JsCommunity/make-error) [![PackagePhobia](https://badgen.net/packagephobia/install/make-error)](https://packagephobia.now.sh/result?p=make-error) [![Latest Commit](https://badgen.net/github/last-commit/JsCommunity/make-error)](https://github.com/JsCommunity/make-error/commits/master)

> Make your own error types!

## Features

- Compatible Node & browsers
- `instanceof` support
- `error.name` & `error.stack` support
- compatible with [CSP](https://en.wikipedia.org/wiki/Content_Security_Policy) (i.e. no `eval()`)

## Installation

### Node & [Browserify](http://browserify.org/)/[Webpack](https://webpack.js.org/)

Installation of the [npm package](https://npmjs.org/package/make-error):

```
> npm install --save make-error
```

Then require the package:

```javascript
var makeError = require("make-error");
```

### Browser

You can directly use the build provided at [unpkg.com](https://unpkg.com):

```html
<script src="https://unpkg.com/make-error@1/dist/make-error.js"></script>
```

## Usage

### Basic named error

```javascript
var CustomError = makeError("CustomError");

// Parameters are forwarded to the super class (here Error).
throw new CustomError("a message");
```

### Advanced error class

```javascript
function CustomError(customValue) {
  CustomError.super.call(this, "custom error message");

  this.customValue = customValue;
}
makeError(CustomError);

// Feel free to extend the prototype.
CustomError.prototype.myMethod = function CustomError$myMethod() {
后面还有 52 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。