aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack-chain/src/ChainedSet.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webpack-chain/src/ChainedSet.js')
-rw-r--r--node_modules/webpack-chain/src/ChainedSet.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/webpack-chain/src/ChainedSet.js b/node_modules/webpack-chain/src/ChainedSet.js
new file mode 100644
index 00000000..ea469daa
--- /dev/null
+++ b/node_modules/webpack-chain/src/ChainedSet.js
@@ -0,0 +1,55 @@
+const Chainable = require('./Chainable');
+
+module.exports = class extends Chainable {
+ constructor(parent) {
+ super(parent);
+ this.store = new Set();
+ }
+
+ add(value) {
+ this.store.add(value);
+ return this;
+ }
+
+ prepend(value) {
+ this.store = new Set([value, ...this.store]);
+ return this;
+ }
+
+ clear() {
+ this.store.clear();
+ return this;
+ }
+
+ delete(value) {
+ this.store.delete(value);
+ return this;
+ }
+
+ values() {
+ return [...this.store];
+ }
+
+ has(value) {
+ return this.store.has(value);
+ }
+
+ merge(arr) {
+ this.store = new Set([...this.store, ...arr]);
+ return this;
+ }
+
+ when(
+ condition,
+ whenTruthy = Function.prototype,
+ whenFalsy = Function.prototype
+ ) {
+ if (condition) {
+ whenTruthy(this);
+ } else {
+ whenFalsy(this);
+ }
+
+ return this;
+ }
+};