code: public void writeJavaScript(JavaScript javaScript, SerializerProvider provider) throws IOException {
  		_writeArrayFieldNameIfNeeded();
  		_verifyValueWrite("write javascript");
  		if (javaScript.getScope() == null) {
  			_buffer.putByte(_typeMarker, BsonConstants.TYPE_JAVASCRIPT);
  			_writeString(javaScript.getCode());
  		} else {
  			_buffer.putByte(_typeMarker, BsonConstants.TYPE_JAVASCRIPT_WITH_SCOPE);
  			// reserve space for the entire structure size
  			int p = _buffer.size();
  			_buffer.putInt(0);
  
  			// write the code
  			_writeString(javaScript.getCode());
  
  			nextObjectIsEmbeddedInValue = true;
  			// write the document
  			provider.findValueSerializer(Map.class, null).serialize(javaScript.getScope(), this, provider);
  			// write the length
  			if (!isEnabled(Feature.ENABLE_STREAMING)) {
  				int l = _buffer.size() - p;
  				_buffer.putInt(p, l);
  			}
  		}
  		flushBuffer();
  	}
docs: Write a BSON JavaScript object
  
  @param javaScript The javaScript to write
  @param provider The serializer provider, for serializing the scope
  @throws IOException If an error occurred in the stream while writing