Added a browserified version (#98)

This commit is contained in:
Max Gordon 2019-03-08 06:29:59 +01:00 committed by Luke Page
parent 7acfa680b1
commit 728cc7e265
4 changed files with 774 additions and 14 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ node_modules
.idea .idea
coverage coverage
examples/*.png examples/*.png
browser\.js

View file

@ -19,13 +19,13 @@ Known lack of support for:
* Extended PNG e.g. Animation * Extended PNG e.g. Animation
* Writing in colortype 3 (indexed color) * Writing in colortype 3 (indexed color)
# Table of Contents # Table of Contents
* [Requirements](#requirements) * [Requirements](#requirements)
* [Comparison Table](#comparison-table) * [Comparison Table](#comparison-table)
* [Tests](#tests) * [Tests](#tests)
* [Installation](#installation) * [Installation](#installation)
* [Browserify](#browserify) * [Browser](#browser)
* [Example](#example) * [Example](#example)
* [Async API](#async-api) * [Async API](#async-api)
* [Sync API](#sync-api) * [Sync API](#sync-api)
@ -73,13 +73,13 @@ Installation
$ npm install pngjs --save $ npm install pngjs --save
``` ```
Browserify Browser
=========== ===========
Use [Browserify](browserify.org) to build a version of library that can run client-side: The package has been build with a [Browserify](browserify.org) version (`npm run browserify`) and you can use the browser version by including in your code:
``` ```
$ browserify lib/png.js --standalone png > bundle.js import { PNG } from 'pngjs/browser';
``` ```
Then depending on your module system you can either `require('bundle.js')` or if you're not using module loader you can use plain old `<script src="bundle.js"></script>` tag and the library will be available under `window.PNG` or just `PNG`.
Example Example
========== ==========

View file

@ -34,9 +34,14 @@
}, },
"main": "./lib/png.js", "main": "./lib/png.js",
"directories": { "directories": {
"example": "examples" "lib": "lib",
"example": "examples",
"test": "test"
}, },
"scripts": { "scripts": {
"build": "npm run prepublish",
"prepublish": "npm run browserify",
"browserify": "browserify lib/png.js --standalone png > browser.js",
"coverage": "istanbul -- cover node_modules/tape/bin/tape test/*-spec.js nolarge", "coverage": "istanbul -- cover node_modules/tape/bin/tape test/*-spec.js nolarge",
"coverage-report": "npm run coverage && istanbul report html", "coverage-report": "npm run coverage && istanbul report html",
"coveralls": "cat ./coverage/lcov.info | coveralls", "coveralls": "cat ./coverage/lcov.info | coveralls",
@ -52,6 +57,7 @@
"url": "https://github.com/lukeapage/pngjs2/issues" "url": "https://github.com/lukeapage/pngjs2/issues"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^14.5.0",
"buffer-equal": "1.0.0", "buffer-equal": "1.0.0",
"connect": "^3.4.0", "connect": "^3.4.0",
"eslint": "^3.2.2", "eslint": "^3.2.2",

767
yarn.lock

File diff suppressed because it is too large Load diff