@fluid-experimental/property-common 0.49.0 → 0.50.0-41540

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 (130) hide show
  1. package/dist/constants.d.ts +4 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +4 -0
  4. package/dist/constants.js.map +1 -1
  5. package/dist/packageVersion.d.ts +1 -1
  6. package/dist/packageVersion.d.ts.map +1 -1
  7. package/dist/packageVersion.js +1 -1
  8. package/dist/packageVersion.js.map +1 -1
  9. package/lib/chronometer.d.ts +55 -0
  10. package/lib/chronometer.d.ts.map +1 -0
  11. package/lib/chronometer.js +185 -0
  12. package/lib/chronometer.js.map +1 -0
  13. package/lib/consoleUtils.d.ts +16 -0
  14. package/lib/consoleUtils.d.ts.map +1 -0
  15. package/lib/consoleUtils.js +20 -0
  16. package/lib/consoleUtils.js.map +1 -0
  17. package/lib/constants.d.ts +1219 -0
  18. package/lib/constants.d.ts.map +1 -0
  19. package/lib/constants.js +1274 -0
  20. package/lib/constants.js.map +1 -0
  21. package/lib/datastructures/collection.d.ts +203 -0
  22. package/lib/datastructures/collection.d.ts.map +1 -0
  23. package/lib/datastructures/collection.js +377 -0
  24. package/lib/datastructures/collection.js.map +1 -0
  25. package/lib/datastructures/dataArray.d.ts +275 -0
  26. package/lib/datastructures/dataArray.d.ts.map +1 -0
  27. package/lib/datastructures/dataArray.js +497 -0
  28. package/lib/datastructures/dataArray.js.map +1 -0
  29. package/lib/datastructures/index.d.ts +9 -0
  30. package/lib/datastructures/index.d.ts.map +1 -0
  31. package/lib/datastructures/index.js +9 -0
  32. package/lib/datastructures/index.js.map +1 -0
  33. package/lib/datastructures/integer64.d.ts +47 -0
  34. package/lib/datastructures/integer64.d.ts.map +1 -0
  35. package/lib/datastructures/integer64.js +140 -0
  36. package/lib/datastructures/integer64.js.map +1 -0
  37. package/lib/datastructures/sortedCollection.d.ts +77 -0
  38. package/lib/datastructures/sortedCollection.d.ts.map +1 -0
  39. package/lib/datastructures/sortedCollection.js +140 -0
  40. package/lib/datastructures/sortedCollection.js.map +1 -0
  41. package/lib/deferredPromise.d.ts +28 -0
  42. package/lib/deferredPromise.d.ts.map +1 -0
  43. package/lib/deferredPromise.js +43 -0
  44. package/lib/deferredPromise.js.map +1 -0
  45. package/lib/deterministicRandomGenerator.d.ts +39 -0
  46. package/lib/deterministicRandomGenerator.d.ts.map +1 -0
  47. package/lib/deterministicRandomGenerator.js +83 -0
  48. package/lib/deterministicRandomGenerator.js.map +1 -0
  49. package/lib/error_objects/flaggedError.d.ts +29 -0
  50. package/lib/error_objects/flaggedError.d.ts.map +1 -0
  51. package/lib/error_objects/flaggedError.js +45 -0
  52. package/lib/error_objects/flaggedError.js.map +1 -0
  53. package/lib/error_objects/httpError.d.ts +31 -0
  54. package/lib/error_objects/httpError.d.ts.map +1 -0
  55. package/lib/error_objects/httpError.js +58 -0
  56. package/lib/error_objects/httpError.js.map +1 -0
  57. package/lib/error_objects/httpErrorNoStack.d.ts +25 -0
  58. package/lib/error_objects/httpErrorNoStack.d.ts.map +1 -0
  59. package/lib/error_objects/httpErrorNoStack.js +29 -0
  60. package/lib/error_objects/httpErrorNoStack.js.map +1 -0
  61. package/lib/error_objects/index.d.ts +9 -0
  62. package/lib/error_objects/index.d.ts.map +1 -0
  63. package/lib/error_objects/index.js +9 -0
  64. package/lib/error_objects/index.js.map +1 -0
  65. package/lib/error_objects/operationError.d.ts +32 -0
  66. package/lib/error_objects/operationError.d.ts.map +1 -0
  67. package/lib/error_objects/operationError.js +73 -0
  68. package/lib/error_objects/operationError.js.map +1 -0
  69. package/lib/guidUtils.d.ts +16 -0
  70. package/lib/guidUtils.d.ts.map +1 -0
  71. package/lib/guidUtils.js +297 -0
  72. package/lib/guidUtils.js.map +1 -0
  73. package/lib/hashCalculator.d.ts +6 -0
  74. package/lib/hashCalculator.d.ts.map +1 -0
  75. package/lib/hashCalculator.js +14 -0
  76. package/lib/hashCalculator.js.map +1 -0
  77. package/lib/index.d.ts +16 -0
  78. package/lib/index.d.ts.map +1 -0
  79. package/lib/index.js +16 -0
  80. package/lib/index.js.map +1 -0
  81. package/lib/joinPaths.d.ts +19 -0
  82. package/lib/joinPaths.d.ts.map +1 -0
  83. package/lib/joinPaths.js +28 -0
  84. package/lib/joinPaths.js.map +1 -0
  85. package/lib/packageVersion.d.ts +9 -0
  86. package/lib/packageVersion.d.ts.map +1 -0
  87. package/lib/packageVersion.js +9 -0
  88. package/lib/packageVersion.js.map +1 -0
  89. package/package.json +22 -2
  90. package/platform-dependent/package.json +1 -1
  91. package/src/constants.ts +5 -0
  92. package/src/packageVersion.ts +1 -1
  93. package/dist/test/chronometer.spec.js +0 -90
  94. package/dist/test/chronometer.spec.js.map +0 -1
  95. package/dist/test/datastructures/collection.spec.js +0 -401
  96. package/dist/test/datastructures/collection.spec.js.map +0 -1
  97. package/dist/test/datastructures/dataArray.spec.js +0 -79
  98. package/dist/test/datastructures/dataArray.spec.js.map +0 -1
  99. package/dist/test/datastructures/sortedCollection.spec.js +0 -106
  100. package/dist/test/datastructures/sortedCollection.spec.js.map +0 -1
  101. package/dist/test/deterministicRandomGenerator.spec.js +0 -18
  102. package/dist/test/deterministicRandomGenerator.spec.js.map +0 -1
  103. package/dist/test/error_objects/flaggedError.spec.js +0 -23
  104. package/dist/test/error_objects/flaggedError.spec.js.map +0 -1
  105. package/dist/test/error_objects/httpError.spec.js +0 -61
  106. package/dist/test/error_objects/httpError.spec.js.map +0 -1
  107. package/dist/test/error_objects/httpErrorNoStack.spec.js +0 -55
  108. package/dist/test/error_objects/httpErrorNoStack.spec.js.map +0 -1
  109. package/dist/test/error_objects/operationError.spec.js +0 -132
  110. package/dist/test/error_objects/operationError.spec.js.map +0 -1
  111. package/dist/test/guidUtils.spec.js +0 -184
  112. package/dist/test/guidUtils.spec.js.map +0 -1
  113. package/dist/test/strings/joinPaths.spec.js +0 -18
  114. package/dist/test/strings/joinPaths.spec.js.map +0 -1
  115. package/dist/test/tsconfig.tsbuildinfo +0 -2278
  116. package/nyc/mocha-junit-report.xml +0 -175
  117. package/src/test/chronometer.spec.ts +0 -99
  118. package/src/test/datastructures/collection.spec.ts +0 -567
  119. package/src/test/datastructures/dataArray.spec.ts +0 -81
  120. package/src/test/datastructures/sortedCollection.spec.ts +0 -128
  121. package/src/test/deterministicRandomGenerator.spec.ts +0 -18
  122. package/src/test/error_objects/flaggedError.spec.ts +0 -22
  123. package/src/test/error_objects/httpError.spec.ts +0 -68
  124. package/src/test/error_objects/httpErrorNoStack.spec.ts +0 -64
  125. package/src/test/error_objects/operationError.spec.ts +0 -152
  126. package/src/test/guidUtils.spec.ts +0 -213
  127. package/src/test/strings/joinPaths.spec.ts +0 -17
  128. package/src/test/tsconfig.json +0 -21
  129. package/tsconfig.esnext.tsbuildinfo +0 -824
  130. package/tsconfig.tsbuildinfo +0 -823
@@ -1,567 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /**
7
- * @fileoverview In this file, we will test the functions exported by datastructres/collection.js
8
- */
9
-
10
- import _ from "lodash";
11
- import { expect } from "chai";
12
- import { Collection } from "../../index";
13
-
14
- describe("collection", function() {
15
- const createObject = () => ({
16
- item4: Number.NaN,
17
- item5: undefined,
18
- // eslint-disable-next-line no-null/no-null
19
- item6: null,
20
- item7: "",
21
- item8: false,
22
- item9: {},
23
- item10: [],
24
- item11: "test",
25
- item12: 0,
26
- item13: 1,
27
- });
28
-
29
- it("should add a value under a key", function(done) {
30
- const collection = new Collection<string>();
31
-
32
- expect(collection.add("item1", "test")).to.equal("test");
33
-
34
- expect(collection.has("item1")).to.equal(true);
35
-
36
- collection.add(0, "test2");
37
-
38
- expect(collection.has(0)).to.equal(true);
39
-
40
- done();
41
- });
42
-
43
- it("should bulk add a key-value object to the list of items", function(done) {
44
- const collection = new Collection<any>();
45
-
46
- const objectToAdd = createObject();
47
-
48
- expect(collection.bulkAdd(objectToAdd)).to.equal(collection);
49
-
50
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
51
- const itemExists = _.every(objectToAdd, (item, key) => collection.has(key));
52
-
53
- expect(itemExists).to.equal(true);
54
-
55
- done();
56
- });
57
-
58
- it("should remove a value associated with a key", function(done) {
59
- const collection = new Collection<string>();
60
-
61
- collection.add("item1", "test");
62
-
63
- expect(collection.remove("item1")).to.equal(true);
64
-
65
- expect(collection.has("item1")).to.equal(false);
66
-
67
- expect(collection.remove("item1")).to.equal(false);
68
-
69
- done();
70
- });
71
-
72
- it("should bulk remove a key-value object from the list of items", function(done) {
73
- const collection = new Collection();
74
-
75
- const objectToAdd = createObject();
76
-
77
- collection.bulkAdd(objectToAdd);
78
- collection.bulkRemove(objectToAdd);
79
-
80
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
81
- const itemExists = _.every(objectToAdd, (item, key) => collection.has(key));
82
-
83
- expect(itemExists).to.equal(false);
84
-
85
- done();
86
- });
87
-
88
- it("should check for emptyness", function(done) {
89
- const collection = new Collection<string>();
90
-
91
- expect(collection.isEmpty()).to.equal(true);
92
-
93
- collection.add("item1", "test");
94
-
95
- expect(collection.isEmpty()).to.equal(false);
96
- done();
97
- });
98
-
99
- it("should get the first value in the collection", function(done) {
100
- const collection = new Collection<string>();
101
-
102
- collection.add("item1", "test1");
103
- collection.add("item2", "test2");
104
-
105
- expect(collection.getFirstItem()).to.equal("test1");
106
- done();
107
- });
108
-
109
- it("should get the last value in the collection", function(done) {
110
- const collection = new Collection<string>();
111
-
112
- collection.add("item1", "test1");
113
- collection.add("item2", "test2");
114
-
115
- expect(collection.getLastItem()).to.equal("test2");
116
- done();
117
- });
118
-
119
- it("should get the type of the collection", function(done) {
120
- const collection = new Collection("collection1", Array);
121
-
122
- expect(collection.getType()).to.equal(Array);
123
-
124
- done();
125
- });
126
-
127
- it("should filter out values based on a predicate function", function(done) {
128
- const collection = new Collection<number>();
129
-
130
- const objectToAdd = {
131
- item1: 0,
132
- item2: 2,
133
- item3: 3,
134
- };
135
-
136
- collection.bulkAdd(objectToAdd);
137
-
138
- const filteredCollection = collection.filter((key, item) => item > 0);
139
-
140
- expect(filteredCollection.has("item1")).to.equal(false);
141
- expect(filteredCollection.has("item2")).to.equal(true);
142
- expect(filteredCollection.has("item3")).to.equal(true);
143
-
144
- done();
145
- });
146
-
147
- it("should filter out values based on a key predicate", function(done) {
148
- const collection = new Collection();
149
-
150
- const objectToAdd = {
151
- item1: 0,
152
- item2: 2,
153
- item3: 3,
154
- };
155
-
156
- collection.bulkAdd(objectToAdd);
157
-
158
- const filteredCollection = collection.filterByKey(["item2", "item3"]);
159
-
160
- expect(filteredCollection.has("item1")).to.equal(false);
161
- expect(filteredCollection.has("item2")).to.equal(true);
162
- expect(filteredCollection.has("item3")).to.equal(true);
163
-
164
- const filteredCollection2 = collection.filterByKey("item2");
165
-
166
- expect(filteredCollection2.has("item1")).to.equal(false);
167
- expect(filteredCollection2.has("item2")).to.equal(true);
168
- expect(filteredCollection2.has("item3")).to.equal(false);
169
-
170
- done();
171
- });
172
-
173
- it("should filter out values based on a value predicate", function(done) {
174
- const collection = new Collection();
175
-
176
- const objectToAdd = {
177
- item1: 0,
178
- item2: 2,
179
- item3: 3,
180
- };
181
-
182
- collection.bulkAdd(objectToAdd);
183
-
184
- const filteredCollection = collection.filterByValue(objectToAdd.item1);
185
-
186
- expect(filteredCollection.has("item1")).to.equal(true);
187
- expect(filteredCollection.has("item2")).to.equal(false);
188
- expect(filteredCollection.has("item3")).to.equal(false);
189
-
190
- done();
191
- });
192
-
193
- it("should return the number of elements in the collection", function(done) {
194
- const collection = new Collection();
195
-
196
- const objectToAdd = {
197
- item1: 0,
198
- item2: 2,
199
- item3: 3,
200
- };
201
-
202
- collection.bulkAdd(objectToAdd);
203
-
204
- expect(collection.getCount()).to.equal(3);
205
- done();
206
- });
207
-
208
- it("should return the list of items in an array", function(done) {
209
- const collection = new Collection();
210
-
211
- const objectToAdd = {
212
- item1: 0,
213
- item2: 2,
214
- item3: 3,
215
- };
216
-
217
- collection.bulkAdd(objectToAdd);
218
-
219
- const array = collection.getAsArray();
220
-
221
- expect(array).to.be.an("array");
222
-
223
- const exists = _.every(objectToAdd, (item) => _.includes(array, item));
224
-
225
- expect(exists).to.equal(true);
226
-
227
- done();
228
- });
229
-
230
- it("should check if an item exists", function(done) {
231
- const collection = new Collection();
232
-
233
- const objectToAdd = {
234
- item1: 0,
235
- item2: 2,
236
- item3: 3,
237
- };
238
-
239
- collection.bulkAdd(objectToAdd);
240
-
241
- expect(collection.has("item2")).to.equal(true);
242
- expect(collection.has("foo")).to.equal(false);
243
-
244
- done();
245
- });
246
-
247
- it("should get an item from the collection", function(done) {
248
- const collection = new Collection();
249
-
250
- const objectToAdd = {
251
- item1: 0,
252
- item2: 2,
253
- item3: 3,
254
- };
255
-
256
- collection.bulkAdd(objectToAdd);
257
-
258
- expect(collection.item("item2")).to.equal(objectToAdd.item2);
259
-
260
- done();
261
- });
262
-
263
- it("should set the value of a key", function(done) {
264
- const collection = new Collection();
265
-
266
- const objectToAdd = {
267
- item1: 0,
268
- item2: 2,
269
- item3: 3,
270
- };
271
-
272
- collection.bulkAdd(objectToAdd);
273
-
274
- collection.set("item1", 5);
275
-
276
- expect(collection.item("item1")).to.equal(5);
277
-
278
- done();
279
- });
280
-
281
- it("should iterate over the set of items", function(done) {
282
- const collection = new Collection();
283
-
284
- const objectToAdd = {
285
- item1: 0,
286
- item2: 2,
287
- item3: 3,
288
- };
289
-
290
- collection.bulkAdd(objectToAdd);
291
-
292
- const result = {};
293
- collection.iterate(function(key, item) {
294
- result[key] = item;
295
- });
296
-
297
- expect(result).to.deep.equal(objectToAdd);
298
-
299
- done();
300
- });
301
-
302
- it("should iterate over the set of items starting from the tail", function(done) {
303
- const collection = new Collection();
304
-
305
- const objectToAdd = {
306
- item1: 0,
307
- item2: 2,
308
- item3: 3,
309
- };
310
-
311
- collection.bulkAdd(objectToAdd);
312
-
313
- const result = {};
314
- const keys = collection.getKeys();
315
- let i = keys.length - 1;
316
- collection.iterateFromTail(function(key, item) {
317
- result[key] = item;
318
- expect(key).to.equal(keys[i]);
319
- i--;
320
- });
321
-
322
- expect(result).to.deep.equal(objectToAdd);
323
-
324
- done();
325
- });
326
-
327
- it("should return all items in an JSON format", function(done) {
328
- const collection = new Collection();
329
-
330
- const objectToAdd = {
331
- item1: 0,
332
- item2: 2,
333
- item3: 3,
334
- };
335
-
336
- collection.bulkAdd(objectToAdd);
337
-
338
- expect(collection.getItems()).to.deep.equal(objectToAdd);
339
-
340
- done();
341
- });
342
-
343
- it("should return all keys in an array", function(done) {
344
- const collection = new Collection();
345
-
346
- const objectToAdd = {
347
- item1: 0,
348
- item2: 2,
349
- item3: 3,
350
- };
351
-
352
- collection.bulkAdd(objectToAdd);
353
-
354
- expect(collection.getKeys()).to.deep.equal(_.keys(objectToAdd));
355
-
356
- done();
357
- });
358
-
359
- it("should return the first item in the collection along with the key", function(done) {
360
- const collection = new Collection();
361
-
362
- collection.add("item1", "test1");
363
- collection.add("item2", "test2");
364
-
365
- expect(collection.peak()).to.deep.equal({ key: "item1", item: "test1" });
366
-
367
- done();
368
- });
369
-
370
- describe("clear", function() {
371
- it("should empty the collection", function(done) {
372
- const collection = new Collection();
373
-
374
- const objectToAdd = {
375
- item1: 0,
376
- item2: 2,
377
- item3: 3,
378
- };
379
-
380
- collection.bulkAdd(objectToAdd);
381
-
382
- const ret = collection.clear();
383
-
384
- expect(collection.isEmpty()).to.equal(true);
385
- expect(ret).to.equal(collection);
386
-
387
- done();
388
- });
389
-
390
- it("should return the collection itself", function(done) {
391
- const collection = new Collection();
392
- const ret = collection.clear();
393
- expect(ret).to.equal(collection);
394
- done();
395
- });
396
- });
397
-
398
- it("should clone the collection", function(done) {
399
- const collection = new Collection();
400
-
401
- const objectToAdd = {
402
- item1: 0,
403
- item2: 2,
404
- item3: 3,
405
- };
406
-
407
- collection.bulkAdd(objectToAdd);
408
-
409
- expect(collection.clone().items).to.deep.equal(collection.items);
410
-
411
- done();
412
- });
413
-
414
- it("should copy the collection", function(done) {
415
- const collection = new Collection();
416
-
417
- const objectToAdd = {
418
- item1: "test",
419
- item2: true,
420
- item3: 23,
421
- };
422
-
423
- collection.bulkAdd(objectToAdd);
424
-
425
- const collection2 = new Collection();
426
-
427
- collection2.copy(collection);
428
-
429
- expect(collection2.items.item1).to.equal(objectToAdd.item1);
430
- expect(collection2.items.item2).to.equal(objectToAdd.item2);
431
- expect(collection2.items.item3).to.equal(objectToAdd.item3);
432
-
433
- done();
434
- });
435
-
436
- it("should invoke the onAdd callback", function(done) {
437
- const collection = new Collection();
438
-
439
- let triggered = false;
440
-
441
- collection.onAdd = function(key, item) {
442
- triggered = true;
443
- expect(key).to.equal("item");
444
- expect(item).to.equal("value");
445
- };
446
- collection.add("item", "value");
447
-
448
- expect(triggered).to.equal(true);
449
-
450
- let callbackCounter = 0;
451
- const objectToAdd = createObject();
452
-
453
- // now override the onAdd function and check wiether we call it
454
- // when we bulkAdd
455
- collection.onAdd = function(key, item) {
456
- callbackCounter++;
457
- expect(Object.prototype.hasOwnProperty.call(objectToAdd, key)).to.equal(true);
458
- };
459
-
460
- collection.bulkAdd(objectToAdd);
461
- expect(callbackCounter).to.equal(_.keys(objectToAdd).length);
462
-
463
- done();
464
- });
465
-
466
- it("should invoke the onRemove callback", function(done) {
467
- const collection = new Collection();
468
-
469
- let triggered = false;
470
-
471
- collection.onRemove = function(key, item) {
472
- triggered = true;
473
- expect(key).to.equal("item");
474
- expect(item).to.equal("value");
475
- };
476
-
477
- collection.add("item", "value");
478
- collection.remove("item");
479
- expect(triggered).to.equal(true);
480
-
481
- // Should not invoke the onRemove here
482
- triggered = false;
483
- collection.remove("item");
484
-
485
- expect(triggered).to.equal(false);
486
-
487
- let callbackCounter = 0;
488
- const objectToAdd = createObject();
489
-
490
- // now override the onRemove function and check wiether we call it
491
- // when we bulkRemove
492
- collection.onRemove = function(key, item) {
493
- callbackCounter++;
494
- expect(Object.prototype.hasOwnProperty.call(objectToAdd, key)).to.equal(true);
495
- };
496
-
497
- collection.bulkAdd(objectToAdd);
498
- collection.bulkRemove(objectToAdd);
499
-
500
- expect(callbackCounter).to.equal(_.keys(objectToAdd).length);
501
-
502
- done();
503
- });
504
-
505
- it("should stop early when iterating", function() {
506
- const collection = new Collection();
507
-
508
- const objectToAdd = {
509
- item1: "test",
510
- item2: true,
511
- item3: 23,
512
- };
513
-
514
- collection.bulkAdd(objectToAdd);
515
-
516
- let iterator = 1;
517
-
518
- collection.iterate(function() {
519
- if (iterator === 2) {
520
- return false;
521
- }
522
-
523
- iterator++;
524
-
525
- return true;
526
- });
527
-
528
- expect(iterator).to.equal(2);
529
-
530
- iterator = 1;
531
-
532
- collection.iterateFromTail(function() {
533
- if (iterator === 2) {
534
- return false;
535
- }
536
-
537
- iterator++;
538
-
539
- return true;
540
- });
541
-
542
- expect(iterator).to.equal(2);
543
- });
544
-
545
- it("should invoke the onClear callback", function(done) {
546
- const collection = new Collection();
547
-
548
- const objectToAdd = createObject();
549
- let triggered = false;
550
- collection.onClear = function(items) {
551
- triggered = true;
552
- expect(items).to.deep.equal(objectToAdd);
553
- };
554
-
555
- // this shouldn't invoke the callback
556
- collection.clear();
557
-
558
- expect(triggered).to.equal(false);
559
-
560
- collection.bulkAdd(objectToAdd);
561
- collection.clear();
562
-
563
- expect(triggered).to.equal(true);
564
-
565
- done();
566
- });
567
- });
@@ -1,81 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * @fileoverview In this file, we will test the functions exported by deep_copy.js
7
- */
8
- import { expect } from "chai";
9
- import {
10
- Int32DataArray,
11
- UniversalDataArray,
12
- Int8DataArray,
13
- BoolDataArray,
14
- } from "../../index";
15
- let error;
16
-
17
- describe("BaseDataArray", function() {
18
- it("should set, insert and remove some values in a (TypedArray) DataArray", function() {
19
- const myDataArray = new Int32DataArray(5);
20
- try {
21
- myDataArray.set(0, [1, 2, 3, 4, 5]);
22
- myDataArray.insertRange(2, [31, 32, 33]);
23
- myDataArray.removeRange(3, 4);
24
- } catch (e) {
25
- error = e;
26
- } finally {
27
- expect(error).to.equal(undefined);
28
- expect(myDataArray.length).to.equal(4);
29
- expect(Array.prototype.slice.call(myDataArray.getBuffer())).to.deep.equal([1, 2, 31, 5]);
30
- }
31
- });
32
-
33
- it("should set, insert and remove some values in a UniversalArray", function() {
34
- const myDataArray = new UniversalDataArray(5);
35
- try {
36
- console.log("UniversalArray: ", myDataArray);
37
- myDataArray.set(0, ["1", "2", "3", "4", "5"]);
38
- myDataArray.insertRange(2, ["31", "32", "33"]);
39
- myDataArray.removeRange(3, 4);
40
- } catch (e) {
41
- error = e;
42
- } finally {
43
- expect(error).to.equal(undefined);
44
- expect(myDataArray.length).to.equal(4);
45
- expect(Array.prototype.slice.call(myDataArray.getBuffer())).to.deep.equal(["1", "2", "31", "5"]);
46
- }
47
- });
48
-
49
- it("should get all elements from array", function() {
50
- const myDataArray = new Int8DataArray(5);
51
- myDataArray.set(0, [1, 2, 3, 4, 5]);
52
- const subArray = myDataArray.getValueRange(0, 5);
53
- expect(subArray.length).to.equal(5);
54
- });
55
- });
56
-
57
- describe("BoolDataArray", function() {
58
- it("should set, insert and remove some values", function() {
59
- const myDataArray = new BoolDataArray(5);
60
-
61
- try {
62
- myDataArray.set(0, [1, 0, false, 1, true]);
63
- myDataArray.insertRange(2, [1, 0, false]);
64
- myDataArray.removeRange(3, 4);
65
- } catch (e) {
66
- error = e;
67
- } finally {
68
- expect(error).to.equal(undefined);
69
- expect(myDataArray.length).to.equal(4);
70
- expect(Array.prototype.slice.call(myDataArray.getBuffer())).to.deep.equal([true, false, true, true]);
71
- }
72
- });
73
-
74
- it("should get all elements from array", function() {
75
- const myDataArray = new BoolDataArray(5);
76
- myDataArray.set(0, [true, false, true, false, false]);
77
- const subArray = myDataArray.getValueRange(1, 4);
78
- expect(subArray.length).to.equal(3);
79
- expect(subArray).to.deep.equal([false, true, false]);
80
- });
81
- });