1.8.0 • Published 6 years ago

phar v1.8.0

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

Phar.js

Utilities for working with PHAR archives in JavaScipt

NPM Version NPM Downloads

Supported modules types: UMD (CommonJS + AMD), SystemJS, es2015

Install

  • NPM
npm i -S phar
  • Bower
bower i -S phar

Usage

  • Node.js (CommonJS)
const PHAR = require('phar')
// PHAR.Archive
// PHAR.File
  • Browser (RequireJS (UMD))
<script src="bower_components/phar/lib/webpack/phar"></script>
<script>
  require(['phar'], (PHAR) => {
    // PHAR.Archive
    // PHAR.File
  })
</script>
  • Loading Phar archive from contents
// Phar contents as <string> or <Uint8Array>
const phar = new PHAR.Archive();
phar.loadPharData(phar_contents);
  • Creating new Phar archive
const phar = new PHAR.Archive();
phar.setStub('<?php echo "Works!" . PHP_EOL; __HALT_COMPILER();');
phar.setSignatureType(PHAR.Signature.SHA256);
  • Adding file to Phar archive
// Phar object
const file = new PHAR.File("myName.txt", "some_contents");
phar.addFile(file);
  • Saving Phar archive to contents
// Phar object
const pharContents = phar.savePharData();
  • Converting to Zip
// Phar object
PHAR.ZipConverter.toZip(phar)
  .then((data) => {
    return data.generateAsync({
      type: 'uint8array'
    })
  })
  .then((zip) => { /* ... */ })
  • Converting from zip
PHAR.ZipConverter.toPhar(fs.readFileSync('test.zip'))
  .then((phar) => { /* ... */ })

...and more! Just look at the source.

1.8.0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

0.9.0

8 years ago