@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
@@ -0,0 +1,377 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /* eslint accessor-pairs: [2, { "getWithoutSet": false }] */
6
+ /**
7
+ * @fileoverview Collection class definition
8
+ */
9
+ import _ from "lodash";
10
+ const MSGS = {
11
+ TYPE_MISMATCH: "Type does not match this collection type",
12
+ KEY_ALREADY_EXISTS: "Collection key already exists. ",
13
+ KEY_DOES_NOT_EXIST: "Collection key does not exist in this collection.",
14
+ MUST_GIVE_KEY: "Collection missing key.",
15
+ MUST_GIVE_VALUE: "Collection missing value.",
16
+ KEY_NOT_VALID: "Key must be of type String or Number",
17
+ };
18
+ export class Collection {
19
+ /**
20
+ * @param _name - a friendly name to describe this collection. If undefined
21
+ * the collection will have a default "Untitled Collection" assigned to its name.
22
+ * @param _type - optional parameter pointing to the constructor
23
+ * of a type this Collection will host.
24
+ */
25
+ constructor(_name = "Untitled Collection", _type) {
26
+ this._name = _name;
27
+ this._type = _type;
28
+ this._items = {};
29
+ this._order = [];
30
+ }
31
+ // Pass-thru binding handles
32
+ onAdd(in_key, in_value) { }
33
+ onRemove(in_key, in_value) { }
34
+ onClear(in_items) { }
35
+ get items() {
36
+ return this._items;
37
+ }
38
+ get keys() {
39
+ return Object.keys(this._items);
40
+ }
41
+ /**
42
+ * @param in_key - Key to store the value under
43
+ * @param in_value - Value to store in the collection
44
+ * @returns Return the value passed in
45
+ */
46
+ add(in_key, in_value) {
47
+ this._checkType(in_value);
48
+ this._checkIsNewKey(in_key);
49
+ this._items[in_key] = in_value;
50
+ this._order.push(in_key);
51
+ this.onAdd(in_key, in_value);
52
+ return in_value;
53
+ }
54
+ /**
55
+ * Checks if in_value's type is equal to this Collection type. If this collection
56
+ * has no type set, the check will pass.
57
+ *
58
+ * @param in_value - A value that is equal to the type managed by this collection.
59
+ * @returns Return true if the type is a valid type for this
60
+ * collection, throw otherwise.
61
+ */
62
+ _checkType(in_value) {
63
+ if (this._type && !(in_value instanceof this._type)) {
64
+ throw new Error(MSGS.TYPE_MISMATCH);
65
+ }
66
+ else {
67
+ return true;
68
+ }
69
+ }
70
+ /**
71
+ * Bulk add items.
72
+ * @param in_items - List of key-value pairs to be stored in the collection
73
+ * @returns this collection after add
74
+ */
75
+ bulkAdd(in_items) {
76
+ _.each(in_items, (item, key) => {
77
+ this.add(key, item);
78
+ });
79
+ return this;
80
+ }
81
+ /**
82
+ * Bulk remove items.
83
+ * @param in_items - List of key-value items to be removed
84
+ * @returns this collection after add
85
+ */
86
+ bulkRemove(in_items) {
87
+ _.each(in_items, (item, key) => {
88
+ this.remove(key);
89
+ });
90
+ return this;
91
+ }
92
+ /**
93
+ * Test if this collection is empty
94
+ * @returns true if empty, false otherwise
95
+ * */
96
+ isEmpty() {
97
+ return _.isEmpty(this._items);
98
+ }
99
+ /**
100
+ * Return the first item in the collection, null if empty
101
+ * @returns first item, or undefined if empty
102
+ * */
103
+ getFirstItem() {
104
+ const index = _.first(this._order);
105
+ return index === undefined ? index : this._items[index];
106
+ }
107
+ /**
108
+ * Return the last item in the collection, null if empty
109
+ * @returns - last item, or undefined if empty
110
+ * */
111
+ getLastItem() {
112
+ const index = _.last(this._order);
113
+ return index === undefined ? index : this._items[index];
114
+ }
115
+ /**
116
+ * @returns Returns the type of collection (Array, etc.)
117
+ */
118
+ getType() {
119
+ return this._type;
120
+ }
121
+ /**
122
+ * @returns Returns the name of the collection
123
+ */
124
+ getName() {
125
+ return this._name;
126
+ }
127
+ /**
128
+ * Filter out by function
129
+ * @param in_filterFunction - with arguments key and item
130
+ * @returns New filtered collection
131
+ */
132
+ filter(in_filterFunction) {
133
+ const rtn = new Collection();
134
+ const filterCb = function (in_key, in_item) {
135
+ const keeper = in_filterFunction(in_key, in_item);
136
+ if (keeper) {
137
+ rtn.add(in_key, in_item);
138
+ }
139
+ };
140
+ this.iterate(filterCb);
141
+ return rtn;
142
+ }
143
+ /**
144
+ * Filter out all keys NOT matching the in_filterKey
145
+ * @param in_filterKey - a single key or an array of keys, if the
146
+ * item matches any of the keys it will be filtered in.
147
+ * @returns New filtered collection with all the items
148
+ * matching at least one key.
149
+ */
150
+ filterByKey(in_filterKey) {
151
+ const rtn = new Collection();
152
+ let filterCb;
153
+ if (_.isArray(in_filterKey)) {
154
+ filterCb = function (in_key, in_item) {
155
+ if (in_filterKey.indexOf(in_key) >= 0) {
156
+ rtn.add(in_key, in_item);
157
+ }
158
+ };
159
+ }
160
+ else {
161
+ // if in_filterKey is an array
162
+ filterCb = function (in_key, in_item) {
163
+ if (in_key === in_filterKey) {
164
+ rtn.add(in_key, in_item);
165
+ }
166
+ };
167
+ }
168
+ this.iterate(filterCb);
169
+ return rtn;
170
+ }
171
+ /**
172
+ * Filter out all keys NOT matching the in_filterValue
173
+ * @param in_filterValue - Value to filter on
174
+ * @returns Return a filtered collection
175
+ */
176
+ filterByValue(in_filterValue) {
177
+ const rtn = new Collection();
178
+ const filterCb = function (in_key, in_item) {
179
+ if (in_item === in_filterValue) {
180
+ rtn.add(in_key, in_item);
181
+ }
182
+ };
183
+ this.iterate(filterCb);
184
+ return rtn;
185
+ }
186
+ /**
187
+ * Remove an item from this Collection. This method returns a Boolean indicating
188
+ * the success or failure of the removal. This is practical because if we were
189
+ * to throw an error when the key doesn't exist, it would require additional
190
+ * checks by the caller to make sure this key exists prior to removal. Which
191
+ * would make the attempt of removal more verbose and also costly because the
192
+ * caller would have to keep a list – somewhere else – of the things he can
193
+ * and cannot remove.
194
+ *
195
+ * @param in_key - the key we wish to remove
196
+ * @returns true if the key exists and was removed, false otherwise.
197
+ */
198
+ remove(in_key) {
199
+ if (!this.has(in_key)) {
200
+ return false;
201
+ }
202
+ const remember = this._items[in_key];
203
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
204
+ delete this._items[in_key];
205
+ this._order.splice(this._order.indexOf(in_key), 1);
206
+ this.onRemove(in_key, remember);
207
+ return true;
208
+ }
209
+ /**
210
+ * Return the number of items in this Collection
211
+ * @returns the number of items in the collection
212
+ */
213
+ getCount() {
214
+ return this._order.length;
215
+ }
216
+ /**
217
+ * Returns this collection as an ordered Array
218
+ * @returns Array including the values
219
+ */
220
+ getAsArray() {
221
+ const rtnArr = new Array(this.getCount());
222
+ for (let i = 0; i < this._order.length; i++) {
223
+ rtnArr[i] = this._items[this._order[i]];
224
+ }
225
+ return rtnArr;
226
+ }
227
+ /**
228
+ * @param in_key - the key we are looking for
229
+ * @returns true if the item exists
230
+ */
231
+ has(in_key) {
232
+ return Object.prototype.hasOwnProperty.call(this._items, in_key);
233
+ }
234
+ /**
235
+ * Return an item associated with the given key
236
+ * @param in_key - the key for the item in this
237
+ * Collection
238
+ * @returns The item
239
+ */
240
+ item(in_key) {
241
+ return this._items[in_key];
242
+ }
243
+ /**
244
+ * Checks if this is a new key in the collection. Throw if already exists.
245
+ * @param in_key - The key to check against
246
+ * @returns true if key is new
247
+ */
248
+ _checkIsNewKey(in_key) {
249
+ if (this.has(in_key)) {
250
+ throw new Error(`${MSGS.KEY_ALREADY_EXISTS} ${in_key}`);
251
+ }
252
+ return true;
253
+ }
254
+ /**
255
+ * Checks if the key exists in the collection. Throw if not.
256
+ * @param in_key - the key to check against
257
+ * @returns true if key exists
258
+ */
259
+ _checkKeyExists(in_key) {
260
+ if (!this.has(in_key)) {
261
+ throw new Error(`${MSGS.KEY_DOES_NOT_EXIST} ${in_key}`);
262
+ }
263
+ return true;
264
+ }
265
+ /**
266
+ * Set an existing key to a value. If key doesn't exist this call will throw
267
+ * an error.
268
+ * @param in_key - the key we want to modify
269
+ * @param in_value - the value we are to set at this key
270
+ * @returns the value passed in
271
+ */
272
+ set(in_key, in_value) {
273
+ this._checkKeyExists(in_key);
274
+ this._items[in_key] = in_value;
275
+ return in_value;
276
+ }
277
+ /**
278
+ * Iterate over this collection and run the callback with passing the key and
279
+ * item in the iteration loop.
280
+ * @param in_callback - a function that we will call on each item
281
+ * of this collection. If the callback returns false then the iteration will exit early.
282
+ */
283
+ iterate(in_callback) {
284
+ for (const key of this._order) {
285
+ const continu = in_callback(key, this._items[key]);
286
+ if (continu === false) {
287
+ break;
288
+ }
289
+ }
290
+ }
291
+ /**
292
+ * Iterate over this collection starting from the tail and run the callback with passing the key and
293
+ * item in the iteration loop.
294
+ * @param in_callback - a function that we will call on each item
295
+ * of this collection. If the callback returns false then the iteration will exit early.
296
+ */
297
+ iterateFromTail(in_callback) {
298
+ let key;
299
+ let continu;
300
+ for (let i = this._order.length - 1; i >= 0; i--) {
301
+ key = this._order[i];
302
+ continu = in_callback(key, this._items[key]);
303
+ if (continu === false) {
304
+ break;
305
+ }
306
+ }
307
+ }
308
+ /**
309
+ * @returns Return an object containing the items of this collection
310
+ */
311
+ getItems() {
312
+ const result = {};
313
+ _.each(this._items, function (item, key) {
314
+ result[key] = item;
315
+ });
316
+ return result;
317
+ }
318
+ /**
319
+ * Return the list of keys
320
+ * @returns List of keys
321
+ */
322
+ getKeys() {
323
+ return Object.keys(this._items);
324
+ }
325
+ /**
326
+ * Method used to get the first element in the collection along with its key.
327
+ */
328
+ peak() {
329
+ return {
330
+ item: this._items[this._order[0]],
331
+ key: this._order[0],
332
+ };
333
+ }
334
+ /**
335
+ * Clear this collection
336
+ * @returns this collection
337
+ */
338
+ clear() {
339
+ if (_.isEmpty(this._items)) {
340
+ return this;
341
+ }
342
+ this.onClear(this._items);
343
+ // Best to just iterate through and remove everything, so that OnRemove
344
+ // handlers are called.
345
+ _.each(this.getKeys(), (key) => {
346
+ this.remove(key);
347
+ });
348
+ return this;
349
+ }
350
+ /**
351
+ * Copy the items of in_collection to this collection.
352
+ * @param in_collection - the collection we want to
353
+ * copy from.
354
+ * @returns new Collection
355
+ */
356
+ clone() {
357
+ const newCol = new Collection(this._name, this._type);
358
+ newCol.bulkAdd(this._items);
359
+ return newCol;
360
+ }
361
+ /**
362
+ * Copy the items of in_collection to this collection.
363
+ * @param in_collection - the collection we want to
364
+ * copy from.
365
+ */
366
+ copy(in_collection) {
367
+ this.clear();
368
+ const its = in_collection.items;
369
+ _.each(its, (item, key) => {
370
+ this.add(key, item);
371
+ });
372
+ }
373
+ get values() {
374
+ return this.getAsArray();
375
+ }
376
+ }
377
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/datastructures/collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,4DAA4D;AAC5D;;GAEG;AACH,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,MAAM,IAAI,GAAG;IACT,aAAa,EAAE,0CAA0C;IACzD,kBAAkB,EAAE,iCAAiC;IACrD,kBAAkB,EAAE,mDAAmD;IACvE,aAAa,EAAE,yBAAyB;IACxC,eAAe,EAAE,2BAA2B;IAC5C,aAAa,EAAE,sCAAsC;CACxD,CAAC;AAEF,MAAM,OAAO,UAAU;IAInB;;;;;OAKG;IACH,YAAsB,QAAQ,qBAAqB,EAAY,KAAqB;QAA9D,UAAK,GAAL,KAAK,CAAwB;QAAY,UAAK,GAAL,KAAK,CAAgB;QAT1E,WAAM,GAAyB,EAAE,CAAC;QAClC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GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint accessor-pairs: [2, { \"getWithoutSet\": false }] */\n/**\n * @fileoverview Collection class definition\n */\nimport _ from \"lodash\";\n\nconst MSGS = {\n TYPE_MISMATCH: \"Type does not match this collection type\",\n KEY_ALREADY_EXISTS: \"Collection key already exists. \",\n KEY_DOES_NOT_EXIST: \"Collection key does not exist in this collection.\",\n MUST_GIVE_KEY: \"Collection missing key.\",\n MUST_GIVE_VALUE: \"Collection missing value.\",\n KEY_NOT_VALID: \"Key must be of type String or Number\",\n};\n\nexport class Collection<T> {\n protected _items: { [key: string]: T } = {};\n protected _order: (string | number)[] = [];\n\n /**\n * @param _name - a friendly name to describe this collection. If undefined\n * the collection will have a default \"Untitled Collection\" assigned to its name.\n * @param _type - optional parameter pointing to the constructor\n * of a type this Collection will host.\n */\n constructor(protected _name = \"Untitled Collection\", protected _type?: new () => any) {\n }\n\n // Pass-thru binding handles\n onAdd(in_key, in_value) { }\n onRemove(in_key, in_value) { }\n onClear(in_items) { }\n\n public get items() {\n return this._items;\n }\n\n public get keys() {\n return Object.keys(this._items);\n }\n\n /**\n * @param in_key - Key to store the value under\n * @param in_value - Value to store in the collection\n * @returns Return the value passed in\n */\n add(in_key: number | string, in_value: T): T {\n this._checkType(in_value);\n this._checkIsNewKey(in_key);\n\n this._items[in_key] = in_value;\n this._order.push(in_key);\n\n this.onAdd(in_key, in_value);\n\n return in_value;\n }\n\n /**\n * Checks if in_value's type is equal to this Collection type. If this collection\n * has no type set, the check will pass.\n *\n * @param in_value - A value that is equal to the type managed by this collection.\n * @returns Return true if the type is a valid type for this\n * collection, throw otherwise.\n */\n private _checkType(in_value: T) {\n if (this._type && !(in_value instanceof this._type)) {\n throw new Error(MSGS.TYPE_MISMATCH);\n } else {\n return true;\n }\n }\n\n /**\n * Bulk add items.\n * @param in_items - List of key-value pairs to be stored in the collection\n * @returns this collection after add\n */\n bulkAdd(in_items: { [key: string]: T }) {\n _.each(in_items, (item, key) => {\n this.add(key, item);\n });\n return this;\n }\n\n /**\n * Bulk remove items.\n * @param in_items - List of key-value items to be removed\n * @returns this collection after add\n */\n bulkRemove(in_items: { [key: string]: T }) {\n _.each(in_items, (item, key) => {\n this.remove(key);\n });\n\n return this;\n }\n\n /**\n * Test if this collection is empty\n * @returns true if empty, false otherwise\n * */\n isEmpty() {\n return _.isEmpty(this._items);\n }\n\n /**\n * Return the first item in the collection, null if empty\n * @returns first item, or undefined if empty\n * */\n getFirstItem(): T | undefined {\n const index = _.first(this._order);\n return index === undefined ? index : this._items[index];\n }\n\n /**\n * Return the last item in the collection, null if empty\n * @returns - last item, or undefined if empty\n * */\n getLastItem(): T | undefined {\n const index = _.last(this._order);\n return index === undefined ? index : this._items[index];\n }\n\n /**\n * @returns Returns the type of collection (Array, etc.)\n */\n getType() {\n return this._type;\n }\n\n /**\n * @returns Returns the name of the collection\n */\n getName(): string {\n return this._name;\n }\n\n /**\n * Filter out by function\n * @param in_filterFunction - with arguments key and item\n * @returns New filtered collection\n */\n filter(in_filterFunction: (key: string, item: T) => boolean): Collection<T> {\n const rtn = new Collection<T>();\n\n const filterCb = function(in_key, in_item) {\n const keeper = in_filterFunction(in_key, in_item);\n if (keeper) {\n rtn.add(in_key, in_item);\n }\n };\n\n this.iterate(filterCb);\n\n return rtn;\n }\n\n /**\n * Filter out all keys NOT matching the in_filterKey\n * @param in_filterKey - a single key or an array of keys, if the\n * item matches any of the keys it will be filtered in.\n * @returns New filtered collection with all the items\n * matching at least one key.\n */\n filterByKey(in_filterKey: string | string[]): Collection<T> {\n const rtn = new Collection<T>();\n\n let filterCb;\n\n if (_.isArray(in_filterKey)) {\n filterCb = function(in_key, in_item) {\n if (in_filterKey.indexOf(in_key) >= 0) {\n rtn.add(in_key, in_item);\n }\n };\n } else {\n // if in_filterKey is an array\n filterCb = function(in_key, in_item) {\n if (in_key === in_filterKey) {\n rtn.add(in_key, in_item);\n }\n };\n }\n\n this.iterate(filterCb);\n\n return rtn;\n }\n\n /**\n * Filter out all keys NOT matching the in_filterValue\n * @param in_filterValue - Value to filter on\n * @returns Return a filtered collection\n */\n filterByValue(in_filterValue: T): Collection<T> {\n const rtn = new Collection<T>();\n\n const filterCb = function(in_key, in_item) {\n if (in_item === in_filterValue) {\n rtn.add(in_key, in_item);\n }\n };\n\n this.iterate(filterCb);\n\n return rtn;\n }\n\n /**\n * Remove an item from this Collection. This method returns a Boolean indicating\n * the success or failure of the removal. This is practical because if we were\n * to throw an error when the key doesn't exist, it would require additional\n * checks by the caller to make sure this key exists prior to removal. Which\n * would make the attempt of removal more verbose and also costly because the\n * caller would have to keep a list – somewhere else – of the things he can\n * and cannot remove.\n *\n * @param in_key - the key we wish to remove\n * @returns true if the key exists and was removed, false otherwise.\n */\n remove(in_key: number | string): boolean {\n if (!this.has(in_key)) {\n return false;\n }\n\n const remember = this._items[in_key];\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this._items[in_key];\n this._order.splice(this._order.indexOf(in_key), 1);\n\n this.onRemove(in_key, remember);\n\n return true;\n }\n\n /**\n * Return the number of items in this Collection\n * @returns the number of items in the collection\n */\n getCount(): number {\n return this._order.length;\n }\n\n /**\n * Returns this collection as an ordered Array\n * @returns Array including the values\n */\n getAsArray() {\n const rtnArr: T[] = new Array(this.getCount());\n\n for (let i = 0; i < this._order.length; i++) {\n rtnArr[i] = this._items[this._order[i]];\n }\n\n return rtnArr;\n }\n\n /**\n * @param in_key - the key we are looking for\n * @returns true if the item exists\n */\n has(in_key: string | number): boolean {\n return Object.prototype.hasOwnProperty.call(this._items, in_key);\n }\n\n /**\n * Return an item associated with the given key\n * @param in_key - the key for the item in this\n * Collection\n * @returns The item\n */\n item(in_key: number | string) {\n return this._items[in_key];\n }\n\n /**\n * Checks if this is a new key in the collection. Throw if already exists.\n * @param in_key - The key to check against\n * @returns true if key is new\n */\n private _checkIsNewKey(in_key: number | string) {\n if (this.has(in_key)) {\n throw new Error(`${MSGS.KEY_ALREADY_EXISTS} ${in_key}`);\n }\n\n return true;\n }\n\n /**\n * Checks if the key exists in the collection. Throw if not.\n * @param in_key - the key to check against\n * @returns true if key exists\n */\n private _checkKeyExists(in_key: number | string) {\n if (!this.has(in_key)) {\n throw new Error(`${MSGS.KEY_DOES_NOT_EXIST} ${in_key}`);\n }\n\n return true;\n }\n\n /**\n * Set an existing key to a value. If key doesn't exist this call will throw\n * an error.\n * @param in_key - the key we want to modify\n * @param in_value - the value we are to set at this key\n * @returns the value passed in\n */\n set(in_key: string, in_value: T) {\n this._checkKeyExists(in_key);\n\n this._items[in_key] = in_value;\n\n return in_value;\n }\n\n /**\n * Iterate over this collection and run the callback with passing the key and\n * item in the iteration loop.\n * @param in_callback - a function that we will call on each item\n * of this collection. If the callback returns false then the iteration will exit early.\n */\n iterate(in_callback) {\n for (const key of this._order) {\n const continu = in_callback(key, this._items[key]);\n if (continu === false) {\n break;\n }\n }\n }\n\n /**\n * Iterate over this collection starting from the tail and run the callback with passing the key and\n * item in the iteration loop.\n * @param in_callback - a function that we will call on each item\n * of this collection. If the callback returns false then the iteration will exit early.\n */\n iterateFromTail(in_callback) {\n let key; let continu;\n for (let i = this._order.length - 1; i >= 0; i--) {\n key = this._order[i];\n continu = in_callback(key, this._items[key]);\n if (continu === false) {\n break;\n }\n }\n }\n\n /**\n * @returns Return an object containing the items of this collection\n */\n getItems(): { [key: string]: T } {\n const result = {};\n\n _.each(this._items, function(item, key) {\n result[key] = item;\n });\n\n return result;\n }\n\n /**\n * Return the list of keys\n * @returns List of keys\n */\n getKeys(): string[] {\n return Object.keys(this._items);\n }\n\n /**\n * Method used to get the first element in the collection along with its key.\n */\n peak() {\n return {\n item: this._items[this._order[0]],\n key: this._order[0],\n };\n }\n\n /**\n * Clear this collection\n * @returns this collection\n */\n clear() {\n if (_.isEmpty(this._items)) {\n return this;\n }\n\n this.onClear(this._items);\n\n // Best to just iterate through and remove everything, so that OnRemove\n // handlers are called.\n\n _.each(this.getKeys(), (key) => {\n this.remove(key);\n });\n\n return this;\n }\n\n /**\n * Copy the items of in_collection to this collection.\n * @param in_collection - the collection we want to\n * copy from.\n * @returns new Collection\n */\n clone(): Collection<T> {\n const newCol = new Collection<T>(this._name, this._type);\n newCol.bulkAdd(this._items);\n return newCol;\n }\n\n /**\n * Copy the items of in_collection to this collection.\n * @param in_collection - the collection we want to\n * copy from.\n */\n copy(in_collection: Collection<T>) {\n this.clear();\n const its = in_collection.items;\n\n _.each(its, (item, key) => {\n this.add(key, item);\n });\n }\n\n get values() {\n return this.getAsArray();\n }\n}\n"]}
@@ -0,0 +1,275 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ @fileoverview The data arrays definition file.
7
+ */
8
+ /**
9
+ * A typed data container that is persistable, high-performance, and can be used
10
+ * as a backing store for collaborative property sets.
11
+ */
12
+ declare class BaseDataArray {
13
+ protected _buffer: any;
14
+ private readonly bufferConstructor;
15
+ protected size: number;
16
+ constructor(size: number);
17
+ /**
18
+ * @param bufferConstructor - This is the constructor to be used to
19
+ * setup the internal buffer of the DataArray.
20
+ * @param size - The initial size with which to allocate the array.
21
+ */
22
+ constructor(bufferConstructor: any, size: number);
23
+ /**
24
+ * Get the value at an index. If no index is passed, return zeroth item.
25
+ * @param in_idx - the specific item in the data array.
26
+ * @returns the value at that index
27
+ */
28
+ getValue(in_idx?: number): any;
29
+ /**
30
+ * Return a range of values in the array.
31
+ * @param in_idxStart - the starting index
32
+ * @param in_idxEnd - the end index
33
+ * @returns the array of values in the range
34
+ */
35
+ getValueRange(in_idxStart: number, in_idxEnd: number): any;
36
+ /**
37
+ * Return the serialized form of Data Arrays.
38
+ * @returns An object containing an array of the values.
39
+ */
40
+ serialize(): number[];
41
+ /**
42
+ * Deserialize data from a serialized representation
43
+ * @param in_serialized - the serialized representation
44
+ */
45
+ deserialize(in_serialized: any): void;
46
+ /**
47
+ * Set value at an index.
48
+ * @param in_idx - the index
49
+ * @param in_value - the value we want to set at index
50
+ */
51
+ setValue(in_idx: number, in_value: any): void;
52
+ /**
53
+ * creates a copy of a typed array with removed elements
54
+ * @param in_arr - the input array (won't be modified)
55
+ * @param in_offset - starting index of range that will be removed
56
+ * @param in_deleteCount - number of removed elements
57
+ * @returns a copy of the input array without the selected range
58
+ */
59
+ private _removeElementsFromArray;
60
+ /**
61
+ * remove a range of elements from the array
62
+ * @param in_offset - start of the range
63
+ * @param in_deleteCount - number of elements to be removed
64
+ */
65
+ removeRange(in_offset: number, in_deleteCount: number): void;
66
+ /**
67
+ * copy an array with elements inserted into the copy
68
+ * @param in_arr - the input array (won't be modified)
69
+ * @param in_offset - the index where the new elements will be inserted
70
+ * @param in_addedArray - the array with the elements that will be added
71
+ * @returns the combined array
72
+ */
73
+ private _insert;
74
+ /**
75
+ * insert the content of an array into the DataArray
76
+ * @param in_offset - the target index
77
+ * @param in_array - the array to be inserted
78
+ */
79
+ insertRange(in_offset: number, in_array: any): void;
80
+ /**
81
+ * Set this array values to be equal to in_array values
82
+ * @param in_offset - An optional offset in this array to begin start
83
+ * setting this arrays values to in_array values.
84
+ * @param in_array - the input array
85
+ */
86
+ set(in_offset: number, in_array: any): void;
87
+ /**
88
+ * insert a value at the end of the array, creates a new element at the end and sets the value
89
+ * @param in_value - the new value
90
+ */
91
+ push(in_value: any): void;
92
+ /**
93
+ * get direct access to the data (for performance reasons)
94
+ * this should be uses read only
95
+ * @returns the (read only) raw data
96
+ */
97
+ getBuffer(): any;
98
+ /**
99
+ * get the constructor of the underlying TypedArray
100
+ * @returns the constructor for the data buffer
101
+ */
102
+ getBufferCtor(): any;
103
+ /**
104
+ * apply a given function to all elements of the array
105
+ * @param in_fn - the function that will be applied to every element
106
+ */
107
+ iterate(in_fn: any): void;
108
+ /**
109
+ * get a resized buffer copy
110
+ * @param in_bufferCtor - the constructor for the returned buffer
111
+ * @param in_buffer - the input buffer (won't be modified)
112
+ * @param in_newSize - the target size
113
+ * @returns the buffer with the new size
114
+ */
115
+ private resizeBuffer;
116
+ /**
117
+ * allocate memory for the array (for performance reasons, you can allocate more space than the current length,
118
+ * which makes pushes to the array less expensive later)
119
+ * @param size - the target allocated space
120
+ * @returns the DataArray itself
121
+ */
122
+ protected _alloc(size: number): any;
123
+ /**
124
+ * change the size of the array
125
+ * @param size - the target size
126
+ * @returns the DataArray itself
127
+ */
128
+ resize(size: number): this;
129
+ copy(): any;
130
+ get length(): number;
131
+ }
132
+ declare class Int8DataArray extends BaseDataArray {
133
+ constructor(size: number);
134
+ }
135
+ declare class Int16DataArray extends BaseDataArray {
136
+ constructor(size: number);
137
+ }
138
+ declare class Int32DataArray extends BaseDataArray {
139
+ constructor(size: number);
140
+ }
141
+ declare class Uint8DataArray extends BaseDataArray {
142
+ constructor(size: number);
143
+ }
144
+ declare class Uint16DataArray extends BaseDataArray {
145
+ constructor(size: number);
146
+ }
147
+ declare class Uint32DataArray extends BaseDataArray {
148
+ constructor(size: number);
149
+ }
150
+ declare class Float32DataArray extends BaseDataArray {
151
+ constructor(size: number);
152
+ }
153
+ declare class Float64DataArray extends BaseDataArray {
154
+ constructor(size: number);
155
+ }
156
+ /**
157
+ * A data container that can contain every native type
158
+ *
159
+ * @param size - The initial size with which to allocate the array.
160
+ */
161
+ declare class UniversalDataArray extends BaseDataArray {
162
+ constructor(bufferConstructor: any, size: number);
163
+ constructor(size: number);
164
+ /**
165
+ * helper function to write array values into another array at a given offset
166
+ * @param array - target array
167
+ * @param values - the values we need to write
168
+ * @param offset - starting index in target array
169
+ */
170
+ private arraySet;
171
+ /**
172
+ * insert the content of an array into the DataArray
173
+ * @param in_offset - the target index
174
+ * @param in_array - the array to be inserted
175
+ */
176
+ insertRange(in_offset: number, in_array: any[]): void;
177
+ /**
178
+ * remove a range of elements from the array
179
+ * @param in_offset - start of the range
180
+ * @param in_deleteCount - number of elements to be removed
181
+ */
182
+ removeRange(in_offset: number, in_deleteCount: number): void;
183
+ /**
184
+ * Set this array values to be equal to in_array values
185
+ * @param in_offset - An optional offset in this array to begin start
186
+ * setting this arrays values to in_array values.
187
+ * @param in_array - the input array
188
+ */
189
+ set(in_offset: number, in_array: any): void;
190
+ /**
191
+ * Return a range of values in the array.
192
+ * @param in_idxStart - the starting index
193
+ * @param in_idxEnd - the end index - this offset is exclusive
194
+ * @returns the array of values in the range
195
+ */
196
+ getValueRange(in_idxStart: number, in_idxEnd: number): any;
197
+ /**
198
+ * change the size of a javascript array and keep the content, if possible. Keeps the input buffer.
199
+ * @param in_buffer - input buffer - not changed
200
+ * @param in_newSize - target size
201
+ * @returns an Array of the new size
202
+ */
203
+ private resizeBufferArray;
204
+ /**
205
+ * allocate memory for the array (for performance reasons, you can allocate more space than the current length,
206
+ * which makes pushes to the array less expensive later)
207
+ * @param size - the target allocated space
208
+ * @returns the DataArray itself
209
+ */
210
+ protected _alloc(size: number): any;
211
+ }
212
+ /**
213
+ * A data container that contains a string
214
+ */
215
+ declare class StringDataArray extends BaseDataArray {
216
+ constructor();
217
+ /**
218
+ * insert the content of a string into the StringDataArray
219
+ * @param in_offset - the target index
220
+ * @param in_string - the string to be inserted
221
+ */
222
+ insertRange(in_offset: number, in_string: string): void;
223
+ /**
224
+ * remove a range of elements from the string
225
+ * @param in_offset - start of the range
226
+ * @param in_deleteCount - number of elements to be removed
227
+ */
228
+ removeRange(in_offset: number, in_deleteCount: number): void;
229
+ /**
230
+ * Set this array values to be equal to in_string values
231
+ * @param in_offset - The offset in this array to begin start
232
+ * setting this arrays values to in_string values.
233
+ * @param in_string - the input string
234
+ */
235
+ set(in_offset: number, in_string: string): void;
236
+ /**
237
+ * Return a range of characters in the string.
238
+ * @param in_idxStart - the starting index
239
+ * @param in_idxEnd - the end index - this offset is exclusive
240
+ * @returns the characters in the range
241
+ */
242
+ getValueRange(in_idxStart: number, in_idxEnd: number): string;
243
+ get length(): any;
244
+ }
245
+ /**
246
+ * A data container that can contain boolean type
247
+ */
248
+ declare class BoolDataArray extends UniversalDataArray {
249
+ /**
250
+ * @param size - The initial size with which to allocate the array.
251
+ */
252
+ constructor(size: number);
253
+ /**
254
+ * helper function to write and cast to boolean array values into another array at a given offset
255
+ * @param array - target array
256
+ * @param values - the values we need to write
257
+ * @param offset - starting index in target array
258
+ */
259
+ private arraySetBool;
260
+ /**
261
+ * insert the content of an array into the DataArray
262
+ * @param in_offset - the target index
263
+ * @param in_array - the array to be inserted
264
+ */
265
+ insertRange(in_offset: number, in_array: any[]): void;
266
+ /**
267
+ * Set this array values to be equal to in_array values
268
+ * @param in_offset - An optional offset in this array to begin start
269
+ * setting this arrays values to in_array values.
270
+ * @param in_array - the input array
271
+ */
272
+ set(in_offset: number, in_array: any): void;
273
+ }
274
+ export { BaseDataArray, Float32DataArray, Float64DataArray, Int8DataArray, Int16DataArray, Int32DataArray, Uint8DataArray, Uint16DataArray, Uint32DataArray, UniversalDataArray, StringDataArray, BoolDataArray, };
275
+ //# sourceMappingURL=dataArray.d.ts.map