diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2021-01-21 17:22:53 -0700 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2021-01-21 17:22:53 -0700 |
commit | bcf9b230be6d74c71567fd0771b31d47d8dd39c7 (patch) | |
tree | 2d0fc16142d55bbd5876ac6b8174c2857883b40e /src/assets/viz/2/goog/string/stringbuffer.js | |
parent | d57fd70640948cf20eeb41b56e8d4e23e616cec0 (diff) |
build the blog with nix
Diffstat (limited to 'src/assets/viz/2/goog/string/stringbuffer.js')
-rw-r--r-- | src/assets/viz/2/goog/string/stringbuffer.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/assets/viz/2/goog/string/stringbuffer.js b/src/assets/viz/2/goog/string/stringbuffer.js new file mode 100644 index 0000000..478b08b --- /dev/null +++ b/src/assets/viz/2/goog/string/stringbuffer.js @@ -0,0 +1,103 @@ +// Copyright 2006 The Closure Library Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS-IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Utility for fast string concatenation. + */ + +goog.provide('goog.string.StringBuffer'); + + + +/** + * Utility class to facilitate string concatenation. + * + * @param {*=} opt_a1 Optional first initial item to append. + * @param {...*} var_args Other initial items to + * append, e.g., new goog.string.StringBuffer('foo', 'bar'). + * @constructor + */ +goog.string.StringBuffer = function(opt_a1, var_args) { + if (opt_a1 != null) { + this.append.apply(this, arguments); + } +}; + + +/** + * Internal buffer for the string to be concatenated. + * @type {string} + * @private + */ +goog.string.StringBuffer.prototype.buffer_ = ''; + + +/** + * Sets the contents of the string buffer object, replacing what's currently + * there. + * + * @param {*} s String to set. + */ +goog.string.StringBuffer.prototype.set = function(s) { + this.buffer_ = '' + s; +}; + + +/** + * Appends one or more items to the buffer. + * + * Calling this with null, undefined, or empty arguments is an error. + * + * @param {*} a1 Required first string. + * @param {*=} opt_a2 Optional second string. + * @param {...?} var_args Other items to append, + * e.g., sb.append('foo', 'bar', 'baz'). + * @return {!goog.string.StringBuffer} This same StringBuffer object. + * @suppress {duplicate} + */ +goog.string.StringBuffer.prototype.append = function(a1, opt_a2, var_args) { + // Use a1 directly to avoid arguments instantiation for single-arg case. + this.buffer_ += String(a1); + if (opt_a2 != null) { // second argument is undefined (null == undefined) + for (var i = 1; i < arguments.length; i++) { + this.buffer_ += arguments[i]; + } + } + return this; +}; + + +/** + * Clears the internal buffer. + */ +goog.string.StringBuffer.prototype.clear = function() { + this.buffer_ = ''; +}; + + +/** + * @return {number} the length of the current contents of the buffer. + */ +goog.string.StringBuffer.prototype.getLength = function() { + return this.buffer_.length; +}; + + +/** + * @return {string} The concatenated string. + * @override + */ +goog.string.StringBuffer.prototype.toString = function() { + return this.buffer_; +}; |