Package Exports
- sb-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sb-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sb-js
Purpose
A Node.js library implementing a simple StringBuffer, much like the Java class.
Efficiently uses an Array internally, rather than continually appending Strings.
Examples
Setup
Add sb-js to your project or package.json file:
npm install sb-jsRequire sb-js in your code:
StringBuffer = require("sb-js").StringBufferNote: this library is now implemented in TypeScript, but these examples are in CoffeeScript.
StringBuffer
Construct a StringBuffer, optionally provide an initial String value.
Original "snake_case" methods add(), add_line(), newline(), to_string(), as_lines(), and is_empty() are available. Corresponding new "camelCase" methods addLine(), newLine(), toString(), asLines(), and isEmpty() are also available.
sb = new StringBuffer()
sb.is_empty() -> true
sb.isEmpty() -> true
sb.to_string() -> ""
sb.toString() -> ""
sb.add("one")
sb.is_empty() -> false
sb.add(",two")
sb.to_string() -> "one,two"
sb.newline()
sb.add_line("three")
sb.add_line(null) // null values ignored
sb.addLine(undefined) // undefined values ignored
sb.to_string() -> "one,two
three
"
sb.as_lines() -> "["one,two","three",""]"
sb.asLines() -> "["one,two","three",""]"
sb2 = new StringBuffer(" hello world ")
sb2.is_empty() -> false
sb2.as_lines() -> "[" hello world "]"
sb2.to_string() -> " hello world "
sb2.to_string(true) -> "hello world"
StringBuffer.VERSION -> 0.2.0Release History
- 2015-04-22 v0.2.0 Implementation language is now TypeScript. API expanded to both snake_case and camelCase.
- 2015-01-24 v0.1.1 Changed line endings from "\n" to os.EOL. Replaced jasmine with mocha and istanbul.
- 2014-11-06 v0.1.0 Initial working version; implemented in CoffeeScript.
- 2014-11-06 v0.0.1 alpha 1