brackets-memory-db 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +8 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53,7 +53,6 @@ class InMemoryDatabase {
53
53
  id = this.data[table].length;
54
54
  if (!Array.isArray(values)) {
55
55
  try {
56
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
56
  // @ts-ignore
58
57
  this.data[table].push({ id, ...values });
59
58
  }
@@ -68,7 +67,6 @@ class InMemoryDatabase {
68
67
  }
69
68
  try {
70
69
  values.map((object) => {
71
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72
70
  // @ts-ignore
73
71
  this.data[table].push({ id: id++, ...object });
74
72
  });
@@ -90,20 +88,17 @@ class InMemoryDatabase {
90
88
  try {
91
89
  if (arg === undefined) {
92
90
  return new Promise((resolve) => {
93
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
94
91
  // @ts-ignore
95
92
  resolve(this.data[table].map(clone));
96
93
  });
97
94
  }
98
95
  if (typeof arg === 'number') {
99
96
  return new Promise((resolve) => {
100
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
101
97
  // @ts-ignore
102
98
  resolve(clone(this.data[table][arg]));
103
99
  });
104
100
  }
105
101
  return new Promise((resolve) => {
106
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
107
102
  // @ts-ignore
108
103
  resolve(this.data[table].filter(this.makeFilter(arg))).map(clone);
109
104
  });
@@ -124,7 +119,6 @@ class InMemoryDatabase {
124
119
  update(table, arg, value) {
125
120
  if (typeof arg === 'number') {
126
121
  try {
127
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
128
122
  // @ts-ignore
129
123
  this.data[table][arg] = value;
130
124
  return new Promise((resolve) => {
@@ -137,7 +131,6 @@ class InMemoryDatabase {
137
131
  });
138
132
  }
139
133
  }
140
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
141
134
  // @ts-ignore
142
135
  const values = this.data[table].filter(this.makeFilter(arg));
143
136
  if (!values) {
@@ -148,9 +141,14 @@ class InMemoryDatabase {
148
141
  values.forEach((v) => {
149
142
  const existing = this.data[table][v.id];
150
143
  for (const key in value) {
151
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
152
- // @ts-ignore
153
- Object.assign(existing[key], value[key]);
144
+ if (typeof value[key] === 'object') {
145
+ // @ts-ignore
146
+ Object.assign(existing[key], value[key]); // For opponent objects, this does a deep merge of level 2.
147
+ }
148
+ else {
149
+ // @ts-ignore
150
+ existing[key] = value[key]; // Otherwise, do a simple value assignment.
151
+ }
154
152
  }
155
153
  this.data[table][v.id] = existing;
156
154
  });
@@ -179,7 +177,6 @@ class InMemoryDatabase {
179
177
  }
180
178
  const predicate = this.makeFilter(filter);
181
179
  const negativeFilter = (value) => !predicate(value);
182
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
183
180
  // @ts-ignore
184
181
  this.data[table] = values.filter(negativeFilter);
185
182
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brackets-memory-db",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "An in-memory database for brackets-manager.js",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",