'use strict'
var int53 = require('int53')

function getWrite (name) {
  if (Buffer.prototype[name]) return Buffer.prototype[name]
  return function (value, offset) {
    return int53[name](value, this, offset)
  }
}

function getRead (name) {
  if (Buffer.prototype[name]) return Buffer.prototype[name]
  return function (offset) {
    return int53[name](this, offset)
  }
}

exports.create = function (type, length) {
  var write = getWrite('write' + type)
  var read = getRead('read' + type)

  function encode (value, buffer, offset) {
    if (!buffer) buffer = Buffer.allocUnsafe(length)
    if (!offset) offset = 0
    write.call(buffer, value, offset)
    return buffer
  }

  function decode (buffer, offset, end) {
    if (!offset) offset = 0
    if (!end) return read.call(buffer, offset)
    return read.call(buffer.slice(offset, end), 0)
  }

  encode.bytes = decode.bytes = length
  return { encode: encode, decode: decode, encodingLength: function () { return length } }
}

@@ -528,24 +528,105 @@
 , offset) %7B%0A
+    if (typeof value !== 'number') throw new TypeError('value must be a number')%0A
     if (!buf

add type check