/// <summary>
        /// Writes a BSON JavaScript to the writer.
        /// </summary>
        /// <param name="code">The JavaScript code.</param>
        public override void WriteJavaScript(string code)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException("BsonBinaryWriter");
            }
            if (State != BsonWriterState.Value)
            {
                ThrowInvalidState("WriteJavaScript", BsonWriterState.Value);
            }

            _buffer.WriteByte((byte)BsonType.JavaScript);
            WriteNameHelper();
            _buffer.WriteString(code);

            State = GetNextState();
        }
        /// <summary>
        /// Writes a BSON JavaScript to the writer.
        /// </summary>
        /// <param name="code">The JavaScript code.</param>
        public override void WriteJavaScript(
            string code
            )
        {
            if (disposed)
            {
                throw new ObjectDisposedException("BsonBinaryWriter");
            }
            if (state != BsonWriterState.Value)
            {
                var message = string.Format("WriteJavaScript cannot be called when State is: {0}", state);
                throw new InvalidOperationException(message);
            }

            buffer.WriteByte((byte)BsonType.JavaScript);
            WriteNameHelper();
            buffer.WriteString(code);

            state = GetNextState();
        }