auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const get = require("lodash.get")
const includes = require("lodash.includes")
const MAX_LENGTH = 10000
// Retrieve emails stored in $checkpoint
const emails = get($checkpoint, 'emails', [])
// and grab the key to dedupe in, from the event body
const { email } = event.body
if (includes(emails, email)) {
$end("Email already seen. Exiting early")
}
if (emails.length >= MAX_LENGTH) {
emails.shift()
}
// Store new emails back in $checkpoint
emails.push(email)
$checkpoint = {
emails
}