├── Lambda Files ├── async │ ├── .babelrc │ ├── mocha_test │ │ ├── .jshintrc │ │ ├── mocha.opts │ │ ├── support │ │ │ ├── is_browser.js │ │ │ └── get_function_object.js │ │ ├── setImmediate.js │ │ ├── apply.js │ │ ├── constant.js │ │ ├── nextTick.js │ │ ├── sortBy.js │ │ ├── forever.js │ │ ├── transform.js │ │ ├── concat.js │ │ ├── iterator.js │ │ ├── reduce.js │ │ ├── retryable.js │ │ ├── race.js │ │ ├── consoleFunctions.js │ │ ├── timeout.js │ │ ├── times.js │ │ ├── ensureAsync.js │ │ ├── during.js │ │ ├── compose.js │ │ ├── mapValues.js │ │ ├── every.js │ │ ├── until.js │ │ ├── applyEach.js │ │ ├── seq.js │ │ └── some.js │ ├── lib │ │ ├── internal │ │ │ ├── notId.js │ │ │ ├── findGetResult.js │ │ │ ├── withoutIndex.js │ │ │ ├── doLimit.js │ │ │ ├── getIterator.js │ │ │ ├── doParallel.js │ │ │ ├── once.js │ │ │ ├── doSeries.js │ │ │ ├── initialParams.js │ │ │ ├── doParallelLimit.js │ │ │ ├── onlyOnce.js │ │ │ ├── concat.js │ │ │ ├── reject.js │ │ │ ├── map.js │ │ │ ├── applyEach.js │ │ │ ├── parallel.js │ │ │ ├── consoleFunc.js │ │ │ ├── setImmediate.js │ │ │ ├── filter.js │ │ │ ├── iterator.js │ │ │ ├── createTester.js │ │ │ └── eachOfLimit.js │ │ ├── unmemoize.js │ │ ├── timesSeries.js │ │ ├── timesLimit.js │ │ ├── rejectSeries.js │ │ ├── filterSeries.js │ │ ├── applyEachSeries.js │ │ ├── mapSeries.js │ │ ├── rejectLimit.js │ │ ├── everySeries.js │ │ ├── filterLimit.js │ │ ├── mapValuesSeries.js │ │ ├── concatSeries.js │ │ ├── log.js │ │ ├── someSeries.js │ │ ├── eachOfSeries.js │ │ ├── eachSeries.js │ │ ├── mapLimit.js │ │ ├── dir.js │ │ ├── parallelLimit.js │ │ ├── everyLimit.js │ │ ├── times.js │ │ ├── doUntil.js │ │ ├── someLimit.js │ │ ├── eachOfLimit.js │ │ ├── reject.js │ │ ├── detectSeries.js │ │ ├── setImmediate.js │ │ ├── eachLimit.js │ │ ├── until.js │ │ ├── filter.js │ │ ├── detectLimit.js │ │ ├── reduceRight.js │ │ ├── every.js │ │ ├── doDuring.js │ │ ├── reflectAll.js │ │ ├── applyEach.js │ │ ├── doWhilst.js │ │ ├── compose.js │ │ ├── some.js │ │ ├── mapValuesLimit.js │ │ ├── retryable.js │ │ ├── concat.js │ │ ├── nextTick.js │ │ ├── forever.js │ │ ├── iterator.js │ │ ├── constant.js │ │ ├── apply.js │ │ ├── eachOf.js │ │ ├── whilst.js │ │ ├── detect.js │ │ ├── race.js │ │ ├── map.js │ │ ├── timeout.js │ │ ├── mapValues.js │ │ ├── during.js │ │ ├── ensureAsync.js │ │ ├── reflect.js │ │ ├── reduce.js │ │ ├── seq.js │ │ ├── transform.js │ │ ├── sortBy.js │ │ ├── each.js │ │ ├── memoize.js │ │ ├── series.js │ │ ├── parallel.js │ │ ├── asyncify.js │ │ ├── waterfall.js │ │ └── priorityQueue.js │ ├── .npmignore │ ├── .gitattributes │ ├── .gitignore │ ├── index.js │ ├── support │ │ ├── sync-cjs-package.js │ │ ├── sync-es-package.js │ │ ├── es.test.js │ │ ├── module_template.md │ │ └── build.test.js │ ├── .editorconfig │ ├── bower.json │ ├── .travis.yml │ ├── karma.conf.js │ ├── .github │ │ └── ISSUE_TEMPLATE.md │ ├── .eslintrc │ ├── LICENSE │ ├── perf │ │ └── memory.js │ ├── package.json │ └── Makefile ├── AWSRegions.json └── SpeechOutputs.json ├── Alexa Files ├── Custom Slot Types │ ├── LIST_OF_USERNAMES.txt │ ├── LIST_OF_ATTRIBUTES.txt │ ├── LIST_OF_EVENT_NAMES.txt │ ├── LIST_OF_RESOURCES.txt │ ├── LIST_OF_VALUES.txt │ └── LIST_OF_REGIONS.txt ├── SampleUtterances.txt └── IntentSchema.json ├── .github └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── NOTICE.txt ├── AlexaCloudTrailDesignTemplate └── CONTRIBUTING.md /Lambda Files/async/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_USERNAMES.txt: -------------------------------------------------------------------------------- 1 | Add your usernames here 2 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "mocha": true, 3 | "expr": true 4 | } -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/notId.js: -------------------------------------------------------------------------------- 1 | export default function notId(v) { 2 | return !v; 3 | } 4 | -------------------------------------------------------------------------------- /Lambda Files/async/.npmignore: -------------------------------------------------------------------------------- 1 | lib 2 | scripts 3 | support/dependencies.json 4 | support/module_template.md 5 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_ATTRIBUTES.txt: -------------------------------------------------------------------------------- 1 | Event Name 2 | Resource Type 3 | Username 4 | Resource Name 5 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/findGetResult.js: -------------------------------------------------------------------------------- 1 | export default function _findGetResult(v, x) { 2 | return x; 3 | } 4 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/mocha.opts: -------------------------------------------------------------------------------- 1 | --compilers js:babel-core/register 2 | --recursive 3 | --growl 4 | --ui bdd 5 | -------------------------------------------------------------------------------- /Lambda Files/async/.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_EVENT_NAMES.txt: -------------------------------------------------------------------------------- 1 | EventNames should be in the form of: 2 | console login 3 | detach role policy 4 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_RESOURCES.txt: -------------------------------------------------------------------------------- 1 | Resources should be in the form of: 2 | ServiceName ResourceName 3 | ex: CloudTrail Trail 4 | -------------------------------------------------------------------------------- /Lambda Files/async/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | perf/versions 3 | nyc_output 4 | coverage 5 | *.log 6 | .DS_Store 7 | npm-debug.log 8 | tmp 9 | build 10 | build-es 11 | .idea 12 | -------------------------------------------------------------------------------- /Lambda Files/async/index.js: -------------------------------------------------------------------------------- 1 | // This is not the main file in the npm package, but here so we can use github 2 | // tarballs as packages when necessary. 3 | module.exports = require("./build/"); 4 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/support/is_browser.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { 2 | return (typeof process === "undefined") || 3 | (process + "" !== "[object process]"); // browserify 4 | }; 5 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/withoutIndex.js: -------------------------------------------------------------------------------- 1 | export default function _withoutIndex(iteratee) { 2 | return function (value, index, callback) { 3 | return iteratee(value, callback); 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/doLimit.js: -------------------------------------------------------------------------------- 1 | export default function doLimit(fn, limit) { 2 | return function (iterable, iteratee, callback) { 3 | return fn(iterable, limit, iteratee, callback); 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_VALUES.txt: -------------------------------------------------------------------------------- 1 | List values that you want to do lookups on. 2 | All values for Event Names 3 | All values for Usernames 4 | All values for Resource Types 5 | All values for Resource Names 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 7 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/getIterator.js: -------------------------------------------------------------------------------- 1 | var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; 2 | 3 | export default function (coll) { 4 | return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); 5 | } 6 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/doParallel.js: -------------------------------------------------------------------------------- 1 | import eachOf from '../eachOf'; 2 | 3 | export default function doParallel(fn) { 4 | return function (obj, iteratee, callback) { 5 | return fn(eachOf, obj, iteratee, callback); 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/once.js: -------------------------------------------------------------------------------- 1 | export default function once(fn) { 2 | return function () { 3 | if (fn === null) return; 4 | var callFn = fn; 5 | fn = null; 6 | callFn.apply(this, arguments); 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/doSeries.js: -------------------------------------------------------------------------------- 1 | import eachOfSeries from '../eachOfSeries'; 2 | 3 | export default function doSeries(fn) { 4 | return function (obj, iteratee, callback) { 5 | return fn(eachOfSeries, obj, iteratee, callback); 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/initialParams.js: -------------------------------------------------------------------------------- 1 | import rest from 'lodash/rest'; 2 | 3 | export default function (fn) { 4 | return rest(function (args/*..., callback*/) { 5 | var callback = args.pop(); 6 | fn.call(this, args, callback); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/doParallelLimit.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './eachOfLimit'; 2 | 3 | export default function doParallelLimit(fn) { 4 | return function (obj, limit, iteratee, callback) { 5 | return fn(eachOfLimit(limit), obj, iteratee, callback); 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/onlyOnce.js: -------------------------------------------------------------------------------- 1 | export default function onlyOnce(fn) { 2 | return function() { 3 | if (fn === null) throw new Error("Callback was already called."); 4 | var callFn = fn; 5 | fn = null; 6 | callFn.apply(this, arguments); 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /Lambda Files/async/support/sync-cjs-package.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | var json = JSON.parse(fs.readFileSync(__dirname + "/../package.json"), "utf8"); 5 | 6 | delete json.dependencies["lodash-es"]; 7 | 8 | process.stdout.write(JSON.stringify(json, null, 2)); 9 | 10 | 11 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /Lambda Files/async/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | indent_style = space 10 | indent_size = 4 11 | 12 | [package.json] 13 | indent_size = 2 14 | 15 | [Makefile] 16 | indent_style = tab 17 | indent_size = 4 18 | -------------------------------------------------------------------------------- /Lambda Files/async/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "async", 3 | "main": "dist/async.js", 4 | "ignore": [ 5 | "bower_components", 6 | "lib", 7 | "mocha_test", 8 | "node_modules", 9 | "perf", 10 | "support", 11 | "**/.*", 12 | "*.config.js", 13 | "*.json", 14 | "index.js", 15 | "Makefile" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Lambda Files/async/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | - "0.12" 5 | - "4" 6 | - "6" 7 | sudo: false 8 | after_success: npm run coveralls 9 | 10 | # Needed to run Karma with Firefox on Travis 11 | # http://karma-runner.github.io/0.13/plus/travis.html 12 | before_script: 13 | - export DISPLAY=:99.0 14 | - sh -e /etc/init.d/xvfb start 15 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/concat.js: -------------------------------------------------------------------------------- 1 | export default function concat(eachfn, arr, fn, callback) { 2 | var result = []; 3 | eachfn(arr, function (x, index, cb) { 4 | fn(x, function (err, y) { 5 | result = result.concat(y || []); 6 | cb(err); 7 | }); 8 | }, function (err) { 9 | callback(err, result); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/reject.js: -------------------------------------------------------------------------------- 1 | import filter from './filter'; 2 | 3 | export default function reject(eachfn, arr, iteratee, callback) { 4 | filter(eachfn, arr, function(value, cb) { 5 | iteratee(value, function(err, v) { 6 | if (err) { 7 | cb(err); 8 | } else { 9 | cb(null, !v); 10 | } 11 | }); 12 | }, callback); 13 | } 14 | -------------------------------------------------------------------------------- /Lambda Files/async/support/sync-es-package.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var fs = require('fs'); 4 | var json = JSON.parse(fs.readFileSync(__dirname + "/../package.json"), "utf8"); 5 | 6 | json.name = "async-es"; 7 | json.main = "index.js"; 8 | delete json.dependencies["lodash"]; 9 | delete json.volo; 10 | delete json.spm; 11 | delete json.jam; 12 | 13 | process.stdout.write(JSON.stringify(json, null, 2)); 14 | 15 | 16 | -------------------------------------------------------------------------------- /Lambda Files/async/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(config) { 2 | config.set({ 3 | browsers: ['Firefox'], 4 | files: ['mocha_test/*.js'], 5 | frameworks: ['browserify', 'mocha'], 6 | preprocessors: { 7 | 'mocha_test/*.js': ['browserify'] 8 | }, 9 | reporters: ['mocha'], 10 | singleRun: true, 11 | 12 | browserify: { 13 | debug: true, 14 | transform: ['babelify'] 15 | } 16 | }); 17 | }; 18 | -------------------------------------------------------------------------------- /Lambda Files/async/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | **What version of async are you using?** 6 | 7 | **Which environment did the issue occur in (Node version/browser version)** 8 | 9 | **What did you do? Please include a minimal reproducable case illustrating issue.** 10 | 11 | **What did you expect to happen?** 12 | 13 | **What was the actual result?** 14 | 15 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/unmemoize.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Undoes a {@link async.memoize}d function, reverting it to the original, 3 | * unmemoized form. Handy for testing. 4 | * 5 | * @name unmemoize 6 | * @static 7 | * @memberOf async 8 | * @see async.memoize 9 | * @category Util 10 | * @param {Function} fn - the memoized function 11 | * @returns {Function} a function that calls the original unmemoized function 12 | */ 13 | export default function unmemoize(fn) { 14 | return function () { 15 | return (fn.unmemoized || fn).apply(null, arguments); 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/map.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import once from './once'; 3 | 4 | export default function _asyncMap(eachfn, arr, iteratee, callback) { 5 | callback = once(callback || noop); 6 | arr = arr || []; 7 | var results = []; 8 | var counter = 0; 9 | 10 | eachfn(arr, function (value, _, callback) { 11 | var index = counter++; 12 | iteratee(value, function (err, v) { 13 | results[index] = v; 14 | callback(err); 15 | }); 16 | }, function (err) { 17 | callback(err, results); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Alexa Integration with AWS CloudTrail 2 | 3 | 4 | Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | 6 | Licensed under the Amazon Software License (the "License"). You may not use this 7 | file except in compliance with the License. A copy of the License is located at 8 | 9 | http://aws.amazon.com/asl/ 10 | 11 | or in the "license" file accompanying this file. This file is distributed on 12 | an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or 13 | implied. See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /Lambda Files/async/support/es.test.js: -------------------------------------------------------------------------------- 1 | // simple async example to test ES module build output 2 | 3 | import {waterfall as waterfall} from "../build-es/index"; 4 | import async from "../build-es/index"; 5 | import constant from "../build-es/constant"; 6 | 7 | waterfall([ 8 | constant(42), 9 | function (val, next) { 10 | async.setImmediate(function () { 11 | next(null, val); 12 | }); 13 | } 14 | ], function (err, result) { 15 | if (err) { throw err; } 16 | console.log(result); 17 | if (result !== 42) { 18 | console.log("fail"); 19 | process.exit(1); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /Alexa Files/Custom Slot Types/LIST_OF_REGIONS.txt: -------------------------------------------------------------------------------- 1 | us-east-1 2 | east 3 | north virginia 4 | virginia 5 | east coast 6 | us-west-1 7 | califorina 8 | us-west-2 9 | oregon 10 | ap-south-1 11 | mumbai 12 | bombay 13 | india 14 | south asia 15 | ap-northeast-2 16 | seoul 17 | korea 18 | south korea 19 | ap-southeast-1 20 | singapore 21 | ap-southeast-2 22 | sydney 23 | australia 24 | ap-northeast-1 25 | tokyo 26 | japan 27 | eu-central-1 28 | frankfurt 29 | germany 30 | eastern europe 31 | central europe 32 | eu-west-1 33 | ireland 34 | western wurope 35 | sa-east-1 36 | sao paulo 37 | brazil 38 | south america -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/applyEach.js: -------------------------------------------------------------------------------- 1 | import rest from 'lodash/rest'; 2 | import initialParams from './initialParams'; 3 | 4 | export default function applyEach(eachfn) { 5 | return rest(function(fns, args) { 6 | var go = initialParams(function(args, callback) { 7 | var that = this; 8 | return eachfn(fns, function (fn, cb) { 9 | fn.apply(that, args.concat([cb])); 10 | }, callback); 11 | }); 12 | if (args.length) { 13 | return go.apply(this, args); 14 | } 15 | else { 16 | return go; 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/timesSeries.js: -------------------------------------------------------------------------------- 1 | import timesLimit from './timesLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as {@link async.times} but runs only a single async operation at a time. 6 | * 7 | * @name timesSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.times 11 | * @category Control Flow 12 | * @param {number} n - The number of times to run the function. 13 | * @param {Function} iteratee - The function to call `n` times. Invoked with the 14 | * iteration index and a callback (n, next). 15 | * @param {Function} callback - see {@link async.map}. 16 | */ 17 | export default doLimit(timesLimit, 1); 18 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/parallel.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import isArrayLike from 'lodash/isArrayLike'; 3 | import rest from 'lodash/rest'; 4 | 5 | export default function _parallel(eachfn, tasks, callback) { 6 | callback = callback || noop; 7 | var results = isArrayLike(tasks) ? [] : {}; 8 | 9 | eachfn(tasks, function (task, key, callback) { 10 | task(rest(function (err, args) { 11 | if (args.length <= 1) { 12 | args = args[0]; 13 | } 14 | results[key] = args; 15 | callback(err); 16 | })); 17 | }, function (err) { 18 | callback(err, results); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/setImmediate.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe("setImmediate", function () { 5 | 6 | it('basics', function(done){ 7 | var call_order = []; 8 | async.setImmediate(function(){call_order.push('two');}); 9 | call_order.push('one'); 10 | 11 | setTimeout(function(){ 12 | expect(call_order).to.eql(['one','two']); 13 | done(); 14 | }, 25); 15 | }); 16 | 17 | it("extra args", function (done) { 18 | async.setImmediate(function (a, b, c) { 19 | expect([a, b, c]).to.eql([1, 2, 3]); 20 | done(); 21 | }, 1, 2, 3); 22 | }); 23 | 24 | }); 25 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/support/get_function_object.js: -------------------------------------------------------------------------------- 1 | module.exports = function (call_order) { 2 | return { 3 | one: function(callback) { 4 | setTimeout(function() { 5 | call_order.push(1); 6 | callback(null, 1); 7 | }, 125); 8 | }, 9 | two: function(callback) { 10 | setTimeout(function() { 11 | call_order.push(2); 12 | callback(null, 2); 13 | }, 200); 14 | }, 15 | three: function(callback) { 16 | setTimeout(function() { 17 | call_order.push(3); 18 | callback(null, 3, 3); 19 | }, 50); 20 | } 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/apply.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('concat', function() { 5 | it('apply', function(done) { 6 | var fn = function(){ 7 | expect(Array.prototype.slice.call(arguments)).to.eql([1,2,3,4]); 8 | }; 9 | async.apply(fn, 1, 2, 3, 4)(); 10 | async.apply(fn, 1, 2, 3)(4); 11 | async.apply(fn, 1, 2)(3, 4); 12 | async.apply(fn, 1)(2, 3, 4); 13 | async.apply(fn)(1, 2, 3, 4); 14 | expect( 15 | async.apply(function(name){return 'hello ' + name;}, 'world')() 16 | ).to.equal( 17 | 'hello world' 18 | ); 19 | done(); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/consoleFunc.js: -------------------------------------------------------------------------------- 1 | import arrayEach from 'lodash/_arrayEach'; 2 | import rest from 'lodash/rest'; 3 | 4 | export default function consoleFunc(name) { 5 | return rest(function (fn, args) { 6 | fn.apply(null, args.concat([rest(function (err, args) { 7 | if (typeof console === 'object') { 8 | if (err) { 9 | if (console.error) { 10 | console.error(err); 11 | } 12 | } 13 | else if (console[name]) { 14 | arrayEach(args, function (x) { 15 | console[name](x); 16 | }); 17 | } 18 | } 19 | })])); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/setImmediate.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import rest from 'lodash/rest'; 4 | 5 | export var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; 6 | export var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; 7 | 8 | export function fallback(fn) { 9 | setTimeout(fn, 0); 10 | } 11 | 12 | export function wrap(defer) { 13 | return rest(function (fn, args) { 14 | defer(function () { 15 | fn.apply(null, args); 16 | }); 17 | }); 18 | } 19 | 20 | var _defer; 21 | 22 | if (hasSetImmediate) { 23 | _defer = setImmediate; 24 | } else if (hasNextTick) { 25 | _defer = process.nextTick; 26 | } else { 27 | _defer = fallback; 28 | } 29 | 30 | export default wrap(_defer); 31 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/timesLimit.js: -------------------------------------------------------------------------------- 1 | import mapLimit from './mapLimit'; 2 | import range from 'lodash/_baseRange'; 3 | 4 | /** 5 | * The same as {@link times} but runs a maximum of `limit` async operations at a 6 | * time. 7 | * 8 | * @name timesLimit 9 | * @static 10 | * @memberOf async 11 | * @see async.times 12 | * @category Control Flow 13 | * @param {number} count - The number of times to run the function. 14 | * @param {number} limit - The maximum number of async operations at a time. 15 | * @param {Function} iteratee - The function to call `n` times. Invoked with the 16 | * iteration index and a callback (n, next). 17 | * @param {Function} callback - see {@link async.map}. 18 | */ 19 | export default function timeLimit(count, limit, iteratee, callback) { 20 | mapLimit(range(0, count, 1), limit, iteratee, callback); 21 | } 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/rejectSeries.js: -------------------------------------------------------------------------------- 1 | import rejectLimit from './rejectLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `reject` but runs only a single async operation at a time. 6 | * 7 | * @name rejectSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.reject 11 | * @category Collection 12 | * @param {Array|Object} coll - A collection to iterate over. 13 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 14 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 15 | * with a boolean argument once it has completed. Invoked with (item, callback). 16 | * @param {Function} [callback] - A callback which is called after all the 17 | * `iteratee` functions have finished. Invoked with (err, results). 18 | */ 19 | export default doLimit(rejectLimit, 1); 20 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/filterSeries.js: -------------------------------------------------------------------------------- 1 | import filterLimit from './filterLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `filter` but runs only a single async operation at a time. 6 | * 7 | * @name filterSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.filter 11 | * @alias selectSeries 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 15 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 16 | * with a boolean argument once it has completed. Invoked with (item, callback). 17 | * @param {Function} [callback] - A callback which is called after all the 18 | * `iteratee` functions have finished. Invoked with (err, results) 19 | */ 20 | export default doLimit(filterLimit, 1); 21 | -------------------------------------------------------------------------------- /Lambda Files/async/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true, 5 | "mocha": true, 6 | "es6": true 7 | }, 8 | "parserOptions": { 9 | "ecmaVersion": 6, 10 | "sourceType": "module" 11 | }, 12 | "rules": { 13 | "eqeqeq": 0, 14 | "guard-for-in": 2, 15 | "indent": [ 16 | 2, 17 | 4, 18 | { 19 | "SwitchCase": 1 20 | } 21 | ], 22 | "no-caller": 2, 23 | "no-undef": 2, 24 | "no-unused-vars": 2, 25 | "no-eval": 2, 26 | "comma-style": [ 27 | 2, 28 | "last" 29 | ], 30 | "semi": 0, 31 | "no-eq-null": 0, 32 | "no-unused-expressions": 0, 33 | "no-loop-func": 2, 34 | "dot-notation": 0, 35 | "valid-jsdoc": ["error", { 36 | "requireReturn": false, 37 | "requireReturnDescription": false, 38 | "requireReturnType": false 39 | }] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/filter.js: -------------------------------------------------------------------------------- 1 | import arrayMap from 'lodash/_arrayMap'; 2 | import property from 'lodash/_baseProperty'; 3 | 4 | export default function _filter(eachfn, arr, iteratee, callback) { 5 | var results = []; 6 | eachfn(arr, function (x, index, callback) { 7 | iteratee(x, function (err, v) { 8 | if (err) { 9 | callback(err); 10 | } 11 | else { 12 | if (v) { 13 | results.push({index: index, value: x}); 14 | } 15 | callback(); 16 | } 17 | }); 18 | }, function (err) { 19 | if (err) { 20 | callback(err); 21 | } 22 | else { 23 | callback(null, arrayMap(results.sort(function (a, b) { 24 | return a.index - b.index; 25 | }), property('value'))); 26 | } 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/applyEachSeries.js: -------------------------------------------------------------------------------- 1 | import applyEach from './internal/applyEach'; 2 | import mapSeries from './mapSeries'; 3 | 4 | /** 5 | * The same as `applyEach` but runs only a single async operation at a time. 6 | * 7 | * @name applyEachSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.applyEach 11 | * @category Control Flow 12 | * @param {Array|Object} fns - A collection of asynchronous functions to all 13 | * call with the same arguments 14 | * @param {...*} [args] - any number of separate arguments to pass to the 15 | * function. 16 | * @param {Function} [callback] - the final argument should be the callback, 17 | * called when all functions have completed processing. 18 | * @returns {Function} - If only the first argument is provided, it will return 19 | * a function which lets you pass in the arguments as if it were a single 20 | * function call. 21 | */ 22 | export default applyEach(mapSeries); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/constant.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('constant', function () { 5 | 6 | it('basic usage', function(done){ 7 | var f = async.constant(42, 1, 2, 3); 8 | f(function (err, value, a, b, c) { 9 | expect(err).to.equal(null); 10 | expect(value).to.equal(42); 11 | expect(a).to.equal(1); 12 | expect(b).to.equal(2); 13 | expect(c).to.equal(3); 14 | done(); 15 | }); 16 | }); 17 | 18 | it('called with multiple arguments', function(done){ 19 | var f = async.constant(42, 1, 2, 3); 20 | f('argument to ignore', 'another argument', function (err, value, a) { 21 | expect(err).to.equal(null); 22 | expect(value).to.equal(42); 23 | expect(a).to.equal(1); 24 | done(); 25 | }); 26 | }); 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/mapSeries.js: -------------------------------------------------------------------------------- 1 | import mapLimit from './mapLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `map` but runs only a single async operation at a time. 6 | * 7 | * @name mapSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.map 11 | * @category Collection 12 | * @param {Array|Object} coll - A collection to iterate over. 13 | * @param {Function} iteratee - A function to apply to each item in `coll`. 14 | * The iteratee is passed a `callback(err, transformed)` which must be called 15 | * once it has completed with an error (which can be `null`) and a 16 | * transformed item. Invoked with (item, callback). 17 | * @param {Function} [callback] - A callback which is called when all `iteratee` 18 | * functions have finished, or an error occurs. Results is an array of the 19 | * transformed items from the `coll`. Invoked with (err, results). 20 | */ 21 | export default doLimit(mapLimit, 1); 22 | -------------------------------------------------------------------------------- /Lambda Files/async/support/module_template.md: -------------------------------------------------------------------------------- 1 | # async.<%= name %> 2 | 3 | ![Last version](https://img.shields.io/github/tag/async-js/async.<%= name %>.svg?style=flat-square) 4 | [![Build Status](http://img.shields.io/travis/async-js/async.<%= name %>/master.svg?style=flat-square)](https://travis-ci.org/async-js/async.<%= name %>) 5 | [![Dependency status](http://img.shields.io/david/async-js/async.<%= name %>.svg?style=flat-square)](https://david-dm.org/async-js/async.<%= name %>) 6 | [![Dev Dependencies Status](http://img.shields.io/david/dev/async-js/async.<%= name %>.svg?style=flat-square)](https://david-dm.org/async-js/async.<%= name %>#info=devDependencies) 7 | [![NPM Status](http://img.shields.io/npm/dm/async.<%= name %>.svg?style=flat-square)](https://www.npmjs.org/package/<%= name %>) 8 | 9 | > [async#<%= name %>](https://github.com/async-js/async#<%= name %>) method as module. 10 | 11 | ## License 12 | 13 | MIT © [async-js](https://github.com/async-js) 14 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/rejectLimit.js: -------------------------------------------------------------------------------- 1 | import reject from './internal/reject'; 2 | import doParallelLimit from './internal/doParallelLimit'; 3 | 4 | /** 5 | * The same as `reject` but runs a maximum of `limit` async operations at a 6 | * time. 7 | * 8 | * @name rejectLimit 9 | * @static 10 | * @memberOf async 11 | * @see async.reject 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {number} limit - The maximum number of async operations at a time. 15 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 16 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 17 | * with a boolean argument once it has completed. Invoked with (item, callback). 18 | * @param {Function} [callback] - A callback which is called after all the 19 | * `iteratee` functions have finished. Invoked with (err, results). 20 | */ 21 | export default doParallelLimit(reject); 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/everySeries.js: -------------------------------------------------------------------------------- 1 | import everyLimit from './everyLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `every` but runs only a single async operation at a time. 6 | * 7 | * @name everySeries 8 | * @static 9 | * @memberOf async 10 | * @see async.every 11 | * @alias allSeries 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A truth test to apply to each item in the 15 | * collection in parallel. The iteratee is passed a `callback(err, truthValue)` 16 | * which must be called with a boolean argument once it has completed. Invoked 17 | * with (item, callback). 18 | * @param {Function} [callback] - A callback which is called after all the 19 | * `iteratee` functions have finished. Result will be either `true` or `false` 20 | * depending on the values of the async tests. Invoked with (err, result). 21 | */ 22 | export default doLimit(everyLimit, 1); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/filterLimit.js: -------------------------------------------------------------------------------- 1 | import filter from './internal/filter'; 2 | import doParallelLimit from './internal/doParallelLimit'; 3 | 4 | /** 5 | * The same as `filter` but runs a maximum of `limit` async operations at a 6 | * time. 7 | * 8 | * @name filterLimit 9 | * @static 10 | * @memberOf async 11 | * @see async.filter 12 | * @alias selectLimit 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {number} limit - The maximum number of async operations at a time. 16 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 17 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 18 | * with a boolean argument once it has completed. Invoked with (item, callback). 19 | * @param {Function} [callback] - A callback which is called after all the 20 | * `iteratee` functions have finished. Invoked with (err, results). 21 | */ 22 | export default doParallelLimit(filter); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/mapValuesSeries.js: -------------------------------------------------------------------------------- 1 | import mapValuesLimit from './mapValuesLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `mapValues` but runs only a single async operation at a time. 6 | * 7 | * @name mapValuesSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.mapValues 11 | * @category Collection 12 | * @param {Object} obj - A collection to iterate over. 13 | * @param {Function} iteratee - A function to apply to each value in `obj`. 14 | * The iteratee is passed a `callback(err, transformed)` which must be called 15 | * once it has completed with an error (which can be `null`) and a 16 | * transformed value. Invoked with (value, key, callback). 17 | * @param {Function} [callback] - A callback which is called when all `iteratee` 18 | * functions have finished, or an error occurs. Result is an object of the 19 | * transformed values from the `obj`. Invoked with (err, result). 20 | */ 21 | export default doLimit(mapValuesLimit, 1); 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/concatSeries.js: -------------------------------------------------------------------------------- 1 | import concat from './internal/concat'; 2 | import doSeries from './internal/doSeries'; 3 | 4 | /** 5 | * The same as `concat` but runs only a single async operation at a time. 6 | * 7 | * @name concatSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.concat 11 | * @category Collection 12 | * @param {Array|Object} coll - A collection to iterate over. 13 | * @param {Function} iteratee - A function to apply to each item in `coll`. 14 | * The iteratee is passed a `callback(err, results)` which must be called once 15 | * it has completed with an error (which can be `null`) and an array of results. 16 | * Invoked with (item, callback). 17 | * @param {Function} [callback(err)] - A callback which is called after all the 18 | * `iteratee` functions have finished, or an error occurs. Results is an array 19 | * containing the concatenated results of the `iteratee` function. Invoked with 20 | * (err, results). 21 | */ 22 | export default doSeries(concat); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/iterator.js: -------------------------------------------------------------------------------- 1 | import isArrayLike from 'lodash/isArrayLike'; 2 | import getIterator from './getIterator'; 3 | import keys from 'lodash/keys'; 4 | 5 | export default function iterator(coll) { 6 | var i = -1; 7 | var len; 8 | if (isArrayLike(coll)) { 9 | len = coll.length; 10 | return function next() { 11 | i++; 12 | return i < len ? {value: coll[i], key: i} : null; 13 | }; 14 | } 15 | 16 | var iterate = getIterator(coll); 17 | if (iterate) { 18 | return function next() { 19 | var item = iterate.next(); 20 | if (item.done) 21 | return null; 22 | i++; 23 | return {value: item.value, key: i}; 24 | }; 25 | } 26 | 27 | var okeys = keys(coll); 28 | len = okeys.length; 29 | return function next() { 30 | i++; 31 | var key = okeys[i]; 32 | return i < len ? {value: coll[key], key: key} : null; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/log.js: -------------------------------------------------------------------------------- 1 | import consoleFunc from './internal/consoleFunc'; 2 | 3 | /** 4 | * Logs the result of an `async` function to the `console`. Only works in 5 | * Node.js or in browsers that support `console.log` and `console.error` (such 6 | * as FF and Chrome). If multiple arguments are returned from the async 7 | * function, `console.log` is called on each argument in order. 8 | * 9 | * @name log 10 | * @static 11 | * @memberOf async 12 | * @category Util 13 | * @param {Function} function - The function you want to eventually apply all 14 | * arguments to. 15 | * @param {...*} arguments... - Any number of arguments to apply to the function. 16 | * @example 17 | * 18 | * // in a module 19 | * var hello = function(name, callback) { 20 | * setTimeout(function() { 21 | * callback(null, 'hello ' + name); 22 | * }, 1000); 23 | * }; 24 | * 25 | * // in the node repl 26 | * node> async.log(hello, 'world'); 27 | * 'hello world' 28 | */ 29 | export default consoleFunc('log'); 30 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/someSeries.js: -------------------------------------------------------------------------------- 1 | import someLimit from './someLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `some` but runs only a single async operation at a time. 6 | * 7 | * @name someSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.some 11 | * @alias anySeries 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A truth test to apply to each item in the array 15 | * in parallel. The iteratee is passed a `callback(err, truthValue)` which must 16 | * be called with a boolean argument once it has completed. Invoked with 17 | * (item, callback). 18 | * @param {Function} [callback] - A callback which is called as soon as any 19 | * iteratee returns `true`, or after all the iteratee functions have finished. 20 | * Result will be either `true` or `false` depending on the values of the async 21 | * tests. Invoked with (err, result). 22 | */ 23 | export default doLimit(someLimit, 1); 24 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/eachOfSeries.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './eachOfLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `eachOf` but runs only a single async operation at a time. 6 | * 7 | * @name eachOfSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.eachOf 11 | * @alias forEachOfSeries 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A function to apply to each item in `coll`. The 15 | * `key` is the item's key, or index in the case of an array. The iteratee is 16 | * passed a `callback(err)` which must be called once it has completed. If no 17 | * error has occurred, the callback should be run without arguments or with an 18 | * explicit `null` argument. Invoked with (item, key, callback). 19 | * @param {Function} [callback] - A callback which is called when all `iteratee` 20 | * functions have finished, or an error occurs. Invoked with (err). 21 | */ 22 | export default doLimit(eachOfLimit, 1); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/eachSeries.js: -------------------------------------------------------------------------------- 1 | import eachLimit from './eachLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The same as `each` but runs only a single async operation at a time. 6 | * 7 | * @name eachSeries 8 | * @static 9 | * @memberOf async 10 | * @see async.each 11 | * @alias forEachSeries 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A function to apply to each 15 | * item in `coll`. The iteratee is passed a `callback(err)` which must be called 16 | * once it has completed. If no error has occurred, the `callback` should be run 17 | * without arguments or with an explicit `null` argument. The array index is 18 | * not passed to the iteratee. Invoked with (item, callback). If you need the 19 | * index, use `eachOfSeries`. 20 | * @param {Function} [callback] - A callback which is called when all 21 | * `iteratee` functions have finished, or an error occurs. Invoked with (err). 22 | */ 23 | export default doLimit(eachLimit, 1); 24 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/mapLimit.js: -------------------------------------------------------------------------------- 1 | import doParallelLimit from './internal/doParallelLimit'; 2 | import map from './internal/map'; 3 | 4 | /** 5 | * The same as `map` but runs a maximum of `limit` async operations at a time. 6 | * 7 | * @name mapLimit 8 | * @static 9 | * @memberOf async 10 | * @see async.map 11 | * @category Collection 12 | * @param {Array|Object} coll - A collection to iterate over. 13 | * @param {number} limit - The maximum number of async operations at a time. 14 | * @param {Function} iteratee - A function to apply to each item in `coll`. 15 | * The iteratee is passed a `callback(err, transformed)` which must be called 16 | * once it has completed with an error (which can be `null`) and a transformed 17 | * item. Invoked with (item, callback). 18 | * @param {Function} [callback] - A callback which is called when all `iteratee` 19 | * functions have finished, or an error occurs. Results is an array of the 20 | * transformed items from the `coll`. Invoked with (err, results). 21 | */ 22 | export default doParallelLimit(map); 23 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/dir.js: -------------------------------------------------------------------------------- 1 | import consoleFunc from './internal/consoleFunc'; 2 | 3 | /** 4 | * Logs the result of an `async` function to the `console` using `console.dir` 5 | * to display the properties of the resulting object. Only works in Node.js or 6 | * in browsers that support `console.dir` and `console.error` (such as FF and 7 | * Chrome). If multiple arguments are returned from the async function, 8 | * `console.dir` is called on each argument in order. 9 | * 10 | * @name log 11 | * @static 12 | * @memberOf async 13 | * @category Util 14 | * @param {Function} function - The function you want to eventually apply all 15 | * arguments to. 16 | * @param {...*} arguments... - Any number of arguments to apply to the function. 17 | * @example 18 | * 19 | * // in a module 20 | * var hello = function(name, callback) { 21 | * setTimeout(function() { 22 | * callback(null, {hello: name}); 23 | * }, 1000); 24 | * }; 25 | * 26 | * // in the node repl 27 | * node> async.dir(hello, 'world'); 28 | * {hello: 'world'} 29 | */ 30 | export default consoleFunc('dir'); 31 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/parallelLimit.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './internal/eachOfLimit'; 2 | import parallel from './internal/parallel'; 3 | 4 | /** 5 | * The same as `parallel` but runs a maximum of `limit` async operations at a 6 | * time. 7 | * 8 | * @name parallel 9 | * @static 10 | * @memberOf async 11 | * @see async.parallel 12 | * @category Control Flow 13 | * @param {Array|Collection} tasks - A collection containing functions to run. 14 | * Each function is passed a `callback(err, result)` which it must call on 15 | * completion with an error `err` (which can be `null`) and an optional `result` 16 | * value. 17 | * @param {number} limit - The maximum number of async operations at a time. 18 | * @param {Function} [callback] - An optional callback to run once all the 19 | * functions have completed successfully. This function gets a results array 20 | * (or object) containing all the result arguments passed to the task callbacks. 21 | * Invoked with (err, results). 22 | */ 23 | export default function parallelLimit(tasks, limit, callback) { 24 | parallel(eachOfLimit(limit), tasks, callback); 25 | } 26 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/everyLimit.js: -------------------------------------------------------------------------------- 1 | import createTester from './internal/createTester'; 2 | import eachOfLimit from './eachOfLimit'; 3 | import notId from './internal/notId'; 4 | 5 | /** 6 | * The same as `every` but runs a maximum of `limit` async operations at a time. 7 | * 8 | * @name everyLimit 9 | * @static 10 | * @memberOf async 11 | * @see async.every 12 | * @alias allLimit 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {number} limit - The maximum number of async operations at a time. 16 | * @param {Function} iteratee - A truth test to apply to each item in the 17 | * collection in parallel. The iteratee is passed a `callback(err, truthValue)` 18 | * which must be called with a boolean argument once it has completed. Invoked 19 | * with (item, callback). 20 | * @param {Function} [callback] - A callback which is called after all the 21 | * `iteratee` functions have finished. Result will be either `true` or `false` 22 | * depending on the values of the async tests. Invoked with (err, result). 23 | */ 24 | export default createTester(eachOfLimit, notId, notId); 25 | -------------------------------------------------------------------------------- /Lambda Files/async/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2016 Caolan McMahon 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/times.js: -------------------------------------------------------------------------------- 1 | import timesLimit from './timesLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Calls the `iteratee` function `n` times, and accumulates results in the same 6 | * manner you would use with {@link async.map}. 7 | * 8 | * @name times 9 | * @static 10 | * @memberOf async 11 | * @see async.map 12 | * @category Control Flow 13 | * @param {number} n - The number of times to run the function. 14 | * @param {Function} iteratee - The function to call `n` times. Invoked with the 15 | * iteration index and a callback (n, next). 16 | * @param {Function} callback - see {@link async.map}. 17 | * @example 18 | * 19 | * // Pretend this is some complicated async factory 20 | * var createUser = function(id, callback) { 21 | * callback(null, { 22 | * id: 'user' + id 23 | * }); 24 | * }; 25 | * 26 | * // generate 5 users 27 | * async.times(5, function(n, next) { 28 | * createUser(n, function(err, user) { 29 | * next(err, user); 30 | * }); 31 | * }, function(err, users) { 32 | * // we should now have 5 users 33 | * }); 34 | */ 35 | export default doLimit(timesLimit, Infinity); 36 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/doUntil.js: -------------------------------------------------------------------------------- 1 | import doWhilst from './doWhilst'; 2 | 3 | /** 4 | * Like {@link async.doWhilst}, except the `test` is inverted. Note the 5 | * argument ordering differs from `until`. 6 | * 7 | * @name doUntil 8 | * @static 9 | * @memberOf async 10 | * @see async.doWhilst 11 | * @category Control Flow 12 | * @param {Function} fn - A function which is called each time `test` fails. 13 | * The function is passed a `callback(err)`, which must be called once it has 14 | * completed with an optional `err` argument. Invoked with (callback). 15 | * @param {Function} test - synchronous truth test to perform after each 16 | * execution of `fn`. Invoked with the non-error callback results of `fn`. 17 | * @param {Function} [callback] - A callback which is called after the test 18 | * function has passed and repeated execution of `fn` has stopped. `callback` 19 | * will be passed an error and any arguments passed to the final `fn`'s 20 | * callback. Invoked with (err, [results]); 21 | */ 22 | export default function doUntil(fn, test, callback) { 23 | doWhilst(fn, function() { 24 | return !test.apply(this, arguments); 25 | }, callback); 26 | } 27 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/nextTick.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe("nextTick", function () { 5 | 6 | it('basics', function(done){ 7 | var call_order = []; 8 | async.nextTick(function(){call_order.push('two');}); 9 | call_order.push('one'); 10 | setTimeout(function(){ 11 | expect(call_order).to.eql(['one','two']); 12 | done(); 13 | }, 50); 14 | }); 15 | 16 | it('nextTick in the browser', function(done){ 17 | if (!process.browser) { 18 | // skip this test in node 19 | return done(); 20 | } 21 | 22 | var call_order = []; 23 | async.nextTick(function(){call_order.push('two');}); 24 | 25 | call_order.push('one'); 26 | setTimeout(function(){ 27 | expect(call_order).to.eql(['one','two']); 28 | done(); 29 | }, 50); 30 | }); 31 | 32 | it("extra args", function (done) { 33 | async.nextTick(function (a, b, c) { 34 | expect([a, b, c]).to.eql([1, 2, 3]); 35 | done(); 36 | }, 1, 2, 3); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/someLimit.js: -------------------------------------------------------------------------------- 1 | import createTester from './internal/createTester'; 2 | import eachOfLimit from './eachOfLimit'; 3 | import identity from 'lodash/identity'; 4 | 5 | /** 6 | * The same as `some` but runs a maximum of `limit` async operations at a time. 7 | * 8 | * @name someLimit 9 | * @static 10 | * @memberOf async 11 | * @see async.some 12 | * @alias anyLimit 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {number} limit - The maximum number of async operations at a time. 16 | * @param {Function} iteratee - A truth test to apply to each item in the array 17 | * in parallel. The iteratee is passed a `callback(err, truthValue)` which must 18 | * be called with a boolean argument once it has completed. Invoked with 19 | * (item, callback). 20 | * @param {Function} [callback] - A callback which is called as soon as any 21 | * iteratee returns `true`, or after all the iteratee functions have finished. 22 | * Result will be either `true` or `false` depending on the values of the async 23 | * tests. Invoked with (err, result). 24 | */ 25 | export default createTester(eachOfLimit, Boolean, identity); 26 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/eachOfLimit.js: -------------------------------------------------------------------------------- 1 | import _eachOfLimit from './internal/eachOfLimit'; 2 | 3 | /** 4 | * The same as `eachOf` but runs a maximum of `limit` async operations at a 5 | * time. 6 | * 7 | * @name eachOfLimit 8 | * @static 9 | * @memberOf async 10 | * @see async.eachOf 11 | * @alias forEachOfLimit 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {number} limit - The maximum number of async operations at a time. 15 | * @param {Function} iteratee - A function to apply to each 16 | * item in `coll`. The `key` is the item's key, or index in the case of an 17 | * array. The iteratee is passed a `callback(err)` which must be called once it 18 | * has completed. If no error has occurred, the callback should be run without 19 | * arguments or with an explicit `null` argument. Invoked with 20 | * (item, key, callback). 21 | * @param {Function} [callback] - A callback which is called when all 22 | * `iteratee` functions have finished, or an error occurs. Invoked with (err). 23 | */ 24 | export default function eachOfLimit(coll, limit, iteratee, callback) { 25 | _eachOfLimit(limit)(coll, iteratee, callback); 26 | } 27 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/reject.js: -------------------------------------------------------------------------------- 1 | import rejectLimit from './rejectLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * The opposite of `filter`. Removes values that pass an `async` truth test. 6 | * 7 | * @name reject 8 | * @static 9 | * @memberOf async 10 | * @see async.filter 11 | * @category Collection 12 | * @param {Array|Object} coll - A collection to iterate over. 13 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 14 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 15 | * with a boolean argument once it has completed. Invoked with (item, callback). 16 | * @param {Function} [callback] - A callback which is called after all the 17 | * `iteratee` functions have finished. Invoked with (err, results). 18 | * @example 19 | * 20 | * async.reject(['file1','file2','file3'], function(filePath, callback) { 21 | * fs.access(filePath, function(err) { 22 | * callback(null, !err) 23 | * }); 24 | * }, function(err, results) { 25 | * // results now equals an array of missing files 26 | * createFiles(results); 27 | * }); 28 | */ 29 | export default doLimit(rejectLimit, Infinity); 30 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/detectSeries.js: -------------------------------------------------------------------------------- 1 | import identity from 'lodash/identity'; 2 | 3 | import createTester from './internal/createTester'; 4 | import eachOfSeries from './eachOfSeries'; 5 | import findGetResult from './internal/findGetResult'; 6 | 7 | /** 8 | * The same as `detect` but runs only a single async operation at a time. 9 | * 10 | * @name detectSeries 11 | * @static 12 | * @memberOf async 13 | * @see async.detect 14 | * @alias findSeries 15 | * @category Collection 16 | * @param {Array|Object} coll - A collection to iterate over. 17 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 18 | * The iteratee is passed a `callback(err, truthValue)` which must be called 19 | * with a boolean argument once it has completed. Invoked with (item, callback). 20 | * @param {Function} [callback] - A callback which is called as soon as any 21 | * iteratee returns `true`, or after all the `iteratee` functions have finished. 22 | * Result will be the first item in the array that passes the truth test 23 | * (iteratee) or the value `undefined` if none passed. Invoked with 24 | * (err, result). 25 | */ 26 | export default createTester(eachOfSeries, identity, findGetResult); 27 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/setImmediate.js: -------------------------------------------------------------------------------- 1 | import setImmediate from './internal/setImmediate'; 2 | 3 | /** 4 | * Calls `callback` on a later loop around the event loop. In Node.js this just 5 | * calls `setImmediate`. In the browser it will use `setImmediate` if 6 | * available, otherwise `setTimeout(callback, 0)`, which means other higher 7 | * priority events may precede the execution of `callback`. 8 | * 9 | * This is used internally for browser-compatibility purposes. 10 | * 11 | * @name setImmediate 12 | * @static 13 | * @memberOf async 14 | * @alias nextTick 15 | * @category Util 16 | * @param {Function} callback - The function to call on a later loop around 17 | * the event loop. Invoked with (args...). 18 | * @param {...*} args... - any number of additional arguments to pass to the 19 | * callback on the next tick. 20 | * @example 21 | * 22 | * var call_order = []; 23 | * async.nextTick(function() { 24 | * call_order.push('two'); 25 | * // call_order now equals ['one','two'] 26 | * }); 27 | * call_order.push('one'); 28 | * 29 | * async.setImmediate(function (a, b, c) { 30 | * // a, b, and c equal 1, 2, and 3 31 | * }, 1, 2, 3); 32 | */ 33 | export default setImmediate; 34 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/eachLimit.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './internal/eachOfLimit'; 2 | import withoutIndex from './internal/withoutIndex'; 3 | 4 | /** 5 | * The same as `each` but runs a maximum of `limit` async operations at a time. 6 | * 7 | * @name eachLimit 8 | * @static 9 | * @memberOf async 10 | * @see async.each 11 | * @alias forEachLimit 12 | * @category Collection 13 | * @param {Array|Object} coll - A colleciton to iterate over. 14 | * @param {number} limit - The maximum number of async operations at a time. 15 | * @param {Function} iteratee - A function to apply to each item in `coll`. The 16 | * iteratee is passed a `callback(err)` which must be called once it has 17 | * completed. If no error has occurred, the `callback` should be run without 18 | * arguments or with an explicit `null` argument. The array index is not passed 19 | * to the iteratee. Invoked with (item, callback). If you need the index, use 20 | * `eachOfLimit`. 21 | * @param {Function} [callback] - A callback which is called when all 22 | * `iteratee` functions have finished, or an error occurs. Invoked with (err). 23 | */ 24 | export default function eachLimit(coll, limit, iteratee, callback) { 25 | eachOfLimit(limit)(coll, withoutIndex(iteratee), callback); 26 | } 27 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/until.js: -------------------------------------------------------------------------------- 1 | import whilst from './whilst'; 2 | 3 | /** 4 | * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when 5 | * stopped, or an error occurs. `callback` will be passed an error and any 6 | * arguments passed to the final `fn`'s callback. 7 | * 8 | * The inverse of {@link async.whilst}. 9 | * 10 | * @name until 11 | * @static 12 | * @memberOf async 13 | * @see async.whilst 14 | * @category Control Flow 15 | * @param {Function} test - synchronous truth test to perform before each 16 | * execution of `fn`. Invoked with (). 17 | * @param {Function} fn - A function which is called each time `test` fails. 18 | * The function is passed a `callback(err)`, which must be called once it has 19 | * completed with an optional `err` argument. Invoked with (callback). 20 | * @param {Function} [callback] - A callback which is called after the test 21 | * function has passed and repeated execution of `fn` has stopped. `callback` 22 | * will be passed an error and any arguments passed to the final `fn`'s 23 | * callback. Invoked with (err, [results]); 24 | */ 25 | export default function until(test, fn, callback) { 26 | whilst(function() { 27 | return !test.apply(this, arguments); 28 | }, fn, callback); 29 | } 30 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/filter.js: -------------------------------------------------------------------------------- 1 | import filterLimit from './filterLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Returns a new array of all the values in `coll` which pass an async truth 6 | * test. This operation is performed in parallel, but the results array will be 7 | * in the same order as the original. 8 | * 9 | * @name filter 10 | * @static 11 | * @memberOf async 12 | * @alias select 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 16 | * The `iteratee` is passed a `callback(err, truthValue)`, which must be called 17 | * with a boolean argument once it has completed. Invoked with (item, callback). 18 | * @param {Function} [callback] - A callback which is called after all the 19 | * `iteratee` functions have finished. Invoked with (err, results). 20 | * @example 21 | * 22 | * async.filter(['file1','file2','file3'], function(filePath, callback) { 23 | * fs.access(filePath, function(err) { 24 | * callback(null, !err) 25 | * }); 26 | * }, function(err, results) { 27 | * // results now equals an array of the existing files 28 | * }); 29 | */ 30 | export default doLimit(filterLimit, Infinity); 31 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/detectLimit.js: -------------------------------------------------------------------------------- 1 | import identity from 'lodash/identity'; 2 | 3 | import createTester from './internal/createTester'; 4 | import eachOfLimit from './eachOfLimit'; 5 | import findGetResult from './internal/findGetResult'; 6 | 7 | /** 8 | * The same as `detect` but runs a maximum of `limit` async operations at a 9 | * time. 10 | * 11 | * @name detectLimit 12 | * @static 13 | * @memberOf async 14 | * @see async.detect 15 | * @alias findLimit 16 | * @category Collection 17 | * @param {Array|Object} coll - A collection to iterate over. 18 | * @param {number} limit - The maximum number of async operations at a time. 19 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 20 | * The iteratee is passed a `callback(err, truthValue)` which must be called 21 | * with a boolean argument once it has completed. Invoked with (item, callback). 22 | * @param {Function} [callback] - A callback which is called as soon as any 23 | * iteratee returns `true`, or after all the `iteratee` functions have finished. 24 | * Result will be the first item in the array that passes the truth test 25 | * (iteratee) or the value `undefined` if none passed. Invoked with 26 | * (err, result). 27 | */ 28 | export default createTester(eachOfLimit, identity, findGetResult); 29 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/reduceRight.js: -------------------------------------------------------------------------------- 1 | import reduce from './reduce'; 2 | 3 | var slice = Array.prototype.slice; 4 | 5 | /** 6 | * Same as `reduce`, only operates on `coll` in reverse order. 7 | * 8 | * @name reduceRight 9 | * @static 10 | * @memberOf async 11 | * @see async.reduce 12 | * @alias foldr 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {*} memo - The initial state of the reduction. 16 | * @param {Function} iteratee - A function applied to each item in the 17 | * array to produce the next step in the reduction. The `iteratee` is passed a 18 | * `callback(err, reduction)` which accepts an optional error as its first 19 | * argument, and the state of the reduction as the second. If an error is 20 | * passed to the callback, the reduction is stopped and the main `callback` is 21 | * immediately called with the error. Invoked with (memo, item, callback). 22 | * @param {Function} [callback] - A callback which is called after all the 23 | * `iteratee` functions have finished. Result is the reduced value. Invoked with 24 | * (err, result). 25 | */ 26 | export default function reduceRight (coll, memo, iteratee, callback) { 27 | var reversed = slice.call(coll).reverse(); 28 | reduce(reversed, memo, iteratee, callback); 29 | } 30 | -------------------------------------------------------------------------------- /Lambda Files/async/perf/memory.js: -------------------------------------------------------------------------------- 1 | if (process.execArgv[0] !== "--expose-gc") { 2 | console.error("please run with node --expose-gc"); 3 | process.exit(1); 4 | } 5 | 6 | var async = require("../"); 7 | global.gc(); 8 | var startMem = process.memoryUsage().heapUsed; 9 | 10 | function waterfallTest(cb) { 11 | var functions = []; 12 | 13 | for(var i = 0; i < 10000; i++) { 14 | functions.push(function leaky(next) { 15 | function func1(cb) {return cb(); } 16 | 17 | function func2(callback) { 18 | if (true) { 19 | callback(); 20 | //return next(); // Should be callback here. 21 | } 22 | } 23 | 24 | function func3(cb) {return cb(); } 25 | 26 | async.waterfall([ 27 | func1, 28 | func2, 29 | func3 30 | ], next); 31 | }); 32 | } 33 | 34 | async.parallel(functions, cb); 35 | } 36 | 37 | function reportMemory() { 38 | global.gc(); 39 | var increase = process.memoryUsage().heapUsed - startMem; 40 | console.log("memory increase: " + 41 | (+(increase / 1024).toPrecision(3)) + "kB"); 42 | } 43 | 44 | waterfallTest(function () { 45 | setTimeout(reportMemory, 0); 46 | }); 47 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/sortBy.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('sortBy', function(){ 6 | it('sortBy', function(done) { 7 | async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ 8 | setTimeout(function(){callback(null, x.a);}, 0); 9 | }, function(err, result){ 10 | assert(err === null, err + " passed instead of 'null'"); 11 | expect(result).to.eql([{a:1},{a:6},{a:15}]); 12 | done(); 13 | }); 14 | }); 15 | 16 | it('sortBy inverted', function(done) { 17 | async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ 18 | setTimeout(function(){callback(null, x.a*-1);}, 0); 19 | }, function(err, result){ 20 | expect(result).to.eql([{a:15},{a:6},{a:1}]); 21 | done(); 22 | }); 23 | }); 24 | 25 | it('sortBy error', function(done) { 26 | var error = new Error('asdas'); 27 | async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ 28 | async.setImmediate(function(){ 29 | callback(error); 30 | }); 31 | }, function(err){ 32 | expect(err).to.equal(error); 33 | done(); 34 | }); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/every.js: -------------------------------------------------------------------------------- 1 | import everyLimit from './everyLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Returns `true` if every element in `coll` satisfies an async test. If any 6 | * iteratee call returns `false`, the main `callback` is immediately called. 7 | * 8 | * @name every 9 | * @static 10 | * @memberOf async 11 | * @alias all 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A truth test to apply to each item in the 15 | * collection in parallel. The iteratee is passed a `callback(err, truthValue)` 16 | * which must be called with a boolean argument once it has completed. Invoked 17 | * with (item, callback). 18 | * @param {Function} [callback] - A callback which is called after all the 19 | * `iteratee` functions have finished. Result will be either `true` or `false` 20 | * depending on the values of the async tests. Invoked with (err, result). 21 | * @example 22 | * 23 | * async.every(['file1','file2','file3'], function(filePath, callback) { 24 | * fs.access(filePath, function(err) { 25 | * callback(null, !err) 26 | * }); 27 | * }, function(err, result) { 28 | * // if result is true then every file exists 29 | * }); 30 | */ 31 | export default doLimit(everyLimit, Infinity); 32 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/doDuring.js: -------------------------------------------------------------------------------- 1 | import during from './during'; 2 | 3 | /** 4 | * The post-check version of {@link async.during}. To reflect the difference in 5 | * the order of operations, the arguments `test` and `fn` are switched. 6 | * 7 | * Also a version of {@link async.doWhilst} with asynchronous `test` function. 8 | * @name doDuring 9 | * @static 10 | * @memberOf async 11 | * @see async.during 12 | * @category Control Flow 13 | * @param {Function} fn - A function which is called each time `test` passes. 14 | * The function is passed a `callback(err)`, which must be called once it has 15 | * completed with an optional `err` argument. Invoked with (callback). 16 | * @param {Function} test - asynchronous truth test to perform before each 17 | * execution of `fn`. Invoked with (callback). 18 | * @param {Function} [callback] - A callback which is called after the test 19 | * function has failed and repeated execution of `fn` has stopped. `callback` 20 | * will be passed an error and any arguments passed to the final `fn`'s 21 | * callback. Invoked with (err, [results]); 22 | */ 23 | export default function doDuring(fn, test, callback) { 24 | var calls = 0; 25 | 26 | during(function(next) { 27 | if (calls++ < 1) return next(null, true); 28 | test.apply(this, arguments); 29 | }, fn, callback); 30 | } 31 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/reflectAll.js: -------------------------------------------------------------------------------- 1 | import reflect from './reflect'; 2 | 3 | /** 4 | * A helper function that wraps an array of functions with reflect. 5 | * 6 | * @name reflectAll 7 | * @static 8 | * @memberOf async 9 | * @see async.reflect 10 | * @category Util 11 | * @param {Array} tasks - The array of functions to wrap in `async.reflect`. 12 | * @returns {Array} Returns an array of functions, each function wrapped in 13 | * `async.reflect` 14 | * @example 15 | * 16 | * let tasks = [ 17 | * function(callback) { 18 | * setTimeout(function() { 19 | * callback(null, 'one'); 20 | * }, 200); 21 | * }, 22 | * function(callback) { 23 | * // do some more stuff but error ... 24 | * callback(new Error('bad stuff happened')); 25 | * }, 26 | * function(callback) { 27 | * setTimeout(function() { 28 | * callback(null, 'two'); 29 | * }, 100); 30 | * } 31 | * ]; 32 | * 33 | * async.parallel(async.reflectAll(tasks), 34 | * // optional callback 35 | * function(err, results) { 36 | * // values 37 | * // results[0].value = 'one' 38 | * // results[1].error = Error('bad stuff happened') 39 | * // results[2].value = 'two' 40 | * }); 41 | */ 42 | export default function reflectAll(tasks) { 43 | return tasks.map(reflect); 44 | } 45 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/applyEach.js: -------------------------------------------------------------------------------- 1 | import applyEach from './internal/applyEach'; 2 | import map from './map'; 3 | 4 | /** 5 | * Applies the provided arguments to each function in the array, calling 6 | * `callback` after all functions have completed. If you only provide the first 7 | * argument, then it will return a function which lets you pass in the 8 | * arguments as if it were a single function call. 9 | * 10 | * @name applyEach 11 | * @static 12 | * @memberOf async 13 | * @category Control Flow 14 | * @param {Array|Object} fns - A collection of asynchronous functions to all 15 | * call with the same arguments 16 | * @param {...*} [args] - any number of separate arguments to pass to the 17 | * function. 18 | * @param {Function} [callback] - the final argument should be the callback, 19 | * called when all functions have completed processing. 20 | * @returns {Function} - If only the first argument is provided, it will return 21 | * a function which lets you pass in the arguments as if it were a single 22 | * function call. 23 | * @example 24 | * 25 | * async.applyEach([enableSearch, updateSchema], 'bucket', callback); 26 | * 27 | * // partial application example: 28 | * async.each( 29 | * buckets, 30 | * async.applyEach([enableSearch, updateSchema]), 31 | * callback 32 | * ); 33 | */ 34 | export default applyEach(map); 35 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/doWhilst.js: -------------------------------------------------------------------------------- 1 | import whilst from './whilst'; 2 | 3 | /** 4 | * The post-check version of {@link async.whilst}. To reflect the difference in 5 | * the order of operations, the arguments `test` and `fn` are switched. 6 | * 7 | * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. 8 | * 9 | * @name doWhilst 10 | * @static 11 | * @memberOf async 12 | * @see async.whilst 13 | * @category Control Flow 14 | * @param {Function} fn - A function which is called each time `test` passes. 15 | * The function is passed a `callback(err)`, which must be called once it has 16 | * completed with an optional `err` argument. Invoked with (callback). 17 | * @param {Function} test - synchronous truth test to perform after each 18 | * execution of `fn`. Invoked with Invoked with the non-error callback results 19 | * of `fn`. 20 | * @param {Function} [callback] - A callback which is called after the test 21 | * function has failed and repeated execution of `fn` has stopped. `callback` 22 | * will be passed an error and any arguments passed to the final `fn`'s 23 | * callback. Invoked with (err, [results]); 24 | */ 25 | export default function doWhilst(fn, test, callback) { 26 | var calls = 0; 27 | whilst(function() { 28 | return ++calls <= 1 || test.apply(this, arguments); 29 | }, fn, callback); 30 | } 31 | -------------------------------------------------------------------------------- /Alexa Files/SampleUtterances.txt: -------------------------------------------------------------------------------- 1 | GetCloudTrailData how many events with a {AttributeKey} of {AttributeValue} occurred on {StartDate} 2 | GetCloudTrailData how many events with a {AttributeKey} of {AttributeValue} happened {StartDate} 3 | GetUserActivity what has {Username} been up to on {StartDate} 4 | GetUserActivity what is {Username} been up to on {StartDate} 5 | GetUserActivity what has {Username} been up to between {StartDate} and {EndDate} 6 | LookupByEventName how many {EventName} occurred on {StartDate} 7 | LookupByEventName how many {EventName} happened {StartDate} 8 | LookupByEventName how many {EventName} happened between {StartDate} and {EndDate} 9 | LookupByEventName what is the count of {EventName} 10 | SetRegion my region is {RegionName} 11 | SetPositiveTimeOffset my timezone is ahead by {TimeOffset} hours 12 | SetPositiveTimeOffset my timezone is plus {TimeOffset} 13 | SetNegativeTimeOffset my timezone is behind by {TimeOffset} hours 14 | SetNegativeTimeOffset my timezone is minus {TimeOffset} 15 | GetEventsByDate tell me the count of events between {StartDate} and {EndDate} 16 | GetEventsByDate tell me the count of events on {StartDate} 17 | EnableEmail enable email 18 | DisableEmail disable email 19 | GetResourceActivity have any {ResourceValue} been modified since {StartDate} 20 | ValidatePIN my pin is {UserPIN} 21 | ValidatePIN {UserPIN} 22 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/createTester.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import noop from 'lodash/noop'; 3 | 4 | export default function _createTester(eachfn, check, getResult) { 5 | return function(arr, limit, iteratee, cb) { 6 | function done(err) { 7 | if (cb) { 8 | if (err) { 9 | cb(err); 10 | } else { 11 | cb(null, getResult(false)); 12 | } 13 | } 14 | } 15 | function wrappedIteratee(x, _, callback) { 16 | if (!cb) return callback(); 17 | iteratee(x, function (err, v) { 18 | if (cb) { 19 | if (err) { 20 | cb(err); 21 | cb = iteratee = false; 22 | } else if (check(v)) { 23 | cb(null, getResult(true, x)); 24 | cb = iteratee = false; 25 | } 26 | } 27 | callback(); 28 | }); 29 | } 30 | if (arguments.length > 3) { 31 | cb = cb || noop; 32 | eachfn(arr, limit, wrappedIteratee, done); 33 | } else { 34 | cb = iteratee; 35 | cb = cb || noop; 36 | iteratee = limit; 37 | eachfn(arr, wrappedIteratee, done); 38 | } 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/compose.js: -------------------------------------------------------------------------------- 1 | import seq from './seq'; 2 | 3 | var reverse = Array.prototype.reverse; 4 | 5 | /** 6 | * Creates a function which is a composition of the passed asynchronous 7 | * functions. Each function consumes the return value of the function that 8 | * follows. Composing functions `f()`, `g()`, and `h()` would produce the result 9 | * of `f(g(h()))`, only this version uses callbacks to obtain the return values. 10 | * 11 | * Each function is executed with the `this` binding of the composed function. 12 | * 13 | * @name compose 14 | * @static 15 | * @memberOf async 16 | * @category Control Flow 17 | * @param {...Function} functions - the asynchronous functions to compose 18 | * @returns {Function} an asynchronous function that is the composed 19 | * asynchronous `functions` 20 | * @example 21 | * 22 | * function add1(n, callback) { 23 | * setTimeout(function () { 24 | * callback(null, n + 1); 25 | * }, 10); 26 | * } 27 | * 28 | * function mul3(n, callback) { 29 | * setTimeout(function () { 30 | * callback(null, n * 3); 31 | * }, 10); 32 | * } 33 | * 34 | * var add1mul3 = async.compose(mul3, add1); 35 | * add1mul3(4, function (err, result) { 36 | * // result now equals 15 37 | * }); 38 | */ 39 | export default function compose(/* functions... */) { 40 | return seq.apply(null, reverse.call(arguments)); 41 | } 42 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/some.js: -------------------------------------------------------------------------------- 1 | import someLimit from './someLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Returns `true` if at least one element in the `coll` satisfies an async test. 6 | * If any iteratee call returns `true`, the main `callback` is immediately 7 | * called. 8 | * 9 | * @name some 10 | * @static 11 | * @memberOf async 12 | * @alias any 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {Function} iteratee - A truth test to apply to each item in the array 16 | * in parallel. The iteratee is passed a `callback(err, truthValue)` which must 17 | * be called with a boolean argument once it has completed. Invoked with 18 | * (item, callback). 19 | * @param {Function} [callback] - A callback which is called as soon as any 20 | * iteratee returns `true`, or after all the iteratee functions have finished. 21 | * Result will be either `true` or `false` depending on the values of the async 22 | * tests. Invoked with (err, result). 23 | * @example 24 | * 25 | * async.some(['file1','file2','file3'], function(filePath, callback) { 26 | * fs.access(filePath, function(err) { 27 | * callback(null, !err) 28 | * }); 29 | * }, function(err, result) { 30 | * // if result is true then at least one of the files exists 31 | * }); 32 | */ 33 | export default doLimit(someLimit, Infinity); 34 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/mapValuesLimit.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './eachOfLimit'; 2 | 3 | /** 4 | * The same as `mapValues` but runs a maximum of `limit` async operations at a 5 | * time. 6 | * 7 | * @name mapValuesLimit 8 | * @static 9 | * @memberOf async 10 | * @see async.mapValues 11 | * @category Collection 12 | * @param {Object} obj - A collection to iterate over. 13 | * @param {number} limit - The maximum number of async operations at a time. 14 | * @param {Function} iteratee - A function to apply to each value in `obj`. 15 | * The iteratee is passed a `callback(err, transformed)` which must be called 16 | * once it has completed with an error (which can be `null`) and a 17 | * transformed value. Invoked with (value, key, callback). 18 | * @param {Function} [callback] - A callback which is called when all `iteratee` 19 | * functions have finished, or an error occurs. Result is an object of the 20 | * transformed values from the `obj`. Invoked with (err, result). 21 | */ 22 | export default function mapValuesLimit(obj, limit, iteratee, callback) { 23 | var newObj = {}; 24 | eachOfLimit(obj, limit, function(val, key, next) { 25 | iteratee(val, key, function (err, result) { 26 | if (err) return next(err); 27 | newObj[key] = result; 28 | next(); 29 | }); 30 | }, function (err) { 31 | callback(err, newObj); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/retryable.js: -------------------------------------------------------------------------------- 1 | import retry from './retry'; 2 | import initialParams from './internal/initialParams'; 3 | 4 | /** 5 | * A close relative of `retry`. This method wraps a task and makes it 6 | * retryable, rather than immediately calling it with retries. 7 | * 8 | * @name retryable 9 | * @static 10 | * @memberOf async 11 | * @see async.retry 12 | * @category Control Flow 13 | * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional 14 | * options, exactly the same as from `retry` 15 | * @param {Function} task - the asynchronous function to wrap 16 | * @returns {Functions} The wrapped function, which when invoked, will retry on 17 | * an error, based on the parameters specified in `opts`. 18 | * @example 19 | * 20 | * async.auto({ 21 | * dep1: async.retryable(3, getFromFlakyService), 22 | * process: ["dep1", async.retryable(3, function (results, cb) { 23 | * maybeProcessData(results.dep1, cb); 24 | * })] 25 | * }, callback); 26 | */ 27 | export default function (opts, task) { 28 | if (!task) { 29 | task = opts; 30 | opts = null; 31 | } 32 | return initialParams(function (args, callback) { 33 | function taskFn(cb) { 34 | task.apply(null, args.concat([cb])); 35 | } 36 | 37 | if (opts) retry(opts, taskFn, callback); 38 | else retry(taskFn, callback); 39 | 40 | }); 41 | } 42 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/concat.js: -------------------------------------------------------------------------------- 1 | import concat from './internal/concat'; 2 | import doParallel from './internal/doParallel'; 3 | 4 | /** 5 | * Applies `iteratee` to each item in `coll`, concatenating the results. Returns 6 | * the concatenated list. The `iteratee`s are called in parallel, and the 7 | * results are concatenated as they return. There is no guarantee that the 8 | * results array will be returned in the original order of `coll` passed to the 9 | * `iteratee` function. 10 | * 11 | * @name concat 12 | * @static 13 | * @memberOf async 14 | * @category Collection 15 | * @param {Array|Object} coll - A collection to iterate over. 16 | * @param {Function} iteratee - A function to apply to each item in `coll`. 17 | * The iteratee is passed a `callback(err, results)` which must be called once 18 | * it has completed with an error (which can be `null`) and an array of results. 19 | * Invoked with (item, callback). 20 | * @param {Function} [callback(err)] - A callback which is called after all the 21 | * `iteratee` functions have finished, or an error occurs. Results is an array 22 | * containing the concatenated results of the `iteratee` function. Invoked with 23 | * (err, results). 24 | * @example 25 | * 26 | * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) { 27 | * // files is now a list of filenames that exist in the 3 directories 28 | * }); 29 | */ 30 | export default doParallel(concat); 31 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/nextTick.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { hasNextTick, hasSetImmediate, fallback, wrap } from './internal/setImmediate'; 4 | 5 | /** 6 | * Calls `callback` on a later loop around the event loop. In Node.js this just 7 | * calls `setImmediate`. In the browser it will use `setImmediate` if 8 | * available, otherwise `setTimeout(callback, 0)`, which means other higher 9 | * priority events may precede the execution of `callback`. 10 | * 11 | * This is used internally for browser-compatibility purposes. 12 | * 13 | * @name nextTick 14 | * @static 15 | * @memberOf async 16 | * @alias setImmediate 17 | * @category Util 18 | * @param {Function} callback - The function to call on a later loop around 19 | * the event loop. Invoked with (args...). 20 | * @param {...*} args... - any number of additional arguments to pass to the 21 | * callback on the next tick. 22 | * @example 23 | * 24 | * var call_order = []; 25 | * async.nextTick(function() { 26 | * call_order.push('two'); 27 | * // call_order now equals ['one','two'] 28 | * }); 29 | * call_order.push('one'); 30 | * 31 | * async.setImmediate(function (a, b, c) { 32 | * // a, b, and c equal 1, 2, and 3 33 | * }, 1, 2, 3); 34 | */ 35 | var _defer; 36 | 37 | if (hasNextTick) { 38 | _defer = process.nextTick; 39 | } else if (hasSetImmediate) { 40 | _defer = setImmediate; 41 | } else { 42 | _defer = fallback; 43 | } 44 | 45 | export default wrap(_defer); 46 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/forever.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | 3 | import onlyOnce from './internal/onlyOnce'; 4 | import ensureAsync from './ensureAsync'; 5 | 6 | /** 7 | * Calls the asynchronous function `fn` with a callback parameter that allows it 8 | * to call itself again, in series, indefinitely. 9 | 10 | * If an error is passed to the 11 | * callback then `errback` is called with the error, and execution stops, 12 | * otherwise it will never be called. 13 | * 14 | * @name forever 15 | * @static 16 | * @memberOf async 17 | * @category Control Flow 18 | * @param {Function} fn - a function to call repeatedly. Invoked with (next). 19 | * @param {Function} [errback] - when `fn` passes an error to it's callback, 20 | * this function will be called, and execution stops. Invoked with (err). 21 | * @example 22 | * 23 | * async.forever( 24 | * function(next) { 25 | * // next is suitable for passing to things that need a callback(err [, whatever]); 26 | * // it will result in this function being called again. 27 | * }, 28 | * function(err) { 29 | * // if next is called with a value in its first parameter, it will appear 30 | * // in here as 'err', and execution will stop. 31 | * } 32 | * ); 33 | */ 34 | export default function forever(fn, errback) { 35 | var done = onlyOnce(errback || noop); 36 | var task = ensureAsync(fn); 37 | 38 | function next(err) { 39 | if (err) return done(err); 40 | task(next); 41 | } 42 | next(); 43 | } 44 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/iterator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creates an iterator function which calls the next function in the `tasks` 3 | * array, returning a continuation to call the next one after that. It's also 4 | * possible to “peek” at the next iterator with `iterator.next()`. 5 | * 6 | * This function is used internally by the `async` module, but can be useful 7 | * when you want to manually control the flow of functions in series. 8 | * 9 | * @name iterator 10 | * @static 11 | * @memberOf async 12 | * @category Control Flow 13 | * @param {Array} tasks - An array of functions to run. 14 | * @returns The next function to run in the series. 15 | * @example 16 | * 17 | * var iterator = async.iterator([ 18 | * function() { sys.p('one'); }, 19 | * function() { sys.p('two'); }, 20 | * function() { sys.p('three'); } 21 | * ]); 22 | * 23 | * node> var iterator2 = iterator(); 24 | * 'one' 25 | * node> var iterator3 = iterator2(); 26 | * 'two' 27 | * node> iterator3(); 28 | * 'three' 29 | * node> var nextfn = iterator2.next(); 30 | * node> nextfn(); 31 | * 'three' 32 | */ 33 | export default function(tasks) { 34 | function makeCallback(index) { 35 | function fn() { 36 | if (tasks.length) { 37 | tasks[index].apply(null, arguments); 38 | } 39 | return fn.next(); 40 | } 41 | fn.next = function() { 42 | return (index < tasks.length - 1) ? makeCallback(index + 1) : null; 43 | }; 44 | return fn; 45 | } 46 | return makeCallback(0); 47 | } 48 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/constant.js: -------------------------------------------------------------------------------- 1 | import rest from 'lodash/rest'; 2 | import initialParams from './internal/initialParams'; 3 | 4 | /** 5 | * Returns a function that when called, calls-back with the values provided. 6 | * Useful as the first function in a `waterfall`, or for plugging values in to 7 | * `auto`. 8 | * 9 | * @name constant 10 | * @static 11 | * @memberOf async 12 | * @category Util 13 | * @param {...*} arguments... - Any number of arguments to automatically invoke 14 | * callback with. 15 | * @returns {Function} Returns a function that when invoked, automatically 16 | * invokes the callback with the previous given arguments. 17 | * @example 18 | * 19 | * async.waterfall([ 20 | * async.constant(42), 21 | * function (value, next) { 22 | * // value === 42 23 | * }, 24 | * //... 25 | * ], callback); 26 | * 27 | * async.waterfall([ 28 | * async.constant(filename, "utf8"), 29 | * fs.readFile, 30 | * function (fileData, next) { 31 | * //... 32 | * } 33 | * //... 34 | * ], callback); 35 | * 36 | * async.auto({ 37 | * hostname: async.constant("https://server.net/"), 38 | * port: findFreePort, 39 | * launchServer: ["hostname", "port", function (options, cb) { 40 | * startServer(options, cb); 41 | * }], 42 | * //... 43 | * }, callback); 44 | */ 45 | export default rest(function(values) { 46 | var args = [null].concat(values); 47 | return initialParams(function (ignoredArgs, callback) { 48 | return callback.apply(this, args); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/internal/eachOfLimit.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import once from './once'; 3 | 4 | import iterator from './iterator'; 5 | import onlyOnce from './onlyOnce'; 6 | 7 | export default function _eachOfLimit(limit) { 8 | return function (obj, iteratee, callback) { 9 | callback = once(callback || noop); 10 | obj = obj || []; 11 | var nextElem = iterator(obj); 12 | if (limit <= 0) { 13 | return callback(null); 14 | } 15 | var done = false; 16 | var running = 0; 17 | var errored = false; 18 | 19 | (function replenish () { 20 | if (done && running <= 0) { 21 | return callback(null); 22 | } 23 | 24 | while (running < limit && !errored) { 25 | var elem = nextElem(); 26 | if (elem === null) { 27 | done = true; 28 | if (running <= 0) { 29 | callback(null); 30 | } 31 | return; 32 | } 33 | running += 1; 34 | /* eslint {no-loop-func: 0} */ 35 | iteratee(elem.value, elem.key, onlyOnce(function (err) { 36 | running -= 1; 37 | if (err) { 38 | callback(err); 39 | errored = true; 40 | } 41 | else { 42 | replenish(); 43 | } 44 | })); 45 | } 46 | })(); 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/apply.js: -------------------------------------------------------------------------------- 1 | import rest from 'lodash/rest'; 2 | 3 | /** 4 | * Creates a continuation function with some arguments already applied. 5 | * 6 | * Useful as a shorthand when combined with other control flow functions. Any 7 | * arguments passed to the returned function are added to the arguments 8 | * originally passed to apply. 9 | * 10 | * @name apply 11 | * @static 12 | * @memberOf async 13 | * @category Util 14 | * @param {Function} function - The function you want to eventually apply all 15 | * arguments to. Invokes with (arguments...). 16 | * @param {...*} arguments... - Any number of arguments to automatically apply 17 | * when the continuation is called. 18 | * @example 19 | * 20 | * // using apply 21 | * async.parallel([ 22 | * async.apply(fs.writeFile, 'testfile1', 'test1'), 23 | * async.apply(fs.writeFile, 'testfile2', 'test2') 24 | * ]); 25 | * 26 | * 27 | * // the same process without using apply 28 | * async.parallel([ 29 | * function(callback) { 30 | * fs.writeFile('testfile1', 'test1', callback); 31 | * }, 32 | * function(callback) { 33 | * fs.writeFile('testfile2', 'test2', callback); 34 | * } 35 | * ]); 36 | * 37 | * // It's possible to pass any number of additional arguments when calling the 38 | * // continuation: 39 | * 40 | * node> var fn = async.apply(sys.puts, 'one'); 41 | * node> fn('two', 'three'); 42 | * one 43 | * two 44 | * three 45 | */ 46 | export default rest(function(fn, args) { 47 | return rest(function(callArgs) { 48 | return fn.apply(null, args.concat(callArgs)); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/eachOf.js: -------------------------------------------------------------------------------- 1 | import eachOfLimit from './eachOfLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Like `each`, except that it passes the key (or index) as the second argument 6 | * to the iteratee. 7 | * 8 | * @name eachOf 9 | * @static 10 | * @memberOf async 11 | * @alias forEachOf 12 | * @category Collection 13 | * @param {Array|Object} coll - A collection to iterate over. 14 | * @param {Function} iteratee - A function to apply to each 15 | * item in `coll`. The `key` is the item's key, or index in the case of an 16 | * array. The iteratee is passed a `callback(err)` which must be called once it 17 | * has completed. If no error has occurred, the callback should be run without 18 | * arguments or with an explicit `null` argument. Invoked with 19 | * (item, key, callback). 20 | * @param {Function} [callback] - A callback which is called when all 21 | * `iteratee` functions have finished, or an error occurs. Invoked with (err). 22 | * @example 23 | * 24 | * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; 25 | * var configs = {}; 26 | * 27 | * async.forEachOf(obj, function (value, key, callback) { 28 | * fs.readFile(__dirname + value, "utf8", function (err, data) { 29 | * if (err) return callback(err); 30 | * try { 31 | * configs[key] = JSON.parse(data); 32 | * } catch (e) { 33 | * return callback(e); 34 | * } 35 | * callback(); 36 | * }); 37 | * }, function (err) { 38 | * if (err) console.error(err.message); 39 | * // configs is now a map of JSON data 40 | * doSomethingWith(configs); 41 | * }); 42 | */ 43 | export default doLimit(eachOfLimit, Infinity); 44 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/forever.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var isBrowser = require('./support/is_browser'); 4 | 5 | describe('forever', function(){ 6 | context('function is asynchronous', function(){ 7 | it('executes the function over and over until it yields an error', function(done){ 8 | var counter = 0; 9 | function addOne(callback) { 10 | counter++; 11 | if (counter === 50) { 12 | return callback('too big!'); 13 | } 14 | async.setImmediate(function () { 15 | callback(); 16 | }); 17 | } 18 | async.forever(addOne, function (err) { 19 | expect(err).to.eql('too big!'); 20 | expect(counter).to.eql(50); 21 | done(); 22 | }); 23 | }); 24 | }); 25 | 26 | context('function is synchronous', function(){ 27 | it('does not cause a stack overflow', function(done){ 28 | if (isBrowser()) return done(); // this will take forever in a browser 29 | var counter = 0; 30 | function addOne(callback) { 31 | counter++; 32 | if (counter === 50000) { // needs to be huge to potentially overflow stack in node 33 | return callback('too big!'); 34 | } 35 | callback(); 36 | } 37 | async.forever(addOne, function (err) { 38 | expect(err).to.eql('too big!'); 39 | expect(counter).to.eql(50000); 40 | done(); 41 | }); 42 | }); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/whilst.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import rest from 'lodash/rest'; 3 | 4 | /** 5 | * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when 6 | * stopped, or an error occurs. 7 | * 8 | * @name whilst 9 | * @static 10 | * @memberOf async 11 | * @category Control Flow 12 | * @param {Function} test - synchronous truth test to perform before each 13 | * execution of `fn`. Invoked with (). 14 | * @param {Function} iteratee - A function which is called each time `test` passes. 15 | * The function is passed a `callback(err)`, which must be called once it has 16 | * completed with an optional `err` argument. Invoked with (callback). 17 | * @param {Function} [callback] - A callback which is called after the test 18 | * function has failed and repeated execution of `fn` has stopped. `callback` 19 | * will be passed an error and any arguments passed to the final `fn`'s 20 | * callback. Invoked with (err, [results]); 21 | * @returns undefined 22 | * @example 23 | * 24 | * var count = 0; 25 | * async.whilst( 26 | * function() { return count < 5; }, 27 | * function(callback) { 28 | * count++; 29 | * setTimeout(function() { 30 | * callback(null, count); 31 | * }, 1000); 32 | * }, 33 | * function (err, n) { 34 | * // 5 seconds have passed, n = 5 35 | * } 36 | * ); 37 | */ 38 | export default function whilst(test, iteratee, callback) { 39 | callback = callback || noop; 40 | if (!test()) return callback(null); 41 | var next = rest(function(err, args) { 42 | if (err) return callback(err); 43 | if (test.apply(this, args)) return iteratee(next); 44 | callback.apply(null, [null].concat(args)); 45 | }); 46 | iteratee(next); 47 | } 48 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/transform.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('transform', function() { 5 | 6 | it('transform implictly determines memo if not provided', function(done) { 7 | async.transform([1,2,3], function(memo, x, v, callback){ 8 | memo.push(x + 1); 9 | callback(); 10 | }, function(err, result){ 11 | expect(result).to.eql([2, 3, 4]); 12 | done(); 13 | }); 14 | }); 15 | 16 | it('transform async with object memo', function(done) { 17 | async.transform([1,3,2], {}, function(memo, v, k, callback){ 18 | setTimeout(function() { 19 | memo[k] = v; 20 | callback(); 21 | }); 22 | }, function(err, result) { 23 | expect(err).to.equal(null); 24 | expect(result).to.eql({ 25 | 0: 1, 26 | 1: 3, 27 | 2: 2 28 | }); 29 | done(); 30 | }); 31 | }); 32 | 33 | it('transform iterating object', function(done) { 34 | async.transform({a: 1, b: 3, c: 2}, function(memo, v, k, callback){ 35 | setTimeout(function() { 36 | memo[k] = v + 1; 37 | callback(); 38 | }); 39 | }, function(err, result) { 40 | expect(err).to.equal(null); 41 | expect(result).to.eql({a: 2, b: 4, c: 3}); 42 | done(); 43 | }); 44 | }); 45 | 46 | it('transform error', function(done) { 47 | async.transform([1,2,3], function(a, v, k, callback){ 48 | callback('error'); 49 | }, function(err){ 50 | expect(err).to.equal('error'); 51 | done(); 52 | }); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/detect.js: -------------------------------------------------------------------------------- 1 | import identity from 'lodash/identity'; 2 | 3 | import createTester from './internal/createTester'; 4 | import eachOf from './eachOf'; 5 | import findGetResult from './internal/findGetResult'; 6 | 7 | /** 8 | * Returns the first value in `coll` that passes an async truth test. The 9 | * `iteratee` is applied in parallel, meaning the first iteratee to return 10 | * `true` will fire the detect `callback` with that result. That means the 11 | * result might not be the first item in the original `coll` (in terms of order) 12 | * that passes the test. 13 | 14 | * If order within the original `coll` is important, then look at 15 | * `detectSeries`. 16 | * 17 | * @name detect 18 | * @static 19 | * @memberOf async 20 | * @alias find 21 | * @category Collection 22 | * @param {Array|Object} coll - A collection to iterate over. 23 | * @param {Function} iteratee - A truth test to apply to each item in `coll`. 24 | * The iteratee is passed a `callback(err, truthValue)` which must be called 25 | * with a boolean argument once it has completed. Invoked with (item, callback). 26 | * @param {Function} [callback] - A callback which is called as soon as any 27 | * iteratee returns `true`, or after all the `iteratee` functions have finished. 28 | * Result will be the first item in the array that passes the truth test 29 | * (iteratee) or the value `undefined` if none passed. Invoked with 30 | * (err, result). 31 | * @example 32 | * 33 | * async.detect(['file1','file2','file3'], function(filePath, callback) { 34 | * fs.access(filePath, function(err) { 35 | * callback(null, !err) 36 | * }); 37 | * }, function(err, result) { 38 | * // result now equals the first file in the list that exists 39 | * }); 40 | */ 41 | export default createTester(eachOf, identity, findGetResult); 42 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/race.js: -------------------------------------------------------------------------------- 1 | import isArray from 'lodash/isArray'; 2 | import each from 'lodash/each'; 3 | import noop from 'lodash/noop'; 4 | import once from './internal/once'; 5 | 6 | /** 7 | * Runs the `tasks` array of functions in parallel, without waiting until the 8 | * previous function has completed. Once any the `tasks` completed or pass an 9 | * error to its callback, the main `callback` is immediately called. It's 10 | * equivalent to `Promise.race()`. 11 | * 12 | * @name race 13 | * @static 14 | * @memberOf async 15 | * @category Control Flow 16 | * @param {Array} tasks - An array containing functions to run. Each function 17 | * is passed a `callback(err, result)` which it must call on completion with an 18 | * error `err` (which can be `null`) and an optional `result` value. 19 | * @param {Function} callback - A callback to run once any of the functions have 20 | * completed. This function gets an error or result from the first function that 21 | * completed. Invoked with (err, result). 22 | * @returns undefined 23 | * @example 24 | * 25 | * async.race([ 26 | * function(callback) { 27 | * setTimeout(function() { 28 | * callback(null, 'one'); 29 | * }, 200); 30 | * }, 31 | * function(callback) { 32 | * setTimeout(function() { 33 | * callback(null, 'two'); 34 | * }, 100); 35 | * } 36 | * ], 37 | * // main callback 38 | * function(err, result) { 39 | * // the result will be equal to 'two' as it finishes earlier 40 | * }); 41 | */ 42 | export default function race(tasks, callback) { 43 | callback = once(callback || noop); 44 | if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); 45 | if (!tasks.length) return callback(); 46 | each(tasks, function (task) { 47 | task(callback); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/map.js: -------------------------------------------------------------------------------- 1 | import mapLimit from './mapLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Produces a new collection of values by mapping each value in `coll` through 6 | * the `iteratee` function. The `iteratee` is called with an item from `coll` 7 | * and a callback for when it has finished processing. Each of these callback 8 | * takes 2 arguments: an `error`, and the transformed item from `coll`. If 9 | * `iteratee` passes an error to its callback, the main `callback` (for the 10 | * `map` function) is immediately called with the error. 11 | * 12 | * Note, that since this function applies the `iteratee` to each item in 13 | * parallel, there is no guarantee that the `iteratee` functions will complete 14 | * in order. However, the results array will be in the same order as the 15 | * original `coll`. 16 | * 17 | * If `map` is passed an Object, the results will be an Array. The results 18 | * will roughly be in the order of the original Objects' keys (but this can 19 | * vary across JavaScript engines) 20 | * 21 | * @name map 22 | * @static 23 | * @memberOf async 24 | * @category Collection 25 | * @param {Array|Object} coll - A collection to iterate over. 26 | * @param {Function} iteratee - A function to apply to each item in `coll`. 27 | * The iteratee is passed a `callback(err, transformed)` which must be called 28 | * once it has completed with an error (which can be `null`) and a 29 | * transformed item. Invoked with (item, callback). 30 | * @param {Function} [callback] - A callback which is called when all `iteratee` 31 | * functions have finished, or an error occurs. Results is an Array of the 32 | * transformed items from the `coll`. Invoked with (err, results). 33 | * @example 34 | * 35 | * async.map(['file1','file2','file3'], fs.stat, function(err, results) { 36 | * // results is now an array of stats for each file 37 | * }); 38 | */ 39 | export default doLimit(mapLimit, Infinity); 40 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/concat.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('concat', function() { 6 | it('concat', function(done) { 7 | var call_order = []; 8 | var iteratee = function (x, cb) { 9 | setTimeout(function(){ 10 | call_order.push(x); 11 | var r = []; 12 | while (x > 0) { 13 | r.push(x); 14 | x--; 15 | } 16 | cb(null, r); 17 | }, x*25); 18 | }; 19 | async.concat([1,3,2], iteratee, function(err, results){ 20 | expect(results).to.eql([1,2,1,3,2,1]); 21 | expect(call_order).to.eql([1,2,3]); 22 | assert(err === null, err + " passed instead of 'null'"); 23 | done(); 24 | }); 25 | }); 26 | 27 | it('concat error', function(done) { 28 | var iteratee = function (x, cb) { 29 | cb(new Error('test error')); 30 | }; 31 | async.concat([1,2,3], iteratee, function(err){ 32 | assert(err); 33 | done(); 34 | }); 35 | }); 36 | 37 | it('concatSeries', function(done) { 38 | var call_order = []; 39 | var iteratee = function (x, cb) { 40 | setTimeout(function(){ 41 | call_order.push(x); 42 | var r = []; 43 | while (x > 0) { 44 | r.push(x); 45 | x--; 46 | } 47 | cb(null, r); 48 | }, x*25); 49 | }; 50 | async.concatSeries([1,3,2], iteratee, function(err, results){ 51 | expect(results).to.eql([1,3,2,1,2,1]); 52 | expect(call_order).to.eql([1,3,2]); 53 | assert(err === null, err + " passed instead of 'null'"); 54 | done(); 55 | }); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /Lambda Files/AWSRegions.json: -------------------------------------------------------------------------------- 1 | { 2 | "us-east-1": { 3 | "east": "us-east-1", 4 | "north virginia": "us-east-1", 5 | "virginia": "us-east-1", 6 | "us east 1": "us-east-1" 7 | }, 8 | "us-west-1": { 9 | "us west 1": "us-west-1", 10 | "california": "us-west-1" 11 | }, 12 | "us-west-2": { 13 | "oregon": "us-west-2", 14 | "us west 2": "us-west-2" 15 | }, 16 | "ap-south-1": { 17 | "mumbai": "ap-south-1", 18 | "bombay": "ap-south-1", 19 | "india": "ap-south-1", 20 | "south asia": "ap-south-1" 21 | }, 22 | "ap-northeast-2": { 23 | "seoul": "ap-northeast-2", 24 | "korea": "ap-northeast-2", 25 | "south korea": "ap-northeast-2", 26 | "ap northeast 2": "ap-northeast-2" 27 | }, 28 | "ap-southeast-1": { 29 | "singapore": "ap-southeast-1", 30 | "ap southeast 1": "ap-southeast-1" 31 | }, 32 | "ap-southeast-2": { 33 | "sydney": "ap-southeast-2", 34 | "australia": "ap-southeast-2", 35 | "ap southeast 2": "ap-southeast-2" 36 | }, 37 | "ap-northeast-1": { 38 | "Tokyo": "ap-northeast-1", 39 | "Japan": "ap-northeast-1", 40 | "ap northeast 1": "ap-northeast-1" 41 | }, 42 | "eu-central-1": { 43 | "frankfurt": "eu-central-1", 44 | "germany": "eu-central-1", 45 | "eastern europe": "eu-central-1", 46 | "central europe": "eu-central-1", 47 | "eu central 1": "eu-central-1" 48 | }, 49 | "eu-west-1": { 50 | "ireland": "eu-west-1", 51 | "western europe": "eu-west-1", 52 | "eu west 1": "eu-west-1" 53 | }, 54 | "sa-east-1": { 55 | "sao paulo": "sa-east-1", 56 | "brazil": "sa-east-1", 57 | "south america": "sa-east-1", 58 | "sa east 1": "sa-east-1" 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Lambda Files/async/lib/timeout.js: -------------------------------------------------------------------------------- 1 | import initialParams from './internal/initialParams'; 2 | 3 | /** 4 | * Sets a time limit on an asynchronous function. If the function does not call 5 | * its callback within the specified milliseconds, it will be called with a 6 | * timeout error. The code property for the error object will be `'ETIMEDOUT'`. 7 | * 8 | * @name timeout 9 | * @static 10 | * @memberOf async 11 | * @category Util 12 | * @param {Function} asyncFn - The asynchronous function you want to set the 13 | * time limit. 14 | * @param {number} milliseconds - The specified time limit. 15 | * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) 16 | * to timeout Error for more information.. 17 | * @returns {Function} Returns a wrapped function that can be used with any of 18 | * the control flow functions. 19 | * @example 20 | * 21 | * async.timeout(function(callback) { 22 | * doAsyncTask(callback); 23 | * }, 1000); 24 | */ 25 | export default function timeout(asyncFn, milliseconds, info) { 26 | var originalCallback, timer; 27 | var timedOut = false; 28 | 29 | function injectedCallback() { 30 | if (!timedOut) { 31 | originalCallback.apply(null, arguments); 32 | clearTimeout(timer); 33 | } 34 | } 35 | 36 | function timeoutCallback() { 37 | var name = asyncFn.name || 'anonymous'; 38 | var error = new Error('Callback function "' + name + '" timed out.'); 39 | error.code = 'ETIMEDOUT'; 40 | if (info) { 41 | error.info = info; 42 | } 43 | timedOut = true; 44 | originalCallback(error); 45 | } 46 | 47 | return initialParams(function (args, origCallback) { 48 | originalCallback = origCallback; 49 | // setup timer and call original function 50 | timer = setTimeout(timeoutCallback, milliseconds); 51 | asyncFn.apply(null, args.concat(injectedCallback)); 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/mapValues.js: -------------------------------------------------------------------------------- 1 | import mapValuesLimit from './mapValuesLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | 5 | /** 6 | * A relative of `map`, designed for use with objects. 7 | * 8 | * Produces a new Object by mapping each value of `obj` through the `iteratee` 9 | * function. The `iteratee` is called each `value` and `key` from `obj` and a 10 | * callback for when it has finished processing. Each of these callbacks takes 11 | * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` 12 | * passes an error to its callback, the main `callback` (for the `mapValues` 13 | * function) is immediately called with the error. 14 | * 15 | * Note, the order of the keys in the result is not guaranteed. The keys will 16 | * be roughly in the order they complete, (but this is very engine-specific) 17 | * 18 | * @name mapValues 19 | * @static 20 | * @memberOf async 21 | * @category Collection 22 | * @param {Object} obj - A collection to iterate over. 23 | * @param {Function} iteratee - A function to apply to each value and key in 24 | * `coll`. The iteratee is passed a `callback(err, transformed)` which must be 25 | * called once it has completed with an error (which can be `null`) and a 26 | * transformed value. Invoked with (value, key, callback). 27 | * @param {Function} [callback] - A callback which is called when all `iteratee` 28 | * functions have finished, or an error occurs. Results is an array of the 29 | * transformed items from the `obj`. Invoked with (err, result). 30 | * @example 31 | * 32 | * async.mapValues({ 33 | * f1: 'file1', 34 | * f2: 'file2', 35 | * f3: 'file3' 36 | * }, fs.stat, function(err, result) { 37 | * // results is now a map of stats for each file, e.g. 38 | * // { 39 | * // f1: [stats for file1], 40 | * // f2: [stats for file2], 41 | * // f3: [stats for file3] 42 | * // } 43 | * }); 44 | */ 45 | 46 | export default doLimit(mapValuesLimit, Infinity); 47 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/during.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import rest from 'lodash/rest'; 3 | 4 | /** 5 | * Like {@link async.whilst}, except the `test` is an asynchronous function that 6 | * is passed a callback in the form of `function (err, truth)`. If error is 7 | * passed to `test` or `fn`, the main callback is immediately called with the 8 | * value of the error. 9 | * 10 | * @name during 11 | * @static 12 | * @memberOf async 13 | * @see async.whilst 14 | * @category Control Flow 15 | * @param {Function} test - asynchronous truth test to perform before each 16 | * execution of `fn`. Invoked with (callback). 17 | * @param {Function} fn - A function which is called each time `test` passes. 18 | * The function is passed a `callback(err)`, which must be called once it has 19 | * completed with an optional `err` argument. Invoked with (callback). 20 | * @param {Function} [callback] - A callback which is called after the test 21 | * function has failed and repeated execution of `fn` has stopped. `callback` 22 | * will be passed an error and any arguments passed to the final `fn`'s 23 | * callback. Invoked with (err, [results]); 24 | * @example 25 | * 26 | * var count = 0; 27 | * 28 | * async.during( 29 | * function (callback) { 30 | * return callback(null, count < 5); 31 | * }, 32 | * function (callback) { 33 | * count++; 34 | * setTimeout(callback, 1000); 35 | * }, 36 | * function (err) { 37 | * // 5 seconds have passed 38 | * } 39 | * ); 40 | */ 41 | export default function during(test, fn, callback) { 42 | callback = callback || noop; 43 | 44 | var next = rest(function(err, args) { 45 | if (err) { 46 | callback(err); 47 | } else { 48 | args.push(check); 49 | test.apply(this, args); 50 | } 51 | }); 52 | 53 | var check = function(err, truth) { 54 | if (err) return callback(err); 55 | if (!truth) return callback(null); 56 | fn(next); 57 | }; 58 | 59 | test(check); 60 | } 61 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/ensureAsync.js: -------------------------------------------------------------------------------- 1 | import setImmediate from './internal/setImmediate'; 2 | import initialParams from './internal/initialParams'; 3 | 4 | /** 5 | * Wrap an async function and ensure it calls its callback on a later tick of 6 | * the event loop. If the function already calls its callback on a next tick, 7 | * no extra deferral is added. This is useful for preventing stack overflows 8 | * (`RangeError: Maximum call stack size exceeded`) and generally keeping 9 | * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) 10 | * contained. 11 | * 12 | * @name ensureAsync 13 | * @static 14 | * @memberOf async 15 | * @category Util 16 | * @param {Function} fn - an async function, one that expects a node-style 17 | * callback as its last argument. 18 | * @returns {Function} Returns a wrapped function with the exact same call 19 | * signature as the function passed in. 20 | * @example 21 | * 22 | * function sometimesAsync(arg, callback) { 23 | * if (cache[arg]) { 24 | * return callback(null, cache[arg]); // this would be synchronous!! 25 | * } else { 26 | * doSomeIO(arg, callback); // this IO would be asynchronous 27 | * } 28 | * } 29 | * 30 | * // this has a risk of stack overflows if many results are cached in a row 31 | * async.mapSeries(args, sometimesAsync, done); 32 | * 33 | * // this will defer sometimesAsync's callback if necessary, 34 | * // preventing stack overflows 35 | * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); 36 | */ 37 | export default function ensureAsync(fn) { 38 | return initialParams(function (args, callback) { 39 | var sync = true; 40 | args.push(function () { 41 | var innerArgs = arguments; 42 | if (sync) { 43 | setImmediate(function () { 44 | callback.apply(null, innerArgs); 45 | }); 46 | } else { 47 | callback.apply(null, innerArgs); 48 | } 49 | }); 50 | fn.apply(this, args); 51 | sync = false; 52 | }); 53 | } 54 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/reflect.js: -------------------------------------------------------------------------------- 1 | import initialParams from './internal/initialParams'; 2 | import rest from 'lodash/rest'; 3 | 4 | /** 5 | * Wraps the function in another function that always returns data even when it 6 | * errors. 7 | * 8 | * The object returned has either the property `error` or `value`. 9 | * 10 | * @name reflect 11 | * @static 12 | * @memberOf async 13 | * @category Util 14 | * @param {Function} fn - The function you want to wrap 15 | * @returns {Function} - A function that always passes null to it's callback as 16 | * the error. The second argument to the callback will be an `object` with 17 | * either an `error` or a `value` property. 18 | * @example 19 | * 20 | * async.parallel([ 21 | * async.reflect(function(callback) { 22 | * // do some stuff ... 23 | * callback(null, 'one'); 24 | * }), 25 | * async.reflect(function(callback) { 26 | * // do some more stuff but error ... 27 | * callback('bad stuff happened'); 28 | * }), 29 | * async.reflect(function(callback) { 30 | * // do some more stuff ... 31 | * callback(null, 'two'); 32 | * }) 33 | * ], 34 | * // optional callback 35 | * function(err, results) { 36 | * // values 37 | * // results[0].value = 'one' 38 | * // results[1].error = 'bad stuff happened' 39 | * // results[2].value = 'two' 40 | * }); 41 | */ 42 | export default function reflect(fn) { 43 | return initialParams(function reflectOn(args, reflectCallback) { 44 | args.push(rest(function callback(err, cbArgs) { 45 | if (err) { 46 | reflectCallback(null, { 47 | error: err 48 | }); 49 | } else { 50 | var value = null; 51 | if (cbArgs.length === 1) { 52 | value = cbArgs[0]; 53 | } else if (cbArgs.length > 1) { 54 | value = cbArgs; 55 | } 56 | reflectCallback(null, { 57 | value: value 58 | }); 59 | } 60 | })); 61 | 62 | return fn.apply(this, args); 63 | }); 64 | } 65 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/iterator.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('iterator', function() { 5 | 6 | it('iterator', function(done) { 7 | var call_order = []; 8 | var iterator = async.iterator([ 9 | function(){call_order.push(1);}, 10 | function(arg1){ 11 | expect(arg1).to.equal('arg1'); 12 | call_order.push(2); 13 | }, 14 | function(arg1, arg2){ 15 | expect(arg1).to.equal('arg1'); 16 | expect(arg2).to.equal('arg2'); 17 | call_order.push(3); 18 | } 19 | ]); 20 | iterator(); 21 | expect(call_order).to.eql([1]); 22 | var iterator2 = iterator(); 23 | expect(call_order).to.eql([1,1]); 24 | var iterator3 = iterator2('arg1'); 25 | expect(call_order).to.eql([1,1,2]); 26 | var iterator4 = iterator3('arg1', 'arg2'); 27 | expect(call_order).to.eql([1,1,2,3]); 28 | expect(iterator4).to.equal(null); 29 | done(); 30 | }); 31 | 32 | it('iterator empty array', function(done) { 33 | var iterator = async.iterator([]); 34 | expect(iterator()).to.equal(null); 35 | expect(iterator.next()).to.equal(null); 36 | done(); 37 | }); 38 | 39 | it('iterator.next', function(done) { 40 | var call_order = []; 41 | var iterator = async.iterator([ 42 | function(){call_order.push(1);}, 43 | function(arg1){ 44 | expect(arg1).to.equal('arg1'); 45 | call_order.push(2); 46 | }, 47 | function(arg1, arg2){ 48 | expect(arg1).to.equal('arg1'); 49 | expect(arg2).to.equal('arg2'); 50 | call_order.push(3); 51 | } 52 | ]); 53 | var fn = iterator.next(); 54 | var iterator2 = fn('arg1'); 55 | expect(call_order).to.eql([2]); 56 | iterator2('arg1','arg2'); 57 | expect(call_order).to.eql([2,3]); 58 | expect(iterator2.next()).to.equal(null); 59 | done(); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/reduce.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('reduce', function() { 6 | 7 | it('reduce', function(done) { 8 | var call_order = []; 9 | async.reduce([1,2,3], 0, function(a, x, callback){ 10 | call_order.push(x); 11 | callback(null, a + x); 12 | }, function(err, result){ 13 | assert(err === null, err + " passed instead of 'null'"); 14 | expect(result).to.equal(6); 15 | expect(call_order).to.eql([1,2,3]); 16 | done(); 17 | }); 18 | }); 19 | 20 | it('reduce async with non-reference memo', function(done) { 21 | async.reduce([1,3,2], 0, function(a, x, callback){ 22 | setTimeout(function(){callback(null, a + x);}, Math.random()*100); 23 | }, function(err, result){ 24 | expect(result).to.equal(6); 25 | done(); 26 | }); 27 | }); 28 | 29 | it('reduce error', function(done) { 30 | async.reduce([1,2,3], 0, function(a, x, callback){ 31 | callback('error'); 32 | }, function(err){ 33 | expect(err).to.equal('error'); 34 | }); 35 | setTimeout(done, 50); 36 | }); 37 | 38 | it('inject alias', function(done) { 39 | expect(async.inject).to.equal(async.reduce); 40 | done(); 41 | }); 42 | 43 | it('foldl alias', function(done) { 44 | expect(async.foldl).to.equal(async.reduce); 45 | done(); 46 | }); 47 | 48 | it('reduceRight', function(done) { 49 | var call_order = []; 50 | var a = [1,2,3]; 51 | async.reduceRight(a, 0, function(a, x, callback){ 52 | call_order.push(x); 53 | callback(null, a + x); 54 | }, function(err, result){ 55 | expect(result).to.equal(6); 56 | expect(call_order).to.eql([3,2,1]); 57 | expect(a).to.eql([1,2,3]); 58 | done(); 59 | }); 60 | }); 61 | 62 | it('foldr alias', function(done) { 63 | expect(async.foldr).to.equal(async.reduceRight); 64 | done(); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/reduce.js: -------------------------------------------------------------------------------- 1 | import eachOfSeries from './eachOfSeries'; 2 | 3 | /** 4 | * Reduces `coll` into a single value using an async `iteratee` to return each 5 | * successive step. `memo` is the initial state of the reduction. This function 6 | * only operates in series. 7 | * 8 | * For performance reasons, it may make sense to split a call to this function 9 | * into a parallel map, and then use the normal `Array.prototype.reduce` on the 10 | * results. This function is for situations where each step in the reduction 11 | * needs to be async; if you can get the data before reducing it, then it's 12 | * probably a good idea to do so. 13 | * 14 | * @name reduce 15 | * @static 16 | * @memberOf async 17 | * @alias inject 18 | * @alias foldl 19 | * @category Collection 20 | * @param {Array|Object} coll - A collection to iterate over. 21 | * @param {*} memo - The initial state of the reduction. 22 | * @param {Function} iteratee - A function applied to each item in the 23 | * array to produce the next step in the reduction. The `iteratee` is passed a 24 | * `callback(err, reduction)` which accepts an optional error as its first 25 | * argument, and the state of the reduction as the second. If an error is 26 | * passed to the callback, the reduction is stopped and the main `callback` is 27 | * immediately called with the error. Invoked with (memo, item, callback). 28 | * @param {Function} [callback] - A callback which is called after all the 29 | * `iteratee` functions have finished. Result is the reduced value. Invoked with 30 | * (err, result). 31 | * @example 32 | * 33 | * async.reduce([1,2,3], 0, function(memo, item, callback) { 34 | * // pointless async: 35 | * process.nextTick(function() { 36 | * callback(null, memo + item) 37 | * }); 38 | * }, function(err, result) { 39 | * // result is now equal to the last value of memo, which is 6 40 | * }); 41 | */ 42 | export default function reduce(coll, memo, iteratee, callback) { 43 | eachOfSeries(coll, function(x, i, callback) { 44 | iteratee(memo, x, function(err, v) { 45 | memo = v; 46 | callback(err); 47 | }); 48 | }, function(err) { 49 | callback(err, memo); 50 | }); 51 | } 52 | -------------------------------------------------------------------------------- /Lambda Files/async/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "async", 3 | "description": "Higher-order functions and common patterns for asynchronous code", 4 | "version": "2.0.0-rc.6", 5 | "main": "dist/async.js", 6 | "author": "Caolan McMahon", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/caolan/async.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/caolan/async/issues" 13 | }, 14 | "keywords": [ 15 | "async", 16 | "callback", 17 | "module", 18 | "utility" 19 | ], 20 | "dependencies": { 21 | "lodash": "^4.8.0", 22 | "lodash-es": "^4.8.0" 23 | }, 24 | "devDependencies": { 25 | "babel-cli": "^6.3.17", 26 | "babel-core": "^6.3.26", 27 | "babel-plugin-add-module-exports": "~0.1.2", 28 | "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16", 29 | "babel-preset-es2015": "^6.3.13", 30 | "babelify": "^7.2.0", 31 | "benchmark": "bestiejs/benchmark.js", 32 | "bluebird": "^2.9.32", 33 | "chai": "^3.1.0", 34 | "coveralls": "^2.11.2", 35 | "es6-promise": "^2.3.0", 36 | "eslint": "^2.11.1", 37 | "fs-extra": "^0.26.7", 38 | "jscs-jsdoc": "^1.3.2", 39 | "karma": "^0.13.2", 40 | "karma-browserify": "^4.2.1", 41 | "karma-firefox-launcher": "^0.1.6", 42 | "karma-mocha": "^0.2.0", 43 | "karma-mocha-reporter": "^1.0.2", 44 | "mocha": "^2.2.5", 45 | "native-promise-only": "^0.8.0-a", 46 | "nyc": "^2.1.0", 47 | "recursive-readdir": "^1.3.0", 48 | "rimraf": "^2.5.0", 49 | "rollup": "^0.25.0", 50 | "rollup-plugin-node-resolve": "^1.5.0", 51 | "rollup-plugin-npm": "~1.3.0", 52 | "rsvp": "^3.0.18", 53 | "semver": "^4.3.6", 54 | "uglify-js": "~2.4.0", 55 | "yargs": "~3.9.1" 56 | }, 57 | "scripts": { 58 | "coverage": "nyc npm test && nyc report", 59 | "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", 60 | "lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ karma.conf.js", 61 | "mocha-browser-test": "karma start", 62 | "mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register", 63 | "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test", 64 | "test": "npm run-script lint && npm run mocha-node-test" 65 | }, 66 | "license": "MIT" 67 | } 68 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/seq.js: -------------------------------------------------------------------------------- 1 | import noop from 'lodash/noop'; 2 | import rest from 'lodash/rest'; 3 | import reduce from './reduce'; 4 | 5 | /** 6 | * Version of the compose function that is more natural to read. Each function 7 | * consumes the return value of the previous function. It is the equivalent of 8 | * {@link async.compose} with the arguments reversed. 9 | * 10 | * Each function is executed with the `this` binding of the composed function. 11 | * 12 | * @name seq 13 | * @static 14 | * @memberOf async 15 | * @see async.compose 16 | * @category Control Flow 17 | * @param {...Function} functions - the asynchronous functions to compose 18 | * @returns {Function} a function that composes the `functions` in order 19 | * @example 20 | * 21 | * // Requires lodash (or underscore), express3 and dresende's orm2. 22 | * // Part of an app, that fetches cats of the logged user. 23 | * // This example uses `seq` function to avoid overnesting and error 24 | * // handling clutter. 25 | * app.get('/cats', function(request, response) { 26 | * var User = request.models.User; 27 | * async.seq( 28 | * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) 29 | * function(user, fn) { 30 | * user.getCats(fn); // 'getCats' has signature (callback(err, data)) 31 | * } 32 | * )(req.session.user_id, function (err, cats) { 33 | * if (err) { 34 | * console.error(err); 35 | * response.json({ status: 'error', message: err.message }); 36 | * } else { 37 | * response.json({ status: 'ok', message: 'Cats found', data: cats }); 38 | * } 39 | * }); 40 | * }); 41 | */ 42 | export default rest(function seq(functions) { 43 | return rest(function(args) { 44 | var that = this; 45 | 46 | var cb = args[args.length - 1]; 47 | if (typeof cb == 'function') { 48 | args.pop(); 49 | } else { 50 | cb = noop; 51 | } 52 | 53 | reduce(functions, args, function(newargs, fn, cb) { 54 | fn.apply(that, newargs.concat([rest(function(err, nextargs) { 55 | cb(err, nextargs); 56 | })])); 57 | }, 58 | function(err, results) { 59 | cb.apply(that, [err].concat(results)); 60 | }); 61 | }); 62 | }) 63 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/transform.js: -------------------------------------------------------------------------------- 1 | import isArray from 'lodash/isArray'; 2 | 3 | import eachOf from './eachOf'; 4 | 5 | /** 6 | * A relative of `reduce`. Takes an Object or Array, and iterates over each 7 | * element in series, each step potentially mutating an `accumulator` value. 8 | * The type of the accumulator defaults to the type of collection passed in. 9 | * 10 | * @name transform 11 | * @static 12 | * @memberOf async 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {*} [accumulator] - The initial state of the transform. If omitted, 16 | * it will default to an empty Object or Array, depending on the type of `coll` 17 | * @param {Function} iteratee - A function applied to each item in the 18 | * collection that potentially modifies the accumulator. The `iteratee` is 19 | * passed a `callback(err)` which accepts an optional error as its first 20 | * argument. If an error is passed to the callback, the transform is stopped 21 | * and the main `callback` is immediately called with the error. 22 | * Invoked with (accumulator, item, key, callback). 23 | * @param {Function} [callback] - A callback which is called after all the 24 | * `iteratee` functions have finished. Result is the transformed accumulator. 25 | * Invoked with (err, result). 26 | * @example 27 | * 28 | * async.transform([1,2,3], function(acc, item, index, callback) { 29 | * // pointless async: 30 | * process.nextTick(function() { 31 | * acc.push(item * 2) 32 | * callback(null) 33 | * }); 34 | * }, function(err, result) { 35 | * // result is now equal to [2, 4, 6] 36 | * }); 37 | * 38 | * @example 39 | * 40 | * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { 41 | * setImmediate(function () { 42 | * obj[key] = val * 2; 43 | * callback(); 44 | * }) 45 | * }, function (err, result) { 46 | * // result is equal to {a: 2, b: 4, c: 6} 47 | * }) 48 | */ 49 | export default function transform (coll, accumulator, iteratee, callback) { 50 | if (arguments.length === 3) { 51 | callback = iteratee; 52 | iteratee = accumulator; 53 | accumulator = isArray(coll) ? [] : {}; 54 | } 55 | 56 | eachOf(coll, function(v, k, cb) { 57 | iteratee(accumulator, v, k, cb); 58 | }, function(err) { 59 | callback(err, accumulator); 60 | }); 61 | } 62 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/retryable.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('retryable', function () { 6 | it('basics', function (done) { 7 | var calls = 0; 8 | var retryableTask = async.retryable(3, function (arg, cb) { 9 | calls++; 10 | expect(arg).to.equal(42); 11 | cb('fail'); 12 | }); 13 | 14 | retryableTask(42, function (err) { 15 | expect(err).to.equal('fail'); 16 | expect(calls).to.equal(3); 17 | done(); 18 | }); 19 | 20 | setTimeout(function () { 21 | }, 15); 22 | }); 23 | 24 | it('should work as an embedded task', function(done) { 25 | var retryResult = 'RETRY'; 26 | var fooResults; 27 | var retryResults; 28 | 29 | async.auto({ 30 | dep: async.constant('dep'), 31 | foo: ['dep', function(results, callback){ 32 | fooResults = results; 33 | callback(null, 'FOO'); 34 | }], 35 | retry: ['dep', async.retryable(function(results, callback) { 36 | retryResults = results; 37 | callback(null, retryResult); 38 | })] 39 | }, function(err, results){ 40 | assert.equal(results.retry, retryResult, "Incorrect result was returned from retry function"); 41 | assert.equal(fooResults, retryResults, "Incorrect results were passed to retry function"); 42 | done(); 43 | }); 44 | }); 45 | 46 | it('should work as an embedded task with interval', function(done) { 47 | var start = new Date().getTime(); 48 | var opts = {times: 5, interval: 20}; 49 | 50 | async.auto({ 51 | foo: function(callback){ 52 | callback(null, 'FOO'); 53 | }, 54 | retry: async.retryable(opts, function(callback) { 55 | callback('err'); 56 | }) 57 | }, function(){ 58 | var duration = new Date().getTime() - start; 59 | var expectedMinimumDuration = (opts.times -1) * opts.interval; 60 | assert(duration >= expectedMinimumDuration, 61 | "The duration should have been greater than " + 62 | expectedMinimumDuration + ", but was " + duration); 63 | done(); 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/sortBy.js: -------------------------------------------------------------------------------- 1 | import arrayMap from 'lodash/_arrayMap'; 2 | import property from 'lodash/_baseProperty'; 3 | 4 | import map from './map'; 5 | 6 | /** 7 | * Sorts a list by the results of running each `coll` value through an async 8 | * `iteratee`. 9 | * 10 | * @name sortBy 11 | * @static 12 | * @memberOf async 13 | * @category Collection 14 | * @param {Array|Object} coll - A collection to iterate over. 15 | * @param {Function} iteratee - A function to apply to each item in `coll`. 16 | * The iteratee is passed a `callback(err, sortValue)` which must be called once 17 | * it has completed with an error (which can be `null`) and a value to use as 18 | * the sort criteria. Invoked with (item, callback). 19 | * @param {Function} [callback] - A callback which is called after all the 20 | * `iteratee` functions have finished, or an error occurs. Results is the items 21 | * from the original `coll` sorted by the values returned by the `iteratee` 22 | * calls. Invoked with (err, results). 23 | * @example 24 | * 25 | * async.sortBy(['file1','file2','file3'], function(file, callback) { 26 | * fs.stat(file, function(err, stats) { 27 | * callback(err, stats.mtime); 28 | * }); 29 | * }, function(err, results) { 30 | * // results is now the original array of files sorted by 31 | * // modified date 32 | * }); 33 | * 34 | * // By modifying the callback parameter the 35 | * // sorting order can be influenced: 36 | * 37 | * // ascending order 38 | * async.sortBy([1,9,3,5], function(x, callback) { 39 | * callback(null, x); 40 | * }, function(err,result) { 41 | * // result callback 42 | * }); 43 | * 44 | * // descending order 45 | * async.sortBy([1,9,3,5], function(x, callback) { 46 | * callback(null, x*-1); //<- x*-1 instead of x, turns the order around 47 | * }, function(err,result) { 48 | * // result callback 49 | * }); 50 | */ 51 | export default function sortBy (coll, iteratee, callback) { 52 | map(coll, function (x, callback) { 53 | iteratee(x, function (err, criteria) { 54 | if (err) return callback(err); 55 | callback(null, {value: x, criteria: criteria}); 56 | }); 57 | }, function (err, results) { 58 | if (err) return callback(err); 59 | callback(null, arrayMap(results.sort(comparator), property('value'))); 60 | }); 61 | 62 | function comparator(left, right) { 63 | var a = left.criteria, b = right.criteria; 64 | return a < b ? -1 : a > b ? 1 : 0; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/race.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var assert = require('assert'); 3 | 4 | describe('race', function () { 5 | it('should call each function in parallel and callback with first result', function raceTest10(done) { 6 | var finished = 0; 7 | var tasks = []; 8 | function eachTest(i) { 9 | var index = i; 10 | return function (next) { 11 | finished++; 12 | next(null, index); 13 | }; 14 | } 15 | for (var i = 0; i < 10; i++) { 16 | tasks[i] = eachTest(i); 17 | } 18 | async.race(tasks, function (err, result) { 19 | assert.ifError(err); 20 | //0 finished first 21 | assert.strictEqual(result, 0); 22 | assert.strictEqual(finished, 1); 23 | async.setImmediate(function () { 24 | assert.strictEqual(finished, 10); 25 | done(); 26 | }); 27 | }); 28 | }); 29 | it('should callback with the first error', function raceTest20(done) { 30 | var tasks = []; 31 | function eachTest(i) { 32 | var index = i; 33 | return function (next) { 34 | setTimeout(function () { 35 | next(new Error('ERR' + index)); 36 | }, 50 - index * 2); 37 | }; 38 | } 39 | for (var i = 0; i <= 5; i++) { 40 | tasks[i] = eachTest(i); 41 | } 42 | async.race(tasks, function (err, result) { 43 | assert.ok(err); 44 | assert.ok(err instanceof Error); 45 | assert.strictEqual(typeof result, 'undefined'); 46 | assert.strictEqual(err.message, 'ERR5'); 47 | done(); 48 | }); 49 | }); 50 | it('should callback when task is empty', function raceTest30(done) { 51 | async.race([], function (err, result) { 52 | assert.ifError(err); 53 | assert.strictEqual(typeof result, 'undefined'); 54 | done(); 55 | }); 56 | }); 57 | it('should callback in error the task arg is not an Array', function raceTest40() { 58 | var errors = []; 59 | async.race(null, function (err) { 60 | errors.push(err); 61 | }); 62 | async.race({}, function (err) { 63 | errors.push(err); 64 | }); 65 | assert.strictEqual(errors.length, 2); 66 | assert.ok(errors[0] instanceof TypeError); 67 | assert.ok(errors[1] instanceof TypeError); 68 | }); 69 | }); 70 | 71 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/each.js: -------------------------------------------------------------------------------- 1 | import eachLimit from './eachLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Applies the function `iteratee` to each item in `coll`, in parallel. 6 | * The `iteratee` is called with an item from the list, and a callback for when 7 | * it has finished. If the `iteratee` passes an error to its `callback`, the 8 | * main `callback` (for the `each` function) is immediately called with the 9 | * error. 10 | * 11 | * Note, that since this function applies `iteratee` to each item in parallel, 12 | * there is no guarantee that the iteratee functions will complete in order. 13 | * 14 | * @name each 15 | * @static 16 | * @memberOf async 17 | * @alias forEach 18 | * @category Collection 19 | * @param {Array|Object} coll - A collection to iterate over. 20 | * @param {Function} iteratee - A function to apply to each item 21 | * in `coll`. The iteratee is passed a `callback(err)` which must be called once 22 | * it has completed. If no error has occurred, the `callback` should be run 23 | * without arguments or with an explicit `null` argument. The array index is not 24 | * passed to the iteratee. Invoked with (item, callback). If you need the index, 25 | * use `eachOf`. 26 | * @param {Function} [callback] - A callback which is called when all 27 | * `iteratee` functions have finished, or an error occurs. Invoked with (err). 28 | * @example 29 | * 30 | * // assuming openFiles is an array of file names and saveFile is a function 31 | * // to save the modified contents of that file: 32 | * 33 | * async.each(openFiles, saveFile, function(err){ 34 | * // if any of the saves produced an error, err would equal that error 35 | * }); 36 | * 37 | * // assuming openFiles is an array of file names 38 | * async.each(openFiles, function(file, callback) { 39 | * 40 | * // Perform operation on file here. 41 | * console.log('Processing file ' + file); 42 | * 43 | * if( file.length > 32 ) { 44 | * console.log('This file name is too long'); 45 | * callback('File name too long'); 46 | * } else { 47 | * // Do work to process file here 48 | * console.log('File processed'); 49 | * callback(); 50 | * } 51 | * }, function(err) { 52 | * // if any of the file processing produced an error, err would equal that error 53 | * if( err ) { 54 | * // One of the iterations produced an error. 55 | * // All processing will now stop. 56 | * console.log('A file failed to process'); 57 | * } else { 58 | * console.log('All files have been processed successfully'); 59 | * } 60 | * }); 61 | */ 62 | export default doLimit(eachLimit, Infinity); 63 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/memoize.js: -------------------------------------------------------------------------------- 1 | import identity from 'lodash/identity'; 2 | import rest from 'lodash/rest'; 3 | 4 | import setImmediate from './internal/setImmediate'; 5 | import initialParams from './internal/initialParams'; 6 | 7 | function has(obj, key) { 8 | return key in obj; 9 | } 10 | 11 | /** 12 | * Caches the results of an `async` function. When creating a hash to store 13 | * function results against, the callback is omitted from the hash and an 14 | * optional hash function can be used. 15 | * 16 | * If no hash function is specified, the first argument is used as a hash key, 17 | * which may work reasonably if it is a string or a data type that converts to a 18 | * distinct string. Note that objects and arrays will not behave reasonably. 19 | * Neither will cases where the other arguments are significant. In such cases, 20 | * specify your own hash function. 21 | * 22 | * The cache of results is exposed as the `memo` property of the function 23 | * returned by `memoize`. 24 | * 25 | * @name memoize 26 | * @static 27 | * @memberOf async 28 | * @category Util 29 | * @param {Function} fn - The function to proxy and cache results from. 30 | * @param {Function} hasher - An optional function for generating a custom hash 31 | * for storing results. It has all the arguments applied to it apart from the 32 | * callback, and must be synchronous. 33 | * @returns {Function} a memoized version of `fn` 34 | * @example 35 | * 36 | * var slow_fn = function(name, callback) { 37 | * // do something 38 | * callback(null, result); 39 | * }; 40 | * var fn = async.memoize(slow_fn); 41 | * 42 | * // fn can now be used as if it were slow_fn 43 | * fn('some name', function() { 44 | * // callback 45 | * }); 46 | */ 47 | export default function memoize(fn, hasher) { 48 | var memo = Object.create(null); 49 | var queues = Object.create(null); 50 | hasher = hasher || identity; 51 | var memoized = initialParams(function memoized(args, callback) { 52 | var key = hasher.apply(null, args); 53 | if (has(memo, key)) { 54 | setImmediate(function() { 55 | callback.apply(null, memo[key]); 56 | }); 57 | } else if (has(queues, key)) { 58 | queues[key].push(callback); 59 | } else { 60 | queues[key] = [callback]; 61 | fn.apply(null, args.concat([rest(function(args) { 62 | memo[key] = args; 63 | var q = queues[key]; 64 | delete queues[key]; 65 | for (var i = 0, l = q.length; i < l; i++) { 66 | q[i].apply(null, args); 67 | } 68 | })])); 69 | } 70 | }); 71 | memoized.memo = memo; 72 | memoized.unmemoized = fn; 73 | return memoized; 74 | } 75 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/consoleFunctions.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('console functions', function() { 5 | 6 | var names = [ 7 | 'log', 8 | 'dir', 9 | /* 'info' 10 | 'warn' 11 | 'error' */ 12 | ]; 13 | 14 | // generates tests for console functions such as async.log 15 | names.forEach(function(name) { 16 | if (typeof console !== 'undefined') { 17 | it(name, function(done) { 18 | var fn = function(arg1, callback){ 19 | expect(arg1).to.equal('one'); 20 | setTimeout(function(){callback(null, 'test');}, 0); 21 | }; 22 | var fn_err = function(arg1, callback){ 23 | expect(arg1).to.equal('one'); 24 | setTimeout(function(){callback('error');}, 0); 25 | }; 26 | var _console_fn = console[name]; 27 | var _error = console.error; 28 | console[name] = function(val){ 29 | expect(val).to.equal('test'); 30 | expect(arguments.length).to.equal(1); 31 | console.error = function(val){ 32 | expect(val).to.equal('error'); 33 | console[name] = _console_fn; 34 | console.error = _error; 35 | done(); 36 | }; 37 | async[name](fn_err, 'one'); 38 | }; 39 | async[name](fn, 'one'); 40 | }); 41 | 42 | it(name + ' with multiple result params', function(done) { 43 | var fn = function(callback){callback(null,'one','two','three');}; 44 | var _console_fn = console[name]; 45 | var called_with = []; 46 | console[name] = function(x){ 47 | called_with.push(x); 48 | }; 49 | async[name](fn); 50 | expect(called_with).to.eql(['one','two','three']); 51 | console[name] = _console_fn; 52 | done(); 53 | }); 54 | } 55 | 56 | // browser-only test 57 | if (typeof window !== 'undefined') { 58 | it(name + ' without console.' + name, function(done) { 59 | var _console = window.console; 60 | window.console = undefined; 61 | var fn = function(callback){callback(null, 'val');}; 62 | var fn_err = function(callback){callback('error');}; 63 | async[name](fn); 64 | async[name](fn_err); 65 | window.console = _console; 66 | done(); 67 | }); 68 | } 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/series.js: -------------------------------------------------------------------------------- 1 | import parallel from './internal/parallel'; 2 | import eachOfSeries from './eachOfSeries'; 3 | 4 | /** 5 | * Run the functions in the `tasks` collection in series, each one running once 6 | * the previous function has completed. If any functions in the series pass an 7 | * error to its callback, no more functions are run, and `callback` is 8 | * immediately called with the value of the error. Otherwise, `callback` 9 | * receives an array of results when `tasks` have completed. 10 | * 11 | * It is also possible to use an object instead of an array. Each property will 12 | * be run as a function, and the results will be passed to the final `callback` 13 | * as an object instead of an array. This can be a more readable way of handling 14 | * results from {@link async.series}. 15 | * 16 | * **Note** that while many implementations preserve the order of object 17 | * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) 18 | * explicitly states that 19 | * 20 | * > The mechanics and order of enumerating the properties is not specified. 21 | * 22 | * So if you rely on the order in which your series of functions are executed, 23 | * and want this to work on all platforms, consider using an array. 24 | * 25 | * @name series 26 | * @static 27 | * @memberOf async 28 | * @category Control Flow 29 | * @param {Array|Object} tasks - A collection containing functions to run, each 30 | * function is passed a `callback(err, result)` it must call on completion with 31 | * an error `err` (which can be `null`) and an optional `result` value. 32 | * @param {Function} [callback] - An optional callback to run once all the 33 | * functions have completed. This function gets a results array (or object) 34 | * containing all the result arguments passed to the `task` callbacks. Invoked 35 | * with (err, result). 36 | * @example 37 | * async.series([ 38 | * function(callback) { 39 | * // do some stuff ... 40 | * callback(null, 'one'); 41 | * }, 42 | * function(callback) { 43 | * // do some more stuff ... 44 | * callback(null, 'two'); 45 | * } 46 | * ], 47 | * // optional callback 48 | * function(err, results) { 49 | * // results is now equal to ['one', 'two'] 50 | * }); 51 | * 52 | * async.series({ 53 | * one: function(callback) { 54 | * setTimeout(function() { 55 | * callback(null, 1); 56 | * }, 200); 57 | * }, 58 | * two: function(callback){ 59 | * setTimeout(function() { 60 | * callback(null, 2); 61 | * }, 100); 62 | * } 63 | * }, function(err, results) { 64 | * // results is now equal to: {one: 1, two: 2} 65 | * }); 66 | */ 67 | export default function series(tasks, callback) { 68 | parallel(eachOfSeries, tasks, callback); 69 | } 70 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/timeout.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('timeout', function () { 5 | 6 | it('timeout with series', function(done){ 7 | async.series([ 8 | async.timeout(function asyncFn(callback) { 9 | setTimeout(function() { 10 | callback(null, 'I didn\'t time out'); 11 | }, 25); 12 | }, 50), 13 | async.timeout(function asyncFn(callback) { 14 | setTimeout(function() { 15 | callback(null, 'I will time out'); 16 | }, 75); 17 | }, 50) 18 | ], 19 | function(err, results) { 20 | expect(err.message).to.equal('Callback function "asyncFn" timed out.'); 21 | expect(err.code).to.equal('ETIMEDOUT'); 22 | expect(err.info).to.equal(undefined); 23 | expect(results[0]).to.equal('I didn\'t time out'); 24 | done(); 25 | }); 26 | }); 27 | 28 | it('timeout with series and info', function (done) { 29 | var info = { custom: 'info about callback' }; 30 | async.series([ 31 | async.timeout(function asyncFn(callback) { 32 | setTimeout(function() { 33 | callback(null, 'I didn\'t time out'); 34 | }, 25); 35 | }, 50), 36 | async.timeout(function asyncFn(callback) { 37 | setTimeout(function() { 38 | callback(null, 'I will time out'); 39 | }, 75); 40 | }, 50, info) 41 | ], 42 | function(err, results) { 43 | expect(err.message).to.equal('Callback function "asyncFn" timed out.'); 44 | expect(err.code).to.equal('ETIMEDOUT'); 45 | expect(err.info).to.equal(info); 46 | expect(results[0]).to.equal('I didn\'t time out'); 47 | done(); 48 | }); 49 | }); 50 | 51 | it('timeout with parallel', function(done){ 52 | async.parallel([ 53 | async.timeout(function asyncFn(callback) { 54 | setTimeout(function() { 55 | callback(null, 'I didn\'t time out'); 56 | }, 25); 57 | }, 50), 58 | async.timeout(function asyncFn(callback) { 59 | setTimeout(function() { 60 | callback(null, 'I will time out'); 61 | }, 75); 62 | }, 50) 63 | ], 64 | function(err, results) { 65 | expect(err.message).to.equal('Callback function "asyncFn" timed out.'); 66 | expect(err.code).to.equal('ETIMEDOUT'); 67 | expect(err.info).to.equal(undefined); 68 | expect(results[0]).to.equal('I didn\'t time out'); 69 | done(); 70 | }); 71 | }); 72 | }); 73 | -------------------------------------------------------------------------------- /Lambda Files/async/support/build.test.js: -------------------------------------------------------------------------------- 1 | // Smoke test for the CJS build 2 | var methods = ["each", "waterfall", "queue", "eachSeries"]; 3 | var expect = require('chai').expect; 4 | var rollup = require('rollup').rollup; 5 | var rollupPluginNodeResolve = require('rollup-plugin-node-resolve'); 6 | var fs = require('fs'); 7 | var exec = require('child_process').exec; 8 | 9 | describe("async main", function() { 10 | var async; 11 | 12 | before(function() { 13 | async = require("../build/"); 14 | }); 15 | 16 | it("should have methods", function() { 17 | methods.forEach(function(methodName) { 18 | expect(async[methodName]).to.be.a("function"); 19 | }); 20 | }); 21 | }); 22 | 23 | describe("async umd", function() { 24 | var async; 25 | 26 | before(function() { 27 | async = require("../build/dist/async.js"); 28 | }); 29 | 30 | it("should have methods", function() { 31 | methods.forEach(function(methodName) { 32 | expect(async[methodName]).to.be.a("function"); 33 | }); 34 | }); 35 | }); 36 | 37 | describe("async umd minified", function() { 38 | var async; 39 | 40 | before(function() { 41 | async = require("../build/dist/async.min.js"); 42 | }); 43 | 44 | it("should have methods", function() { 45 | methods.forEach(function(methodName) { 46 | expect(async[methodName]).to.be.a("function"); 47 | }); 48 | }); 49 | }); 50 | 51 | methods.forEach(function (methodName) { 52 | describe("async." + methodName, function () { 53 | var method; 54 | before(function () { 55 | method = require("../build/" + methodName); 56 | }); 57 | 58 | it("should require the individual method", function() { 59 | expect(method).to.be.a("function"); 60 | }); 61 | }); 62 | }); 63 | 64 | describe("ES Modules", function () { 65 | var tmpDir = __dirname + "/../tmp"; 66 | var buildFile = __dirname + "/../tmp/es.test.js"; 67 | 68 | before(function (done) { 69 | if (fs.existsSync(tmpDir)) { 70 | return done(); 71 | } 72 | fs.mkdir(tmpDir, done); 73 | }); 74 | 75 | before(function () { 76 | return rollup({ 77 | entry: __dirname + "/es.test.js", 78 | plugins: [ 79 | rollupPluginNodeResolve() 80 | ] 81 | }).then(function (bundle) { 82 | return bundle.write({ 83 | format: "umd", 84 | dest: buildFile 85 | }); 86 | }); 87 | }); 88 | 89 | it("should build a successful bundle", function (done) { 90 | exec("node " + buildFile, function (err, stdout) { 91 | if (err) { return done(err); } 92 | expect(stdout).to.match(/42/); 93 | done(); 94 | }); 95 | }); 96 | }); 97 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/parallel.js: -------------------------------------------------------------------------------- 1 | import parallelLimit from './parallelLimit'; 2 | import doLimit from './internal/doLimit'; 3 | 4 | /** 5 | * Run the `tasks` collection of functions in parallel, without waiting until 6 | * the previous function has completed. If any of the functions pass an error to 7 | * its callback, the main `callback` is immediately called with the value of the 8 | * error. Once the `tasks` have completed, the results are passed to the final 9 | * `callback` as an array. 10 | * 11 | * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about 12 | * parallel execution of code. If your tasks do not use any timers or perform 13 | * any I/O, they will actually be executed in series. Any synchronous setup 14 | * sections for each task will happen one after the other. JavaScript remains 15 | * single-threaded. 16 | * 17 | * It is also possible to use an object instead of an array. Each property will 18 | * be run as a function and the results will be passed to the final `callback` 19 | * as an object instead of an array. This can be a more readable way of handling 20 | * results from {@link async.parallel}. 21 | * 22 | * @name parallel 23 | * @static 24 | * @memberOf async 25 | * @category Control Flow 26 | * @param {Array|Object} tasks - A collection containing functions to run. 27 | * Each function is passed a `callback(err, result)` which it must call on 28 | * completion with an error `err` (which can be `null`) and an optional `result` 29 | * value. 30 | * @param {Function} [callback] - An optional callback to run once all the 31 | * functions have completed successfully. This function gets a results array 32 | * (or object) containing all the result arguments passed to the task callbacks. 33 | * Invoked with (err, results). 34 | * @example 35 | * async.parallel([ 36 | * function(callback) { 37 | * setTimeout(function() { 38 | * callback(null, 'one'); 39 | * }, 200); 40 | * }, 41 | * function(callback) { 42 | * setTimeout(function() { 43 | * callback(null, 'two'); 44 | * }, 100); 45 | * } 46 | * ], 47 | * // optional callback 48 | * function(err, results) { 49 | * // the results array will equal ['one','two'] even though 50 | * // the second function had a shorter timeout. 51 | * }); 52 | * 53 | * // an example using an object instead of an array 54 | * async.parallel({ 55 | * one: function(callback) { 56 | * setTimeout(function() { 57 | * callback(null, 1); 58 | * }, 200); 59 | * }, 60 | * two: function(callback) { 61 | * setTimeout(function() { 62 | * callback(null, 2); 63 | * }, 100); 64 | * } 65 | * }, function(err, results) { 66 | * // results is now equals to: {one: 1, two: 2} 67 | * }); 68 | */ 69 | export default doLimit(parallelLimit, Infinity); 70 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/asyncify.js: -------------------------------------------------------------------------------- 1 | import isObject from 'lodash/isObject'; 2 | import initialParams from './internal/initialParams'; 3 | 4 | /** 5 | * Take a sync function and make it async, passing its return value to a 6 | * callback. This is useful for plugging sync functions into a waterfall, 7 | * series, or other async functions. Any arguments passed to the generated 8 | * function will be passed to the wrapped function (except for the final 9 | * callback argument). Errors thrown will be passed to the callback. 10 | * 11 | * If the function passed to `asyncify` returns a Promise, that promises's 12 | * resolved/rejected state will be used to call the callback, rather than simply 13 | * the synchronous return value. 14 | * 15 | * This also means you can asyncify ES2016 `async` functions. 16 | * 17 | * @name asyncify 18 | * @static 19 | * @memberOf async 20 | * @alias wrapSync 21 | * @category Util 22 | * @param {Function} func - The synchronous function to convert to an 23 | * asynchronous function. 24 | * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with 25 | * (callback). 26 | * @example 27 | * 28 | * // passing a regular synchronous function 29 | * async.waterfall([ 30 | * async.apply(fs.readFile, filename, "utf8"), 31 | * async.asyncify(JSON.parse), 32 | * function (data, next) { 33 | * // data is the result of parsing the text. 34 | * // If there was a parsing error, it would have been caught. 35 | * } 36 | * ], callback); 37 | * 38 | * // passing a function returning a promise 39 | * async.waterfall([ 40 | * async.apply(fs.readFile, filename, "utf8"), 41 | * async.asyncify(function (contents) { 42 | * return db.model.create(contents); 43 | * }), 44 | * function (model, next) { 45 | * // `model` is the instantiated model object. 46 | * // If there was an error, this function would be skipped. 47 | * } 48 | * ], callback); 49 | * 50 | * // es6 example 51 | * var q = async.queue(async.asyncify(async function(file) { 52 | * var intermediateStep = await processFile(file); 53 | * return await somePromise(intermediateStep) 54 | * })); 55 | * 56 | * q.push(files); 57 | */ 58 | export default function asyncify(func) { 59 | return initialParams(function (args, callback) { 60 | var result; 61 | try { 62 | result = func.apply(this, args); 63 | } catch (e) { 64 | return callback(e); 65 | } 66 | // if result is Promise object 67 | if (isObject(result) && typeof result.then === 'function') { 68 | result.then(function(value) { 69 | callback(null, value); 70 | }, function(err) { 71 | callback(err.message ? err : new Error(err)); 72 | }); 73 | } else { 74 | callback(null, result); 75 | } 76 | }); 77 | } 78 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/times.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('times', function() { 6 | 7 | it('times', function(done) { 8 | async.times(5, function(n, next) { 9 | next(null, n); 10 | }, function(err, results) { 11 | assert(err === null, err + " passed instead of 'null'"); 12 | expect(results).to.eql([0,1,2,3,4]); 13 | done(); 14 | }); 15 | }); 16 | 17 | it('times 3', function(done) { 18 | var args = []; 19 | async.times(3, function(n, callback){ 20 | setTimeout(function(){ 21 | args.push(n); 22 | callback(); 23 | }, n * 25); 24 | }, function(err){ 25 | if (err) throw err; 26 | expect(args).to.eql([0,1,2]); 27 | done(); 28 | }); 29 | }); 30 | 31 | it('times 0', function(done) { 32 | async.times(0, function(n, callback){ 33 | assert(false, 'iteratee should not be called'); 34 | callback(); 35 | }, function(err){ 36 | if (err) throw err; 37 | assert(true, 'should call callback'); 38 | }); 39 | setTimeout(done, 25); 40 | }); 41 | 42 | it('times error', function(done) { 43 | async.times(3, function(n, callback){ 44 | callback('error'); 45 | }, function(err){ 46 | expect(err).to.equal('error'); 47 | }); 48 | setTimeout(done, 50); 49 | }); 50 | 51 | it('timesSeries', function(done) { 52 | var call_order = []; 53 | async.timesSeries(5, function(n, callback){ 54 | setTimeout(function(){ 55 | call_order.push(n); 56 | callback(null, n); 57 | }, 100 - n * 10); 58 | }, function(err, results){ 59 | expect(call_order).to.eql([0,1,2,3,4]); 60 | expect(results).to.eql([0,1,2,3,4]); 61 | done(); 62 | }); 63 | }); 64 | 65 | it('timesSeries error', function(done) { 66 | async.timesSeries(5, function(n, callback){ 67 | callback('error'); 68 | }, function(err){ 69 | expect(err).to.equal('error'); 70 | }); 71 | setTimeout(done, 50); 72 | }); 73 | 74 | it('timesLimit', function(done) { 75 | var limit = 2; 76 | var running = 0; 77 | async.timesLimit(5, limit, function (i, next) { 78 | running++; 79 | assert(running <= limit && running > 0, running); 80 | setTimeout(function () { 81 | running--; 82 | next(null, i * 2); 83 | }, (3 - i) * 10); 84 | }, function(err, results){ 85 | assert(err === null, err + " passed instead of 'null'"); 86 | expect(results).to.eql([0, 2, 4, 6, 8]); 87 | done(); 88 | }); 89 | }); 90 | }); 91 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/ensureAsync.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('ensureAsync', function() { 6 | var passContext = function(cb) { 7 | cb(this); 8 | }; 9 | 10 | it('defer sync functions', function(done) { 11 | var sync = true; 12 | async.ensureAsync(function (arg1, arg2, cb) { 13 | expect(arg1).to.equal(1); 14 | expect(arg2).to.equal(2); 15 | cb(null, 4, 5); 16 | })(1, 2, function (err, arg4, arg5) { 17 | expect(err).to.equal(null); 18 | expect(arg4).to.equal(4); 19 | expect(arg5).to.equal(5); 20 | assert(!sync, 'callback called on same tick'); 21 | done(); 22 | }); 23 | sync = false; 24 | }); 25 | 26 | it('do not defer async functions', function(done) { 27 | var sync = false; 28 | async.ensureAsync(function (arg1, arg2, cb) { 29 | expect(arg1).to.equal(1); 30 | expect(arg2).to.equal(2); 31 | async.setImmediate(function () { 32 | sync = true; 33 | cb(null, 4, 5); 34 | sync = false; 35 | }); 36 | })(1, 2, function (err, arg4, arg5) { 37 | expect(err).to.equal(null); 38 | expect(arg4).to.equal(4); 39 | expect(arg5).to.equal(5); 40 | assert(sync, 'callback called on next tick'); 41 | done(); 42 | }); 43 | }); 44 | 45 | it('double wrapping', function(done) { 46 | var sync = true; 47 | async.ensureAsync(async.ensureAsync(function (arg1, arg2, cb) { 48 | expect(arg1).to.equal(1); 49 | expect(arg2).to.equal(2); 50 | cb(null, 4, 5); 51 | }))(1, 2, function (err, arg4, arg5) { 52 | expect(err).to.equal(null); 53 | expect(arg4).to.equal(4); 54 | expect(arg5).to.equal(5); 55 | assert(!sync, 'callback called on same tick'); 56 | done(); 57 | }); 58 | sync = false; 59 | }); 60 | 61 | 62 | it('should propely bind context to the wrapped function', function(done) { 63 | 64 | // call bind after wrapping with ensureAsync 65 | var context = {context: "post"}; 66 | var postBind = async.ensureAsync(passContext); 67 | postBind = postBind.bind(context); 68 | postBind(function(ref) { 69 | expect(ref).to.equal(context); 70 | done(); 71 | }); 72 | }); 73 | 74 | it('should not override the bound context of a function when wrapping', function(done) { 75 | 76 | // call bind before wrapping with ensureAsync 77 | var context = {context: "pre"}; 78 | var preBind = passContext.bind(context); 79 | preBind = async.ensureAsync(preBind); 80 | preBind(function(ref) { 81 | expect(ref).to.equal(context); 82 | done(); 83 | }); 84 | }); 85 | }); 86 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/during.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('during', function() { 6 | 7 | it('during', function(done) { 8 | var call_order = []; 9 | 10 | var count = 0; 11 | async.during( 12 | function (cb) { 13 | call_order.push(['test', count]); 14 | cb(null, count < 5); 15 | }, 16 | function (cb) { 17 | call_order.push(['iteratee', count]); 18 | count++; 19 | cb(); 20 | }, 21 | function (err) { 22 | assert(err === null, err + " passed instead of 'null'"); 23 | expect(call_order).to.eql([ 24 | ['test', 0], 25 | ['iteratee', 0], ['test', 1], 26 | ['iteratee', 1], ['test', 2], 27 | ['iteratee', 2], ['test', 3], 28 | ['iteratee', 3], ['test', 4], 29 | ['iteratee', 4], ['test', 5], 30 | ]); 31 | expect(count).to.equal(5); 32 | done(); 33 | } 34 | ); 35 | }); 36 | 37 | it('doDuring', function(done) { 38 | var call_order = []; 39 | 40 | var count = 0; 41 | async.doDuring( 42 | function (cb) { 43 | call_order.push(['iteratee', count]); 44 | count++; 45 | cb(); 46 | }, 47 | function (cb) { 48 | call_order.push(['test', count]); 49 | cb(null, count < 5); 50 | }, 51 | function (err) { 52 | assert(err === null, err + " passed instead of 'null'"); 53 | expect(call_order).to.eql([ 54 | ['iteratee', 0], ['test', 1], 55 | ['iteratee', 1], ['test', 2], 56 | ['iteratee', 2], ['test', 3], 57 | ['iteratee', 3], ['test', 4], 58 | ['iteratee', 4], ['test', 5], 59 | ]); 60 | expect(count).to.equal(5); 61 | done(); 62 | } 63 | ); 64 | }); 65 | 66 | it('doDuring - error test', function(done) { 67 | var error = new Error('asdas'); 68 | 69 | async.doDuring( 70 | function (cb) { 71 | cb(error); 72 | }, 73 | function () {}, 74 | function (err) { 75 | expect(err).to.equal(error); 76 | done(); 77 | } 78 | ); 79 | }); 80 | 81 | it('doDuring - error iteratee', function(done) { 82 | var error = new Error('asdas'); 83 | 84 | async.doDuring( 85 | function (cb) { 86 | cb(null); 87 | }, 88 | function (cb) { 89 | cb(error); 90 | }, 91 | function (err) { 92 | expect(err).to.equal(error); 93 | done(); 94 | } 95 | ); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/waterfall.js: -------------------------------------------------------------------------------- 1 | import isArray from 'lodash/isArray'; 2 | import noop from 'lodash/noop'; 3 | import once from './internal/once'; 4 | import rest from 'lodash/rest'; 5 | 6 | import onlyOnce from './internal/onlyOnce'; 7 | 8 | /** 9 | * Runs the `tasks` array of functions in series, each passing their results to 10 | * the next in the array. However, if any of the `tasks` pass an error to their 11 | * own callback, the next function is not executed, and the main `callback` is 12 | * immediately called with the error. 13 | * 14 | * @name waterfall 15 | * @static 16 | * @memberOf async 17 | * @category Control Flow 18 | * @param {Array} tasks - An array of functions to run, each function is passed 19 | * a `callback(err, result1, result2, ...)` it must call on completion. The 20 | * first argument is an error (which can be `null`) and any further arguments 21 | * will be passed as arguments in order to the next task. 22 | * @param {Function} [callback] - An optional callback to run once all the 23 | * functions have completed. This will be passed the results of the last task's 24 | * callback. Invoked with (err, [results]). 25 | * @returns undefined 26 | * @example 27 | * 28 | * async.waterfall([ 29 | * function(callback) { 30 | * callback(null, 'one', 'two'); 31 | * }, 32 | * function(arg1, arg2, callback) { 33 | * // arg1 now equals 'one' and arg2 now equals 'two' 34 | * callback(null, 'three'); 35 | * }, 36 | * function(arg1, callback) { 37 | * // arg1 now equals 'three' 38 | * callback(null, 'done'); 39 | * } 40 | * ], function (err, result) { 41 | * // result now equals 'done' 42 | * }); 43 | * 44 | * // Or, with named functions: 45 | * async.waterfall([ 46 | * myFirstFunction, 47 | * mySecondFunction, 48 | * myLastFunction, 49 | * ], function (err, result) { 50 | * // result now equals 'done' 51 | * }); 52 | * function myFirstFunction(callback) { 53 | * callback(null, 'one', 'two'); 54 | * } 55 | * function mySecondFunction(arg1, arg2, callback) { 56 | * // arg1 now equals 'one' and arg2 now equals 'two' 57 | * callback(null, 'three'); 58 | * } 59 | * function myLastFunction(arg1, callback) { 60 | * // arg1 now equals 'three' 61 | * callback(null, 'done'); 62 | * } 63 | */ 64 | export default function(tasks, callback) { 65 | callback = once(callback || noop); 66 | if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); 67 | if (!tasks.length) return callback(); 68 | var taskIndex = 0; 69 | 70 | function nextTask(args) { 71 | if (taskIndex === tasks.length) { 72 | return callback.apply(null, [null].concat(args)); 73 | } 74 | 75 | var taskCallback = onlyOnce(rest(function(err, args) { 76 | if (err) { 77 | return callback.apply(null, [err].concat(args)); 78 | } 79 | nextTask(args); 80 | })); 81 | 82 | args.push(taskCallback); 83 | 84 | var task = tasks[taskIndex++]; 85 | task.apply(null, args); 86 | } 87 | 88 | nextTask([]); 89 | } 90 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/compose.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('compose', function(){ 5 | context('all functions succeed', function(){ 6 | it('yields the result of the composition of the functions', function(done){ 7 | var add2 = function (n, cb) { 8 | setTimeout(function () { 9 | cb(null, n + 2); 10 | }); 11 | }; 12 | var mul3 = function (n, cb) { 13 | setTimeout(function () { 14 | cb(null, n * 3); 15 | }); 16 | }; 17 | var add1 = function (n, cb) { 18 | setTimeout(function () { 19 | cb(null, n + 1); 20 | }); 21 | }; 22 | var add2mul3add1 = async.compose(add1, mul3, add2); 23 | add2mul3add1(3, function (err, result) { 24 | expect(err).to.not.exist; 25 | expect(result).to.eql(16); 26 | done(); 27 | }); 28 | }); 29 | }); 30 | 31 | context('a function errors', function(){ 32 | it('yields the error and does not call later functions', function(done){ 33 | var add1called = false; 34 | var mul3error = new Error('mul3 error'); 35 | var add2 = function (n, cb) { 36 | setTimeout(function () { 37 | cb(null, n + 2); 38 | }); 39 | }; 40 | var mul3 = function (n, cb) { 41 | setTimeout(function () { 42 | cb(mul3error); 43 | }); 44 | }; 45 | var add1 = function (n, cb) { 46 | add1called = true; 47 | setTimeout(function () { 48 | cb(null, n + 1); 49 | }); 50 | }; 51 | var add2mul3add1 = async.compose(add1, mul3, add2); 52 | add2mul3add1(3, function (err, result) { 53 | expect(err).to.eql(mul3error); 54 | expect(result).to.not.exist; 55 | expect(add1called).to.be.false; 56 | done(); 57 | }); 58 | }); 59 | }); 60 | 61 | it('calls each function with the binding of the composed function', function(done){ 62 | var context = {}; 63 | var add2Context = null; 64 | var mul3Context = null; 65 | var add2 = function (n, cb) { 66 | add2Context = this; 67 | setTimeout(function () { 68 | cb(null, n + 2); 69 | }); 70 | }; 71 | var mul3 = function (n, cb) { 72 | mul3Context = this; 73 | setTimeout(function () { 74 | cb(null, n * 3); 75 | }); 76 | }; 77 | var add2mul3 = async.compose(mul3, add2); 78 | add2mul3.call(context, 3, function (err, result) { 79 | expect(err).to.not.exist; 80 | expect(result).to.eql(15); 81 | expect(add2Context).to.equal(context); 82 | expect(mul3Context).to.equal(context); 83 | done(); 84 | }); 85 | }); 86 | }); 87 | -------------------------------------------------------------------------------- /Lambda Files/SpeechOutputs.json: -------------------------------------------------------------------------------- 1 | { 2 | "welcomeResponse": { 3 | "welcome": "Welcome to the Alexa Integration with Cloud Trail. ", 4 | "reprompt": "Please enter your PIN ", 5 | "noPINSet": "Error. Cannot perform request until PIN has been set." 6 | }, 7 | "setRegion": { 8 | "success": "Region set as {0}", 9 | "failure": "You have given an invalid region. Please try again" 10 | }, 11 | "sendEmail": { 12 | "success": "An email was sent to {0}", 13 | "failure": " There was an error sending the email response." 14 | }, 15 | "emailSwitch": { 16 | "success": "Email services have been {0}" 17 | }, 18 | "lookup": { 19 | "noLookupAttribute": "Error. No lookup attribute was given.", 20 | "invalidLookupAttribute": "You have entered an invalid lookup attribute. Please try again.", 21 | "noLookupValue": "Error. No lookup value was given.", 22 | "invalidLookupValue": "You have entered an invalid lookup value. Please try again.", 23 | "lookupFailed": "Error. CloudTrail Lookup failed. Make sure you have CloudTrail read-only permission" 24 | }, 25 | "getEventCount": { 26 | "start": "The number of events ", 27 | "lookupVariables": "with a {0} of {1} ", 28 | "dates": "at the specified dates ", 29 | "end": "is {0}.", 30 | "attributeError": "Error. Only a lookup value or a lookup attribute was given, but not both." 31 | 32 | }, 33 | "getUserActivity": { 34 | "start": "{0} has done {1} unique actions and {2} total actions", 35 | "dates": " at the specified dates", 36 | "listEvents": ". The actions done by {0} include {1}", 37 | "usernameError": "Error. No username was given." 38 | }, 39 | "setTimeOffset": "Offset has been set as {0}{1} hours", 40 | "reprompt": { 41 | "start": "You can ", 42 | "middle": " by saying, ", 43 | "randomReprompt": { 44 | "look up events by a certain attribute": "how many events with an event name of detach role policy occurred on may 31st", 45 | "set your region": "my region is U S east one or California", 46 | "set your time offset": "my time offset is ahead by eight hours", 47 | "enable email services": "enable email", 48 | "disable email services": "disable email", 49 | "ask about user activity": "what has Bob been up to", 50 | "look up events by event name": "how many console logins happened today", 51 | "hear how many events happened in a specific timeframe": "tell me the count of events between yesterday and today" 52 | } 53 | }, 54 | "resourceActivity": { 55 | "activity": "At least one {0} has been modified since the given date", 56 | "noActivity": "No {0}s have been modified since the given date" 57 | }, 58 | "validateUserPIN" : { 59 | "success": "PIN has been validated", 60 | "failure": "Error. Invalid PIN entered", 61 | "alreadyValid": "You have already validated your PIN" 62 | }, 63 | "logInToCloudTrail" : { 64 | "accessDenied": "Error. Tried to log into an account with invalid credentials. " 65 | } 66 | } -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/mapValues.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe('mapValues', function () { 5 | var obj = {a: 1, b: 2, c: 3}; 6 | 7 | context('mapValuesLimit', function () { 8 | it('basics', function (done) { 9 | var running = 0; 10 | var concurrency = { 11 | a: 2, 12 | b: 2, 13 | c: 1 14 | }; 15 | async.mapValuesLimit(obj, 2, function (val, key, next) { 16 | running++; 17 | async.setImmediate(function () { 18 | expect(running).to.equal(concurrency[key]); 19 | running--; 20 | next(null, key + val); 21 | }); 22 | }, function (err, result) { 23 | expect(running).to.equal(0); 24 | expect(err).to.eql(null); 25 | expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); 26 | done(); 27 | }); 28 | }); 29 | 30 | it('error', function (done) { 31 | async.mapValuesLimit(obj, 1, function(val, key, next) { 32 | if (key === 'b') { 33 | return next(new Error("fail")); 34 | } 35 | next(null, val); 36 | }, function (err, result) { 37 | expect(err).to.not.eql(null); 38 | expect(result).to.eql({a: 1}); 39 | done(); 40 | }); 41 | }); 42 | }); 43 | 44 | context('mapValues', function () { 45 | it('basics', function (done) { 46 | var running = 0; 47 | var concurrency = { 48 | a: 3, 49 | b: 2, 50 | c: 1 51 | }; 52 | async.mapValues(obj, function (val, key, next) { 53 | running++; 54 | async.setImmediate(function () { 55 | expect(running).to.equal(concurrency[key]); 56 | running--; 57 | next(null, key + val); 58 | }); 59 | }, function (err, result) { 60 | expect(running).to.equal(0); 61 | expect(err).to.eql(null); 62 | expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); 63 | done(); 64 | }); 65 | }); 66 | }); 67 | 68 | context('mapValuesSeries', function () { 69 | it('basics', function (done) { 70 | var running = 0; 71 | var concurrency = { 72 | a: 1, 73 | b: 1, 74 | c: 1 75 | }; 76 | async.mapValuesSeries(obj, function (val, key, next) { 77 | running++; 78 | async.setImmediate(function () { 79 | expect(running).to.equal(concurrency[key]); 80 | running--; 81 | next(null, key + val); 82 | }); 83 | }, function (err, result) { 84 | expect(running).to.equal(0); 85 | expect(err).to.eql(null); 86 | expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); 87 | done(); 88 | }); 89 | }); 90 | }); 91 | }); 92 | -------------------------------------------------------------------------------- /Lambda Files/async/lib/priorityQueue.js: -------------------------------------------------------------------------------- 1 | import arrayEach from 'lodash/_arrayEach'; 2 | import isArray from 'lodash/isArray'; 3 | import noop from 'lodash/noop'; 4 | 5 | import setImmediate from './setImmediate'; 6 | 7 | import queue from './queue'; 8 | 9 | /** 10 | * The same as {@link async.queue} only tasks are assigned a priority and 11 | * completed in ascending priority order. 12 | * 13 | * @name priorityQueue 14 | * @static 15 | * @memberOf async 16 | * @see async.queue 17 | * @category Control Flow 18 | * @param {Function} worker - An asynchronous function for processing a queued 19 | * task, which must call its `callback(err)` argument when finished, with an 20 | * optional `error` as an argument. If you want to handle errors from an 21 | * individual task, pass a callback to `q.push()`. Invoked with 22 | * (task, callback). 23 | * @param {number} concurrency - An `integer` for determining how many `worker` 24 | * functions should be run in parallel. If omitted, the concurrency defaults to 25 | * `1`. If the concurrency is `0`, an error is thrown. 26 | * @returns {queue} A priorityQueue object to manage the tasks. There are two 27 | * differences between `queue` and `priorityQueue` objects: 28 | * * `push(task, priority, [callback])` - `priority` should be a number. If an 29 | * array of `tasks` is given, all tasks will be assigned the same priority. 30 | * * The `unshift` method was removed. 31 | */ 32 | export default function(worker, concurrency) { 33 | function _compareTasks(a, b) { 34 | return a.priority - b.priority; 35 | } 36 | 37 | function _binarySearch(sequence, item, compare) { 38 | var beg = -1, 39 | end = sequence.length - 1; 40 | while (beg < end) { 41 | var mid = beg + ((end - beg + 1) >>> 1); 42 | if (compare(item, sequence[mid]) >= 0) { 43 | beg = mid; 44 | } else { 45 | end = mid - 1; 46 | } 47 | } 48 | return beg; 49 | } 50 | 51 | function _insert(q, data, priority, callback) { 52 | if (callback != null && typeof callback !== 'function') { 53 | throw new Error('task callback must be a function'); 54 | } 55 | q.started = true; 56 | if (!isArray(data)) { 57 | data = [data]; 58 | } 59 | if (data.length === 0) { 60 | // call drain immediately if there are no tasks 61 | return setImmediate(function() { 62 | q.drain(); 63 | }); 64 | } 65 | arrayEach(data, function(task) { 66 | var item = { 67 | data: task, 68 | priority: priority, 69 | callback: typeof callback === 'function' ? callback : noop 70 | }; 71 | 72 | q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item); 73 | 74 | setImmediate(q.process); 75 | }); 76 | } 77 | 78 | // Start with a normal queue 79 | var q = queue(worker, concurrency); 80 | 81 | // Override push to accept second parameter representing priority 82 | q.push = function(data, priority, callback) { 83 | _insert(q, data, priority, callback); 84 | }; 85 | 86 | // Remove unshift function 87 | delete q.unshift; 88 | 89 | return q; 90 | } 91 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/every.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe("every", function () { 5 | 6 | it('everyLimit true', function(done){ 7 | async.everyLimit([3,1,2], 1, function(x, callback){ 8 | setTimeout(function(){callback(null, x >= 1);}, 0); 9 | }, function(err, result){ 10 | expect(err).to.equal(null); 11 | expect(result).to.equal(true); 12 | done(); 13 | }); 14 | }); 15 | 16 | it('everyLimit false', function(done){ 17 | async.everyLimit([3,1,2], 2, function(x, callback){ 18 | setTimeout(function(){callback(null, x === 2);}, 0); 19 | }, function(err, result){ 20 | expect(err).to.equal(null); 21 | expect(result).to.equal(false); 22 | done(); 23 | }); 24 | }); 25 | 26 | it('everyLimit short-circuit', function(done){ 27 | var calls = 0; 28 | async.everyLimit([3,1,2], 1, function(x, callback){ 29 | calls++; 30 | callback(null, x === 1); 31 | }, function(err, result){ 32 | expect(err).to.equal(null); 33 | expect(result).to.equal(false); 34 | expect(calls).to.equal(1); 35 | done(); 36 | }); 37 | }); 38 | 39 | 40 | it('true', function(done){ 41 | async.every([1,2,3], function(x, callback){ 42 | setTimeout(function(){callback(null, true);}, 0); 43 | }, function(err, result){ 44 | expect(err).to.equal(null); 45 | expect(result).to.equal(true); 46 | done(); 47 | }); 48 | }); 49 | 50 | it('false', function(done){ 51 | async.every([1,2,3], function(x, callback){ 52 | setTimeout(function(){callback(null, x % 2);}, 0); 53 | }, function(err, result){ 54 | expect(err).to.equal(null); 55 | expect(result).to.equal(false); 56 | done(); 57 | }); 58 | }); 59 | 60 | it('early return', function(done){ 61 | var call_order = []; 62 | async.every([1,2,3], function(x, callback){ 63 | setTimeout(function(){ 64 | call_order.push(x); 65 | callback(null, x === 1); 66 | }, x*5); 67 | }, function(){ 68 | call_order.push('callback'); 69 | }); 70 | setTimeout(function(){ 71 | expect(call_order).to.eql([1,2,'callback',3]); 72 | done(); 73 | }, 25); 74 | }); 75 | 76 | it('error', function(done){ 77 | async.every([1,2,3], function(x, callback){ 78 | setTimeout(function(){callback('error');}, 0); 79 | }, function(err, result){ 80 | expect(err).to.equal('error'); 81 | expect(result).to.not.exist; 82 | done(); 83 | }); 84 | }); 85 | 86 | it('all alias', function(){ 87 | expect(async.all).to.equal(async.every); 88 | }); 89 | 90 | it('allLimit alias', function(){ 91 | expect(async.allLimit).to.equal(async.everyLimit); 92 | }); 93 | 94 | it('allSeries alias', function(){ 95 | expect(async.allSeries).to.be.a('function'); 96 | expect(async.allSeries).to.equal(async.everySeries); 97 | }); 98 | 99 | }); 100 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/until.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('until', function(){ 6 | it('until', function(done) { 7 | var call_order = []; 8 | var count = 0; 9 | async.until( 10 | function () { 11 | call_order.push(['test', count]); 12 | return (count == 5); 13 | }, 14 | function (cb) { 15 | call_order.push(['iteratee', count]); 16 | count++; 17 | cb(null, count); 18 | }, 19 | function (err, result) { 20 | assert(err === null, err + " passed instead of 'null'"); 21 | expect(result).to.equal(5, 'last result passed through'); 22 | expect(call_order).to.eql([ 23 | ['test', 0], 24 | ['iteratee', 0], ['test', 1], 25 | ['iteratee', 1], ['test', 2], 26 | ['iteratee', 2], ['test', 3], 27 | ['iteratee', 3], ['test', 4], 28 | ['iteratee', 4], ['test', 5], 29 | ]); 30 | expect(count).to.equal(5); 31 | done(); 32 | } 33 | ); 34 | }); 35 | 36 | it('doUntil', function(done) { 37 | var call_order = []; 38 | var count = 0; 39 | async.doUntil( 40 | function (cb) { 41 | call_order.push(['iteratee', count]); 42 | count++; 43 | cb(null, count); 44 | }, 45 | function () { 46 | call_order.push(['test', count]); 47 | return (count == 5); 48 | }, 49 | function (err, result) { 50 | assert(err === null, err + " passed instead of 'null'"); 51 | expect(result).to.equal(5, 'last result passed through'); 52 | expect(call_order).to.eql([ 53 | ['iteratee', 0], ['test', 1], 54 | ['iteratee', 1], ['test', 2], 55 | ['iteratee', 2], ['test', 3], 56 | ['iteratee', 3], ['test', 4], 57 | ['iteratee', 4], ['test', 5] 58 | ]); 59 | expect(count).to.equal(5); 60 | done(); 61 | } 62 | ); 63 | }); 64 | 65 | it('doUntil callback params', function(done) { 66 | var call_order = []; 67 | var count = 0; 68 | async.doUntil( 69 | function (cb) { 70 | call_order.push(['iteratee', count]); 71 | count++; 72 | cb(null, count); 73 | }, 74 | function (c) { 75 | call_order.push(['test', c]); 76 | return (c == 5); 77 | }, 78 | function (err, result) { 79 | if (err) throw err; 80 | expect(result).to.equal(5, 'last result passed through'); 81 | expect(call_order).to.eql([ 82 | ['iteratee', 0], ['test', 1], 83 | ['iteratee', 1], ['test', 2], 84 | ['iteratee', 2], ['test', 3], 85 | ['iteratee', 3], ['test', 4], 86 | ['iteratee', 4], ['test', 5] 87 | ]); 88 | expect(count).to.equal(5); 89 | done(); 90 | } 91 | ); 92 | }); 93 | }); 94 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/applyEach.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('applyEach', function () { 6 | 7 | it('applyEach', function (done) { 8 | var call_order = []; 9 | var one = function (val, cb) { 10 | expect(val).to.equal(5); 11 | setTimeout(function () { 12 | call_order.push('one'); 13 | cb(null, 1); 14 | }, 10); 15 | }; 16 | var two = function (val, cb) { 17 | expect(val).to.equal(5); 18 | setTimeout(function () { 19 | call_order.push('two'); 20 | cb(null, 2); 21 | }, 5); 22 | }; 23 | var three = function (val, cb) { 24 | expect(val).to.equal(5); 25 | setTimeout(function () { 26 | call_order.push('three'); 27 | cb(null, 3); 28 | }, 15); 29 | }; 30 | async.applyEach([one, two, three], 5, function (err, results) { 31 | assert(err === null, err + " passed instead of 'null'"); 32 | expect(call_order).to.eql(['two', 'one', 'three']); 33 | expect(results).to.eql([1, 2, 3]); 34 | done(); 35 | }); 36 | }); 37 | 38 | it('applyEachSeries', function (done) { 39 | var call_order = []; 40 | var one = function (val, cb) { 41 | expect(val).to.equal(5); 42 | setTimeout(function () { 43 | call_order.push('one'); 44 | cb(null, 1); 45 | }, 10); 46 | }; 47 | var two = function (val, cb) { 48 | expect(val).to.equal(5); 49 | setTimeout(function () { 50 | call_order.push('two'); 51 | cb(null, 2); 52 | }, 5); 53 | }; 54 | var three = function (val, cb) { 55 | expect(val).to.equal(5); 56 | setTimeout(function () { 57 | call_order.push('three'); 58 | cb(null, 3); 59 | }, 15); 60 | }; 61 | async.applyEachSeries([one, two, three], 5, function (err, results) { 62 | assert(err === null, err + " passed instead of 'null'"); 63 | expect(call_order).to.eql(['one', 'two', 'three']); 64 | expect(results).to.eql([1, 2, 3]); 65 | done(); 66 | }); 67 | }); 68 | 69 | it('applyEach partial application', function (done) { 70 | var call_order = []; 71 | var one = function (val, cb) { 72 | expect(val).to.equal(5); 73 | setTimeout(function () { 74 | call_order.push('one'); 75 | cb(null, 1); 76 | }, 10); 77 | }; 78 | var two = function (val, cb) { 79 | expect(val).to.equal(5); 80 | setTimeout(function () { 81 | call_order.push('two'); 82 | cb(null, 2); 83 | }, 5); 84 | }; 85 | var three = function (val, cb) { 86 | expect(val).to.equal(5); 87 | setTimeout(function () { 88 | call_order.push('three'); 89 | cb(null, 3); 90 | }, 15); 91 | }; 92 | async.applyEach([one, two, three])(5, function (err, results) { 93 | if (err) throw err; 94 | expect(call_order).to.eql(['two', 'one', 'three']); 95 | expect(results).to.eql([1, 2, 3]); 96 | done(); 97 | }); 98 | }); 99 | }); 100 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/seq.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | var assert = require('assert'); 4 | 5 | describe('seq', function() { 6 | 7 | it('seq', function(done) { 8 | var add2 = function (n, cb) { 9 | expect(n).to.equal(3); 10 | setTimeout(function () { 11 | cb(null, n + 2); 12 | }, 50); 13 | }; 14 | var mul3 = function (n, cb) { 15 | expect(n).to.equal(5); 16 | setTimeout(function () { 17 | cb(null, n * 3); 18 | }, 15); 19 | }; 20 | var add1 = function (n, cb) { 21 | expect(n).to.equal(15); 22 | setTimeout(function () { 23 | cb(null, n + 1); 24 | }, 100); 25 | }; 26 | var add2mul3add1 = async.seq(add2, mul3, add1); 27 | add2mul3add1(3, function (err, result) { 28 | if (err) { 29 | return done(err); 30 | } 31 | assert(err === null, err + " passed instead of 'null'"); 32 | expect(result).to.equal(16); 33 | done(); 34 | }); 35 | }); 36 | 37 | it('seq error', function(done) { 38 | var testerr = new Error('test'); 39 | 40 | var add2 = function (n, cb) { 41 | expect(n).to.equal(3); 42 | setTimeout(function () { 43 | cb(null, n + 2); 44 | }, 50); 45 | }; 46 | var mul3 = function (n, cb) { 47 | expect(n).to.equal(5); 48 | setTimeout(function () { 49 | cb(testerr); 50 | }, 15); 51 | }; 52 | var add1 = function (n, cb) { 53 | assert(false, 'add1 should not get called'); 54 | setTimeout(function () { 55 | cb(null, n + 1); 56 | }, 100); 57 | }; 58 | var add2mul3add1 = async.seq(add2, mul3, add1); 59 | add2mul3add1(3, function (err) { 60 | expect(err).to.equal(testerr); 61 | done(); 62 | }); 63 | }); 64 | 65 | it('seq binding', function(done) { 66 | var testcontext = {name: 'foo'}; 67 | 68 | var add2 = function (n, cb) { 69 | expect(this).to.equal(testcontext); 70 | setTimeout(function () { 71 | cb(null, n + 2); 72 | }, 50); 73 | }; 74 | var mul3 = function (n, cb) { 75 | expect(this).to.equal(testcontext); 76 | setTimeout(function () { 77 | cb(null, n * 3); 78 | }, 15); 79 | }; 80 | var add2mul3 = async.seq(add2, mul3); 81 | add2mul3.call(testcontext, 3, function (err, result) { 82 | if (err) { 83 | return done(err); 84 | } 85 | expect(this).to.equal(testcontext); 86 | expect(result).to.equal(15); 87 | done(); 88 | }); 89 | }); 90 | 91 | it('seq without callback', function(done) { 92 | var testcontext = {name: 'foo'}; 93 | 94 | var add2 = function (n, cb) { 95 | expect(this).to.equal(testcontext); 96 | setTimeout(function () { 97 | cb(null, n + 2); 98 | }, 50); 99 | }; 100 | var mul3 = function () { 101 | expect(this).to.equal(testcontext); 102 | setTimeout(function () { 103 | done(); 104 | }, 15); 105 | }; 106 | var add2mul3 = async.seq(add2, mul3); 107 | add2mul3.call(testcontext, 3); 108 | }); 109 | }); 110 | -------------------------------------------------------------------------------- /AlexaCloudTrailDesignTemplate: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion": "2010-09-09", 3 | "Metadata": { 4 | "AWS::CloudFormation::Designer": { 5 | "6ee0b0e3-9f0c-44e0-84de-81ad59fcf431": { 6 | "size": { 7 | "width": 60, 8 | "height": 60 9 | }, 10 | "position": { 11 | "x": 440, 12 | "y": 230 13 | }, 14 | "z": 0, 15 | "embeds": [] 16 | }, 17 | "1bc4b3ee-32fd-408b-9046-262eb15c5ca5": { 18 | "size": { 19 | "width": 60, 20 | "height": 60 21 | }, 22 | "position": { 23 | "x": 150, 24 | "y": 230 25 | }, 26 | "z": 0, 27 | "embeds": [], 28 | "dependson": [ 29 | "6ee0b0e3-9f0c-44e0-84de-81ad59fcf431" 30 | ], 31 | "isrelatedto": [ 32 | "6ee0b0e3-9f0c-44e0-84de-81ad59fcf431" 33 | ] 34 | }, 35 | "bb393217-baa1-4525-8b83-b19bafbbaede": { 36 | "source": { 37 | "id": "1bc4b3ee-32fd-408b-9046-262eb15c5ca5" 38 | }, 39 | "target": { 40 | "id": "6ee0b0e3-9f0c-44e0-84de-81ad59fcf431" 41 | }, 42 | "z": 1 43 | } 44 | } 45 | }, 46 | "Resources": { 47 | "AlexaIntegrationWithCloudTrail": { 48 | "Type": "AWS::Lambda::Function", 49 | "Properties": { 50 | "Handler": "index.handler", 51 | "Role": { 52 | "Fn::GetAtt": [ 53 | "ExecuteAlexaIntegrationWithCloudTrail", 54 | "Arn" 55 | ] 56 | }, 57 | "Code": { 58 | "ZipFile": "AAA" 59 | }, 60 | "Runtime": "nodejs4.3", 61 | "Timeout": "60" 62 | }, 63 | "Metadata": { 64 | "AWS::CloudFormation::Designer": { 65 | "id": "1bc4b3ee-32fd-408b-9046-262eb15c5ca5" 66 | } 67 | }, 68 | "DependsOn": [ 69 | "ExecuteAlexaIntegrationWithCloudTrail" 70 | ] 71 | }, 72 | "ExecuteAlexaIntegrationWithCloudTrail": { 73 | "Type": "AWS::IAM::Role", 74 | "Properties": { 75 | "AssumeRolePolicyDocument": { 76 | "Version": "2012-10-17", 77 | "Statement": [ 78 | { 79 | "Effect": "Allow", 80 | "Principal": { 81 | "Service": [ 82 | "lambda.amazonaws.com" 83 | ] 84 | }, 85 | "Action": [ 86 | "sts:AssumeRole" 87 | ] 88 | } 89 | ] 90 | }, 91 | "ManagedPolicyArns": [ 92 | "arn:aws:iam::aws:policy/AWSCloudTrailReadOnlyAccess", 93 | "arn:aws:iam::aws:policy/AmazonSESFullAccess", 94 | "arn:aws:iam::aws:policy/AmazonSNSFullAccess" 95 | ], 96 | "Path": "/", 97 | "Policies": [ 98 | { 99 | "PolicyName": "root", 100 | "PolicyDocument": { 101 | "Version": "2012-10-17", 102 | "Statement": [ 103 | { 104 | "Effect": "Allow", 105 | "Action": [ 106 | "logs:CreateLogGroup", 107 | "logs:CreateLogStream", 108 | "logs:PutLogEvents", 109 | "ses:sendEmail" 110 | ], 111 | "Resource": "*" 112 | } 113 | ] 114 | } 115 | } 116 | ] 117 | }, 118 | "Metadata": { 119 | "AWS::CloudFormation::Designer": { 120 | "id": "6ee0b0e3-9f0c-44e0-84de-81ad59fcf431" 121 | } 122 | } 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /Lambda Files/async/Makefile: -------------------------------------------------------------------------------- 1 | # This makefile is meant to be run on OSX/Linux. Make sure any artifacts 2 | # created here are checked in so people on all platforms can run npm scripts. 3 | # This build should be run once per release. 4 | 5 | SHELL=/bin/bash 6 | export PATH := ./node_modules/.bin/:$(PATH):./bin/ 7 | 8 | PACKAGE = asyncjs 9 | REQUIRE_NAME = async 10 | BABEL_NODE = babel-node 11 | UGLIFY = uglifyjs 12 | XYZ = support/xyz.sh --repo git@github.com:caolan/async.git 13 | 14 | BUILDDIR = build 15 | BUILD_ES = build-es 16 | DIST = dist 17 | SRC = lib/index.js 18 | SCRIPTS = ./support 19 | JS_SRC = $(shell find lib/ -type f -name '*.js') 20 | LINT_FILES = lib/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) support/ karma.conf.js 21 | 22 | UMD_BUNDLE = $(BUILDDIR)/dist/async.js 23 | UMD_BUNDLE_MIN = $(BUILDDIR)/dist/async.min.js 24 | CJS_BUNDLE = $(BUILDDIR)/index.js 25 | ES_MODULES = $(patsubst lib/%.js, build-es/%.js, $(JS_SRC)) 26 | 27 | 28 | all: clean lint build test 29 | 30 | test: 31 | npm test 32 | 33 | clean: 34 | rm -rf $(BUILDDIR) 35 | rm -rf $(BUILD_ES) 36 | rm -rf $(DIST) 37 | rm -rf tmp/ 38 | 39 | lint: 40 | eslint $(LINT_FILES) 41 | 42 | # Compile the ES6 modules to singular bundles, and individual bundles 43 | build-bundle: build-modules $(UMD_BUNDLE) $(CJS_BUNDLE) 44 | 45 | build-modules: 46 | $(BABEL_NODE) $(SCRIPTS)/build/modules-cjs.js 47 | 48 | $(UMD_BUNDLE): $(JS_SRC) package.json 49 | mkdir -p "$(@D)" 50 | $(BABEL_NODE) $(SCRIPTS)/build/aggregate-bundle.js 51 | 52 | $(CJS_BUNDLE): $(JS_SRC) package.json 53 | $(BABEL_NODE) $(SCRIPTS)/build/aggregate-cjs.js 54 | 55 | # Create the minified UMD versions and copy them to dist/ for bower 56 | build-dist: $(DIST) $(UMD_BUNDLE) $(UMD_BUNDLE_MIN) $(DIST)/async.js $(DIST)/async.min.js 57 | 58 | $(DIST): 59 | mkdir -p $@ 60 | 61 | $(UMD_BUNDLE_MIN): $(UMD_BUNDLE) 62 | mkdir -p "$(@D)" 63 | $(UGLIFY) $< --mangle --compress \ 64 | --source-map $(DIST)/async.min.map \ 65 | --source-map-url async.min.map \ 66 | -o $@ 67 | 68 | $(DIST)/async.js: $(UMD_BUNDLE) 69 | cp $< $@ 70 | 71 | $(DIST)/async.min.js: $(UMD_BUNDLE_MIN) 72 | cp $< $@ 73 | 74 | build-es: $(ES_MODULES) 75 | 76 | $(BUILD_ES)/%.js: lib/%.js 77 | mkdir -p "$(@D)" 78 | sed -E "s/(import.+)lodash/\1lodash-es/g" $< > $@ 79 | 80 | test-build: 81 | mocha support/build.test.js 82 | 83 | build-config: $(BUILDDIR)/package.json $(BUILDDIR)/bower.json $(BUILDDIR)/README.md $(BUILDDIR)/LICENSE $(BUILDDIR)/CHANGELOG.md 84 | 85 | build-es-config: $(BUILD_ES)/package.json $(BUILD_ES)/README.md $(BUILD_ES)/LICENSE $(BUILD_ES)/CHANGELOG.md 86 | 87 | $(BUILDDIR)/package.json: package.json 88 | mkdir -p "$(@D)" 89 | support/sync-cjs-package.js > $@ 90 | 91 | $(BUILDDIR)/%: % 92 | mkdir -p "$(@D)" 93 | cp $< $@ 94 | 95 | $(BUILD_ES)/package.json: package.json 96 | mkdir -p "$(@D)" 97 | support/sync-es-package.js > $@ 98 | 99 | $(BUILD_ES)/%: % 100 | mkdir -p "$(@D)" 101 | cp $< $@ 102 | 103 | .PHONY: build-modules build-bundle build-dist build-es build-config build-es-config test-build 104 | 105 | build: clean build-bundle build-dist build-es build-config build-es-config test-build 106 | 107 | .PHONY: test lint build all clean 108 | 109 | .PHONY: release-major release-minor release-patch release-prerelease 110 | release-major release-minor release-patch release-prerelease: all 111 | npm i # ensure dependencies are up to date (#1158) 112 | git add --force $(DIST) 113 | git commit -am "Update built files"; true 114 | $(XYZ) --increment $(@:release-%=%) 115 | # build again to propagate the version 116 | $(MAKE) build-config 117 | $(MAKE) build-es-config 118 | cd build/ && npm publish 119 | cd build-es/ && npm publish 120 | -------------------------------------------------------------------------------- /Lambda Files/async/mocha_test/some.js: -------------------------------------------------------------------------------- 1 | var async = require('../lib'); 2 | var expect = require('chai').expect; 3 | 4 | describe("some", function () { 5 | 6 | it('some true', function(done){ 7 | async.some([3,1,2], function(x, callback){ 8 | setTimeout(function(){callback(null, x === 1);}, 0); 9 | }, function(err, result){ 10 | expect(err).to.equal(null); 11 | expect(result).to.equal(true); 12 | done(); 13 | }); 14 | }); 15 | 16 | it('some false', function(done){ 17 | async.some([3,1,2], function(x, callback){ 18 | setTimeout(function(){callback(null, x === 10);}, 0); 19 | }, function(err, result){ 20 | expect(err).to.equal(null); 21 | expect(result).to.equal(false); 22 | done(); 23 | }); 24 | }); 25 | 26 | it('some early return', function(done){ 27 | var call_order = []; 28 | async.some([1,2,3], function(x, callback){ 29 | setTimeout(function(){ 30 | call_order.push(x); 31 | callback(null, x === 1); 32 | }, x*5); 33 | }, function(){ 34 | call_order.push('callback'); 35 | }); 36 | setTimeout(function(){ 37 | expect(call_order).to.eql([1,'callback',2,3]); 38 | done(); 39 | }, 25); 40 | }); 41 | 42 | it('some error', function(done){ 43 | async.some([3,1,2], function(x, callback){ 44 | setTimeout(function(){callback('error');}, 0); 45 | }, function(err, result){ 46 | expect(err).to.equal('error'); 47 | expect(result).to.not.exist; 48 | done(); 49 | }); 50 | }); 51 | 52 | it('some no callback', function(done) { 53 | var calls = []; 54 | 55 | async.some([1, 2, 3], function (val, cb) { 56 | calls.push(val); 57 | cb(); 58 | }); 59 | 60 | setTimeout(function () { 61 | expect(calls).to.eql([1, 2, 3]); 62 | done(); 63 | }, 10); 64 | }); 65 | 66 | it('someLimit true', function(done){ 67 | async.someLimit([3,1,2], 2, function(x, callback){ 68 | setTimeout(function(){callback(null, x === 2);}, 0); 69 | }, function(err, result){ 70 | expect(err).to.equal(null); 71 | expect(result).to.equal(true); 72 | done(); 73 | }); 74 | }); 75 | 76 | it('someLimit false', function(done){ 77 | async.someLimit([3,1,2], 2, function(x, callback){ 78 | setTimeout(function(){callback(null, x === 10);}, 0); 79 | }, function(err, result){ 80 | expect(err).to.equal(null); 81 | expect(result).to.equal(false); 82 | done(); 83 | }); 84 | }); 85 | 86 | 87 | it('someLimit short-circuit', function(done){ 88 | var calls = 0; 89 | async.someLimit([3,1,2], 1, function(x, callback){ 90 | calls++; 91 | callback(null, x === 1); 92 | }, function(err, result){ 93 | expect(err).to.equal(null); 94 | expect(result).to.equal(true); 95 | expect(calls).to.equal(2); 96 | done(); 97 | }); 98 | }); 99 | 100 | it('any alias', function(){ 101 | expect(async.any).to.equal(async.some); 102 | }); 103 | 104 | it('anyLimit alias', function(){ 105 | expect(async.anyLimit).to.equal(async.someLimit); 106 | }); 107 | 108 | it('anySeries alias', function(){ 109 | expect(async.anySeries).to.be.a('function'); 110 | expect(async.anySeries).to.equal(async.someSeries); 111 | }); 112 | 113 | 114 | }); 115 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/awslabs/aws-cloudtrail-alexa/issues), or [recently closed](https://github.com/awslabs/aws-cloudtrail-alexa/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/awslabs/aws-cloudtrail-alexa/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/awslabs/aws-cloudtrail-alexa/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /Alexa Files/IntentSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "intents":[ 3 | { 4 | "intent":"GetCloudTrailData", 5 | "slots":[ 6 | { 7 | "name":"AttributeKey", 8 | "type":"LIST_OF_ATTRIBUTES" 9 | }, 10 | { 11 | "name":"AttributeValue", 12 | "type":"LIST_OF_VALUES" 13 | }, 14 | { 15 | "name":"StartDate", 16 | "type":"AMAZON.DATE" 17 | }, 18 | { 19 | "name":"EndDate", 20 | "type":"AMAZON.DATE" 21 | } 22 | ] 23 | }, 24 | { 25 | "intent":"LookupByEventName", 26 | "slots":[ 27 | { 28 | "name":"EventName", 29 | "type":"LIST_OF_EVENT_NAMES" 30 | }, 31 | { 32 | "name":"StartDate", 33 | "type":"AMAZON.DATE" 34 | }, 35 | { 36 | "name":"EndDate", 37 | "type":"AMAZON.DATE" 38 | } 39 | ] 40 | }, 41 | { 42 | "intent":"GetUserActivity", 43 | "slots":[ 44 | { 45 | "name":"Username", 46 | "type":"LIST_OF_USERNAMES" 47 | }, 48 | { 49 | "name":"StartDate", 50 | "type":"AMAZON.DATE" 51 | }, 52 | { 53 | "name":"EndDate", 54 | "type":"AMAZON.DATE" 55 | } 56 | ] 57 | }, 58 | { 59 | "intent":"GetEventsByDate", 60 | "slots":[ 61 | { 62 | "name":"StartDate", 63 | "type":"AMAZON.DATE" 64 | }, 65 | { 66 | "name":"EndDate", 67 | "type":"AMAZON.DATE" 68 | } 69 | ] 70 | }, 71 | { 72 | "intent":"SetRegion", 73 | "slots":[ 74 | { 75 | "name":"RegionName", 76 | "type":"LIST_OF_REGIONS" 77 | } 78 | ] 79 | }, 80 | { 81 | "intent":"SetPositiveTimeOffset", 82 | "slots":[ 83 | { 84 | "name":"TimeOffset", 85 | "type":"AMAZON.NUMBER" 86 | } 87 | ] 88 | }, 89 | { 90 | "intent":"SetNegativeTimeOffset", 91 | "slots":[ 92 | { 93 | "name":"TimeOffset", 94 | "type":"AMAZON.NUMBER" 95 | } 96 | ] 97 | }, 98 | { 99 | "intent":"EnableEmail" 100 | }, 101 | { 102 | "intent":"DisableEmail" 103 | }, 104 | { 105 | "intent":"AMAZON.StopIntent" 106 | }, 107 | { 108 | "intent":"AMAZON.CancelIntent" 109 | }, 110 | { 111 | "intent":"GetResourceActivity", 112 | "slots":[ 113 | { 114 | "name":"StartDate", 115 | "type":"AMAZON.DATE" 116 | }, 117 | { 118 | "name":"ResourceValue", 119 | "type":"LIST_OF_RESOURCES" 120 | } 121 | ] 122 | }, 123 | { 124 | "intent":"ValidatePIN", 125 | "slots":[ 126 | { 127 | "name":"UserPIN", 128 | "type":"AMAZON.NUMBER" 129 | } 130 | ] 131 | } 132 | ] 133 | } --------------------------------------------------------------------------------