Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a39df508
Unverified
Commit
a39df508
authored
Mar 07, 2023
by
JJ Kasper
Committed by
GitHub
Mar 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove extra exports from filter utils (#46860)
These utilities aren't needed so can be removed
parent
8f5ffed7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
74 deletions
+0
-74
utils.ts
packages/next/src/shared/lib/bloom-filter/utils.ts
+0
-74
No files found.
packages/next/src/shared/lib/bloom-filter/utils.ts
View file @
a39df508
...
@@ -61,34 +61,6 @@ export interface TwoHashesIntAndString {
...
@@ -61,34 +61,6 @@ export interface TwoHashesIntAndString {
*/
*/
export
type
HashableInput
=
string
|
ArrayBuffer
|
Buffer
export
type
HashableInput
=
string
|
ArrayBuffer
|
Buffer
/**
* BufferError
*/
export
const
BufferError
=
'The buffer class must be available, if you are a browser user use the buffer package (https://www.npmjs.com/package/buffer)'
/**
* Create a new array fill with a base value
* @param size - The size of the array
* @param defaultValue - The default value used to fill the array. If it's a function, it will be invoked to get the default value.
* @return A newly allocated array
* @memberof Utils
*/
export
function
allocateArray
<
T
>
(
size
:
number
,
defaultValue
:
T
|
(()
=>
T
)
):
Array
<
T
>
{
const
array
:
Array
<
T
>
=
new
Array
<
T
>
(
size
)
const
getDefault
=
typeof
defaultValue
===
'function'
?
(
defaultValue
as
()
=>
T
)
:
()
=>
defaultValue
for
(
let
ind
=
0
;
ind
<
size
;
ind
++
)
{
array
[
ind
]
=
getDefault
()
}
return
array
}
/**
/**
* Return a number to its Hex format by padding zeroes if length mod 4 != 0
* Return a number to its Hex format by padding zeroes if length mod 4 != 0
* @param elem the element to transform in HEX
* @param elem the element to transform in HEX
...
@@ -125,52 +97,6 @@ export function randomInt(
...
@@ -125,52 +97,6 @@ export function randomInt(
return
Math
.
floor
(
rn
*
(
max
-
min
+
1
))
+
min
return
Math
.
floor
(
rn
*
(
max
-
min
+
1
))
+
min
}
}
/**
* Return the non-destructive XOR of two buffers
* @param a - The buffer to copy, then to xor with b
* @param b - The buffer to xor with
* @return The results of the XOR between the two buffers
* @author Arnaud Grall
*/
export
function
xorBuffer
(
a
:
Buffer
,
b
:
Buffer
):
Buffer
{
const
length
=
Math
.
max
(
a
.
length
,
b
.
length
)
const
buffer
=
Buffer
.
allocUnsafe
(
length
).
fill
(
0
)
for
(
let
i
=
0
;
i
<
length
;
++
i
)
{
if
(
i
<
a
.
length
&&
i
<
b
.
length
)
{
buffer
[
length
-
i
-
1
]
=
a
[
a
.
length
-
i
-
1
]
^
b
[
b
.
length
-
i
-
1
]
}
else
if
(
i
<
a
.
length
&&
i
>=
b
.
length
)
{
buffer
[
length
-
i
-
1
]
^=
a
[
a
.
length
-
i
-
1
]
}
else
if
(
i
<
b
.
length
&&
i
>=
a
.
length
)
{
buffer
[
length
-
i
-
1
]
^=
b
[
b
.
length
-
i
-
1
]
}
}
// now need to remove leading zeros in the buffer if any
let
start
=
0
const
it
=
buffer
.
values
()
let
value
=
it
.
next
()
while
(
!
value
.
done
&&
value
.
value
===
0
)
{
start
++
value
=
it
.
next
()
}
return
buffer
.
slice
(
start
)
}
/**
* Return true if the buffer is empty, i.e., all value are equals to 0.
* @param buffer - The buffer to inspect
* @return True if the buffer only contains zero, False otherwise
* @author Arnaud Grall
*/
export
function
isEmptyBuffer
(
buffer
:
Buffer
|
null
):
boolean
{
if
(
buffer
===
null
||
!
buffer
)
return
true
for
(
const
value
of
buffer
)
{
if
(
value
!==
0
)
{
return
false
}
}
return
true
}
/**
/**
* Return the default seed used in the package
* Return the default seed used in the package
* @return A seed as a floating point number
* @return A seed as a floating point number
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment