tinytar-fix
Version:
Pure javascript implementation of POSIX TAR file format.
61 lines (59 loc) • 1.43 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TinyTAR Example</title>
</head>
<body>
<h1>TinyTAR Example</h1>
<p>Open a console and press the button:</p>
<p><button type="button" onclick="createTar()">Create TAR</button></p>
<script type="text/javascript" src="../dist/tinytar.js"></script>
<script type="text/javascript">
function createTar() {
console.time('Creating TAR');
var data = tinyTar.tar([
{
name: 'dir/test.txt',
data: 'Hello, world!'
},
{
name: 'test.json',
data: JSON.stringify({
title: 'test file',
author: 'Levko Kravets'
}),
prefix: 'dir'
},
{
name: 'a.txt',
data: { // 'Hello'
0: 72,
1: 101,
2: 108,
3: 108,
4: 111,
length: 5
}
},
{
name: 'long.txt',
data: (function() {
var result = '';
for (var i = 0; i < 3000; i++) {
result += 'abcdefg'.charAt(i % 7);
}
return result;
})()
},
{
name: 'b.txt',
data: new Uint16Array([101 * 256 + 72, 111 * 256 + 108]) // 'Helo'
}
]);
console.timeEnd('Creating TAR');
console.log(data);
}
</script>
</body>
</html>