### Install isarray with component Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/isarray/README.md Install the 'isarray' package using the component package manager. ```bash $ component install juliangruber/isarray ``` -------------------------------- ### Install safe-buffer Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/safe-buffer/README.md Install the package using npm. ```bash npm install safe-buffer ``` -------------------------------- ### Installation Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/base64-js/README.md Instructions on how to install and require the base64-js library using npm, and how to include it in web browsers. ```APIDOC ## Installation With [npm](https://npmjs.org) do: `npm install base64-js` and `var base64js = require('base64-js')` For use in web browsers do: `` ``` -------------------------------- ### Install object-inspect via npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object-inspect/readme.markdown Instructions for installing the object-inspect package using npm. ```bash npm install object-inspect ``` -------------------------------- ### Object.assign Test Suite Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Initializes the tape test suite for the Object.assign polyfill, starting with tests for handling invalid array or 'this' values. ```javascript var test = require('tape'); var runTests = require('./tests'); test('as a function', function (t) { t.test('bad array/this value', function (st) { ``` -------------------------------- ### Install xmlbuilder-js Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/xmlbuilder/README.md Install the xmlbuilder package using npm. ```sh npm install xmlbuilder ``` -------------------------------- ### Install isarray with npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/isarray/README.md Install the 'isarray' package using npm for use in your Node.js projects or for browserify bundling. ```bash $ npm install isarray ``` -------------------------------- ### Install buffer module Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/buffer/README.md Install the buffer module using npm for direct usage. ```bash npm install buffer ``` -------------------------------- ### Install node-fetch Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/node-fetch/README.md Install the latest stable release of node-fetch using npm. ```sh $ npm install node-fetch ``` -------------------------------- ### Example: Shim Object.keys When Present Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object-keys/README.md This example shows how to use the shim method when Object.keys is already present in the environment. The shim method will return the original Object.keys function. ```javascript var keys = require('object-keys'); var assert = require('assert'); /* when Object.keys is present */ var shimmedKeys = keys.shim(); assert.equal(shimmedKeys, Object.keys); assert.deepEqual(Object.keys(obj), keys(obj)); ``` -------------------------------- ### Install querystring Module Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/querystring/Readme.md Use npm to install the querystring module for your Node.js project. ```bash npm install querystring ``` -------------------------------- ### Install uuid Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/uuid/README.md Install the uuid package using npm. ```shell npm install uuid ``` -------------------------------- ### Install Punycode.js via Component Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/punycode/README.md Install the Punycode.js library using the Component package manager. ```bash component install bestiejs/punycode.js ``` -------------------------------- ### Example: Using object-keys When Object.keys is Absent Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object-keys/README.md This example shows how to use the 'object-keys' module when the native Object.keys method is not present. It demonstrates deleting Object.keys and then using the shimmed version. ```javascript var keys = require('object-keys'); var assert = require('assert'); var obj = { a: true, b: true, c: true }; assert.deepEqual(keys(obj), ['a', 'b', 'c']); ``` -------------------------------- ### Install util with npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/util/README.md Install the util module using npm if your environment does not include it by default and bundlers are not used. ```shell npm install util ``` -------------------------------- ### Install Punycode.js via Bower Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/punycode/README.md Install the Punycode.js library using Bower for front-end projects. ```bash bower install punycode ``` -------------------------------- ### Example: Shim Object.keys When Not Present Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object-keys/README.md This example demonstrates how to shim Object.keys when it is not available in the environment. It explicitly deletes Object.keys to simulate its absence and then calls the shim method. ```javascript var keys = require('object-keys'); var assert = require('assert'); /* when Object.keys is not present */ delete Object.keys; var shimmedKeys = keys.shim(); assert.equal(shimmedKeys, keys); assert.deepEqual(Object.keys(obj), keys(obj)); ``` -------------------------------- ### Install the 'has' module Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/has/README.md Install the 'has' module using npm for use in your project. ```sh npm install --save has ``` -------------------------------- ### Test Suite Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Sets up a test function that creates and manages test instances. It allows for defining tests with names, configurations, and callbacks. ```javascript module.exports.createHarness = createHarness; module.exports.Test = Test; module.exports.test = module.exports; // tap compat module.exports.test.skip = Test.skip; function createHarness(conf_) { var results = createResult(); if (!conf_ || conf_.autoclose !== false) { results.once('done', function () { results.close(); }); } var test = function (name, conf, cb) { var t = new Test(name, conf, cb); test._tests.push(t); (function (t) { t.on('end', function () { results.push(t); }); })(t); return t; }; test._tests = []; test.createStream = function (opts) { return results.createStream(opts); }; test.run = function () { for (var i = 0; i < test._tests.length; i++) { test._tests[i].run(); } }; return test; } ``` -------------------------------- ### Install Node.js Events Module Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/events/Readme.md Install the events module using npm. This is the first step to using event-driven programming in Node.js. ```bash npm install events ``` -------------------------------- ### Object.assign Polyfill Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html This snippet shows how to set up the Object.assign polyfill, making it available globally or for specific modules. ```javascript 'use strict'; var defineProperties = require('define-properties'); var callBind = require('call-bind'); var implementation = require('./implementation'); var getPolyfill = require('./polyfill'); var shim = require('./shim'); var polyfill = callBind.apply(getPolyfill()); // eslint-disable-next-line no-unused-vars var bound = function assign(target, source1) { return polyfill(Object, arguments); }; defineProperties(bound, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = bound; ``` -------------------------------- ### Basic Transform Stream Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html A minimal example demonstrating a transform stream that processes chunks and signals completion. ```javascript // A bit simpler than readable stream ``` -------------------------------- ### Install is-callable via npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/is-callable/README.md Install the is-callable package using npm for use in your Node.js projects. ```bash npm install is-callable ``` -------------------------------- ### Test Suite Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Sets up the test environment for the object.assign polyfill. It requires necessary modules like 'defined', 'createDefaultStream', 'Test', 'createResult', and 'through'. ```javascript "use strict"; var defined = require('defined'); var createDefaultStream = require('./lib/default_stream'); var Test = require('./lib/test'); var createResult = require('./lib/results'); var through = require('through'); var canEmitEx ``` -------------------------------- ### Install base64-js with npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/base64-js/README.md Install the base64-js module using npm and require it in your Node.js project. ```javascript npm install base64-js var base64js = require('base64-js') ``` -------------------------------- ### Install Punycode.js via npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/punycode/README.md Use npm to install the Punycode.js library, primarily for Node.js versions older than v0.6.2. ```bash npm install punycode ``` -------------------------------- ### Basic Usage Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/webidl-conversions/README.md Demonstrates how to use the webidl-conversions package to convert JavaScript values to specific WebIDL types. ```APIDOC ## Basic Usage This package's main module's default export is an object with a variety of methods, each corresponding to a different WebIDL type. Each method, when invoked on a JavaScript value, will give back the new JavaScript value that results after passing through the WebIDL conversion rules. ### Example ```js const conversions = require("webidl-conversions"); function doStuff(x, y) { x = conversions["boolean"](x); y = conversions["unsigned long"](y); // actual algorithm code here } ``` This example shows how `conversions["boolean"](x)` and `conversions["unsigned long"](y)` convert the JavaScript values `x` and `y` according to their respective WebIDL types, mimicking the behavior of a WebIDL operation `void doStuff(boolean x, unsigned long y);`. ``` -------------------------------- ### Object.is polyfill setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Provides a polyfill for Object.is, including its implementation, getter, and shim. ```javascript var define = require('define-properties'); var callBind = require('call-bind'); var implementation = require('./implementation'); var getPolyfill = require('./polyfill'); var shim = require('./shim'); var polyfill = callBind(getPolyfill(), Object); define(polyfill, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = polyfill; ``` -------------------------------- ### Install ieee754 Module Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/ieee754/README.md Use npm to install the ieee754 module. This is the standard way to add packages to your Node.js project. ```bash npm install ieee754 ``` -------------------------------- ### Example Usage Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object-inspect/readme.markdown Demonstrates how to use the inspect function with different scenarios, including circular references and DOM elements. ```javascript var inspect = require('object-inspect'); // Circular reference example var obj = { a: 1, b: [3,4] }; obj.c = obj; console.log(inspect(obj)); // DOM element example var d = document.createElement('div'); d.setAttribute('id', 'beep'); d.innerHTML = 'woooiiiii'; console.log(inspect([ d, { a: 3, b : 4, c: [5,6,[7,[8,[9]]]] } ])); ``` -------------------------------- ### Vulnerable HTTP Server Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/safe-buffer/README.md This example demonstrates a common vulnerability where user input is directly used to create a Buffer without type checking, potentially leading to memory disclosure. ```javascript var server = http.createServer(function (req, res) { var data = '' req.setEncoding('utf8') req.on('data', function (chunk) { data += chunk }) req.on('end', function () { var body = JSON.parse(data) res.end(new Buffer(body.str).toString('hex')) }) }) server.listen(8080) ``` -------------------------------- ### Get and Cache JS Intrinsics Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/get-intrinsic/README.md Use `GetIntrinsic` to retrieve and cache language-level intrinsics. This example shows how to access static methods like `Math.pow`, instance methods like `Array.prototype.push`, and how the package handles missing features by throwing an error or returning undefined. ```javascript var GetIntrinsic = require('get-intrinsic'); var assert = require('assert'); // static methods assert.equal(GetIntrinsic('%Math.pow%'), Math.pow); assert.equal(Math.pow(2, 3), 8); assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); delete Math.pow; assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8); // instance methods var arr = [1]; assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push); assert.deepEqual(arr, [1]); arr.push(2); assert.deepEqual(arr, [1, 2]); GetIntrinsic('%Array.prototype.push%').call(arr, 3); assert.deepEqual(arr, [1, 2, 3]); delete Array.prototype.push; GetIntrinsic('%Array.prototype.push%').call(arr, 4); assert.deepEqual(arr, [1, 2, 3, 4]); // missing features delete JSON.parse; // to simulate a real intrinsic that is missing in the environment assert.throws(() => GetIntrinsic('%JSON.parse%')); assert.equal(undefined, GetIntrinsic('%JSON.parse%', true)); ``` -------------------------------- ### Perform an HTTP GET request Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html A convenience function to perform an HTTP GET request. It calls http.request with the method set to 'GET' and immediately ends the request. ```javascript http.get = function (params, cb) { params.method = 'GET'; var req = http.request(params, cb); req.end(); return req; }; ``` -------------------------------- ### Common Usage of String.prototype.trimStart Shim Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/string.prototype.trimstart/README.md Demonstrates the most common usage pattern for the trimStart shim. It shows how to import the shim, use it for trimming, and conditionally apply it if the native method is not available. ```javascript var trimStart = require('string.prototype.trimstart'); assert(trimStart(' a ') === 'a '); if (!String.prototype.trimStart) { trimStart.shim(); } assert(trimStart(' a ') === ' a '.trimStart()); ``` -------------------------------- ### Test Runner Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Initializes the test runner, sets up event listeners for test completion and failure, and defines methods for creating streams and handling 'only' tests. ```javascript "use strict"; var through = require('through'); var fs = require('fs'); module.exports = function () { var line = ''; var stream = through(write, flush); return stream; function write(buf) { for (var i = 0; i < buf.length; i++) { var c = typeof buf === 'string' ? buf.charAt(i) : String.fromCharCode(buf[i]); if (c === '\n') { flush(); } else { line += c; } } } function flush() { if (fs.writeSync && /win/.test(process.platform)) { try { fs.writeSync(1, line + '\n'); } catch (e) { stream.emit('error', e); } } else { try { console.log(line); // eslint-disable-line no-console } catch (e) { stream.emit('error', e); } } line = ''; } }; ``` -------------------------------- ### String Trim Polyfill Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Sets up the String.prototype.trim polyfill by defining it on the String prototype. It uses 'define-properties' to ensure compatibility and provides a test function to check if the shim is necessary. ```javascript 'use strict'; var callBind = require('call-bind'); var define = require('define-properties'); var implementation = require('./implementation'); var getPolyfill = require('./polyfill'); var shim = require('./shim'); var boundTrim = callBind(getPolyfill()); define(boundTrim, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = boundTrim; ``` -------------------------------- ### Basic Usage Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/sax/README.md Demonstrates how to instantiate and use the SAX parser with event handlers for different XML events. ```APIDOC ## Basic Usage ```javascript var sax = require("./lib/sax"), strict = true, // set to false for html-mode parser = sax.parser(strict); parser.onerror = function (e) { // an error happened. }; parser.ontext = function (t) { // got some text. t is the string of text. }; parser.onopentag = function (node) { // opened a tag. node has "name" and "attributes" }; parser.onattribute = function (attr) { // an attribute. attr has "name" and "value" }; parser.onend = function () { // parser stream is done, and ready to have more stuff written to it. }; parser.write('Hello, world!').close(); ``` ``` -------------------------------- ### Assigning Properties from Objects with `get` Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Tests how properties named `get` are handled. They should be copied like any other own property. ```javascript var obj = {}; Object.assign(obj, { get: 'test' }); console.log(obj.get === 'test'); // Should be true ``` -------------------------------- ### Basic Usage and Shim Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/string.prototype.trimend/README.md Demonstrates the most common usage of the trimEnd shim. It shows how to import the shim, use it for trimming, and conditionally apply it to String.prototype if it's not already available. ```javascript var trimEnd = require('string.prototype.trimend'); assert(trimEnd(' a ') === 'a '); if (!String.prototype.trimEnd) { trimEnd.shim(); } assert(trimEnd(' a ') === ' a '.trimEnd()); ``` -------------------------------- ### Get Object.assign Polyfill Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/README.md Use this to get the native Object.assign method if it's compliant, otherwise it returns the polyfill. ```javascript var assign = require('object.assign').getPolyfill(); ``` ```javascript var assign = require('object.assign/polyfill')(); ``` -------------------------------- ### Test Modification During [[Get]] Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Checks how Object.assign behaves when properties are modified (deleted or made non-enumerable) during the [[Get]] operation of a source property. ```javascript t.test('checks enumerability and existence, in case of modification during [[Get]]', { skip: !Object.defineProperty }, function (st) { var targetBvalue = {}; var targetCvalue = {}; var target = { b: targetBvalue, c: targetCvalue }; var source = {}; Object.defineProperty(source, 'a', { enumerable: true, get: function () { delete this.b; Object.defineProperty(this, 'c', { enumerable: false }); return 'a'; } }); var sourceBvalue = {}; var sourceCvalue = {}; source.b = sourceBvalue; source.c = sourceCvalue; var result = assign(target, source); st.equal(result, target, 'sanity check: result is === target'); st.equal(result.b, targetBvalue, 'target key not overwritten by deleted source key'); st.equal(result.c, targetCvalue, 'target key not overwritten by non-enumerable source key'); st.end(); }); ``` -------------------------------- ### Get Object's Internal toString Representation Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html A helper function to get the internal [[Class]] property of an object using Object.prototype.toString. ```javascript function objectToString(o) { return Object.prototype.toString.call(o); } ``` -------------------------------- ### Release Script for New Versions Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/aws-sdk/scripts/changelog/README.md Run this script for each release to create a new changelog entry based on JSON files in .changes/next-release/. It also creates a new version JSON file in .changes/. The .changes/ and next-release/ directories must exist prior to execution. ```bash ./scripts/changelog/release ``` ```bash ./scripts/changelog/release minor ``` -------------------------------- ### Loading node-fetch Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/node-fetch/README.md Demonstrates how to load the node-fetch module in a Node.js environment. ```javascript const fetch = require('node-fetch'); ``` -------------------------------- ### Get Symbol Description Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/get-symbol-description/README.md Use this function to get the description of a Symbol. It handles Symbols created with no arguments, empty strings, and named Symbols, as well as built-in Symbols like Symbol.iterator. ```javascript var getSymbolDescription = require('get-symbol-description'); var assert = require('assert'); assert(getSymbolDescription(Symbol()) === undefined); assert(getSymbolDescription(Symbol('')) === ''); // or `undefined`, if in an engine that lacks name inference from concise method assert(getSymbolDescription(Symbol('foo')) === 'foo'); assert(getSymbolDescription(Symbol.iterator) === 'Symbol.iterator'); ``` -------------------------------- ### Usage Example for function.prototype.name Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/function.prototype.name/README.md Demonstrates how to use the function.prototype.name shim. It first checks the function name using the shimmed function and then applies the shim to the prototype to verify its functionality. ```javascript var functionName = require('function.prototype.name'); var assert = require('assert'); assert.equal(functionName(function foo() {}), 'foo'); functionName.shim(); assert.equal(function foo() {}.name, 'foo'); ``` -------------------------------- ### WebIDL Float Conversion Error Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/webidl-conversions/README.md Illustrates that certain WebIDL conversions, like float, can throw errors if the input is invalid. For example, converting NaN to a float will result in a TypeError. ```javascript conversions["float"](NaN) ``` -------------------------------- ### Get the number of listeners for an event Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Provides a static method to get the listener count for an emitter and event type, falling back to an internal method if the emitter doesn't have a dedicated 'listenerCount' function. ```javascript EventEmitter.listenerCount = function(emitter, type) { if (typeof emitter.listenerCount === 'function') { return emitter.listenerCount(type); } else { return listenerCount.call(emitter, type); } }; ``` -------------------------------- ### Test Environment Setup for Object.assign Polyfill Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Sets up the testing environment for the object.assign polyfill. It mocks Node.js streams and process methods to work within a browser context for testing. ```javascript (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'"})}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o> 8 - idx % 1 * 8) ) { charCode = input.charCodeAt(idx += 3/4); if (charCode > 0xFF) { throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); } block = block << 8 | charCode; } return output; }); // decoder // [https://gist.github.com/1020396] by [https://github.com/atk] object.atob || ( object.atob = function (input) { input = input.replace(/=+$/, ''); if (input.length % 4 == 1) { throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); } for ( // initialize result and counters var bc = 0, bs, buffer, idx = 0, output = ''; // get next character buffer = input.charAt(idx++); // character found in table? initialize bit storage and add its ascii value; ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, // and if not first of each 4 characters, // ``` -------------------------------- ### Get Own Property Descriptor Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Retrieves the own property descriptor of an object. ```javascript "use strict"; var GetIntrinsic = require('get-intrinsic'); var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); ``` -------------------------------- ### Basic WebIDL Type Conversion Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/webidl-conversions/README.md Demonstrates how to use the webidl-conversions package to convert JavaScript values to specific WebIDL types within a function. This ensures that the function behaves consistently with its WebIDL declaration. ```javascript const conversions = require("webidl-conversions"); function doStuff(x, y) { x = conversions["boolean"](x); y = conversions["unsigned long"](y); // actual algorithm code here } ``` -------------------------------- ### Get Function Name Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Retrieves the name of a function. Returns null if the name cannot be determined. ```javascript function nameOf(f) { if (f.name) { return f.name; } var m = $match.call(functionToString.call(f), /^function\s*([\w$]*)/); if (m) { return m[1]; } return null; } ``` -------------------------------- ### React Native Integration Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/uuid/README.md Resolves 'getRandomValues not supported' error in React Native by installing and importing a polyfill. ```APIDOC ## React Native Polyfill ### Description If you encounter the error "getRandomValues not supported" in React Native, install and import the `react-native-get-random-values` polyfill before importing `uuid`. ### Installation ```bash npm install react-native-get-random-values # or yarn add react-native-get-random-values ``` ### Usage ```javascript import 'react-native-get-random-values'; // Import polyfill first import { v4 as uuidv4 } from 'uuid'; const uuid = uuidv4(); console.log(uuid); ``` ``` -------------------------------- ### Get Buffer Implementation Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Retrieves the current buffer of data for the writable state. This method is deprecated in favor of `_writableState.getBuffer()`. ```javascript WritableState.prototype.getBuffer = function() { var current = this.bufferedRequest; var out = []; while (current) { out.push(current); current = current.next; } return out; }; ``` -------------------------------- ### Test Runner Initialization Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Initializes the test runner, sets up output streams, and begins the test execution process. This is typically the entry point for running the test suite. ```javascript function runTests(t) { var output = typeof console !== 'undefined' ? console : require('testem/lib/console'); if (t.isAsync) { t.on('done', function () { output.queue(null); }); } t.on('test', function (st) { ontest(st, { parent: id }); }); t.on('result', function (res) { if (res && typeof res === 'object') { res.test = id; res.type = 'assert'; } output.queue(res); }); t.on('end', function () { output.queue({ type: 'end', test: id }); }); self.on('done', function () { output.queue(null); }); } else { output = resum(); output.queue('TAP version 13\n'); self.stream.pipe(output); } if (!this._isRunning) { this._isRunning = true; nextTick(function next() { var t; while (t = getNextTest(self)) { t.run(); if (!t.ended) { t.once('end', function () { nextTick(next); }); return; } } self.emit('done'); }); } return output; } ``` -------------------------------- ### Run Tests with npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/uuid/CONTRIBUTING.md Execute the test suite for the uuid library using npm. ```shell npm test ``` -------------------------------- ### Get Directory Name Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Extracts the directory name from a given path. It handles trailing slashes and root paths. ```javascript exports.dirname = function (path) { if (typeof path !== 'string') path = path + ''; if (path.length === 0) return '.'; var code = path.charCodeAt(0); var hasRoot = code === 47 /* / */; var end = -1; var matchedSlash = true; for (var i = path.length - 1; i >= 1; i--) { code = path.charCodeAt(i); if (code === 47 /* / */) { if (!matchedSlash) { end = i; break; } } else { // We saw the first non-path separator matchedSlash = false; } } if (end === -1) return hasRoot ? '/' : '.'; if (hasRoot && end === 1) { // return '//'; // Backwards-compat fix: return '/'; } return path.slice(0, end); }; ``` -------------------------------- ### Test Case: Invalid Get/Set Options Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Ensures that 'get' and 'set' options, when provided, must be functions or undefined. ```JavaScript it('should throw an error when get and set options, when present, must be functions or `undefined`', function () { // Arrange var obj = {}; var prop = 'foo'; var options = { get: 1, set: function () {} }; // Assert expect(function () { Object.defineProperty(obj, prop, options); }).to.throw(TypeError, '`get` and `set` options, when present, must be functions or `undefined`'); }); ``` -------------------------------- ### Use new Buffer APIs Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/safe-buffer/README.md Utilize the explicit Buffer creation methods for clarity and safety. Buffer.from() converts various types to a Buffer, Buffer.alloc() creates a zero-filled buffer, and Buffer.allocUnsafe() creates an uninitialized buffer. ```javascript Buffer.from('hey', 'utf8') // convert from many types to a Buffer Buffer.alloc(16) // create a zero-filled buffer (safe) Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe) ``` -------------------------------- ### Get Listeners for an Event Type Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Retrieves listeners for a specific event type. It can optionally unwrap listeners if they are wrapped. ```javascript function _listeners(target, type, unwrap) { var events = target.events; if (!events) return []; var evlisteners = events[type]; if (!evlisteners) return []; if (typeof evlisteners === 'function') return unwrap ? [evlisteners.listener || evlisteners] : [evlisteners]; return unwrap ? unwrapListeners(evlisteners) : arrayClone(evlisteners, evlisteners.length); } ``` -------------------------------- ### Get RegExp.prototype.flags Polyfill Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Retrieves the polyfill for RegExp.prototype.flags, ensuring the environment supports property descriptors. Throws a TypeError if not. ```javascript supportsDescriptors = require('define-properties').supportsDescriptors; var $gOPD = Object.getOwnPropertyDescriptor; var $TypeError = TypeError; module.exports = function getPolyfill() { if (!supportsDescriptors) { throw new $TypeError('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors'); } if ((/a/mig).flags === 'gim') { var descriptor = $gOPD(RegExp.prototype, 'flags'); if (descriptor && typeof descriptor.get === 'function' && typeof (/a/).dotAll === 'boolean') { return descriptor.get; } } return implementation; }; ``` -------------------------------- ### Fetch Plain Text or HTML Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/node-fetch/README.md Fetch content from a URL and log the response body as text. ```javascript fetch('https://github.com/') .then(res => res.text()) .then(body => console.log(body)); ``` -------------------------------- ### Request Header Management Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Methods for setting, getting, and removing request headers. Headers are stored in a case-insensitive manner. ```javascript Request.prototype.setHeader = function (key, value) { this._headers[key.toLowerCase()] = value; }; Request.prototype.getHeader = function (key) { return this._headers[key.toLowerCase()]; }; Request.prototype.removeHeader = function (key) { delete this._headers[key.toLowerCase()]; }; ``` -------------------------------- ### URL Formatting Example Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/url/README.md Format a URL object back into a URL string. Various properties like protocol, host, pathname, and query are handled with specific rules. ```javascript url.format({ protocol: 'http:', host: 'host.com:8080', pathname: '/p/a/t/h', query: 'query=string', hash: '#hash' }); ``` -------------------------------- ### Get Punycode.js version Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/punycode/README.md Access the `punycode.version` property to retrieve the current version number of the Punycode.js library as a string. ```js punycode.version; ``` -------------------------------- ### Add Changelog Entry CLI Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/aws-sdk/scripts/changelog/README.md This script prompts for a type, category, and description to create a changelog entry. It places a JSON file representing the change in $SDK_ROOT/.changes/next-release/. Requires Node.js 0.12.x or higher. ```bash node ./scripts/changelog/add-change.js ``` -------------------------------- ### Get byteLength of a base64 string Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/base64-js/README.md Use the `byteLength` function to determine the byte length of a base64 encoded string. ```javascript base64js.byteLength(base64String) ``` -------------------------------- ### Test Runner Initialization Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Initializes a new Test instance with a name, options, and a callback function. It increments the pending count and emits a 'test' event. It also sets up assertions to be counted on 'prerun' and handles potential plan execution. ```javascript Test.prototype.test = function test(name, opts, cb) { var self = this; var t = new Test(name, opts, cb); $push(this._progeny, t); this.pendingCount++; this.emit('test', t); t.on('prerun', function () { self.assertionCount++; }); if (!self._pendingAssertions()) { nextTick(function () { self._end(); }); } nextTick(function () { if (!self._plan && self.pendingCount === self._progeny.length) { self._end(); } }); }; ``` -------------------------------- ### Main forEach Function Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html The main entry point for the polyfill. It determines the type of the input (array, string, or object) and dispatches to the appropriate iteration function. ```javascript var forEach = function forEach(list, iterator, thisArg) { if (!isCallable(iterator)) { throw new TypeError('iterator must be a function'); } var receiver; if (arguments.length >= 3) { receiver = thisArg; } if (toString.call(list) === '[object Array]') { forEachArray(list, iterator, receiver); } else if (typeof list === 'string') { forEachString(list, iterator, receiver); } else { forEachObject(list, iterator, receiver); } }; module.exports = forEach; ``` -------------------------------- ### Require core-util-is and inherits Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Imports utility functions from 'core-util-is' and the 'inherits' module for inheritance. ```javascript var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); ``` -------------------------------- ### Convert String to Hex Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/safe-buffer/README.md This example demonstrates a common but unsafe way to convert UTF-8 strings to hex using the Buffer constructor with a string argument. Be cautious when the argument type is not guaranteed to be a string. ```javascript // Convert UTF-8 strings to hex function toHex (str) { return new Buffer(str).toString('hex') } ``` -------------------------------- ### Test Case: Missing Native Getter/Setter Support Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Verifies that 'get' or 'set' options require native getter/setter support. ```JavaScript it('should throw an error when the `get`/`set` options require native getter/setter support', function () { // Arrange var obj = {}; var prop = 'foo'; var options = { get: function () {}, set: function () {} }; // Assert expect(function () { Object.defineProperty(obj, prop, options); }).to.throw($SyntaxError, 'the `get`/`set` options require native getter/setter support'); }); ``` -------------------------------- ### Event Emitter Listeners Method Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Provides a way to get all listeners for a specific event type from an Event Emitter instance. ```javascript EventEmitter.prototype.listeners = function listeners(type) { return _listeners(this, type, true); }; ``` -------------------------------- ### StringDecoder Constructor and Basic Usage Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Demonstrates the initialization of StringDecoder with an encoding and the basic write/end methods for processing buffers. Handles UTF-8 encoding by default. ```javascript exports.StringDecoder = StringDecoder; function StringDecoder(encoding) { this.encoding = normalizeEncoding(encoding); var nb; switch (this.encoding) { case 'utf16le': this.text = utf16Text; this.end = utf16End; nb = 4; break; case 'utf8': this.fillLast = utf8FillLast; nb = 4; break; case 'base64': this.text = base64Text; this.end = base64End; nb = 3; break; default: this.write = simpleWrite; this.end = simpleEnd; return; } this.lastNeed = 0; this.lastTotal = 0; this.lastChar = Buffer.allocUnsafe(nb); } StringDecoder.prototype.write = function (buf) { if (buf.length === 0) return ''; var r; var i; if (this.lastNeed) { r = this.fillLast(buf); if (r === undefined) return ''; i = this.lastNeed; this.lastNeed = 0; } else { i = 0; } if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); return r || ''; }; StringDecoder.prototype.end = utf8End; // Returns only complete characters in a Buffer StringDecoder.prototype.text = utf8Text; // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer StringDecoder.prototype.fillLast = function (buf) { if (this.lastNeed <= buf.length) { buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); return this.lastChar.toString(this.encoding, 0, this.lastTotal); } buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); this.lastNeed -= buf.length; }; ``` -------------------------------- ### Get the number of listeners for an event type Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Returns the number of listeners registered for a specific event type on an EventEmitter instance. ```javascript EventEmitter.listenerCount = function(emitter, type) { var ret; if (!emitter._events || !emitter._events[type]) ret = 0; else if (isFunction(emitter._events[type])) ret = 1; else ret = emitter._events[type].length; return ret; }; ``` -------------------------------- ### ES6 Shims and Polyfills Setup Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Sets up essential shims and polyfills for ES6 features, including handling of syntax errors, function constructors, and property descriptors. It aims to provide compatibility for older JavaScript environments. ```javascript 'use strict'; var undefined; var $SyntaxError = SyntaxError; var $Function = Function; var $TypeError = TypeError; // eslint-disable-next-line consistent-return var getEvalledConstructor = function (expressionSyntax) { ttry { return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')(); } catch (e) {} }; var $gOPD = Object.getOwnPropertyDescriptor; if ($gOPD) { ttry { $gOPD({}, ''); } catch (e) { $gOPD = null; // this is IE 8, which has a broken gOPD } } var throwTypeError = function () { throw new $TypeError(); }; var ThrowTypeError = $gOPD ? (function () { ttry { // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties arguments.callee; // IE 8 does not throw here return throwTypeError; } catch (calleeThrows) { try { // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '') return $gOPD(arguments, 'callee').get; } catch (gOPDthrows) { return throwTypeError; } } }()) : throwTypeError; var hasSymbols = require('has-symbols')(); var getProto = Object.getPrototypeOf || function (x) { // eslint-disable-line no-proto return x.__proto__; }; var needsEval = {}; var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array); var INTRINSICS = { '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError, '%Array%': Array, '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer, '%ArrayIteratorPrototype%': hasSymbols ? getProto(\[\][Symbol.iterator]()) : undefined, '%AsyncFromSyncIteratorPrototype%': undefined, ``` -------------------------------- ### Perform Release with npm Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/uuid/CONTRIBUTING.md Execute the automated release process for the uuid library. Follow the instructions provided in the command output. ```shell npm run release # follow the instructions from the output of this command ``` -------------------------------- ### Test Comment Emission Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Processes and emits comments within a test. Comments starting with '#' are treated as metadata and are emitted as results. ```javascript Test.prototype.comment = function comment(msg) { var that = this; forEach($split(trim(msg), '\n'), function (aMsg) { that.emit('result', $replace(trim(aMsg), /^#\s*/, '')); }); }; ``` -------------------------------- ### Hexadecimal Slice Implementation Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Converts a buffer segment into its hexadecimal string representation. Handles optional start and end bounds. ```javascript function _hexSlice (buf, start, end) { var len = buf.length if (!start || start < 0) start = 0 if (!end || end < 0 || end > len) end = len var out = '' for (var i = start; i < end; i++) { out += toHex(buf[i]) } return out } ``` -------------------------------- ### Create Changelog Script Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/aws-sdk/scripts/changelog/README.md Use this script to create or recreate the changelog from JSON files in the .changes/ directory. Ensure the .changes/ directory exists before running. ```bash ./scripts/changelog/create-changelog ``` -------------------------------- ### Tape Test Harness Initialization Source: https://github.com/iann0036/iam-dataset/blob/main/util/aws_js/node_modules/object.assign/test.html Initializes the 'tape' test harness, providing options for stream output, object mode, and controlling test execution. It supports lazy loading and provides methods for running tests, setting up specific test cases, and managing test streams. ```javascript (function (process){(function (){ 'use strict'; var defined = require('defined'); var createDefaultStream = require('./lib/default_stream'); var Test = require('./lib/test'); var createResult = require('./lib/results'); var through = require('through'); var canEmitExit = typeof process !== 'undefined' && process && typeof process.on === 'function' && process.browser !== true; var canExit = typeof process !== 'undefined' && process && typeof process.exit === 'function'; module.exports = (function () { var wait = false; var harness; var lazyLoad = function () { // eslint-disable-next-line no-invalid-this return getHarness().apply(this, arguments); }; lazyLoad.wait = function () { wait = true; }; lazyLoad.run = function () { var run = getHarness().run; if (run) { run(); } }; lazyLoad.only = function () { return getHarness().only.apply(this, arguments); }; lazyLoad.createStream = function (opts) { var options = opts || {}; if (!harness) { var output = through(); getHarness({ stream: output, objectMode: options.objectMode }); return output; } return harness.createStream(options); }; lazyLoad.onFinish = function () { return getHarness().onFinish.apply(this, arguments); }; lazyLoad.onFailure = function () { return getHarness().onFailure.apply(this, arguments); }; lazyLoad.getHarness = getHarness; return lazyLoad; function getHarness(opts) { if (!opts) { opts = {}; } opts.autoclose = !canEmitExit; if (!harness) { harness = createExitHarness(opts, wait); } return harness; } }()); function createExitHarness(conf, wait) { var config = conf || {}; var harness = createHarness({ autoclose: defined(config.autoclose, false), noOnly: defined(conf.noOnly, ```