Skip to content
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

feat: hybrid cjs and esm support #82

Merged
merged 6 commits into from
Jun 22, 2024
Merged

Conversation

Nesopie
Copy link
Contributor

@Nesopie Nesopie commented Jun 16, 2024

This PR adds support for cjs and esm modules.

ts_src/index.ts Outdated
@@ -26,8 +26,7 @@ function base (ALPHABET: string): base.BaseConverter {
const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up

function encode (source: Uint8Array | number[]): string {
if (source instanceof Uint8Array) {
} else if (ArrayBuffer.isView(source)) {
if (ArrayBuffer.isView(source)) {
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this was originally poorly written, but this change makes the code different.

What if source is BOTH Uint8Array AND one of the other else if?

If you are 100% confident that these conditions will never overlap in any JS runtime ever, then maybe this is OK. But I would rather just leave it as is... or at least re-write it with the same semantic meaning... like wrapping the whole if else chain with a negation of the empty if.

Copy link
Contributor Author

@Nesopie Nesopie Jun 16, 2024

Choose a reason for hiding this comment

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

Actually, I'm wondering if I should remove the first if statement (ArrayBuffer one). The function just accepts Uint8Array | number[] clearly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted back to the original code

@junderw junderw requested a review from fanatid June 16, 2024 12:55
@junderw
Copy link
Member

junderw commented Jun 16, 2024

npm v6 doesn't support "lockfileVersion": 3

with:
node-version: 12
node-version: 17
Copy link
Member

Choose a reason for hiding this comment

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

The commit says 18 but it's 17 (EOL)

@junderw junderw merged commit 223252c into cryptocoinjs:master Jun 22, 2024
3 checks passed
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.

2 participants