Skip to content

Commit

Permalink
Use includes instead of has
Browse files Browse the repository at this point in the history
  • Loading branch information
Pannatier Guillaume authored and Pannatier Guillaume committed Dec 14, 2022
1 parent 0b14a9d commit aed9912
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .changeset/late-bottles-shop.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

improve performance of `isBinaryType` in the netlify and architect adapters

previous implementation from arc itself has a complexity of O(N*includesComplexity), where as now it is O(1).
previous implementation from arc itself has a complexity of O(N*includesComplexity), where as now it is O(includesComplexity).
6 changes: 3 additions & 3 deletions packages/remix-architect/binaryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Common binary MIME types
* @see https://github.com/architect/functions/blob/45254fc1936a1794c185aac07e9889b241a2e5c6/src/http/helpers/binary-types.js
*/
const binaryTypes = new Set([
const binaryTypes = [
"application/octet-stream",
// Docs
"application/epub+zip",
Expand Down Expand Up @@ -60,10 +60,10 @@ const binaryTypes = new Set([
"application/x-tar",
"application/x-zip",
"application/zip",
]);
];

export function isBinaryType(contentType: string | null | undefined) {
if (!contentType) return false;
let [test] = contentType.split(";");
return binaryTypes.has(test);
return binaryTypes.includes(test);
}
6 changes: 3 additions & 3 deletions packages/remix-netlify/binaryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Common binary MIME types
* @see https://github.com/architect/functions/blob/45254fc1936a1794c185aac07e9889b241a2e5c6/src/http/helpers/binary-types.js
*/
const binaryTypes = new Set([
const binaryTypes = [
"application/octet-stream",
// Docs
"application/epub+zip",
Expand Down Expand Up @@ -60,10 +60,10 @@ const binaryTypes = new Set([
"application/x-tar",
"application/x-zip",
"application/zip",
]);
];

export function isBinaryType(contentType: string | null | undefined) {
if (!contentType) return false;
let [test] = contentType.split(";");
return binaryTypes.has(test);
return binaryTypes.includes(test);
}

0 comments on commit aed9912

Please sign in to comment.