Skip to content

feat!: implement with unjs template #3

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nozomuikuta
Copy link

@nozomuikuta nozomuikuta commented Jan 18, 2023

No related PRs.

I applied unjs/template to this repository.

⚠️ This PR includes breaking changes:

  • Return type of serial is now Promise<unknown> (as far as I research, there is no way to exactly infer type of the last result). Treating it as unknown is for safety (cf. any). I added "escape hatch" to its typing (i.e. second type argument), for cases where developer is sure what is return type of the function.
const tasks = [1, "2", 3, 4];

const result = await serial(tasks, (task, previous) => {
  return Promise.resolve(Number(task) + Number(/* unknown */ previous === null ? 0 : previous));
});

const result = await serial<(number | string)[], number>(tasks, (task, previous) => {
  return Promise.resolve(Number(task) + Number(/* number | null */ previous === null ? 0 : previous));
});

Please close this PR with a message if it is not needed to "unjs-nize" the repository, or is there any other way I can contribute?

@nozomuikuta nozomuikuta self-assigned this Jan 18, 2023
@codecov
Copy link

codecov bot commented Jan 18, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@f951c3a). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff            @@
##             main        #3   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         1           
  Lines           ?        20           
  Branches        ?         7           
========================================
  Hits            ?        20           
  Misses          ?         0           
  Partials        ?         0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines +5 to +6
/* eslint-disable-next-line unicorn/no-null */
let promise = fn(firstTask, null);
Copy link
Author

Choose a reason for hiding this comment

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

Should I pass undefined instead?

Comment on lines +6 to +8
"contributors": [
"Nozomu Ikuta <[email protected]>"
],
Copy link
Author

Choose a reason for hiding this comment

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

Of course, only if you are fine.

@nozomuikuta
Copy link
Author

nozomuikuta commented Jan 24, 2023

📝 Applied unjs/template (until 070b86f)

@nozomuikuta nozomuikuta requested a review from pi0 January 24, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant