Exemple #1
0
function validateChildren(attributes, children) {
  if (isArray(attributes)) {
    return attributes;
  }
  if (isArray(children)) {
    return children;
  }
  return [];
}
Exemple #2
0
Buffer.concat = function (list, totalLength) {
  if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')

  if (list.length === 0) {
    return new Buffer(0)
  } else if (list.length === 1) {
    return list[0]
  }

  var i
  if (totalLength === undefined) {
    totalLength = 0
    for (i = 0; i < list.length; i++) {
      totalLength += list[i].length
    }
  }

  var buf = new Buffer(totalLength)
  var pos = 0
  for (i = 0; i < list.length; i++) {
    var item = list[i]
    item.copy(buf, pos)
    pos += item.length
  }
  return buf
}
Exemple #3
0
module.exports = function (arr, options) {

  if (!arr || !isArrayLike(arr)) {
    return arr;
  }

  // arrayLike will always create a copy
  var result = (!isArray(arr) || options && options.copy === true)
    ? [].slice.call(arr)
    : arr;

  var length = arr.length;
  var random;
  var temp;

  while (length) {
    random = Math.floor(Math.random() * length);
    length -= 1;

    temp           = result[length];
    result[length] = result[random];
    result[random] = temp;
  }

  return typeof arr === 'string' ? result.join('') : result;
};
Buffer.concat = function concat (list, length) {
  if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')

  if (list.length === 0) {
    return new Buffer(0)
  } else if (list.length === 1) {
    return list[0]
  }

  var i
  if (length === undefined) {
    length = 0
    for (i = 0; i < list.length; i++) {
      length += list[i].length
    }
  }

  var buf = new Buffer(length)
  var pos = 0
  for (i = 0; i < list.length; i++) {
    var item = list[i]
    item.copy(buf, pos)
    pos += item.length
  }
  return buf
}
/**
 * Class: Buffer
 * =============
 *
 * The Buffer constructor returns instances of `Uint8Array` that are augmented
 * with function properties for all the node `Buffer` API functions. We use
 * `Uint8Array` so that square bracket notation works as expected -- it returns
 * a single octet.
 *
 * By augmenting the instances, we can avoid modifying the `Uint8Array`
 * prototype.
 */
function Buffer (subject, encoding, noZero) {
  if (!(this instanceof Buffer))
    return new Buffer(subject, encoding, noZero)

  var type = typeof subject

  // Find the length
  var length
  if (type === 'number')
    length = subject > 0 ? subject >>> 0 : 0
  else if (type === 'string') {
    if (encoding === 'base64')
      subject = base64clean(subject)
    length = Buffer.byteLength(subject, encoding)
  } else if (type === 'object' && subject !== null) { // assume object is array-like
    if (subject.type === 'Buffer' && isArray(subject.data))
      subject = subject.data
    length = +subject.length > 0 ? Math.floor(+subject.length) : 0
  } else
    throw new TypeError('must start with number, buffer, array or string')

  if (this.length > kMaxLength)
    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
      'size: 0x' + kMaxLength.toString(16) + ' bytes')

  var buf
  if (Buffer.TYPED_ARRAY_SUPPORT) {
    // Preferred: Return an augmented `Uint8Array` instance for best performance
    buf = Buffer._augment(new Uint8Array(length))
  } else {
    // Fallback: Return THIS instance of Buffer (created by `new`)
    buf = this
    buf.length = length
    buf._isBuffer = true
  }

  var i
  if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
    // Speed optimization -- use set if we're copying from a typed array
    buf._set(subject)
  } else if (isArrayish(subject)) {
    // Treat array-ish objects as a byte array
    if (Buffer.isBuffer(subject)) {
      for (i = 0; i < length; i++)
        buf[i] = subject.readUInt8(i)
    } else {
      for (i = 0; i < length; i++)
        buf[i] = ((subject[i] % 256) + 256) % 256
    }
  } else if (type === 'string') {
    buf.write(subject, 0, encoding)
  } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
    for (i = 0; i < length; i++) {
      buf[i] = 0
    }
  }

  return buf
}
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
// Returns a zero-length buffer for inputs that don't conform to the spec.
function fromJsonObject (that, object) {
  var array
  var length = 0

  if (object.type === 'Buffer' && isArray(object.data)) {
    array = object.data
    length = checked(array.length) | 0
  }
  that = allocate(that, length)

  for (var i = 0; i < length; i += 1) {
    that[i] = array[i] & 255
  }
  return that
}
function fromObject (that, object) {
  if (Buffer.isBuffer(object)) return fromBuffer(that, object)

  if (isArray(object)) return fromArray(that, object)

  if (object == null) {
    throw new TypeError('must start with number, buffer, array or string')
  }

  if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) {
    return fromTypedArray(that, object)
  }

  if (object.length) return fromArrayLike(that, object)

  return fromJsonObject(that, object)
}
	function decamelizeObject(object, separator)
	{
		if(isArray(object))
		{
			var newObject = [];

			for(var k in object)
			{
				if(object.hasOwnProperty(k))
				{
					if(typeof object[k] == "object" && object[k])
					{
						newObject.push(decamelizeObject(object[k]));
					}
					else
					{
						newObject.push(object[k]);
					}
				}
			}
		}
		else
		{
			var newObject = {};

			for(var k in object)
			{
				if(object.hasOwnProperty(k))
				{
					var newK = decamelize(k, separator);
					newObject[newK] = object[k];

					if(typeof newObject[newK] == "object" && newObject[newK])
					{
						newObject[newK] = decamelizeObject(newObject[newK]);
					}
				}
			}
		}

		return newObject;
	}
Exemple #9
0
module.exports = function (n, attributes, options) {
  if (!options && isArray(attributes)) {
    options = attributes
    attributes = {}
  }

  var a = n.split('.')
  var name = a.shift()
  var className = a.join(' ')

  var attrs = xtend({
    className: className,
    id: name,
    name: name
  }, attributes)

  return h('fieldset', [
    h('label', { htmlFor: name }, capitalize(name)),
    h('select', attrs, options)
  ])
}
Exemple #10
0
module.exports = function($elements, wrap) {
  
  if ($elements === undefined
      || !isObject($elements)
      || $elements === window
      || $elements === document) {
    return false
  }

  var $sanitized = []

  if (isElement($elements)) {
    if (wrap) {
      $sanitized.push($elements)
    } else {
      return $elements
    }
  } 
  else if (isArray($elements)) {
    $elements.forEach(function(value) {
      if (isElement(value)) {
        $sanitized.push(value)
      }
    })
  }
  else if (isObject($elements)) {
    Object.keys($elements).forEach(function(key) {
      if (isElement($elements[key])) {
        $sanitized.push($elements[key])
      }
    })
  } 

  if (!$sanitized.length) {
    return false
  }

  return $sanitized

}
 _normalizeRules: function(rules){
     if(typeof rules === 'string') {
         if(Validation.cache[rules] === undefined) {
             var strRules = rules.split(' ');
             let object = {};
             for(var i = 0; i < strRules.length; i++) {
                 var args = strRules[i].split(':');
                 var name = args.shift();
                 object[name] = args;
             }
             Validation.cache[rules] = object;
         }
         rules = Validation.cache[rules];
     } else if(isPlainObject(rules)) {
         for(var k in rules) {
             if(rules.hasOwnProperty(k) && !isArray(rules[k])){
                 rules[k] = [rules[k]]
             }
         }
     }
     return rules ? rules : {};
 },
    remove: function (models, options) {
        var singular = !isArray(models);
        var i, length, model, index;

        models = singular ? [models] : slice.call(models);
        options || (options = {});
        for (i = 0, length = models.length; i < length; i++) {
            model = models[i] = this.get(models[i]);
            if (!model) continue;
            this._deIndex(model);
            index = this.models.indexOf(model);
            this.models.splice(index, 1);
            if (!options.silent) {
                options.index = index;
                if (model.trigger) {
                    model.trigger('remove', model, this, options);
                } else {
                    this.trigger('remove', model, this, options);
                }
            }
            this._removeReference(model, options);
        }
        return singular ? models[0] : models;
    },
Exemple #13
0
var isElement=require("is-element"),isObject=require("is-object"),isArray=require("is-array");module.exports=function(e,i){if(void 0===e||!isObject(e)||e===window||e===document)return!1;var r=[];if(isElement(e)){if(!i)return e;r.push(e)}else isArray(e)?e.forEach(function(e){isElement(e)&&r.push(e)}):isObject(e)&&Object.keys(e).forEach(function(i){isElement(e[i])&&r.push(e[i])});return!!r.length&&r};
Exemple #14
0
function isArrayish (subject) {
  return isArray(subject) || Buffer.isBuffer(subject) ||
      subject && typeof subject === 'object' &&
      typeof subject.length === 'number'
}
Exemple #15
0
/**
 * Class: Buffer
 * =============
 *
 * The Buffer constructor returns instances of `Uint8Array` that are augmented
 * with function properties for all the node `Buffer` API functions. We use
 * `Uint8Array` so that square bracket notation works as expected -- it returns
 * a single octet.
 *
 * By augmenting the instances, we can avoid modifying the `Uint8Array`
 * prototype.
 */
function Buffer (subject, encoding, noZero) {
  if (!(this instanceof Buffer))
    return new Buffer(subject, encoding, noZero)

  var type = typeof subject

  // Find the length
  var length
  if (type === 'number') {
    length = +subject
  } else if (type === 'string') {
    length = Buffer.byteLength(subject, encoding)
  } else if (type === 'object' && subject !== null) { // assume object is array-like
    if (subject.type === 'Buffer' && isArray(subject.data))
      subject = subject.data
    length = +subject.length
  } else {
    throw new TypeError('must start with number, buffer, array or string')
  }

  if (length > kMaxLength)
    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
      'size: 0x' + kMaxLength.toString(16) + ' bytes')

  if (length < 0)
    length = 0
  else
    length >>>= 0 // Coerce to uint32.

  var self = this
  if (Buffer.TYPED_ARRAY_SUPPORT) {
    // Preferred: Return an augmented `Uint8Array` instance for best performance
    /*eslint-disable consistent-this */
    self = Buffer._augment(new Uint8Array(length))
    /*eslint-enable consistent-this */
  } else {
    // Fallback: Return THIS instance of Buffer (created by `new`)
    self.length = length
    self._isBuffer = true
  }

  var i
  if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
    // Speed optimization -- use set if we're copying from a typed array
    self._set(subject)
  } else if (isArrayish(subject)) {
    // Treat array-ish objects as a byte array
    if (Buffer.isBuffer(subject)) {
      for (i = 0; i < length; i++)
        self[i] = subject.readUInt8(i)
    } else {
      for (i = 0; i < length; i++)
        self[i] = ((subject[i] % 256) + 256) % 256
    }
  } else if (type === 'string') {
    self.write(subject, 0, encoding)
  } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
    for (i = 0; i < length; i++) {
      self[i] = 0
    }
  }

  if (length > 0 && length <= Buffer.poolSize)
    self.parent = rootParent

  return self
}
Exemple #16
0
module.exports.thunk = function(rows, opts) {
  return (!isArray(rows) ? [rows] : rows).map(function(row, i) {
    if (i === 0) return header(row, opts).concat(line(row));
    return line(row);
  }).join('');
};
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){document.body.appendChild(require("./index.js")())},{"./index.js":2}],2:[function(require,module,exports){(function(Buffer){var crel=require("crel"),badge='<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- Created with Inkscape (http://www.inkscape.org/) -->\n\n<svg\n   xmlns:dc="http://purl.org/dc/elements/1.1/"\n   xmlns:cc="http://creativecommons.org/ns#"\n   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n   xmlns:svg="http://www.w3.org/2000/svg"\n   xmlns="http://www.w3.org/2000/svg"\n   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"\n   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"\n   viewBox="0 0 200 365"\n   id="svg2"\n   version="1.1"\n   inkscape:version="0.48.4 r9939"\n   sodipodi:docname="rtcio.svg"\n   inkscape:export-filename="/home/doehlman/code/rtc.io/site/images/rtcio-new.png"\n   inkscape:export-xdpi="90"\n   inkscape:export-ydpi="90">\n  <defs\n     id="defs4" />\n  <sodipodi:namedview\n     id="base"\n     pagecolor="#ffffff"\n     bordercolor="#666666"\n     borderopacity="1.0"\n     inkscape:pageopacity="0.0"\n     inkscape:pageshadow="2"\n     inkscape:zoom="2.290411"\n     inkscape:cx="100"\n     inkscape:cy="182.5"\n     inkscape:document-units="px"\n     inkscape:current-layer="g3930"\n     showgrid="false"\n     inkscape:window-width="1918"\n     inkscape:window-height="1054"\n     inkscape:window-x="0"\n     inkscape:window-y="24"\n     inkscape:window-maximized="0"\n     fit-margin-top="0"\n     fit-margin-left="0"\n     fit-margin-right="0"\n     fit-margin-bottom="0" />\n  <metadata\n     id="metadata7">\n    <rdf:RDF>\n      <cc:Work\n         rdf:about="">\n        <dc:format>image/svg+xml</dc:format>\n        <dc:type\n           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />\n        <dc:title />\n      </cc:Work>\n    </rdf:RDF>\n  </metadata>\n  <g\n     inkscape:groupmode="layer"\n     id="layer5"\n     inkscape:label="background"\n     style="display:none"\n     transform="translate(3.374635e-6,-15)"\n     sodipodi:insensitive="true">\n    <rect\n       style="opacity:0.8;fill:#000000;fill-opacity:1;stroke:none"\n       id="rect4022"\n       width="200"\n       height="365"\n       x="0"\n       y="15" />\n  </g>\n  <g\n     inkscape:label="character"\n     inkscape:groupmode="layer"\n     id="layer1"\n     style="display:inline"\n     transform="translate(-180.07918,-522.53277)">\n    <g\n       id="g3930"\n       transform="matrix(1.0166062,0,0,1.0166062,1.2237313,-8.8377098)">\n      <g\n         transform="matrix(0.98832117,0,0,0.98832117,3.7075063,6.7892848)"\n         id="g3888">\n        <path\n           sodipodi:type="arc"\n           style="fill:#b0bc15;fill-opacity:1;stroke:#ffffff;stroke-width:5.06201172;stroke-miterlimit:4;stroke-dasharray:none"\n           id="path3050"\n           sodipodi:cx="219.66173"\n           sodipodi:cy="256.16711"\n           sodipodi:rx="125.25124"\n           sodipodi:ry="125.25124"\n           d="m 344.91297,256.16711 c 0,69.17436 -56.07689,125.25125 -125.25124,125.25125 -69.17435,0 -125.251246,-56.07689 -125.251246,-125.25125 0,-69.17435 56.076896,-125.25124 125.251246,-125.25124 69.17435,0 125.25124,56.07689 125.25124,125.25124 z"\n           transform="matrix(0.77889448,0,0,0.77889448,102.6971,425.47025)" />\n        <path\n           d="m 344.91297,256.16711 c 0,69.17436 -56.07689,125.25125 -125.25124,125.25125 -69.17435,0 -125.251246,-56.07689 -125.251246,-125.25125 0,-69.17435 56.076896,-125.25124 125.251246,-125.25124 69.17435,0 125.25124,56.07689 125.25124,125.25124 z"\n           sodipodi:ry="125.25124"\n           sodipodi:rx="125.25124"\n           sodipodi:cy="256.16711"\n           sodipodi:cx="219.66173"\n           id="path3820"\n           style="fill:#d1d59f;fill-opacity:1;stroke:none"\n           sodipodi:type="arc"\n           transform="matrix(0.53120051,0,0,0.53120051,173.24207,472.24301)" />\n        <path\n           transform="matrix(0.35756673,0,0,0.35756673,219.67502,511.45503)"\n           sodipodi:type="arc"\n           style="fill:#ffffff;fill-opacity:1;stroke:none"\n           id="path3822"\n           sodipodi:cx="219.66173"\n           sodipodi:cy="256.16711"\n           sodipodi:rx="125.25124"\n           sodipodi:ry="125.25124"\n           d="m 344.91297,256.16711 c 0,69.17436 -56.07689,125.25125 -125.25124,125.25125 -69.17435,0 -125.251246,-56.07689 -125.251246,-125.25125 0,-69.17435 56.076896,-125.25124 125.251246,-125.25124 69.17435,0 125.25124,56.07689 125.25124,125.25124 z" />\n        <path\n           d="m 344.91297,256.16711 c 0,69.17436 -56.07689,125.25125 -125.25124,125.25125 -69.17435,0 -125.251246,-56.07689 -125.251246,-125.25125 0,-69.17435 56.076896,-125.25124 125.251246,-125.25124 69.17435,0 125.25124,56.07689 125.25124,125.25124 z"\n           sodipodi:ry="125.25124"\n           sodipodi:rx="125.25124"\n           sodipodi:cy="256.16711"\n           sodipodi:cx="219.66173"\n           id="path3824"\n           style="fill:#000000;fill-opacity:0.91764706;stroke:none"\n           sodipodi:type="arc"\n           transform="matrix(0.24653057,0,0,0.24653057,252.53503,534.90609)" />\n        <path\n           transform="matrix(0.1238064,0,0,0.1238064,289.16206,557.8624)"\n           sodipodi:type="arc"\n           style="fill:#ffffff;fill-opacity:0.91764706;stroke:none"\n           id="path3826"\n           sodipodi:cx="219.66173"\n           sodipodi:cy="256.16711"\n           sodipodi:rx="125.25124"\n           sodipodi:ry="125.25124"\n           d="m 344.91297,256.16711 c 0,69.17436 -56.07689,125.25125 -125.25124,125.25125 -69.17435,0 -125.251246,-56.07689 -125.251246,-125.25125 0,-69.17435 56.076896,-125.25124 125.251246,-125.25124 69.17435,0 125.25124,56.07689 125.25124,125.25124 z" />\n        <path\n           inkscape:connector-curvature="0"\n           style="fill:#b0bc16;fill-opacity:1;stroke:none"\n           d="m 252.94822,655.72765 c -12.9795,2.60911 -24.24607,8.97677 -32.8768,17.75689 11.28234,27.85439 41.10161,44.63846 71.64169,38.49936 12.98271,-2.60975 24.24211,-8.98902 32.87367,-17.77249 -11.28769,-27.84403 -41.10481,-44.62158 -71.63856,-38.48376 z"\n           id="path3828" />\n        <path\n           sodipodi:type="arc"\n           style="fill:#c2ca35;fill-opacity:1;stroke:none"\n           id="path3835"\n           sodipodi:cx="186.30336"\n           sodipodi:cy="303.37234"\n           sodipodi:rx="16.364483"\n           sodipodi:ry="16.364483"\n           d="m 202.66784,303.37234 c 0,9.03786 -7.32663,16.36449 -16.36448,16.36449 -9.03785,0 -16.36448,-7.32663 -16.36448,-16.36449 0,-9.03785 7.32663,-16.36448 16.36448,-16.36448 9.03785,0 16.36448,7.32663 16.36448,16.36448 z"\n           transform="matrix(0.65906456,0,0,0.65906456,136.68363,473.36766)" />\n        <path\n           sodipodi:type="arc"\n           style="fill:#a9b601;fill-opacity:1;stroke:none"\n           id="path3886"\n           sodipodi:cx="217.30147"\n           sodipodi:cy="741.59436"\n           sodipodi:rx="1.7308588"\n           sodipodi:ry="1.4161572"\n           d="m 219.03233,741.59436 c 0,0.78212 -0.77494,1.41616 -1.73086,1.41616 -0.95593,0 -1.73086,-0.63404 -1.73086,-1.41616 0,-0.78212 0.77493,-1.41616 1.73086,-1.41616 0.95592,0 1.73086,0.63404 1.73086,1.41616 z" />\n      </g>\n      <path\n         sodipodi:nodetypes="ssscccsssccscsscscs"\n         inkscape:connector-curvature="0"\n         id="path3050-0"\n         d="m 216.71472,706.56121 c -2.3849,-0.0284 -4.81475,0.31068 -7.21875,1 -15.38557,4.41166 -24.38296,22.49678 -20.09375,40.40625 3.45517,14.42695 19.38493,20.9738 26.6875,25.3125 7.3868,16.59148 22.38691,29.0271 40.5625,32.90625 l -1.8186,56.96061 c -1.2531,0.80654 -5.3064,4.10434 -5.3064,8.44564 0,4.51893 3.66857,8.1875 8.1875,8.1875 4.51893,0 8.04171,-3.61718 8.04171,-8.13611 0,-4.06344 -2.89158,-6.49137 -4.92735,-8.10597 l 7.38564,-56.07042 c 0.16699,0.001 0.33267,0 0.5,0 24.62169,0 43.7179,-12.93397 51.95554,-34.66989 10.23196,-5.37174 19.79503,-12.3272 24.01321,-23.23636 6.26816,-16.21085 0.455,-33.57868 -13,-38.78125 -7.33739,-2.83711 -12.29417,-0.76011 -22.28125,3 -11.128,4.41827 -23.26834,6.84375 -35.96875,6.84375 -15.81894,0 -30.75648,-3.78444 -43.96875,-10.46875 -3.93457,-2.25488 -8.27638,-3.54051 -12.75,-3.59375 z"\n         style="fill:#b0bc15;fill-opacity:1;stroke:#ffffff;stroke-width:3.89672589;stroke-miterlimit:4;stroke-dasharray:none" />\n    </g>\n  </g>\n</svg>\n',css=Buffer("LnJ0Y2lvLWJhZGdlIHsKICBwb3NpdGlvbjogYWJzb2x1dGU7CiAgYm90dG9tOiA1cHg7CiAgcmlnaHQ6IDVweDsKICBvcGFjaXR5OiAwLjI7CiAgdHJhbnNpdGlvbjogb3BhY2l0eSBlYXNlLWluLW91dCAwLjJzOwp9CgoucnRjaW8tYmFkZ2U6aG92ZXIgewogIG9wYWNpdHk6IDE7Cn0KCi5ydGNpby1iYWRnZSBzdmcgewogIGhlaWdodDogNjRweDsKICB3aWR0aDogNjRweDsKfQo=","base64"),defaultcss=require("defaultcss");module.exports=function(){var a=crel("a",{href:"http://rtc.io/",title:"powered by rtc.io"});return a.innerHTML=badge,defaultcss("rtcio-poweredby",css),crel("div",{"class":"rtcio-badge"},a)}}).call(this,require("buffer").Buffer)},{buffer:3,crel:7,defaultcss:8}],3:[function(require,module,exports){function Buffer(subject,encoding){var self=this;if(!(self instanceof Buffer))return new Buffer(subject,encoding);var length,type=typeof subject;if("number"===type)length=+subject;else if("string"===type)length=Buffer.byteLength(subject,encoding);else{if("object"!==type||null===subject)throw new TypeError("must start with number, buffer, array or string");"Buffer"===subject.type&&isArray(subject.data)&&(subject=subject.data),length=+subject.length}if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength.toString(16)+" bytes");0>length?length=0:length>>>=0,Buffer.TYPED_ARRAY_SUPPORT?self=Buffer._augment(new Uint8Array(length)):(self.length=length,self._isBuffer=!0);var i;if(Buffer.TYPED_ARRAY_SUPPORT&&"number"==typeof subject.byteLength)self._set(subject);else if(isArrayish(subject))if(Buffer.isBuffer(subject))for(i=0;length>i;i++)self[i]=subject.readUInt8(i);else for(i=0;length>i;i++)self[i]=(subject[i]%256+256)%256;else if("string"===type)self.write(subject,0,encoding);else if("number"===type&&!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;length>i;i++)self[i]=0;return length>0&&length<=Buffer.poolSize&&(self.parent=rootParent),self}function SlowBuffer(subject,encoding){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding);var buf=new Buffer(subject,encoding);return delete buf.parent,buf}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length),length>remaining&&(length=remaining)):length=remaining;var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");length>strLen/2&&(length=strLen/2);for(var i=0;length>i;i++){var parsed=parseInt(string.substr(2*i,2),16);if(isNaN(parsed))throw new Error("Invalid hex string");buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function base64Slice(buf,start,end){return base64.fromByteArray(0===start&&end===buf.length?buf:buf.slice(start,end))}function utf8Slice(buf,start,end){var res="",tmp="";end=Math.min(buf.length,end);for(var i=start;end>i;i++)buf[i]<=127?(res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]),tmp=""):tmp+="%"+buf[i].toString(16);return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;end>i;i++)ret+=String.fromCharCode(127&buf[i]);return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;end>i;i++)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||0>start)&&(start=0),(!end||0>end||end>len)&&(end=len);for(var out="",i=start;end>i;i++)out+=toHex(buf[i]);return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!==0||0>offset)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||min>value)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}function objectWriteUInt16(buf,value,offset,littleEndian){0>value&&(value=65535+value+1);for(var i=0,j=Math.min(buf.length-offset,2);j>i;i++)buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>8*(littleEndian?i:1-i)}function objectWriteUInt32(buf,value,offset,littleEndian){0>value&&(value=4294967295+value+1);for(var i=0,j=Math.min(buf.length-offset,4);j>i;i++)buf[offset+i]=value>>>8*(littleEndian?i:3-i)&255}function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||min>value)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(0>offset)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return noAssert||checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}function base64clean(str){if(str=stringtrim(str).replace(INVALID_BASE64_RE,""),str.length<2)return"";for(;str.length%4!==0;)str+="=";return str}function stringtrim(str){return str.trim?str.trim():str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&"object"==typeof subject&&"number"==typeof subject.length}function toHex(n){return 16>n?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(string,units){units=units||1/0;for(var codePoint,length=string.length,leadSurrogate=null,bytes=[],i=0;length>i;i++){if(codePoint=string.charCodeAt(i),codePoint>55295&&57344>codePoint){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(56320>codePoint){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=leadSurrogate-55296<<10|codePoint-56320|65536,leadSurrogate=null}else leadSurrogate&&((units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=null);if(128>codePoint){if((units-=1)<0)break;bytes.push(codePoint)}else if(2048>codePoint){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(65536>codePoint){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(2097152>codePoint))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function asciiToBytes(str){for(var byteArray=[],i=0;i<str.length;i++)byteArray.push(255&str.charCodeAt(i));return byteArray}function utf16leToBytes(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);i++)c=str.charCodeAt(i),hi=c>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;length>i&&!(i+offset>=dst.length||i>=src.length);i++)dst[i+offset]=src[i];return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}var base64=require("base64-js"),ieee754=require("ieee754"),isArray=require("is-array");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.poolSize=8192;var kMaxLength=1073741823,rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0),arr=new Uint8Array(buf);return arr.foo=function(){return 42},42===arr.foo()&&"function"==typeof arr.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(e){return!1}}(),Buffer.isBuffer=function(b){return!(null==b||!b._isBuffer)},Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);len>i&&a[i]===b[i];i++);return i!==len&&(x=a[i],y=b[i]),y>x?-1:x>y?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("list argument must be an Array of Buffers.");if(0===list.length)return new Buffer(0);if(1===list.length)return list[0];var i;if(void 0===totalLength)for(totalLength=0,i=0;i<list.length;i++)totalLength+=list[i].length;var buf=new Buffer(totalLength),pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos),pos+=item.length}return buf},Buffer.byteLength=function(str,encoding){var ret;switch(str+="",encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=2*str.length;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret},Buffer.prototype.length=void 0,Buffer.prototype.parent=void 0,Buffer.prototype.toString=function(encoding,start,end){var loweredCase=!1;if(start>>>=0,end=void 0===end||end===1/0?this.length:end>>>0,encoding||(encoding="utf8"),0>start&&(start=0),end>this.length&&(end=this.length),start>=end)return"";for(;;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}},Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?!0:0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return this.length>0&&(str=this.toString("hex",0,max).match(/.{2}/g).join(" "),this.length>max&&(str+=" ... ")),"<Buffer "+str+">"},Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b?0:Buffer.compare(this,b)},Buffer.prototype.indexOf=function(val,byteOffset){function arrayIndexOf(arr,val,byteOffset){for(var foundIndex=-1,i=0;byteOffset+i<arr.length;i++)if(arr[byteOffset+i]===val[-1===foundIndex?0:i-foundIndex]){if(-1===foundIndex&&(foundIndex=i),i-foundIndex+1===val.length)return byteOffset+foundIndex}else foundIndex=-1;return-1}if(byteOffset>2147483647?byteOffset=2147483647:-2147483648>byteOffset&&(byteOffset=-2147483648),byteOffset>>=0,0===this.length)return-1;if(byteOffset>=this.length)return-1;if(0>byteOffset&&(byteOffset=Math.max(this.length+byteOffset,0)),"string"==typeof val)return 0===val.length?-1:String.prototype.indexOf.call(this,val,byteOffset);if(Buffer.isBuffer(val))return arrayIndexOf(this,val,byteOffset);if("number"==typeof val)return Buffer.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,val,byteOffset):arrayIndexOf(this,[val],byteOffset);throw new TypeError("val must be string, number or Buffer")},Buffer.prototype.get=function(offset){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(offset)},Buffer.prototype.set=function(v,offset){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(v,offset)},Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset))isFinite(length)||(encoding=length,length=void 0);else{var swap=encoding;encoding=offset,offset=length,length=swap}if(offset=Number(offset)||0,0>length||0>offset||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");var remaining=this.length-offset;length?(length=Number(length),length>remaining&&(length=remaining)):length=remaining,encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start,end=void 0===end?len:~~end,0>start?(start+=len,0>start&&(start=0)):start>len&&(start=len),0>end?(end+=len,0>end&&(end=0)):end>len&&(end=len),start>end&&(end=start);var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT)newBuf=Buffer._augment(this.subarray(start,end));else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,void 0);for(var i=0;sliceLen>i;i++)newBuf[i]=this[i+start]}return newBuf.length&&(newBuf.parent=this.parent||this),newBuf},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return mul*=128,val>=mul&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,byteLength>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul>>>0&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,byteLength>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul>>>0&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),this[offset]=value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=value):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1));var i=0,mul=1,sub=0>value?1:0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1));var i=byteLength-1,mul=1,sub=0>value?1:0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(value=Math.floor(value)),0>value&&(value=255+value+1),this[offset]=value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value,this[offset+1]=value>>>8):objectWriteUInt16(this,value,offset,!0),offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>8,this[offset+1]=value):objectWriteUInt16(this,value,offset,!1),offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24):objectWriteUInt32(this,value,offset,!0),offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),0>value&&(value=4294967295+value+1),Buffer.TYPED_ARRAY_SUPPORT?(this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=value):objectWriteUInt32(this,value,offset,!1),offset+4},Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)},Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,target_start,start,end){if(start||(start=0),end||0===end||(end=this.length),target_start>=target.length&&(target_start=target.length),target_start||(target_start=0),end>0&&start>end&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(0>target_start)throw new RangeError("targetStart out of bounds");if(0>start||start>=this.length)throw new RangeError("sourceStart out of bounds");if(0>end)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-target_start<end-start&&(end=target.length-target_start+start);var len=end-start;if(1e3>len||!Buffer.TYPED_ARRAY_SUPPORT)for(var i=0;len>i;i++)target[i+target_start]=this[i+start];else target._set(this.subarray(start,start+len),target_start);return len},Buffer.prototype.fill=function(value,start,end){if(value||(value=0),start||(start=0),end||(end=this.length),start>end)throw new RangeError("end < start");if(end!==start&&0!==this.length){if(0>start||start>=this.length)throw new RangeError("start out of bounds");if(0>end||end>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof value)for(i=start;end>i;i++)this[i]=value;else{var bytes=utf8ToBytes(value.toString()),len=bytes.length;
    set: function (models, options) {
        options = extend({add: true, remove: true, merge: true}, options);
        if (options.parse) models = this.parse(models, options);
        var singular = !isArray(models);
        models = singular ? (models ? [models] : []) : models.slice();
        var id, model, attrs, existing, sort, i, length;
        var at = options.at;
        var sortable = this.comparator && (at == null) && options.sort !== false;
        var sortAttr = ('string' === typeof this.comparator) ? this.comparator : null;
        var toAdd = [], toRemove = [], modelMap = {};
        var add = options.add, merge = options.merge, remove = options.remove;
        var order = !sortable && add && remove ? [] : false;
        var targetProto = this.model && this.model.prototype || Object.prototype;

        // Turn bare objects into model references, and prevent invalid models
        // from being added.
        for (i = 0, length = models.length; i < length; i++) {
            attrs = models[i] || {};
            if (this.isModel(attrs)) {
                id = model = attrs;
            } else if (targetProto.generateId) {
                id = targetProto.generateId(attrs);
            } else {
                id = attrs[this.mainIndex];
            }

            // If a duplicate is found, prevent it from being added and
            // optionally merge it into the existing model.
            if (existing = this.get(id)) {
                if (remove) modelMap[existing.cid || existing[this.mainIndex]] = true;
                if (merge) {
                    attrs = attrs === model ? model.attributes : attrs;
                    if (options.parse) attrs = existing.parse(attrs, options);
                    // if this is model
                    if (existing.set) {
                        existing.set(attrs, options);
                        if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
                    } else {
                        // if not just update the properties
                        extend(existing, attrs);
                    }
                }
                models[i] = existing;

            // If this is a new, valid model, push it to the `toAdd` list.
            } else if (add) {
                model = models[i] = this._prepareModel(attrs, options);
                if (!model) continue;
                toAdd.push(model);
                this._addReference(model, options);
            }

            // Do not add multiple models with the same `id`.
            model = existing || model;
            if (!model) continue;
            if (order && ((model.isNew && model.isNew() || !model[this.mainIndex]) || !modelMap[model.cid || model[this.mainIndex]])) order.push(model);
            modelMap[model[this.mainIndex]] = true;
        }

        // Remove nonexistent models if appropriate.
        if (remove) {
            for (i = 0, length = this.length; i < length; i++) {
                model = this.models[i];
                if (!modelMap[model.cid || model[this.mainIndex]]) toRemove.push(model);
            }
            if (toRemove.length) this.remove(toRemove, options);
        }

        // See if sorting is needed, update `length` and splice in new models.
        if (toAdd.length || (order && order.length)) {
            if (sortable) sort = true;
            if (at != null) {
                for (i = 0, length = toAdd.length; i < length; i++) {
                    this.models.splice(at + i, 0, toAdd[i]);
                }
            } else {
                var orderedModels = order || toAdd;
                for (i = 0, length = orderedModels.length; i < length; i++) {
                    this.models.push(orderedModels[i]);
                }
            }
        }

        // Silently sort the collection if appropriate.
        if (sort) this.sort({silent: true});

        // Unless silenced, it's time to fire all appropriate add/sort events.
        if (!options.silent) {
            for (i = 0, length = toAdd.length; i < length; i++) {
                model = toAdd[i];
                if (model.trigger) {
                    model.trigger('add', model, this, options);
                } else {
                    this.trigger('add', model, this, options);
                }
            }
            if (sort || (order && order.length)) this.trigger('sort', this, options);
        }

        // Return the added (or merged) model (or models).
        return singular ? models[0] : models;
    },
for(i=start;end>i;i++)this[i]=bytes[i%len]}return this}},Buffer.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(Buffer.TYPED_ARRAY_SUPPORT)return new Buffer(this).buffer;for(var buf=new Uint8Array(this.length),i=0,len=buf.length;len>i;i+=1)buf[i]=this[i];return buf.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var BP=Buffer.prototype;Buffer._augment=function(arr){return arr.constructor=Buffer,arr._isBuffer=!0,arr._set=arr.set,arr.get=BP.get,arr.set=BP.set,arr.write=BP.write,arr.toString=BP.toString,arr.toLocaleString=BP.toString,arr.toJSON=BP.toJSON,arr.equals=BP.equals,arr.compare=BP.compare,arr.indexOf=BP.indexOf,arr.copy=BP.copy,arr.slice=BP.slice,arr.readUIntLE=BP.readUIntLE,arr.readUIntBE=BP.readUIntBE,arr.readUInt8=BP.readUInt8,arr.readUInt16LE=BP.readUInt16LE,arr.readUInt16BE=BP.readUInt16BE,arr.readUInt32LE=BP.readUInt32LE,arr.readUInt32BE=BP.readUInt32BE,arr.readIntLE=BP.readIntLE,arr.readIntBE=BP.readIntBE,arr.readInt8=BP.readInt8,arr.readInt16LE=BP.readInt16LE,arr.readInt16BE=BP.readInt16BE,arr.readInt32LE=BP.readInt32LE,arr.readInt32BE=BP.readInt32BE,arr.readFloatLE=BP.readFloatLE,arr.readFloatBE=BP.readFloatBE,arr.readDoubleLE=BP.readDoubleLE,arr.readDoubleBE=BP.readDoubleBE,arr.writeUInt8=BP.writeUInt8,arr.writeUIntLE=BP.writeUIntLE,arr.writeUIntBE=BP.writeUIntBE,arr.writeUInt16LE=BP.writeUInt16LE,arr.writeUInt16BE=BP.writeUInt16BE,arr.writeUInt32LE=BP.writeUInt32LE,arr.writeUInt32BE=BP.writeUInt32BE,arr.writeIntLE=BP.writeIntLE,arr.writeIntBE=BP.writeIntBE,arr.writeInt8=BP.writeInt8,arr.writeInt16LE=BP.writeInt16LE,arr.writeInt16BE=BP.writeInt16BE,arr.writeInt32LE=BP.writeInt32LE,arr.writeInt32BE=BP.writeInt32BE,arr.writeFloatLE=BP.writeFloatLE,arr.writeFloatBE=BP.writeFloatBE,arr.writeDoubleLE=BP.writeDoubleLE,arr.writeDoubleBE=BP.writeDoubleBE,arr.fill=BP.fill,arr.inspect=BP.inspect,arr.toArrayBuffer=BP.toArrayBuffer,arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g},{"base64-js":4,ieee754:5,"is-array":6}],4:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(exports){"use strict";function decode(elt){var code=elt.charCodeAt(0);return code===PLUS||code===PLUS_URL_SAFE?62:code===SLASH||code===SLASH_URL_SAFE?63:NUMBER>code?-1:NUMBER+10>code?code-NUMBER+26+26:UPPER+26>code?code-UPPER:LOWER+26>code?code-LOWER+26:void 0}function b64ToByteArray(b64){function push(v){arr[L++]=v}var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0,arr=new Arr(3*b64.length/4-placeHolders),l=placeHolders>0?b64.length-4:b64.length;var L=0;for(i=0,j=0;l>i;i+=4,j+=3)tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3)),push((16711680&tmp)>>16),push((65280&tmp)>>8),push(255&tmp);return 2===placeHolders?(tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4,push(255&tmp)):1===placeHolders&&(tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2,push(tmp>>8&255),push(255&tmp)),arr}function uint8ToBase64(uint8){function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(63&num)}var i,temp,length,extraBytes=uint8.length%3,output="";for(i=0,length=uint8.length-extraBytes;length>i;i+=3)temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2],output+=tripletToBase64(temp);switch(extraBytes){case 1:temp=uint8[uint8.length-1],output+=encode(temp>>2),output+=encode(temp<<4&63),output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1],output+=encode(temp>>10),output+=encode(temp>>4&63),output+=encode(temp<<2&63),output+="="}return output}var Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,PLUS="+".charCodeAt(0),SLASH="/".charCodeAt(0),NUMBER="0".charCodeAt(0),LOWER="a".charCodeAt(0),UPPER="A".charCodeAt(0),PLUS_URL_SAFE="-".charCodeAt(0),SLASH_URL_SAFE="_".charCodeAt(0);exports.toByteArray=b64ToByteArray,exports.fromByteArray=uint8ToBase64}("undefined"==typeof exports?this.base64js={}:exports)},{}],5:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?0/0:(s?-1:1)*(1/0);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=0>value||0===value&&0>1/value?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias),value*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],6:[function(require,module,exports){var isArray=Array.isArray,str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],7:[function(require,module,exports){!function(root,factory){"object"==typeof exports?module.exports=factory():"function"==typeof define&&define.amd?define(factory):root.crel=factory()}(this,function(){function crel(){var child,args=arguments,element=args[0],settings=args[1],childIndex=2,argumentsLength=args.length,attributeMap=crel[attrMapString];if(element=crel[isElementString](element)?element:d.createElement(element),1===argumentsLength)return element;if((!isType(settings,obj)||crel[isNodeString](settings)||isArray(settings))&&(--childIndex,settings=null),argumentsLength-childIndex===1&&isType(args[childIndex],"string")&&void 0!==element[textContent])element[textContent]=args[childIndex];else for(;argumentsLength>childIndex;++childIndex)if(child=args[childIndex],null!=child)if(isArray(child))for(var i=0;i<child.length;++i)appendChild(element,child[i]);else appendChild(element,child);for(var key in settings)if(attributeMap[key]){var attr=attributeMap[key];typeof attr===fn?attr(element,settings[key]):element[setAttribute](attr,settings[key])}else element[setAttribute](key,settings[key]);return element}var fn="function",obj="object",nodeType="nodeType",textContent="textContent",setAttribute="setAttribute",attrMapString="attrMap",isNodeString="isNode",isElementString="isElement",d=typeof document===obj?document:{},isType=function(a,type){return typeof a===type},isNode=typeof Node===fn?function(object){return object instanceof Node}:function(object){return object&&isType(object,obj)&&nodeType in object&&isType(object.ownerDocument,obj)},isElement=function(object){return crel[isNodeString](object)&&1===object[nodeType]},isArray=function(a){return a instanceof Array},appendChild=function(element,child){crel[isNodeString](child)||(child=d.createTextNode(child)),element.appendChild(child)};return crel[attrMapString]={},crel[isElementString]=isElement,crel[isNodeString]=isNode,crel})},{}],8:[function(require,module,exports){"use strict";module.exports=function(label,text){var styleId=label+"_defaultstyle",styleEl=document.getElementById(styleId),firstStyleDef=document.querySelector('link[rel="stylesheet"],style');return styleEl?styleEl:(styleEl=document.createElement("style"),styleEl.innerHTML=text,firstStyleDef?firstStyleDef.parentNode.insertBefore(styleEl,firstStyleDef):document.head?document.head.appendChild(styleEl):document.body&&document.body.childNodes.length>0?document.body.insertBefore(styleEl,document.body.childNodes[0]):document.body&&document.body.appendChild(styleEl),styleEl)}},{}]},{},[1]);
Exemple #20
0
function validateAttributes(attributes) {
  if (isObject(attributes) && !isArray(attributes)) {
    return attributes;
  }
  return {};
}