diff options
author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 |
commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/parse5/lib/utils | |
parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/parse5/lib/utils')
-rw-r--r-- | node_modules/parse5/lib/utils/merge-options.js | 13 | ||||
-rw-r--r-- | node_modules/parse5/lib/utils/mixin.js | 39 |
2 files changed, 52 insertions, 0 deletions
diff --git a/node_modules/parse5/lib/utils/merge-options.js b/node_modules/parse5/lib/utils/merge-options.js new file mode 100644 index 0000000..0bbe893 --- /dev/null +++ b/node_modules/parse5/lib/utils/merge-options.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = function mergeOptions(defaults, options) { + options = options || Object.create(null); + + return [defaults, options].reduce((merged, optObj) => { + Object.keys(optObj).forEach(key => { + merged[key] = optObj[key]; + }); + + return merged; + }, Object.create(null)); +}; diff --git a/node_modules/parse5/lib/utils/mixin.js b/node_modules/parse5/lib/utils/mixin.js new file mode 100644 index 0000000..26465c4 --- /dev/null +++ b/node_modules/parse5/lib/utils/mixin.js @@ -0,0 +1,39 @@ +'use strict'; + +class Mixin { + constructor(host) { + const originalMethods = {}; + const overriddenMethods = this._getOverriddenMethods(this, originalMethods); + + for (const key of Object.keys(overriddenMethods)) { + if (typeof overriddenMethods[key] === 'function') { + originalMethods[key] = host[key]; + host[key] = overriddenMethods[key]; + } + } + } + + _getOverriddenMethods() { + throw new Error('Not implemented'); + } +} + +Mixin.install = function(host, Ctor, opts) { + if (!host.__mixins) { + host.__mixins = []; + } + + for (let i = 0; i < host.__mixins.length; i++) { + if (host.__mixins[i].constructor === Ctor) { + return host.__mixins[i]; + } + } + + const mixin = new Ctor(host, opts); + + host.__mixins.push(mixin); + + return mixin; +}; + +module.exports = Mixin; |