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
Merged

add encoding/hex module #434

merged 9 commits into from
Jun 17, 2019

Conversation

axetroy
Copy link
Contributor

@axetroy axetroy 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()

encoding/hex.ts Outdated Show resolved Hide resolved
encoding/hex.ts Outdated Show resolved Hide resolved
@ry
Copy link
Member

ry commented Jun 5, 2019

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

encoding/hex.ts Outdated
* 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
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor Author

axetroy 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 June 6, 2019 03:22
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.

Cool - looks good - just a few comments

encoding/hex.ts Outdated
// 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";
Copy link
Member

Choose a reason for hiding this comment

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

Remove dead code

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

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

Choose a reason for hiding this comment

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

dead code

encoding/hex.ts Outdated

/**
* 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)`.
Copy link
Member

Choose a reason for hiding this comment

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

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];
Copy link
Member

Choose a reason for hiding this comment

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

encoding/hex.ts Outdated

// return n;
// }
// }
Copy link
Member

Choose a reason for hiding this comment

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

Remove dead code

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 - thanks!

@ry ry merged commit 418cdff into denoland:master Jun 17, 2019
ry pushed a commit to ry/deno that referenced this pull request Oct 9, 2019
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