Skip to content

Add atob/btoa based on base64-js #776

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 3 commits into from
Sep 20, 2018
Merged

Conversation

kevinkassimo
Copy link
Contributor

Related to #775 . Uses base64-js for implementation (pure JS/TS)

There is still another option: use a polyfill version, which might be more lightweighted.

js/errors.ts Outdated
super(msg);
this.name = "InvalidCharacterError";
}
}
Copy link
Member

@ry ry Sep 20, 2018

Choose a reason for hiding this comment

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

Either add the new error to the ErrorKind enum

deno/src/msg.fbs

Lines 29 to 73 in 52d4155

enum ErrorKind: byte {
NoError = 0,
// io errors
NotFound,
PermissionDenied,
ConnectionRefused,
ConnectionReset,
ConnectionAborted,
NotConnected,
AddrInUse,
AddrNotAvailable,
BrokenPipe,
AlreadyExists,
WouldBlock,
InvalidInput,
InvalidData,
TimedOut,
Interrupted,
WriteZero,
Other,
UnexpectedEof,
// url errors
EmptyHost,
IdnaError,
InvalidPort,
InvalidIpv4Address,
InvalidIpv6Address,
InvalidDomainCharacter,
RelativeUrlWithoutBase,
RelativeUrlWithCannotBeABaseBase,
SetHostOnCannotBeABaseUrl,
Overflow,
// hyper errors
HttpUser,
HttpClosed,
HttpCanceled,
HttpParse,
HttpOther,
}

Or (ideally) reuse one of the existing codes. Maybe

InvalidInput,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chose to reuse InvalidInput

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Looks good - one comment

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 4d16d54 into denoland:master Sep 20, 2018
}
let result = "";
for (let i = 0; i < byteArray.length; i++) {
result += String.fromCharCode(byteArray[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it better for performance to push to an array and join?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually just saw an interesting benchmark on this, and by running on both Safari and Chrome, it seems for V8 string concat is faster, while JavaScriptCore runs join with better performance. There is a stackoverflow thread that discuss the internals, though it might be dated and not true any more

ry added a commit to ry/deno that referenced this pull request Sep 22, 2018
- Add atob() btoa() denoland#776
- Add deno.arch deno.platform denoland#773
- Add deno.symlink() and deno.symlinkSync() denoland#742
- Add deno.mkdir() and deno.mkdirSync() denoland#746
- Add deno.makeTempDir() denoland#740
- Improvements to FileInfo interface denoland#765, denoland#761
- Add fetch.blob()
- Upgrade V8 to 7.0.276.15
- Upgrade Rust crates
@ry ry mentioned this pull request Sep 22, 2018
ry added a commit that referenced this pull request Sep 22, 2018
- Add atob() btoa() #776
- Add deno.arch deno.platform #773
- Add deno.symlink() and deno.symlinkSync() #742
- Add deno.mkdir() and deno.mkdirSync() #746
- Add deno.makeTempDir() #740
- Improvements to FileInfo interface #765, #761
- Add fetch.blob()
- Upgrade V8 to 7.0.276.15
- Upgrade Rust crates
@kevinkassimo kevinkassimo deleted the encoding/base64-js branch December 27, 2019 07:50
hardfist pushed a commit to hardfist/deno that referenced this pull request Aug 7, 2024
…and#772)" (denoland#776)

This reverts commit 98d52cf.

CC @littledivy I had trouble updating `deno_core` in Deno as it died on
`node_unit_tests::vm_test`
with signal 11 during `vm context promise rejection` test. Also
`Box<Rc<...>>` seems fishy as pointed
as by @dsherret in
denoland/deno_core#775 (comment)
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.

3 participants