Skip to content

Commit

Permalink
standard
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Nov 11, 2020
1 parent 2de03c4 commit 34c73a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions test/big-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ const test = require('tape')
const b64 = require('../')

test('convert big data to base64', function (t) {
let b64str, arr, i, length
const big = new Uint8Array(64 * 1024 * 1024)
for (i = 0, length = big.length; i < length; ++i) {
for (let i = 0, length = big.length; i < length; ++i) {
big[i] = i % 256
}
b64str = b64.fromByteArray(big)
arr = b64.toByteArray(b64str)
const b64str = b64.fromByteArray(big)
const arr = b64.toByteArray(b64str)
t.ok(equal(arr, big))
t.equal(b64.byteLength(b64str), arr.length)
t.end()
Expand Down
7 changes: 3 additions & 4 deletions test/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ test('convert to base64 and back', function (t) {

for (let i = 0; i < checks.length; i++) {
const check = checks[i]
var b64Str, arr, str

b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0) }))
const b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0) }))

arr = b64.toByteArray(b64Str)
str = map(arr, function (byte) { return String.fromCharCode(byte) }).join('')
const arr = b64.toByteArray(b64Str)
const str = map(arr, function (byte) { return String.fromCharCode(byte) }).join('')

t.equal(check, str, 'Checked ' + check)
t.equal(b64.byteLength(b64Str), arr.length, 'Checked length for ' + check)
Expand Down
4 changes: 2 additions & 2 deletions test/url-safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ test('decode url-safe style base64 strings', function (t) {

let str = '//++/++/++//'
let actual = b64.toByteArray(str)
for (var i = 0; i < actual.length; i++) {
for (let i = 0; i < actual.length; i++) {
t.equal(actual[i], expected[i])
}

t.equal(b64.byteLength(str), actual.length)

str = '__--_--_--__'
actual = b64.toByteArray(str)
for (i = 0; i < actual.length; i++) {
for (let i = 0; i < actual.length; i++) {
t.equal(actual[i], expected[i])
}

Expand Down

0 comments on commit 34c73a8

Please sign in to comment.