/* global exports */
/* global Buffer */
/* global require */
"use strict";

// module Node.Buffer

exports.showImpl = require('util').inspect;

exports.create = function (size) {
  return new Buffer(size);
};

exports.fromArray = function (octets) {
  return new Buffer(octets);
};

exports.fromStringImpl = function (str) {
  return function (encoding) {
    return new Buffer(str, encoding);
  };
};

exports.readImpl = function (ty) {
  return function (offset) {
    return function (buf) {
      return buf['read' + ty](offset);
    };
  };
};

exports.readStringImpl = function (enc) {
  return function (start) {
    return function (end) {
      return function (buff) {
        return buff.toString(enc, start, end);
      };
    };
  };
};

exports.toStringImpl = function (enc) {
  return function (buff) {
    return buff.toString(enc);
  };
};

exports.writeImpl = function (ty) {
  return function (value) {
    return function (offset) {
      return function (buf) {
        buf['write' + ty](value, offset);
        return {};
      };
    };
  };
};

exports.writeStringImpl = function (enc) {
  return function (offset) {
    return function (length) {
      return function (value) {
        return function (buff) {
          return buff.write(value, offset, length, encoding);
        };
      };
    };
  };
};

exports.toArray = function (buff) {
  return buff.toJSON();
};

exports.getAtOffsetImpl = function (nothing) {
  return function (just) {
    return function (buff) {
      return function (offset) {
        var octet = buff[offset];
        return octet == null ? nothing
                             : just(buff[i]);
      };
    };
  };
};

exports.setAtOffset = function (value) {
  return function (offset) {
    return function (buff) {
      buff[offset] = value;
      return {};
    };
  };
};

exports.size = function (buff) {
  return buff.length;
};



exports.concat = function (buffs) {
  return Buffer.concat(buffs);
};

exports.concat$prime = function (buffs) {
  return function (totalLength) {
    return Buffer.concat(buffs, totalLength);
  };
};

exports.copy = function (srcStart) {
  return function (srcEnd) {
    return function (src) {
      return function (targStart) {
        return function (targ) {
          return src.copy(targ, targStart, srcStart, strcEnd);
        };
      };
    };
  };
};

exports.fill = function (buff) {
  return function (octet) {
    return function (start) {
      return function (end) {
        buff.fill(octet, start, end);
        return {};
      };
    };
  };
};

@@ -973,24 +973,54 @@
 ion (buf) %7B%0A
+        return function() %7B%0A  
         buf%5B
@@ -1049,32 +1049,34 @@
 ffset);%0A        
+  
 return %7B%7D;%0A     
@@ -1062,32 +1062,42 @@
      return %7B%7D;%0A
+        %7D%0A
       %7D;%0A    %7D;%0A
@@ -1265,32 +1265,64 @@
 nction (buff) %7B%0A
+          return function() %7B%0A  
           return
@@ -1367,16 +1367,28 @@
 oding);%0A
+          %7D%0A
         
@@ -2561,24 +2561,54 @@
 ion (end) %7B%0A
+        return function() %7B%0A  
         buff
@@ -2633,32 +2633,34 @@
 , end);%0A        
+  
 return %7B%7D;%0A     
@@ -2650,24 +2650,34 @@
  return %7B%7D;%0A
+        %7D%0A
       %7D;%0A   

Fix FFI code in Node.Buffer