Removed require-kiss dependency in favor of pakmanager

This commit is contained in:
Jameson Little 2011-10-28 18:04:25 -06:00
parent f28fe10f6b
commit 5bdc55ed37
8 changed files with 53 additions and 52 deletions

View file

@ -17,14 +17,14 @@ Dependencies
Tar needs an HTML5 compliant browser. More specifically it needs `Uint8Array` to work.
The only external module is require-kiss, which makes browser JS much more Node-like.
The examples depend on pakmanager, a package manager for the browser to make code written for node run in the browser. Install it as such:
This module can be installed from npm (`npm install require-kiss`) or directly downloaded from github (https://github.com/coolaj86/require-kiss-js).
`pakmanager build`
Usage Guide
===========
In your HTML file, make sure that require-kiss is included first. Then, to use it, do something like this:
The easiest way to interface with it is by using pakmanager. Include the package from pakmanager in your html, and then in you javascript:
var Tar = require('tar'),
tape = new Tar();

View file

@ -3,41 +3,7 @@
<head>
<title>Browser Tar</title>
<script src='../node_modules/require-kiss/require-kiss.js'></script>
<script src='../lib/utils.js'></script>
<script src='../lib/header.js'></script>
<script src='../lib/tar.js'></script>
<script>
(function () {
"use strict";
var Tar = require('tar'),
utils = require('utils'),
tape = new Tar(),
out,
url,
base64;
function uint8ToString(buf) {
var i, length, out = '';
for (i = 0, length = buf.length; i < length; i += 1) {
out += String.fromCharCode(buf[i]);
}
return out;
}
out = tape.append('output.txt', 'This is test1!');
out = tape.append('dir/out.txt', 'This is test2! I changed up the directory');
out = tape.append('arr.txt', utils.stringToUint8('This is a Uint8Array!'));
base64 = btoa(uint8ToString(out));
url = "data:application/tar;base64," + base64;
window.open(url);
}());
</script>
<script src='./pakmanaged.js'></script>
</head>
<body>

38
examples/main.js Normal file
View file

@ -0,0 +1,38 @@
(function () {
"use strict";
var Tar = require('tar-js'),
tape = new Tar(),
out,
url,
base64;
function uint8ToString(buf) {
var i, length, out = '';
for (i = 0, length = buf.length; i < length; i += 1) {
out += String.fromCharCode(buf[i]);
}
return out;
}
function stringToUint8 (input) {
var out = new Uint8Array(input.length), i;
for (i = 0; i < input.length; i += 1) {
out[i] = input.charCodeAt(i);
}
return out;
}
out = tape.append('output.txt', 'This is test1!');
out = tape.append('dir/out.txt', 'This is test2! I changed up the directory');
out = tape.append('arr.txt', stringToUint8('This is a Uint8Array!'));
base64 = btoa(uint8ToString(out));
url = "data:application/tar;base64," + base64;
window.open(url);
}());

10
examples/package.json Normal file
View file

@ -0,0 +1,10 @@
{
"author": "",
"name": "tar-example",
"engines": {
"node": "~0.4.7"
},
"main": "./main.js",
"dependencies": {
}
}

View file

@ -6,8 +6,6 @@
(function () {
"use strict";
require('require-kiss');
/*
struct posix_header { // byte offset
char name[100]; // 0
@ -124,6 +122,4 @@ struct posix_header { // byte offset
module.exports.structure = headerFormat;
module.exports.format = formatHeader;
provide('header', module.exports);
}());

View file

@ -6,8 +6,6 @@
(function () {
"use strict";
require('require-kiss');
var header = require("./header"),
utils = require("./utils"),
recordSize = 512,
@ -109,6 +107,4 @@
};
module.exports = Tar;
provide('tar', module.exports);
}());

View file

@ -6,8 +6,6 @@
(function () {
"use strict";
require('require-kiss');
var lookup = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
@ -90,6 +88,4 @@
module.exports.extend = extend;
module.exports.stringToUint8 = stringToUint8;
module.exports.uint8ToBase64 = uint8ToBase64;
provide('utils');
}());

View file

@ -1,7 +1,7 @@
{
"name": "tar-js",
"description": "Tar implemented in the browser",
"version": "0.1.1",
"version": "0.2.0",
"homepage": "http://github.com/beatgammit/tar-js",
"repository": {
"type": "git",
@ -14,6 +14,5 @@
"lib": "lib"
},
"dependencies": {
"require-kiss": "*"
}
}