md-spreadsheet-parser 1.1.9 → 1.1.11

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.
package/dist/index.js CHANGED
@@ -161,37 +161,43 @@ export class Table {
161
161
  updateCell(rowIdx, colIdx, value) {
162
162
  const dto = this.toDTO();
163
163
  const res = _tableUpdateCell(dto, rowIdx, colIdx, value);
164
- Object.assign(this, res);
164
+ const hydrated = new Table(res);
165
+ Object.assign(this, hydrated);
165
166
  return this;
166
167
  }
167
168
  deleteRow(rowIdx) {
168
169
  const dto = this.toDTO();
169
170
  const res = _tableDeleteRow(dto, rowIdx);
170
- Object.assign(this, res);
171
+ const hydrated = new Table(res);
172
+ Object.assign(this, hydrated);
171
173
  return this;
172
174
  }
173
175
  deleteColumn(colIdx) {
174
176
  const dto = this.toDTO();
175
177
  const res = _tableDeleteColumn(dto, colIdx);
176
- Object.assign(this, res);
178
+ const hydrated = new Table(res);
179
+ Object.assign(this, hydrated);
177
180
  return this;
178
181
  }
179
182
  clearColumnData(colIdx) {
180
183
  const dto = this.toDTO();
181
184
  const res = _tableClearColumnData(dto, colIdx);
182
- Object.assign(this, res);
185
+ const hydrated = new Table(res);
186
+ Object.assign(this, hydrated);
183
187
  return this;
184
188
  }
185
189
  insertRow(rowIdx) {
186
190
  const dto = this.toDTO();
187
191
  const res = _tableInsertRow(dto, rowIdx);
188
- Object.assign(this, res);
192
+ const hydrated = new Table(res);
193
+ Object.assign(this, hydrated);
189
194
  return this;
190
195
  }
191
196
  insertColumn(colIdx) {
192
197
  const dto = this.toDTO();
193
198
  const res = _tableInsertColumn(dto, colIdx);
194
- Object.assign(this, res);
199
+ const hydrated = new Table(res);
200
+ Object.assign(this, hydrated);
195
201
  return this;
196
202
  }
197
203
  }
@@ -199,7 +205,7 @@ export class Sheet {
199
205
  constructor(data) {
200
206
  if (data) {
201
207
  this.name = data.name;
202
- this.tables = data.tables;
208
+ this.tables = (data.tables || []).map((x) => x instanceof Table ? x : new Table(x));
203
209
  this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
204
210
  }
205
211
  }
@@ -236,7 +242,7 @@ export class Sheet {
236
242
  export class Workbook {
237
243
  constructor(data) {
238
244
  if (data) {
239
- this.sheets = data.sheets;
245
+ this.sheets = (data.sheets || []).map((x) => x instanceof Sheet ? x : new Sheet(x));
240
246
  this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
241
247
  }
242
248
  }
@@ -271,13 +277,15 @@ export class Workbook {
271
277
  addSheet(name) {
272
278
  const dto = this.toDTO();
273
279
  const res = _workbookAddSheet(dto, name);
274
- Object.assign(this, res);
280
+ const hydrated = new Workbook(res);
281
+ Object.assign(this, hydrated);
275
282
  return this;
276
283
  }
277
284
  deleteSheet(index) {
278
285
  const dto = this.toDTO();
279
286
  const res = _workbookDeleteSheet(dto, index);
280
- Object.assign(this, res);
287
+ const hydrated = new Workbook(res);
288
+ Object.assign(this, hydrated);
281
289
  return this;
282
290
  }
283
291
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-spreadsheet-parser",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "A robust Markdown table parser and manipulator, powered by Python and WebAssembly.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
package/src/index.ts CHANGED
@@ -199,42 +199,48 @@ export class Table {
199
199
  updateCell(rowIdx: any, colIdx: any, value: any): any {
200
200
  const dto = this.toDTO();
201
201
  const res = _tableUpdateCell(dto, rowIdx, colIdx, value);
202
- Object.assign(this, res);
202
+ const hydrated = new Table(res);
203
+ Object.assign(this, hydrated);
203
204
  return this;
204
205
  }
205
206
 
206
207
  deleteRow(rowIdx: any): any {
207
208
  const dto = this.toDTO();
208
209
  const res = _tableDeleteRow(dto, rowIdx);
209
- Object.assign(this, res);
210
+ const hydrated = new Table(res);
211
+ Object.assign(this, hydrated);
210
212
  return this;
211
213
  }
212
214
 
213
215
  deleteColumn(colIdx: any): any {
214
216
  const dto = this.toDTO();
215
217
  const res = _tableDeleteColumn(dto, colIdx);
216
- Object.assign(this, res);
218
+ const hydrated = new Table(res);
219
+ Object.assign(this, hydrated);
217
220
  return this;
218
221
  }
219
222
 
220
223
  clearColumnData(colIdx: any): any {
221
224
  const dto = this.toDTO();
222
225
  const res = _tableClearColumnData(dto, colIdx);
223
- Object.assign(this, res);
226
+ const hydrated = new Table(res);
227
+ Object.assign(this, hydrated);
224
228
  return this;
225
229
  }
226
230
 
227
231
  insertRow(rowIdx: any): any {
228
232
  const dto = this.toDTO();
229
233
  const res = _tableInsertRow(dto, rowIdx);
230
- Object.assign(this, res);
234
+ const hydrated = new Table(res);
235
+ Object.assign(this, hydrated);
231
236
  return this;
232
237
  }
233
238
 
234
239
  insertColumn(colIdx: any): any {
235
240
  const dto = this.toDTO();
236
241
  const res = _tableInsertColumn(dto, colIdx);
237
- Object.assign(this, res);
242
+ const hydrated = new Table(res);
243
+ Object.assign(this, hydrated);
238
244
  return this;
239
245
  }
240
246
  }
@@ -247,7 +253,7 @@ export class Sheet {
247
253
  constructor(data?: Partial<Sheet>) {
248
254
  if (data) {
249
255
  this.name = data.name;
250
- this.tables = data.tables;
256
+ this.tables = (data.tables || []).map((x: any) => x instanceof Table ? x : new Table(x));
251
257
  this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
252
258
  }
253
259
  }
@@ -290,7 +296,7 @@ export class Workbook {
290
296
 
291
297
  constructor(data?: Partial<Workbook>) {
292
298
  if (data) {
293
- this.sheets = data.sheets;
299
+ this.sheets = (data.sheets || []).map((x: any) => x instanceof Sheet ? x : new Sheet(x));
294
300
  this.metadata = (typeof data.metadata === 'string') ? JSON.parse(data.metadata) : data.metadata;
295
301
  }
296
302
  }
@@ -328,14 +334,16 @@ export class Workbook {
328
334
  addSheet(name: any): any {
329
335
  const dto = this.toDTO();
330
336
  const res = _workbookAddSheet(dto, name);
331
- Object.assign(this, res);
337
+ const hydrated = new Workbook(res);
338
+ Object.assign(this, hydrated);
332
339
  return this;
333
340
  }
334
341
 
335
342
  deleteSheet(index: any): any {
336
343
  const dto = this.toDTO();
337
344
  const res = _workbookDeleteSheet(dto, index);
338
- Object.assign(this, res);
345
+ const hydrated = new Workbook(res);
346
+ Object.assign(this, hydrated);
339
347
  return this;
340
348
  }
341
349
  }