Skip to content

BREAKING(http): rename Entity to ETagSource and calculate() to eTag() #5144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Jun 26, 2024

What's changed

The Entity interface has been renamed ETagSource, and calculate() has been renamed eTag().

Why these changes were made

These changes were made to better describe the purposes of these symbols. Previously, their names were too generic for their purposes to be immediately clear.

Migration guide

To migrate, use the ETagSource interface instead of Entity and eTag() instead of calculate().

- import { calculate, type Entity } from "@std/http/etag";
+ import { eTag, type ETagSource } from "@std/http/etag";

- const body: Entity = "hello deno!";
+ const body: ETagSource = "hello deno!";

- const etag = await calculate(body);
+ const etag = await eTag(body);

  const res = new Response(body, { headers: { etag } });

Related

Closes #5141
Closes #5140

@github-actions github-actions bot added the http label Jun 26, 2024
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.33%. Comparing base (acdea7c) to head (0b8b3ff).

Files Patch % Lines
http/file_server.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5144   +/-   ##
=======================================
  Coverage   96.33%   96.33%           
=======================================
  Files         458      458           
  Lines       37767    37767           
  Branches     5576     5576           
=======================================
  Hits        36383    36383           
  Misses       1341     1341           
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iuioiua iuioiua marked this pull request as ready for review June 26, 2024 04:56
@iuioiua iuioiua requested a review from kt3k as a code owner June 26, 2024 04:56
@timreichen
Copy link
Contributor

Web APIs have the convention of using a verb first for functions. eTag() breaks that convention. Maybe it would be better to call it calculateETag() or something similar.

@kt3k
Copy link
Member

kt3k commented Jun 26, 2024

We have many examples of functions which have the noun as its name:

Web APIs have the convention of using a verb first for functions. eTag() breaks that convention.

I don't think we have this convention in std.

@timreichen
Copy link
Contributor

Valid point, though I think just calling it eTag() doesn't provide any information on what the function actually does except it has to do something with etag. Maybe createETag() borrowed from Deno.createKv() or toETagString() borrowed from toString() would reflect better what the function does?

@kt3k
Copy link
Member

kt3k commented Jul 1, 2024

though I think just calling it eTag() doesn't provide any information on what the function actually does except it has to do something with etag.

It feels common to name the function as its returned thing. The above std functions are the examples of such naming convention.

I can also find many Web APIs named in that way:

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iuioiua iuioiua merged commit aa06ae3 into main Jul 10, 2024
13 checks passed
@iuioiua iuioiua deleted the http-etag-etagsource branch July 10, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal(http): rename Entity to ETagSource proposal(http): rename calculate to eTag
3 participants