1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-07-06 19:00:50 +00:00
This commit is contained in:
MatteZ02
2019-05-30 12:06:47 +03:00
parent cbdffcf19c
commit 5eb0264906
2502 changed files with 360854 additions and 0 deletions

25
node_modules/base64-js/test/big-data.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
var test = require('tape')
var b64 = require('../')
test('convert big data to base64', function (t) {
var b64str, arr, i, length
var big = new Uint8Array(64 * 1024 * 1024)
for (i = 0, length = big.length; i < length; ++i) {
big[i] = i % 256
}
b64str = b64.fromByteArray(big)
arr = b64.toByteArray(b64str)
t.ok(equal(arr, big))
t.equal(b64.byteLength(b64str), arr.length)
t.end()
})
function equal (a, b) {
var i
var length = a.length
if (length !== b.length) return false
for (i = 0; i < length; ++i) {
if (a[i] !== b[i]) return false
}
return true
}

88
node_modules/base64-js/test/convert.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
var test = require('tape')
var b64 = require('../')
var checks = [
'a',
'aa',
'aaa',
'hi',
'hi!',
'hi!!',
'sup',
'sup?',
'sup?!'
]
test('convert to base64 and back', function (t) {
t.plan(checks.length * 2)
for (var i = 0; i < checks.length; i++) {
var check = checks[i]
var b64Str, arr, str
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('')
t.equal(check, str, 'Checked ' + check)
t.equal(b64.byteLength(b64Str), arr.length, 'Checked length for ' + check)
}
})
var data = [
[[0, 0, 0], 'AAAA'],
[[0, 0, 1], 'AAAB'],
[[0, 1, -1], 'AAH/'],
[[1, 1, 1], 'AQEB'],
[[0, -73, 23], 'ALcX']
]
test('convert known data to string', function (t) {
for (var i = 0; i < data.length; i++) {
var bytes = data[i][0]
var expected = data[i][1]
var actual = b64.fromByteArray(bytes)
t.equal(actual, expected, 'Ensure that ' + bytes + ' serialise to ' + expected)
}
t.end()
})
test('convert known data from string', function (t) {
for (var i = 0; i < data.length; i++) {
var expected = data[i][0]
var string = data[i][1]
var actual = b64.toByteArray(string)
t.ok(equal(actual, expected), 'Ensure that ' + string + ' deserialise to ' + expected)
var length = b64.byteLength(string)
t.equal(length, expected.length, 'Ensure that ' + string + ' has byte lentgh of ' + expected.length)
}
t.end()
})
function equal (a, b) {
var i
var length = a.length
if (length !== b.length) return false
for (i = 0; i < length; ++i) {
if ((a[i] & 0xFF) !== (b[i] & 0xFF)) return false
}
return true
}
function map (arr, callback) {
var res = []
var kValue, mappedValue
for (var k = 0, len = arr.length; k < len; k++) {
if ((typeof arr === 'string' && !!arr.charAt(k))) {
kValue = arr.charAt(k)
mappedValue = callback(kValue, k, arr)
res[k] = mappedValue
} else if (typeof arr !== 'string' && k in arr) {
kValue = arr[k]
mappedValue = callback(kValue, k, arr)
res[k] = mappedValue
}
}
return res
}

10
node_modules/base64-js/test/corrupt.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
var test = require('tape')
var b64 = require('../')
test('padding bytes found inside base64 string', function (t) {
// See https://github.com/beatgammit/base64-js/issues/42
var str = 'SQ==QU0='
t.deepEqual(b64.toByteArray(str), new Uint8Array([73]))
t.equal(b64.byteLength(str), 1)
t.end()
})

24
node_modules/base64-js/test/url-safe.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
var test = require('tape')
var b64 = require('../')
test('decode url-safe style base64 strings', function (t) {
var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]
var str = '//++/++/++//'
var actual = b64.toByteArray(str)
for (var 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++) {
t.equal(actual[i], expected[i])
}
t.equal(b64.byteLength(str), actual.length)
t.end()
})