photopea / UZIP.js

Simple ZIPping library for Javascript
MIT License
187 stars 27 forks source link

nodejs module export #3

Closed SheetJSDev closed 5 years ago

SheetJSDev commented 6 years ago

A one-line change makes this library usable in nodejs without breaking browser usage. This PR adds that line.

In current node versions, Buffer extends Uint8Array, so the following works:

var UZIP = require("uzip");
var zip = UZIP.parse(fs.readFileSync("sheetjs.xlsx"));
Object.keys(zip); // list of entries
Buffer.from(zip['[Content_Types].xml']).toString() // contents of `[Content_Types].xml` as text

In addition, there were some trailing whitespace characters that were removed. A proper lint configuration (like jscs/jshint or eslint) is probably a good idea.

We also took the liberty of publishing "version 0.0.0" to npm: https://www.npmjs.com/package/uzip . NPM user ~photopea has been added as an owner, feel free to remove ~sheetjs from the owner list using the npm owner CLI command.

torch2424 commented 6 years ago

Definitely reccomend updating this project on npm. Super lightweight and very awesome 👍

Would be cool to wrap it up in rollup as well.

photopea commented 5 years ago

This version is out of date with my local version, so I will discard it.