var hasFullSupport=function(){try{if(!Buffer.isEncoding("latin1"))return!1;var r=Buffer.alloc?Buffer.alloc(4):new Buffer(4);return r.fill("ab","ucs2"),"61006200"===r.toString("hex")}catch(r){return!1}}();function isSingleByte(r){return 1===r.length&&r.charCodeAt(0)<256}function fillWithNumber(r,e,n,t){if(n<0||t>r.length)throw new RangeError("Out of range index");return n>>>=0,(t=void 0===t?r.length:t>>>0)>n&&r.fill(e,n,t),r}function fillWithBuffer(r,e,n,t){if(n<0||t>r.length)throw new RangeError("Out of range index");if(t<=n)return r;n>>>=0,t=void 0===t?r.length:t>>>0;for(var i=n,f=e.length;i<=t-f;)e.copy(r,i),i+=f;return i!==t&&e.copy(r,i,0,t-i),r}function fill(r,e,n,t,i){if(hasFullSupport)return r.fill(e,n,t,i);if("number"==typeof e)return fillWithNumber(r,e,n,t);if("string"==typeof e){if("string"==typeof n?(i=n,n=0,t=r.length):"string"==typeof t&&(i=t,t=r.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("latin1"===i&&(i="binary"),"string"==typeof i&&!Buffer.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(""===e)return fillWithNumber(r,0,n,t);if(isSingleByte(e))return fillWithNumber(r,e.charCodeAt(0),n,t);e=new Buffer(e,i)}return Buffer.isBuffer(e)?fillWithBuffer(r,e,n,t):fillWithNumber(r,0,n,t)}module.exports=fill;