holder_rails 2.9.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/holder_rails/helpers.rb +1 -1
- data/lib/holder_rails/version.rb +1 -1
- data/test/holder_rails_test.rb +1 -1
- data/vendor/assets/javascripts/holder.js +2118 -254
- data/vendor/assets/javascripts/holder.min.js +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b958dd1ed08fe21e5c00de8deb5e5f79da1e61
|
4
|
+
data.tar.gz: bf8fa791d9728a772e2d907a8630dc052e417854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a88514ea4815e61057a7185a3800bc4aaf81c2522a01cfc317c259563612081f3db560abc6ea701d16e76ef687226a82d82e4238b493541759a3e1233173da
|
7
|
+
data.tar.gz: cb2db20ff202a5ecff3fbe08fe6981d627334b1e3fbb15b3cbc1dffb716aac1fd89e59d8ff0b407a4563791a32ac384d6f0c74245383163be2fb68802978106b
|
data/lib/holder_rails/helpers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module HolderRails
|
2
2
|
module Helpers
|
3
3
|
def holder_tag(size, text='', theme=nil, html_options={}, holder_options={})
|
4
|
-
size = "#{size}x#{size}" unless size =~ /\A\d
|
4
|
+
size = "#{size}x#{size}" unless size =~ /\A\d+p?x\d+\z/
|
5
5
|
|
6
6
|
holder_options[:text] = text unless text.to_s.empty?
|
7
7
|
holder_options[:theme] = theme unless theme.nil?
|
data/lib/holder_rails/version.rb
CHANGED
data/test/holder_rails_test.rb
CHANGED
@@ -7,7 +7,7 @@ class HolderRailsTest < ActionView::TestCase
|
|
7
7
|
test "size" do
|
8
8
|
assert_dom_equal '<img data-src="holder.js/100x100?" src="" />', holder_tag(100)
|
9
9
|
assert_dom_equal '<img data-src="holder.js/200x300?" src="" />', holder_tag('200x300')
|
10
|
-
assert_dom_equal '<img data-src="holder.js/
|
10
|
+
assert_dom_equal '<img data-src="holder.js/100px75?" src="" />', holder_tag('100px75')
|
11
11
|
end
|
12
12
|
|
13
13
|
test "text" do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/*!
|
2
2
|
|
3
3
|
Holder - client side image placeholders
|
4
|
-
Version 2.9.
|
5
|
-
©
|
4
|
+
Version 2.9.1+ygdp
|
5
|
+
© 2016 Ivan Malopinsky - http://imsky.co
|
6
6
|
|
7
7
|
Site: http://holderjs.com
|
8
8
|
Issues: https://github.com/imsky/holder/issues
|
@@ -210,36 +210,32 @@ License: MIT
|
|
210
210
|
|
211
211
|
//requestAnimationFrame polyfill for older Firefox/Chrome versions
|
212
212
|
if (!window.requestAnimationFrame) {
|
213
|
-
if (window.webkitRequestAnimationFrame) {
|
213
|
+
if (window.webkitRequestAnimationFrame && window.webkitCancelAnimationFrame) {
|
214
214
|
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-webkit.js
|
215
215
|
(function (global) {
|
216
|
-
// window.requestAnimationFrame
|
217
216
|
global.requestAnimationFrame = function (callback) {
|
218
217
|
return webkitRequestAnimationFrame(function () {
|
219
218
|
callback(global.performance.now());
|
220
219
|
});
|
221
220
|
};
|
222
221
|
|
223
|
-
|
224
|
-
global.cancelAnimationFrame = webkitCancelAnimationFrame;
|
222
|
+
global.cancelAnimationFrame = global.webkitCancelAnimationFrame;
|
225
223
|
}(window));
|
226
|
-
} else if (window.mozRequestAnimationFrame) {
|
224
|
+
} else if (window.mozRequestAnimationFrame && window.mozCancelAnimationFrame) {
|
227
225
|
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-moz.js
|
228
226
|
(function (global) {
|
229
|
-
// window.requestAnimationFrame
|
230
227
|
global.requestAnimationFrame = function (callback) {
|
231
228
|
return mozRequestAnimationFrame(function () {
|
232
229
|
callback(global.performance.now());
|
233
230
|
});
|
234
231
|
};
|
235
232
|
|
236
|
-
|
237
|
-
global.cancelAnimationFrame = mozCancelAnimationFrame;
|
233
|
+
global.cancelAnimationFrame = global.mozCancelAnimationFrame;
|
238
234
|
}(window));
|
239
235
|
} else {
|
240
236
|
(function (global) {
|
241
237
|
global.requestAnimationFrame = function (callback) {
|
242
|
-
|
238
|
+
return global.setTimeout(callback, 1000 / 60);
|
243
239
|
};
|
244
240
|
|
245
241
|
global.cancelAnimationFrame = global.clearTimeout;
|
@@ -325,15 +321,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
325
321
|
var onDomReady = __webpack_require__(2);
|
326
322
|
var querystring = __webpack_require__(3);
|
327
323
|
|
328
|
-
var SceneGraph = __webpack_require__(
|
329
|
-
var utils = __webpack_require__(
|
330
|
-
var SVG = __webpack_require__(
|
331
|
-
var DOM = __webpack_require__(
|
332
|
-
var Color = __webpack_require__(
|
333
|
-
var constants = __webpack_require__(
|
324
|
+
var SceneGraph = __webpack_require__(10);
|
325
|
+
var utils = __webpack_require__(11);
|
326
|
+
var SVG = __webpack_require__(12);
|
327
|
+
var DOM = __webpack_require__(13);
|
328
|
+
var Color = __webpack_require__(14);
|
329
|
+
var constants = __webpack_require__(15);
|
334
330
|
|
335
|
-
var svgRenderer = __webpack_require__(
|
336
|
-
var sgCanvasRenderer = __webpack_require__(
|
331
|
+
var svgRenderer = __webpack_require__(16);
|
332
|
+
var sgCanvasRenderer = __webpack_require__(19);
|
337
333
|
|
338
334
|
var extend = utils.extend;
|
339
335
|
var dimensionCheck = utils.dimensionCheck;
|
@@ -602,7 +598,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
602
598
|
instanceOptions: instanceOptions
|
603
599
|
};
|
604
600
|
|
605
|
-
var
|
601
|
+
var firstQuestionMark = url.indexOf('?');
|
602
|
+
var parts = [url];
|
603
|
+
|
604
|
+
if (firstQuestionMark !== -1) {
|
605
|
+
parts = [url.slice(0, firstQuestionMark), url.slice(firstQuestionMark + 1)];
|
606
|
+
}
|
607
|
+
|
606
608
|
var basics = parts[0].split('/');
|
607
609
|
|
608
610
|
holder.holderURL = url;
|
@@ -1779,9 +1781,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1779
1781
|
|
1780
1782
|
/***/ },
|
1781
1783
|
/* 5 */
|
1782
|
-
/***/ function(module, exports) {
|
1784
|
+
/***/ function(module, exports, __webpack_require__) {
|
1783
1785
|
|
1784
|
-
/**
|
1786
|
+
/* WEBPACK VAR INJECTION */(function(Buffer) {/**
|
1785
1787
|
* toString ref.
|
1786
1788
|
*/
|
1787
1789
|
|
@@ -1809,6 +1811,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1809
1811
|
if (val !== val) return 'nan';
|
1810
1812
|
if (val && val.nodeType === 1) return 'element';
|
1811
1813
|
|
1814
|
+
if (typeof Buffer != 'undefined' && Buffer.isBuffer(val)) return 'buffer';
|
1815
|
+
|
1812
1816
|
val = val.valueOf
|
1813
1817
|
? val.valueOf()
|
1814
1818
|
: Object.prototype.valueOf.apply(val)
|
@@ -1816,249 +1820,2060 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1816
1820
|
return typeof val;
|
1817
1821
|
};
|
1818
1822
|
|
1823
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).Buffer))
|
1819
1824
|
|
1820
1825
|
/***/ },
|
1821
1826
|
/* 6 */
|
1822
|
-
/***/ function(module, exports) {
|
1823
|
-
|
1824
|
-
var SceneGraph = function(sceneProperties) {
|
1825
|
-
var nodeCount = 1;
|
1826
|
-
|
1827
|
-
//todo: move merge to helpers section
|
1828
|
-
function merge(parent, child) {
|
1829
|
-
for (var prop in child) {
|
1830
|
-
parent[prop] = child[prop];
|
1831
|
-
}
|
1832
|
-
return parent;
|
1833
|
-
}
|
1834
|
-
|
1835
|
-
var SceneNode = function(name) {
|
1836
|
-
nodeCount++;
|
1837
|
-
this.parent = null;
|
1838
|
-
this.children = {};
|
1839
|
-
this.id = nodeCount;
|
1840
|
-
this.name = 'n' + nodeCount;
|
1841
|
-
if (typeof name !== 'undefined') {
|
1842
|
-
this.name = name;
|
1843
|
-
}
|
1844
|
-
this.x = this.y = this.z = 0;
|
1845
|
-
this.width = this.height = 0;
|
1846
|
-
};
|
1827
|
+
/***/ function(module, exports, __webpack_require__) {
|
1847
1828
|
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
};
|
1829
|
+
/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
|
1830
|
+
* The buffer module from node.js, for the browser.
|
1831
|
+
*
|
1832
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
1833
|
+
* @license MIT
|
1834
|
+
*/
|
1835
|
+
/* eslint-disable no-proto */
|
1856
1836
|
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
this.z = z != null ? z : this.z;
|
1861
|
-
};
|
1837
|
+
var base64 = __webpack_require__(7)
|
1838
|
+
var ieee754 = __webpack_require__(8)
|
1839
|
+
var isArray = __webpack_require__(9)
|
1862
1840
|
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
child.parent = this;
|
1868
|
-
} else {
|
1869
|
-
throw 'SceneGraph: child already exists: ' + name;
|
1870
|
-
}
|
1871
|
-
};
|
1841
|
+
exports.Buffer = Buffer
|
1842
|
+
exports.SlowBuffer = SlowBuffer
|
1843
|
+
exports.INSPECT_MAX_BYTES = 50
|
1844
|
+
Buffer.poolSize = 8192 // not used by this implementation
|
1872
1845
|
|
1873
|
-
|
1874
|
-
SceneNode.call(this, 'root');
|
1875
|
-
this.properties = sceneProperties;
|
1876
|
-
};
|
1846
|
+
var rootParent = {}
|
1877
1847
|
|
1878
|
-
|
1848
|
+
/**
|
1849
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
1850
|
+
* === true Use Uint8Array implementation (fastest)
|
1851
|
+
* === false Use Object implementation (most compatible, even IE6)
|
1852
|
+
*
|
1853
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
1854
|
+
* Opera 11.6+, iOS 4.2+.
|
1855
|
+
*
|
1856
|
+
* Due to various browser bugs, sometimes the Object implementation will be used even
|
1857
|
+
* when the browser supports typed arrays.
|
1858
|
+
*
|
1859
|
+
* Note:
|
1860
|
+
*
|
1861
|
+
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
1862
|
+
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
1863
|
+
*
|
1864
|
+
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
|
1865
|
+
* on objects.
|
1866
|
+
*
|
1867
|
+
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
1868
|
+
*
|
1869
|
+
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
1870
|
+
* incorrect length in some situations.
|
1879
1871
|
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1872
|
+
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
1873
|
+
* get the Object implementation, which is slower but behaves correctly.
|
1874
|
+
*/
|
1875
|
+
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
1876
|
+
? global.TYPED_ARRAY_SUPPORT
|
1877
|
+
: typedArraySupport()
|
1878
|
+
|
1879
|
+
function typedArraySupport () {
|
1880
|
+
function Bar () {}
|
1881
|
+
try {
|
1882
|
+
var arr = new Uint8Array(1)
|
1883
|
+
arr.foo = function () { return 42 }
|
1884
|
+
arr.constructor = Bar
|
1885
|
+
return arr.foo() === 42 && // typed array instances can be augmented
|
1886
|
+
arr.constructor === Bar && // constructor can be set
|
1887
|
+
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
1888
|
+
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
1889
|
+
} catch (e) {
|
1890
|
+
return false
|
1891
|
+
}
|
1892
|
+
}
|
1891
1893
|
|
1892
|
-
|
1894
|
+
function kMaxLength () {
|
1895
|
+
return Buffer.TYPED_ARRAY_SUPPORT
|
1896
|
+
? 0x7fffffff
|
1897
|
+
: 0x3fffffff
|
1898
|
+
}
|
1893
1899
|
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1900
|
+
/**
|
1901
|
+
* Class: Buffer
|
1902
|
+
* =============
|
1903
|
+
*
|
1904
|
+
* The Buffer constructor returns instances of `Uint8Array` that are augmented
|
1905
|
+
* with function properties for all the node `Buffer` API functions. We use
|
1906
|
+
* `Uint8Array` so that square bracket notation works as expected -- it returns
|
1907
|
+
* a single octet.
|
1908
|
+
*
|
1909
|
+
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
1910
|
+
* prototype.
|
1911
|
+
*/
|
1912
|
+
function Buffer (arg) {
|
1913
|
+
if (!(this instanceof Buffer)) {
|
1914
|
+
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
|
1915
|
+
if (arguments.length > 1) return new Buffer(arg, arguments[1])
|
1916
|
+
return new Buffer(arg)
|
1917
|
+
}
|
1898
1918
|
|
1899
|
-
|
1919
|
+
this.length = 0
|
1920
|
+
this.parent = undefined
|
1900
1921
|
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1922
|
+
// Common case.
|
1923
|
+
if (typeof arg === 'number') {
|
1924
|
+
return fromNumber(this, arg)
|
1925
|
+
}
|
1905
1926
|
|
1906
|
-
|
1927
|
+
// Slightly less common case.
|
1928
|
+
if (typeof arg === 'string') {
|
1929
|
+
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
|
1930
|
+
}
|
1907
1931
|
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
this.properties.text = text;
|
1912
|
-
};
|
1932
|
+
// Unusual.
|
1933
|
+
return fromObject(this, arg)
|
1934
|
+
}
|
1913
1935
|
|
1914
|
-
|
1936
|
+
function fromNumber (that, length) {
|
1937
|
+
that = allocate(that, length < 0 ? 0 : checked(length) | 0)
|
1938
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
1939
|
+
for (var i = 0; i < length; i++) {
|
1940
|
+
that[i] = 0
|
1941
|
+
}
|
1942
|
+
}
|
1943
|
+
return that
|
1944
|
+
}
|
1915
1945
|
|
1916
|
-
|
1946
|
+
function fromString (that, string, encoding) {
|
1947
|
+
if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
|
1917
1948
|
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
'Group': Group
|
1922
|
-
};
|
1949
|
+
// Assumption: byteLength() return value is always < kMaxLength.
|
1950
|
+
var length = byteLength(string, encoding) | 0
|
1951
|
+
that = allocate(that, length)
|
1923
1952
|
|
1924
|
-
|
1925
|
-
|
1926
|
-
}
|
1953
|
+
that.write(string, encoding)
|
1954
|
+
return that
|
1955
|
+
}
|
1927
1956
|
|
1928
|
-
|
1957
|
+
function fromObject (that, object) {
|
1958
|
+
if (Buffer.isBuffer(object)) return fromBuffer(that, object)
|
1929
1959
|
|
1960
|
+
if (isArray(object)) return fromArray(that, object)
|
1930
1961
|
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1962
|
+
if (object == null) {
|
1963
|
+
throw new TypeError('must start with number, buffer, array or string')
|
1964
|
+
}
|
1934
1965
|
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
* @param a Object A
|
1939
|
-
* @param b Object B
|
1940
|
-
* @returns {Object} New object with all of A's properties, and all of B's properties, overwriting A's properties
|
1941
|
-
*/
|
1942
|
-
exports.extend = function(a, b) {
|
1943
|
-
var c = {};
|
1944
|
-
for (var x in a) {
|
1945
|
-
if (a.hasOwnProperty(x)) {
|
1946
|
-
c[x] = a[x];
|
1947
|
-
}
|
1966
|
+
if (typeof ArrayBuffer !== 'undefined') {
|
1967
|
+
if (object.buffer instanceof ArrayBuffer) {
|
1968
|
+
return fromTypedArray(that, object)
|
1948
1969
|
}
|
1949
|
-
if (
|
1950
|
-
|
1951
|
-
if (b.hasOwnProperty(y)) {
|
1952
|
-
c[y] = b[y];
|
1953
|
-
}
|
1954
|
-
}
|
1970
|
+
if (object instanceof ArrayBuffer) {
|
1971
|
+
return fromArrayBuffer(that, object)
|
1955
1972
|
}
|
1956
|
-
|
1957
|
-
};
|
1973
|
+
}
|
1958
1974
|
|
1959
|
-
|
1960
|
-
* Takes a k/v list of CSS properties and returns a rule
|
1961
|
-
*
|
1962
|
-
* @param props CSS properties object
|
1963
|
-
*/
|
1964
|
-
exports.cssProps = function(props) {
|
1965
|
-
var ret = [];
|
1966
|
-
for (var p in props) {
|
1967
|
-
if (props.hasOwnProperty(p)) {
|
1968
|
-
ret.push(p + ':' + props[p]);
|
1969
|
-
}
|
1970
|
-
}
|
1971
|
-
return ret.join(';');
|
1972
|
-
};
|
1975
|
+
if (object.length) return fromArrayLike(that, object)
|
1973
1976
|
|
1974
|
-
|
1975
|
-
|
1976
|
-
*
|
1977
|
-
* @param str Input string
|
1978
|
-
*/
|
1979
|
-
exports.encodeHtmlEntity = function(str) {
|
1980
|
-
var buf = [];
|
1981
|
-
var charCode = 0;
|
1982
|
-
for (var i = str.length - 1; i >= 0; i--) {
|
1983
|
-
charCode = str.charCodeAt(i);
|
1984
|
-
if (charCode > 128) {
|
1985
|
-
buf.unshift(['&#', charCode, ';'].join(''));
|
1986
|
-
} else {
|
1987
|
-
buf.unshift(str[i]);
|
1988
|
-
}
|
1989
|
-
}
|
1990
|
-
return buf.join('');
|
1991
|
-
};
|
1977
|
+
return fromJsonObject(that, object)
|
1978
|
+
}
|
1992
1979
|
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
exports.imageExists = function(src, callback) {
|
2000
|
-
var image = new Image();
|
2001
|
-
image.onerror = function() {
|
2002
|
-
callback.call(this, false);
|
2003
|
-
};
|
2004
|
-
image.onload = function() {
|
2005
|
-
callback.call(this, true);
|
2006
|
-
};
|
2007
|
-
image.src = src;
|
2008
|
-
};
|
1980
|
+
function fromBuffer (that, buffer) {
|
1981
|
+
var length = checked(buffer.length) | 0
|
1982
|
+
that = allocate(that, length)
|
1983
|
+
buffer.copy(that, 0, 0, length)
|
1984
|
+
return that
|
1985
|
+
}
|
2009
1986
|
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
});
|
2019
|
-
};
|
1987
|
+
function fromArray (that, array) {
|
1988
|
+
var length = checked(array.length) | 0
|
1989
|
+
that = allocate(that, length)
|
1990
|
+
for (var i = 0; i < length; i += 1) {
|
1991
|
+
that[i] = array[i] & 255
|
1992
|
+
}
|
1993
|
+
return that
|
1994
|
+
}
|
2020
1995
|
|
1996
|
+
// Duplicate of fromArray() to keep fromArray() monomorphic.
|
1997
|
+
function fromTypedArray (that, array) {
|
1998
|
+
var length = checked(array.length) | 0
|
1999
|
+
that = allocate(that, length)
|
2000
|
+
// Truncating the elements is probably not what people expect from typed
|
2001
|
+
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
|
2002
|
+
// of the old Buffer constructor.
|
2003
|
+
for (var i = 0; i < length; i += 1) {
|
2004
|
+
that[i] = array[i] & 255
|
2005
|
+
}
|
2006
|
+
return that
|
2007
|
+
}
|
2021
2008
|
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2009
|
+
function fromArrayBuffer (that, array) {
|
2010
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2011
|
+
// Return an augmented `Uint8Array` instance, for best performance
|
2012
|
+
array.byteLength
|
2013
|
+
that = Buffer._augment(new Uint8Array(array))
|
2014
|
+
} else {
|
2015
|
+
// Fallback: Return an object instance of the Buffer class
|
2016
|
+
that = fromTypedArray(that, new Uint8Array(array))
|
2017
|
+
}
|
2018
|
+
return that
|
2019
|
+
}
|
2032
2020
|
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2021
|
+
function fromArrayLike (that, array) {
|
2022
|
+
var length = checked(array.length) | 0
|
2023
|
+
that = allocate(that, length)
|
2024
|
+
for (var i = 0; i < length; i += 1) {
|
2025
|
+
that[i] = array[i] & 255
|
2026
|
+
}
|
2027
|
+
return that
|
2028
|
+
}
|
2039
2029
|
|
2030
|
+
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
|
2031
|
+
// Returns a zero-length buffer for inputs that don't conform to the spec.
|
2032
|
+
function fromJsonObject (that, object) {
|
2033
|
+
var array
|
2034
|
+
var length = 0
|
2040
2035
|
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
if (typeof val === 'string') {
|
2047
|
-
return val === 'true' || val === 'yes' || val === '1' || val === 'on' || val === '✓';
|
2048
|
-
}
|
2049
|
-
return !!val;
|
2050
|
-
};
|
2036
|
+
if (object.type === 'Buffer' && isArray(object.data)) {
|
2037
|
+
array = object.data
|
2038
|
+
length = checked(array.length) | 0
|
2039
|
+
}
|
2040
|
+
that = allocate(that, length)
|
2051
2041
|
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
var hexre = /(^(?:#?)[0-9a-f]{6}$)|(^(?:#?)[0-9a-f]{3}$)/i;
|
2058
|
-
var rgbre = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
|
2059
|
-
var rgbare = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0\.\d{1,}|1)\)$/;
|
2042
|
+
for (var i = 0; i < length; i += 1) {
|
2043
|
+
that[i] = array[i] & 255
|
2044
|
+
}
|
2045
|
+
return that
|
2046
|
+
}
|
2060
2047
|
|
2061
|
-
|
2048
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2049
|
+
Buffer.prototype.__proto__ = Uint8Array.prototype
|
2050
|
+
Buffer.__proto__ = Uint8Array
|
2051
|
+
}
|
2052
|
+
|
2053
|
+
function allocate (that, length) {
|
2054
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2055
|
+
// Return an augmented `Uint8Array` instance, for best performance
|
2056
|
+
that = Buffer._augment(new Uint8Array(length))
|
2057
|
+
that.__proto__ = Buffer.prototype
|
2058
|
+
} else {
|
2059
|
+
// Fallback: Return an object instance of the Buffer class
|
2060
|
+
that.length = length
|
2061
|
+
that._isBuffer = true
|
2062
|
+
}
|
2063
|
+
|
2064
|
+
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
|
2065
|
+
if (fromPool) that.parent = rootParent
|
2066
|
+
|
2067
|
+
return that
|
2068
|
+
}
|
2069
|
+
|
2070
|
+
function checked (length) {
|
2071
|
+
// Note: cannot use `length < kMaxLength` here because that fails when
|
2072
|
+
// length is NaN (which is otherwise coerced to zero.)
|
2073
|
+
if (length >= kMaxLength()) {
|
2074
|
+
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
2075
|
+
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
2076
|
+
}
|
2077
|
+
return length | 0
|
2078
|
+
}
|
2079
|
+
|
2080
|
+
function SlowBuffer (subject, encoding) {
|
2081
|
+
if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
|
2082
|
+
|
2083
|
+
var buf = new Buffer(subject, encoding)
|
2084
|
+
delete buf.parent
|
2085
|
+
return buf
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
Buffer.isBuffer = function isBuffer (b) {
|
2089
|
+
return !!(b != null && b._isBuffer)
|
2090
|
+
}
|
2091
|
+
|
2092
|
+
Buffer.compare = function compare (a, b) {
|
2093
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
2094
|
+
throw new TypeError('Arguments must be Buffers')
|
2095
|
+
}
|
2096
|
+
|
2097
|
+
if (a === b) return 0
|
2098
|
+
|
2099
|
+
var x = a.length
|
2100
|
+
var y = b.length
|
2101
|
+
|
2102
|
+
var i = 0
|
2103
|
+
var len = Math.min(x, y)
|
2104
|
+
while (i < len) {
|
2105
|
+
if (a[i] !== b[i]) break
|
2106
|
+
|
2107
|
+
++i
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
if (i !== len) {
|
2111
|
+
x = a[i]
|
2112
|
+
y = b[i]
|
2113
|
+
}
|
2114
|
+
|
2115
|
+
if (x < y) return -1
|
2116
|
+
if (y < x) return 1
|
2117
|
+
return 0
|
2118
|
+
}
|
2119
|
+
|
2120
|
+
Buffer.isEncoding = function isEncoding (encoding) {
|
2121
|
+
switch (String(encoding).toLowerCase()) {
|
2122
|
+
case 'hex':
|
2123
|
+
case 'utf8':
|
2124
|
+
case 'utf-8':
|
2125
|
+
case 'ascii':
|
2126
|
+
case 'binary':
|
2127
|
+
case 'base64':
|
2128
|
+
case 'raw':
|
2129
|
+
case 'ucs2':
|
2130
|
+
case 'ucs-2':
|
2131
|
+
case 'utf16le':
|
2132
|
+
case 'utf-16le':
|
2133
|
+
return true
|
2134
|
+
default:
|
2135
|
+
return false
|
2136
|
+
}
|
2137
|
+
}
|
2138
|
+
|
2139
|
+
Buffer.concat = function concat (list, length) {
|
2140
|
+
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
2141
|
+
|
2142
|
+
if (list.length === 0) {
|
2143
|
+
return new Buffer(0)
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
var i
|
2147
|
+
if (length === undefined) {
|
2148
|
+
length = 0
|
2149
|
+
for (i = 0; i < list.length; i++) {
|
2150
|
+
length += list[i].length
|
2151
|
+
}
|
2152
|
+
}
|
2153
|
+
|
2154
|
+
var buf = new Buffer(length)
|
2155
|
+
var pos = 0
|
2156
|
+
for (i = 0; i < list.length; i++) {
|
2157
|
+
var item = list[i]
|
2158
|
+
item.copy(buf, pos)
|
2159
|
+
pos += item.length
|
2160
|
+
}
|
2161
|
+
return buf
|
2162
|
+
}
|
2163
|
+
|
2164
|
+
function byteLength (string, encoding) {
|
2165
|
+
if (typeof string !== 'string') string = '' + string
|
2166
|
+
|
2167
|
+
var len = string.length
|
2168
|
+
if (len === 0) return 0
|
2169
|
+
|
2170
|
+
// Use a for loop to avoid recursion
|
2171
|
+
var loweredCase = false
|
2172
|
+
for (;;) {
|
2173
|
+
switch (encoding) {
|
2174
|
+
case 'ascii':
|
2175
|
+
case 'binary':
|
2176
|
+
// Deprecated
|
2177
|
+
case 'raw':
|
2178
|
+
case 'raws':
|
2179
|
+
return len
|
2180
|
+
case 'utf8':
|
2181
|
+
case 'utf-8':
|
2182
|
+
return utf8ToBytes(string).length
|
2183
|
+
case 'ucs2':
|
2184
|
+
case 'ucs-2':
|
2185
|
+
case 'utf16le':
|
2186
|
+
case 'utf-16le':
|
2187
|
+
return len * 2
|
2188
|
+
case 'hex':
|
2189
|
+
return len >>> 1
|
2190
|
+
case 'base64':
|
2191
|
+
return base64ToBytes(string).length
|
2192
|
+
default:
|
2193
|
+
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
2194
|
+
encoding = ('' + encoding).toLowerCase()
|
2195
|
+
loweredCase = true
|
2196
|
+
}
|
2197
|
+
}
|
2198
|
+
}
|
2199
|
+
Buffer.byteLength = byteLength
|
2200
|
+
|
2201
|
+
// pre-set for values that may exist in the future
|
2202
|
+
Buffer.prototype.length = undefined
|
2203
|
+
Buffer.prototype.parent = undefined
|
2204
|
+
|
2205
|
+
function slowToString (encoding, start, end) {
|
2206
|
+
var loweredCase = false
|
2207
|
+
|
2208
|
+
start = start | 0
|
2209
|
+
end = end === undefined || end === Infinity ? this.length : end | 0
|
2210
|
+
|
2211
|
+
if (!encoding) encoding = 'utf8'
|
2212
|
+
if (start < 0) start = 0
|
2213
|
+
if (end > this.length) end = this.length
|
2214
|
+
if (end <= start) return ''
|
2215
|
+
|
2216
|
+
while (true) {
|
2217
|
+
switch (encoding) {
|
2218
|
+
case 'hex':
|
2219
|
+
return hexSlice(this, start, end)
|
2220
|
+
|
2221
|
+
case 'utf8':
|
2222
|
+
case 'utf-8':
|
2223
|
+
return utf8Slice(this, start, end)
|
2224
|
+
|
2225
|
+
case 'ascii':
|
2226
|
+
return asciiSlice(this, start, end)
|
2227
|
+
|
2228
|
+
case 'binary':
|
2229
|
+
return binarySlice(this, start, end)
|
2230
|
+
|
2231
|
+
case 'base64':
|
2232
|
+
return base64Slice(this, start, end)
|
2233
|
+
|
2234
|
+
case 'ucs2':
|
2235
|
+
case 'ucs-2':
|
2236
|
+
case 'utf16le':
|
2237
|
+
case 'utf-16le':
|
2238
|
+
return utf16leSlice(this, start, end)
|
2239
|
+
|
2240
|
+
default:
|
2241
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
2242
|
+
encoding = (encoding + '').toLowerCase()
|
2243
|
+
loweredCase = true
|
2244
|
+
}
|
2245
|
+
}
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
Buffer.prototype.toString = function toString () {
|
2249
|
+
var length = this.length | 0
|
2250
|
+
if (length === 0) return ''
|
2251
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
2252
|
+
return slowToString.apply(this, arguments)
|
2253
|
+
}
|
2254
|
+
|
2255
|
+
Buffer.prototype.equals = function equals (b) {
|
2256
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
2257
|
+
if (this === b) return true
|
2258
|
+
return Buffer.compare(this, b) === 0
|
2259
|
+
}
|
2260
|
+
|
2261
|
+
Buffer.prototype.inspect = function inspect () {
|
2262
|
+
var str = ''
|
2263
|
+
var max = exports.INSPECT_MAX_BYTES
|
2264
|
+
if (this.length > 0) {
|
2265
|
+
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
2266
|
+
if (this.length > max) str += ' ... '
|
2267
|
+
}
|
2268
|
+
return '<Buffer ' + str + '>'
|
2269
|
+
}
|
2270
|
+
|
2271
|
+
Buffer.prototype.compare = function compare (b) {
|
2272
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
2273
|
+
if (this === b) return 0
|
2274
|
+
return Buffer.compare(this, b)
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
|
2278
|
+
if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
|
2279
|
+
else if (byteOffset < -0x80000000) byteOffset = -0x80000000
|
2280
|
+
byteOffset >>= 0
|
2281
|
+
|
2282
|
+
if (this.length === 0) return -1
|
2283
|
+
if (byteOffset >= this.length) return -1
|
2284
|
+
|
2285
|
+
// Negative offsets start from the end of the buffer
|
2286
|
+
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
2287
|
+
|
2288
|
+
if (typeof val === 'string') {
|
2289
|
+
if (val.length === 0) return -1 // special case: looking for empty string always fails
|
2290
|
+
return String.prototype.indexOf.call(this, val, byteOffset)
|
2291
|
+
}
|
2292
|
+
if (Buffer.isBuffer(val)) {
|
2293
|
+
return arrayIndexOf(this, val, byteOffset)
|
2294
|
+
}
|
2295
|
+
if (typeof val === 'number') {
|
2296
|
+
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
2297
|
+
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
2298
|
+
}
|
2299
|
+
return arrayIndexOf(this, [ val ], byteOffset)
|
2300
|
+
}
|
2301
|
+
|
2302
|
+
function arrayIndexOf (arr, val, byteOffset) {
|
2303
|
+
var foundIndex = -1
|
2304
|
+
for (var i = 0; byteOffset + i < arr.length; i++) {
|
2305
|
+
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
2306
|
+
if (foundIndex === -1) foundIndex = i
|
2307
|
+
if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
|
2308
|
+
} else {
|
2309
|
+
foundIndex = -1
|
2310
|
+
}
|
2311
|
+
}
|
2312
|
+
return -1
|
2313
|
+
}
|
2314
|
+
|
2315
|
+
throw new TypeError('val must be string, number or Buffer')
|
2316
|
+
}
|
2317
|
+
|
2318
|
+
// `get` is deprecated
|
2319
|
+
Buffer.prototype.get = function get (offset) {
|
2320
|
+
console.log('.get() is deprecated. Access using array indexes instead.')
|
2321
|
+
return this.readUInt8(offset)
|
2322
|
+
}
|
2323
|
+
|
2324
|
+
// `set` is deprecated
|
2325
|
+
Buffer.prototype.set = function set (v, offset) {
|
2326
|
+
console.log('.set() is deprecated. Access using array indexes instead.')
|
2327
|
+
return this.writeUInt8(v, offset)
|
2328
|
+
}
|
2329
|
+
|
2330
|
+
function hexWrite (buf, string, offset, length) {
|
2331
|
+
offset = Number(offset) || 0
|
2332
|
+
var remaining = buf.length - offset
|
2333
|
+
if (!length) {
|
2334
|
+
length = remaining
|
2335
|
+
} else {
|
2336
|
+
length = Number(length)
|
2337
|
+
if (length > remaining) {
|
2338
|
+
length = remaining
|
2339
|
+
}
|
2340
|
+
}
|
2341
|
+
|
2342
|
+
// must be an even number of digits
|
2343
|
+
var strLen = string.length
|
2344
|
+
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
2345
|
+
|
2346
|
+
if (length > strLen / 2) {
|
2347
|
+
length = strLen / 2
|
2348
|
+
}
|
2349
|
+
for (var i = 0; i < length; i++) {
|
2350
|
+
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
2351
|
+
if (isNaN(parsed)) throw new Error('Invalid hex string')
|
2352
|
+
buf[offset + i] = parsed
|
2353
|
+
}
|
2354
|
+
return i
|
2355
|
+
}
|
2356
|
+
|
2357
|
+
function utf8Write (buf, string, offset, length) {
|
2358
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
2359
|
+
}
|
2360
|
+
|
2361
|
+
function asciiWrite (buf, string, offset, length) {
|
2362
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
2363
|
+
}
|
2364
|
+
|
2365
|
+
function binaryWrite (buf, string, offset, length) {
|
2366
|
+
return asciiWrite(buf, string, offset, length)
|
2367
|
+
}
|
2368
|
+
|
2369
|
+
function base64Write (buf, string, offset, length) {
|
2370
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
2371
|
+
}
|
2372
|
+
|
2373
|
+
function ucs2Write (buf, string, offset, length) {
|
2374
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
2378
|
+
// Buffer#write(string)
|
2379
|
+
if (offset === undefined) {
|
2380
|
+
encoding = 'utf8'
|
2381
|
+
length = this.length
|
2382
|
+
offset = 0
|
2383
|
+
// Buffer#write(string, encoding)
|
2384
|
+
} else if (length === undefined && typeof offset === 'string') {
|
2385
|
+
encoding = offset
|
2386
|
+
length = this.length
|
2387
|
+
offset = 0
|
2388
|
+
// Buffer#write(string, offset[, length][, encoding])
|
2389
|
+
} else if (isFinite(offset)) {
|
2390
|
+
offset = offset | 0
|
2391
|
+
if (isFinite(length)) {
|
2392
|
+
length = length | 0
|
2393
|
+
if (encoding === undefined) encoding = 'utf8'
|
2394
|
+
} else {
|
2395
|
+
encoding = length
|
2396
|
+
length = undefined
|
2397
|
+
}
|
2398
|
+
// legacy write(string, encoding, offset, length) - remove in v0.13
|
2399
|
+
} else {
|
2400
|
+
var swap = encoding
|
2401
|
+
encoding = offset
|
2402
|
+
offset = length | 0
|
2403
|
+
length = swap
|
2404
|
+
}
|
2405
|
+
|
2406
|
+
var remaining = this.length - offset
|
2407
|
+
if (length === undefined || length > remaining) length = remaining
|
2408
|
+
|
2409
|
+
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
2410
|
+
throw new RangeError('attempt to write outside buffer bounds')
|
2411
|
+
}
|
2412
|
+
|
2413
|
+
if (!encoding) encoding = 'utf8'
|
2414
|
+
|
2415
|
+
var loweredCase = false
|
2416
|
+
for (;;) {
|
2417
|
+
switch (encoding) {
|
2418
|
+
case 'hex':
|
2419
|
+
return hexWrite(this, string, offset, length)
|
2420
|
+
|
2421
|
+
case 'utf8':
|
2422
|
+
case 'utf-8':
|
2423
|
+
return utf8Write(this, string, offset, length)
|
2424
|
+
|
2425
|
+
case 'ascii':
|
2426
|
+
return asciiWrite(this, string, offset, length)
|
2427
|
+
|
2428
|
+
case 'binary':
|
2429
|
+
return binaryWrite(this, string, offset, length)
|
2430
|
+
|
2431
|
+
case 'base64':
|
2432
|
+
// Warning: maxLength not taken into account in base64Write
|
2433
|
+
return base64Write(this, string, offset, length)
|
2434
|
+
|
2435
|
+
case 'ucs2':
|
2436
|
+
case 'ucs-2':
|
2437
|
+
case 'utf16le':
|
2438
|
+
case 'utf-16le':
|
2439
|
+
return ucs2Write(this, string, offset, length)
|
2440
|
+
|
2441
|
+
default:
|
2442
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
2443
|
+
encoding = ('' + encoding).toLowerCase()
|
2444
|
+
loweredCase = true
|
2445
|
+
}
|
2446
|
+
}
|
2447
|
+
}
|
2448
|
+
|
2449
|
+
Buffer.prototype.toJSON = function toJSON () {
|
2450
|
+
return {
|
2451
|
+
type: 'Buffer',
|
2452
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
2453
|
+
}
|
2454
|
+
}
|
2455
|
+
|
2456
|
+
function base64Slice (buf, start, end) {
|
2457
|
+
if (start === 0 && end === buf.length) {
|
2458
|
+
return base64.fromByteArray(buf)
|
2459
|
+
} else {
|
2460
|
+
return base64.fromByteArray(buf.slice(start, end))
|
2461
|
+
}
|
2462
|
+
}
|
2463
|
+
|
2464
|
+
function utf8Slice (buf, start, end) {
|
2465
|
+
end = Math.min(buf.length, end)
|
2466
|
+
var res = []
|
2467
|
+
|
2468
|
+
var i = start
|
2469
|
+
while (i < end) {
|
2470
|
+
var firstByte = buf[i]
|
2471
|
+
var codePoint = null
|
2472
|
+
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
2473
|
+
: (firstByte > 0xDF) ? 3
|
2474
|
+
: (firstByte > 0xBF) ? 2
|
2475
|
+
: 1
|
2476
|
+
|
2477
|
+
if (i + bytesPerSequence <= end) {
|
2478
|
+
var secondByte, thirdByte, fourthByte, tempCodePoint
|
2479
|
+
|
2480
|
+
switch (bytesPerSequence) {
|
2481
|
+
case 1:
|
2482
|
+
if (firstByte < 0x80) {
|
2483
|
+
codePoint = firstByte
|
2484
|
+
}
|
2485
|
+
break
|
2486
|
+
case 2:
|
2487
|
+
secondByte = buf[i + 1]
|
2488
|
+
if ((secondByte & 0xC0) === 0x80) {
|
2489
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
2490
|
+
if (tempCodePoint > 0x7F) {
|
2491
|
+
codePoint = tempCodePoint
|
2492
|
+
}
|
2493
|
+
}
|
2494
|
+
break
|
2495
|
+
case 3:
|
2496
|
+
secondByte = buf[i + 1]
|
2497
|
+
thirdByte = buf[i + 2]
|
2498
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
2499
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
2500
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
2501
|
+
codePoint = tempCodePoint
|
2502
|
+
}
|
2503
|
+
}
|
2504
|
+
break
|
2505
|
+
case 4:
|
2506
|
+
secondByte = buf[i + 1]
|
2507
|
+
thirdByte = buf[i + 2]
|
2508
|
+
fourthByte = buf[i + 3]
|
2509
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
2510
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
2511
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
2512
|
+
codePoint = tempCodePoint
|
2513
|
+
}
|
2514
|
+
}
|
2515
|
+
}
|
2516
|
+
}
|
2517
|
+
|
2518
|
+
if (codePoint === null) {
|
2519
|
+
// we did not generate a valid codePoint so insert a
|
2520
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
2521
|
+
codePoint = 0xFFFD
|
2522
|
+
bytesPerSequence = 1
|
2523
|
+
} else if (codePoint > 0xFFFF) {
|
2524
|
+
// encode to utf16 (surrogate pair dance)
|
2525
|
+
codePoint -= 0x10000
|
2526
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
2527
|
+
codePoint = 0xDC00 | codePoint & 0x3FF
|
2528
|
+
}
|
2529
|
+
|
2530
|
+
res.push(codePoint)
|
2531
|
+
i += bytesPerSequence
|
2532
|
+
}
|
2533
|
+
|
2534
|
+
return decodeCodePointsArray(res)
|
2535
|
+
}
|
2536
|
+
|
2537
|
+
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
2538
|
+
// the lowest limit is Chrome, with 0x10000 args.
|
2539
|
+
// We go 1 magnitude less, for safety
|
2540
|
+
var MAX_ARGUMENTS_LENGTH = 0x1000
|
2541
|
+
|
2542
|
+
function decodeCodePointsArray (codePoints) {
|
2543
|
+
var len = codePoints.length
|
2544
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
2545
|
+
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
2546
|
+
}
|
2547
|
+
|
2548
|
+
// Decode in chunks to avoid "call stack size exceeded".
|
2549
|
+
var res = ''
|
2550
|
+
var i = 0
|
2551
|
+
while (i < len) {
|
2552
|
+
res += String.fromCharCode.apply(
|
2553
|
+
String,
|
2554
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
2555
|
+
)
|
2556
|
+
}
|
2557
|
+
return res
|
2558
|
+
}
|
2559
|
+
|
2560
|
+
function asciiSlice (buf, start, end) {
|
2561
|
+
var ret = ''
|
2562
|
+
end = Math.min(buf.length, end)
|
2563
|
+
|
2564
|
+
for (var i = start; i < end; i++) {
|
2565
|
+
ret += String.fromCharCode(buf[i] & 0x7F)
|
2566
|
+
}
|
2567
|
+
return ret
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
function binarySlice (buf, start, end) {
|
2571
|
+
var ret = ''
|
2572
|
+
end = Math.min(buf.length, end)
|
2573
|
+
|
2574
|
+
for (var i = start; i < end; i++) {
|
2575
|
+
ret += String.fromCharCode(buf[i])
|
2576
|
+
}
|
2577
|
+
return ret
|
2578
|
+
}
|
2579
|
+
|
2580
|
+
function hexSlice (buf, start, end) {
|
2581
|
+
var len = buf.length
|
2582
|
+
|
2583
|
+
if (!start || start < 0) start = 0
|
2584
|
+
if (!end || end < 0 || end > len) end = len
|
2585
|
+
|
2586
|
+
var out = ''
|
2587
|
+
for (var i = start; i < end; i++) {
|
2588
|
+
out += toHex(buf[i])
|
2589
|
+
}
|
2590
|
+
return out
|
2591
|
+
}
|
2592
|
+
|
2593
|
+
function utf16leSlice (buf, start, end) {
|
2594
|
+
var bytes = buf.slice(start, end)
|
2595
|
+
var res = ''
|
2596
|
+
for (var i = 0; i < bytes.length; i += 2) {
|
2597
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
2598
|
+
}
|
2599
|
+
return res
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
Buffer.prototype.slice = function slice (start, end) {
|
2603
|
+
var len = this.length
|
2604
|
+
start = ~~start
|
2605
|
+
end = end === undefined ? len : ~~end
|
2606
|
+
|
2607
|
+
if (start < 0) {
|
2608
|
+
start += len
|
2609
|
+
if (start < 0) start = 0
|
2610
|
+
} else if (start > len) {
|
2611
|
+
start = len
|
2612
|
+
}
|
2613
|
+
|
2614
|
+
if (end < 0) {
|
2615
|
+
end += len
|
2616
|
+
if (end < 0) end = 0
|
2617
|
+
} else if (end > len) {
|
2618
|
+
end = len
|
2619
|
+
}
|
2620
|
+
|
2621
|
+
if (end < start) end = start
|
2622
|
+
|
2623
|
+
var newBuf
|
2624
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2625
|
+
newBuf = Buffer._augment(this.subarray(start, end))
|
2626
|
+
} else {
|
2627
|
+
var sliceLen = end - start
|
2628
|
+
newBuf = new Buffer(sliceLen, undefined)
|
2629
|
+
for (var i = 0; i < sliceLen; i++) {
|
2630
|
+
newBuf[i] = this[i + start]
|
2631
|
+
}
|
2632
|
+
}
|
2633
|
+
|
2634
|
+
if (newBuf.length) newBuf.parent = this.parent || this
|
2635
|
+
|
2636
|
+
return newBuf
|
2637
|
+
}
|
2638
|
+
|
2639
|
+
/*
|
2640
|
+
* Need to make sure that buffer isn't trying to write out of bounds.
|
2641
|
+
*/
|
2642
|
+
function checkOffset (offset, ext, length) {
|
2643
|
+
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
2644
|
+
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
2645
|
+
}
|
2646
|
+
|
2647
|
+
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
2648
|
+
offset = offset | 0
|
2649
|
+
byteLength = byteLength | 0
|
2650
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
2651
|
+
|
2652
|
+
var val = this[offset]
|
2653
|
+
var mul = 1
|
2654
|
+
var i = 0
|
2655
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
2656
|
+
val += this[offset + i] * mul
|
2657
|
+
}
|
2658
|
+
|
2659
|
+
return val
|
2660
|
+
}
|
2661
|
+
|
2662
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
2663
|
+
offset = offset | 0
|
2664
|
+
byteLength = byteLength | 0
|
2665
|
+
if (!noAssert) {
|
2666
|
+
checkOffset(offset, byteLength, this.length)
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
var val = this[offset + --byteLength]
|
2670
|
+
var mul = 1
|
2671
|
+
while (byteLength > 0 && (mul *= 0x100)) {
|
2672
|
+
val += this[offset + --byteLength] * mul
|
2673
|
+
}
|
2674
|
+
|
2675
|
+
return val
|
2676
|
+
}
|
2677
|
+
|
2678
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
2679
|
+
if (!noAssert) checkOffset(offset, 1, this.length)
|
2680
|
+
return this[offset]
|
2681
|
+
}
|
2682
|
+
|
2683
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
2684
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
2685
|
+
return this[offset] | (this[offset + 1] << 8)
|
2686
|
+
}
|
2687
|
+
|
2688
|
+
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
2689
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
2690
|
+
return (this[offset] << 8) | this[offset + 1]
|
2691
|
+
}
|
2692
|
+
|
2693
|
+
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
2694
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2695
|
+
|
2696
|
+
return ((this[offset]) |
|
2697
|
+
(this[offset + 1] << 8) |
|
2698
|
+
(this[offset + 2] << 16)) +
|
2699
|
+
(this[offset + 3] * 0x1000000)
|
2700
|
+
}
|
2701
|
+
|
2702
|
+
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
2703
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2704
|
+
|
2705
|
+
return (this[offset] * 0x1000000) +
|
2706
|
+
((this[offset + 1] << 16) |
|
2707
|
+
(this[offset + 2] << 8) |
|
2708
|
+
this[offset + 3])
|
2709
|
+
}
|
2710
|
+
|
2711
|
+
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
2712
|
+
offset = offset | 0
|
2713
|
+
byteLength = byteLength | 0
|
2714
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
2715
|
+
|
2716
|
+
var val = this[offset]
|
2717
|
+
var mul = 1
|
2718
|
+
var i = 0
|
2719
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
2720
|
+
val += this[offset + i] * mul
|
2721
|
+
}
|
2722
|
+
mul *= 0x80
|
2723
|
+
|
2724
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
2725
|
+
|
2726
|
+
return val
|
2727
|
+
}
|
2728
|
+
|
2729
|
+
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
2730
|
+
offset = offset | 0
|
2731
|
+
byteLength = byteLength | 0
|
2732
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
2733
|
+
|
2734
|
+
var i = byteLength
|
2735
|
+
var mul = 1
|
2736
|
+
var val = this[offset + --i]
|
2737
|
+
while (i > 0 && (mul *= 0x100)) {
|
2738
|
+
val += this[offset + --i] * mul
|
2739
|
+
}
|
2740
|
+
mul *= 0x80
|
2741
|
+
|
2742
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
2743
|
+
|
2744
|
+
return val
|
2745
|
+
}
|
2746
|
+
|
2747
|
+
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
2748
|
+
if (!noAssert) checkOffset(offset, 1, this.length)
|
2749
|
+
if (!(this[offset] & 0x80)) return (this[offset])
|
2750
|
+
return ((0xff - this[offset] + 1) * -1)
|
2751
|
+
}
|
2752
|
+
|
2753
|
+
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
2754
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
2755
|
+
var val = this[offset] | (this[offset + 1] << 8)
|
2756
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
2757
|
+
}
|
2758
|
+
|
2759
|
+
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
2760
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
2761
|
+
var val = this[offset + 1] | (this[offset] << 8)
|
2762
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
2763
|
+
}
|
2764
|
+
|
2765
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
2766
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2767
|
+
|
2768
|
+
return (this[offset]) |
|
2769
|
+
(this[offset + 1] << 8) |
|
2770
|
+
(this[offset + 2] << 16) |
|
2771
|
+
(this[offset + 3] << 24)
|
2772
|
+
}
|
2773
|
+
|
2774
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
2775
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2776
|
+
|
2777
|
+
return (this[offset] << 24) |
|
2778
|
+
(this[offset + 1] << 16) |
|
2779
|
+
(this[offset + 2] << 8) |
|
2780
|
+
(this[offset + 3])
|
2781
|
+
}
|
2782
|
+
|
2783
|
+
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
2784
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2785
|
+
return ieee754.read(this, offset, true, 23, 4)
|
2786
|
+
}
|
2787
|
+
|
2788
|
+
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
2789
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
2790
|
+
return ieee754.read(this, offset, false, 23, 4)
|
2791
|
+
}
|
2792
|
+
|
2793
|
+
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
2794
|
+
if (!noAssert) checkOffset(offset, 8, this.length)
|
2795
|
+
return ieee754.read(this, offset, true, 52, 8)
|
2796
|
+
}
|
2797
|
+
|
2798
|
+
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
2799
|
+
if (!noAssert) checkOffset(offset, 8, this.length)
|
2800
|
+
return ieee754.read(this, offset, false, 52, 8)
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
function checkInt (buf, value, offset, ext, max, min) {
|
2804
|
+
if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
|
2805
|
+
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
2806
|
+
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
2807
|
+
}
|
2808
|
+
|
2809
|
+
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
2810
|
+
value = +value
|
2811
|
+
offset = offset | 0
|
2812
|
+
byteLength = byteLength | 0
|
2813
|
+
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
2814
|
+
|
2815
|
+
var mul = 1
|
2816
|
+
var i = 0
|
2817
|
+
this[offset] = value & 0xFF
|
2818
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
2819
|
+
this[offset + i] = (value / mul) & 0xFF
|
2820
|
+
}
|
2821
|
+
|
2822
|
+
return offset + byteLength
|
2823
|
+
}
|
2824
|
+
|
2825
|
+
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
2826
|
+
value = +value
|
2827
|
+
offset = offset | 0
|
2828
|
+
byteLength = byteLength | 0
|
2829
|
+
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
2830
|
+
|
2831
|
+
var i = byteLength - 1
|
2832
|
+
var mul = 1
|
2833
|
+
this[offset + i] = value & 0xFF
|
2834
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
2835
|
+
this[offset + i] = (value / mul) & 0xFF
|
2836
|
+
}
|
2837
|
+
|
2838
|
+
return offset + byteLength
|
2839
|
+
}
|
2840
|
+
|
2841
|
+
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
2842
|
+
value = +value
|
2843
|
+
offset = offset | 0
|
2844
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
2845
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
2846
|
+
this[offset] = (value & 0xff)
|
2847
|
+
return offset + 1
|
2848
|
+
}
|
2849
|
+
|
2850
|
+
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
2851
|
+
if (value < 0) value = 0xffff + value + 1
|
2852
|
+
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
2853
|
+
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
2854
|
+
(littleEndian ? i : 1 - i) * 8
|
2855
|
+
}
|
2856
|
+
}
|
2857
|
+
|
2858
|
+
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
2859
|
+
value = +value
|
2860
|
+
offset = offset | 0
|
2861
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
2862
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2863
|
+
this[offset] = (value & 0xff)
|
2864
|
+
this[offset + 1] = (value >>> 8)
|
2865
|
+
} else {
|
2866
|
+
objectWriteUInt16(this, value, offset, true)
|
2867
|
+
}
|
2868
|
+
return offset + 2
|
2869
|
+
}
|
2870
|
+
|
2871
|
+
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
2872
|
+
value = +value
|
2873
|
+
offset = offset | 0
|
2874
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
2875
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2876
|
+
this[offset] = (value >>> 8)
|
2877
|
+
this[offset + 1] = (value & 0xff)
|
2878
|
+
} else {
|
2879
|
+
objectWriteUInt16(this, value, offset, false)
|
2880
|
+
}
|
2881
|
+
return offset + 2
|
2882
|
+
}
|
2883
|
+
|
2884
|
+
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
2885
|
+
if (value < 0) value = 0xffffffff + value + 1
|
2886
|
+
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
2887
|
+
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
2888
|
+
}
|
2889
|
+
}
|
2890
|
+
|
2891
|
+
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
2892
|
+
value = +value
|
2893
|
+
offset = offset | 0
|
2894
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
2895
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2896
|
+
this[offset + 3] = (value >>> 24)
|
2897
|
+
this[offset + 2] = (value >>> 16)
|
2898
|
+
this[offset + 1] = (value >>> 8)
|
2899
|
+
this[offset] = (value & 0xff)
|
2900
|
+
} else {
|
2901
|
+
objectWriteUInt32(this, value, offset, true)
|
2902
|
+
}
|
2903
|
+
return offset + 4
|
2904
|
+
}
|
2905
|
+
|
2906
|
+
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
2907
|
+
value = +value
|
2908
|
+
offset = offset | 0
|
2909
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
2910
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2911
|
+
this[offset] = (value >>> 24)
|
2912
|
+
this[offset + 1] = (value >>> 16)
|
2913
|
+
this[offset + 2] = (value >>> 8)
|
2914
|
+
this[offset + 3] = (value & 0xff)
|
2915
|
+
} else {
|
2916
|
+
objectWriteUInt32(this, value, offset, false)
|
2917
|
+
}
|
2918
|
+
return offset + 4
|
2919
|
+
}
|
2920
|
+
|
2921
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
2922
|
+
value = +value
|
2923
|
+
offset = offset | 0
|
2924
|
+
if (!noAssert) {
|
2925
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
2926
|
+
|
2927
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
2928
|
+
}
|
2929
|
+
|
2930
|
+
var i = 0
|
2931
|
+
var mul = 1
|
2932
|
+
var sub = value < 0 ? 1 : 0
|
2933
|
+
this[offset] = value & 0xFF
|
2934
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
2935
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
2936
|
+
}
|
2937
|
+
|
2938
|
+
return offset + byteLength
|
2939
|
+
}
|
2940
|
+
|
2941
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
2942
|
+
value = +value
|
2943
|
+
offset = offset | 0
|
2944
|
+
if (!noAssert) {
|
2945
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
2946
|
+
|
2947
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
2948
|
+
}
|
2949
|
+
|
2950
|
+
var i = byteLength - 1
|
2951
|
+
var mul = 1
|
2952
|
+
var sub = value < 0 ? 1 : 0
|
2953
|
+
this[offset + i] = value & 0xFF
|
2954
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
2955
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
2956
|
+
}
|
2957
|
+
|
2958
|
+
return offset + byteLength
|
2959
|
+
}
|
2960
|
+
|
2961
|
+
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
2962
|
+
value = +value
|
2963
|
+
offset = offset | 0
|
2964
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
2965
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
2966
|
+
if (value < 0) value = 0xff + value + 1
|
2967
|
+
this[offset] = (value & 0xff)
|
2968
|
+
return offset + 1
|
2969
|
+
}
|
2970
|
+
|
2971
|
+
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
2972
|
+
value = +value
|
2973
|
+
offset = offset | 0
|
2974
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
2975
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2976
|
+
this[offset] = (value & 0xff)
|
2977
|
+
this[offset + 1] = (value >>> 8)
|
2978
|
+
} else {
|
2979
|
+
objectWriteUInt16(this, value, offset, true)
|
2980
|
+
}
|
2981
|
+
return offset + 2
|
2982
|
+
}
|
2983
|
+
|
2984
|
+
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
2985
|
+
value = +value
|
2986
|
+
offset = offset | 0
|
2987
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
2988
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
2989
|
+
this[offset] = (value >>> 8)
|
2990
|
+
this[offset + 1] = (value & 0xff)
|
2991
|
+
} else {
|
2992
|
+
objectWriteUInt16(this, value, offset, false)
|
2993
|
+
}
|
2994
|
+
return offset + 2
|
2995
|
+
}
|
2996
|
+
|
2997
|
+
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
2998
|
+
value = +value
|
2999
|
+
offset = offset | 0
|
3000
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
3001
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
3002
|
+
this[offset] = (value & 0xff)
|
3003
|
+
this[offset + 1] = (value >>> 8)
|
3004
|
+
this[offset + 2] = (value >>> 16)
|
3005
|
+
this[offset + 3] = (value >>> 24)
|
3006
|
+
} else {
|
3007
|
+
objectWriteUInt32(this, value, offset, true)
|
3008
|
+
}
|
3009
|
+
return offset + 4
|
3010
|
+
}
|
3011
|
+
|
3012
|
+
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
3013
|
+
value = +value
|
3014
|
+
offset = offset | 0
|
3015
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
3016
|
+
if (value < 0) value = 0xffffffff + value + 1
|
3017
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
3018
|
+
this[offset] = (value >>> 24)
|
3019
|
+
this[offset + 1] = (value >>> 16)
|
3020
|
+
this[offset + 2] = (value >>> 8)
|
3021
|
+
this[offset + 3] = (value & 0xff)
|
3022
|
+
} else {
|
3023
|
+
objectWriteUInt32(this, value, offset, false)
|
3024
|
+
}
|
3025
|
+
return offset + 4
|
3026
|
+
}
|
3027
|
+
|
3028
|
+
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
3029
|
+
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
3030
|
+
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
3031
|
+
if (offset < 0) throw new RangeError('index out of range')
|
3032
|
+
}
|
3033
|
+
|
3034
|
+
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
3035
|
+
if (!noAssert) {
|
3036
|
+
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
3037
|
+
}
|
3038
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
3039
|
+
return offset + 4
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
3043
|
+
return writeFloat(this, value, offset, true, noAssert)
|
3044
|
+
}
|
3045
|
+
|
3046
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
3047
|
+
return writeFloat(this, value, offset, false, noAssert)
|
3048
|
+
}
|
3049
|
+
|
3050
|
+
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
3051
|
+
if (!noAssert) {
|
3052
|
+
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
3053
|
+
}
|
3054
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
3055
|
+
return offset + 8
|
3056
|
+
}
|
3057
|
+
|
3058
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
3059
|
+
return writeDouble(this, value, offset, true, noAssert)
|
3060
|
+
}
|
3061
|
+
|
3062
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
3063
|
+
return writeDouble(this, value, offset, false, noAssert)
|
3064
|
+
}
|
3065
|
+
|
3066
|
+
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
3067
|
+
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
3068
|
+
if (!start) start = 0
|
3069
|
+
if (!end && end !== 0) end = this.length
|
3070
|
+
if (targetStart >= target.length) targetStart = target.length
|
3071
|
+
if (!targetStart) targetStart = 0
|
3072
|
+
if (end > 0 && end < start) end = start
|
3073
|
+
|
3074
|
+
// Copy 0 bytes; we're done
|
3075
|
+
if (end === start) return 0
|
3076
|
+
if (target.length === 0 || this.length === 0) return 0
|
3077
|
+
|
3078
|
+
// Fatal error conditions
|
3079
|
+
if (targetStart < 0) {
|
3080
|
+
throw new RangeError('targetStart out of bounds')
|
3081
|
+
}
|
3082
|
+
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
3083
|
+
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
3084
|
+
|
3085
|
+
// Are we oob?
|
3086
|
+
if (end > this.length) end = this.length
|
3087
|
+
if (target.length - targetStart < end - start) {
|
3088
|
+
end = target.length - targetStart + start
|
3089
|
+
}
|
3090
|
+
|
3091
|
+
var len = end - start
|
3092
|
+
var i
|
3093
|
+
|
3094
|
+
if (this === target && start < targetStart && targetStart < end) {
|
3095
|
+
// descending copy from end
|
3096
|
+
for (i = len - 1; i >= 0; i--) {
|
3097
|
+
target[i + targetStart] = this[i + start]
|
3098
|
+
}
|
3099
|
+
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
3100
|
+
// ascending copy from start
|
3101
|
+
for (i = 0; i < len; i++) {
|
3102
|
+
target[i + targetStart] = this[i + start]
|
3103
|
+
}
|
3104
|
+
} else {
|
3105
|
+
target._set(this.subarray(start, start + len), targetStart)
|
3106
|
+
}
|
3107
|
+
|
3108
|
+
return len
|
3109
|
+
}
|
3110
|
+
|
3111
|
+
// fill(value, start=0, end=buffer.length)
|
3112
|
+
Buffer.prototype.fill = function fill (value, start, end) {
|
3113
|
+
if (!value) value = 0
|
3114
|
+
if (!start) start = 0
|
3115
|
+
if (!end) end = this.length
|
3116
|
+
|
3117
|
+
if (end < start) throw new RangeError('end < start')
|
3118
|
+
|
3119
|
+
// Fill 0 bytes; we're done
|
3120
|
+
if (end === start) return
|
3121
|
+
if (this.length === 0) return
|
3122
|
+
|
3123
|
+
if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
|
3124
|
+
if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
|
3125
|
+
|
3126
|
+
var i
|
3127
|
+
if (typeof value === 'number') {
|
3128
|
+
for (i = start; i < end; i++) {
|
3129
|
+
this[i] = value
|
3130
|
+
}
|
3131
|
+
} else {
|
3132
|
+
var bytes = utf8ToBytes(value.toString())
|
3133
|
+
var len = bytes.length
|
3134
|
+
for (i = start; i < end; i++) {
|
3135
|
+
this[i] = bytes[i % len]
|
3136
|
+
}
|
3137
|
+
}
|
3138
|
+
|
3139
|
+
return this
|
3140
|
+
}
|
3141
|
+
|
3142
|
+
/**
|
3143
|
+
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
3144
|
+
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
3145
|
+
*/
|
3146
|
+
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
3147
|
+
if (typeof Uint8Array !== 'undefined') {
|
3148
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
3149
|
+
return (new Buffer(this)).buffer
|
3150
|
+
} else {
|
3151
|
+
var buf = new Uint8Array(this.length)
|
3152
|
+
for (var i = 0, len = buf.length; i < len; i += 1) {
|
3153
|
+
buf[i] = this[i]
|
3154
|
+
}
|
3155
|
+
return buf.buffer
|
3156
|
+
}
|
3157
|
+
} else {
|
3158
|
+
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
3159
|
+
}
|
3160
|
+
}
|
3161
|
+
|
3162
|
+
// HELPER FUNCTIONS
|
3163
|
+
// ================
|
3164
|
+
|
3165
|
+
var BP = Buffer.prototype
|
3166
|
+
|
3167
|
+
/**
|
3168
|
+
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
3169
|
+
*/
|
3170
|
+
Buffer._augment = function _augment (arr) {
|
3171
|
+
arr.constructor = Buffer
|
3172
|
+
arr._isBuffer = true
|
3173
|
+
|
3174
|
+
// save reference to original Uint8Array set method before overwriting
|
3175
|
+
arr._set = arr.set
|
3176
|
+
|
3177
|
+
// deprecated
|
3178
|
+
arr.get = BP.get
|
3179
|
+
arr.set = BP.set
|
3180
|
+
|
3181
|
+
arr.write = BP.write
|
3182
|
+
arr.toString = BP.toString
|
3183
|
+
arr.toLocaleString = BP.toString
|
3184
|
+
arr.toJSON = BP.toJSON
|
3185
|
+
arr.equals = BP.equals
|
3186
|
+
arr.compare = BP.compare
|
3187
|
+
arr.indexOf = BP.indexOf
|
3188
|
+
arr.copy = BP.copy
|
3189
|
+
arr.slice = BP.slice
|
3190
|
+
arr.readUIntLE = BP.readUIntLE
|
3191
|
+
arr.readUIntBE = BP.readUIntBE
|
3192
|
+
arr.readUInt8 = BP.readUInt8
|
3193
|
+
arr.readUInt16LE = BP.readUInt16LE
|
3194
|
+
arr.readUInt16BE = BP.readUInt16BE
|
3195
|
+
arr.readUInt32LE = BP.readUInt32LE
|
3196
|
+
arr.readUInt32BE = BP.readUInt32BE
|
3197
|
+
arr.readIntLE = BP.readIntLE
|
3198
|
+
arr.readIntBE = BP.readIntBE
|
3199
|
+
arr.readInt8 = BP.readInt8
|
3200
|
+
arr.readInt16LE = BP.readInt16LE
|
3201
|
+
arr.readInt16BE = BP.readInt16BE
|
3202
|
+
arr.readInt32LE = BP.readInt32LE
|
3203
|
+
arr.readInt32BE = BP.readInt32BE
|
3204
|
+
arr.readFloatLE = BP.readFloatLE
|
3205
|
+
arr.readFloatBE = BP.readFloatBE
|
3206
|
+
arr.readDoubleLE = BP.readDoubleLE
|
3207
|
+
arr.readDoubleBE = BP.readDoubleBE
|
3208
|
+
arr.writeUInt8 = BP.writeUInt8
|
3209
|
+
arr.writeUIntLE = BP.writeUIntLE
|
3210
|
+
arr.writeUIntBE = BP.writeUIntBE
|
3211
|
+
arr.writeUInt16LE = BP.writeUInt16LE
|
3212
|
+
arr.writeUInt16BE = BP.writeUInt16BE
|
3213
|
+
arr.writeUInt32LE = BP.writeUInt32LE
|
3214
|
+
arr.writeUInt32BE = BP.writeUInt32BE
|
3215
|
+
arr.writeIntLE = BP.writeIntLE
|
3216
|
+
arr.writeIntBE = BP.writeIntBE
|
3217
|
+
arr.writeInt8 = BP.writeInt8
|
3218
|
+
arr.writeInt16LE = BP.writeInt16LE
|
3219
|
+
arr.writeInt16BE = BP.writeInt16BE
|
3220
|
+
arr.writeInt32LE = BP.writeInt32LE
|
3221
|
+
arr.writeInt32BE = BP.writeInt32BE
|
3222
|
+
arr.writeFloatLE = BP.writeFloatLE
|
3223
|
+
arr.writeFloatBE = BP.writeFloatBE
|
3224
|
+
arr.writeDoubleLE = BP.writeDoubleLE
|
3225
|
+
arr.writeDoubleBE = BP.writeDoubleBE
|
3226
|
+
arr.fill = BP.fill
|
3227
|
+
arr.inspect = BP.inspect
|
3228
|
+
arr.toArrayBuffer = BP.toArrayBuffer
|
3229
|
+
|
3230
|
+
return arr
|
3231
|
+
}
|
3232
|
+
|
3233
|
+
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
3234
|
+
|
3235
|
+
function base64clean (str) {
|
3236
|
+
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
3237
|
+
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
3238
|
+
// Node converts strings with length < 2 to ''
|
3239
|
+
if (str.length < 2) return ''
|
3240
|
+
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
3241
|
+
while (str.length % 4 !== 0) {
|
3242
|
+
str = str + '='
|
3243
|
+
}
|
3244
|
+
return str
|
3245
|
+
}
|
3246
|
+
|
3247
|
+
function stringtrim (str) {
|
3248
|
+
if (str.trim) return str.trim()
|
3249
|
+
return str.replace(/^\s+|\s+$/g, '')
|
3250
|
+
}
|
3251
|
+
|
3252
|
+
function toHex (n) {
|
3253
|
+
if (n < 16) return '0' + n.toString(16)
|
3254
|
+
return n.toString(16)
|
3255
|
+
}
|
3256
|
+
|
3257
|
+
function utf8ToBytes (string, units) {
|
3258
|
+
units = units || Infinity
|
3259
|
+
var codePoint
|
3260
|
+
var length = string.length
|
3261
|
+
var leadSurrogate = null
|
3262
|
+
var bytes = []
|
3263
|
+
|
3264
|
+
for (var i = 0; i < length; i++) {
|
3265
|
+
codePoint = string.charCodeAt(i)
|
3266
|
+
|
3267
|
+
// is surrogate component
|
3268
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
3269
|
+
// last char was a lead
|
3270
|
+
if (!leadSurrogate) {
|
3271
|
+
// no lead yet
|
3272
|
+
if (codePoint > 0xDBFF) {
|
3273
|
+
// unexpected trail
|
3274
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3275
|
+
continue
|
3276
|
+
} else if (i + 1 === length) {
|
3277
|
+
// unpaired lead
|
3278
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3279
|
+
continue
|
3280
|
+
}
|
3281
|
+
|
3282
|
+
// valid lead
|
3283
|
+
leadSurrogate = codePoint
|
3284
|
+
|
3285
|
+
continue
|
3286
|
+
}
|
3287
|
+
|
3288
|
+
// 2 leads in a row
|
3289
|
+
if (codePoint < 0xDC00) {
|
3290
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3291
|
+
leadSurrogate = codePoint
|
3292
|
+
continue
|
3293
|
+
}
|
3294
|
+
|
3295
|
+
// valid surrogate pair
|
3296
|
+
codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
|
3297
|
+
} else if (leadSurrogate) {
|
3298
|
+
// valid bmp char, but last char was a lead
|
3299
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
3300
|
+
}
|
3301
|
+
|
3302
|
+
leadSurrogate = null
|
3303
|
+
|
3304
|
+
// encode utf8
|
3305
|
+
if (codePoint < 0x80) {
|
3306
|
+
if ((units -= 1) < 0) break
|
3307
|
+
bytes.push(codePoint)
|
3308
|
+
} else if (codePoint < 0x800) {
|
3309
|
+
if ((units -= 2) < 0) break
|
3310
|
+
bytes.push(
|
3311
|
+
codePoint >> 0x6 | 0xC0,
|
3312
|
+
codePoint & 0x3F | 0x80
|
3313
|
+
)
|
3314
|
+
} else if (codePoint < 0x10000) {
|
3315
|
+
if ((units -= 3) < 0) break
|
3316
|
+
bytes.push(
|
3317
|
+
codePoint >> 0xC | 0xE0,
|
3318
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
3319
|
+
codePoint & 0x3F | 0x80
|
3320
|
+
)
|
3321
|
+
} else if (codePoint < 0x110000) {
|
3322
|
+
if ((units -= 4) < 0) break
|
3323
|
+
bytes.push(
|
3324
|
+
codePoint >> 0x12 | 0xF0,
|
3325
|
+
codePoint >> 0xC & 0x3F | 0x80,
|
3326
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
3327
|
+
codePoint & 0x3F | 0x80
|
3328
|
+
)
|
3329
|
+
} else {
|
3330
|
+
throw new Error('Invalid code point')
|
3331
|
+
}
|
3332
|
+
}
|
3333
|
+
|
3334
|
+
return bytes
|
3335
|
+
}
|
3336
|
+
|
3337
|
+
function asciiToBytes (str) {
|
3338
|
+
var byteArray = []
|
3339
|
+
for (var i = 0; i < str.length; i++) {
|
3340
|
+
// Node's code seems to be doing this and not & 0x7F..
|
3341
|
+
byteArray.push(str.charCodeAt(i) & 0xFF)
|
3342
|
+
}
|
3343
|
+
return byteArray
|
3344
|
+
}
|
3345
|
+
|
3346
|
+
function utf16leToBytes (str, units) {
|
3347
|
+
var c, hi, lo
|
3348
|
+
var byteArray = []
|
3349
|
+
for (var i = 0; i < str.length; i++) {
|
3350
|
+
if ((units -= 2) < 0) break
|
3351
|
+
|
3352
|
+
c = str.charCodeAt(i)
|
3353
|
+
hi = c >> 8
|
3354
|
+
lo = c % 256
|
3355
|
+
byteArray.push(lo)
|
3356
|
+
byteArray.push(hi)
|
3357
|
+
}
|
3358
|
+
|
3359
|
+
return byteArray
|
3360
|
+
}
|
3361
|
+
|
3362
|
+
function base64ToBytes (str) {
|
3363
|
+
return base64.toByteArray(base64clean(str))
|
3364
|
+
}
|
3365
|
+
|
3366
|
+
function blitBuffer (src, dst, offset, length) {
|
3367
|
+
for (var i = 0; i < length; i++) {
|
3368
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
3369
|
+
dst[i + offset] = src[i]
|
3370
|
+
}
|
3371
|
+
return i
|
3372
|
+
}
|
3373
|
+
|
3374
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).Buffer, (function() { return this; }())))
|
3375
|
+
|
3376
|
+
/***/ },
|
3377
|
+
/* 7 */
|
3378
|
+
/***/ function(module, exports, __webpack_require__) {
|
3379
|
+
|
3380
|
+
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
3381
|
+
|
3382
|
+
;(function (exports) {
|
3383
|
+
'use strict';
|
3384
|
+
|
3385
|
+
var Arr = (typeof Uint8Array !== 'undefined')
|
3386
|
+
? Uint8Array
|
3387
|
+
: Array
|
3388
|
+
|
3389
|
+
var PLUS = '+'.charCodeAt(0)
|
3390
|
+
var SLASH = '/'.charCodeAt(0)
|
3391
|
+
var NUMBER = '0'.charCodeAt(0)
|
3392
|
+
var LOWER = 'a'.charCodeAt(0)
|
3393
|
+
var UPPER = 'A'.charCodeAt(0)
|
3394
|
+
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
3395
|
+
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
3396
|
+
|
3397
|
+
function decode (elt) {
|
3398
|
+
var code = elt.charCodeAt(0)
|
3399
|
+
if (code === PLUS ||
|
3400
|
+
code === PLUS_URL_SAFE)
|
3401
|
+
return 62 // '+'
|
3402
|
+
if (code === SLASH ||
|
3403
|
+
code === SLASH_URL_SAFE)
|
3404
|
+
return 63 // '/'
|
3405
|
+
if (code < NUMBER)
|
3406
|
+
return -1 //no match
|
3407
|
+
if (code < NUMBER + 10)
|
3408
|
+
return code - NUMBER + 26 + 26
|
3409
|
+
if (code < UPPER + 26)
|
3410
|
+
return code - UPPER
|
3411
|
+
if (code < LOWER + 26)
|
3412
|
+
return code - LOWER + 26
|
3413
|
+
}
|
3414
|
+
|
3415
|
+
function b64ToByteArray (b64) {
|
3416
|
+
var i, j, l, tmp, placeHolders, arr
|
3417
|
+
|
3418
|
+
if (b64.length % 4 > 0) {
|
3419
|
+
throw new Error('Invalid string. Length must be a multiple of 4')
|
3420
|
+
}
|
3421
|
+
|
3422
|
+
// the number of equal signs (place holders)
|
3423
|
+
// if there are two placeholders, than the two characters before it
|
3424
|
+
// represent one byte
|
3425
|
+
// if there is only one, then the three characters before it represent 2 bytes
|
3426
|
+
// this is just a cheap hack to not do indexOf twice
|
3427
|
+
var len = b64.length
|
3428
|
+
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
3429
|
+
|
3430
|
+
// base64 is 4/3 + up to two characters of the original data
|
3431
|
+
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
3432
|
+
|
3433
|
+
// if there are placeholders, only get up to the last complete 4 chars
|
3434
|
+
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
3435
|
+
|
3436
|
+
var L = 0
|
3437
|
+
|
3438
|
+
function push (v) {
|
3439
|
+
arr[L++] = v
|
3440
|
+
}
|
3441
|
+
|
3442
|
+
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
3443
|
+
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
3444
|
+
push((tmp & 0xFF0000) >> 16)
|
3445
|
+
push((tmp & 0xFF00) >> 8)
|
3446
|
+
push(tmp & 0xFF)
|
3447
|
+
}
|
3448
|
+
|
3449
|
+
if (placeHolders === 2) {
|
3450
|
+
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
3451
|
+
push(tmp & 0xFF)
|
3452
|
+
} else if (placeHolders === 1) {
|
3453
|
+
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
3454
|
+
push((tmp >> 8) & 0xFF)
|
3455
|
+
push(tmp & 0xFF)
|
3456
|
+
}
|
3457
|
+
|
3458
|
+
return arr
|
3459
|
+
}
|
3460
|
+
|
3461
|
+
function uint8ToBase64 (uint8) {
|
3462
|
+
var i,
|
3463
|
+
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
3464
|
+
output = "",
|
3465
|
+
temp, length
|
3466
|
+
|
3467
|
+
function encode (num) {
|
3468
|
+
return lookup.charAt(num)
|
3469
|
+
}
|
3470
|
+
|
3471
|
+
function tripletToBase64 (num) {
|
3472
|
+
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
3473
|
+
}
|
3474
|
+
|
3475
|
+
// go through the array every three bytes, we'll deal with trailing stuff later
|
3476
|
+
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
3477
|
+
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
3478
|
+
output += tripletToBase64(temp)
|
3479
|
+
}
|
3480
|
+
|
3481
|
+
// pad the end with zeros, but make sure to not forget the extra bytes
|
3482
|
+
switch (extraBytes) {
|
3483
|
+
case 1:
|
3484
|
+
temp = uint8[uint8.length - 1]
|
3485
|
+
output += encode(temp >> 2)
|
3486
|
+
output += encode((temp << 4) & 0x3F)
|
3487
|
+
output += '=='
|
3488
|
+
break
|
3489
|
+
case 2:
|
3490
|
+
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
3491
|
+
output += encode(temp >> 10)
|
3492
|
+
output += encode((temp >> 4) & 0x3F)
|
3493
|
+
output += encode((temp << 2) & 0x3F)
|
3494
|
+
output += '='
|
3495
|
+
break
|
3496
|
+
}
|
3497
|
+
|
3498
|
+
return output
|
3499
|
+
}
|
3500
|
+
|
3501
|
+
exports.toByteArray = b64ToByteArray
|
3502
|
+
exports.fromByteArray = uint8ToBase64
|
3503
|
+
}( false ? (this.base64js = {}) : exports))
|
3504
|
+
|
3505
|
+
|
3506
|
+
/***/ },
|
3507
|
+
/* 8 */
|
3508
|
+
/***/ function(module, exports) {
|
3509
|
+
|
3510
|
+
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
3511
|
+
var e, m
|
3512
|
+
var eLen = nBytes * 8 - mLen - 1
|
3513
|
+
var eMax = (1 << eLen) - 1
|
3514
|
+
var eBias = eMax >> 1
|
3515
|
+
var nBits = -7
|
3516
|
+
var i = isLE ? (nBytes - 1) : 0
|
3517
|
+
var d = isLE ? -1 : 1
|
3518
|
+
var s = buffer[offset + i]
|
3519
|
+
|
3520
|
+
i += d
|
3521
|
+
|
3522
|
+
e = s & ((1 << (-nBits)) - 1)
|
3523
|
+
s >>= (-nBits)
|
3524
|
+
nBits += eLen
|
3525
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
3526
|
+
|
3527
|
+
m = e & ((1 << (-nBits)) - 1)
|
3528
|
+
e >>= (-nBits)
|
3529
|
+
nBits += mLen
|
3530
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
3531
|
+
|
3532
|
+
if (e === 0) {
|
3533
|
+
e = 1 - eBias
|
3534
|
+
} else if (e === eMax) {
|
3535
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
3536
|
+
} else {
|
3537
|
+
m = m + Math.pow(2, mLen)
|
3538
|
+
e = e - eBias
|
3539
|
+
}
|
3540
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
3541
|
+
}
|
3542
|
+
|
3543
|
+
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
3544
|
+
var e, m, c
|
3545
|
+
var eLen = nBytes * 8 - mLen - 1
|
3546
|
+
var eMax = (1 << eLen) - 1
|
3547
|
+
var eBias = eMax >> 1
|
3548
|
+
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
3549
|
+
var i = isLE ? 0 : (nBytes - 1)
|
3550
|
+
var d = isLE ? 1 : -1
|
3551
|
+
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
3552
|
+
|
3553
|
+
value = Math.abs(value)
|
3554
|
+
|
3555
|
+
if (isNaN(value) || value === Infinity) {
|
3556
|
+
m = isNaN(value) ? 1 : 0
|
3557
|
+
e = eMax
|
3558
|
+
} else {
|
3559
|
+
e = Math.floor(Math.log(value) / Math.LN2)
|
3560
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
3561
|
+
e--
|
3562
|
+
c *= 2
|
3563
|
+
}
|
3564
|
+
if (e + eBias >= 1) {
|
3565
|
+
value += rt / c
|
3566
|
+
} else {
|
3567
|
+
value += rt * Math.pow(2, 1 - eBias)
|
3568
|
+
}
|
3569
|
+
if (value * c >= 2) {
|
3570
|
+
e++
|
3571
|
+
c /= 2
|
3572
|
+
}
|
3573
|
+
|
3574
|
+
if (e + eBias >= eMax) {
|
3575
|
+
m = 0
|
3576
|
+
e = eMax
|
3577
|
+
} else if (e + eBias >= 1) {
|
3578
|
+
m = (value * c - 1) * Math.pow(2, mLen)
|
3579
|
+
e = e + eBias
|
3580
|
+
} else {
|
3581
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
3582
|
+
e = 0
|
3583
|
+
}
|
3584
|
+
}
|
3585
|
+
|
3586
|
+
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
3587
|
+
|
3588
|
+
e = (e << mLen) | m
|
3589
|
+
eLen += mLen
|
3590
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
3591
|
+
|
3592
|
+
buffer[offset + i - d] |= s * 128
|
3593
|
+
}
|
3594
|
+
|
3595
|
+
|
3596
|
+
/***/ },
|
3597
|
+
/* 9 */
|
3598
|
+
/***/ function(module, exports) {
|
3599
|
+
|
3600
|
+
|
3601
|
+
/**
|
3602
|
+
* isArray
|
3603
|
+
*/
|
3604
|
+
|
3605
|
+
var isArray = Array.isArray;
|
3606
|
+
|
3607
|
+
/**
|
3608
|
+
* toString
|
3609
|
+
*/
|
3610
|
+
|
3611
|
+
var str = Object.prototype.toString;
|
3612
|
+
|
3613
|
+
/**
|
3614
|
+
* Whether or not the given `val`
|
3615
|
+
* is an array.
|
3616
|
+
*
|
3617
|
+
* example:
|
3618
|
+
*
|
3619
|
+
* isArray([]);
|
3620
|
+
* // > true
|
3621
|
+
* isArray(arguments);
|
3622
|
+
* // > false
|
3623
|
+
* isArray('');
|
3624
|
+
* // > false
|
3625
|
+
*
|
3626
|
+
* @param {mixed} val
|
3627
|
+
* @return {bool}
|
3628
|
+
*/
|
3629
|
+
|
3630
|
+
module.exports = isArray || function (val) {
|
3631
|
+
return !! val && '[object Array]' == str.call(val);
|
3632
|
+
};
|
3633
|
+
|
3634
|
+
|
3635
|
+
/***/ },
|
3636
|
+
/* 10 */
|
3637
|
+
/***/ function(module, exports) {
|
3638
|
+
|
3639
|
+
var SceneGraph = function(sceneProperties) {
|
3640
|
+
var nodeCount = 1;
|
3641
|
+
|
3642
|
+
//todo: move merge to helpers section
|
3643
|
+
function merge(parent, child) {
|
3644
|
+
for (var prop in child) {
|
3645
|
+
parent[prop] = child[prop];
|
3646
|
+
}
|
3647
|
+
return parent;
|
3648
|
+
}
|
3649
|
+
|
3650
|
+
var SceneNode = function(name) {
|
3651
|
+
nodeCount++;
|
3652
|
+
this.parent = null;
|
3653
|
+
this.children = {};
|
3654
|
+
this.id = nodeCount;
|
3655
|
+
this.name = 'n' + nodeCount;
|
3656
|
+
if (typeof name !== 'undefined') {
|
3657
|
+
this.name = name;
|
3658
|
+
}
|
3659
|
+
this.x = this.y = this.z = 0;
|
3660
|
+
this.width = this.height = 0;
|
3661
|
+
};
|
3662
|
+
|
3663
|
+
SceneNode.prototype.resize = function(width, height) {
|
3664
|
+
if (width != null) {
|
3665
|
+
this.width = width;
|
3666
|
+
}
|
3667
|
+
if (height != null) {
|
3668
|
+
this.height = height;
|
3669
|
+
}
|
3670
|
+
};
|
3671
|
+
|
3672
|
+
SceneNode.prototype.moveTo = function(x, y, z) {
|
3673
|
+
this.x = x != null ? x : this.x;
|
3674
|
+
this.y = y != null ? y : this.y;
|
3675
|
+
this.z = z != null ? z : this.z;
|
3676
|
+
};
|
3677
|
+
|
3678
|
+
SceneNode.prototype.add = function(child) {
|
3679
|
+
var name = child.name;
|
3680
|
+
if (typeof this.children[name] === 'undefined') {
|
3681
|
+
this.children[name] = child;
|
3682
|
+
child.parent = this;
|
3683
|
+
} else {
|
3684
|
+
throw 'SceneGraph: child already exists: ' + name;
|
3685
|
+
}
|
3686
|
+
};
|
3687
|
+
|
3688
|
+
var RootNode = function() {
|
3689
|
+
SceneNode.call(this, 'root');
|
3690
|
+
this.properties = sceneProperties;
|
3691
|
+
};
|
3692
|
+
|
3693
|
+
RootNode.prototype = new SceneNode();
|
3694
|
+
|
3695
|
+
var Shape = function(name, props) {
|
3696
|
+
SceneNode.call(this, name);
|
3697
|
+
this.properties = {
|
3698
|
+
'fill': '#000000'
|
3699
|
+
};
|
3700
|
+
if (typeof props !== 'undefined') {
|
3701
|
+
merge(this.properties, props);
|
3702
|
+
} else if (typeof name !== 'undefined' && typeof name !== 'string') {
|
3703
|
+
throw 'SceneGraph: invalid node name';
|
3704
|
+
}
|
3705
|
+
};
|
3706
|
+
|
3707
|
+
Shape.prototype = new SceneNode();
|
3708
|
+
|
3709
|
+
var Group = function() {
|
3710
|
+
Shape.apply(this, arguments);
|
3711
|
+
this.type = 'group';
|
3712
|
+
};
|
3713
|
+
|
3714
|
+
Group.prototype = new Shape();
|
3715
|
+
|
3716
|
+
var Rect = function() {
|
3717
|
+
Shape.apply(this, arguments);
|
3718
|
+
this.type = 'rect';
|
3719
|
+
};
|
3720
|
+
|
3721
|
+
Rect.prototype = new Shape();
|
3722
|
+
|
3723
|
+
var Text = function(text) {
|
3724
|
+
Shape.call(this);
|
3725
|
+
this.type = 'text';
|
3726
|
+
this.properties.text = text;
|
3727
|
+
};
|
3728
|
+
|
3729
|
+
Text.prototype = new Shape();
|
3730
|
+
|
3731
|
+
var root = new RootNode();
|
3732
|
+
|
3733
|
+
this.Shape = {
|
3734
|
+
'Rect': Rect,
|
3735
|
+
'Text': Text,
|
3736
|
+
'Group': Group
|
3737
|
+
};
|
3738
|
+
|
3739
|
+
this.root = root;
|
3740
|
+
return this;
|
3741
|
+
};
|
3742
|
+
|
3743
|
+
module.exports = SceneGraph;
|
3744
|
+
|
3745
|
+
|
3746
|
+
/***/ },
|
3747
|
+
/* 11 */
|
3748
|
+
/***/ function(module, exports) {
|
3749
|
+
|
3750
|
+
/* WEBPACK VAR INJECTION */(function(global) {/**
|
3751
|
+
* Shallow object clone and merge
|
3752
|
+
*
|
3753
|
+
* @param a Object A
|
3754
|
+
* @param b Object B
|
3755
|
+
* @returns {Object} New object with all of A's properties, and all of B's properties, overwriting A's properties
|
3756
|
+
*/
|
3757
|
+
exports.extend = function(a, b) {
|
3758
|
+
var c = {};
|
3759
|
+
for (var x in a) {
|
3760
|
+
if (a.hasOwnProperty(x)) {
|
3761
|
+
c[x] = a[x];
|
3762
|
+
}
|
3763
|
+
}
|
3764
|
+
if (b != null) {
|
3765
|
+
for (var y in b) {
|
3766
|
+
if (b.hasOwnProperty(y)) {
|
3767
|
+
c[y] = b[y];
|
3768
|
+
}
|
3769
|
+
}
|
3770
|
+
}
|
3771
|
+
return c;
|
3772
|
+
};
|
3773
|
+
|
3774
|
+
/**
|
3775
|
+
* Takes a k/v list of CSS properties and returns a rule
|
3776
|
+
*
|
3777
|
+
* @param props CSS properties object
|
3778
|
+
*/
|
3779
|
+
exports.cssProps = function(props) {
|
3780
|
+
var ret = [];
|
3781
|
+
for (var p in props) {
|
3782
|
+
if (props.hasOwnProperty(p)) {
|
3783
|
+
ret.push(p + ':' + props[p]);
|
3784
|
+
}
|
3785
|
+
}
|
3786
|
+
return ret.join(';');
|
3787
|
+
};
|
3788
|
+
|
3789
|
+
/**
|
3790
|
+
* Encodes HTML entities in a string
|
3791
|
+
*
|
3792
|
+
* @param str Input string
|
3793
|
+
*/
|
3794
|
+
exports.encodeHtmlEntity = function(str) {
|
3795
|
+
var buf = [];
|
3796
|
+
var charCode = 0;
|
3797
|
+
for (var i = str.length - 1; i >= 0; i--) {
|
3798
|
+
charCode = str.charCodeAt(i);
|
3799
|
+
if (charCode > 128) {
|
3800
|
+
buf.unshift(['&#', charCode, ';'].join(''));
|
3801
|
+
} else {
|
3802
|
+
buf.unshift(str[i]);
|
3803
|
+
}
|
3804
|
+
}
|
3805
|
+
return buf.join('');
|
3806
|
+
};
|
3807
|
+
|
3808
|
+
/**
|
3809
|
+
* Checks if an image exists
|
3810
|
+
*
|
3811
|
+
* @param src URL of image
|
3812
|
+
* @param callback Callback to call once image status has been found
|
3813
|
+
*/
|
3814
|
+
exports.imageExists = function(src, callback) {
|
3815
|
+
var image = new Image();
|
3816
|
+
image.onerror = function() {
|
3817
|
+
callback.call(this, false);
|
3818
|
+
};
|
3819
|
+
image.onload = function() {
|
3820
|
+
callback.call(this, true);
|
3821
|
+
};
|
3822
|
+
image.src = src;
|
3823
|
+
};
|
3824
|
+
|
3825
|
+
/**
|
3826
|
+
* Decodes HTML entities in a string
|
3827
|
+
*
|
3828
|
+
* @param str Input string
|
3829
|
+
*/
|
3830
|
+
exports.decodeHtmlEntity = function(str) {
|
3831
|
+
return str.replace(/&#(\d+);/g, function(match, dec) {
|
3832
|
+
return String.fromCharCode(dec);
|
3833
|
+
});
|
3834
|
+
};
|
3835
|
+
|
3836
|
+
|
3837
|
+
/**
|
3838
|
+
* Returns an element's dimensions if it's visible, `false` otherwise.
|
3839
|
+
*
|
3840
|
+
* @param el DOM element
|
3841
|
+
*/
|
3842
|
+
exports.dimensionCheck = function(el) {
|
3843
|
+
var dimensions = {
|
3844
|
+
height: el.clientHeight,
|
3845
|
+
width: el.clientWidth
|
3846
|
+
};
|
3847
|
+
|
3848
|
+
if (dimensions.height && dimensions.width) {
|
3849
|
+
return dimensions;
|
3850
|
+
} else {
|
3851
|
+
return false;
|
3852
|
+
}
|
3853
|
+
};
|
3854
|
+
|
3855
|
+
|
3856
|
+
/**
|
3857
|
+
* Returns true if value is truthy or if it is "semantically truthy"
|
3858
|
+
* @param val
|
3859
|
+
*/
|
3860
|
+
exports.truthy = function(val) {
|
3861
|
+
if (typeof val === 'string') {
|
3862
|
+
return val === 'true' || val === 'yes' || val === '1' || val === 'on' || val === '✓';
|
3863
|
+
}
|
3864
|
+
return !!val;
|
3865
|
+
};
|
3866
|
+
|
3867
|
+
/**
|
3868
|
+
* Parses input into a well-formed CSS color
|
3869
|
+
* @param val
|
3870
|
+
*/
|
3871
|
+
exports.parseColor = function(val) {
|
3872
|
+
var hexre = /(^(?:#?)[0-9a-f]{6}$)|(^(?:#?)[0-9a-f]{3}$)/i;
|
3873
|
+
var rgbre = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
|
3874
|
+
var rgbare = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0\.\d{1,}|1)\)$/;
|
3875
|
+
|
3876
|
+
var match = val.match(hexre);
|
2062
3877
|
var retval;
|
2063
3878
|
|
2064
3879
|
if (match !== null) {
|
@@ -2108,10 +3923,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2108
3923
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
2109
3924
|
|
2110
3925
|
/***/ },
|
2111
|
-
/*
|
3926
|
+
/* 12 */
|
2112
3927
|
/***/ function(module, exports, __webpack_require__) {
|
2113
3928
|
|
2114
|
-
/* WEBPACK VAR INJECTION */(function(global) {var DOM = __webpack_require__(
|
3929
|
+
/* WEBPACK VAR INJECTION */(function(global) {var DOM = __webpack_require__(13);
|
2115
3930
|
|
2116
3931
|
var SVG_NS = 'http://www.w3.org/2000/svg';
|
2117
3932
|
var NODE_TYPE_COMMENT = 8;
|
@@ -2224,7 +4039,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2224
4039
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
2225
4040
|
|
2226
4041
|
/***/ },
|
2227
|
-
/*
|
4042
|
+
/* 13 */
|
2228
4043
|
/***/ function(module, exports) {
|
2229
4044
|
|
2230
4045
|
/* WEBPACK VAR INJECTION */(function(global) {/**
|
@@ -2293,7 +4108,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2293
4108
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
2294
4109
|
|
2295
4110
|
/***/ },
|
2296
|
-
/*
|
4111
|
+
/* 14 */
|
2297
4112
|
/***/ function(module, exports) {
|
2298
4113
|
|
2299
4114
|
var Color = function(color, options) {
|
@@ -2501,23 +4316,23 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2501
4316
|
|
2502
4317
|
|
2503
4318
|
/***/ },
|
2504
|
-
/*
|
4319
|
+
/* 15 */
|
2505
4320
|
/***/ function(module, exports) {
|
2506
4321
|
|
2507
4322
|
module.exports = {
|
2508
|
-
'version': '2.9.
|
4323
|
+
'version': '2.9.1',
|
2509
4324
|
'svg_ns': 'http://www.w3.org/2000/svg'
|
2510
4325
|
};
|
2511
4326
|
|
2512
4327
|
/***/ },
|
2513
|
-
/*
|
4328
|
+
/* 16 */
|
2514
4329
|
/***/ function(module, exports, __webpack_require__) {
|
2515
4330
|
|
2516
|
-
var shaven = __webpack_require__(
|
4331
|
+
var shaven = __webpack_require__(17);
|
2517
4332
|
|
2518
|
-
var SVG = __webpack_require__(
|
2519
|
-
var constants = __webpack_require__(
|
2520
|
-
var utils = __webpack_require__(
|
4333
|
+
var SVG = __webpack_require__(12);
|
4334
|
+
var constants = __webpack_require__(15);
|
4335
|
+
var utils = __webpack_require__(11);
|
2521
4336
|
|
2522
4337
|
var SVG_NS = constants.svg_ns;
|
2523
4338
|
|
@@ -2669,10 +4484,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2669
4484
|
};
|
2670
4485
|
|
2671
4486
|
/***/ },
|
2672
|
-
/*
|
4487
|
+
/* 17 */
|
2673
4488
|
/***/ function(module, exports, __webpack_require__) {
|
2674
4489
|
|
2675
|
-
var escape = __webpack_require__(
|
4490
|
+
var escape = __webpack_require__(18)
|
2676
4491
|
|
2677
4492
|
// TODO: remove namespace
|
2678
4493
|
|
@@ -2866,15 +4681,26 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2866
4681
|
|
2867
4682
|
|
2868
4683
|
/***/ },
|
2869
|
-
/*
|
4684
|
+
/* 18 */
|
2870
4685
|
/***/ function(module, exports) {
|
2871
4686
|
|
2872
4687
|
/*!
|
2873
4688
|
* escape-html
|
2874
4689
|
* Copyright(c) 2012-2013 TJ Holowaychuk
|
4690
|
+
* Copyright(c) 2015 Andreas Lubbe
|
4691
|
+
* Copyright(c) 2015 Tiancheng "Timothy" Gu
|
2875
4692
|
* MIT Licensed
|
2876
4693
|
*/
|
2877
4694
|
|
4695
|
+
'use strict';
|
4696
|
+
|
4697
|
+
/**
|
4698
|
+
* Module variables.
|
4699
|
+
* @private
|
4700
|
+
*/
|
4701
|
+
|
4702
|
+
var matchHtmlRegExp = /["'&<>]/;
|
4703
|
+
|
2878
4704
|
/**
|
2879
4705
|
* Module exports.
|
2880
4706
|
* @public
|
@@ -2885,27 +4711,65 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
2885
4711
|
/**
|
2886
4712
|
* Escape special characters in the given string of html.
|
2887
4713
|
*
|
2888
|
-
* @param {string}
|
4714
|
+
* @param {string} string The string to escape for inserting into HTML
|
2889
4715
|
* @return {string}
|
2890
4716
|
* @public
|
2891
4717
|
*/
|
2892
4718
|
|
2893
|
-
function escapeHtml(
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
4719
|
+
function escapeHtml(string) {
|
4720
|
+
var str = '' + string;
|
4721
|
+
var match = matchHtmlRegExp.exec(str);
|
4722
|
+
|
4723
|
+
if (!match) {
|
4724
|
+
return str;
|
4725
|
+
}
|
4726
|
+
|
4727
|
+
var escape;
|
4728
|
+
var html = '';
|
4729
|
+
var index = 0;
|
4730
|
+
var lastIndex = 0;
|
4731
|
+
|
4732
|
+
for (index = match.index; index < str.length; index++) {
|
4733
|
+
switch (str.charCodeAt(index)) {
|
4734
|
+
case 34: // "
|
4735
|
+
escape = '"';
|
4736
|
+
break;
|
4737
|
+
case 38: // &
|
4738
|
+
escape = '&';
|
4739
|
+
break;
|
4740
|
+
case 39: // '
|
4741
|
+
escape = ''';
|
4742
|
+
break;
|
4743
|
+
case 60: // <
|
4744
|
+
escape = '<';
|
4745
|
+
break;
|
4746
|
+
case 62: // >
|
4747
|
+
escape = '>';
|
4748
|
+
break;
|
4749
|
+
default:
|
4750
|
+
continue;
|
4751
|
+
}
|
4752
|
+
|
4753
|
+
if (lastIndex !== index) {
|
4754
|
+
html += str.substring(lastIndex, index);
|
4755
|
+
}
|
4756
|
+
|
4757
|
+
lastIndex = index + 1;
|
4758
|
+
html += escape;
|
4759
|
+
}
|
4760
|
+
|
4761
|
+
return lastIndex !== index
|
4762
|
+
? html + str.substring(lastIndex, index)
|
4763
|
+
: html;
|
2900
4764
|
}
|
2901
4765
|
|
2902
4766
|
|
2903
4767
|
/***/ },
|
2904
|
-
/*
|
4768
|
+
/* 19 */
|
2905
4769
|
/***/ function(module, exports, __webpack_require__) {
|
2906
4770
|
|
2907
|
-
var DOM = __webpack_require__(
|
2908
|
-
var utils = __webpack_require__(
|
4771
|
+
var DOM = __webpack_require__(13);
|
4772
|
+
var utils = __webpack_require__(11);
|
2909
4773
|
|
2910
4774
|
module.exports = (function() {
|
2911
4775
|
var canvas = DOM.newEl('canvas');
|