This commit is contained in:
45
node_modules/unherit/index.js
generated
vendored
Normal file
45
node_modules/unherit/index.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict'
|
||||
|
||||
var xtend = require('xtend')
|
||||
var inherits = require('inherits')
|
||||
|
||||
module.exports = unherit
|
||||
|
||||
// Create a custom constructor which can be modified without affecting the
|
||||
// original class.
|
||||
function unherit(Super) {
|
||||
var result
|
||||
var key
|
||||
var value
|
||||
|
||||
inherits(Of, Super)
|
||||
inherits(From, Of)
|
||||
|
||||
// Clone values.
|
||||
result = Of.prototype
|
||||
|
||||
for (key in result) {
|
||||
value = result[key]
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
result[key] = 'concat' in value ? value.concat() : xtend(value)
|
||||
}
|
||||
}
|
||||
|
||||
return Of
|
||||
|
||||
// Constructor accepting a single argument, which itself is an `arguments`
|
||||
// object.
|
||||
function From(parameters) {
|
||||
return Super.apply(this, parameters)
|
||||
}
|
||||
|
||||
// Constructor accepting variadic arguments.
|
||||
function Of() {
|
||||
if (!(this instanceof Of)) {
|
||||
return new From(arguments)
|
||||
}
|
||||
|
||||
return Super.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
21
node_modules/unherit/license
generated
vendored
Normal file
21
node_modules/unherit/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
72
node_modules/unherit/package.json
generated
vendored
Normal file
72
node_modules/unherit/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "unherit",
|
||||
"version": "1.1.3",
|
||||
"description": "Clone a constructor without affecting the super-class",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"clone",
|
||||
"super",
|
||||
"class",
|
||||
"constructor"
|
||||
],
|
||||
"repository": "wooorm/unherit",
|
||||
"bugs": "https://github.com/wooorm/unherit/issues",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark-cli": "^7.0.0",
|
||||
"remark-preset-wooorm": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"build-bundle": "browserify . -s unherit -o unherit.js",
|
||||
"build-mangle": "browserify . -s unherit -p tinyify -o unherit.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"rules": {
|
||||
"unicorn/prefer-reflect-apply": "off",
|
||||
"guard-for-in": "off"
|
||||
},
|
||||
"ignores": [
|
||||
"unherit.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
79
node_modules/unherit/readme.md
generated
vendored
Normal file
79
node_modules/unherit/readme.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
# unherit
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
Create a custom constructor which can be modified without affecting the original
|
||||
class.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unherit
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var unherit = require('unherit')
|
||||
|
||||
// Create a private class which acts just like `EventEmitter`.
|
||||
var Emitter = unherit(EventEmitter)
|
||||
|
||||
Emitter.prototype.defaultMaxListeners = 0
|
||||
// Now, all instances of `Emitter` have no maximum listeners, without affecting
|
||||
// other `EventEmitter`s.
|
||||
|
||||
new Emitter().defaultMaxListeners === 0 // => true
|
||||
new EventEmitter().defaultMaxListeners === undefined // => true
|
||||
new Emitter() instanceof EventEmitter // => true
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `unherit(Super)`
|
||||
|
||||
Create a custom constructor which can be modified without affecting the original
|
||||
class.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `Super` (`Function`) — Super-class
|
||||
|
||||
###### Returns
|
||||
|
||||
`Function` — Constructor acting like `Super`, which can be modified without
|
||||
affecting the original class.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/wooorm/unherit.svg
|
||||
|
||||
[build]: https://travis-ci.org/wooorm/unherit
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/unherit.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/wooorm/unherit
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unherit.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unherit
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unherit.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unherit
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
Reference in New Issue
Block a user