🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
29
node_modules/unherit/index.js
generated
vendored
Normal file
29
node_modules/unherit/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Create a subclass that can be modified without affecting the super class.
|
||||
*
|
||||
* @template {{prototype: object, new (...args: any[]): any}} Class
|
||||
* @param {Class} Super
|
||||
* @return {Class}
|
||||
*/
|
||||
export function unherit(Super) {
|
||||
const Of = class extends Super {}
|
||||
|
||||
// Clone values.
|
||||
const proto = Of.prototype
|
||||
/** @type {string} */
|
||||
let key
|
||||
|
||||
// We specifically want to get *all* fields, not just own fields.
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (key in proto) {
|
||||
/** @type {unknown} */
|
||||
const value = proto[key]
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
// @ts-expect-error: shallow clone arrays or other values.
|
||||
proto[key] = 'concat' in value ? value.concat() : Object.assign({}, value)
|
||||
}
|
||||
}
|
||||
|
||||
return Of
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue