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

add encoding/hex module #434

Merged
merged 9 commits into from Jun 17, 2019

Conversation

3 participants
@axetroy
Copy link
Contributor

commented May 22, 2019

ref: https://golang.org/pkg/encoding/hex , #431

  • decode()
  • decodeString()
  • decodeLen()
  • new Decoder() (no test case yet)
  • encode()
  • encodeToString()
  • encodeLen()
  • new Encoder() (no test case yet)
  • new Dumper()
  • dump()

axetroy added some commits May 22, 2019

Show resolved Hide resolved encoding/hex.ts Outdated
Show resolved Hide resolved encoding/hex.ts Outdated

axetroy added some commits May 23, 2019

@ry

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2019

@axetroy what's the status of this PR? Is it ready?

* DecodeString returns the bytes represented by the hexadecimal string `s`.
* DecodeString expects that src contains only hexadecimal characters and that src has even length.
* If the input is malformed, DecodeString will throws an error.
* @param s

This comment has been minimized.

Copy link
@kitsonk

kitsonk Jun 6, 2019

Contributor

You only need to add this if you are actually going to add a comment about the argument, otherwise I would just omit it as it adds nothing.

@axetroy

This comment has been minimized.

Copy link
Contributor Author

commented Jun 6, 2019

@axetroy what's the status of this PR? Is it ready?

The Encoder/Decoder class is not ready yet. Everything else has been tested.

merge the part of hex module first and the rest are waiting for other modules to be completed.

So I think it is ready for review.

@axetroy axetroy marked this pull request as ready for review Jun 6, 2019

@ry
Copy link
Contributor

left a comment

Cool - looks good - just a few comments

// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// import { copyBytes } from "../io/util.ts";

This comment has been minimized.

Copy link
@ry

ry Jun 6, 2019

Contributor

Remove dead code

// import { copyBytes } from "../io/util.ts";

const hextable = new TextEncoder().encode("0123456789abcdef");
// const bufferSize = 1024;

This comment has been minimized.

Copy link
@ry

ry Jun 6, 2019

Contributor

dead code


/**
* Encode encodes `src` into `encodedLen(src.length)` bytes of `dst`.
* As a convenience, it returns the number of bytes written to `dst`, but this value is always `encodedLen(src.length)`.

This comment has been minimized.

Copy link
@ry

ry Jun 6, 2019

Contributor

wrap at 80 columns

for (let i = 0; i < src.length; i++) {
const v = src[i];
dst[i * 2] = hextable[v >> 4];
dst[i * 2 + 1] = hextable[v & 0x0f];

This comment has been minimized.

Copy link
@ry

// return n;
// }
// }

This comment has been minimized.

Copy link
@ry

ry Jun 6, 2019

Contributor

Remove dead code

@ry

ry approved these changes Jun 17, 2019

Copy link
Contributor

left a comment

LGTM - thanks!

@ry ry merged commit 418cdff into denoland:master Jun 17, 2019

5 checks passed

denoland.deno_std Build #20190616.1 succeeded
Details
denoland.deno_std (Linux) Linux succeeded
Details
denoland.deno_std (Mac) Mac succeeded
Details
denoland.deno_std (Windows) Windows succeeded
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.