项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

26 lines
591 B

  1. var test = require('tape')
  2. var b64 = require('../')
  3. test('convert big data to base64', function (t) {
  4. var b64str, arr, i, length
  5. var big = new Uint8Array(64 * 1024 * 1024)
  6. for (i = 0, length = big.length; i < length; ++i) {
  7. big[i] = i % 256
  8. }
  9. b64str = b64.fromByteArray(big)
  10. arr = b64.toByteArray(b64str)
  11. t.ok(equal(arr, big))
  12. t.equal(b64.byteLength(b64str), arr.length)
  13. t.end()
  14. })
  15. function equal (a, b) {
  16. var i
  17. var length = a.length
  18. if (length !== b.length) return false
  19. for (i = 0; i < length; ++i) {
  20. if (a[i] !== b[i]) return false
  21. }
  22. return true
  23. }