Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tellimer/mailer

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tellimer/mailer - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

__tests__/ab-send.unit.test.ts

16

dist/send.js

@@ -29,2 +29,3 @@ "use strict";

const POOL_LIMIT = 10;
const BATCH_SIZE = parseInt(process.env.SENDGRID_BATCH_SIZE || '1000');
function isPersonalizationList(x) {

@@ -142,12 +143,15 @@ return typeof x[0] !== 'string';

const personalizations = [...data.personalizations];
const senders = [];
const sendgridData = [];
while (personalizations.length > 0) {
data.personalizations = personalizations.splice(0, 1000);
// data.mailSettings = { sandboxMode: { enable: true } }
// console.log(JSON.stringify(data, undefined, 2))
sendgridData.push(data);
const _data = Object.assign({}, data);
_data.personalizations = personalizations.splice(0, BATCH_SIZE);
sendgridData.push(_data);
}
const senders = [];
try {
for (var _b = __asyncValues((0, tiny_async_pool_1.default)(POOL_LIMIT, sendgridData, mail_1.default.send)), _c; _c = yield _b.next(), !_c.done;) {
for (var _b = __asyncValues((0, tiny_async_pool_1.default)(POOL_LIMIT, sendgridData, d => {
var _a;
console.log(`Sending batch of ${(_a = d.personalizations) === null || _a === void 0 ? void 0 : _a.length} emails.`);
return mail_1.default.send(d);
})), _c; _c = yield _b.next(), !_c.done;) {
const value = _c.value;

@@ -154,0 +158,0 @@ senders.push(value);

{
"name": "@tellimer/mailer",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -8,3 +8,4 @@ "main": "dist/index.js",

"scripts": {
"test": "ts-mocha --paths './__tests__/**/*.test.ts' --exit",
"test": "ts-mocha --paths './__tests__/**/*.unit.test.ts' --exit",
"test:integration": "ts-mocha --paths './__tests__/**/*.integration.test.ts' --exit",
"build": "rm -rf ./dist && tsc -p tsconfig.json",

@@ -18,3 +19,3 @@ "lint": "eslint src --fix",

"dependencies": {
"@tellimer/mailable": "workspace:@tellimer/mailable@*",
"@tellimer/mailable": "workspace:^",
"tiny-async-pool": "^2.0.1"

@@ -21,0 +22,0 @@ },

@@ -14,2 +14,3 @@ import sendgrid from '@sendgrid/mail'

const POOL_LIMIT = 10
const BATCH_SIZE = parseInt(process.env.SENDGRID_BATCH_SIZE || '1000')

@@ -164,14 +165,17 @@ export type Person = string | PersonObj

const personalizations = [...data.personalizations]
const senders: [sendgrid.ClientResponse, Record<any, any>][] = []
const sendgridData = []
const sendgridData: sendgrid.MailDataRequired[] = []
while (personalizations.length > 0) {
data.personalizations = personalizations.splice(0, 1000)
// data.mailSettings = { sandboxMode: { enable: true } }
// console.log(JSON.stringify(data, undefined, 2))
sendgridData.push(data)
const _data = {
...data,
}
_data.personalizations = personalizations.splice(0, BATCH_SIZE)
sendgridData.push(_data)
}
for await (const value of asyncPool(POOL_LIMIT, sendgridData, sendgrid.send)) {
const senders: [sendgrid.ClientResponse, Record<any, any>][] = []
for await (const value of asyncPool(POOL_LIMIT, sendgridData, d => {
console.log(`Sending batch of ${d.personalizations?.length} emails.`)
return sendgrid.send(d)
})) {
senders.push(value)

@@ -178,0 +182,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc