The current implementation forces you to instantiate the AWSHelper like this:
var AwsHelper = require('aws-lambda-helper');
...
var awsHelper = AwsHelper(context);
awsHelper.Lambda.invoke(...);
...
You have to do this in every place you need the helper, or you can pass the awsHelper around.
Would it not be nicer to do this instead:
var AwsHelper = require('aws-lambda-helper');
...
AwsHelper.init(context);
AwsHelper.Lambda.invoke(...);
...
From the moment of initialisation you can now require AwsHelper and everything will be available for you without reinitialising or without passing the awsHelper around.
This makes mocking in tests a lot easier too, because now it requires you to initialise the AwsHelper before you can access it's functions to mock.
The current implementation forces you to instantiate the AWSHelper like this:
You have to do this in every place you need the helper, or you can pass the
awsHelper
around.Would it not be nicer to do this instead:
From the moment of initialisation you can now require
AwsHelper
and everything will be available for you without reinitialising or without passing theawsHelper
around.This makes mocking in tests a lot easier too, because now it requires you to initialise the AwsHelper before you can access it's functions to mock.
It would be very handy if we could just do