code: function createSerializer(serializer) {
    var applyFn = function serializationWrapper(v, cb) {
      try {
        return cb ? serializer(v, cb) : serializer(v);
      } catch (e) {
        var modifiedError = new Error('Could not serialize value: ' + e.message);
        modifiedError.value = v;
        modifiedError.serializer = serializer;
        throw modifiedError;
      }
    };
  
    // We can check how many parameters the function has and activate the asynchronous
    // operation if the number of parameters the function accepts is > 1
    return {
      apply: applyFn,
      async: serializer.length > 1
    };
  }
docs: Create a serializer
  
  Method simply wraps a serializer provided by a user
  so it adds context to the error
  
  @returns {function} Serialization function