npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-butler

v3.0.1

Published

Extends the AWS SDK adding the ability to use either promises or callbacks and makes the extraction of data easier by allowing requests to take optional transform parameter

Downloads

9

Readme

aws-butler

Build Status

Features

  • all methods for all services can be executed using either promises or callbacks - promises use when.js for maximum compatibility
  • pageable requests are handled for you - the promise or callback will only be resolved once all pages of data have been retrieved
  • an optional transform function can be provided in request parameters - this allows you to get the data you want with ease
  • aws-butler doesn't change the interface to the SDK methods nor does it alter the response so your current code will work with this module

NOTE: when requests are 'pageable', an array is returned with each element containing the data from a page. If you provide a transform function, the transform is executed for every page of data before it's added to the resulting array. This enables you to tailor the resulting array to get the data in a suitable format. Check out the transform example to see how this can be used to your advantage.

Usage

Simple example

var AWS = require("aws-butler");

var ec2 = new AWS.EC2({ region: "us-east-1" });

// example using promise
ec2.describeInstances()
  .then(data => {
    console.log(data); // data contains standard AWS response
  })
  .catch(err => {
    throw err;
  })
  .done();

// example using callback
ec2.describeInstances(function(err, data) {
  if (err) throw err;
  console.log(data);
});

Example using a transform function to get the IDs of running instances

var AWS = require("aws-butler");

var ec2 = new AWS.EC2({ region: "eu-west-1" });

// params defined with optional transform function
var params = {
  Filters: [
    {
      Name: "instance-state-name",
      Values: ["running"]
    }
  ],
  Transform: function(data) {
    var ids = [];
    data.Reservations.map(function(r) {
      ids = ids.concat(r.Instances.map(function(i) { return i.InstanceId; }));
    });
    return ids;
  }
};

// example using promise
ec2.describeInstances(params)
  .then(data => {
    console.log(data); // data contains a flattened array of instance IDs as collated by the transform function
  })
  .catch(err => {
    throw err;
  })
  .done();

// example using callback
ec2.describeInstances(params, function(err, data) {
  if (err) throw err;
  console.log(data); // data contains a flattened array of instance IDs as collated by the transform function
});

ES6/ES2015

Initially I wrote this using ES6 native promises, arrow functions etc. Unfortunately, ES6 support is still lacking in many places e.g. AWS Lambda uses Node v0.10.36 so no ES6 there. I tried using babel but it was too unreliable. I decided that for maximum compatibility and so people can use this module without issues I'd avoid ES6, at least for now.

Disclaimer

This module is open source and free to use however AWS is not free. I can't be held responsible for any charges you may incur from Amazon while using this module.

If you find any bugs or issues please raise them here.