In this Page
Table of Contents | ||||
---|---|---|---|---|
|
Overview
...
Expression libraries are files (.expr) that contain one or more expressions that can be imported into a Pipeline for use across all expression properties. Libraries can be useful if you have static metadata or common functions that you wish to reference in a Snap's expression properties, but may require a strong familiarity with JavaScript syntax.
...
Placing this content in a file named "helpers.expr" and uploading it to your project will make it available for use in Pipelines.
Info |
---|
|
To import a library into a Pipeline:
...
If you would like to explicitly set the name of the library in the lib variable, you can fill out the "As" column in the Expression Libraries table in the Pipeline Properties dialog.
Example 2
The following expression library can be used to generate the start date and end date of the previous month in multiple formats.
Code Block |
---|
{ // Convert the given Date-with-time object into a Date with only the year and month to_month_date: x => Date.UTC(x.getFullYear(), x.getMonth() - 1), // Get the start of the previous month based on the given date or the current time if no parameters are given prev_month_start: x => this.to_month_date((x || Date.now()).minusMonths(1)), // Get the end time of the previous month based on the given date or the current time if no parameters are given prev_month_end: x => this.to_month_date((x || Date.now()).withDayOfMonth(1)).minusSeconds(1), prev_month_start_string: x => this.prev_month_start(x).toString().split('T')[0], prev_month_end_string: x => this.prev_month_end(x).toString().split('T')[0], prev_month_start_epoch: x => this.prev_month_start(x).getTime(), prev_month_end_epoch: x => this.prev_month_end(x).getTime() } |
...