@fluidframework/map 2.52.0 → 2.53.0

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/src/mapKernel.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  serializeValue,
24
24
  migrateIfSharedSerializable,
25
25
  } from "./localValues.js";
26
+ import { findLast, findLastIndex } from "./utils.js";
26
27
 
27
28
  /**
28
29
  * Defines the means to process and resubmit a given op on a map.
@@ -106,25 +107,6 @@ type PendingDataEntry = PendingKeyLifetime | PendingKeyDelete | PendingClear;
106
107
  */
107
108
  type PendingLocalOpMetadata = PendingKeySet | PendingKeyDelete | PendingClear;
108
109
 
109
- /**
110
- * Rough polyfill for Array.findLastIndex until we target ES2023 or greater.
111
- */
112
- const findLastIndex = <T>(array: T[], callbackFn: (value: T) => boolean): number => {
113
- for (let i = array.length - 1; i >= 0; i--) {
114
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
115
- if (callbackFn(array[i]!)) {
116
- return i;
117
- }
118
- }
119
- return -1;
120
- };
121
-
122
- /**
123
- * Rough polyfill for Array.findLast until we target ES2023 or greater.
124
- */
125
- const findLast = <T>(array: T[], callbackFn: (value: T) => boolean): T | undefined =>
126
- array[findLastIndex(array, callbackFn)];
127
-
128
110
  /**
129
111
  * A SharedMap is a map-like distributed data structure.
130
112
  */
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/map";
9
- export const pkgVersion = "2.52.0";
9
+ export const pkgVersion = "2.53.0";
package/src/utils.ts ADDED
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * Rough polyfill for Array.findLastIndex until we target ES2023 or greater.
8
+ */
9
+ export const findLastIndex = <T>(array: T[], callbackFn: (value: T) => boolean): number => {
10
+ for (let i = array.length - 1; i >= 0; i--) {
11
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
+ if (callbackFn(array[i]!)) {
13
+ return i;
14
+ }
15
+ }
16
+ return -1;
17
+ };
18
+
19
+ /**
20
+ * Rough polyfill for Array.findLast until we target ES2023 or greater.
21
+ */
22
+ export const findLast = <T>(array: T[], callbackFn: (value: T) => boolean): T | undefined =>
23
+ array[findLastIndex(array, callbackFn)];