code: public static void escapeJavaScript(final String text, final Writer writer,
                                          final JavaScriptEscapeType type, final JavaScriptEscapeLevel level)
              throws IOException {
  
          if (writer == null) {
              throw new IllegalArgumentException("Argument 'writer' cannot be null");
          }
  
          if (type == null) {
              throw new IllegalArgumentException("The 'type' argument cannot be null");
          }
  
          if (level == null) {
              throw new IllegalArgumentException("The 'level' argument cannot be null");
          }
  
          JavaScriptEscapeUtil.escape(new InternalStringReader(text), writer, type, level);
  
      }
docs: <p>
  Perform a (configurable) JavaScript <strong>escape</strong> operation on a <tt>String</tt> input,
  writing results to a <tt>Writer</tt>.
  </p>
  <p>
  This method will perform an escape operation according to the specified
  {@link org.unbescape.javascript.JavaScriptEscapeType} and
  {@link org.unbescape.javascript.JavaScriptEscapeLevel} argument values.
  </p>
  <p>
  All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeJavaScript*(...)</tt> methods call this one with preconfigured
  <tt>type</tt> and <tt>level</tt> values.
  </p>
  <p>
  This method is <strong>thread-safe</strong>.
  </p>
  
  @param text the <tt>String</tt> to be escaped.
  @param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
  be written at all to this writer if input is <tt>null</tt>.
  @param type the type of escape operation to be performed, see
  {@link org.unbescape.javascript.JavaScriptEscapeType}.
  @param level the escape level to be applied, see {@link org.unbescape.javascript.JavaScriptEscapeLevel}.
  @throws IOException if an input/output exception occurs
  
  @since 1.1.2