diff --git a/.source.1499879393800.0.5760841517536723.html b/.source.1499879393800.0.5760841517536723.html new file mode 100644 index 00000000..89380eee --- /dev/null +++ b/.source.1499879393800.0.5760841517536723.html @@ -0,0 +1,37567 @@ + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a64b1aa2..6a47c883 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,23 @@ language: node_js node_js: - '4' - '5' + - '6' + - '7' # Node.js 7 is most stable version env: - CXX=g++-4.8 -script: npm test +before_script: + - npm install grunt-cli -g # for "grunt build" +script: + - npm test + - grunt build addons: apt: sources: - ubuntu-toolchain-r-test packages: - g++-4.8 + - xvfb # for tape-run +install: + - export DISPLAY=':99.0' # for tape-run + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & # for tape-run + - npm install # for tape-run diff --git a/README.md b/README.md index 57fd2f28..455bd259 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Image Sequencer aka "Consequencer" -[![Build Status](https://travis-ci.org/jywarren/image-sequencer.svg?branch=master)](https://travis-ci.org/jywarren/image-sequencer) +[![Build Status](https://travis-ci.org/publiclab/image-sequencer.svg?branch=master)](https://travis-ci.org/publiclab/image-sequencer) ## Why @@ -26,8 +26,31 @@ It is also for prototyping some other related ideas: * [Basic example](https://jywarren.github.io/image-sequencer/) * [NDVI example](https://jywarren.github.io/image-sequencer/examples/ndvi/) - related to [Infragram.org](http://infragram.org) -## Using the library: +## Quick Usage +Image Sequencer can be used to run modules on an HTML Image Element using the +`replaceImage` method. The method accepts two parameters - `selector` and `steps`. +`selector` is a CSS selector. If it matches multiple images, all images will be +modified. `steps` may be the name of a module or array of names of modules. + +Note: Browser CORS Restrictions apply. Some browsers may not allow local images +form other folders, and throw a Security Error instead. + +```js + sequencer.replaceImage(selector,steps,optional_options); +``` + +`optional_options` allows to pass additional arguments to the module itself. + +For example: + +```js + sequencer.replaceImage('#photo','invert'); + sequencer.replaceImage('#photo',['invert','ndvi-red']); +``` + + +## Classic Usage ### Initializing the Sequencer @@ -37,11 +60,137 @@ The Image Sequencer Library exports a function ImageSequencer which initializes var sequencer = ImageSequencer(); ``` -### Loading Images into the Sequencer +### Loading an Image into the Sequencer -Image Sequencer has an array of images which gets stored in `sequencer.images` in this case. -Images can be loaded into this array by the method `loadImages`. -loadImages accepts 1, 2, or 3 parameters. +The `loadImage` method is used to load an image into the sequencer. It accepts +a name and an image. The method also accepts an optional callback. + +```js +sequencer.loadImage(image_src,optional_callback); +``` +On `Node.js` the `image_src` may be a DataURI or a local path. On browsers, it +must be a DatURI (or 'selector to image' -- Work in Progress) + +return value: **`sequencer`** (To allow method chaining) + + +### Adding steps to the image + +The `addSteps` method is used to add steps on the image. One or more steps can +be added at a time. Each step is called a module. + +```js +sequencer.addSteps(modules, optional_options); +``` + +If only one module is to be added, `modules` is simply the name of the module. +If multiple images are to be added, `modules` is an array of the names of modules +which are to be added, in that particular order. + +optional_otions is just additional parameters, in object form, which you might +want to provide to the modules. It's an optional parameter. + +return value: **`sequencer`** (To allow method chaining) + + +### Running the Sequencer + +Once all steps are added, This method is used to generate the output of all these +modules. + +```js +sequencer.run(); +``` + +Additionally, an optional callback can be passed to this method. + +```js +sequencer.run(function(out){ + // this gets called back. + // "out" is the DataURL of the final image. +}); +``` + +return value: **`sequencer`** (To allow method chaining) + + +### Removing a step from the sequencer + +The `removeSteps` method is used to remove unwanted steps from the sequencer. +It accepts the index of the step as an input, or an array of the unwanted indices +if there are more than one. + +For example, if the modules ['ndvi-red','crop','invert'] were added in this order, +and I wanted to remove 'crop' and 'invert', I can either do this: +```js +sequencer.removeSteps(2); +sequencer.removeSteps(3); +``` +or: +```js +sequencer.removeSteps([2,3]); +``` + +return value: **`sequencer`** (To allow method chaining) + + +### Inserting a step in between the sequencer + +The `insertSteps` method can be used to insert one or more steps at a given index +in the sequencer. It accepts the index where the module is to be inserted, name of +the module, and an optional options parameter. `index` is the index of the inserted +step. Only one step can be inserted at a time. `optional_options` plays the same +role it played in `addSteps`. + +Indexes can be negative. Negative sign with an index means that counting will be +done in reverse order. If the index is out of bounds, the counting will wrap in +the original direction of counting. So, an `index` of -1 means that the module is +inserted at the end. + +```js +sequencer.insertSteps(index,module_name,optional_options); +``` + +return value: **`sequencer`** (To allow method chaining) + + +## Method Chaining +Methods can be chained on the Image Sequencer: +* run() can not be in the middle of the chain. +* If the chain starts with loadImage() or loadImages(), the following methods are +applied only to the newly loaded images. +* If no name is provided to the image, a name will be generated for it. The name will +be of the form "image". For ex: "image1", "image2", "image3", etc. + +Valid Chains: +```js +sequencer.loadImage('red').addSteps('invert').run(function(out){ + //do something with otuput. +}); +sequencer.addSteps(['ndvi-red','invert']).run(); +et cetra. +``` + +Invalid Chains: +```js +sequencer.addSteps('invert').run().addSteps('ndvi-red'); +``` + + +## Multiple Images +Image Sequencer is capable of handling multiple images at once. + +### Initializing a sequencer with multiple images. +This is just like before. +```js +var sequencer = ImageSequencer(); +``` + +### Loading Multiple Images into the Sequencer + +Multiple images can be loaded by the method `loadImages`. Everything is the same, +except that now, a unique identification called `image_name` has to be provided +with each image. This is a string literal. * 3/2 parameters : ```js @@ -52,19 +201,22 @@ loadImages accepts 1, 2, or 3 parameters. ```js sequencer.loadImages({ images: { - image_name_1: image_src, - image_name_2: image_src, + image1_name: image_src, + image2_name: image_src, ... }, callback: optional_callback }); ``` -### Adding Steps on Images +return value: **`sequencer`** (To allow method chaining) -After loading the image, we can add modules to the image using the addSteps method. -The options argument (object) is an optional parameter to pass in arguments to the module. -In all the following examples, `image_name` and `module_name` may be a string or an array of strings. + +### Adding Steps on Multiple Images + +The same method `addSteps` is used for this. There's just a slight obvious change +in the syntax that the image name has to be supplied too. `image_name` as well as +`module_name` in the following examples can be either strings or arrays of strings. ```js sequencer.addSteps(image_name,module_name,optional_options); @@ -80,53 +232,81 @@ All this can be passed in as JSON: ```js sequencer.addSteps({ - image_name: {name: module_name, o: optional_options}, - image_name: {name: module_name, o: optional_options}, + image1_name: {name: module_name, o: optional_options}, + image2_name: {name: module_name, o: optional_options}, ... }); ``` -### Running the Sequencer +return value: **`sequencer`** (To allow method chaining) -After adding the steps, now we must generate output for each of the step via the `run` method. -The `run` method accepts parameters `image` and `from`. -`from` is the index from where the function starts generating output. By default, it will run across all the steps. (from = 1) If no image is specified, the sequencer will be run over all the images. + +### Running a Sequencer with multiple images + +The same `run` method can be used with a slight change in syntax. +The `run` method accepts parameters `image` and `from`. `from` is the index from +where the function starts generating output. By default, it will run across all +the steps. (from = 1) If no image is specified, the sequencer will be run over **all +the images**. `image_name` may be an array of image names. ```js sequencer.run(); //All images from first step ``` ```js -sequencer.run(image,from); //Image 'image' from 'from' +sequencer.run(image_name,from); //Image 'image' from 'from' ``` -image may either be an array or a string. -An optional callback may also be passed. - -### Removing Steps from an Image - -Steps can be removed using the `removeSteps` method. It accepts `image` and `index` as parameters. -Either, both, or none of them can be an array. JSON input is also accepted. +The `run` method also accepts an optional callback just like before: ```js -sequencer.removeSteps("image",[steps]); + sequencer.run(image_name,from,function(out){ + // This gets called back. + // "out" is the DataURL of final image. + }); ``` -```js -sequencer.removeSteps("image",step); -``` +JSON Input is also acceptable. ```js -sequencer.removeSteps({ - image: [steps], - image: [steps], +sequencer.run({ + image1_name: from, + image2_name: from, ... }); ``` +return value: **`sequencer`** (To allow method chaining) + + +### Removing Steps from an Image + +Similarly, `removeSteps` can also accept an `image_name` parameter. Either, both, +or none of `image_name` and `steps` them may be an array. JSON input is also acceptable. + +```js +sequencer.removeSteps("image_name",[steps]); +``` + +```js +sequencer.removeSteps("image_name",step); +``` + +```js +sequencer.removeSteps({ + image1_name: [steps], + image2_name: [steps], + ... +}); +``` +return value: **`sequencer`** (To allow method chaining) + + ### Inserting steps on an image -Steps can be inserted using the `insertSteps` method. It accepts `image`, `index`, `module_name` and `optional_options` as parameters. `image` may be an array. `optional_options` is an object. The rest are literals. JSON Input is supported too. If no image is provided, Steps will be inserted on all images. Indexes can be negative. Negative sign with an index means that counting will be done in reverse order. If the index is out of bounds, the counting will wrap in the original direction of counting. +The `insertSteps` method can also accept an `image_name` parameter. `image_name` +may be an array. Everything else remains the same. JSON Inout is acceptable too. + ```js sequencer.insertSteps("image",index,"module_name",o); ``` @@ -142,6 +322,7 @@ sequencer.insertSteps({ ] }); ``` +return value: **`sequencer`** (To allow method chaining) ## Contributing @@ -214,16 +395,16 @@ Notes on development next steps: ### Modularization * [ ] remotely includable modules, not compiled in -- see plugin structures in other libs -* [ ] ability to start running at any point -- already works? -* [ ] commandline runnability? - * [ ] Make available as browserified OR `require()` includable... +* [x] ability to start running at any point -- already works? +* [x] commandline runnability? + * [x] Make available as browserified OR `require()` includable... * [ ] standardize panel addition with submodule that offers Panel.display(image) * [ ] allow passing data as data-uri or Image object, or stream, or ndarray or ImageData array, if both of neighboring pair has ability? * see https://github.com/jywarren/image-sequencer/issues/1 * [ ] ...could we directly include package.json for module descriptions? At least as a fallback. * [ ] (for node-and-line style UIs) non-linear sequences with Y-splitters * [ ] `sequencer.addModule('path/to/module.js')` style module addition -- also to avoid browserifying all of Plotly :-P -* [ ] remove step +* [x] remove step ### Testing @@ -237,7 +418,7 @@ Notes on development next steps: ### Bugs -* [ ] BUG: this doesn't work for defaults: imageboard.loadImage('examples/grid.png', function() { +* [x] BUG: this doesn't work for defaults: imageboard.loadImage('examples/grid.png', function() {}); * we should make defaults a config of the first module **** diff --git a/dist/image-sequencer.css b/dist/image-sequencer.css index ffd9fb97..7547cad2 100644 --- a/dist/image-sequencer.css +++ b/dist/image-sequencer.css @@ -1,6 +1,6 @@ /* https://github.com/theleagueof/league-spartan */ -@font-face { +/*@font-face { font-family: 'League Spartan'; src: url('https://raw.githubusercontent.com/theleagueof/league-spartan/master/_webfonts/leaguespartan-bold.eot'); src: url('https://raw.githubusercontent.com/theleagueof/league-spartan/master/_webfonts/leaguespartan-bold.eot?#iefix') format('embedded-opentype'), @@ -10,7 +10,7 @@ url('https://raw.githubusercontent.com/theleagueof/league-spartan/master/_webfonts/leaguespartan-bold.svg#league_spartanbold') format('svg'); font-weight: bold; font-style: normal; -} +}*/ body { padding: 20px; diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index 981f32c4..92a4e574 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -395,22 +395,22 @@ function placeHoldersCount (b64) { function byteLength (b64) { // base64 is 4/3 + up to two characters of the original data - return b64.length * 3 / 4 - placeHoldersCount(b64) + return (b64.length * 3 / 4) - placeHoldersCount(b64) } function toByteArray (b64) { - var i, j, l, tmp, placeHolders, arr + var i, l, tmp, placeHolders, arr var len = b64.length placeHolders = placeHoldersCount(b64) - arr = new Arr(len * 3 / 4 - placeHolders) + arr = new Arr((len * 3 / 4) - placeHolders) // if there are placeholders, only get up to the last complete 4 chars l = placeHolders > 0 ? len - 4 : len var L = 0 - for (i = 0, j = 0; i < l; i += 4, j += 3) { + for (i = 0; i < l; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] arr[L++] = (tmp >> 16) & 0xFF arr[L++] = (tmp >> 8) & 0xFF @@ -895,7 +895,7 @@ Zlib.prototype._error = function(status) { exports.Zlib = Zlib; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":87,"buffer":10,"pako/lib/zlib/constants":55,"pako/lib/zlib/deflate.js":57,"pako/lib/zlib/inflate.js":59,"pako/lib/zlib/messages":61,"pako/lib/zlib/zstream":63}],8:[function(require,module,exports){ +},{"_process":86,"buffer":10,"pako/lib/zlib/constants":54,"pako/lib/zlib/deflate.js":56,"pako/lib/zlib/inflate.js":58,"pako/lib/zlib/messages":60,"pako/lib/zlib/zstream":62}],8:[function(require,module,exports){ (function (process,Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -1509,7 +1509,7 @@ util.inherits(InflateRaw, Zlib); util.inherits(Unzip, Zlib); }).call(this,require('_process'),require("buffer").Buffer) -},{"./binding":7,"_process":87,"_stream_transform":98,"assert":1,"buffer":10,"util":113}],9:[function(require,module,exports){ +},{"./binding":7,"_process":86,"_stream_transform":98,"assert":1,"buffer":10,"util":113}],9:[function(require,module,exports){ arguments[4][6][0].apply(exports,arguments) },{"dup":6}],10:[function(require,module,exports){ (function (global){ @@ -3304,7 +3304,7 @@ function isnan (val) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"base64-js":2,"ieee754":40,"isarray":11}],11:[function(require,module,exports){ +},{"base64-js":2,"ieee754":39,"isarray":11}],11:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { @@ -3312,118 +3312,6 @@ module.exports = Array.isArray || function (arr) { }; },{}],12:[function(require,module,exports){ -(function (global){ -'use strict'; - -var buffer = require('buffer'); -var Buffer = buffer.Buffer; -var SlowBuffer = buffer.SlowBuffer; -var MAX_LEN = buffer.kMaxLength || 2147483647; -exports.alloc = function alloc(size, fill, encoding) { - if (typeof Buffer.alloc === 'function') { - return Buffer.alloc(size, fill, encoding); - } - if (typeof encoding === 'number') { - throw new TypeError('encoding must not be number'); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size > MAX_LEN) { - throw new RangeError('size is too large'); - } - var enc = encoding; - var _fill = fill; - if (_fill === undefined) { - enc = undefined; - _fill = 0; - } - var buf = new Buffer(size); - if (typeof _fill === 'string') { - var fillBuf = new Buffer(_fill, enc); - var flen = fillBuf.length; - var i = -1; - while (++i < size) { - buf[i] = fillBuf[i % flen]; - } - } else { - buf.fill(_fill); - } - return buf; -} -exports.allocUnsafe = function allocUnsafe(size) { - if (typeof Buffer.allocUnsafe === 'function') { - return Buffer.allocUnsafe(size); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size > MAX_LEN) { - throw new RangeError('size is too large'); - } - return new Buffer(size); -} -exports.from = function from(value, encodingOrOffset, length) { - if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) { - return Buffer.from(value, encodingOrOffset, length); - } - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number'); - } - if (typeof value === 'string') { - return new Buffer(value, encodingOrOffset); - } - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - var offset = encodingOrOffset; - if (arguments.length === 1) { - return new Buffer(value); - } - if (typeof offset === 'undefined') { - offset = 0; - } - var len = length; - if (typeof len === 'undefined') { - len = value.byteLength - offset; - } - if (offset >= value.byteLength) { - throw new RangeError('\'offset\' is out of bounds'); - } - if (len > value.byteLength - offset) { - throw new RangeError('\'length\' is out of bounds'); - } - return new Buffer(value.slice(offset, offset + len)); - } - if (Buffer.isBuffer(value)) { - var out = new Buffer(value.length); - value.copy(out, 0, 0, value.length); - return out; - } - if (value) { - if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) { - return new Buffer(value); - } - if (value.type === 'Buffer' && Array.isArray(value.data)) { - return new Buffer(value.data); - } - } - - throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.'); -} -exports.allocUnsafeSlow = function allocUnsafeSlow(size) { - if (typeof Buffer.allocUnsafeSlow === 'function') { - return Buffer.allocUnsafeSlow(size); - } - if (typeof size !== 'number') { - throw new TypeError('size must be a number'); - } - if (size >= MAX_LEN) { - throw new RangeError('size is too large'); - } - return new SlowBuffer(size); -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"buffer":10}],13:[function(require,module,exports){ (function (Buffer){ /**! * contentstream - index.js @@ -3472,12 +3360,12 @@ ContentStream.prototype._read = function (n) { }; }).call(this,require("buffer").Buffer) -},{"buffer":10,"readable-stream":20,"util":113}],14:[function(require,module,exports){ +},{"buffer":10,"readable-stream":19,"util":113}],13:[function(require,module,exports){ module.exports = Array.isArray || function (arr) { return Object.prototype.toString.call(arr) == '[object Array]'; }; -},{}],15:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -3570,7 +3458,7 @@ function forEach (xs, f) { } }).call(this,require('_process')) -},{"./_stream_readable":17,"./_stream_writable":19,"_process":87,"core-util-is":22,"inherits":41}],16:[function(require,module,exports){ +},{"./_stream_readable":16,"./_stream_writable":18,"_process":86,"core-util-is":21,"inherits":40}],15:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -3618,7 +3506,7 @@ PassThrough.prototype._transform = function(chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":18,"core-util-is":22,"inherits":41}],17:[function(require,module,exports){ +},{"./_stream_transform":17,"core-util-is":21,"inherits":40}],16:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -4604,7 +4492,7 @@ function indexOf (xs, x) { } }).call(this,require('_process')) -},{"_process":87,"buffer":10,"core-util-is":22,"events":27,"inherits":41,"isarray":14,"stream":105,"string_decoder/":21}],18:[function(require,module,exports){ +},{"_process":86,"buffer":10,"core-util-is":21,"events":26,"inherits":40,"isarray":13,"stream":105,"string_decoder/":20}],17:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -4816,7 +4704,7 @@ function done(stream, er) { return stream.push(null); } -},{"./_stream_duplex":15,"core-util-is":22,"inherits":41}],19:[function(require,module,exports){ +},{"./_stream_duplex":14,"core-util-is":21,"inherits":40}],18:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -5206,7 +5094,7 @@ function endWritable(stream, state, cb) { } }).call(this,require('_process')) -},{"./_stream_duplex":15,"_process":87,"buffer":10,"core-util-is":22,"inherits":41,"stream":105}],20:[function(require,module,exports){ +},{"./_stream_duplex":14,"_process":86,"buffer":10,"core-util-is":21,"inherits":40,"stream":105}],19:[function(require,module,exports){ (function (process){ var Stream = require('stream'); // hack to fix a circular dependency issue when used with browserify exports = module.exports = require('./lib/_stream_readable.js'); @@ -5221,7 +5109,7 @@ if (!process.browser && process.env.READABLE_STREAM === 'disable') { } }).call(this,require('_process')) -},{"./lib/_stream_duplex.js":15,"./lib/_stream_passthrough.js":16,"./lib/_stream_readable.js":17,"./lib/_stream_transform.js":18,"./lib/_stream_writable.js":19,"_process":87,"stream":105}],21:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":14,"./lib/_stream_passthrough.js":15,"./lib/_stream_readable.js":16,"./lib/_stream_transform.js":17,"./lib/_stream_writable.js":18,"_process":86,"stream":105}],20:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -5444,7 +5332,7 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":10}],22:[function(require,module,exports){ +},{"buffer":10}],21:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -5555,7 +5443,7 @@ function objectToString(o) { } }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":43}],23:[function(require,module,exports){ +},{"../../is-buffer/index.js":42}],22:[function(require,module,exports){ "use strict" var createThunk = require("./lib/thunk.js") @@ -5666,7 +5554,7 @@ function compileCwise(user_args) { module.exports = compileCwise -},{"./lib/thunk.js":25}],24:[function(require,module,exports){ +},{"./lib/thunk.js":24}],23:[function(require,module,exports){ "use strict" var uniq = require("uniq") @@ -6026,7 +5914,7 @@ function generateCWiseOp(proc, typesig) { } module.exports = generateCWiseOp -},{"uniq":108}],25:[function(require,module,exports){ +},{"uniq":108}],24:[function(require,module,exports){ "use strict" // The function below is called when constructing a cwise function object, and does the following: @@ -6114,7 +6002,7 @@ function createThunk(proc) { module.exports = createThunk -},{"./compile.js":24}],26:[function(require,module,exports){ +},{"./compile.js":23}],25:[function(require,module,exports){ (function (Buffer){ /** @@ -6172,7 +6060,7 @@ function dataUriToBuffer (uri) { } }).call(this,require("buffer").Buffer) -},{"buffer":10}],27:[function(require,module,exports){ +},{"buffer":10}],26:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6476,7 +6364,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],28:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ (function (Buffer,process){ 'use strict' @@ -6614,7 +6502,7 @@ module.exports = function getPixels(url, type, cb) { } } }).call(this,{"isBuffer":require("../is-buffer/index.js")},require('_process')) -},{"../is-buffer/index.js":43,"_process":87,"data-uri-to-buffer":26,"ndarray":51,"ndarray-pack":49,"omggif":52,"path":64,"through":107}],29:[function(require,module,exports){ +},{"../is-buffer/index.js":42,"_process":86,"data-uri-to-buffer":25,"ndarray":50,"ndarray-pack":48,"omggif":51,"path":63,"through":107}],28:[function(require,module,exports){ (function (Buffer){ /* GIFEncoder.js @@ -7087,7 +6975,7 @@ GIFEncoder.ByteCapacitor = ByteCapacitor; module.exports = GIFEncoder; }).call(this,require("buffer").Buffer) -},{"./LZWEncoder.js":30,"./TypedNeuQuant.js":31,"assert":1,"buffer":10,"events":27,"readable-stream":38,"util":113}],30:[function(require,module,exports){ +},{"./LZWEncoder.js":29,"./TypedNeuQuant.js":30,"assert":1,"buffer":10,"events":26,"readable-stream":37,"util":113}],29:[function(require,module,exports){ /* LZWEncoder.js @@ -7301,7 +7189,7 @@ function LZWEncoder(width, height, pixels, colorDepth) { module.exports = LZWEncoder; -},{}],31:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ /* NeuQuant Neural-Net Quantization Algorithm * ------------------------------------------ * @@ -7734,13 +7622,13 @@ function NeuQuant(pixels, samplefac) { module.exports = NeuQuant; -},{}],32:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ +arguments[4][13][0].apply(exports,arguments) +},{"dup":13}],32:[function(require,module,exports){ arguments[4][14][0].apply(exports,arguments) -},{"dup":14}],33:[function(require,module,exports){ +},{"./_stream_readable":34,"./_stream_writable":36,"_process":86,"core-util-is":21,"dup":14,"inherits":40}],33:[function(require,module,exports){ arguments[4][15][0].apply(exports,arguments) -},{"./_stream_readable":35,"./_stream_writable":37,"_process":87,"core-util-is":22,"dup":15,"inherits":41}],34:[function(require,module,exports){ -arguments[4][16][0].apply(exports,arguments) -},{"./_stream_transform":36,"core-util-is":22,"dup":16,"inherits":41}],35:[function(require,module,exports){ +},{"./_stream_transform":35,"core-util-is":21,"dup":15,"inherits":40}],34:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -8695,7 +8583,7 @@ function indexOf (xs, x) { } }).call(this,require('_process')) -},{"./_stream_duplex":33,"_process":87,"buffer":10,"core-util-is":22,"events":27,"inherits":41,"isarray":32,"stream":105,"string_decoder/":39,"util":6}],36:[function(require,module,exports){ +},{"./_stream_duplex":32,"_process":86,"buffer":10,"core-util-is":21,"events":26,"inherits":40,"isarray":31,"stream":105,"string_decoder/":38,"util":6}],35:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -8906,7 +8794,7 @@ function done(stream, er) { return stream.push(null); } -},{"./_stream_duplex":33,"core-util-is":22,"inherits":41}],37:[function(require,module,exports){ +},{"./_stream_duplex":32,"core-util-is":21,"inherits":40}],36:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -9387,7 +9275,7 @@ function endWritable(stream, state, cb) { } }).call(this,require('_process')) -},{"./_stream_duplex":33,"_process":87,"buffer":10,"core-util-is":22,"inherits":41,"stream":105}],38:[function(require,module,exports){ +},{"./_stream_duplex":32,"_process":86,"buffer":10,"core-util-is":21,"inherits":40,"stream":105}],37:[function(require,module,exports){ (function (process){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = require('stream'); @@ -9401,9 +9289,9 @@ if (!process.browser && process.env.READABLE_STREAM === 'disable') { } }).call(this,require('_process')) -},{"./lib/_stream_duplex.js":33,"./lib/_stream_passthrough.js":34,"./lib/_stream_readable.js":35,"./lib/_stream_transform.js":36,"./lib/_stream_writable.js":37,"_process":87,"stream":105}],39:[function(require,module,exports){ -arguments[4][21][0].apply(exports,arguments) -},{"buffer":10,"dup":21}],40:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":32,"./lib/_stream_passthrough.js":33,"./lib/_stream_readable.js":34,"./lib/_stream_transform.js":35,"./lib/_stream_writable.js":36,"_process":86,"stream":105}],38:[function(require,module,exports){ +arguments[4][20][0].apply(exports,arguments) +},{"buffer":10,"dup":20}],39:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -9489,7 +9377,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],41:[function(require,module,exports){ +},{}],40:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -9514,7 +9402,7 @@ if (typeof Object.create === 'function') { } } -},{}],42:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ "use strict" function iota(n) { @@ -9526,7 +9414,7 @@ function iota(n) { } module.exports = iota -},{}],43:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -9549,9 +9437,9 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],44:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ arguments[4][11][0].apply(exports,arguments) -},{"dup":11}],45:[function(require,module,exports){ +},{"dup":11}],44:[function(require,module,exports){ /*! * jQuery JavaScript Library v2.2.4 * http://jquery.com/ @@ -19367,7 +19255,7 @@ if ( !noGlobal ) { return jQuery; })); -},{}],46:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ (function (process){ var path = require('path'); var fs = require('fs'); @@ -19479,10 +19367,10 @@ mime.charsets = { module.exports = mime; }).call(this,require('_process')) -},{"./types.json":47,"_process":87,"fs":9,"path":64}],47:[function(require,module,exports){ +},{"./types.json":46,"_process":86,"fs":9,"path":63}],46:[function(require,module,exports){ module.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/bdoc":["bdoc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["exe"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["3gpp"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp3":["mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/wav":["wav"],"audio/wave":["wav"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["ra"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/apng":["apng"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["bmp"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/mathml":["mml"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/rtf":["rtf"],"text/sgml":["sgml","sgm"],"text/slim":["slim","slm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/xml":["xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]} -},{}],48:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict" var compile = require("cwise-compiler") @@ -19945,7 +19833,7 @@ exports.equals = compile({ -},{"cwise-compiler":23}],49:[function(require,module,exports){ +},{"cwise-compiler":22}],48:[function(require,module,exports){ "use strict" var ndarray = require("ndarray") @@ -19968,10 +19856,10 @@ module.exports = function convert(arr, result) { return result } -},{"./doConvert.js":50,"ndarray":51}],50:[function(require,module,exports){ +},{"./doConvert.js":49,"ndarray":50}],49:[function(require,module,exports){ module.exports=require('cwise-compiler')({"args":["array","scalar","index"],"pre":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"body":{"body":"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}","args":[{"name":"_inline_1_arg0_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_1_arg1_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_1_arg2_","lvalue":false,"rvalue":true,"count":4}],"thisVars":[],"localVars":["_inline_1_i","_inline_1_v"]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"funcName":"convert","blockSize":64}) -},{"cwise-compiler":23}],51:[function(require,module,exports){ +},{"cwise-compiler":22}],50:[function(require,module,exports){ var iota = require("iota-array") var isBuffer = require("is-buffer") @@ -20316,7 +20204,7 @@ function wrappedNDArrayCtor(data, shape, stride, offset) { module.exports = wrappedNDArrayCtor -},{"iota-array":42,"is-buffer":43}],52:[function(require,module,exports){ +},{"iota-array":41,"is-buffer":42}],51:[function(require,module,exports){ // (c) Dean McNamee , 2013. // // https://github.com/deanm/omggif @@ -21100,7 +20988,7 @@ function GifReaderLZWOutputIndexStream(code_stream, p, output, output_length) { try { exports.GifWriter = GifWriter; exports.GifReader = GifReader } catch(e) { } // CommonJS. -},{}],53:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ 'use strict'; @@ -21204,7 +21092,7 @@ exports.setTyped = function (on) { exports.setTyped(TYPED_OK); -},{}],54:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ 'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6. @@ -21238,7 +21126,7 @@ function adler32(adler, buf, len, pos) { module.exports = adler32; -},{}],55:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ 'use strict'; @@ -21290,7 +21178,7 @@ module.exports = { //Z_NULL: null // Use -1 or null inline, depending on var type }; -},{}],56:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ 'use strict'; // Note: we can't get significant speed boost here. @@ -21333,7 +21221,7 @@ function crc32(crc, buf, len, pos) { module.exports = crc32; -},{}],57:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ 'use strict'; var utils = require('../utils/common'); @@ -23190,7 +23078,7 @@ exports.deflatePrime = deflatePrime; exports.deflateTune = deflateTune; */ -},{"../utils/common":53,"./adler32":54,"./crc32":56,"./messages":61,"./trees":62}],58:[function(require,module,exports){ +},{"../utils/common":52,"./adler32":53,"./crc32":55,"./messages":60,"./trees":61}],57:[function(require,module,exports){ 'use strict'; // See state defs from inflate.js @@ -23518,7 +23406,7 @@ module.exports = function inflate_fast(strm, start) { return; }; -},{}],59:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ 'use strict'; @@ -25058,7 +24946,7 @@ exports.inflateSyncPoint = inflateSyncPoint; exports.inflateUndermine = inflateUndermine; */ -},{"../utils/common":53,"./adler32":54,"./crc32":56,"./inffast":58,"./inftrees":60}],60:[function(require,module,exports){ +},{"../utils/common":52,"./adler32":53,"./crc32":55,"./inffast":57,"./inftrees":59}],59:[function(require,module,exports){ 'use strict'; @@ -25387,7 +25275,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 0; }; -},{"../utils/common":53}],61:[function(require,module,exports){ +},{"../utils/common":52}],60:[function(require,module,exports){ 'use strict'; module.exports = { @@ -25402,7 +25290,7 @@ module.exports = { '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ }; -},{}],62:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ 'use strict'; @@ -26606,7 +26494,7 @@ exports._tr_flush_block = _tr_flush_block; exports._tr_tally = _tr_tally; exports._tr_align = _tr_align; -},{"../utils/common":53}],63:[function(require,module,exports){ +},{"../utils/common":52}],62:[function(require,module,exports){ 'use strict'; @@ -26637,7 +26525,7 @@ function ZStream() { module.exports = ZStream; -},{}],64:[function(require,module,exports){ +},{}],63:[function(require,module,exports){ (function (process){ // Copyright Joyent, Inc. and other Node contributors. // @@ -26865,7 +26753,7 @@ var substr = 'ab'.substr(-1) === 'b' ; }).call(this,require('_process')) -},{"_process":87}],65:[function(require,module,exports){ +},{"_process":86}],64:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27061,7 +26949,7 @@ exports.dataToBitMap = function(data, bitmapInfo) { }; }).call(this,require("buffer").Buffer) -},{"./interlace":75,"buffer":10}],66:[function(require,module,exports){ +},{"./interlace":74,"buffer":10}],65:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27129,7 +27017,7 @@ module.exports = function(data, width, height, options) { }; }).call(this,require("buffer").Buffer) -},{"./constants":68,"buffer":10}],67:[function(require,module,exports){ +},{"./constants":67,"buffer":10}],66:[function(require,module,exports){ (function (process,Buffer){ 'use strict'; @@ -27342,7 +27230,7 @@ ChunkStream.prototype._process = function() { }; }).call(this,require('_process'),require("buffer").Buffer) -},{"_process":87,"buffer":10,"stream":105,"util":113}],68:[function(require,module,exports){ +},{"_process":86,"buffer":10,"stream":105,"util":113}],67:[function(require,module,exports){ 'use strict'; @@ -27378,7 +27266,7 @@ module.exports = { GAMMA_DIVISION: 100000 }; -},{}],69:[function(require,module,exports){ +},{}],68:[function(require,module,exports){ 'use strict'; var crcTable = []; @@ -27424,7 +27312,7 @@ CrcCalculator.crc32 = function(buf) { return crc ^ -1; }; -},{}],70:[function(require,module,exports){ +},{}],69:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27611,7 +27499,7 @@ module.exports = function(pxData, width, height, options, bpp) { }; }).call(this,require("buffer").Buffer) -},{"./paeth-predictor":79,"buffer":10}],71:[function(require,module,exports){ +},{"./paeth-predictor":78,"buffer":10}],70:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27640,7 +27528,7 @@ var FilterAsync = module.exports = function(bitmapInfo) { util.inherits(FilterAsync, ChunkStream); }).call(this,require("buffer").Buffer) -},{"./chunkstream":67,"./filter-parse":73,"buffer":10,"util":113}],72:[function(require,module,exports){ +},{"./chunkstream":66,"./filter-parse":72,"buffer":10,"util":113}],71:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27667,7 +27555,7 @@ exports.process = function(inBuffer, bitmapInfo) { return Buffer.concat(outBuffers); }; }).call(this,require("buffer").Buffer) -},{"./filter-parse":73,"./sync-reader":85,"buffer":10}],73:[function(require,module,exports){ +},{"./filter-parse":72,"./sync-reader":84,"buffer":10}],72:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27842,7 +27730,7 @@ Filter.prototype._reverseFilterLine = function(rawData) { }; }).call(this,require("buffer").Buffer) -},{"./interlace":75,"./paeth-predictor":79,"buffer":10}],74:[function(require,module,exports){ +},{"./interlace":74,"./paeth-predictor":78,"buffer":10}],73:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -27935,7 +27823,7 @@ module.exports = function(indata, imageData) { }; }).call(this,require("buffer").Buffer) -},{"buffer":10}],75:[function(require,module,exports){ +},{"buffer":10}],74:[function(require,module,exports){ 'use strict'; // Adam 7 @@ -28023,7 +27911,7 @@ exports.getInterlaceIterator = function(width) { return (outerX * 4) + (outerY * width * 4); }; }; -},{}],76:[function(require,module,exports){ +},{}],75:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -28072,7 +27960,7 @@ PackerAsync.prototype.pack = function(data, width, height, gamma) { }; }).call(this,require("buffer").Buffer) -},{"./constants":68,"./packer":78,"buffer":10,"stream":105,"util":113}],77:[function(require,module,exports){ +},{"./constants":67,"./packer":77,"buffer":10,"stream":105,"util":113}],76:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -28124,7 +28012,7 @@ module.exports = function(metaData, opt) { }; }).call(this,require("buffer").Buffer) -},{"./constants":68,"./packer":78,"buffer":10,"zlib":8}],78:[function(require,module,exports){ +},{"./constants":67,"./packer":77,"buffer":10,"zlib":8}],77:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -28219,7 +28107,7 @@ Packer.prototype.packIEND = function() { return this._packChunk(constants.TYPE_IEND, null); }; }).call(this,require("buffer").Buffer) -},{"./bitpacker":66,"./constants":68,"./crc":69,"./filter-pack":70,"buffer":10,"zlib":8}],79:[function(require,module,exports){ +},{"./bitpacker":65,"./constants":67,"./crc":68,"./filter-pack":69,"buffer":10,"zlib":8}],78:[function(require,module,exports){ 'use strict'; module.exports = function paethPredictor(left, above, upLeft) { @@ -28237,7 +28125,7 @@ module.exports = function paethPredictor(left, above, upLeft) { } return upLeft; }; -},{}],80:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ 'use strict'; var util = require('util'); @@ -28349,7 +28237,7 @@ ParserAsync.prototype._complete = function(filteredData) { this.emit('parsed', normalisedBitmapData); }; -},{"./bitmapper":65,"./chunkstream":67,"./filter-parse-async":71,"./format-normaliser":74,"./parser":82,"util":113,"zlib":8}],81:[function(require,module,exports){ +},{"./bitmapper":64,"./chunkstream":66,"./filter-parse-async":70,"./format-normaliser":73,"./parser":81,"util":113,"zlib":8}],80:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -28444,7 +28332,7 @@ module.exports = function(buffer, options) { }; }).call(this,require("buffer").Buffer) -},{"./bitmapper":65,"./filter-parse-sync":72,"./format-normaliser":74,"./parser":82,"./sync-reader":85,"buffer":10,"zlib":8}],82:[function(require,module,exports){ +},{"./bitmapper":64,"./filter-parse-sync":71,"./format-normaliser":73,"./parser":81,"./sync-reader":84,"buffer":10,"zlib":8}],81:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -28738,7 +28626,7 @@ Parser.prototype._parseIEND = function(data) { }; }).call(this,require("buffer").Buffer) -},{"./constants":68,"./crc":69,"buffer":10}],83:[function(require,module,exports){ +},{"./constants":67,"./crc":68,"buffer":10}],82:[function(require,module,exports){ 'use strict'; @@ -28756,7 +28644,7 @@ exports.write = function(png) { return pack(png); }; -},{"./packer-sync":77,"./parser-sync":81}],84:[function(require,module,exports){ +},{"./packer-sync":76,"./parser-sync":80}],83:[function(require,module,exports){ (function (process,Buffer){ 'use strict'; @@ -28923,7 +28811,7 @@ PNG.prototype.adjustGamma = function() { }; }).call(this,require('_process'),require("buffer").Buffer) -},{"./packer-async":76,"./parser-async":80,"./png-sync":83,"_process":87,"buffer":10,"stream":105,"util":113}],85:[function(require,module,exports){ +},{"./packer-async":75,"./parser-async":79,"./png-sync":82,"_process":86,"buffer":10,"stream":105,"util":113}],84:[function(require,module,exports){ 'use strict'; var SyncReader = module.exports = function(buffer) { @@ -28976,7 +28864,7 @@ SyncReader.prototype.process = function() { }; -},{}],86:[function(require,module,exports){ +},{}],85:[function(require,module,exports){ (function (process){ 'use strict'; @@ -29023,7 +28911,7 @@ function nextTick(fn, arg1, arg2, arg3) { } }).call(this,require('_process')) -},{"_process":87}],87:[function(require,module,exports){ +},{"_process":86}],86:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -29209,10 +29097,31 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],88:[function(require,module,exports){ +},{}],87:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); -},{"./lib/_stream_duplex.js":89}],89:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":88}],88:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from @@ -29222,6 +29131,10 @@ module.exports = require('./lib/_stream_duplex.js'); /**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { @@ -29232,10 +29145,6 @@ var objectKeys = Object.keys || function (obj) { module.exports = Duplex; -/**/ -var processNextTick = require('process-nextick-args'); -/**/ - /**/ var util = require('core-util-is'); util.inherits = require('inherits'); @@ -29283,12 +29192,61 @@ function onEndNT(self) { self.end(); } +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + processNextTick(cb, err); +}; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); } } -},{"./_stream_readable":91,"./_stream_writable":93,"core-util-is":22,"inherits":41,"process-nextick-args":86}],90:[function(require,module,exports){ +},{"./_stream_readable":90,"./_stream_writable":92,"core-util-is":21,"inherits":40,"process-nextick-args":85}],89:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. @@ -29315,16 +29273,38 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":92,"core-util-is":22,"inherits":41}],91:[function(require,module,exports){ -(function (process){ +},{"./_stream_transform":91,"core-util-is":21,"inherits":40}],90:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + 'use strict'; -module.exports = Readable; - /**/ + var processNextTick = require('process-nextick-args'); /**/ +module.exports = Readable; + /**/ var isArray = require('isarray'); /**/ @@ -29347,9 +29327,17 @@ var EElistenerCount = function (emitter, type) { var Stream = require('./internal/streams/stream'); /**/ -var Buffer = require('buffer').Buffer; +// TODO(bmeurer): Change this back to const once hole checks are +// properly optimized away early in Ignition+TurboFan. /**/ -var bufferShim = require('buffer-shims'); +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} /**/ /**/ @@ -29368,6 +29356,7 @@ if (debugUtil && debugUtil.debuglog) { /**/ var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); var StringDecoder; util.inherits(Readable, Stream); @@ -29406,7 +29395,7 @@ function ReadableState(options, stream) { this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~~this.highWaterMark; + this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than @@ -29420,10 +29409,10 @@ function ReadableState(options, stream) { this.endEmitted = false; this.reading = false; - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. this.sync = true; // whenever we return null, then we set a flag to say @@ -29433,15 +29422,14 @@ function ReadableState(options, stream) { this.readableListening = false; this.resumeScheduled = false; + // has it been destroyed + this.destroyed = false; + // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. this.defaultEncoding = options.defaultEncoding || 'utf8'; - // when piping, we only care about 'readable' events that happen - // after read()ing all the bytes and not getting any pushback. - this.ranOut = false; - // the number of writers that are awaiting a drain event in .pipe()s this.awaitDrain = 0; @@ -29467,87 +29455,129 @@ function Readable(options) { // legacy this.readable = true; - if (options && typeof options.read === 'function') this._read = options.read; + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } Stream.call(this); } +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; + var skipChunkCheck; - if (!state.objectMode && typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = bufferShim.from(chunk, encoding); - encoding = ''; + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; } + } else { + skipChunkCheck = true; } - return readableAddChunk(this, state, chunk, encoding, false); + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); }; // Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { - var state = this._readableState; - return readableAddChunk(this, state, chunk, '', true); + return readableAddChunk(this, chunk, null, true, false); }; -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; - -function readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (chunk === null) { +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { state.reading = false; onEofChunk(stream, state); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (state.ended && !addToFront) { - var e = new Error('stream.push() after EOF'); - stream.emit('error', e); - } else if (state.endEmitted && addToFront) { - var _e = new Error('stream.unshift() after end event'); - stream.emit('error', _e); - } else { - var skipAdd; - if (state.decoder && !addToFront && !encoding) { - chunk = state.decoder.write(chunk); - skipAdd = !state.objectMode && chunk.length === 0; + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); } - if (!addToFront) state.reading = false; - - // Don't add to the buffer if we've decoded to an empty string chunk and - // we're not in object mode - if (!skipAdd) { - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - - if (state.needReadable) emitReadable(stream); + addChunk(stream, state, chunk, false); } } - - maybeReadMore(stream, state); + } else if (!addToFront) { + state.reading = false; } - } else if (!addToFront) { - state.reading = false; } return needMoreData(state); } +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + // if it's past the high water mark, we can push in some more. // Also, if we have no data yet, we can stand some // more bytes. This is to work around cases where hwm=0, @@ -29559,6 +29589,10 @@ function needMoreData(state) { return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + // backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; @@ -29707,14 +29741,6 @@ Readable.prototype.read = function (n) { return ret; }; -function chunkInvalid(state, chunk) { - var er = null; - if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} - function onEofChunk(stream, state) { if (state.ended) return; if (state.decoder) { @@ -29802,14 +29828,17 @@ Readable.prototype.pipe = function (dest, pipeOpts) { var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : cleanup; + var endFn = doEnd ? onend : unpipe; if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); - function onunpipe(readable) { + function onunpipe(readable, unpipeInfo) { debug('onunpipe'); if (readable === src) { - cleanup(); + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } } } @@ -29835,7 +29864,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) { dest.removeListener('error', onerror); dest.removeListener('unpipe', onunpipe); src.removeListener('end', onend); - src.removeListener('end', cleanup); + src.removeListener('end', unpipe); src.removeListener('data', ondata); cleanedUp = true; @@ -29928,6 +29957,7 @@ function pipeOnDrain(src) { Readable.prototype.unpipe = function (dest) { var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; // if we're not piping anywhere, then do nothing. if (state.pipesCount === 0) return this; @@ -29943,7 +29973,7 @@ Readable.prototype.unpipe = function (dest) { state.pipes = null; state.pipesCount = 0; state.flowing = false; - if (dest) dest.emit('unpipe', this); + if (dest) dest.emit('unpipe', this, unpipeInfo); return this; } @@ -29958,7 +29988,7 @@ Readable.prototype.unpipe = function (dest) { state.flowing = false; for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this); + dests[i].emit('unpipe', this, unpipeInfo); }return this; } @@ -29970,7 +30000,7 @@ Readable.prototype.unpipe = function (dest) { state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this); + dest.emit('unpipe', this, unpipeInfo); return this; }; @@ -29991,7 +30021,7 @@ Readable.prototype.on = function (ev, fn) { if (!state.reading) { processNextTick(nReadingNextTick, this); } else if (state.length) { - emitReadable(this, state); + emitReadable(this); } } } @@ -30192,7 +30222,7 @@ function copyFromBufferString(n, list) { // This function is designed to be inlinable, so please take care when making // changes to the function body. function copyFromBuffer(n, list) { - var ret = bufferShim.allocUnsafe(n); + var ret = Buffer.allocUnsafe(n); var p = list.head; var c = 1; p.data.copy(ret); @@ -30252,8 +30282,29 @@ function indexOf(xs, x) { } return -1; } -}).call(this,require('_process')) -},{"./_stream_duplex":89,"./internal/streams/BufferList":94,"./internal/streams/stream":95,"_process":87,"buffer":10,"buffer-shims":12,"core-util-is":22,"events":27,"inherits":41,"isarray":44,"process-nextick-args":86,"string_decoder/":106,"util":6}],92:[function(require,module,exports){ +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":88,"./internal/streams/BufferList":93,"./internal/streams/destroy":94,"./internal/streams/stream":95,"_process":86,"core-util-is":21,"events":26,"inherits":40,"isarray":43,"process-nextick-args":85,"safe-buffer":100,"string_decoder/":106,"util":6}],91:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -30327,7 +30378,9 @@ function afterTransform(stream, er, data) { var cb = ts.writecb; - if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + if (!cb) { + return stream.emit('error', new Error('write callback called multiple times')); + } ts.writechunk = null; ts.writecb = null; @@ -30420,6 +30473,15 @@ Transform.prototype._read = function (n) { } }; +Transform.prototype._destroy = function (err, cb) { + var _this = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this.emit('close'); + }); +}; + function done(stream, er, data) { if (er) return stream.emit('error', er); @@ -30436,20 +30498,63 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":89,"core-util-is":22,"inherits":41}],93:[function(require,module,exports){ -(function (process){ +},{"./_stream_duplex":88,"core-util-is":21,"inherits":40}],92:[function(require,module,exports){ +(function (process,global){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. 'use strict'; -module.exports = Writable; - /**/ + var processNextTick = require('process-nextick-args'); /**/ +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + /**/ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; /**/ @@ -30475,22 +30580,23 @@ var internalUtil = { var Stream = require('./internal/streams/stream'); /**/ -var Buffer = require('buffer').Buffer; /**/ -var bufferShim = require('buffer-shims'); +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} /**/ +var destroyImpl = require('./internal/streams/destroy'); + util.inherits(Writable, Stream); function nop() {} -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; -} - function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -30510,7 +30616,10 @@ function WritableState(options, stream) { this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~~this.highWaterMark; + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; // drain event flag. this.needDrain = false; @@ -30521,6 +30630,9 @@ function WritableState(options, stream) { // when 'finish' is emitted this.finished = false; + // has it been destroyed + this.destroyed = false; + // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. @@ -30602,7 +30714,7 @@ WritableState.prototype.getBuffer = function getBuffer() { Object.defineProperty(WritableState.prototype, 'buffer', { get: internalUtil.deprecate(function () { return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); } catch (_) {} })(); @@ -30648,6 +30760,10 @@ function Writable(options) { if (typeof options.write === 'function') this._write = options.write; if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; } Stream.call(this); @@ -30688,7 +30804,11 @@ function validChunk(stream, state, chunk, cb) { Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; - var isBuf = Buffer.isBuffer(chunk); + var isBuf = _isUint8Array(chunk) && !state.objectMode; + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } if (typeof encoding === 'function') { cb = encoding; @@ -30733,7 +30853,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = bufferShim.from(chunk, encoding); + chunk = Buffer.from(chunk, encoding); } return chunk; } @@ -30743,8 +30863,12 @@ function decodeChunk(state, chunk, encoding) { // If we return false, then we need a drain event, so set that flag. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { - chunk = decodeChunk(state, chunk, encoding); - if (Buffer.isBuffer(chunk)) encoding = 'buffer'; + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } } var len = state.objectMode ? 1 : chunk.length; @@ -30756,7 +30880,13 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (state.writing || state.corked) { var last = state.lastBufferedRequest; - state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; if (last) { last.next = state.lastBufferedRequest; } else { @@ -30781,10 +30911,26 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; - if (sync) processNextTick(cb, er);else cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + processNextTick(cb, er); + // this can emit finish, and it will always happen + // after error + processNextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } } function onwriteStateUpdate(state) { @@ -30849,11 +30995,14 @@ function clearBuffer(stream, state) { holder.entry = entry; var count = 0; + var allBuffers = true; while (entry) { buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } + buffer.allBuffers = allBuffers; doWrite(stream, state, true, state.length, buffer, '', holder.finish); @@ -30927,23 +31076,37 @@ Writable.prototype.end = function (chunk, encoding, cb) { function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } - -function prefinish(stream, state) { - if (!state.prefinished) { +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } state.prefinished = true; stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + processNextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } } } function finishMaybe(stream, state) { var need = needFinish(state); if (need) { + prefinish(stream, state); if (state.pendingcb === 0) { - prefinish(stream, state); state.finished = true; stream.emit('finish'); - } else { - prefinish(stream, state); } } return need; @@ -30959,99 +31122,201 @@ function endWritable(stream, state, cb) { stream.writable = false; } -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; - this.finish = function (err) { - var entry = _this.entry; - _this.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = _this; - } else { - state.corkedRequestsFree = _this; - } - }; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } } -}).call(this,require('_process')) -},{"./_stream_duplex":89,"./internal/streams/stream":95,"_process":87,"buffer":10,"buffer-shims":12,"core-util-is":22,"inherits":41,"process-nextick-args":86,"util-deprecate":110}],94:[function(require,module,exports){ + +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":88,"./internal/streams/destroy":94,"./internal/streams/stream":95,"_process":86,"core-util-is":21,"inherits":40,"process-nextick-args":85,"safe-buffer":100,"util-deprecate":110}],93:[function(require,module,exports){ 'use strict'; -var Buffer = require('buffer').Buffer; /**/ -var bufferShim = require('buffer-shims'); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; /**/ -module.exports = BufferList; - -function BufferList() { - this.head = null; - this.tail = null; - this.length = 0; +function copyBuffer(src, target, offset) { + src.copy(target, offset); } -BufferList.prototype.push = function (v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; -}; +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); -BufferList.prototype.unshift = function (v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; -}; - -BufferList.prototype.shift = function () { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; -}; - -BufferList.prototype.clear = function () { - this.head = this.tail = null; - this.length = 0; -}; - -BufferList.prototype.join = function (s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; -}; - -BufferList.prototype.concat = function (n) { - if (this.length === 0) return bufferShim.alloc(0); - if (this.length === 1) return this.head.data; - var ret = bufferShim.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - p.data.copy(ret, i); - i += p.data.length; - p = p.next; + this.head = null; + this.tail = null; + this.length = 0; } - return ret; + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); +},{"safe-buffer":100}],94:[function(require,module,exports){ +'use strict'; + +/**/ + +var processNextTick = require('process-nextick-args'); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + processNextTick(emitErrorNT, this, err); + } + return; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + processNextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy }; -},{"buffer":10,"buffer-shims":12}],95:[function(require,module,exports){ +},{"process-nextick-args":85}],95:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":27}],96:[function(require,module,exports){ +},{"events":26}],96:[function(require,module,exports){ module.exports = require('./readable').PassThrough },{"./readable":97}],97:[function(require,module,exports){ @@ -31063,14 +31328,75 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":89,"./lib/_stream_passthrough.js":90,"./lib/_stream_readable.js":91,"./lib/_stream_transform.js":92,"./lib/_stream_writable.js":93}],98:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":88,"./lib/_stream_passthrough.js":89,"./lib/_stream_readable.js":90,"./lib/_stream_transform.js":91,"./lib/_stream_writable.js":92}],98:[function(require,module,exports){ module.exports = require('./readable').Transform },{"./readable":97}],99:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_writable.js":93}],100:[function(require,module,exports){ -module.exports = require('buffer') +},{"./lib/_stream_writable.js":92}],100:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} },{"buffer":10}],101:[function(require,module,exports){ var encode = require('./lib/encoder'), @@ -32979,7 +33305,7 @@ module.exports = function savePixels (array, type, options) { } }).call(this,require("buffer").Buffer) -},{"buffer":10,"contentstream":13,"gif-encoder":29,"jpeg-js":101,"ndarray":51,"ndarray-ops":48,"pngjs-nozlib":84,"through":107}],105:[function(require,module,exports){ +},{"buffer":10,"contentstream":12,"gif-encoder":28,"jpeg-js":101,"ndarray":50,"ndarray-ops":47,"pngjs-nozlib":83,"through":107}],105:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -33108,7 +33434,7 @@ Stream.prototype.pipe = function(dest, options) { return dest; }; -},{"events":27,"inherits":41,"readable-stream/duplex.js":88,"readable-stream/passthrough.js":96,"readable-stream/readable.js":97,"readable-stream/transform.js":98,"readable-stream/writable.js":99}],106:[function(require,module,exports){ +},{"events":26,"inherits":40,"readable-stream/duplex.js":87,"readable-stream/passthrough.js":96,"readable-stream/readable.js":97,"readable-stream/transform.js":98,"readable-stream/writable.js":99}],106:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -33493,7 +33819,7 @@ function through (write, end, opts) { }).call(this,require('_process')) -},{"_process":87,"stream":105}],108:[function(require,module,exports){ +},{"_process":86,"stream":105}],108:[function(require,module,exports){ "use strict" function unique_pred(list, compare) { @@ -33562,7 +33888,7 @@ module.exports = function urifyNode (file) { return 'data:' + type + ';base64,' + data; }; -},{"fs":9,"mime":46}],110:[function(require,module,exports){ +},{"fs":9,"mime":45}],110:[function(require,module,exports){ (function (global){ /** @@ -33634,8 +33960,8 @@ function config (name) { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],111:[function(require,module,exports){ -arguments[4][41][0].apply(exports,arguments) -},{"dup":41}],112:[function(require,module,exports){ +arguments[4][40][0].apply(exports,arguments) +},{"dup":40}],112:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' @@ -34232,13 +34558,13 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":112,"_process":87,"inherits":111}],114:[function(require,module,exports){ +},{"./support/isBuffer":112,"_process":86,"inherits":111}],114:[function(require,module,exports){ function AddStep(ref, image, name, o) { function addStep(image, name, o_) { - ref.clog('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".'); + ref.log('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".'); - o = {}; + o = ref.copy(o_); o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step o.name = o_.name || name; o.selector = o_.selector || 'ismod-' + name; @@ -34294,7 +34620,7 @@ function copy(a) { } function formatInput(args,format,images) { - images = images || []; + images = []; for (image in this.images) { images.push(image); } @@ -34309,7 +34635,7 @@ function formatInput(args,format,images) { else if (format == "r") format = ['o_string_a', 'o_number']; else if (format == "l") - format = ['string','string','o_function']; + format = ['o_string','string','o_function']; /* formats: @@ -34357,6 +34683,14 @@ function formatInput(args,format,images) { args.splice(0,0,copy(images)); } } + else if (format[0] == "o_string" && format_i == "l" && args.length == 2) { + if (typeof(args[0]) == "string") { + identifier = "image"; + number = 1; + while (this.images.hasOwnProperty(identifier+number)) number++; + args.splice(0,0,identifier+number); + } + } if(args.length == format.length) { for (i in format) { @@ -34415,15 +34749,19 @@ function formatInput(args,format,images) { } } + if(format_i == "l") { + json_q.loadedimages = []; + for (i in json_q.images) json_q.loadedimages.push(i); + } + return json_q; } module.exports = formatInput; },{}],116:[function(require,module,exports){ -(function (global){ if (typeof window !== 'undefined') {window.$ = window.jQuery = require('jquery'); isBrowser = true} -else {window = global; var isBrowser = false} +else {var isBrowser = false} ImageSequencer = function ImageSequencer(options) { @@ -34436,7 +34774,7 @@ ImageSequencer = function ImageSequencer(options) { return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1) } - function clog(color,msg) { + function log(color,msg) { if(options.ui!="none") { if(arguments.length==1) console.log(arguments[0]); else if(arguments.length==2) console.log(color,msg); @@ -34466,27 +34804,32 @@ ImageSequencer = function ImageSequencer(options) { steps = [], modules = require('./Modules'), images = {}, - log = []; + inputlog = []; // if in browser, prompt for an image // if (options.imageSelect || options.inBrowser) addStep('image-select'); // else if (options.imageUrl) loadImage(imageUrl); function addSteps(){ - args = []; - json_q = {}; - for(arg in arguments){args.push(copy(arguments[arg]));} - json_q = formatInput.call(this,args,"+"); - log.push({method:"addSteps", json_q:copy(json_q)}); - for (i in json_q) - for (j in json_q[i]) - require("./AddStep")(this,i,json_q[i][j].name,json_q[i][j].o); - } + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; + json_q = {}; + for(arg in arguments){args.push(copy(arguments[arg]));} + json_q = formatInput.call(this_,args,"+"); + + inputlog.push({method:"addSteps", json_q:copy(json_q)}); + + for (i in json_q) + for (j in json_q[i]) + require("./AddStep")(this_,i,json_q[i][j].name,json_q[i][j].o); + + return this; + } function removeStep(image,index) { //remove the step from images[image].steps and redraw remaining images if(index>0) { - clog('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image); + log('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image); images[image].steps.splice(index,1); } //tell the UI a step has been removed @@ -34494,10 +34837,12 @@ ImageSequencer = function ImageSequencer(options) { function removeSteps(image,index) { run = {}; - args = []; + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for(arg in arguments) args.push(copy(arguments[arg])); - json_q = formatInput.call(this,args,"-"); - log.push({method:"removeSteps", json_q:copy(json_q)}); + + json_q = formatInput.call(this_,args,"-"); + inputlog.push({method:"removeSteps", json_q:copy(json_q)}); for (img in json_q) { indices = json_q[img].sort(function(a,b){return b-a}); @@ -34506,90 +34851,104 @@ ImageSequencer = function ImageSequencer(options) { removeStep(img,indices[i]); } // this.run(run); // This is creating problems + return this; } function insertSteps(image, index, name, o) { run = {}; - this_ = this; - args = []; + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for (arg in arguments) args.push(arguments[arg]); - json_q = formatInput.call(this,args,"^"); - log.push({method:"insertSteps", json_q:copy(json_q)}); + json_q = formatInput.call(this_,args,"^"); + inputlog.push({method:"insertSteps", json_q:copy(json_q)}); for (img in json_q) { var details = json_q[img]; details = details.sort(function(a,b){return b.index-a.index}); for (i in details) - require("./InsertStep")(this,img,details[i].index,details[i].name,details[i].o); - // run[img] = details[details.length-1].index; + require("./InsertStep")(this_,img,details[i].index,details[i].name,details[i].o); + run[img] = details[details.length-1].index; } // this.run(run); // This is Creating issues + return this; } function run(t_image,t_from) { - clog('\x1b[32m%s\x1b[0m',"Running the Sequencer!"); - this_ = this; - args = []; + log('\x1b[32m%s\x1b[0m',"Running the Sequencer!"); + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for (var arg in arguments) args.push(copy(arguments[arg])); + callback = function() {}; for (var arg in args) if(objTypeOf(args[arg]) == "Function") callback = args.splice(arg,1)[0]; - json_q = formatInput.call(this,args,"r"); + json_q = formatInput.call(this_,args,"r"); - require('./Run')(this, json_q, callback); + require('./Run')(this_, json_q, callback); + + return true; } function loadImages() { args = []; for (arg in arguments) args.push(copy(arguments[arg])); json_q = formatInput.call(this,args,"l"); - json_q_push = copy(json_q); - delete json_q_push.callback; - log.push({method:"loadImages", json_q:json_q_push}); + + inputlog.push({method:"loadImages", json_q:copy(json_q)}); + loadedimages = this.copy(json_q.loadedimages); for (i in json_q.images) require('./LoadImage')(this,i,json_q.images[i]) - if (json_q.callback) json_q.callback(); + json_q.callback(); + return { + name: "ImageSequencer Wrapper", + sequencer: this, + addSteps: this.addSteps, + removeSteps: this.removeSteps, + insertSteps: this.insertSteps, + run: this.run, + images: loadedimages + }; } - function runLog() { - for(i in sequencer.log) - eval("sequencer."+sequencer.log[i].method).call(sequencer,sequencer.log[i].json_q); - return true + function replaceImage(selector,steps,options) { + options = options || {}; + return require('./ReplaceImage')(this,selector,steps); } return { + name: "ImageSequencer", options: options, loadImages: loadImages, + loadImage: loadImages, addSteps: addSteps, removeSteps: removeSteps, insertSteps: insertSteps, + replaceImage: replaceImage, run: run, - log: log, + inputlog: inputlog, modules: modules, images: images, ui: options.ui, - clog: clog, + log: log, objTypeOf: objTypeOf, - copy: copy, - runLog: runLog + copy: copy } } module.exports = ImageSequencer; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./AddStep":114,"./FormatInput":115,"./InsertStep":117,"./LoadImage":118,"./Modules":119,"./Run":120,"jquery":45}],117:[function(require,module,exports){ +},{"./AddStep":114,"./FormatInput":115,"./InsertStep":117,"./LoadImage":118,"./Modules":119,"./ReplaceImage":120,"./Run":121,"jquery":44}],117:[function(require,module,exports){ function InsertStep(ref, image, index, name, o) { - function insertStep(image, index, name, o) { - ref.clog('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".'); + function insertStep(image, index, name, o_) { + ref.log('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".'); - o = o || {}; + o = ref.copy(o_); o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step o.name = o.name || name; o.selector = o.selector || 'ismod-' + name; @@ -34642,7 +35001,12 @@ function LoadImage(ref, name, src) { }, draw: function() { if(arguments.length==1){ - this.outputData = CImage(arguments[0]); + this.output = CImage(arguments[0]); + return true; + } + else if(arguments.length==2) { + this.output = CImage(arguments[0]); + arguments[1](); return true; } return false; @@ -34667,15 +35031,59 @@ module.exports = { 'green-channel': require('./modules/GreenChannel'), 'ndvi-red': require('./modules/NdviRed'), 'do-nothing-pix': require('./modules/DoNothingPix'), - 'invert': require('./modules/Invert') + 'invert': require('./modules/Invert'), + 'crop': require('./modules/Crop') } -},{"./modules/DoNothing":121,"./modules/DoNothingPix":122,"./modules/GreenChannel":123,"./modules/Invert":124,"./modules/NdviRed":125}],120:[function(require,module,exports){ -function Run(ref, json_q, callback) { +},{"./modules/Crop":122,"./modules/DoNothing":123,"./modules/DoNothingPix":124,"./modules/GreenChannel":125,"./modules/Invert":126,"./modules/NdviRed":127}],120:[function(require,module,exports){ +function ReplaceImage(ref,selector,steps,options) { + if(!ref.options.inBrowser) return false; // This isn't for Node.js + this_ = ref; + var input = document.querySelectorAll(selector); + var images = []; + for (i = 0; i < input.length; i++) + if (input[i] instanceof HTMLImageElement) images.push(input[i]); + for (i in images) { + the_image = images[i]; + var url = images[i].src; + var ext = url.split('.').pop(); + var xmlHTTP = new XMLHttpRequest(); + xmlHTTP.open('GET', url, true); + xmlHTTP.responseType = 'arraybuffer'; + xmlHTTP.onload = function(e) { + var arr = new Uint8Array(this.response); + var raw = String.fromCharCode.apply(null,arr); + var base64 = btoa(raw); + var dataURL="data:image/"+ext+";base64," + base64; + make(dataURL); + }; + + if(url.substr(0,11).toLowerCase()!="data:image/") xmlHTTP.send(); + else make(url); + + function make(url) { + this_.loadImage('default',url).addSteps('default',steps).run(function(out){ + the_image.src = out; + }); + } + } +} + +module.exports = ReplaceImage; + +},{}],121:[function(require,module,exports){ +function Run(ref, json_q, callback) { function drawStep(drawarray,pos) { - if(pos==drawarray.length) if(ref.objTypeOf(callback)=='Function') callback(); - if(pos>=drawarray.length) return true; + if(pos==drawarray.length) { + image = drawarray[pos-1].image; + if(ref.objTypeOf(callback)=='Function'){ + steps = ref.images[image].steps; + out = steps[steps.length-1].output.src; + callback(out); + return true; + } + } image = drawarray[pos].image; i = drawarray[pos].i; input = ref.images[image].steps[i-1].output; @@ -34698,7 +35106,7 @@ function Run(ref, json_q, callback) { for (image in json_q) { if (json_q[image]==0 && ref.images[image].steps.length==1) delete json_q[image]; - else json_q[image]++; + else if (json_q[image]==0) json_q[image]++; } for (image in json_q) { prevstep = ref.images[image].steps[json_q[image]-1]; @@ -34709,11 +35117,76 @@ function Run(ref, json_q, callback) { return json_q; } json_q = filter(json_q); - drawSteps(json_q); + return drawSteps(json_q); } module.exports = Run; -},{}],121:[function(require,module,exports){ +},{}],122:[function(require,module,exports){ +/* + * Image Cropping module + * Usage: + * Expected Inputs: + * options.x : x-coordinate of image where the modules starts cropping | default : 0 + * options.y : y-coordinate of image where the modules starts cropping | default : 0 + * options.w : width of the resulting cropped image | default : 50% of input image width + * options.h : height of the resulting cropped image | default : 50% of input image height + * Output: + * The cropped image, which is essentially a rectangle bounded by the lines: + * x = options.x + * x = options.x + options.w + * y = options.y + * y = options.y + options.h + */ + module.exports = function Crop(options) { + options = options || {}; + options.title = "Do Nothing"; + this_ = this; + var output + var getPixels = require("get-pixels"), + savePixels = require("save-pixels"), + base64 = require('base64-stream'); + + function draw(input,callback) { + + const this_ = this; + + getPixels(input.src,function(err,pixels){ + var newdata = []; + var ox = options.x || 0; + var oy = options.y || 0; + var w = options.w || Math.floor(0.5*pixels.shape[0]); + var h = options.h || Math.floor(0.5*pixels.shape[1]); + var iw = pixels.shape[0]; //Width of Original Image + newarray = new Uint8Array(4*w*h); + for (var n = oy; n < oy + h; n++) { + newarray.set(pixels.data.slice(n*4*iw + ox, n*4*iw + ox + 4*w),4*w*(n-oy)); + } + pixels.data = newarray; + pixels.shape = [w,h,4]; + pixels.stride[1] = 4*w; + + options.format = "jpeg"; + + w = base64.encode(); + var r = savePixels(pixels, options.format); + r.pipe(w).on('finish',function(){ + data = w.read().toString(); + datauri = 'data:image/' + options.format + ';base64,' + data; + this_.output = {src:datauri,format:options.format}; + callback(); + }); + }); + + } + + return { + options: options, + draw: draw, + output: output + } + } + +},{"base64-stream":3,"get-pixels":27,"save-pixels":104}],123:[function(require,module,exports){ /* * Demo Module. Does nothing. */ @@ -34735,7 +35208,7 @@ module.exports = function DoNothing(options) { } } -},{}],122:[function(require,module,exports){ +},{}],124:[function(require,module,exports){ /* * Display only the green channel */ @@ -34773,7 +35246,7 @@ module.exports = function GreenChannel(options) { } } -},{"./PixelManipulation.js":126}],123:[function(require,module,exports){ +},{"./PixelManipulation.js":128}],125:[function(require,module,exports){ /* * Display only the green channel */ @@ -34811,7 +35284,7 @@ module.exports = function GreenChannel(options) { } } -},{"./PixelManipulation.js":126}],124:[function(require,module,exports){ +},{"./PixelManipulation.js":128}],126:[function(require,module,exports){ /* * Display only the green channel */ @@ -34849,7 +35322,7 @@ module.exports = function GreenChannel(options) { } } -},{"./PixelManipulation.js":126}],125:[function(require,module,exports){ +},{"./PixelManipulation.js":128}],127:[function(require,module,exports){ /* * NDVI with red filter (blue channel is infrared) */ @@ -34886,7 +35359,7 @@ module.exports = function NdviRed(options) { } } -},{"./PixelManipulation.js":126}],126:[function(require,module,exports){ +},{"./PixelManipulation.js":128}],128:[function(require,module,exports){ /* * General purpose per-pixel manipulation * accepting a changePixel() method to remix a pixel's channels @@ -34946,4 +35419,4 @@ module.exports = function PixelManipulation(image, options) { } -},{"base64-stream":3,"get-pixels":28,"save-pixels":104}]},{},[116]); +},{"base64-stream":3,"get-pixels":27,"save-pixels":104}]},{},[116]); diff --git a/examples/cyan.jpg b/examples/cyan.jpg new file mode 100644 index 00000000..ec09619b Binary files /dev/null and b/examples/cyan.jpg differ diff --git a/examples/replace.html b/examples/replace.html new file mode 100644 index 00000000..b3242b81 --- /dev/null +++ b/examples/replace.html @@ -0,0 +1,63 @@ + + + + + Replace Image Demo | Image Sequencer + + + + + + + + + + + + + + + + +
+ +

Image Sequencer

+

+ +

+ +
+ + + +
+ +
+ +
+ +
+ +
+

+ Click on the image above to invert it.
+ (This may take a few seconds)
+ Syntax:

+
+ +
+

var sequencer = new ImageSequencer();


+

sequencer.replaceImage('#pencils','invert');

+
+ + + + + diff --git a/examples/replace.jpg b/examples/replace.jpg new file mode 100644 index 00000000..be4edba8 Binary files /dev/null and b/examples/replace.jpg differ diff --git a/index.html b/index.html index 7b410446..fc43abf3 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - + Image Sequencer diff --git a/package.json b/package.json index c0ea2efa..7f6af8c9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A modular JavaScript image manipulation library modeled on a storyboard.", "main": "dist/image-sequencer.js", "scripts": { - "test": "tape test/*.js" + "test": "tape test/*.js | tap-spec; browserify test/image-sequencer.js test/chain.js | tape-run --render=\"tap-spec\"" }, "repository": { "type": "git", @@ -39,7 +39,9 @@ "matchdep": "^0.3.0", "plotly.js": "~1.21.2", "save-pixels": "~2.3.4", - "tape": "^3.5.0" + "tap-spec": "^4.1.1", + "tape": ">=4.7.0", + "tape-run": "^3.0.0" }, "homepage": "https://github.com/publiclab/image-sequencer" } diff --git a/src/AddStep.js b/src/AddStep.js index 32f00e2f..c28dca97 100644 --- a/src/AddStep.js +++ b/src/AddStep.js @@ -1,9 +1,9 @@ function AddStep(ref, image, name, o) { function addStep(image, name, o_) { - ref.clog('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".'); + ref.log('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".'); - o = {}; + o = ref.copy(o_); o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step o.name = o_.name || name; o.selector = o_.selector || 'ismod-' + name; diff --git a/src/FormatInput.js b/src/FormatInput.js index bd12410d..01944f99 100644 --- a/src/FormatInput.js +++ b/src/FormatInput.js @@ -24,7 +24,7 @@ function copy(a) { } function formatInput(args,format,images) { - images = images || []; + images = []; for (image in this.images) { images.push(image); } @@ -39,7 +39,7 @@ function formatInput(args,format,images) { else if (format == "r") format = ['o_string_a', 'o_number']; else if (format == "l") - format = ['string','string','o_function']; + format = ['o_string','string','o_function']; /* formats: @@ -87,6 +87,14 @@ function formatInput(args,format,images) { args.splice(0,0,copy(images)); } } + else if (format[0] == "o_string" && format_i == "l" && args.length == 2) { + if (typeof(args[0]) == "string") { + identifier = "image"; + number = 1; + while (this.images.hasOwnProperty(identifier+number)) number++; + args.splice(0,0,identifier+number); + } + } if(args.length == format.length) { for (i in format) { @@ -145,6 +153,11 @@ function formatInput(args,format,images) { } } + if(format_i == "l") { + json_q.loadedimages = []; + for (i in json_q.images) json_q.loadedimages.push(i); + } + return json_q; } diff --git a/src/ImageSequencer.js b/src/ImageSequencer.js index 895ae45f..0f3ad290 100644 --- a/src/ImageSequencer.js +++ b/src/ImageSequencer.js @@ -1,5 +1,5 @@ if (typeof window !== 'undefined') {window.$ = window.jQuery = require('jquery'); isBrowser = true} -else {window = global; var isBrowser = false} +else {var isBrowser = false} ImageSequencer = function ImageSequencer(options) { @@ -12,7 +12,7 @@ ImageSequencer = function ImageSequencer(options) { return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1) } - function clog(color,msg) { + function log(color,msg) { if(options.ui!="none") { if(arguments.length==1) console.log(arguments[0]); else if(arguments.length==2) console.log(color,msg); @@ -42,27 +42,32 @@ ImageSequencer = function ImageSequencer(options) { steps = [], modules = require('./Modules'), images = {}, - log = []; + inputlog = []; // if in browser, prompt for an image // if (options.imageSelect || options.inBrowser) addStep('image-select'); // else if (options.imageUrl) loadImage(imageUrl); function addSteps(){ - args = []; - json_q = {}; - for(arg in arguments){args.push(copy(arguments[arg]));} - json_q = formatInput.call(this,args,"+"); - log.push({method:"addSteps", json_q:copy(json_q)}); - for (i in json_q) - for (j in json_q[i]) - require("./AddStep")(this,i,json_q[i][j].name,json_q[i][j].o); - } + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; + json_q = {}; + for(arg in arguments){args.push(copy(arguments[arg]));} + json_q = formatInput.call(this_,args,"+"); + + inputlog.push({method:"addSteps", json_q:copy(json_q)}); + + for (i in json_q) + for (j in json_q[i]) + require("./AddStep")(this_,i,json_q[i][j].name,json_q[i][j].o); + + return this; + } function removeStep(image,index) { //remove the step from images[image].steps and redraw remaining images if(index>0) { - clog('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image); + log('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image); images[image].steps.splice(index,1); } //tell the UI a step has been removed @@ -70,10 +75,12 @@ ImageSequencer = function ImageSequencer(options) { function removeSteps(image,index) { run = {}; - args = []; + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for(arg in arguments) args.push(copy(arguments[arg])); - json_q = formatInput.call(this,args,"-"); - log.push({method:"removeSteps", json_q:copy(json_q)}); + + json_q = formatInput.call(this_,args,"-"); + inputlog.push({method:"removeSteps", json_q:copy(json_q)}); for (img in json_q) { indices = json_q[img].sort(function(a,b){return b-a}); @@ -82,77 +89,92 @@ ImageSequencer = function ImageSequencer(options) { removeStep(img,indices[i]); } // this.run(run); // This is creating problems + return this; } function insertSteps(image, index, name, o) { run = {}; - this_ = this; - args = []; + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for (arg in arguments) args.push(arguments[arg]); - json_q = formatInput.call(this,args,"^"); - log.push({method:"insertSteps", json_q:copy(json_q)}); + json_q = formatInput.call(this_,args,"^"); + inputlog.push({method:"insertSteps", json_q:copy(json_q)}); for (img in json_q) { var details = json_q[img]; details = details.sort(function(a,b){return b.index-a.index}); for (i in details) - require("./InsertStep")(this,img,details[i].index,details[i].name,details[i].o); - // run[img] = details[details.length-1].index; + require("./InsertStep")(this_,img,details[i].index,details[i].name,details[i].o); + run[img] = details[details.length-1].index; } // this.run(run); // This is Creating issues + return this; } function run(t_image,t_from) { - clog('\x1b[32m%s\x1b[0m',"Running the Sequencer!"); - this_ = this; - args = []; + log('\x1b[32m%s\x1b[0m',"Running the Sequencer!"); + const this_ = (this.name == "ImageSequencer")?this:this.sequencer; + args = (this.name == "ImageSequencer")?[]:[this.images]; for (var arg in arguments) args.push(copy(arguments[arg])); + callback = function() {}; for (var arg in args) if(objTypeOf(args[arg]) == "Function") callback = args.splice(arg,1)[0]; - json_q = formatInput.call(this,args,"r"); + json_q = formatInput.call(this_,args,"r"); - require('./Run')(this, json_q, callback); + require('./Run')(this_, json_q, callback); + + return true; } function loadImages() { args = []; for (arg in arguments) args.push(copy(arguments[arg])); json_q = formatInput.call(this,args,"l"); - json_q_push = copy(json_q); - delete json_q_push.callback; - log.push({method:"loadImages", json_q:json_q_push}); + + inputlog.push({method:"loadImages", json_q:copy(json_q)}); + loadedimages = this.copy(json_q.loadedimages); for (i in json_q.images) require('./LoadImage')(this,i,json_q.images[i]) - if (json_q.callback) json_q.callback(); + json_q.callback(); + return { + name: "ImageSequencer Wrapper", + sequencer: this, + addSteps: this.addSteps, + removeSteps: this.removeSteps, + insertSteps: this.insertSteps, + run: this.run, + images: loadedimages + }; } - function runLog() { - for(i in sequencer.log) - eval("sequencer."+sequencer.log[i].method).call(sequencer,sequencer.log[i].json_q); - return true + function replaceImage(selector,steps,options) { + options = options || {}; + return require('./ReplaceImage')(this,selector,steps); } return { + name: "ImageSequencer", options: options, loadImages: loadImages, + loadImage: loadImages, addSteps: addSteps, removeSteps: removeSteps, insertSteps: insertSteps, + replaceImage: replaceImage, run: run, - log: log, + inputlog: inputlog, modules: modules, images: images, ui: options.ui, - clog: clog, + log: log, objTypeOf: objTypeOf, - copy: copy, - runLog: runLog + copy: copy } } diff --git a/src/InsertStep.js b/src/InsertStep.js index 49c82a07..08a99c67 100644 --- a/src/InsertStep.js +++ b/src/InsertStep.js @@ -1,9 +1,9 @@ function InsertStep(ref, image, index, name, o) { - function insertStep(image, index, name, o) { - ref.clog('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".'); + function insertStep(image, index, name, o_) { + ref.log('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".'); - o = o || {}; + o = ref.copy(o_); o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step o.name = o.name || name; o.selector = o.selector || 'ismod-' + name; diff --git a/src/LoadImage.js b/src/LoadImage.js index 772a2d1e..7beaf458 100644 --- a/src/LoadImage.js +++ b/src/LoadImage.js @@ -19,7 +19,12 @@ function LoadImage(ref, name, src) { }, draw: function() { if(arguments.length==1){ - this.outputData = CImage(arguments[0]); + this.output = CImage(arguments[0]); + return true; + } + else if(arguments.length==2) { + this.output = CImage(arguments[0]); + arguments[1](); return true; } return false; diff --git a/src/Modules.js b/src/Modules.js index b2a7d732..90e53906 100644 --- a/src/Modules.js +++ b/src/Modules.js @@ -6,5 +6,6 @@ module.exports = { 'green-channel': require('./modules/GreenChannel'), 'ndvi-red': require('./modules/NdviRed'), 'do-nothing-pix': require('./modules/DoNothingPix'), - 'invert': require('./modules/Invert') + 'invert': require('./modules/Invert'), + 'crop': require('./modules/Crop') } diff --git a/src/ReplaceImage.js b/src/ReplaceImage.js new file mode 100644 index 00000000..cba128b8 --- /dev/null +++ b/src/ReplaceImage.js @@ -0,0 +1,35 @@ +function ReplaceImage(ref,selector,steps,options) { + if(!ref.options.inBrowser) return false; // This isn't for Node.js + this_ = ref; + var input = document.querySelectorAll(selector); + var images = []; + for (i = 0; i < input.length; i++) + if (input[i] instanceof HTMLImageElement) images.push(input[i]); + for (i in images) { + the_image = images[i]; + var url = images[i].src; + var ext = url.split('.').pop(); + + var xmlHTTP = new XMLHttpRequest(); + xmlHTTP.open('GET', url, true); + xmlHTTP.responseType = 'arraybuffer'; + xmlHTTP.onload = function(e) { + var arr = new Uint8Array(this.response); + var raw = String.fromCharCode.apply(null,arr); + var base64 = btoa(raw); + var dataURL="data:image/"+ext+";base64," + base64; + make(dataURL); + }; + + if(url.substr(0,11).toLowerCase()!="data:image/") xmlHTTP.send(); + else make(url); + + function make(url) { + this_.loadImage('default',url).addSteps('default',steps).run(function(out){ + the_image.src = out; + }); + } + } +} + +module.exports = ReplaceImage; diff --git a/src/Run.js b/src/Run.js index fe78b624..2dff8c37 100644 --- a/src/Run.js +++ b/src/Run.js @@ -1,8 +1,14 @@ function Run(ref, json_q, callback) { - function drawStep(drawarray,pos) { - if(pos==drawarray.length) if(ref.objTypeOf(callback)=='Function') callback(); - if(pos>=drawarray.length) return true; + if(pos==drawarray.length) { + image = drawarray[pos-1].image; + if(ref.objTypeOf(callback)=='Function'){ + steps = ref.images[image].steps; + out = steps[steps.length-1].output.src; + callback(out); + return true; + } + } image = drawarray[pos].image; i = drawarray[pos].i; input = ref.images[image].steps[i-1].output; @@ -25,7 +31,7 @@ function Run(ref, json_q, callback) { for (image in json_q) { if (json_q[image]==0 && ref.images[image].steps.length==1) delete json_q[image]; - else json_q[image]++; + else if (json_q[image]==0) json_q[image]++; } for (image in json_q) { prevstep = ref.images[image].steps[json_q[image]-1]; @@ -36,6 +42,6 @@ function Run(ref, json_q, callback) { return json_q; } json_q = filter(json_q); - drawSteps(json_q); + return drawSteps(json_q); } module.exports = Run; diff --git a/src/modules/Crop.js b/src/modules/Crop.js index c98dc63e..be5909c6 100644 --- a/src/modules/Crop.js +++ b/src/modules/Crop.js @@ -13,18 +13,20 @@ * y = options.y * y = options.y + options.h */ - module.exports = function Crop(options){ - + module.exports = function Crop(options) { options = options || {}; - options.title = "Crop Image"; - options.format = options.format || "png"; + options.title = "Do Nothing"; + this_ = this; + var output + var getPixels = require("get-pixels"), + savePixels = require("save-pixels"), + base64 = require('base64-stream'); - function draw(image) { - var getPixels = require("get-pixels"), - savePixels = require("save-pixels"), - base64 = require('base64-stream'); + function draw(input,callback) { - getPixels(image.src,function(err,pixels){ + const this_ = this; + + getPixels(input.src,function(err,pixels){ var newdata = []; var ox = options.x || 0; var oy = options.y || 0; @@ -39,23 +41,23 @@ pixels.shape = [w,h,4]; pixels.stride[1] = 4*w; - var buffer = base64.encode(); - savePixels(pixels, options.format) - .on('end', function() { - - var img = new Image(); - - img.src = 'data:image/' + options.format + ';base64,' + buffer.read().toString(); - - if (options.output) options.output(img); - - }).pipe(buffer); + options.format = "jpeg"; + w = base64.encode(); + var r = savePixels(pixels, options.format); + r.pipe(w).on('finish',function(){ + data = w.read().toString(); + datauri = 'data:image/' + options.format + ';base64,' + data; + this_.output = {src:datauri,format:options.format}; + callback(); + }); }); + } return { options: options, - draw: draw + draw: draw, + output: output } } diff --git a/src/modules/ImageThreshold.js b/src/modules/ImageThreshold.js index e5ffb41b..64b583e3 100644 --- a/src/modules/ImageThreshold.js +++ b/src/modules/ImageThreshold.js @@ -9,28 +9,25 @@ module.exports = function ImageThreshold(options) { var image; function draw(inputImage) { - $(inputImage).load(function(){ - var canvas = document.createElement('canvas'); - canvas.width = inputImage.naturalWidth; - canvas.height = inputImage.naturalHeight; - var context = canvas.getContext('2d'); - context.drawImage(inputImage, 0, 0); + var canvas = document.createElement('canvas'); + canvas.width = inputImage.naturalWidth; + canvas.height = inputImage.naturalHeight; + var context = canvas.getContext('2d'); + context.drawImage(inputImage, 0, 0 ); + var imageData = context.getImageData(0, 0, inputImage.naturalWidth, inputImage.naturalHeight); - var imageData = context.getImageData(0, 0, canvas.width, canvas.height); + var imageThreshold = require('image-filter-threshold'); + var imageFilterCore = require('image-filter-core'); - var imageThreshold = require('image-filter-threshold'); - var imageFilterCore = require('image-filter-core'); - - var result = imageThreshold({ - data: imageData, - threshold: options.threshold - }).then(function (imageData) { - image = new Image(); - image.onload = function onLoad() { - if (options.output) options.output(image); - } - image.src = imageFilterCore.convertImageDataToCanvasURL(imageData); - }); + var result = imageThreshold({ + data: imageData, + threshold: options.threshold + }).then(function (imageData) { + image = new Image(); + image.onload = function onLoad() { + if (options.output) options.output(image); + } + image.src = imageFilterCore.convertImageDataToCanvasURL(imageData); }); } diff --git a/test/chain.js b/test/chain.js new file mode 100644 index 00000000..d5c1ec59 --- /dev/null +++ b/test/chain.js @@ -0,0 +1,76 @@ +'use strict'; + +var fs = require('fs'); +var test = require('tape'); + +// We should only test headless code here. +// http://stackoverflow.com/questions/21358015/error-jquery-requires-a-window-with-a-document#25622933 + +require('../src/ImageSequencer.js'); + +var sequencer = ImageSequencer({ ui: "none" }); +var red = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; + +test('loadImages/loadImage has a name generator.', function (t){ + sequencer.loadImage(red); + t.equal(sequencer.images.image1.steps.length, 1, "Initial Step Created"); + t.end(); +}); + +test('loadImages/loadImage returns a wrapper.', function (t){ + var returnval = sequencer.loadImage(red); + t.equal(returnval.name,"ImageSequencer Wrapper", "Wrapper is returned"); + t.equal(returnval.images[0],"image2","Image scope is defined"); + t.end(); +}); + +test('addSteps is two-way chainable.', function (t){ + var returnval = sequencer.loadImage(red).addSteps('invert'); + t.equal(returnval.name,"ImageSequencer Wrapper", "Wrapper is returned"); + t.equal(returnval.images[0],"image3","Image scope is defined"); + t.equal(sequencer.images.image3.steps.length,2,"Loaded image is affected"); + t.equal(sequencer.images.image3.steps[1].options.name,"invert","Correct Step Added"); + t.equal(sequencer.images.image2.steps.length,1,"Other images are not affected"); + t.equal(sequencer.images.image1.steps.length,1,"Other images are not affected"); + t.end(); +}); + +test('addSteps is two-way chainable without loadImages.', function (t){ + var returnval = sequencer.addSteps("image3","ndvi-red"); + t.equal(returnval.name,"ImageSequencer","Sequencer is returned"); + t.equal(sequencer.images.image3.steps.length,3,"Step length increased"); + t.equal(sequencer.images.image3.steps[2].options.name,"ndvi-red","Correct Step Added"); + t.end(); +}); + +test('removeSteps is two-way chainable.', function (t){ + var returnval = sequencer.loadImage(red).addSteps('invert').removeSteps(1); + t.equal(returnval.name,"ImageSequencer Wrapper", "Wrapper is returned"); + t.equal(returnval.images[0],"image4","Image scope is defined"); + t.equal(sequencer.images.image4.steps.length,1); + t.end(); +}); + +test('removeSteps is two-way chainable without loadImages.', function (t){ + var returnval = sequencer.removeSteps("image3",1); + t.equal(returnval.name,"ImageSequencer","Sequencer is returned"); + t.equal(sequencer.images.image3.steps.length,2); + t.end(); +}); + +test('insertSteps is two-way chainable.', function (t){ + var returnval = sequencer.loadImage(red).insertSteps(1,'invert'); + t.equal(returnval.name,"ImageSequencer Wrapper","Wrapper is returned"); + t.equal(returnval.images[0],"image5","Image scope is defined"); + t.equal(sequencer.images.image5.steps.length,2); + t.equal(sequencer.images.image5.steps[1].options.name,"invert","Correct Step Inserrted"); + t.end(); +}); + +test('insertSteps is two-way chainable without loadImages.', function (t){ + var returnval = sequencer.insertSteps("image5",1,"ndvi-red"); + t.equal(returnval.name,"ImageSequencer","Sequencer is returned"); + t.equal(sequencer.images.image5.steps.length,3); + t.equal(sequencer.images.image5.steps[1].options.name,"ndvi-red","Correct Step Inserrted"); + t.end(); +}); diff --git a/test/image-manip.js b/test/image-manip.js index cb37dd40..83421516 100644 --- a/test/image-manip.js +++ b/test/image-manip.js @@ -9,20 +9,17 @@ require('../src/ImageSequencer.js'); var sequencer = ImageSequencer({ ui: "none" }); var image = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; -sequencer.loadImages({images:{ - test1: image, - test2: image -}, callback:function(){}}); +sequencer.loadImages(image); -sequencer.addSteps("test1", ['do-nothing-pix','invert','invert']); +sequencer.addSteps(['do-nothing-pix','invert','invert']); sequencer.run(); test("Inverted image isn't identical", function (t) { - t.notEqual(sequencer.images.test1.steps[1].output.src, sequencer.images.test1.steps[2].output.src); + t.notEqual(sequencer.images.image1.steps[1].output.src, sequencer.images.image1.steps[2].output.src); t.end(); }); test("Twice inverted image is identical to original image", function (t) { - t.equal(sequencer.images.test1.steps[1].output.src, sequencer.images.test1.steps[3].output.src); + t.equal(sequencer.images.image1.steps[1].output.src, sequencer.images.image1.steps[3].output.src); t.end(); }); diff --git a/test/image-sequencer.js b/test/image-sequencer.js index 83f06fcc..3ad55809 100644 --- a/test/image-sequencer.js +++ b/test/image-sequencer.js @@ -9,102 +9,132 @@ var test = require('tape'); require('../src/ImageSequencer.js'); var sequencer = ImageSequencer({ ui: "none" }); +var red = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; test('Image Sequencer has tests', function (t) { - t.equal(true, true); + t.equal(true, true, "Initial Test"); t.end(); }); -test('loadImages loads an image and creates a step.', function (t){ - sequencer.loadImages('test','examples/red.jpg'); - t.equal(sequencer.images.test.steps.length, 1, "It Does!"); +test('loadImages loads a DataURL image and creates a step.', function (t){ + sequencer.loadImages('test',red); + t.equal(sequencer.images.test.steps.length, 1, "Initial Step Created"); + t.equal(typeof(sequencer.images.test.steps[0].output.src), "string", "Initial output exists"); + t.end(); +}); + +test('loadImages loads a PATH image and creates a step. (NodeJS)', function (t){ + if(sequencer.options.inBrowser){ + t.equal("not applicable","not applicable","Not applicable for Browser"); + t.end(); + } + else { + sequencer.loadImages(red); + t.equal(sequencer.images.image1.steps.length, 1, "Initial Step Created"); + t.equal(typeof(sequencer.images.image1.steps[0].output.src), "string", "Initial output exists"); + t.end(); + } +}); + +test('loadImage works too.', function (t){ + sequencer.loadImage('test2',red); + t.equal(sequencer.images.test2.steps.length, 1, "Initial Step Created"); + t.equal(typeof(sequencer.images.test2.steps[0].output.src), "string", "Initial output exists"); t.end(); }); test('addSteps("image","name") adds a step', function (t) { sequencer.addSteps('test','do-nothing'); - t.equal(sequencer.images.test.steps[1].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 2, "It Does!") + t.equal(sequencer.images.test.steps.length, 2, "Length of steps increased") + t.equal(sequencer.images.test.steps[1].options.name, "do-nothing", "Correct Step Added"); t.end(); }); test('addSteps("name") adds a step', function (t) { sequencer.addSteps('do-nothing'); - t.equal(sequencer.images.test.steps[2].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 3, "It Does!") + t.equal(sequencer.images.test.steps.length, 3, "Length of steps increased"); + t.equal(sequencer.images.test.steps[2].options.name, "do-nothing", "Correct Step Added"); t.end(); }); test('addSteps(["name"]) adds a step', function (t) { sequencer.addSteps(['do-nothing','do-nothing-pix']); - t.equal(sequencer.images.test.steps[3].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps[4].options.name, "do-nothing-pix"); - t.equal(sequencer.images.test.steps.length, 5, "It Does!") + t.equal(sequencer.images.test.steps.length, 5, "Length of steps increased by two") + t.equal(sequencer.images.test.steps[3].options.name, "do-nothing", "Correct Step Added"); + t.equal(sequencer.images.test.steps[4].options.name, "do-nothing-pix", "Correct Step Added"); t.end(); }); test('addSteps("name",o) adds a step', function (t) { sequencer.addSteps('do-nothing',{}); - t.equal(sequencer.images.test.steps[5].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 6, "It Does!") + t.equal(sequencer.images.test.steps.length, 6, "Length of steps increased"); + t.equal(sequencer.images.test.steps[5].options.name, "do-nothing", "Correct Step Added"); t.end(); }); test('addSteps("image","name",o) adds a step', function (t) { sequencer.addSteps('test','do-nothing',{}); - t.equal(sequencer.images.test.steps[6].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 7, "It Does!") + t.equal(sequencer.images.test.steps.length, 7, "Length of steps increased"); + t.equal(sequencer.images.test.steps[6].options.name, "do-nothing", "Correct Step Added"); t.end(); }); test('removeSteps("image",position) removes a step', function (t) { sequencer.removeSteps('test',1); - t.equal(sequencer.images.test.steps.length, 6, "It Does!"); + t.equal(sequencer.images.test.steps.length, 6, "Length of steps reduced"); t.end(); }); test('removeSteps({image: [positions]}) removes steps', function (t) { sequencer.removeSteps('test',[1,2]); - t.equal(sequencer.images.test.steps.length, 4, "It Does!"); + t.equal(sequencer.images.test.steps.length, 4, "Length of steps reduced"); t.end(); }); test('removeSteps(position) removes steps', function (t) { sequencer.removeSteps([1,2]); - t.equal(sequencer.images.test.steps.length, 2, "It Does!"); + t.equal(sequencer.images.test.steps.length, 2, "Length of steps reduced"); t.end(); }); test('insertSteps("image",position,"module",options) inserts a step', function (t) { sequencer.insertSteps('test',1,'do-nothing',{}); - t.equal(sequencer.images.test.steps[1].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 3, "It Does!"); + t.equal(sequencer.images.test.steps.length, 3, "Length of Steps increased"); + t.equal(sequencer.images.test.steps[1].options.name, "do-nothing", "Correct Step Inserted"); t.end(); }); test('insertSteps("image",position,"module") inserts a step', function (t) { sequencer.insertSteps('test',1,'do-nothing'); - t.equal(sequencer.images.test.steps[1].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 4, "It Does!"); + t.equal(sequencer.images.test.steps.length, 4, "Length of Steps increased"); + t.equal(sequencer.images.test.steps[1].options.name, "do-nothing", "Correct Step Inserted"); t.end(); }); test('insertSteps(position,"module") inserts a step', function (t) { sequencer.insertSteps(1,'do-nothing'); - t.equal(sequencer.images.test.steps[1].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 5, "It Does!"); + t.equal(sequencer.images.test.steps.length, 5, "Length of Steps increased"); + t.equal(sequencer.images.test.steps[1].options.name, "do-nothing", "Correct Step Inserted"); t.end(); }); test('insertSteps({image: {index: index, name: "module", o: options} }) inserts a step', function (t) { sequencer.insertSteps({test: {index:1, name:'do-nothing', o:{} } }); - t.equal(sequencer.images.test.steps[1].options.name, "do-nothing"); - t.equal(sequencer.images.test.steps.length, 6, "It Does!"); + t.equal(sequencer.images.test.steps.length, 6, "Length of Steps increased"); + t.equal(sequencer.images.test.steps[1].options.name, "do-nothing", "Correct Step Inserted"); t.end(); }); -test('run() runs the sequencer', function (t) { - sequencer.run(); - t.equal(typeof(sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output), "object", "It Does!"); +test('run() runs the sequencer and returns output to callback', function (t) { + sequencer.run('test',function(out){ + t.equal(typeof(sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output), "object", "Output is Generated"); + t.equal(out,sequencer.images.test.steps[sequencer.images.test.steps.length - 1].output.src, "Output callback works"); + }); + t.end(); +}); + +test('replaceImage returns false in NodeJS', function (t) { + var returnvalue = (sequencer.options.inBrowser)?false:sequencer.replaceImage("#selector","test"); + t.equal(returnvalue,false,"It does."); t.end(); });