Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Fix deprecation warning
Browse files Browse the repository at this point in the history
For environments which support `Buffer.allocUnsafe()`, use it instead.

https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/
  • Loading branch information
sirlancelot committed Apr 17, 2020
1 parent e59df56 commit 3fdfc10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ process_url = (url, transferredHeaders, resp, remaining_redirects) ->
# decode a string of two char hex digits
hexdec = (str) ->
if str and str.length > 0 and str.length % 2 == 0 and not str.match(/[^0-9a-f]/)
buf = new Buffer(str.length / 2)
size = str.length / 2
buf = if Buffer.allocUnsafe then Buffer.allocUnsafe(size) else new Buffer(size)
for i in [0...str.length] by 2
buf[i/2] = parseInt(str[i..i+1], 16)
buf.toString()
Expand Down
7 changes: 4 additions & 3 deletions server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3fdfc10

Please sign in to comment.