Skip to content

Commit

Permalink
Updating / fixing bugs / adding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Vilk committed Nov 5, 2016
1 parent 73c9481 commit 218877d
Show file tree
Hide file tree
Showing 88 changed files with 4,876 additions and 7,427 deletions.
30 changes: 30 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip filter=lfs diff=lfs merge=lfs -text
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/src/*.js
^/src/macros.js
/node_modules
.vscode
/dist
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/test
.vscode
37 changes: 0 additions & 37 deletions .vscode/launch.json

This file was deleted.

131 changes: 0 additions & 131 deletions .vscode/tasks.json

This file was deleted.

52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
## `decompress-implode`: EXPLODE implementation in JavaScript
# BrowserFS ZipFS Extras

A direct port of Info-Zip's EXPLODE algorithm to JavaScript. [Based on the version in this release of Info-Zip.](https://downloads.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz)
Adds the following decompression algorithms to BrowserFS, which were used in
older versions of PKZip:

It appears to work, but I need some test files that exercise the code base!
* EXPLODE and UNSHRINK (ported from Info-Zip's GPL2'd code)
* UNREDUCE (ported from [this GPL2 code](http://aluigi.altervista.org/papers/unreduce.c))

Prereqs:
Although BrowserFS is licensed under the MIT license, this add-on library is
based on GPL2 code and is provided under the GPL2 license.

## Using

### Browser

Simply include [browserfs.js](https://github.com/jvilk/browserfs) and `browserfs-zipfs-extras.js` on the same page, and BrowserFS will know how to decompress these extra algorithms.
Make sure you include `browserfs.js` *first*.

### Node

Add both `browserfs` and `browserfs-zipfs-extras` as dependencies of your project. Then, simply `require` `browserfs-zipfs-extras` before you begin using `browserfs`.

```javascript
const BrowserFS = require('browserfs');
require('browserfs-zipfs-extras');
// Now you can use BrowserFS.
```
$ npm i -g typescript sweet.js
$ # In Git repository directory
$ npm install
```

Building:
## Building

Requires a reasonably recent version of Node. Run:

```
$ tsc
$ sjs -m ./macros/macros.js ./build/explode.js -o ./build/explode.js
$ npm install
```

...or simply run `./make.sh`
## Running Tests

Running:
**NOTE: You must have [Git LFS](https://git-lfs.github.com/) installed and use it to clone the repository.**
We use Git LFS to manage our test fixtures, which are a bunch of zip files.

```
$ node build/extract.js [path to zip file] [file to extract]
$ npm test
```

Porting Comments:
## Porting Comments

We emulate pointers and pointer arithmetic with the `Ptr` `class`, which
takes an array and an offset into the array. `extract.ts` and `inflate.ts`
Expand All @@ -36,7 +52,5 @@ to iterate through table values!

To reduce object allocations, most `Ptr` manipulations edit the value of
an existing `Ptr` rather than create a new one. As a result, developers
must be cognizant of `Ptr` aliasing; if two places contain the same `Ptr`
object, then manipulating one will change the other!

It's possible that this is the current source of a bug.
maintaining this project must be cognizant of `Ptr` aliasing; if two places
contain the same `Ptr` object, then manipulating one will change the other!
49 changes: 49 additions & 0 deletions karma.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';
const detectBrowsers = require('detect-browsers');
const seenBrowsers = {};
const isTravis = process.env.TRAVIS;
// Browser detection does not work properly on Travis.
const installedBrowsers = isTravis ? ['Firefox'] : detectBrowsers.getInstalledBrowsers()
.map(function(browser) { return browser.name; })
.filter(function(browser) {
if (seenBrowsers[browser]) {
return false;
} else {
seenBrowsers[browser] = true;
return true;
}
});

module.exports = function(configSetter) {
configSetter.set({
basePath: __dirname,
frameworks: ['mocha'],
files: [
{pattern: 'test/fixtures/**/*', included: false},
'node_modules/browserfs/dist/browserfs.js',
'dist/browserfs-zipfs-extras.js',
'node_modules/js-crc/build/crc.min.js',
'build/test/index.js'
],
exclude: [],
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: 'INFO',
autoWatch: true,
concurrency: 1,
browsers: installedBrowsers,
captureTimeout: 60000,
singleRun: false,
urlRoot: '/',
browserNoActivityTimeout: 30000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
client: {
mocha: {
// Stop tests after first failure.
bail: true
}
}
});
};
4 changes: 0 additions & 4 deletions make.sh

This file was deleted.

Loading

0 comments on commit 218877d

Please sign in to comment.