Underscore.string for Google Apps Script is a library that enables the use of the underscore.string library in Google Apps Script. API docs are available here.
Underscore.string for Google Apps Script is made available as a script library. This is how you add it to your project:
- Select "Resources" > "Libraries..." in the Google Apps Script editor.
- Enter the project key (
MgrAm34sxMTTeOlfoFv8DT-Bao7QLBR4j
) in the "Find a Library" field, and choose "Select". (If you have copied the library, enter instead the project key of your copy.) - Select the highest version number, and choose UnderscoreString as the identifier. (Do not turn on Development Mode unless you know what you are doing. The development version may not work.)
- Press Save. You can now use the Underscore.string library in your code.
If you want to combine Underscore.string with Underscore for Google Apps Script, then also add its project key by following these instructions.
To load Underscore.string as a standalone library:
var _s = UnderscoreString.load();
To extend an Underscore for Google Apps Script library object with underscore.string functions:
var _ = UnderscoreString.load(Underscore.load());
The underscore object can also be extended with non-conflicting underscore.string functions mixed in:
var _ = UnderscoreString.load(Underscore.load(), true);
which is equivalent to:
var _ = UnderscoreString.load(Underscore.load());
_.mixin(_.str.exports());
A Google Apps Script project for Underscore.string is available here.
To copy the library, Select "File" > "Make a copy..." in the Google Apps Script editor.
Underscore.string can partially be tested with QUnit for Google Apps Script.
Click here to run the tests (and wait for the test results to show up.)
There is also a Google Apps Script project for the Underscore.string test suite available.
Underscore.string for Google Apps Script is released under the MIT license.