Underscore for Google Apps Script is a library that enables the use of the underscore.js library in Google Apps Script. API docs are available here.
Underscore 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 script id (
1PcEHcGVC1njZd8SfXtmgQk19djwVd2GrrW1gd7U5hNk033tzi6IUvIAV
) 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 Underscore 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 library in your code.
If you want to combine Underscore with Underscore.string for Google Apps Script, then also add its project key by following these instructions.
To load Underscore:
var _ = Underscore.load();
To extend the Underscore library object with string functions, see Underscore.string for Google Apps Script.
A Google Apps Script project for Underscore is available here.
To copy the library, Select "File" > "Make a copy..." in the Google Apps Script editor.
Underscore 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 test suite available.
Underscore for Google Apps Script is released under the MIT license.