New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@smallwins/lambda

Package Overview
Dependencies
Maintainers
5
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smallwins/lambda - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

test/lambda-fail-test.js

18

index.js

@@ -5,4 +5,2 @@ var async = require('async')

var firstRun = true
/**

@@ -14,4 +12,4 @@ * lambda - accepts node style callbacks and returns an aws lambda function

// grab all the functions
var fns = [].slice.call(arguments, 0)
var firstRun = true // important to keep this here in this closure
var fns = [].slice.call(arguments, 0) // grab all the functions

@@ -32,4 +30,4 @@ // fail loudly for programmer not passing anything

if(firstRun) {
// put this callback at the front of the line to pass in the event data
// this is to avoid warm start (sometimes lambda containers are cached … yeaaaaah.)
if (firstRun) {
fns.unshift(function(callback) {

@@ -40,2 +38,10 @@ callback(null, event)

}
else {
// mutates! wtf. remove the cached callback
fns.shift()
// add the fresh event
fns.unshift(function(callback) {
callback(null, event)
})
}

@@ -42,0 +48,0 @@ // the real worker here

{
"name": "@smallwins/lambda",
"version": "1.1.2",
"version": "2.0.0",
"description": "Author your AWS Lambda functions as node style errbacks.",

@@ -5,0 +5,0 @@ "main": "index",

@@ -43,40 +43,1 @@ var test = require('tape')

})
test('can invoke a successful lambda', t=> {
t.plan(1)
// always succeeds
function tester(event, callback) {
event.allGood = true
callback(null, event)
}
// mocks don't need a cray mocking lib
var fakeEvent = {}
var fakeContext = {
succeed: function fakeSucceed(v) {
t.ok(v.allGood, 'got the event!')
console.log('fake succeed called with ', v)
}
}
// get our lambda and invoke it with the mocks
var fn = lambda(tester)
fn(fakeEvent, fakeContext)
})
test('can invoke a failful lambda', t=> {
t.plan(1)
// always succeeds
function tester(callback) {
callback(Error('wtf'))
}
// mocks don't need a cray mocking lib
var fakeEvent = {}
var fakeContext = {
succeed: function fakeSucceed(v) {
t.ok(isArray(v), 'got an Errors array')
console.log('faked fail called with ', v)
}
}
// get our lambda and invoke it with the mocks
var fn = lambda(tester)
fn(fakeEvent, fakeContext)
})
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