File tree Expand file tree Collapse file tree 2 files changed +28
-28
lines changed
packages/workers-shared/asset-worker Expand file tree Collapse file tree 2 files changed +28
-28
lines changed Original file line number Diff line number Diff line change @@ -121,30 +121,3 @@ function comparePathHashWithEntry(
121121const Uint8ToHexString = ( array : Uint8Array ) => {
122122 return [ ...array ] . map ( ( b ) => b . toString ( 16 ) . padStart ( 2 , "0" ) ) . join ( "" ) ;
123123} ;
124-
125- /**
126- * Compare two Uint8Array values
127- * @param a First array
128- * @param b Second array
129- * @returns -1 if a < b, 1 if a > b, 0 if equal
130- */
131- export const compare = ( a : Uint8Array , b : Uint8Array ) => {
132- if ( a . byteLength < b . byteLength ) {
133- return - 1 ;
134- }
135- if ( a . byteLength > b . byteLength ) {
136- return 1 ;
137- }
138-
139- for ( const [ i , v ] of a . entries ( ) ) {
140- const bVal = b [ i ] as number ;
141- if ( v < bVal ) {
142- return - 1 ;
143- }
144- if ( v > bVal ) {
145- return 1 ;
146- }
147- }
148-
149- return 0 ;
150- } ;
Original file line number Diff line number Diff line change 66 PATH_HASH_SIZE ,
77} from "../../utils/constants" ;
88import AssetManifestFixture from "../fixtures/AssetManifest.bin" ;
9- import { binarySearch , compare , hashPath } from "../src/assets-manifest" ;
9+ import { binarySearch , hashPath } from "../src/assets-manifest" ;
1010
1111const encoder = new TextEncoder ( ) ;
1212
@@ -214,3 +214,30 @@ describe("search methods", async () => {
214214 } ) ;
215215 } ) ;
216216} ) ;
217+
218+ /**
219+ * Compare two Uint8Array values
220+ * @param a First array
221+ * @param b Second array
222+ * @returns -1 if a < b, 1 if a > b, 0 if equal
223+ */
224+ function compare ( a : Uint8Array , b : Uint8Array ) {
225+ if ( a . byteLength < b . byteLength ) {
226+ return - 1 ;
227+ }
228+ if ( a . byteLength > b . byteLength ) {
229+ return 1 ;
230+ }
231+
232+ for ( const [ i , v ] of a . entries ( ) ) {
233+ const bVal = b [ i ] as number ;
234+ if ( v < bVal ) {
235+ return - 1 ;
236+ }
237+ if ( v > bVal ) {
238+ return 1 ;
239+ }
240+ }
241+
242+ return 0 ;
243+ }
You can’t perform that action at this time.
0 commit comments