repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
swimlane/ngx-datatable
release/utils/column-helper.js
setColumnDefaults
function setColumnDefaults(columns) { if (!columns) return; // Only one column should hold the tree view // Thus if multiple columns are provided with // isTreeColumn as true we take only the first one var treeColumnFound = false; for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) { var column = columns_1[_i]; if (!column.$$id) { column.$$id = id_1.id(); } // prop can be numeric; zero is valid not a missing prop // translate name => prop if (isNullOrUndefined(column.prop) && column.name) { column.prop = camel_case_1.camelCase(column.name); } if (!column.$$valueGetter) { column.$$valueGetter = column_prop_getters_1.getterForProp(column.prop); } // format props if no name passed if (!isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) { column.name = camel_case_1.deCamelCase(String(column.prop)); } if (isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) { column.name = ''; // Fixes IE and Edge displaying `null` } if (!column.hasOwnProperty('resizeable')) { column.resizeable = true; } if (!column.hasOwnProperty('sortable')) { column.sortable = true; } if (!column.hasOwnProperty('draggable')) { column.draggable = true; } if (!column.hasOwnProperty('canAutoResize')) { column.canAutoResize = true; } if (!column.hasOwnProperty('width')) { column.width = 150; } if (!column.hasOwnProperty('isTreeColumn')) { column.isTreeColumn = false; } else { if (column.isTreeColumn && !treeColumnFound) { // If the first column with isTreeColumn is true found // we mark that treeCoulmn is found treeColumnFound = true; } else { // After that isTreeColumn property for any other column // will be set as false column.isTreeColumn = false; } } } }
javascript
function setColumnDefaults(columns) { if (!columns) return; // Only one column should hold the tree view // Thus if multiple columns are provided with // isTreeColumn as true we take only the first one var treeColumnFound = false; for (var _i = 0, columns_1 = columns; _i < columns_1.length; _i++) { var column = columns_1[_i]; if (!column.$$id) { column.$$id = id_1.id(); } // prop can be numeric; zero is valid not a missing prop // translate name => prop if (isNullOrUndefined(column.prop) && column.name) { column.prop = camel_case_1.camelCase(column.name); } if (!column.$$valueGetter) { column.$$valueGetter = column_prop_getters_1.getterForProp(column.prop); } // format props if no name passed if (!isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) { column.name = camel_case_1.deCamelCase(String(column.prop)); } if (isNullOrUndefined(column.prop) && isNullOrUndefined(column.name)) { column.name = ''; // Fixes IE and Edge displaying `null` } if (!column.hasOwnProperty('resizeable')) { column.resizeable = true; } if (!column.hasOwnProperty('sortable')) { column.sortable = true; } if (!column.hasOwnProperty('draggable')) { column.draggable = true; } if (!column.hasOwnProperty('canAutoResize')) { column.canAutoResize = true; } if (!column.hasOwnProperty('width')) { column.width = 150; } if (!column.hasOwnProperty('isTreeColumn')) { column.isTreeColumn = false; } else { if (column.isTreeColumn && !treeColumnFound) { // If the first column with isTreeColumn is true found // we mark that treeCoulmn is found treeColumnFound = true; } else { // After that isTreeColumn property for any other column // will be set as false column.isTreeColumn = false; } } } }
[ "function", "setColumnDefaults", "(", "columns", ")", "{", "if", "(", "!", "columns", ")", "return", ";", "var", "treeColumnFound", "=", "false", ";", "for", "(", "var", "_i", "=", "0", ",", "columns_1", "=", "columns", ";", "_i", "<", "columns_1", ".", "length", ";", "_i", "++", ")", "{", "var", "column", "=", "columns_1", "[", "_i", "]", ";", "if", "(", "!", "column", ".", "$$id", ")", "{", "column", ".", "$$id", "=", "id_1", ".", "id", "(", ")", ";", "}", "if", "(", "isNullOrUndefined", "(", "column", ".", "prop", ")", "&&", "column", ".", "name", ")", "{", "column", ".", "prop", "=", "camel_case_1", ".", "camelCase", "(", "column", ".", "name", ")", ";", "}", "if", "(", "!", "column", ".", "$$valueGetter", ")", "{", "column", ".", "$$valueGetter", "=", "column_prop_getters_1", ".", "getterForProp", "(", "column", ".", "prop", ")", ";", "}", "if", "(", "!", "isNullOrUndefined", "(", "column", ".", "prop", ")", "&&", "isNullOrUndefined", "(", "column", ".", "name", ")", ")", "{", "column", ".", "name", "=", "camel_case_1", ".", "deCamelCase", "(", "String", "(", "column", ".", "prop", ")", ")", ";", "}", "if", "(", "isNullOrUndefined", "(", "column", ".", "prop", ")", "&&", "isNullOrUndefined", "(", "column", ".", "name", ")", ")", "{", "column", ".", "name", "=", "''", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'resizeable'", ")", ")", "{", "column", ".", "resizeable", "=", "true", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'sortable'", ")", ")", "{", "column", ".", "sortable", "=", "true", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'draggable'", ")", ")", "{", "column", ".", "draggable", "=", "true", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'canAutoResize'", ")", ")", "{", "column", ".", "canAutoResize", "=", "true", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'width'", ")", ")", "{", "column", ".", "width", "=", "150", ";", "}", "if", "(", "!", "column", ".", "hasOwnProperty", "(", "'isTreeColumn'", ")", ")", "{", "column", ".", "isTreeColumn", "=", "false", ";", "}", "else", "{", "if", "(", "column", ".", "isTreeColumn", "&&", "!", "treeColumnFound", ")", "{", "treeColumnFound", "=", "true", ";", "}", "else", "{", "column", ".", "isTreeColumn", "=", "false", ";", "}", "}", "}", "}" ]
Sets the column defaults
[ "Sets", "the", "column", "defaults" ]
d7df15a070282a169524dba51d9572008b74804c
https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-helper.js#L9-L67
train
swimlane/ngx-datatable
release/utils/column-helper.js
translateTemplates
function translateTemplates(templates) { var result = []; for (var _i = 0, templates_1 = templates; _i < templates_1.length; _i++) { var temp = templates_1[_i]; var col = {}; var props = Object.getOwnPropertyNames(temp); for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; col[prop] = temp[prop]; } if (temp.headerTemplate) { col.headerTemplate = temp.headerTemplate; } if (temp.cellTemplate) { col.cellTemplate = temp.cellTemplate; } if (temp.summaryFunc) { col.summaryFunc = temp.summaryFunc; } if (temp.summaryTemplate) { col.summaryTemplate = temp.summaryTemplate; } result.push(col); } return result; }
javascript
function translateTemplates(templates) { var result = []; for (var _i = 0, templates_1 = templates; _i < templates_1.length; _i++) { var temp = templates_1[_i]; var col = {}; var props = Object.getOwnPropertyNames(temp); for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; col[prop] = temp[prop]; } if (temp.headerTemplate) { col.headerTemplate = temp.headerTemplate; } if (temp.cellTemplate) { col.cellTemplate = temp.cellTemplate; } if (temp.summaryFunc) { col.summaryFunc = temp.summaryFunc; } if (temp.summaryTemplate) { col.summaryTemplate = temp.summaryTemplate; } result.push(col); } return result; }
[ "function", "translateTemplates", "(", "templates", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "_i", "=", "0", ",", "templates_1", "=", "templates", ";", "_i", "<", "templates_1", ".", "length", ";", "_i", "++", ")", "{", "var", "temp", "=", "templates_1", "[", "_i", "]", ";", "var", "col", "=", "{", "}", ";", "var", "props", "=", "Object", ".", "getOwnPropertyNames", "(", "temp", ")", ";", "for", "(", "var", "_a", "=", "0", ",", "props_1", "=", "props", ";", "_a", "<", "props_1", ".", "length", ";", "_a", "++", ")", "{", "var", "prop", "=", "props_1", "[", "_a", "]", ";", "col", "[", "prop", "]", "=", "temp", "[", "prop", "]", ";", "}", "if", "(", "temp", ".", "headerTemplate", ")", "{", "col", ".", "headerTemplate", "=", "temp", ".", "headerTemplate", ";", "}", "if", "(", "temp", ".", "cellTemplate", ")", "{", "col", ".", "cellTemplate", "=", "temp", ".", "cellTemplate", ";", "}", "if", "(", "temp", ".", "summaryFunc", ")", "{", "col", ".", "summaryFunc", "=", "temp", ".", "summaryFunc", ";", "}", "if", "(", "temp", ".", "summaryTemplate", ")", "{", "col", ".", "summaryTemplate", "=", "temp", ".", "summaryTemplate", ";", "}", "result", ".", "push", "(", "col", ")", ";", "}", "return", "result", ";", "}" ]
Translates templates definitions to objects
[ "Translates", "templates", "definitions", "to", "objects" ]
d7df15a070282a169524dba51d9572008b74804c
https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-helper.js#L76-L101
train
swimlane/ngx-datatable
release/utils/column-prop-getters.js
getterForProp
function getterForProp(prop) { if (prop == null) return emptyStringGetter; if (typeof prop === 'number') { return numericIndexGetter; } else { // deep or simple if (prop.indexOf('.') !== -1) { return deepValueGetter; } else { return shallowValueGetter; } } }
javascript
function getterForProp(prop) { if (prop == null) return emptyStringGetter; if (typeof prop === 'number') { return numericIndexGetter; } else { // deep or simple if (prop.indexOf('.') !== -1) { return deepValueGetter; } else { return shallowValueGetter; } } }
[ "function", "getterForProp", "(", "prop", ")", "{", "if", "(", "prop", "==", "null", ")", "return", "emptyStringGetter", ";", "if", "(", "typeof", "prop", "===", "'number'", ")", "{", "return", "numericIndexGetter", ";", "}", "else", "{", "if", "(", "prop", ".", "indexOf", "(", "'.'", ")", "!==", "-", "1", ")", "{", "return", "deepValueGetter", ";", "}", "else", "{", "return", "shallowValueGetter", ";", "}", "}", "}" ]
Returns the appropriate getter function for this kind of prop. If prop == null, returns the emptyStringGetter.
[ "Returns", "the", "appropriate", "getter", "function", "for", "this", "kind", "of", "prop", ".", "If", "prop", "==", "null", "returns", "the", "emptyStringGetter", "." ]
d7df15a070282a169524dba51d9572008b74804c
https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-prop-getters.js#L16-L31
train
swimlane/ngx-datatable
release/utils/column-prop-getters.js
numericIndexGetter
function numericIndexGetter(row, index) { if (row == null) return ''; // mimic behavior of deepValueGetter if (!row || index == null) return row; var value = row[index]; if (value == null) return ''; return value; }
javascript
function numericIndexGetter(row, index) { if (row == null) return ''; // mimic behavior of deepValueGetter if (!row || index == null) return row; var value = row[index]; if (value == null) return ''; return value; }
[ "function", "numericIndexGetter", "(", "row", ",", "index", ")", "{", "if", "(", "row", "==", "null", ")", "return", "''", ";", "if", "(", "!", "row", "||", "index", "==", "null", ")", "return", "row", ";", "var", "value", "=", "row", "[", "index", "]", ";", "if", "(", "value", "==", "null", ")", "return", "''", ";", "return", "value", ";", "}" ]
Returns the value at this numeric index. @param row array of values @param index numeric index @returns {any} or '' if invalid index
[ "Returns", "the", "value", "at", "this", "numeric", "index", "." ]
d7df15a070282a169524dba51d9572008b74804c
https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-prop-getters.js#L39-L49
train
aws/aws-sdk-js
lib/credentials/chainable_temporary_credentials.js
ChainableTemporaryCredentials
function ChainableTemporaryCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.errorCode = 'ChainableTemporaryCredentialsProviderFailure'; this.expired = true; this.tokenCodeFn = null; var params = AWS.util.copy(options.params) || {}; if (params.RoleArn) { params.RoleSessionName = params.RoleSessionName || 'temporary-credentials'; } if (params.SerialNumber) { if (!options.tokenCodeFn || (typeof options.tokenCodeFn !== 'function')) { throw new AWS.util.error( new Error('tokenCodeFn must be a function when params.SerialNumber is given'), {code: this.errorCode} ); } else { this.tokenCodeFn = options.tokenCodeFn; } } this.service = new STS({ params: params, credentials: options.masterCredentials || AWS.config.credentials }); }
javascript
function ChainableTemporaryCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.errorCode = 'ChainableTemporaryCredentialsProviderFailure'; this.expired = true; this.tokenCodeFn = null; var params = AWS.util.copy(options.params) || {}; if (params.RoleArn) { params.RoleSessionName = params.RoleSessionName || 'temporary-credentials'; } if (params.SerialNumber) { if (!options.tokenCodeFn || (typeof options.tokenCodeFn !== 'function')) { throw new AWS.util.error( new Error('tokenCodeFn must be a function when params.SerialNumber is given'), {code: this.errorCode} ); } else { this.tokenCodeFn = options.tokenCodeFn; } } this.service = new STS({ params: params, credentials: options.masterCredentials || AWS.config.credentials }); }
[ "function", "ChainableTemporaryCredentials", "(", "options", ")", "{", "AWS", ".", "Credentials", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "this", ".", "errorCode", "=", "'ChainableTemporaryCredentialsProviderFailure'", ";", "this", ".", "expired", "=", "true", ";", "this", ".", "tokenCodeFn", "=", "null", ";", "var", "params", "=", "AWS", ".", "util", ".", "copy", "(", "options", ".", "params", ")", "||", "{", "}", ";", "if", "(", "params", ".", "RoleArn", ")", "{", "params", ".", "RoleSessionName", "=", "params", ".", "RoleSessionName", "||", "'temporary-credentials'", ";", "}", "if", "(", "params", ".", "SerialNumber", ")", "{", "if", "(", "!", "options", ".", "tokenCodeFn", "||", "(", "typeof", "options", ".", "tokenCodeFn", "!==", "'function'", ")", ")", "{", "throw", "new", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", "'tokenCodeFn must be a function when params.SerialNumber is given'", ")", ",", "{", "code", ":", "this", ".", "errorCode", "}", ")", ";", "}", "else", "{", "this", ".", "tokenCodeFn", "=", "options", ".", "tokenCodeFn", ";", "}", "}", "this", ".", "service", "=", "new", "STS", "(", "{", "params", ":", "params", ",", "credentials", ":", "options", ".", "masterCredentials", "||", "AWS", ".", "config", ".", "credentials", "}", ")", ";", "}" ]
Creates a new temporary credentials object. @param options [map] a set of options @option options params [map] ({}) a map of options that are passed to the {AWS.STS.assumeRole} or {AWS.STS.getSessionToken} operations. If a `RoleArn` parameter is passed in, credentials will be based on the IAM role. If a `SerialNumber` parameter is passed in, {tokenCodeFn} must also be passed in or an error will be thrown. @option options masterCredentials [AWS.Credentials] the master credentials used to get and refresh temporary credentials from AWS STS. By default, AWS.config.credentials or AWS.config.credentialProvider will be used. @option options tokenCodeFn [Function] (null) Function to provide `TokenCode`, if `SerialNumber` is provided for profile in {params}. Function is called with value of `SerialNumber` and `callback`, and should provide the `TokenCode` or an error to the callback in the format `callback(err, token)`. @example Creating a new credentials object for generic temporary credentials AWS.config.credentials = new AWS.ChainableTemporaryCredentials(); @example Creating a new credentials object for an IAM role AWS.config.credentials = new AWS.ChainableTemporaryCredentials({ params: { RoleArn: 'arn:aws:iam::1234567890:role/TemporaryCredentials' } }); @see AWS.STS.assumeRole @see AWS.STS.getSessionToken
[ "Creates", "a", "new", "temporary", "credentials", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/chainable_temporary_credentials.js#L101-L126
train
aws/aws-sdk-js
features/extra/helpers.js
eventually
function eventually(callback, block, options) { if (!options) options = {}; if (!options.delay) options.delay = 0; if (!options.backoff) options.backoff = 500; if (!options.maxTime) options.maxTime = 5; var delay = options.delay; var started = this.AWS.util.date.getDate(); var self = this; var retry = function() { callback(); }; retry.fail = function(err) { var now = self.AWS.util.date.getDate(); if (now - started < options.maxTime * 1000) { setTimeout(function () { delay += options.backoff; block.call(self, retry); }, delay); } else { callback.fail(err || new Error('Eventually block timed out')); } }; block.call(this, retry); }
javascript
function eventually(callback, block, options) { if (!options) options = {}; if (!options.delay) options.delay = 0; if (!options.backoff) options.backoff = 500; if (!options.maxTime) options.maxTime = 5; var delay = options.delay; var started = this.AWS.util.date.getDate(); var self = this; var retry = function() { callback(); }; retry.fail = function(err) { var now = self.AWS.util.date.getDate(); if (now - started < options.maxTime * 1000) { setTimeout(function () { delay += options.backoff; block.call(self, retry); }, delay); } else { callback.fail(err || new Error('Eventually block timed out')); } }; block.call(this, retry); }
[ "function", "eventually", "(", "callback", ",", "block", ",", "options", ")", "{", "if", "(", "!", "options", ")", "options", "=", "{", "}", ";", "if", "(", "!", "options", ".", "delay", ")", "options", ".", "delay", "=", "0", ";", "if", "(", "!", "options", ".", "backoff", ")", "options", ".", "backoff", "=", "500", ";", "if", "(", "!", "options", ".", "maxTime", ")", "options", ".", "maxTime", "=", "5", ";", "var", "delay", "=", "options", ".", "delay", ";", "var", "started", "=", "this", ".", "AWS", ".", "util", ".", "date", ".", "getDate", "(", ")", ";", "var", "self", "=", "this", ";", "var", "retry", "=", "function", "(", ")", "{", "callback", "(", ")", ";", "}", ";", "retry", ".", "fail", "=", "function", "(", "err", ")", "{", "var", "now", "=", "self", ".", "AWS", ".", "util", ".", "date", ".", "getDate", "(", ")", ";", "if", "(", "now", "-", "started", "<", "options", ".", "maxTime", "*", "1000", ")", "{", "setTimeout", "(", "function", "(", ")", "{", "delay", "+=", "options", ".", "backoff", ";", "block", ".", "call", "(", "self", ",", "retry", ")", ";", "}", ",", "delay", ")", ";", "}", "else", "{", "callback", ".", "fail", "(", "err", "||", "new", "Error", "(", "'Eventually block timed out'", ")", ")", ";", "}", "}", ";", "block", ".", "call", "(", "this", ",", "retry", ")", ";", "}" ]
Call this function with a block that will be executed multiple times to deal with eventually consistent conditions. this.When(/^I something is eventually consistent$/, function(callback) { this.eventually(callback, function(next) { doSomething(function(response) { if (response != notWhatIExpect) { next.fail(); } else { next(); } }); }); }); You can pass in a few options after the function: delay: The number of milliseconds to delay before retrying. backoff: Add this number of milliseconds to the delay between each attempt. maxTime: Maximum duration of milliseconds to wait for success.
[ "Call", "this", "function", "with", "a", "block", "that", "will", "be", "executed", "multiple", "times", "to", "deal", "with", "eventually", "consistent", "conditions", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L33-L59
train
aws/aws-sdk-js
features/extra/helpers.js
request
function request(svc, operation, params, next, extra) { var world = this; if (!svc) svc = this.service; if (typeof svc === 'string') svc = this[svc]; svc[operation](params, function(err, data) { world.response = this; world.error = err; world.data = data; try { if (typeof next.condition === 'function') { var condition = next.condition.call(world, world); if (!condition) { next.fail(new Error('Request success condition failed')); return; } } if (extra) { extra.call(world, world.response); next.call(world); } else if (extra !== false && err) { world.unexpectedError(world.response, next); } else { next.call(world); } } catch (err) { next.fail(err); } }); }
javascript
function request(svc, operation, params, next, extra) { var world = this; if (!svc) svc = this.service; if (typeof svc === 'string') svc = this[svc]; svc[operation](params, function(err, data) { world.response = this; world.error = err; world.data = data; try { if (typeof next.condition === 'function') { var condition = next.condition.call(world, world); if (!condition) { next.fail(new Error('Request success condition failed')); return; } } if (extra) { extra.call(world, world.response); next.call(world); } else if (extra !== false && err) { world.unexpectedError(world.response, next); } else { next.call(world); } } catch (err) { next.fail(err); } }); }
[ "function", "request", "(", "svc", ",", "operation", ",", "params", ",", "next", ",", "extra", ")", "{", "var", "world", "=", "this", ";", "if", "(", "!", "svc", ")", "svc", "=", "this", ".", "service", ";", "if", "(", "typeof", "svc", "===", "'string'", ")", "svc", "=", "this", "[", "svc", "]", ";", "svc", "[", "operation", "]", "(", "params", ",", "function", "(", "err", ",", "data", ")", "{", "world", ".", "response", "=", "this", ";", "world", ".", "error", "=", "err", ";", "world", ".", "data", "=", "data", ";", "try", "{", "if", "(", "typeof", "next", ".", "condition", "===", "'function'", ")", "{", "var", "condition", "=", "next", ".", "condition", ".", "call", "(", "world", ",", "world", ")", ";", "if", "(", "!", "condition", ")", "{", "next", ".", "fail", "(", "new", "Error", "(", "'Request success condition failed'", ")", ")", ";", "return", ";", "}", "}", "if", "(", "extra", ")", "{", "extra", ".", "call", "(", "world", ",", "world", ".", "response", ")", ";", "next", ".", "call", "(", "world", ")", ";", "}", "else", "if", "(", "extra", "!==", "false", "&&", "err", ")", "{", "world", ".", "unexpectedError", "(", "world", ".", "response", ",", "next", ")", ";", "}", "else", "{", "next", ".", "call", "(", "world", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "next", ".", "fail", "(", "err", ")", ";", "}", "}", ")", ";", "}" ]
A short-cut for calling a service operation and waiting for it to finish execution before moving onto the next step in the scenario.
[ "A", "short", "-", "cut", "for", "calling", "a", "service", "operation", "and", "waiting", "for", "it", "to", "finish", "execution", "before", "moving", "onto", "the", "next", "step", "in", "the", "scenario", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L65-L98
train
aws/aws-sdk-js
features/extra/helpers.js
unexpectedError
function unexpectedError(resp, next) { var svc = resp.request.service.api.serviceName; var op = resp.request.operation; var code = resp.error.code; var msg = resp.error.message; var err = 'Received unexpected error from ' + svc + '.' + op + ', ' + code + ': ' + msg; next.fail(new Error(err)); }
javascript
function unexpectedError(resp, next) { var svc = resp.request.service.api.serviceName; var op = resp.request.operation; var code = resp.error.code; var msg = resp.error.message; var err = 'Received unexpected error from ' + svc + '.' + op + ', ' + code + ': ' + msg; next.fail(new Error(err)); }
[ "function", "unexpectedError", "(", "resp", ",", "next", ")", "{", "var", "svc", "=", "resp", ".", "request", ".", "service", ".", "api", ".", "serviceName", ";", "var", "op", "=", "resp", ".", "request", ".", "operation", ";", "var", "code", "=", "resp", ".", "error", ".", "code", ";", "var", "msg", "=", "resp", ".", "error", ".", "message", ";", "var", "err", "=", "'Received unexpected error from '", "+", "svc", "+", "'.'", "+", "op", "+", "', '", "+", "code", "+", "': '", "+", "msg", ";", "next", ".", "fail", "(", "new", "Error", "(", "err", ")", ")", ";", "}" ]
Given a response that contains an error, this fails the current step with a formatted error message that indicates which service and operation failed.
[ "Given", "a", "response", "that", "contains", "an", "error", "this", "fails", "the", "current", "step", "with", "a", "formatted", "error", "message", "that", "indicates", "which", "service", "and", "operation", "failed", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L105-L112
train
aws/aws-sdk-js
features/extra/helpers.js
function(bucket) { var fs = require('fs'); var path = require('path'); var filePath = path.resolve('integ.buckets.json'); var cache; if (fs.existsSync(filePath)) { try { cache = JSON.parse(fs.readFileSync(filePath)); cache.buckets.push(bucket); fs.writeFileSync(filePath, JSON.stringify(cache)); } catch (fileErr) { throw fileErr; } } else { cache = {}; cache.buckets = [bucket]; fs.writeFileSync(filePath, JSON.stringify(cache)); } }
javascript
function(bucket) { var fs = require('fs'); var path = require('path'); var filePath = path.resolve('integ.buckets.json'); var cache; if (fs.existsSync(filePath)) { try { cache = JSON.parse(fs.readFileSync(filePath)); cache.buckets.push(bucket); fs.writeFileSync(filePath, JSON.stringify(cache)); } catch (fileErr) { throw fileErr; } } else { cache = {}; cache.buckets = [bucket]; fs.writeFileSync(filePath, JSON.stringify(cache)); } }
[ "function", "(", "bucket", ")", "{", "var", "fs", "=", "require", "(", "'fs'", ")", ";", "var", "path", "=", "require", "(", "'path'", ")", ";", "var", "filePath", "=", "path", ".", "resolve", "(", "'integ.buckets.json'", ")", ";", "var", "cache", ";", "if", "(", "fs", ".", "existsSync", "(", "filePath", ")", ")", "{", "try", "{", "cache", "=", "JSON", ".", "parse", "(", "fs", ".", "readFileSync", "(", "filePath", ")", ")", ";", "cache", ".", "buckets", ".", "push", "(", "bucket", ")", ";", "fs", ".", "writeFileSync", "(", "filePath", ",", "JSON", ".", "stringify", "(", "cache", ")", ")", ";", "}", "catch", "(", "fileErr", ")", "{", "throw", "fileErr", ";", "}", "}", "else", "{", "cache", "=", "{", "}", ";", "cache", ".", "buckets", "=", "[", "bucket", "]", ";", "fs", ".", "writeFileSync", "(", "filePath", ",", "JSON", ".", "stringify", "(", "cache", ")", ")", ";", "}", "}" ]
Cache bucket names used for cleanup after all features have run.
[ "Cache", "bucket", "names", "used", "for", "cleanup", "after", "all", "features", "have", "run", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L117-L135
train
aws/aws-sdk-js
features/extra/helpers.js
function(size, name) { var fs = require('fs'); var path = require('path'); name = this.uniqueName(name); // Cannot set this as a world property because the world // is cleaned up before the AfterFeatures hook is fired. var fixturePath = path.resolve('./features/extra/fixtures/tmp'); if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath); var filename = path.join(fixturePath, name); var body; if (typeof size === 'string') { switch (size) { case 'empty': body = new Buffer(0); break; case 'small': body = new Buffer(1024 * 1024); break; case 'large': body = new Buffer(1024 * 1024 * 20); break; } } else if (typeof size === 'number') { body = new Buffer(size); } fs.writeFileSync(filename, body); return filename; }
javascript
function(size, name) { var fs = require('fs'); var path = require('path'); name = this.uniqueName(name); // Cannot set this as a world property because the world // is cleaned up before the AfterFeatures hook is fired. var fixturePath = path.resolve('./features/extra/fixtures/tmp'); if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath); var filename = path.join(fixturePath, name); var body; if (typeof size === 'string') { switch (size) { case 'empty': body = new Buffer(0); break; case 'small': body = new Buffer(1024 * 1024); break; case 'large': body = new Buffer(1024 * 1024 * 20); break; } } else if (typeof size === 'number') { body = new Buffer(size); } fs.writeFileSync(filename, body); return filename; }
[ "function", "(", "size", ",", "name", ")", "{", "var", "fs", "=", "require", "(", "'fs'", ")", ";", "var", "path", "=", "require", "(", "'path'", ")", ";", "name", "=", "this", ".", "uniqueName", "(", "name", ")", ";", "var", "fixturePath", "=", "path", ".", "resolve", "(", "'./features/extra/fixtures/tmp'", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "fixturePath", ")", ")", "fs", ".", "mkdirSync", "(", "fixturePath", ")", ";", "var", "filename", "=", "path", ".", "join", "(", "fixturePath", ",", "name", ")", ";", "var", "body", ";", "if", "(", "typeof", "size", "===", "'string'", ")", "{", "switch", "(", "size", ")", "{", "case", "'empty'", ":", "body", "=", "new", "Buffer", "(", "0", ")", ";", "break", ";", "case", "'small'", ":", "body", "=", "new", "Buffer", "(", "1024", "*", "1024", ")", ";", "break", ";", "case", "'large'", ":", "body", "=", "new", "Buffer", "(", "1024", "*", "1024", "*", "20", ")", ";", "break", ";", "}", "}", "else", "if", "(", "typeof", "size", "===", "'number'", ")", "{", "body", "=", "new", "Buffer", "(", "size", ")", ";", "}", "fs", ".", "writeFileSync", "(", "filename", ",", "body", ")", ";", "return", "filename", ";", "}" ]
Creates a fixture file of given size and returns the path.
[ "Creates", "a", "fixture", "file", "of", "given", "size", "and", "returns", "the", "path", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L140-L162
train
aws/aws-sdk-js
features/extra/helpers.js
function(size) { var match; var buffer; if (match = size.match(/(\d+)KB/)) { buffer = new Buffer(parseInt(match[1]) * 1024); } else if (match = size.match(/(\d+)MB/)) { buffer = new Buffer(parseInt(match[1]) * 1024 * 1024); } else { switch (size) { case 'empty': buffer = new Buffer(0); break; case 'small': buffer = new Buffer(1024 * 1024); break; case 'large': buffer = new Buffer(1024 * 1024 * 20); break; default: return new Buffer(1024 * 1024); } } buffer.fill('x'); return buffer; }
javascript
function(size) { var match; var buffer; if (match = size.match(/(\d+)KB/)) { buffer = new Buffer(parseInt(match[1]) * 1024); } else if (match = size.match(/(\d+)MB/)) { buffer = new Buffer(parseInt(match[1]) * 1024 * 1024); } else { switch (size) { case 'empty': buffer = new Buffer(0); break; case 'small': buffer = new Buffer(1024 * 1024); break; case 'large': buffer = new Buffer(1024 * 1024 * 20); break; default: return new Buffer(1024 * 1024); } } buffer.fill('x'); return buffer; }
[ "function", "(", "size", ")", "{", "var", "match", ";", "var", "buffer", ";", "if", "(", "match", "=", "size", ".", "match", "(", "/", "(\\d+)KB", "/", ")", ")", "{", "buffer", "=", "new", "Buffer", "(", "parseInt", "(", "match", "[", "1", "]", ")", "*", "1024", ")", ";", "}", "else", "if", "(", "match", "=", "size", ".", "match", "(", "/", "(\\d+)MB", "/", ")", ")", "{", "buffer", "=", "new", "Buffer", "(", "parseInt", "(", "match", "[", "1", "]", ")", "*", "1024", "*", "1024", ")", ";", "}", "else", "{", "switch", "(", "size", ")", "{", "case", "'empty'", ":", "buffer", "=", "new", "Buffer", "(", "0", ")", ";", "break", ";", "case", "'small'", ":", "buffer", "=", "new", "Buffer", "(", "1024", "*", "1024", ")", ";", "break", ";", "case", "'large'", ":", "buffer", "=", "new", "Buffer", "(", "1024", "*", "1024", "*", "20", ")", ";", "break", ";", "default", ":", "return", "new", "Buffer", "(", "1024", "*", "1024", ")", ";", "}", "}", "buffer", ".", "fill", "(", "'x'", ")", ";", "return", "buffer", ";", "}" ]
Creates and returns a buffer of given size
[ "Creates", "and", "returns", "a", "buffer", "of", "given", "size" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L167-L184
train
aws/aws-sdk-js
lib/event-stream/event-message-chunker.js
eventMessageChunker
function eventMessageChunker(buffer) { /** @type Buffer[] */ var messages = []; var offset = 0; while (offset < buffer.length) { var totalLength = buffer.readInt32BE(offset); // create new buffer for individual message (shares memory with original) var message = buffer.slice(offset, totalLength + offset); // increment offset to it starts at the next message offset += totalLength; messages.push(message); } return messages; }
javascript
function eventMessageChunker(buffer) { /** @type Buffer[] */ var messages = []; var offset = 0; while (offset < buffer.length) { var totalLength = buffer.readInt32BE(offset); // create new buffer for individual message (shares memory with original) var message = buffer.slice(offset, totalLength + offset); // increment offset to it starts at the next message offset += totalLength; messages.push(message); } return messages; }
[ "function", "eventMessageChunker", "(", "buffer", ")", "{", "var", "messages", "=", "[", "]", ";", "var", "offset", "=", "0", ";", "while", "(", "offset", "<", "buffer", ".", "length", ")", "{", "var", "totalLength", "=", "buffer", ".", "readInt32BE", "(", "offset", ")", ";", "var", "message", "=", "buffer", ".", "slice", "(", "offset", ",", "totalLength", "+", "offset", ")", ";", "offset", "+=", "totalLength", ";", "messages", ".", "push", "(", "message", ")", ";", "}", "return", "messages", ";", "}" ]
Takes in a buffer of event messages and splits them into individual messages. @param {Buffer} buffer @api private
[ "Takes", "in", "a", "buffer", "of", "event", "messages", "and", "splits", "them", "into", "individual", "messages", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/event-stream/event-message-chunker.js#L6-L23
train
aws/aws-sdk-js
lib/credentials/shared_ini_file_credentials.js
SharedIniFileCredentials
function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile; this.disableAssumeRole = Boolean(options.disableAssumeRole); this.preferStaticCredentials = Boolean(options.preferStaticCredentials); this.tokenCodeFn = options.tokenCodeFn || null; this.httpOptions = options.httpOptions || null; this.get(options.callback || AWS.util.fn.noop); }
javascript
function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile; this.disableAssumeRole = Boolean(options.disableAssumeRole); this.preferStaticCredentials = Boolean(options.preferStaticCredentials); this.tokenCodeFn = options.tokenCodeFn || null; this.httpOptions = options.httpOptions || null; this.get(options.callback || AWS.util.fn.noop); }
[ "function", "SharedIniFileCredentials", "(", "options", ")", "{", "AWS", ".", "Credentials", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "this", ".", "filename", "=", "options", ".", "filename", ";", "this", ".", "profile", "=", "options", ".", "profile", "||", "process", ".", "env", ".", "AWS_PROFILE", "||", "AWS", ".", "util", ".", "defaultProfile", ";", "this", ".", "disableAssumeRole", "=", "Boolean", "(", "options", ".", "disableAssumeRole", ")", ";", "this", ".", "preferStaticCredentials", "=", "Boolean", "(", "options", ".", "preferStaticCredentials", ")", ";", "this", ".", "tokenCodeFn", "=", "options", ".", "tokenCodeFn", "||", "null", ";", "this", ".", "httpOptions", "=", "options", ".", "httpOptions", "||", "null", ";", "this", ".", "get", "(", "options", ".", "callback", "||", "AWS", ".", "util", ".", "fn", ".", "noop", ")", ";", "}" ]
Creates a new SharedIniFileCredentials object. @param options [map] a set of options @option options profile [String] (AWS_PROFILE env var or 'default') the name of the profile to load. @option options filename [String] ('~/.aws/credentials' or defined by AWS_SHARED_CREDENTIALS_FILE process env var) the filename to use when loading credentials. @option options disableAssumeRole [Boolean] (false) True to disable support for profiles that assume an IAM role. If true, and an assume role profile is selected, an error is raised. @option options preferStaticCredentials [Boolean] (false) True to prefer static credentials to role_arn if both are present. @option options tokenCodeFn [Function] (null) Function to provide STS Assume Role TokenCode, if mfa_serial is provided for profile in ini file. Function is called with value of mfa_serial and callback, and should provide the TokenCode or an error to the callback in the format callback(err, token) @option options callback [Function] (err) Credentials are eagerly loaded by the constructor. When the callback is called with no error, the credentials have been loaded successfully. @option options httpOptions [map] A set of options to pass to the low-level HTTP request. Currently supported options are: * **proxy** [String] &mdash; the URL to proxy requests through * **agent** [http.Agent, https.Agent] &mdash; the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (`http.globalAgent`) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment. * **connectTimeout** [Integer] &mdash; Sets the socket to timeout after failing to establish a connection with the server after `connectTimeout` milliseconds. This timeout has no effect once a socket connection has been established. * **timeout** [Integer] &mdash; Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
[ "Creates", "a", "new", "SharedIniFileCredentials", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/shared_ini_file_credentials.js#L76-L88
train
aws/aws-sdk-js
lib/xml/escape-attribute.js
escapeAttribute
function escapeAttribute(value) { return value.replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }
javascript
function escapeAttribute(value) { return value.replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }
[ "function", "escapeAttribute", "(", "value", ")", "{", "return", "value", ".", "replace", "(", "/", "&", "/", "g", ",", "'&amp;'", ")", ".", "replace", "(", "/", "'", "/", "g", ",", "'&apos;'", ")", ".", "replace", "(", "/", "<", "/", "g", ",", "'&lt;'", ")", ".", "replace", "(", "/", ">", "/", "g", ",", "'&gt;'", ")", ".", "replace", "(", "/", "\"", "/", "g", ",", "'&quot;'", ")", ";", "}" ]
Escapes characters that can not be in an XML attribute.
[ "Escapes", "characters", "that", "can", "not", "be", "in", "an", "XML", "attribute", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/xml/escape-attribute.js#L4-L6
train
aws/aws-sdk-js
lib/credentials/cognito_identity_credentials.js
clearCache
function clearCache() { this._identityId = null; delete this.params.IdentityId; var poolId = this.params.IdentityPoolId; var loginId = this.params.LoginId || ''; delete this.storage[this.localStorageKey.id + poolId + loginId]; delete this.storage[this.localStorageKey.providers + poolId + loginId]; }
javascript
function clearCache() { this._identityId = null; delete this.params.IdentityId; var poolId = this.params.IdentityPoolId; var loginId = this.params.LoginId || ''; delete this.storage[this.localStorageKey.id + poolId + loginId]; delete this.storage[this.localStorageKey.providers + poolId + loginId]; }
[ "function", "clearCache", "(", ")", "{", "this", ".", "_identityId", "=", "null", ";", "delete", "this", ".", "params", ".", "IdentityId", ";", "var", "poolId", "=", "this", ".", "params", ".", "IdentityPoolId", ";", "var", "loginId", "=", "this", ".", "params", ".", "LoginId", "||", "''", ";", "delete", "this", ".", "storage", "[", "this", ".", "localStorageKey", ".", "id", "+", "poolId", "+", "loginId", "]", ";", "delete", "this", ".", "storage", "[", "this", ".", "localStorageKey", ".", "providers", "+", "poolId", "+", "loginId", "]", ";", "}" ]
Clears the cached Cognito ID associated with the currently configured identity pool ID. Use this to manually invalidate your cache if the identity pool ID was deleted.
[ "Clears", "the", "cached", "Cognito", "ID", "associated", "with", "the", "currently", "configured", "identity", "pool", "ID", ".", "Use", "this", "to", "manually", "invalidate", "your", "cache", "if", "the", "identity", "pool", "ID", "was", "deleted", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/cognito_identity_credentials.js#L191-L199
train
aws/aws-sdk-js
lib/resource_waiter.js
loadWaiterConfig
function loadWaiterConfig(state) { if (!this.service.api.waiters[state]) { throw new AWS.util.error(new Error(), { code: 'StateNotFoundError', message: 'State ' + state + ' not found.' }); } this.config = AWS.util.copy(this.service.api.waiters[state]); }
javascript
function loadWaiterConfig(state) { if (!this.service.api.waiters[state]) { throw new AWS.util.error(new Error(), { code: 'StateNotFoundError', message: 'State ' + state + ' not found.' }); } this.config = AWS.util.copy(this.service.api.waiters[state]); }
[ "function", "loadWaiterConfig", "(", "state", ")", "{", "if", "(", "!", "this", ".", "service", ".", "api", ".", "waiters", "[", "state", "]", ")", "{", "throw", "new", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", ")", ",", "{", "code", ":", "'StateNotFoundError'", ",", "message", ":", "'State '", "+", "state", "+", "' not found.'", "}", ")", ";", "}", "this", ".", "config", "=", "AWS", ".", "util", ".", "copy", "(", "this", ".", "service", ".", "api", ".", "waiters", "[", "state", "]", ")", ";", "}" ]
Loads waiter configuration from API configuration @api private
[ "Loads", "waiter", "configuration", "from", "API", "configuration" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/resource_waiter.js#L194-L203
train
aws/aws-sdk-js
lib/xml/xml-node.js
XmlNode
function XmlNode(name, children) { if (children === void 0) { children = []; } this.name = name; this.children = children; this.attributes = {}; }
javascript
function XmlNode(name, children) { if (children === void 0) { children = []; } this.name = name; this.children = children; this.attributes = {}; }
[ "function", "XmlNode", "(", "name", ",", "children", ")", "{", "if", "(", "children", "===", "void", "0", ")", "{", "children", "=", "[", "]", ";", "}", "this", ".", "name", "=", "name", ";", "this", ".", "children", "=", "children", ";", "this", ".", "attributes", "=", "{", "}", ";", "}" ]
Represents an XML node. @api private
[ "Represents", "an", "XML", "node", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/xml/xml-node.js#L7-L12
train
aws/aws-sdk-js
lib/request.js
eachPage
function eachPage(callback) { // Make all callbacks async-ish callback = AWS.util.fn.makeAsync(callback, 3); function wrappedCallback(response) { callback.call(response, response.error, response.data, function (result) { if (result === false) return; if (response.hasNextPage()) { response.nextPage().on('complete', wrappedCallback).send(); } else { callback.call(response, null, null, AWS.util.fn.noop); } }); } this.on('complete', wrappedCallback).send(); }
javascript
function eachPage(callback) { // Make all callbacks async-ish callback = AWS.util.fn.makeAsync(callback, 3); function wrappedCallback(response) { callback.call(response, response.error, response.data, function (result) { if (result === false) return; if (response.hasNextPage()) { response.nextPage().on('complete', wrappedCallback).send(); } else { callback.call(response, null, null, AWS.util.fn.noop); } }); } this.on('complete', wrappedCallback).send(); }
[ "function", "eachPage", "(", "callback", ")", "{", "callback", "=", "AWS", ".", "util", ".", "fn", ".", "makeAsync", "(", "callback", ",", "3", ")", ";", "function", "wrappedCallback", "(", "response", ")", "{", "callback", ".", "call", "(", "response", ",", "response", ".", "error", ",", "response", ".", "data", ",", "function", "(", "result", ")", "{", "if", "(", "result", "===", "false", ")", "return", ";", "if", "(", "response", ".", "hasNextPage", "(", ")", ")", "{", "response", ".", "nextPage", "(", ")", ".", "on", "(", "'complete'", ",", "wrappedCallback", ")", ".", "send", "(", ")", ";", "}", "else", "{", "callback", ".", "call", "(", "response", ",", "null", ",", "null", ",", "AWS", ".", "util", ".", "fn", ".", "noop", ")", ";", "}", "}", ")", ";", "}", "this", ".", "on", "(", "'complete'", ",", "wrappedCallback", ")", ".", "send", "(", ")", ";", "}" ]
Iterates over each page of results given a pageable request, calling the provided callback with each page of data. After all pages have been retrieved, the callback is called with `null` data. @note This operation can generate multiple requests to a service. @example Iterating over multiple pages of objects in an S3 bucket var pages = 1; s3.listObjects().eachPage(function(err, data) { if (err) return; console.log("Page", pages++); console.log(data); }); @example Iterating over multiple pages with an asynchronous callback s3.listObjects(params).eachPage(function(err, data, done) { doSomethingAsyncAndOrExpensive(function() { // The next page of results isn't fetched until done is called done(); }); }); @callback callback function(err, data, [doneCallback]) Called with each page of resulting data from the request. If the optional `doneCallback` is provided in the function, it must be called when the callback is complete. @param err [Error] an error object, if an error occurred. @param data [Object] a single page of response data. If there is no more data, this object will be `null`. @param doneCallback [Function] an optional done callback. If this argument is defined in the function declaration, it should be called when the next page is ready to be retrieved. This is useful for controlling serial pagination across asynchronous operations. @return [Boolean] if the callback returns `false`, pagination will stop. @see AWS.Request.eachItem @see AWS.Response.nextPage @since v1.4.0
[ "Iterates", "over", "each", "page", "of", "results", "given", "a", "pageable", "request", "calling", "the", "provided", "callback", "with", "each", "page", "of", "data", ".", "After", "all", "pages", "have", "been", "retrieved", "the", "callback", "is", "called", "with", "null", "data", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/request.js#L489-L506
train
aws/aws-sdk-js
lib/request.js
eachItem
function eachItem(callback) { var self = this; function wrappedCallback(err, data) { if (err) return callback(err, null); if (data === null) return callback(null, null); var config = self.service.paginationConfig(self.operation); var resultKey = config.resultKey; if (Array.isArray(resultKey)) resultKey = resultKey[0]; var items = jmespath.search(data, resultKey); var continueIteration = true; AWS.util.arrayEach(items, function(item) { continueIteration = callback(null, item); if (continueIteration === false) { return AWS.util.abort; } }); return continueIteration; } this.eachPage(wrappedCallback); }
javascript
function eachItem(callback) { var self = this; function wrappedCallback(err, data) { if (err) return callback(err, null); if (data === null) return callback(null, null); var config = self.service.paginationConfig(self.operation); var resultKey = config.resultKey; if (Array.isArray(resultKey)) resultKey = resultKey[0]; var items = jmespath.search(data, resultKey); var continueIteration = true; AWS.util.arrayEach(items, function(item) { continueIteration = callback(null, item); if (continueIteration === false) { return AWS.util.abort; } }); return continueIteration; } this.eachPage(wrappedCallback); }
[ "function", "eachItem", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "function", "wrappedCallback", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ",", "null", ")", ";", "if", "(", "data", "===", "null", ")", "return", "callback", "(", "null", ",", "null", ")", ";", "var", "config", "=", "self", ".", "service", ".", "paginationConfig", "(", "self", ".", "operation", ")", ";", "var", "resultKey", "=", "config", ".", "resultKey", ";", "if", "(", "Array", ".", "isArray", "(", "resultKey", ")", ")", "resultKey", "=", "resultKey", "[", "0", "]", ";", "var", "items", "=", "jmespath", ".", "search", "(", "data", ",", "resultKey", ")", ";", "var", "continueIteration", "=", "true", ";", "AWS", ".", "util", ".", "arrayEach", "(", "items", ",", "function", "(", "item", ")", "{", "continueIteration", "=", "callback", "(", "null", ",", "item", ")", ";", "if", "(", "continueIteration", "===", "false", ")", "{", "return", "AWS", ".", "util", ".", "abort", ";", "}", "}", ")", ";", "return", "continueIteration", ";", "}", "this", ".", "eachPage", "(", "wrappedCallback", ")", ";", "}" ]
Enumerates over individual items of a request, paging the responses if necessary. @api experimental @since v1.4.0
[ "Enumerates", "over", "individual", "items", "of", "a", "request", "paging", "the", "responses", "if", "necessary", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/request.js#L515-L536
train
aws/aws-sdk-js
lib/publisher/index.js
Publisher
function Publisher(options) { // handle configuration options = options || {}; this.enabled = options.enabled || false; this.port = options.port || 31000; this.clientId = options.clientId || ''; if (this.clientId.length > 255) { // ClientId has a max length of 255 this.clientId = this.clientId.substr(0, 255); } this.messagesInFlight = 0; this.address = 'localhost'; }
javascript
function Publisher(options) { // handle configuration options = options || {}; this.enabled = options.enabled || false; this.port = options.port || 31000; this.clientId = options.clientId || ''; if (this.clientId.length > 255) { // ClientId has a max length of 255 this.clientId = this.clientId.substr(0, 255); } this.messagesInFlight = 0; this.address = 'localhost'; }
[ "function", "Publisher", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "enabled", "=", "options", ".", "enabled", "||", "false", ";", "this", ".", "port", "=", "options", ".", "port", "||", "31000", ";", "this", ".", "clientId", "=", "options", ".", "clientId", "||", "''", ";", "if", "(", "this", ".", "clientId", ".", "length", ">", "255", ")", "{", "this", ".", "clientId", "=", "this", ".", "clientId", ".", "substr", "(", "0", ",", "255", ")", ";", "}", "this", ".", "messagesInFlight", "=", "0", ";", "this", ".", "address", "=", "'localhost'", ";", "}" ]
8 KB Publishes metrics via udp. @param {object} options Paramters for Publisher constructor @param {number} [options.port = 31000] Port number @param {string} [options.clientId = ''] Client Identifier @param {boolean} [options.enabled = false] enable sending metrics datagram @api private
[ "8", "KB", "Publishes", "metrics", "via", "udp", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/index.js#L14-L26
train
aws/aws-sdk-js
lib/services/s3.js
removeVirtualHostedBucketFromPath
function removeVirtualHostedBucketFromPath(req) { var httpRequest = req.httpRequest; var bucket = httpRequest.virtualHostedBucket; if (bucket && httpRequest.path) { if (req.params && req.params.Key) { var encodedS3Key = '/' + AWS.util.uriEscapePath(req.params.Key); if (httpRequest.path.indexOf(encodedS3Key) === 0 && (httpRequest.path.length === encodedS3Key.length || httpRequest.path[encodedS3Key.length] === '?')) { //path only contains key or path contains only key and querystring return; } } httpRequest.path = httpRequest.path.replace(new RegExp('/' + bucket), ''); if (httpRequest.path[0] !== '/') { httpRequest.path = '/' + httpRequest.path; } } }
javascript
function removeVirtualHostedBucketFromPath(req) { var httpRequest = req.httpRequest; var bucket = httpRequest.virtualHostedBucket; if (bucket && httpRequest.path) { if (req.params && req.params.Key) { var encodedS3Key = '/' + AWS.util.uriEscapePath(req.params.Key); if (httpRequest.path.indexOf(encodedS3Key) === 0 && (httpRequest.path.length === encodedS3Key.length || httpRequest.path[encodedS3Key.length] === '?')) { //path only contains key or path contains only key and querystring return; } } httpRequest.path = httpRequest.path.replace(new RegExp('/' + bucket), ''); if (httpRequest.path[0] !== '/') { httpRequest.path = '/' + httpRequest.path; } } }
[ "function", "removeVirtualHostedBucketFromPath", "(", "req", ")", "{", "var", "httpRequest", "=", "req", ".", "httpRequest", ";", "var", "bucket", "=", "httpRequest", ".", "virtualHostedBucket", ";", "if", "(", "bucket", "&&", "httpRequest", ".", "path", ")", "{", "if", "(", "req", ".", "params", "&&", "req", ".", "params", ".", "Key", ")", "{", "var", "encodedS3Key", "=", "'/'", "+", "AWS", ".", "util", ".", "uriEscapePath", "(", "req", ".", "params", ".", "Key", ")", ";", "if", "(", "httpRequest", ".", "path", ".", "indexOf", "(", "encodedS3Key", ")", "===", "0", "&&", "(", "httpRequest", ".", "path", ".", "length", "===", "encodedS3Key", ".", "length", "||", "httpRequest", ".", "path", "[", "encodedS3Key", ".", "length", "]", "===", "'?'", ")", ")", "{", "return", ";", "}", "}", "httpRequest", ".", "path", "=", "httpRequest", ".", "path", ".", "replace", "(", "new", "RegExp", "(", "'/'", "+", "bucket", ")", ",", "''", ")", ";", "if", "(", "httpRequest", ".", "path", "[", "0", "]", "!==", "'/'", ")", "{", "httpRequest", ".", "path", "=", "'/'", "+", "httpRequest", ".", "path", ";", "}", "}", "}" ]
Takes the bucket name out of the path if bucket is virtual-hosted @api private
[ "Takes", "the", "bucket", "name", "out", "of", "the", "path", "if", "bucket", "is", "virtual", "-", "hosted" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L238-L254
train
aws/aws-sdk-js
lib/services/s3.js
addContentType
function addContentType(req) { var httpRequest = req.httpRequest; if (httpRequest.method === 'GET' || httpRequest.method === 'HEAD') { // Content-Type is not set in GET/HEAD requests delete httpRequest.headers['Content-Type']; return; } if (!httpRequest.headers['Content-Type']) { // always have a Content-Type httpRequest.headers['Content-Type'] = 'application/octet-stream'; } var contentType = httpRequest.headers['Content-Type']; if (AWS.util.isBrowser()) { if (typeof httpRequest.body === 'string' && !contentType.match(/;\s*charset=/)) { var charset = '; charset=UTF-8'; httpRequest.headers['Content-Type'] += charset; } else { var replaceFn = function(_, prefix, charsetName) { return prefix + charsetName.toUpperCase(); }; httpRequest.headers['Content-Type'] = contentType.replace(/(;\s*charset=)(.+)$/, replaceFn); } } }
javascript
function addContentType(req) { var httpRequest = req.httpRequest; if (httpRequest.method === 'GET' || httpRequest.method === 'HEAD') { // Content-Type is not set in GET/HEAD requests delete httpRequest.headers['Content-Type']; return; } if (!httpRequest.headers['Content-Type']) { // always have a Content-Type httpRequest.headers['Content-Type'] = 'application/octet-stream'; } var contentType = httpRequest.headers['Content-Type']; if (AWS.util.isBrowser()) { if (typeof httpRequest.body === 'string' && !contentType.match(/;\s*charset=/)) { var charset = '; charset=UTF-8'; httpRequest.headers['Content-Type'] += charset; } else { var replaceFn = function(_, prefix, charsetName) { return prefix + charsetName.toUpperCase(); }; httpRequest.headers['Content-Type'] = contentType.replace(/(;\s*charset=)(.+)$/, replaceFn); } } }
[ "function", "addContentType", "(", "req", ")", "{", "var", "httpRequest", "=", "req", ".", "httpRequest", ";", "if", "(", "httpRequest", ".", "method", "===", "'GET'", "||", "httpRequest", ".", "method", "===", "'HEAD'", ")", "{", "delete", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", ";", "return", ";", "}", "if", "(", "!", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", ")", "{", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", "=", "'application/octet-stream'", ";", "}", "var", "contentType", "=", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", ";", "if", "(", "AWS", ".", "util", ".", "isBrowser", "(", ")", ")", "{", "if", "(", "typeof", "httpRequest", ".", "body", "===", "'string'", "&&", "!", "contentType", ".", "match", "(", "/", ";\\s*charset=", "/", ")", ")", "{", "var", "charset", "=", "'; charset=UTF-8'", ";", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", "+=", "charset", ";", "}", "else", "{", "var", "replaceFn", "=", "function", "(", "_", ",", "prefix", ",", "charsetName", ")", "{", "return", "prefix", "+", "charsetName", ".", "toUpperCase", "(", ")", ";", "}", ";", "httpRequest", ".", "headers", "[", "'Content-Type'", "]", "=", "contentType", ".", "replace", "(", "/", "(;\\s*charset=)(.+)$", "/", ",", "replaceFn", ")", ";", "}", "}", "}" ]
Adds a default content type if none is supplied. @api private
[ "Adds", "a", "default", "content", "type", "if", "none", "is", "supplied", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L272-L298
train
aws/aws-sdk-js
lib/services/s3.js
computeContentMd5
function computeContentMd5(req) { if (req.service.willComputeChecksums(req)) { var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64'); req.httpRequest.headers['Content-MD5'] = md5; } }
javascript
function computeContentMd5(req) { if (req.service.willComputeChecksums(req)) { var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64'); req.httpRequest.headers['Content-MD5'] = md5; } }
[ "function", "computeContentMd5", "(", "req", ")", "{", "if", "(", "req", ".", "service", ".", "willComputeChecksums", "(", "req", ")", ")", "{", "var", "md5", "=", "AWS", ".", "util", ".", "crypto", ".", "md5", "(", "req", ".", "httpRequest", ".", "body", ",", "'base64'", ")", ";", "req", ".", "httpRequest", ".", "headers", "[", "'Content-MD5'", "]", "=", "md5", ";", "}", "}" ]
A listener that computes the Content-MD5 and sets it in the header. @see AWS.S3.willComputeChecksums @api private
[ "A", "listener", "that", "computes", "the", "Content", "-", "MD5", "and", "sets", "it", "in", "the", "header", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L357-L362
train
aws/aws-sdk-js
lib/services/s3.js
dnsCompatibleBucketName
function dnsCompatibleBucketName(bucketName) { var b = bucketName; var domain = new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/); var ipAddress = new RegExp(/(\d+\.){3}\d+/); var dots = new RegExp(/\.\./); return (b.match(domain) && !b.match(ipAddress) && !b.match(dots)) ? true : false; }
javascript
function dnsCompatibleBucketName(bucketName) { var b = bucketName; var domain = new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/); var ipAddress = new RegExp(/(\d+\.){3}\d+/); var dots = new RegExp(/\.\./); return (b.match(domain) && !b.match(ipAddress) && !b.match(dots)) ? true : false; }
[ "function", "dnsCompatibleBucketName", "(", "bucketName", ")", "{", "var", "b", "=", "bucketName", ";", "var", "domain", "=", "new", "RegExp", "(", "/", "^[a-z0-9][a-z0-9\\.\\-]{1,61}[a-z0-9]$", "/", ")", ";", "var", "ipAddress", "=", "new", "RegExp", "(", "/", "(\\d+\\.){3}\\d+", "/", ")", ";", "var", "dots", "=", "new", "RegExp", "(", "/", "\\.\\.", "/", ")", ";", "return", "(", "b", ".", "match", "(", "domain", ")", "&&", "!", "b", ".", "match", "(", "ipAddress", ")", "&&", "!", "b", ".", "match", "(", "dots", ")", ")", "?", "true", ":", "false", ";", "}" ]
Returns true if the bucket name is DNS compatible. Buckets created outside of the classic region MUST be DNS compatible. @api private
[ "Returns", "true", "if", "the", "bucket", "name", "is", "DNS", "compatible", ".", "Buckets", "created", "outside", "of", "the", "classic", "region", "MUST", "be", "DNS", "compatible", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L405-L411
train
aws/aws-sdk-js
lib/services/s3.js
updateReqBucketRegion
function updateReqBucketRegion(request, region) { var httpRequest = request.httpRequest; if (typeof region === 'string' && region.length) { httpRequest.region = region; } if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) { return; } var service = request.service; var s3Config = service.config; var s3BucketEndpoint = s3Config.s3BucketEndpoint; if (s3BucketEndpoint) { delete s3Config.s3BucketEndpoint; } var newConfig = AWS.util.copy(s3Config); delete newConfig.endpoint; newConfig.region = httpRequest.region; httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint; service.populateURI(request); s3Config.s3BucketEndpoint = s3BucketEndpoint; httpRequest.headers.Host = httpRequest.endpoint.host; if (request._asm.currentState === 'validate') { request.removeListener('build', service.populateURI); request.addListener('build', service.removeVirtualHostedBucketFromPath); } }
javascript
function updateReqBucketRegion(request, region) { var httpRequest = request.httpRequest; if (typeof region === 'string' && region.length) { httpRequest.region = region; } if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) { return; } var service = request.service; var s3Config = service.config; var s3BucketEndpoint = s3Config.s3BucketEndpoint; if (s3BucketEndpoint) { delete s3Config.s3BucketEndpoint; } var newConfig = AWS.util.copy(s3Config); delete newConfig.endpoint; newConfig.region = httpRequest.region; httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint; service.populateURI(request); s3Config.s3BucketEndpoint = s3BucketEndpoint; httpRequest.headers.Host = httpRequest.endpoint.host; if (request._asm.currentState === 'validate') { request.removeListener('build', service.populateURI); request.addListener('build', service.removeVirtualHostedBucketFromPath); } }
[ "function", "updateReqBucketRegion", "(", "request", ",", "region", ")", "{", "var", "httpRequest", "=", "request", ".", "httpRequest", ";", "if", "(", "typeof", "region", "===", "'string'", "&&", "region", ".", "length", ")", "{", "httpRequest", ".", "region", "=", "region", ";", "}", "if", "(", "!", "httpRequest", ".", "endpoint", ".", "host", ".", "match", "(", "/", "s3(?!-accelerate).*\\.amazonaws\\.com$", "/", ")", ")", "{", "return", ";", "}", "var", "service", "=", "request", ".", "service", ";", "var", "s3Config", "=", "service", ".", "config", ";", "var", "s3BucketEndpoint", "=", "s3Config", ".", "s3BucketEndpoint", ";", "if", "(", "s3BucketEndpoint", ")", "{", "delete", "s3Config", ".", "s3BucketEndpoint", ";", "}", "var", "newConfig", "=", "AWS", ".", "util", ".", "copy", "(", "s3Config", ")", ";", "delete", "newConfig", ".", "endpoint", ";", "newConfig", ".", "region", "=", "httpRequest", ".", "region", ";", "httpRequest", ".", "endpoint", "=", "(", "new", "AWS", ".", "S3", "(", "newConfig", ")", ")", ".", "endpoint", ";", "service", ".", "populateURI", "(", "request", ")", ";", "s3Config", ".", "s3BucketEndpoint", "=", "s3BucketEndpoint", ";", "httpRequest", ".", "headers", ".", "Host", "=", "httpRequest", ".", "endpoint", ".", "host", ";", "if", "(", "request", ".", "_asm", ".", "currentState", "===", "'validate'", ")", "{", "request", ".", "removeListener", "(", "'build'", ",", "service", ".", "populateURI", ")", ";", "request", ".", "addListener", "(", "'build'", ",", "service", ".", "removeVirtualHostedBucketFromPath", ")", ";", "}", "}" ]
Updates httpRequest with region. If region is not provided, then the httpRequest will be updated based on httpRequest.region @api private
[ "Updates", "httpRequest", "with", "region", ".", "If", "region", "is", "not", "provided", "then", "the", "httpRequest", "will", "be", "updated", "based", "on", "httpRequest", ".", "region" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L461-L488
train
aws/aws-sdk-js
lib/services/s3.js
extractError
function extractError(resp) { var codes = { 304: 'NotModified', 403: 'Forbidden', 400: 'BadRequest', 404: 'NotFound' }; var req = resp.request; var code = resp.httpResponse.statusCode; var body = resp.httpResponse.body || ''; var headers = resp.httpResponse.headers || {}; var region = headers['x-amz-bucket-region'] || null; var bucket = req.params.Bucket || null; var bucketRegionCache = req.service.bucketRegionCache; if (region && bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } var cachedRegion; if (codes[code] && body.length === 0) { if (bucket && !region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: codes[code], message: null, region: region }); } else { var data = new AWS.XML.Parser().parse(body.toString()); if (data.Region && !region) { region = data.Region; if (bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } } else if (bucket && !region && !data.Region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: data.Code || code, message: data.Message || null, region: region }); } req.service.extractRequestIds(resp); }
javascript
function extractError(resp) { var codes = { 304: 'NotModified', 403: 'Forbidden', 400: 'BadRequest', 404: 'NotFound' }; var req = resp.request; var code = resp.httpResponse.statusCode; var body = resp.httpResponse.body || ''; var headers = resp.httpResponse.headers || {}; var region = headers['x-amz-bucket-region'] || null; var bucket = req.params.Bucket || null; var bucketRegionCache = req.service.bucketRegionCache; if (region && bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } var cachedRegion; if (codes[code] && body.length === 0) { if (bucket && !region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: codes[code], message: null, region: region }); } else { var data = new AWS.XML.Parser().parse(body.toString()); if (data.Region && !region) { region = data.Region; if (bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } } else if (bucket && !region && !data.Region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: data.Code || code, message: data.Message || null, region: region }); } req.service.extractRequestIds(resp); }
[ "function", "extractError", "(", "resp", ")", "{", "var", "codes", "=", "{", "304", ":", "'NotModified'", ",", "403", ":", "'Forbidden'", ",", "400", ":", "'BadRequest'", ",", "404", ":", "'NotFound'", "}", ";", "var", "req", "=", "resp", ".", "request", ";", "var", "code", "=", "resp", ".", "httpResponse", ".", "statusCode", ";", "var", "body", "=", "resp", ".", "httpResponse", ".", "body", "||", "''", ";", "var", "headers", "=", "resp", ".", "httpResponse", ".", "headers", "||", "{", "}", ";", "var", "region", "=", "headers", "[", "'x-amz-bucket-region'", "]", "||", "null", ";", "var", "bucket", "=", "req", ".", "params", ".", "Bucket", "||", "null", ";", "var", "bucketRegionCache", "=", "req", ".", "service", ".", "bucketRegionCache", ";", "if", "(", "region", "&&", "bucket", "&&", "region", "!==", "bucketRegionCache", "[", "bucket", "]", ")", "{", "bucketRegionCache", "[", "bucket", "]", "=", "region", ";", "}", "var", "cachedRegion", ";", "if", "(", "codes", "[", "code", "]", "&&", "body", ".", "length", "===", "0", ")", "{", "if", "(", "bucket", "&&", "!", "region", ")", "{", "cachedRegion", "=", "bucketRegionCache", "[", "bucket", "]", "||", "null", ";", "if", "(", "cachedRegion", "!==", "req", ".", "httpRequest", ".", "region", ")", "{", "region", "=", "cachedRegion", ";", "}", "}", "resp", ".", "error", "=", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", ")", ",", "{", "code", ":", "codes", "[", "code", "]", ",", "message", ":", "null", ",", "region", ":", "region", "}", ")", ";", "}", "else", "{", "var", "data", "=", "new", "AWS", ".", "XML", ".", "Parser", "(", ")", ".", "parse", "(", "body", ".", "toString", "(", ")", ")", ";", "if", "(", "data", ".", "Region", "&&", "!", "region", ")", "{", "region", "=", "data", ".", "Region", ";", "if", "(", "bucket", "&&", "region", "!==", "bucketRegionCache", "[", "bucket", "]", ")", "{", "bucketRegionCache", "[", "bucket", "]", "=", "region", ";", "}", "}", "else", "if", "(", "bucket", "&&", "!", "region", "&&", "!", "data", ".", "Region", ")", "{", "cachedRegion", "=", "bucketRegionCache", "[", "bucket", "]", "||", "null", ";", "if", "(", "cachedRegion", "!==", "req", ".", "httpRequest", ".", "region", ")", "{", "region", "=", "cachedRegion", ";", "}", "}", "resp", ".", "error", "=", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", ")", ",", "{", "code", ":", "data", ".", "Code", "||", "code", ",", "message", ":", "data", ".", "Message", "||", "null", ",", "region", ":", "region", "}", ")", ";", "}", "req", ".", "service", ".", "extractRequestIds", "(", "resp", ")", ";", "}" ]
Extracts an error object from the http response. @api private
[ "Extracts", "an", "error", "object", "from", "the", "http", "response", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L537-L592
train
aws/aws-sdk-js
lib/services/s3.js
requestBucketRegion
function requestBucketRegion(resp, done) { var error = resp.error; var req = resp.request; var bucket = req.params.Bucket || null; if (!error || !bucket || error.region || req.operation === 'listObjects' || (AWS.util.isNode() && req.operation === 'headBucket') || (error.statusCode === 400 && req.operation !== 'headObject') || regionRedirectErrorCodes.indexOf(error.code) === -1) { return done(); } var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects'; var reqParams = {Bucket: bucket}; if (reqOperation === 'listObjects') reqParams.MaxKeys = 0; var regionReq = req.service[reqOperation](reqParams); regionReq._requestRegionForBucket = bucket; regionReq.send(function() { var region = req.service.bucketRegionCache[bucket] || null; error.region = region; done(); }); }
javascript
function requestBucketRegion(resp, done) { var error = resp.error; var req = resp.request; var bucket = req.params.Bucket || null; if (!error || !bucket || error.region || req.operation === 'listObjects' || (AWS.util.isNode() && req.operation === 'headBucket') || (error.statusCode === 400 && req.operation !== 'headObject') || regionRedirectErrorCodes.indexOf(error.code) === -1) { return done(); } var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects'; var reqParams = {Bucket: bucket}; if (reqOperation === 'listObjects') reqParams.MaxKeys = 0; var regionReq = req.service[reqOperation](reqParams); regionReq._requestRegionForBucket = bucket; regionReq.send(function() { var region = req.service.bucketRegionCache[bucket] || null; error.region = region; done(); }); }
[ "function", "requestBucketRegion", "(", "resp", ",", "done", ")", "{", "var", "error", "=", "resp", ".", "error", ";", "var", "req", "=", "resp", ".", "request", ";", "var", "bucket", "=", "req", ".", "params", ".", "Bucket", "||", "null", ";", "if", "(", "!", "error", "||", "!", "bucket", "||", "error", ".", "region", "||", "req", ".", "operation", "===", "'listObjects'", "||", "(", "AWS", ".", "util", ".", "isNode", "(", ")", "&&", "req", ".", "operation", "===", "'headBucket'", ")", "||", "(", "error", ".", "statusCode", "===", "400", "&&", "req", ".", "operation", "!==", "'headObject'", ")", "||", "regionRedirectErrorCodes", ".", "indexOf", "(", "error", ".", "code", ")", "===", "-", "1", ")", "{", "return", "done", "(", ")", ";", "}", "var", "reqOperation", "=", "AWS", ".", "util", ".", "isNode", "(", ")", "?", "'headBucket'", ":", "'listObjects'", ";", "var", "reqParams", "=", "{", "Bucket", ":", "bucket", "}", ";", "if", "(", "reqOperation", "===", "'listObjects'", ")", "reqParams", ".", "MaxKeys", "=", "0", ";", "var", "regionReq", "=", "req", ".", "service", "[", "reqOperation", "]", "(", "reqParams", ")", ";", "regionReq", ".", "_requestRegionForBucket", "=", "bucket", ";", "regionReq", ".", "send", "(", "function", "(", ")", "{", "var", "region", "=", "req", ".", "service", ".", "bucketRegionCache", "[", "bucket", "]", "||", "null", ";", "error", ".", "region", "=", "region", ";", "done", "(", ")", ";", "}", ")", ";", "}" ]
If region was not obtained synchronously, then send async request to get bucket region for errors resulting from wrong region. @api private
[ "If", "region", "was", "not", "obtained", "synchronously", "then", "send", "async", "request", "to", "get", "bucket", "region", "for", "errors", "resulting", "from", "wrong", "region", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L600-L621
train
aws/aws-sdk-js
lib/services/s3.js
reqRegionForNetworkingError
function reqRegionForNetworkingError(resp, done) { if (!AWS.util.isBrowser()) { return done(); } var error = resp.error; var request = resp.request; var bucket = request.params.Bucket; if (!error || error.code !== 'NetworkingError' || !bucket || request.httpRequest.region === 'us-east-1') { return done(); } var service = request.service; var bucketRegionCache = service.bucketRegionCache; var cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion && cachedRegion !== request.httpRequest.region) { service.updateReqBucketRegion(request, cachedRegion); done(); } else if (!service.dnsCompatibleBucketName(bucket)) { service.updateReqBucketRegion(request, 'us-east-1'); if (bucketRegionCache[bucket] !== 'us-east-1') { bucketRegionCache[bucket] = 'us-east-1'; } done(); } else if (request.httpRequest.virtualHostedBucket) { var getRegionReq = service.listObjects({Bucket: bucket, MaxKeys: 0}); service.updateReqBucketRegion(getRegionReq, 'us-east-1'); getRegionReq._requestRegionForBucket = bucket; getRegionReq.send(function() { var region = service.bucketRegionCache[bucket] || null; if (region && region !== request.httpRequest.region) { service.updateReqBucketRegion(request, region); } done(); }); } else { // DNS-compatible path-style // (s3ForcePathStyle or bucket name with dot over https) // Cannot obtain region information for this case done(); } }
javascript
function reqRegionForNetworkingError(resp, done) { if (!AWS.util.isBrowser()) { return done(); } var error = resp.error; var request = resp.request; var bucket = request.params.Bucket; if (!error || error.code !== 'NetworkingError' || !bucket || request.httpRequest.region === 'us-east-1') { return done(); } var service = request.service; var bucketRegionCache = service.bucketRegionCache; var cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion && cachedRegion !== request.httpRequest.region) { service.updateReqBucketRegion(request, cachedRegion); done(); } else if (!service.dnsCompatibleBucketName(bucket)) { service.updateReqBucketRegion(request, 'us-east-1'); if (bucketRegionCache[bucket] !== 'us-east-1') { bucketRegionCache[bucket] = 'us-east-1'; } done(); } else if (request.httpRequest.virtualHostedBucket) { var getRegionReq = service.listObjects({Bucket: bucket, MaxKeys: 0}); service.updateReqBucketRegion(getRegionReq, 'us-east-1'); getRegionReq._requestRegionForBucket = bucket; getRegionReq.send(function() { var region = service.bucketRegionCache[bucket] || null; if (region && region !== request.httpRequest.region) { service.updateReqBucketRegion(request, region); } done(); }); } else { // DNS-compatible path-style // (s3ForcePathStyle or bucket name with dot over https) // Cannot obtain region information for this case done(); } }
[ "function", "reqRegionForNetworkingError", "(", "resp", ",", "done", ")", "{", "if", "(", "!", "AWS", ".", "util", ".", "isBrowser", "(", ")", ")", "{", "return", "done", "(", ")", ";", "}", "var", "error", "=", "resp", ".", "error", ";", "var", "request", "=", "resp", ".", "request", ";", "var", "bucket", "=", "request", ".", "params", ".", "Bucket", ";", "if", "(", "!", "error", "||", "error", ".", "code", "!==", "'NetworkingError'", "||", "!", "bucket", "||", "request", ".", "httpRequest", ".", "region", "===", "'us-east-1'", ")", "{", "return", "done", "(", ")", ";", "}", "var", "service", "=", "request", ".", "service", ";", "var", "bucketRegionCache", "=", "service", ".", "bucketRegionCache", ";", "var", "cachedRegion", "=", "bucketRegionCache", "[", "bucket", "]", "||", "null", ";", "if", "(", "cachedRegion", "&&", "cachedRegion", "!==", "request", ".", "httpRequest", ".", "region", ")", "{", "service", ".", "updateReqBucketRegion", "(", "request", ",", "cachedRegion", ")", ";", "done", "(", ")", ";", "}", "else", "if", "(", "!", "service", ".", "dnsCompatibleBucketName", "(", "bucket", ")", ")", "{", "service", ".", "updateReqBucketRegion", "(", "request", ",", "'us-east-1'", ")", ";", "if", "(", "bucketRegionCache", "[", "bucket", "]", "!==", "'us-east-1'", ")", "{", "bucketRegionCache", "[", "bucket", "]", "=", "'us-east-1'", ";", "}", "done", "(", ")", ";", "}", "else", "if", "(", "request", ".", "httpRequest", ".", "virtualHostedBucket", ")", "{", "var", "getRegionReq", "=", "service", ".", "listObjects", "(", "{", "Bucket", ":", "bucket", ",", "MaxKeys", ":", "0", "}", ")", ";", "service", ".", "updateReqBucketRegion", "(", "getRegionReq", ",", "'us-east-1'", ")", ";", "getRegionReq", ".", "_requestRegionForBucket", "=", "bucket", ";", "getRegionReq", ".", "send", "(", "function", "(", ")", "{", "var", "region", "=", "service", ".", "bucketRegionCache", "[", "bucket", "]", "||", "null", ";", "if", "(", "region", "&&", "region", "!==", "request", ".", "httpRequest", ".", "region", ")", "{", "service", ".", "updateReqBucketRegion", "(", "request", ",", "region", ")", ";", "}", "done", "(", ")", ";", "}", ")", ";", "}", "else", "{", "done", "(", ")", ";", "}", "}" ]
For browser only. If NetworkingError received, will attempt to obtain the bucket region. @api private
[ "For", "browser", "only", ".", "If", "NetworkingError", "received", "will", "attempt", "to", "obtain", "the", "bucket", "region", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L629-L671
train
aws/aws-sdk-js
lib/services/s3.js
function(buckets) { var bucketRegionCache = this.bucketRegionCache; if (!buckets) { buckets = Object.keys(bucketRegionCache); } else if (typeof buckets === 'string') { buckets = [buckets]; } for (var i = 0; i < buckets.length; i++) { delete bucketRegionCache[buckets[i]]; } return bucketRegionCache; }
javascript
function(buckets) { var bucketRegionCache = this.bucketRegionCache; if (!buckets) { buckets = Object.keys(bucketRegionCache); } else if (typeof buckets === 'string') { buckets = [buckets]; } for (var i = 0; i < buckets.length; i++) { delete bucketRegionCache[buckets[i]]; } return bucketRegionCache; }
[ "function", "(", "buckets", ")", "{", "var", "bucketRegionCache", "=", "this", ".", "bucketRegionCache", ";", "if", "(", "!", "buckets", ")", "{", "buckets", "=", "Object", ".", "keys", "(", "bucketRegionCache", ")", ";", "}", "else", "if", "(", "typeof", "buckets", "===", "'string'", ")", "{", "buckets", "=", "[", "buckets", "]", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "buckets", ".", "length", ";", "i", "++", ")", "{", "delete", "bucketRegionCache", "[", "buckets", "[", "i", "]", "]", ";", "}", "return", "bucketRegionCache", ";", "}" ]
Clears bucket region cache. @api private
[ "Clears", "bucket", "region", "cache", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L685-L696
train
aws/aws-sdk-js
lib/services/s3.js
correctBucketRegionFromCache
function correctBucketRegionFromCache(req) { var bucket = req.params.Bucket || null; if (bucket) { var service = req.service; var requestRegion = req.httpRequest.region; var cachedRegion = service.bucketRegionCache[bucket]; if (cachedRegion && cachedRegion !== requestRegion) { service.updateReqBucketRegion(req, cachedRegion); } } }
javascript
function correctBucketRegionFromCache(req) { var bucket = req.params.Bucket || null; if (bucket) { var service = req.service; var requestRegion = req.httpRequest.region; var cachedRegion = service.bucketRegionCache[bucket]; if (cachedRegion && cachedRegion !== requestRegion) { service.updateReqBucketRegion(req, cachedRegion); } } }
[ "function", "correctBucketRegionFromCache", "(", "req", ")", "{", "var", "bucket", "=", "req", ".", "params", ".", "Bucket", "||", "null", ";", "if", "(", "bucket", ")", "{", "var", "service", "=", "req", ".", "service", ";", "var", "requestRegion", "=", "req", ".", "httpRequest", ".", "region", ";", "var", "cachedRegion", "=", "service", ".", "bucketRegionCache", "[", "bucket", "]", ";", "if", "(", "cachedRegion", "&&", "cachedRegion", "!==", "requestRegion", ")", "{", "service", ".", "updateReqBucketRegion", "(", "req", ",", "cachedRegion", ")", ";", "}", "}", "}" ]
Corrects request region if bucket's cached region is different @api private
[ "Corrects", "request", "region", "if", "bucket", "s", "cached", "region", "is", "different" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L703-L713
train
aws/aws-sdk-js
lib/services/s3.js
extractRequestIds
function extractRequestIds(resp) { var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null; var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null; resp.extendedRequestId = extendedRequestId; resp.cfId = cfId; if (resp.error) { resp.error.requestId = resp.requestId || null; resp.error.extendedRequestId = extendedRequestId; resp.error.cfId = cfId; } }
javascript
function extractRequestIds(resp) { var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null; var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null; resp.extendedRequestId = extendedRequestId; resp.cfId = cfId; if (resp.error) { resp.error.requestId = resp.requestId || null; resp.error.extendedRequestId = extendedRequestId; resp.error.cfId = cfId; } }
[ "function", "extractRequestIds", "(", "resp", ")", "{", "var", "extendedRequestId", "=", "resp", ".", "httpResponse", ".", "headers", "?", "resp", ".", "httpResponse", ".", "headers", "[", "'x-amz-id-2'", "]", ":", "null", ";", "var", "cfId", "=", "resp", ".", "httpResponse", ".", "headers", "?", "resp", ".", "httpResponse", ".", "headers", "[", "'x-amz-cf-id'", "]", ":", "null", ";", "resp", ".", "extendedRequestId", "=", "extendedRequestId", ";", "resp", ".", "cfId", "=", "cfId", ";", "if", "(", "resp", ".", "error", ")", "{", "resp", ".", "error", ".", "requestId", "=", "resp", ".", "requestId", "||", "null", ";", "resp", ".", "error", ".", "extendedRequestId", "=", "extendedRequestId", ";", "resp", ".", "error", ".", "cfId", "=", "cfId", ";", "}", "}" ]
Extracts S3 specific request ids from the http response. @api private
[ "Extracts", "S3", "specific", "request", "ids", "from", "the", "http", "response", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L720-L731
train
aws/aws-sdk-js
lib/services/s3.js
getSignedUrl
function getSignedUrl(operation, params, callback) { params = AWS.util.copy(params || {}); var expires = params.Expires || 900; delete params.Expires; // we can't validate this var request = this.makeRequest(operation, params); if (callback) { AWS.util.defer(function() { request.presign(expires, callback); }); } else { return request.presign(expires, callback); } }
javascript
function getSignedUrl(operation, params, callback) { params = AWS.util.copy(params || {}); var expires = params.Expires || 900; delete params.Expires; // we can't validate this var request = this.makeRequest(operation, params); if (callback) { AWS.util.defer(function() { request.presign(expires, callback); }); } else { return request.presign(expires, callback); } }
[ "function", "getSignedUrl", "(", "operation", ",", "params", ",", "callback", ")", "{", "params", "=", "AWS", ".", "util", ".", "copy", "(", "params", "||", "{", "}", ")", ";", "var", "expires", "=", "params", ".", "Expires", "||", "900", ";", "delete", "params", ".", "Expires", ";", "var", "request", "=", "this", ".", "makeRequest", "(", "operation", ",", "params", ")", ";", "if", "(", "callback", ")", "{", "AWS", ".", "util", ".", "defer", "(", "function", "(", ")", "{", "request", ".", "presign", "(", "expires", ",", "callback", ")", ";", "}", ")", ";", "}", "else", "{", "return", "request", ".", "presign", "(", "expires", ",", "callback", ")", ";", "}", "}" ]
Get a pre-signed URL for a given operation name. @note You must ensure that you have static or previously resolved credentials if you call this method synchronously (with no callback), otherwise it may not properly sign the request. If you cannot guarantee this (you are using an asynchronous credential provider, i.e., EC2 IAM roles), you should always call this method with an asynchronous callback. @note Not all operation parameters are supported when using pre-signed URLs. Certain parameters, such as `SSECustomerKey`, `ACL`, `Expires`, `ContentLength`, or `Tagging` must be provided as headers when sending a request. If you are using pre-signed URLs to upload from a browser and need to use these fields, see {createPresignedPost}. @note The default signer allows altering the request by adding corresponding headers to set some parameters (e.g. Range) and these added parameters won't be signed. You must use signatureVersion v4 to to include these parameters in the signed portion of the URL and enforce exact matching between headers and signed params in the URL. @note This operation cannot be used with a promise. See note above regarding asynchronous credentials and use with a callback. @param operation [String] the name of the operation to call @param params [map] parameters to pass to the operation. See the given operation for the expected operation parameters. In addition, you can also pass the "Expires" parameter to inform S3 how long the URL should work for. @option params Expires [Integer] (900) the number of seconds to expire the pre-signed URL operation in. Defaults to 15 minutes. @param callback [Function] if a callback is provided, this function will pass the URL as the second parameter (after the error parameter) to the callback function. @return [String] if called synchronously (with no callback), returns the signed URL. @return [null] nothing is returned if a callback is provided. @example Pre-signing a getObject operation (synchronously) var params = {Bucket: 'bucket', Key: 'key'}; var url = s3.getSignedUrl('getObject', params); console.log('The URL is', url); @example Pre-signing a putObject (asynchronously) var params = {Bucket: 'bucket', Key: 'key'}; s3.getSignedUrl('putObject', params, function (err, url) { console.log('The URL is', url); }); @example Pre-signing a putObject operation with a specific payload var params = {Bucket: 'bucket', Key: 'key', Body: 'body'}; var url = s3.getSignedUrl('putObject', params); console.log('The URL is', url); @example Passing in a 1-minute expiry time for a pre-signed URL var params = {Bucket: 'bucket', Key: 'key', Expires: 60}; var url = s3.getSignedUrl('getObject', params); console.log('The URL is', url); // expires in 60 seconds
[ "Get", "a", "pre", "-", "signed", "URL", "for", "a", "given", "operation", "name", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L785-L798
train
aws/aws-sdk-js
lib/services/s3.js
createPresignedPost
function createPresignedPost(params, callback) { if (typeof params === 'function' && callback === undefined) { callback = params; params = null; } params = AWS.util.copy(params || {}); var boundParams = this.config.params || {}; var bucket = params.Bucket || boundParams.Bucket, self = this, config = this.config, endpoint = AWS.util.copy(this.endpoint); if (!config.s3BucketEndpoint) { endpoint.pathname = '/' + bucket; } function finalizePost() { return { url: AWS.util.urlFormat(endpoint), fields: self.preparePostFields( config.credentials, config.region, bucket, params.Fields, params.Conditions, params.Expires ) }; } if (callback) { config.getCredentials(function (err) { if (err) { callback(err); } callback(null, finalizePost()); }); } else { return finalizePost(); } }
javascript
function createPresignedPost(params, callback) { if (typeof params === 'function' && callback === undefined) { callback = params; params = null; } params = AWS.util.copy(params || {}); var boundParams = this.config.params || {}; var bucket = params.Bucket || boundParams.Bucket, self = this, config = this.config, endpoint = AWS.util.copy(this.endpoint); if (!config.s3BucketEndpoint) { endpoint.pathname = '/' + bucket; } function finalizePost() { return { url: AWS.util.urlFormat(endpoint), fields: self.preparePostFields( config.credentials, config.region, bucket, params.Fields, params.Conditions, params.Expires ) }; } if (callback) { config.getCredentials(function (err) { if (err) { callback(err); } callback(null, finalizePost()); }); } else { return finalizePost(); } }
[ "function", "createPresignedPost", "(", "params", ",", "callback", ")", "{", "if", "(", "typeof", "params", "===", "'function'", "&&", "callback", "===", "undefined", ")", "{", "callback", "=", "params", ";", "params", "=", "null", ";", "}", "params", "=", "AWS", ".", "util", ".", "copy", "(", "params", "||", "{", "}", ")", ";", "var", "boundParams", "=", "this", ".", "config", ".", "params", "||", "{", "}", ";", "var", "bucket", "=", "params", ".", "Bucket", "||", "boundParams", ".", "Bucket", ",", "self", "=", "this", ",", "config", "=", "this", ".", "config", ",", "endpoint", "=", "AWS", ".", "util", ".", "copy", "(", "this", ".", "endpoint", ")", ";", "if", "(", "!", "config", ".", "s3BucketEndpoint", ")", "{", "endpoint", ".", "pathname", "=", "'/'", "+", "bucket", ";", "}", "function", "finalizePost", "(", ")", "{", "return", "{", "url", ":", "AWS", ".", "util", ".", "urlFormat", "(", "endpoint", ")", ",", "fields", ":", "self", ".", "preparePostFields", "(", "config", ".", "credentials", ",", "config", ".", "region", ",", "bucket", ",", "params", ".", "Fields", ",", "params", ".", "Conditions", ",", "params", ".", "Expires", ")", "}", ";", "}", "if", "(", "callback", ")", "{", "config", ".", "getCredentials", "(", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "}", "callback", "(", "null", ",", "finalizePost", "(", ")", ")", ";", "}", ")", ";", "}", "else", "{", "return", "finalizePost", "(", ")", ";", "}", "}" ]
Get a pre-signed POST policy to support uploading to S3 directly from an HTML form. @param params [map] @option params Bucket [String] The bucket to which the post should be uploaded @option params Expires [Integer] (3600) The number of seconds for which the presigned policy should be valid. @option params Conditions [Array] An array of conditions that must be met for the presigned policy to allow the upload. This can include required tags, the accepted range for content lengths, etc. @see http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html @option params Fields [map] Fields to include in the form. All values passed in as fields will be signed as exact match conditions. @param callback [Function] @note All fields passed in when creating presigned post data will be signed as exact match conditions. Any fields that will be interpolated by S3 must be added to the fields hash after signing, and an appropriate condition for such fields must be explicitly added to the Conditions array passed to this function before signing. @example Presiging post data with a known key var params = { Bucket: 'bucket', Fields: { key: 'key' } }; s3.createPresignedPost(params, function(err, data) { if (err) { console.error('Presigning post data encountered an error', err); } else { console.log('The post data is', data); } }); @example Presigning post data with an interpolated key var params = { Bucket: 'bucket', Conditions: [ ['starts-with', '$key', 'path/to/uploads/'] ] }; s3.createPresignedPost(params, function(err, data) { if (err) { console.error('Presigning post data encountered an error', err); } else { data.Fields.key = 'path/to/uploads/${filename}'; console.log('The post data is', data); } }); @note You must ensure that you have static or previously resolved credentials if you call this method synchronously (with no callback), otherwise it may not properly sign the request. If you cannot guarantee this (you are using an asynchronous credential provider, i.e., EC2 IAM roles), you should always call this method with an asynchronous callback. @return [map] If called synchronously (with no callback), returns a hash with the url to set as the form action and a hash of fields to include in the form. @return [null] Nothing is returned if a callback is provided. @callback callback function (err, data) @param err [Error] the error object returned from the policy signer @param data [map] The data necessary to construct an HTML form @param data.url [String] The URL to use as the action of the form @param data.fields [map] A hash of fields that must be included in the form for the upload to succeed. This hash will include the signed POST policy, your access key ID and security token (if present), etc. These may be safely included as input elements of type 'hidden.'
[ "Get", "a", "pre", "-", "signed", "POST", "policy", "to", "support", "uploading", "to", "S3", "directly", "from", "an", "HTML", "form", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L881-L922
train
aws/aws-sdk-js
lib/dynamodb/converter.js
convertInput
function convertInput(data, options) { options = options || {}; var type = typeOf(data); if (type === 'Object') { return formatMap(data, options); } else if (type === 'Array') { return formatList(data, options); } else if (type === 'Set') { return formatSet(data, options); } else if (type === 'String') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { S: data }; } else if (type === 'Number' || type === 'NumberValue') { return { N: data.toString() }; } else if (type === 'Binary') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { B: data }; } else if (type === 'Boolean') { return { BOOL: data }; } else if (type === 'null') { return { NULL: true }; } else if (type !== 'undefined' && type !== 'Function') { // this value has a custom constructor return formatMap(data, options); } }
javascript
function convertInput(data, options) { options = options || {}; var type = typeOf(data); if (type === 'Object') { return formatMap(data, options); } else if (type === 'Array') { return formatList(data, options); } else if (type === 'Set') { return formatSet(data, options); } else if (type === 'String') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { S: data }; } else if (type === 'Number' || type === 'NumberValue') { return { N: data.toString() }; } else if (type === 'Binary') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { B: data }; } else if (type === 'Boolean') { return { BOOL: data }; } else if (type === 'null') { return { NULL: true }; } else if (type !== 'undefined' && type !== 'Function') { // this value has a custom constructor return formatMap(data, options); } }
[ "function", "convertInput", "(", "data", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "type", "=", "typeOf", "(", "data", ")", ";", "if", "(", "type", "===", "'Object'", ")", "{", "return", "formatMap", "(", "data", ",", "options", ")", ";", "}", "else", "if", "(", "type", "===", "'Array'", ")", "{", "return", "formatList", "(", "data", ",", "options", ")", ";", "}", "else", "if", "(", "type", "===", "'Set'", ")", "{", "return", "formatSet", "(", "data", ",", "options", ")", ";", "}", "else", "if", "(", "type", "===", "'String'", ")", "{", "if", "(", "data", ".", "length", "===", "0", "&&", "options", ".", "convertEmptyValues", ")", "{", "return", "convertInput", "(", "null", ")", ";", "}", "return", "{", "S", ":", "data", "}", ";", "}", "else", "if", "(", "type", "===", "'Number'", "||", "type", "===", "'NumberValue'", ")", "{", "return", "{", "N", ":", "data", ".", "toString", "(", ")", "}", ";", "}", "else", "if", "(", "type", "===", "'Binary'", ")", "{", "if", "(", "data", ".", "length", "===", "0", "&&", "options", ".", "convertEmptyValues", ")", "{", "return", "convertInput", "(", "null", ")", ";", "}", "return", "{", "B", ":", "data", "}", ";", "}", "else", "if", "(", "type", "===", "'Boolean'", ")", "{", "return", "{", "BOOL", ":", "data", "}", ";", "}", "else", "if", "(", "type", "===", "'null'", ")", "{", "return", "{", "NULL", ":", "true", "}", ";", "}", "else", "if", "(", "type", "!==", "'undefined'", "&&", "type", "!==", "'Function'", ")", "{", "return", "formatMap", "(", "data", ",", "options", ")", ";", "}", "}" ]
Convert a JavaScript value to its equivalent DynamoDB AttributeValue type @param data [any] The data to convert to a DynamoDB AttributeValue @param options [map] @option options convertEmptyValues [Boolean] Whether to automatically convert empty strings, blobs, and sets to `null` @option options wrapNumbers [Boolean] Whether to return numbers as a NumberValue object instead of converting them to native JavaScript numbers. This allows for the safe round-trip transport of numbers of arbitrary size. @return [map] An object in the Amazon DynamoDB AttributeValue format @see AWS.DynamoDB.Converter.marshall AWS.DynamoDB.Converter.marshall to convert entire records (rather than individual attributes)
[ "Convert", "a", "JavaScript", "value", "to", "its", "equivalent", "DynamoDB", "AttributeValue", "type" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/converter.js#L27-L56
train
aws/aws-sdk-js
lib/dynamodb/converter.js
marshallItem
function marshallItem(data, options) { return AWS.DynamoDB.Converter.input(data, options).M; }
javascript
function marshallItem(data, options) { return AWS.DynamoDB.Converter.input(data, options).M; }
[ "function", "marshallItem", "(", "data", ",", "options", ")", "{", "return", "AWS", ".", "DynamoDB", ".", "Converter", ".", "input", "(", "data", ",", "options", ")", ".", "M", ";", "}" ]
Convert a JavaScript object into a DynamoDB record. @param data [any] The data to convert to a DynamoDB record @param options [map] @option options convertEmptyValues [Boolean] Whether to automatically convert empty strings, blobs, and sets to `null` @option options wrapNumbers [Boolean] Whether to return numbers as a NumberValue object instead of converting them to native JavaScript numbers. This allows for the safe round-trip transport of numbers of arbitrary size. @return [map] An object in the DynamoDB record format. @example Convert a JavaScript object into a DynamoDB record var marshalled = AWS.DynamoDB.Converter.marshall({ string: 'foo', list: ['fizz', 'buzz', 'pop'], map: { nestedMap: { key: 'value', } }, number: 123, nullValue: null, boolValue: true, stringSet: new DynamoDBSet(['foo', 'bar', 'baz']) });
[ "Convert", "a", "JavaScript", "object", "into", "a", "DynamoDB", "record", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/converter.js#L90-L92
train
aws/aws-sdk-js
lib/dynamodb/converter.js
convertOutput
function convertOutput(data, options) { options = options || {}; var list, map, i; for (var type in data) { var values = data[type]; if (type === 'M') { map = {}; for (var key in values) { map[key] = convertOutput(values[key], options); } return map; } else if (type === 'L') { list = []; for (i = 0; i < values.length; i++) { list.push(convertOutput(values[i], options)); } return list; } else if (type === 'SS') { list = []; for (i = 0; i < values.length; i++) { list.push(values[i] + ''); } return new DynamoDBSet(list); } else if (type === 'NS') { list = []; for (i = 0; i < values.length; i++) { list.push(convertNumber(values[i], options.wrapNumbers)); } return new DynamoDBSet(list); } else if (type === 'BS') { list = []; for (i = 0; i < values.length; i++) { list.push(new util.Buffer(values[i])); } return new DynamoDBSet(list); } else if (type === 'S') { return values + ''; } else if (type === 'N') { return convertNumber(values, options.wrapNumbers); } else if (type === 'B') { return new util.Buffer(values); } else if (type === 'BOOL') { return (values === 'true' || values === 'TRUE' || values === true); } else if (type === 'NULL') { return null; } } }
javascript
function convertOutput(data, options) { options = options || {}; var list, map, i; for (var type in data) { var values = data[type]; if (type === 'M') { map = {}; for (var key in values) { map[key] = convertOutput(values[key], options); } return map; } else if (type === 'L') { list = []; for (i = 0; i < values.length; i++) { list.push(convertOutput(values[i], options)); } return list; } else if (type === 'SS') { list = []; for (i = 0; i < values.length; i++) { list.push(values[i] + ''); } return new DynamoDBSet(list); } else if (type === 'NS') { list = []; for (i = 0; i < values.length; i++) { list.push(convertNumber(values[i], options.wrapNumbers)); } return new DynamoDBSet(list); } else if (type === 'BS') { list = []; for (i = 0; i < values.length; i++) { list.push(new util.Buffer(values[i])); } return new DynamoDBSet(list); } else if (type === 'S') { return values + ''; } else if (type === 'N') { return convertNumber(values, options.wrapNumbers); } else if (type === 'B') { return new util.Buffer(values); } else if (type === 'BOOL') { return (values === 'true' || values === 'TRUE' || values === true); } else if (type === 'NULL') { return null; } } }
[ "function", "convertOutput", "(", "data", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "list", ",", "map", ",", "i", ";", "for", "(", "var", "type", "in", "data", ")", "{", "var", "values", "=", "data", "[", "type", "]", ";", "if", "(", "type", "===", "'M'", ")", "{", "map", "=", "{", "}", ";", "for", "(", "var", "key", "in", "values", ")", "{", "map", "[", "key", "]", "=", "convertOutput", "(", "values", "[", "key", "]", ",", "options", ")", ";", "}", "return", "map", ";", "}", "else", "if", "(", "type", "===", "'L'", ")", "{", "list", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "list", ".", "push", "(", "convertOutput", "(", "values", "[", "i", "]", ",", "options", ")", ")", ";", "}", "return", "list", ";", "}", "else", "if", "(", "type", "===", "'SS'", ")", "{", "list", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "list", ".", "push", "(", "values", "[", "i", "]", "+", "''", ")", ";", "}", "return", "new", "DynamoDBSet", "(", "list", ")", ";", "}", "else", "if", "(", "type", "===", "'NS'", ")", "{", "list", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "list", ".", "push", "(", "convertNumber", "(", "values", "[", "i", "]", ",", "options", ".", "wrapNumbers", ")", ")", ";", "}", "return", "new", "DynamoDBSet", "(", "list", ")", ";", "}", "else", "if", "(", "type", "===", "'BS'", ")", "{", "list", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "list", ".", "push", "(", "new", "util", ".", "Buffer", "(", "values", "[", "i", "]", ")", ")", ";", "}", "return", "new", "DynamoDBSet", "(", "list", ")", ";", "}", "else", "if", "(", "type", "===", "'S'", ")", "{", "return", "values", "+", "''", ";", "}", "else", "if", "(", "type", "===", "'N'", ")", "{", "return", "convertNumber", "(", "values", ",", "options", ".", "wrapNumbers", ")", ";", "}", "else", "if", "(", "type", "===", "'B'", ")", "{", "return", "new", "util", ".", "Buffer", "(", "values", ")", ";", "}", "else", "if", "(", "type", "===", "'BOOL'", ")", "{", "return", "(", "values", "===", "'true'", "||", "values", "===", "'TRUE'", "||", "values", "===", "true", ")", ";", "}", "else", "if", "(", "type", "===", "'NULL'", ")", "{", "return", "null", ";", "}", "}", "}" ]
Convert a DynamoDB AttributeValue object to its equivalent JavaScript type. @param data [map] An object in the Amazon DynamoDB AttributeValue format @param options [map] @option options convertEmptyValues [Boolean] Whether to automatically convert empty strings, blobs, and sets to `null` @option options wrapNumbers [Boolean] Whether to return numbers as a NumberValue object instead of converting them to native JavaScript numbers. This allows for the safe round-trip transport of numbers of arbitrary size. @return [Object|Array|String|Number|Boolean|null] @see AWS.DynamoDB.Converter.unmarshall AWS.DynamoDB.Converter.unmarshall to convert entire records (rather than individual attributes)
[ "Convert", "a", "DynamoDB", "AttributeValue", "object", "to", "its", "equivalent", "JavaScript", "type", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/converter.js#L114-L161
train
aws/aws-sdk-js
lib/dynamodb/converter.js
unmarshall
function unmarshall(data, options) { return AWS.DynamoDB.Converter.output({M: data}, options); }
javascript
function unmarshall(data, options) { return AWS.DynamoDB.Converter.output({M: data}, options); }
[ "function", "unmarshall", "(", "data", ",", "options", ")", "{", "return", "AWS", ".", "DynamoDB", ".", "Converter", ".", "output", "(", "{", "M", ":", "data", "}", ",", "options", ")", ";", "}" ]
Convert a DynamoDB record into a JavaScript object. @param data [any] The DynamoDB record @param options [map] @option options convertEmptyValues [Boolean] Whether to automatically convert empty strings, blobs, and sets to `null` @option options wrapNumbers [Boolean] Whether to return numbers as a NumberValue object instead of converting them to native JavaScript numbers. This allows for the safe round-trip transport of numbers of arbitrary size. @return [map] An object whose properties have been converted from DynamoDB's AttributeValue format into their corresponding native JavaScript types. @example Convert a record received from a DynamoDB stream var unmarshalled = AWS.DynamoDB.Converter.unmarshall({ string: {S: 'foo'}, list: {L: [{S: 'fizz'}, {S: 'buzz'}, {S: 'pop'}]}, map: { M: { nestedMap: { M: { key: {S: 'value'} } } } }, number: {N: '123'}, nullValue: {NULL: true}, boolValue: {BOOL: true} });
[ "Convert", "a", "DynamoDB", "record", "into", "a", "JavaScript", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/converter.js#L200-L202
train
aws/aws-sdk-js
lib/protocol/helpers.js
populateHostPrefix
function populateHostPrefix(request) { var enabled = request.service.config.hostPrefixEnabled; if (!enabled) return request; var operationModel = request.service.api.operations[request.operation]; //don't marshal host prefix when operation has endpoint discovery traits if (hasEndpointDiscover(request)) return request; if (operationModel.endpoint && operationModel.endpoint.hostPrefix) { var hostPrefixNotation = operationModel.endpoint.hostPrefix; var hostPrefix = expandHostPrefix(hostPrefixNotation, request.params, operationModel.input); prependEndpointPrefix(request.httpRequest.endpoint, hostPrefix); validateHostname(request.httpRequest.endpoint.hostname); } return request; }
javascript
function populateHostPrefix(request) { var enabled = request.service.config.hostPrefixEnabled; if (!enabled) return request; var operationModel = request.service.api.operations[request.operation]; //don't marshal host prefix when operation has endpoint discovery traits if (hasEndpointDiscover(request)) return request; if (operationModel.endpoint && operationModel.endpoint.hostPrefix) { var hostPrefixNotation = operationModel.endpoint.hostPrefix; var hostPrefix = expandHostPrefix(hostPrefixNotation, request.params, operationModel.input); prependEndpointPrefix(request.httpRequest.endpoint, hostPrefix); validateHostname(request.httpRequest.endpoint.hostname); } return request; }
[ "function", "populateHostPrefix", "(", "request", ")", "{", "var", "enabled", "=", "request", ".", "service", ".", "config", ".", "hostPrefixEnabled", ";", "if", "(", "!", "enabled", ")", "return", "request", ";", "var", "operationModel", "=", "request", ".", "service", ".", "api", ".", "operations", "[", "request", ".", "operation", "]", ";", "if", "(", "hasEndpointDiscover", "(", "request", ")", ")", "return", "request", ";", "if", "(", "operationModel", ".", "endpoint", "&&", "operationModel", ".", "endpoint", ".", "hostPrefix", ")", "{", "var", "hostPrefixNotation", "=", "operationModel", ".", "endpoint", ".", "hostPrefix", ";", "var", "hostPrefix", "=", "expandHostPrefix", "(", "hostPrefixNotation", ",", "request", ".", "params", ",", "operationModel", ".", "input", ")", ";", "prependEndpointPrefix", "(", "request", ".", "httpRequest", ".", "endpoint", ",", "hostPrefix", ")", ";", "validateHostname", "(", "request", ".", "httpRequest", ".", "endpoint", ".", "hostname", ")", ";", "}", "return", "request", ";", "}" ]
Prepend prefix defined by API model to endpoint that's already constructed. This feature does not apply to operations using endpoint discovery and can be disabled. @api private
[ "Prepend", "prefix", "defined", "by", "API", "model", "to", "endpoint", "that", "s", "already", "constructed", ".", "This", "feature", "does", "not", "apply", "to", "operations", "using", "endpoint", "discovery", "and", "can", "be", "disabled", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/protocol/helpers.js#L10-L23
train
aws/aws-sdk-js
lib/config.js
loadFromPath
function loadFromPath(path) { this.clear(); var options = JSON.parse(AWS.util.readFileSync(path)); var fileSystemCreds = new AWS.FileSystemCredentials(path); var chain = new AWS.CredentialProviderChain(); chain.providers.unshift(fileSystemCreds); chain.resolve(function (err, creds) { if (err) throw err; else options.credentials = creds; }); this.constructor(options); return this; }
javascript
function loadFromPath(path) { this.clear(); var options = JSON.parse(AWS.util.readFileSync(path)); var fileSystemCreds = new AWS.FileSystemCredentials(path); var chain = new AWS.CredentialProviderChain(); chain.providers.unshift(fileSystemCreds); chain.resolve(function (err, creds) { if (err) throw err; else options.credentials = creds; }); this.constructor(options); return this; }
[ "function", "loadFromPath", "(", "path", ")", "{", "this", ".", "clear", "(", ")", ";", "var", "options", "=", "JSON", ".", "parse", "(", "AWS", ".", "util", ".", "readFileSync", "(", "path", ")", ")", ";", "var", "fileSystemCreds", "=", "new", "AWS", ".", "FileSystemCredentials", "(", "path", ")", ";", "var", "chain", "=", "new", "AWS", ".", "CredentialProviderChain", "(", ")", ";", "chain", ".", "providers", ".", "unshift", "(", "fileSystemCreds", ")", ";", "chain", ".", "resolve", "(", "function", "(", "err", ",", "creds", ")", "{", "if", "(", "err", ")", "throw", "err", ";", "else", "options", ".", "credentials", "=", "creds", ";", "}", ")", ";", "this", ".", "constructor", "(", "options", ")", ";", "return", "this", ";", "}" ]
Loads configuration data from a JSON file into this config object. @note Loading configuration will reset all existing configuration on the object. @!macro nobrowser @param path [String] the path relative to your process's current working directory to load configuration from. @return [AWS.Config] the same configuration object
[ "Loads", "configuration", "data", "from", "a", "JSON", "file", "into", "this", "config", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L434-L449
train
aws/aws-sdk-js
lib/config.js
extractCredentials
function extractCredentials(options) { if (options.accessKeyId && options.secretAccessKey) { options = AWS.util.copy(options); options.credentials = new AWS.Credentials(options); } return options; }
javascript
function extractCredentials(options) { if (options.accessKeyId && options.secretAccessKey) { options = AWS.util.copy(options); options.credentials = new AWS.Credentials(options); } return options; }
[ "function", "extractCredentials", "(", "options", ")", "{", "if", "(", "options", ".", "accessKeyId", "&&", "options", ".", "secretAccessKey", ")", "{", "options", "=", "AWS", ".", "util", ".", "copy", "(", "options", ")", ";", "options", ".", "credentials", "=", "new", "AWS", ".", "Credentials", "(", "options", ")", ";", "}", "return", "options", ";", "}" ]
Extracts accessKeyId, secretAccessKey and sessionToken from a configuration hash. @api private
[ "Extracts", "accessKeyId", "secretAccessKey", "and", "sessionToken", "from", "a", "configuration", "hash", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L536-L542
train
aws/aws-sdk-js
lib/config.js
setPromisesDependency
function setPromisesDependency(dep) { PromisesDependency = dep; // if null was passed in, we should try to use native promises if (dep === null && typeof Promise === 'function') { PromisesDependency = Promise; } var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain]; if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload); AWS.util.addPromises(constructors, PromisesDependency); }
javascript
function setPromisesDependency(dep) { PromisesDependency = dep; // if null was passed in, we should try to use native promises if (dep === null && typeof Promise === 'function') { PromisesDependency = Promise; } var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain]; if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload); AWS.util.addPromises(constructors, PromisesDependency); }
[ "function", "setPromisesDependency", "(", "dep", ")", "{", "PromisesDependency", "=", "dep", ";", "if", "(", "dep", "===", "null", "&&", "typeof", "Promise", "===", "'function'", ")", "{", "PromisesDependency", "=", "Promise", ";", "}", "var", "constructors", "=", "[", "AWS", ".", "Request", ",", "AWS", ".", "Credentials", ",", "AWS", ".", "CredentialProviderChain", "]", ";", "if", "(", "AWS", ".", "S3", "&&", "AWS", ".", "S3", ".", "ManagedUpload", ")", "constructors", ".", "push", "(", "AWS", ".", "S3", ".", "ManagedUpload", ")", ";", "AWS", ".", "util", ".", "addPromises", "(", "constructors", ",", "PromisesDependency", ")", ";", "}" ]
Sets the promise dependency the SDK will use wherever Promises are returned. Passing `null` will force the SDK to use native Promises if they are available. If native Promises are not available, passing `null` will have no effect. @param [Constructor] dep A reference to a Promise constructor
[ "Sets", "the", "promise", "dependency", "the", "SDK", "will", "use", "wherever", "Promises", "are", "returned", ".", "Passing", "null", "will", "force", "the", "SDK", "to", "use", "native", "Promises", "if", "they", "are", "available", ".", "If", "native", "Promises", "are", "not", "available", "passing", "null", "will", "have", "no", "effect", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L550-L559
train
aws/aws-sdk-js
doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js
function() { $('div[id] > :header:first').each(function() { $('<a class="headerlink">\u00B6</a>'). attr('href', '#' + this.id). attr('title', _('Permalink to this headline')). appendTo(this); }); $('dt[id]').each(function() { $('<a class="headerlink">\u00B6</a>'). attr('href', '#' + this.id). attr('title', _('Permalink to this definition')). appendTo(this); }); }
javascript
function() { $('div[id] > :header:first').each(function() { $('<a class="headerlink">\u00B6</a>'). attr('href', '#' + this.id). attr('title', _('Permalink to this headline')). appendTo(this); }); $('dt[id]').each(function() { $('<a class="headerlink">\u00B6</a>'). attr('href', '#' + this.id). attr('title', _('Permalink to this definition')). appendTo(this); }); }
[ "function", "(", ")", "{", "$", "(", "'div[id] > :header:first'", ")", ".", "each", "(", "function", "(", ")", "{", "$", "(", "'<a class=\"headerlink\">\\u00B6</a>'", ")", ".", "\\u00B6", "attr", ".", "(", "'href'", ",", "'#'", "+", "this", ".", "id", ")", "attr", ".", "(", "'title'", ",", "_", "(", "'Permalink to this headline'", ")", ")", "appendTo", ";", "}", ")", ";", "(", "this", ")", "}" ]
add context elements like header anchor links
[ "add", "context", "elements", "like", "header", "anchor", "links" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js#L150-L163
train
aws/aws-sdk-js
doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js
function() { if (document.location.hash && $.browser.mozilla) window.setTimeout(function() { document.location.href += ''; }, 10); }
javascript
function() { if (document.location.hash && $.browser.mozilla) window.setTimeout(function() { document.location.href += ''; }, 10); }
[ "function", "(", ")", "{", "if", "(", "document", ".", "location", ".", "hash", "&&", "$", ".", "browser", ".", "mozilla", ")", "window", ".", "setTimeout", "(", "function", "(", ")", "{", "document", ".", "location", ".", "href", "+=", "''", ";", "}", ",", "10", ")", ";", "}" ]
workaround a firefox stupidity
[ "workaround", "a", "firefox", "stupidity" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js#L168-L173
train
aws/aws-sdk-js
doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js
function() { var togglers = $('img.toggler').click(function() { var src = $(this).attr('src'); var idnum = $(this).attr('id').substr(7); $('tr.cg-' + idnum).toggle(); if (src.substr(-9) == 'minus.png') $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); else $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); }).css('display', ''); if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { togglers.click(); } }
javascript
function() { var togglers = $('img.toggler').click(function() { var src = $(this).attr('src'); var idnum = $(this).attr('id').substr(7); $('tr.cg-' + idnum).toggle(); if (src.substr(-9) == 'minus.png') $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); else $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); }).css('display', ''); if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { togglers.click(); } }
[ "function", "(", ")", "{", "var", "togglers", "=", "$", "(", "'img.toggler'", ")", ".", "click", "(", "function", "(", ")", "{", "var", "src", "=", "$", "(", "this", ")", ".", "attr", "(", "'src'", ")", ";", "var", "idnum", "=", "$", "(", "this", ")", ".", "attr", "(", "'id'", ")", ".", "substr", "(", "7", ")", ";", "$", "(", "'tr.cg-'", "+", "idnum", ")", ".", "toggle", "(", ")", ";", "if", "(", "src", ".", "substr", "(", "-", "9", ")", "==", "'minus.png'", ")", "$", "(", "this", ")", ".", "attr", "(", "'src'", ",", "src", ".", "substr", "(", "0", ",", "src", ".", "length", "-", "9", ")", "+", "'plus.png'", ")", ";", "else", "$", "(", "this", ")", ".", "attr", "(", "'src'", ",", "src", ".", "substr", "(", "0", ",", "src", ".", "length", "-", "8", ")", "+", "'minus.png'", ")", ";", "}", ")", ".", "css", "(", "'display'", ",", "''", ")", ";", "if", "(", "DOCUMENTATION_OPTIONS", ".", "COLLAPSE_INDEX", ")", "{", "togglers", ".", "click", "(", ")", ";", "}", "}" ]
init the domain index toggle buttons
[ "init", "the", "domain", "index", "toggle", "buttons" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js#L197-L210
train
aws/aws-sdk-js
doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js
function() { var path = document.location.pathname; var parts = path.split(/\//); $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { if (this == '..') parts.pop(); }); var url = parts.join('/'); return path.substring(url.lastIndexOf('/') + 1, path.length - 1); }
javascript
function() { var path = document.location.pathname; var parts = path.split(/\//); $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { if (this == '..') parts.pop(); }); var url = parts.join('/'); return path.substring(url.lastIndexOf('/') + 1, path.length - 1); }
[ "function", "(", ")", "{", "var", "path", "=", "document", ".", "location", ".", "pathname", ";", "var", "parts", "=", "path", ".", "split", "(", "/", "\\/", "/", ")", ";", "$", ".", "each", "(", "DOCUMENTATION_OPTIONS", ".", "URL_ROOT", ".", "split", "(", "/", "\\/", "/", ")", ",", "function", "(", ")", "{", "if", "(", "this", "==", "'..'", ")", "parts", ".", "pop", "(", ")", ";", "}", ")", ";", "var", "url", "=", "parts", ".", "join", "(", "'/'", ")", ";", "return", "path", ".", "substring", "(", "url", ".", "lastIndexOf", "(", "'/'", ")", "+", "1", ",", "path", ".", "length", "-", "1", ")", ";", "}" ]
get the current relative url
[ "get", "the", "current", "relative", "url" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js#L230-L239
train
aws/aws-sdk-js
lib/service.js
Service
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
javascript
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
[ "function", "Service", "(", "config", ")", "{", "if", "(", "!", "this", ".", "loadServiceClass", ")", "{", "throw", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", ")", ",", "'Service must be constructed with `new\\' operator'", ")", ";", "}", "\\'", "var", "ServiceClass", "=", "this", ".", "loadServiceClass", "(", "config", "||", "{", "}", ")", ";", "if", "(", "ServiceClass", ")", "{", "var", "originalConfig", "=", "AWS", ".", "util", ".", "copy", "(", "config", ")", ";", "var", "svc", "=", "new", "ServiceClass", "(", "config", ")", ";", "Object", ".", "defineProperty", "(", "svc", ",", "'_originalConfig'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "originalConfig", ";", "}", ",", "enumerable", ":", "false", ",", "configurable", ":", "true", "}", ")", ";", "svc", ".", "_clientId", "=", "++", "clientCount", ";", "return", "svc", ";", "}", "}" ]
Create a new service object with a configuration object @param config [map] a map of configuration options
[ "Create", "a", "new", "service", "object", "with", "a", "configuration", "object" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L23-L41
train
aws/aws-sdk-js
lib/service.js
makeRequest
function makeRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = null; } params = params || {}; if (this.config.params) { // copy only toplevel bound params var rules = this.api.operations[operation]; if (rules) { params = AWS.util.copy(params); AWS.util.each(this.config.params, function(key, value) { if (rules.input.members[key]) { if (params[key] === undefined || params[key] === null) { params[key] = value; } } }); } } var request = new AWS.Request(this, operation, params); this.addAllRequestListeners(request); this.attachMonitoringEmitter(request); if (callback) request.send(callback); return request; }
javascript
function makeRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = null; } params = params || {}; if (this.config.params) { // copy only toplevel bound params var rules = this.api.operations[operation]; if (rules) { params = AWS.util.copy(params); AWS.util.each(this.config.params, function(key, value) { if (rules.input.members[key]) { if (params[key] === undefined || params[key] === null) { params[key] = value; } } }); } } var request = new AWS.Request(this, operation, params); this.addAllRequestListeners(request); this.attachMonitoringEmitter(request); if (callback) request.send(callback); return request; }
[ "function", "makeRequest", "(", "operation", ",", "params", ",", "callback", ")", "{", "if", "(", "typeof", "params", "===", "'function'", ")", "{", "callback", "=", "params", ";", "params", "=", "null", ";", "}", "params", "=", "params", "||", "{", "}", ";", "if", "(", "this", ".", "config", ".", "params", ")", "{", "var", "rules", "=", "this", ".", "api", ".", "operations", "[", "operation", "]", ";", "if", "(", "rules", ")", "{", "params", "=", "AWS", ".", "util", ".", "copy", "(", "params", ")", ";", "AWS", ".", "util", ".", "each", "(", "this", ".", "config", ".", "params", ",", "function", "(", "key", ",", "value", ")", "{", "if", "(", "rules", ".", "input", ".", "members", "[", "key", "]", ")", "{", "if", "(", "params", "[", "key", "]", "===", "undefined", "||", "params", "[", "key", "]", "===", "null", ")", "{", "params", "[", "key", "]", "=", "value", ";", "}", "}", "}", ")", ";", "}", "}", "var", "request", "=", "new", "AWS", ".", "Request", "(", "this", ",", "operation", ",", "params", ")", ";", "this", ".", "addAllRequestListeners", "(", "request", ")", ";", "this", ".", "attachMonitoringEmitter", "(", "request", ")", ";", "if", "(", "callback", ")", "request", ".", "send", "(", "callback", ")", ";", "return", "request", ";", "}" ]
Calls an operation on a service with the given input parameters. @param operation [String] the name of the operation to call on the service. @param params [map] a map of input options for the operation @callback callback function(err, data) If a callback is supplied, it is called when a response is returned from the service. @param err [Error] the error object returned from the request. Set to `null` if the request is successful. @param data [Object] the de-serialized data returned from the request. Set to `null` if a request error occurs.
[ "Calls", "an", "operation", "on", "a", "service", "with", "the", "given", "input", "parameters", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L181-L207
train
aws/aws-sdk-js
lib/service.js
makeUnauthenticatedRequest
function makeUnauthenticatedRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = {}; } var request = this.makeRequest(operation, params).toUnauthenticated(); return callback ? request.send(callback) : request; }
javascript
function makeUnauthenticatedRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = {}; } var request = this.makeRequest(operation, params).toUnauthenticated(); return callback ? request.send(callback) : request; }
[ "function", "makeUnauthenticatedRequest", "(", "operation", ",", "params", ",", "callback", ")", "{", "if", "(", "typeof", "params", "===", "'function'", ")", "{", "callback", "=", "params", ";", "params", "=", "{", "}", ";", "}", "var", "request", "=", "this", ".", "makeRequest", "(", "operation", ",", "params", ")", ".", "toUnauthenticated", "(", ")", ";", "return", "callback", "?", "request", ".", "send", "(", "callback", ")", ":", "request", ";", "}" ]
Calls an operation on a service with the given input parameters, without any authentication data. This method is useful for "public" API operations. @param operation [String] the name of the operation to call on the service. @param params [map] a map of input options for the operation @callback callback function(err, data) If a callback is supplied, it is called when a response is returned from the service. @param err [Error] the error object returned from the request. Set to `null` if the request is successful. @param data [Object] the de-serialized data returned from the request. Set to `null` if a request error occurs.
[ "Calls", "an", "operation", "on", "a", "service", "with", "the", "given", "input", "parameters", "without", "any", "authentication", "data", ".", "This", "method", "is", "useful", "for", "public", "API", "operations", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L223-L231
train
aws/aws-sdk-js
lib/service.js
waitFor
function waitFor(state, params, callback) { var waiter = new AWS.ResourceWaiter(this, state); return waiter.wait(params, callback); }
javascript
function waitFor(state, params, callback) { var waiter = new AWS.ResourceWaiter(this, state); return waiter.wait(params, callback); }
[ "function", "waitFor", "(", "state", ",", "params", ",", "callback", ")", "{", "var", "waiter", "=", "new", "AWS", ".", "ResourceWaiter", "(", "this", ",", "state", ")", ";", "return", "waiter", ".", "wait", "(", "params", ",", "callback", ")", ";", "}" ]
Waits for a given state @param state [String] the state on the service to wait for @param params [map] a map of parameters to pass with each request @option params $waiter [map] a map of configuration options for the waiter @option params $waiter.delay [Number] The number of seconds to wait between requests @option params $waiter.maxAttempts [Number] The maximum number of requests to send while waiting @callback callback function(err, data) If a callback is supplied, it is called when a response is returned from the service. @param err [Error] the error object returned from the request. Set to `null` if the request is successful. @param data [Object] the de-serialized data returned from the request. Set to `null` if a request error occurs.
[ "Waits", "for", "a", "given", "state" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L251-L254
train
aws/aws-sdk-js
lib/service.js
apiCallEvent
function apiCallEvent(request) { var api = request.service.api.operations[request.operation]; var monitoringEvent = { Type: 'ApiCall', Api: api ? api.name : request.operation, Version: 1, Service: request.service.api.serviceId || request.service.api.endpointPrefix, Region: request.httpRequest.region, MaxRetriesExceeded: 0, UserAgent: request.httpRequest.getUserAgent(), }; var response = request.response; if (response.httpResponse.statusCode) { monitoringEvent.FinalHttpStatusCode = response.httpResponse.statusCode; } if (response.error) { var error = response.error; var statusCode = response.httpResponse.statusCode; if (statusCode > 299) { if (error.code) monitoringEvent.FinalAwsException = error.code; if (error.message) monitoringEvent.FinalAwsExceptionMessage = error.message; } else { if (error.code || error.name) monitoringEvent.FinalSdkException = error.code || error.name; if (error.message) monitoringEvent.FinalSdkExceptionMessage = error.message; } } return monitoringEvent; }
javascript
function apiCallEvent(request) { var api = request.service.api.operations[request.operation]; var monitoringEvent = { Type: 'ApiCall', Api: api ? api.name : request.operation, Version: 1, Service: request.service.api.serviceId || request.service.api.endpointPrefix, Region: request.httpRequest.region, MaxRetriesExceeded: 0, UserAgent: request.httpRequest.getUserAgent(), }; var response = request.response; if (response.httpResponse.statusCode) { monitoringEvent.FinalHttpStatusCode = response.httpResponse.statusCode; } if (response.error) { var error = response.error; var statusCode = response.httpResponse.statusCode; if (statusCode > 299) { if (error.code) monitoringEvent.FinalAwsException = error.code; if (error.message) monitoringEvent.FinalAwsExceptionMessage = error.message; } else { if (error.code || error.name) monitoringEvent.FinalSdkException = error.code || error.name; if (error.message) monitoringEvent.FinalSdkExceptionMessage = error.message; } } return monitoringEvent; }
[ "function", "apiCallEvent", "(", "request", ")", "{", "var", "api", "=", "request", ".", "service", ".", "api", ".", "operations", "[", "request", ".", "operation", "]", ";", "var", "monitoringEvent", "=", "{", "Type", ":", "'ApiCall'", ",", "Api", ":", "api", "?", "api", ".", "name", ":", "request", ".", "operation", ",", "Version", ":", "1", ",", "Service", ":", "request", ".", "service", ".", "api", ".", "serviceId", "||", "request", ".", "service", ".", "api", ".", "endpointPrefix", ",", "Region", ":", "request", ".", "httpRequest", ".", "region", ",", "MaxRetriesExceeded", ":", "0", ",", "UserAgent", ":", "request", ".", "httpRequest", ".", "getUserAgent", "(", ")", ",", "}", ";", "var", "response", "=", "request", ".", "response", ";", "if", "(", "response", ".", "httpResponse", ".", "statusCode", ")", "{", "monitoringEvent", ".", "FinalHttpStatusCode", "=", "response", ".", "httpResponse", ".", "statusCode", ";", "}", "if", "(", "response", ".", "error", ")", "{", "var", "error", "=", "response", ".", "error", ";", "var", "statusCode", "=", "response", ".", "httpResponse", ".", "statusCode", ";", "if", "(", "statusCode", ">", "299", ")", "{", "if", "(", "error", ".", "code", ")", "monitoringEvent", ".", "FinalAwsException", "=", "error", ".", "code", ";", "if", "(", "error", ".", "message", ")", "monitoringEvent", ".", "FinalAwsExceptionMessage", "=", "error", ".", "message", ";", "}", "else", "{", "if", "(", "error", ".", "code", "||", "error", ".", "name", ")", "monitoringEvent", ".", "FinalSdkException", "=", "error", ".", "code", "||", "error", ".", "name", ";", "if", "(", "error", ".", "message", ")", "monitoringEvent", ".", "FinalSdkExceptionMessage", "=", "error", ".", "message", ";", "}", "}", "return", "monitoringEvent", ";", "}" ]
Event recording metrics for a whole API call. @returns {object} a subset of api call metrics @api private
[ "Event", "recording", "metrics", "for", "a", "whole", "API", "call", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L292-L319
train
aws/aws-sdk-js
lib/service.js
apiAttemptEvent
function apiAttemptEvent(request) { var api = request.service.api.operations[request.operation]; var monitoringEvent = { Type: 'ApiCallAttempt', Api: api ? api.name : request.operation, Version: 1, Service: request.service.api.serviceId || request.service.api.endpointPrefix, Fqdn: request.httpRequest.endpoint.hostname, UserAgent: request.httpRequest.getUserAgent(), }; var response = request.response; if (response.httpResponse.statusCode) { monitoringEvent.HttpStatusCode = response.httpResponse.statusCode; } if ( !request._unAuthenticated && request.service.config.credentials && request.service.config.credentials.accessKeyId ) { monitoringEvent.AccessKey = request.service.config.credentials.accessKeyId; } if (!response.httpResponse.headers) return monitoringEvent; if (request.httpRequest.headers['x-amz-security-token']) { monitoringEvent.SessionToken = request.httpRequest.headers['x-amz-security-token']; } if (response.httpResponse.headers['x-amzn-requestid']) { monitoringEvent.XAmznRequestId = response.httpResponse.headers['x-amzn-requestid']; } if (response.httpResponse.headers['x-amz-request-id']) { monitoringEvent.XAmzRequestId = response.httpResponse.headers['x-amz-request-id']; } if (response.httpResponse.headers['x-amz-id-2']) { monitoringEvent.XAmzId2 = response.httpResponse.headers['x-amz-id-2']; } return monitoringEvent; }
javascript
function apiAttemptEvent(request) { var api = request.service.api.operations[request.operation]; var monitoringEvent = { Type: 'ApiCallAttempt', Api: api ? api.name : request.operation, Version: 1, Service: request.service.api.serviceId || request.service.api.endpointPrefix, Fqdn: request.httpRequest.endpoint.hostname, UserAgent: request.httpRequest.getUserAgent(), }; var response = request.response; if (response.httpResponse.statusCode) { monitoringEvent.HttpStatusCode = response.httpResponse.statusCode; } if ( !request._unAuthenticated && request.service.config.credentials && request.service.config.credentials.accessKeyId ) { monitoringEvent.AccessKey = request.service.config.credentials.accessKeyId; } if (!response.httpResponse.headers) return monitoringEvent; if (request.httpRequest.headers['x-amz-security-token']) { monitoringEvent.SessionToken = request.httpRequest.headers['x-amz-security-token']; } if (response.httpResponse.headers['x-amzn-requestid']) { monitoringEvent.XAmznRequestId = response.httpResponse.headers['x-amzn-requestid']; } if (response.httpResponse.headers['x-amz-request-id']) { monitoringEvent.XAmzRequestId = response.httpResponse.headers['x-amz-request-id']; } if (response.httpResponse.headers['x-amz-id-2']) { monitoringEvent.XAmzId2 = response.httpResponse.headers['x-amz-id-2']; } return monitoringEvent; }
[ "function", "apiAttemptEvent", "(", "request", ")", "{", "var", "api", "=", "request", ".", "service", ".", "api", ".", "operations", "[", "request", ".", "operation", "]", ";", "var", "monitoringEvent", "=", "{", "Type", ":", "'ApiCallAttempt'", ",", "Api", ":", "api", "?", "api", ".", "name", ":", "request", ".", "operation", ",", "Version", ":", "1", ",", "Service", ":", "request", ".", "service", ".", "api", ".", "serviceId", "||", "request", ".", "service", ".", "api", ".", "endpointPrefix", ",", "Fqdn", ":", "request", ".", "httpRequest", ".", "endpoint", ".", "hostname", ",", "UserAgent", ":", "request", ".", "httpRequest", ".", "getUserAgent", "(", ")", ",", "}", ";", "var", "response", "=", "request", ".", "response", ";", "if", "(", "response", ".", "httpResponse", ".", "statusCode", ")", "{", "monitoringEvent", ".", "HttpStatusCode", "=", "response", ".", "httpResponse", ".", "statusCode", ";", "}", "if", "(", "!", "request", ".", "_unAuthenticated", "&&", "request", ".", "service", ".", "config", ".", "credentials", "&&", "request", ".", "service", ".", "config", ".", "credentials", ".", "accessKeyId", ")", "{", "monitoringEvent", ".", "AccessKey", "=", "request", ".", "service", ".", "config", ".", "credentials", ".", "accessKeyId", ";", "}", "if", "(", "!", "response", ".", "httpResponse", ".", "headers", ")", "return", "monitoringEvent", ";", "if", "(", "request", ".", "httpRequest", ".", "headers", "[", "'x-amz-security-token'", "]", ")", "{", "monitoringEvent", ".", "SessionToken", "=", "request", ".", "httpRequest", ".", "headers", "[", "'x-amz-security-token'", "]", ";", "}", "if", "(", "response", ".", "httpResponse", ".", "headers", "[", "'x-amzn-requestid'", "]", ")", "{", "monitoringEvent", ".", "XAmznRequestId", "=", "response", ".", "httpResponse", ".", "headers", "[", "'x-amzn-requestid'", "]", ";", "}", "if", "(", "response", ".", "httpResponse", ".", "headers", "[", "'x-amz-request-id'", "]", ")", "{", "monitoringEvent", ".", "XAmzRequestId", "=", "response", ".", "httpResponse", ".", "headers", "[", "'x-amz-request-id'", "]", ";", "}", "if", "(", "response", ".", "httpResponse", ".", "headers", "[", "'x-amz-id-2'", "]", ")", "{", "monitoringEvent", ".", "XAmzId2", "=", "response", ".", "httpResponse", ".", "headers", "[", "'x-amz-id-2'", "]", ";", "}", "return", "monitoringEvent", ";", "}" ]
Event recording metrics for an API call attempt. @returns {object} a subset of api call attempt metrics @api private
[ "Event", "recording", "metrics", "for", "an", "API", "call", "attempt", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L326-L361
train
aws/aws-sdk-js
lib/service.js
attemptFailEvent
function attemptFailEvent(request) { var monitoringEvent = this.apiAttemptEvent(request); var response = request.response; var error = response.error; if (response.httpResponse.statusCode > 299 ) { if (error.code) monitoringEvent.AwsException = error.code; if (error.message) monitoringEvent.AwsExceptionMessage = error.message; } else { if (error.code || error.name) monitoringEvent.SdkException = error.code || error.name; if (error.message) monitoringEvent.SdkExceptionMessage = error.message; } return monitoringEvent; }
javascript
function attemptFailEvent(request) { var monitoringEvent = this.apiAttemptEvent(request); var response = request.response; var error = response.error; if (response.httpResponse.statusCode > 299 ) { if (error.code) monitoringEvent.AwsException = error.code; if (error.message) monitoringEvent.AwsExceptionMessage = error.message; } else { if (error.code || error.name) monitoringEvent.SdkException = error.code || error.name; if (error.message) monitoringEvent.SdkExceptionMessage = error.message; } return monitoringEvent; }
[ "function", "attemptFailEvent", "(", "request", ")", "{", "var", "monitoringEvent", "=", "this", ".", "apiAttemptEvent", "(", "request", ")", ";", "var", "response", "=", "request", ".", "response", ";", "var", "error", "=", "response", ".", "error", ";", "if", "(", "response", ".", "httpResponse", ".", "statusCode", ">", "299", ")", "{", "if", "(", "error", ".", "code", ")", "monitoringEvent", ".", "AwsException", "=", "error", ".", "code", ";", "if", "(", "error", ".", "message", ")", "monitoringEvent", ".", "AwsExceptionMessage", "=", "error", ".", "message", ";", "}", "else", "{", "if", "(", "error", ".", "code", "||", "error", ".", "name", ")", "monitoringEvent", ".", "SdkException", "=", "error", ".", "code", "||", "error", ".", "name", ";", "if", "(", "error", ".", "message", ")", "monitoringEvent", ".", "SdkExceptionMessage", "=", "error", ".", "message", ";", "}", "return", "monitoringEvent", ";", "}" ]
Add metrics of failed request. @api private
[ "Add", "metrics", "of", "failed", "request", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L367-L379
train
aws/aws-sdk-js
lib/service.js
attachMonitoringEmitter
function attachMonitoringEmitter(request) { var attemptTimestamp; //timestamp marking the beginning of a request attempt var attemptStartRealTime; //Start time of request attempt. Used to calculating attemptLatency var attemptLatency; //latency from request sent out to http response reaching SDK var callStartRealTime; //Start time of API call. Used to calculating API call latency var attemptCount = 0; //request.retryCount is not reliable here var region; //region cache region for each attempt since it can be updated in plase (e.g. s3) var callTimestamp; //timestamp when the request is created var self = this; var addToHead = true; request.on('validate', function () { callStartRealTime = AWS.util.realClock.now(); callTimestamp = Date.now(); }, addToHead); request.on('sign', function () { attemptStartRealTime = AWS.util.realClock.now(); attemptTimestamp = Date.now(); region = request.httpRequest.region; attemptCount++; }, addToHead); request.on('validateResponse', function() { attemptLatency = Math.round(AWS.util.realClock.now() - attemptStartRealTime); }); request.addNamedListener('API_CALL_ATTEMPT', 'success', function API_CALL_ATTEMPT() { var apiAttemptEvent = self.apiAttemptEvent(request); apiAttemptEvent.Timestamp = attemptTimestamp; apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0; apiAttemptEvent.Region = region; self.emit('apiCallAttempt', [apiAttemptEvent]); }); request.addNamedListener('API_CALL_ATTEMPT_RETRY', 'retry', function API_CALL_ATTEMPT_RETRY() { var apiAttemptEvent = self.attemptFailEvent(request); apiAttemptEvent.Timestamp = attemptTimestamp; //attemptLatency may not be available if fail before response attemptLatency = attemptLatency || Math.round(AWS.util.realClock.now() - attemptStartRealTime); apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0; apiAttemptEvent.Region = region; self.emit('apiCallAttempt', [apiAttemptEvent]); }); request.addNamedListener('API_CALL', 'complete', function API_CALL() { var apiCallEvent = self.apiCallEvent(request); apiCallEvent.AttemptCount = attemptCount; if (apiCallEvent.AttemptCount <= 0) return; apiCallEvent.Timestamp = callTimestamp; var latency = Math.round(AWS.util.realClock.now() - callStartRealTime); apiCallEvent.Latency = latency >= 0 ? latency : 0; var response = request.response; if ( typeof response.retryCount === 'number' && typeof response.maxRetries === 'number' && (response.retryCount >= response.maxRetries) ) { apiCallEvent.MaxRetriesExceeded = 1; } self.emit('apiCall', [apiCallEvent]); }); }
javascript
function attachMonitoringEmitter(request) { var attemptTimestamp; //timestamp marking the beginning of a request attempt var attemptStartRealTime; //Start time of request attempt. Used to calculating attemptLatency var attemptLatency; //latency from request sent out to http response reaching SDK var callStartRealTime; //Start time of API call. Used to calculating API call latency var attemptCount = 0; //request.retryCount is not reliable here var region; //region cache region for each attempt since it can be updated in plase (e.g. s3) var callTimestamp; //timestamp when the request is created var self = this; var addToHead = true; request.on('validate', function () { callStartRealTime = AWS.util.realClock.now(); callTimestamp = Date.now(); }, addToHead); request.on('sign', function () { attemptStartRealTime = AWS.util.realClock.now(); attemptTimestamp = Date.now(); region = request.httpRequest.region; attemptCount++; }, addToHead); request.on('validateResponse', function() { attemptLatency = Math.round(AWS.util.realClock.now() - attemptStartRealTime); }); request.addNamedListener('API_CALL_ATTEMPT', 'success', function API_CALL_ATTEMPT() { var apiAttemptEvent = self.apiAttemptEvent(request); apiAttemptEvent.Timestamp = attemptTimestamp; apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0; apiAttemptEvent.Region = region; self.emit('apiCallAttempt', [apiAttemptEvent]); }); request.addNamedListener('API_CALL_ATTEMPT_RETRY', 'retry', function API_CALL_ATTEMPT_RETRY() { var apiAttemptEvent = self.attemptFailEvent(request); apiAttemptEvent.Timestamp = attemptTimestamp; //attemptLatency may not be available if fail before response attemptLatency = attemptLatency || Math.round(AWS.util.realClock.now() - attemptStartRealTime); apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0; apiAttemptEvent.Region = region; self.emit('apiCallAttempt', [apiAttemptEvent]); }); request.addNamedListener('API_CALL', 'complete', function API_CALL() { var apiCallEvent = self.apiCallEvent(request); apiCallEvent.AttemptCount = attemptCount; if (apiCallEvent.AttemptCount <= 0) return; apiCallEvent.Timestamp = callTimestamp; var latency = Math.round(AWS.util.realClock.now() - callStartRealTime); apiCallEvent.Latency = latency >= 0 ? latency : 0; var response = request.response; if ( typeof response.retryCount === 'number' && typeof response.maxRetries === 'number' && (response.retryCount >= response.maxRetries) ) { apiCallEvent.MaxRetriesExceeded = 1; } self.emit('apiCall', [apiCallEvent]); }); }
[ "function", "attachMonitoringEmitter", "(", "request", ")", "{", "var", "attemptTimestamp", ";", "var", "attemptStartRealTime", ";", "var", "attemptLatency", ";", "var", "callStartRealTime", ";", "var", "attemptCount", "=", "0", ";", "var", "region", ";", "var", "callTimestamp", ";", "var", "self", "=", "this", ";", "var", "addToHead", "=", "true", ";", "request", ".", "on", "(", "'validate'", ",", "function", "(", ")", "{", "callStartRealTime", "=", "AWS", ".", "util", ".", "realClock", ".", "now", "(", ")", ";", "callTimestamp", "=", "Date", ".", "now", "(", ")", ";", "}", ",", "addToHead", ")", ";", "request", ".", "on", "(", "'sign'", ",", "function", "(", ")", "{", "attemptStartRealTime", "=", "AWS", ".", "util", ".", "realClock", ".", "now", "(", ")", ";", "attemptTimestamp", "=", "Date", ".", "now", "(", ")", ";", "region", "=", "request", ".", "httpRequest", ".", "region", ";", "attemptCount", "++", ";", "}", ",", "addToHead", ")", ";", "request", ".", "on", "(", "'validateResponse'", ",", "function", "(", ")", "{", "attemptLatency", "=", "Math", ".", "round", "(", "AWS", ".", "util", ".", "realClock", ".", "now", "(", ")", "-", "attemptStartRealTime", ")", ";", "}", ")", ";", "request", ".", "addNamedListener", "(", "'API_CALL_ATTEMPT'", ",", "'success'", ",", "function", "API_CALL_ATTEMPT", "(", ")", "{", "var", "apiAttemptEvent", "=", "self", ".", "apiAttemptEvent", "(", "request", ")", ";", "apiAttemptEvent", ".", "Timestamp", "=", "attemptTimestamp", ";", "apiAttemptEvent", ".", "AttemptLatency", "=", "attemptLatency", ">=", "0", "?", "attemptLatency", ":", "0", ";", "apiAttemptEvent", ".", "Region", "=", "region", ";", "self", ".", "emit", "(", "'apiCallAttempt'", ",", "[", "apiAttemptEvent", "]", ")", ";", "}", ")", ";", "request", ".", "addNamedListener", "(", "'API_CALL_ATTEMPT_RETRY'", ",", "'retry'", ",", "function", "API_CALL_ATTEMPT_RETRY", "(", ")", "{", "var", "apiAttemptEvent", "=", "self", ".", "attemptFailEvent", "(", "request", ")", ";", "apiAttemptEvent", ".", "Timestamp", "=", "attemptTimestamp", ";", "attemptLatency", "=", "attemptLatency", "||", "Math", ".", "round", "(", "AWS", ".", "util", ".", "realClock", ".", "now", "(", ")", "-", "attemptStartRealTime", ")", ";", "apiAttemptEvent", ".", "AttemptLatency", "=", "attemptLatency", ">=", "0", "?", "attemptLatency", ":", "0", ";", "apiAttemptEvent", ".", "Region", "=", "region", ";", "self", ".", "emit", "(", "'apiCallAttempt'", ",", "[", "apiAttemptEvent", "]", ")", ";", "}", ")", ";", "request", ".", "addNamedListener", "(", "'API_CALL'", ",", "'complete'", ",", "function", "API_CALL", "(", ")", "{", "var", "apiCallEvent", "=", "self", ".", "apiCallEvent", "(", "request", ")", ";", "apiCallEvent", ".", "AttemptCount", "=", "attemptCount", ";", "if", "(", "apiCallEvent", ".", "AttemptCount", "<=", "0", ")", "return", ";", "apiCallEvent", ".", "Timestamp", "=", "callTimestamp", ";", "var", "latency", "=", "Math", ".", "round", "(", "AWS", ".", "util", ".", "realClock", ".", "now", "(", ")", "-", "callStartRealTime", ")", ";", "apiCallEvent", ".", "Latency", "=", "latency", ">=", "0", "?", "latency", ":", "0", ";", "var", "response", "=", "request", ".", "response", ";", "if", "(", "typeof", "response", ".", "retryCount", "===", "'number'", "&&", "typeof", "response", ".", "maxRetries", "===", "'number'", "&&", "(", "response", ".", "retryCount", ">=", "response", ".", "maxRetries", ")", ")", "{", "apiCallEvent", ".", "MaxRetriesExceeded", "=", "1", ";", "}", "self", ".", "emit", "(", "'apiCall'", ",", "[", "apiCallEvent", "]", ")", ";", "}", ")", ";", "}" ]
Attach listeners to request object to fetch metrics of each request and emit data object through \'ApiCall\' and \'ApiCallAttempt\' events. @api private
[ "Attach", "listeners", "to", "request", "object", "to", "fetch", "metrics", "of", "each", "request", "and", "emit", "data", "object", "through", "\\", "ApiCall", "\\", "and", "\\", "ApiCallAttempt", "\\", "events", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L386-L444
train
aws/aws-sdk-js
lib/service.js
getSignerClass
function getSignerClass(request) { var version; // get operation authtype if present var operation = null; var authtype = ''; if (request) { var operations = request.service.api.operations || {}; operation = operations[request.operation] || null; authtype = operation ? operation.authtype : ''; } if (this.config.signatureVersion) { version = this.config.signatureVersion; } else if (authtype === 'v4' || authtype === 'v4-unsigned-body') { version = 'v4'; } else { version = this.api.signatureVersion; } return AWS.Signers.RequestSigner.getVersion(version); }
javascript
function getSignerClass(request) { var version; // get operation authtype if present var operation = null; var authtype = ''; if (request) { var operations = request.service.api.operations || {}; operation = operations[request.operation] || null; authtype = operation ? operation.authtype : ''; } if (this.config.signatureVersion) { version = this.config.signatureVersion; } else if (authtype === 'v4' || authtype === 'v4-unsigned-body') { version = 'v4'; } else { version = this.api.signatureVersion; } return AWS.Signers.RequestSigner.getVersion(version); }
[ "function", "getSignerClass", "(", "request", ")", "{", "var", "version", ";", "var", "operation", "=", "null", ";", "var", "authtype", "=", "''", ";", "if", "(", "request", ")", "{", "var", "operations", "=", "request", ".", "service", ".", "api", ".", "operations", "||", "{", "}", ";", "operation", "=", "operations", "[", "request", ".", "operation", "]", "||", "null", ";", "authtype", "=", "operation", "?", "operation", ".", "authtype", ":", "''", ";", "}", "if", "(", "this", ".", "config", ".", "signatureVersion", ")", "{", "version", "=", "this", ".", "config", ".", "signatureVersion", ";", "}", "else", "if", "(", "authtype", "===", "'v4'", "||", "authtype", "===", "'v4-unsigned-body'", ")", "{", "version", "=", "'v4'", ";", "}", "else", "{", "version", "=", "this", ".", "api", ".", "signatureVersion", ";", "}", "return", "AWS", ".", "Signers", ".", "RequestSigner", ".", "getVersion", "(", "version", ")", ";", "}" ]
Gets the signer class for a given request @api private
[ "Gets", "the", "signer", "class", "for", "a", "given", "request" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L459-L477
train
aws/aws-sdk-js
lib/service.js
defineMethods
function defineMethods(svc) { AWS.util.each(svc.prototype.api.operations, function iterator(method) { if (svc.prototype[method]) return; var operation = svc.prototype.api.operations[method]; if (operation.authtype === 'none') { svc.prototype[method] = function (params, callback) { return this.makeUnauthenticatedRequest(method, params, callback); }; } else { svc.prototype[method] = function (params, callback) { return this.makeRequest(method, params, callback); }; } }); }
javascript
function defineMethods(svc) { AWS.util.each(svc.prototype.api.operations, function iterator(method) { if (svc.prototype[method]) return; var operation = svc.prototype.api.operations[method]; if (operation.authtype === 'none') { svc.prototype[method] = function (params, callback) { return this.makeUnauthenticatedRequest(method, params, callback); }; } else { svc.prototype[method] = function (params, callback) { return this.makeRequest(method, params, callback); }; } }); }
[ "function", "defineMethods", "(", "svc", ")", "{", "AWS", ".", "util", ".", "each", "(", "svc", ".", "prototype", ".", "api", ".", "operations", ",", "function", "iterator", "(", "method", ")", "{", "if", "(", "svc", ".", "prototype", "[", "method", "]", ")", "return", ";", "var", "operation", "=", "svc", ".", "prototype", ".", "api", ".", "operations", "[", "method", "]", ";", "if", "(", "operation", ".", "authtype", "===", "'none'", ")", "{", "svc", ".", "prototype", "[", "method", "]", "=", "function", "(", "params", ",", "callback", ")", "{", "return", "this", ".", "makeUnauthenticatedRequest", "(", "method", ",", "params", ",", "callback", ")", ";", "}", ";", "}", "else", "{", "svc", ".", "prototype", "[", "method", "]", "=", "function", "(", "params", ",", "callback", ")", "{", "return", "this", ".", "makeRequest", "(", "method", ",", "params", ",", "callback", ")", ";", "}", ";", "}", "}", ")", ";", "}" ]
Adds one method for each operation described in the api configuration @api private
[ "Adds", "one", "method", "for", "each", "operation", "described", "in", "the", "api", "configuration" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L663-L677
train
aws/aws-sdk-js
lib/response.js
nextPage
function nextPage(callback) { var config; var service = this.request.service; var operation = this.request.operation; try { config = service.paginationConfig(operation, true); } catch (e) { this.error = e; } if (!this.hasNextPage()) { if (callback) callback(this.error, null); else if (this.error) throw this.error; return null; } var params = AWS.util.copy(this.request.params); if (!this.nextPageTokens) { return callback ? callback(null, null) : null; } else { var inputTokens = config.inputToken; if (typeof inputTokens === 'string') inputTokens = [inputTokens]; for (var i = 0; i < inputTokens.length; i++) { params[inputTokens[i]] = this.nextPageTokens[i]; } return service.makeRequest(this.request.operation, params, callback); } }
javascript
function nextPage(callback) { var config; var service = this.request.service; var operation = this.request.operation; try { config = service.paginationConfig(operation, true); } catch (e) { this.error = e; } if (!this.hasNextPage()) { if (callback) callback(this.error, null); else if (this.error) throw this.error; return null; } var params = AWS.util.copy(this.request.params); if (!this.nextPageTokens) { return callback ? callback(null, null) : null; } else { var inputTokens = config.inputToken; if (typeof inputTokens === 'string') inputTokens = [inputTokens]; for (var i = 0; i < inputTokens.length; i++) { params[inputTokens[i]] = this.nextPageTokens[i]; } return service.makeRequest(this.request.operation, params, callback); } }
[ "function", "nextPage", "(", "callback", ")", "{", "var", "config", ";", "var", "service", "=", "this", ".", "request", ".", "service", ";", "var", "operation", "=", "this", ".", "request", ".", "operation", ";", "try", "{", "config", "=", "service", ".", "paginationConfig", "(", "operation", ",", "true", ")", ";", "}", "catch", "(", "e", ")", "{", "this", ".", "error", "=", "e", ";", "}", "if", "(", "!", "this", ".", "hasNextPage", "(", ")", ")", "{", "if", "(", "callback", ")", "callback", "(", "this", ".", "error", ",", "null", ")", ";", "else", "if", "(", "this", ".", "error", ")", "throw", "this", ".", "error", ";", "return", "null", ";", "}", "var", "params", "=", "AWS", ".", "util", ".", "copy", "(", "this", ".", "request", ".", "params", ")", ";", "if", "(", "!", "this", ".", "nextPageTokens", ")", "{", "return", "callback", "?", "callback", "(", "null", ",", "null", ")", ":", "null", ";", "}", "else", "{", "var", "inputTokens", "=", "config", ".", "inputToken", ";", "if", "(", "typeof", "inputTokens", "===", "'string'", ")", "inputTokens", "=", "[", "inputTokens", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "inputTokens", ".", "length", ";", "i", "++", ")", "{", "params", "[", "inputTokens", "[", "i", "]", "]", "=", "this", ".", "nextPageTokens", "[", "i", "]", ";", "}", "return", "service", ".", "makeRequest", "(", "this", ".", "request", ".", "operation", ",", "params", ",", "callback", ")", ";", "}", "}" ]
Creates a new request for the next page of response data, calling the callback with the page data if a callback is provided. @callback callback function(err, data) Called when a page of data is returned from the next request. @param err [Error] an error object, if an error occurred in the request @param data [Object] the next page of data, or null, if there are no more pages left. @return [AWS.Request] the request object for the next page of data @return [null] if no callback is provided and there are no pages left to retrieve. @since v1.4.0
[ "Creates", "a", "new", "request", "for", "the", "next", "page", "of", "response", "data", "calling", "the", "callback", "with", "the", "page", "data", "if", "a", "callback", "is", "provided", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/response.js#L132-L157
train
aws/aws-sdk-js
lib/event-stream/to-buffer.js
toBuffer
function toBuffer(data, encoding) { return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ? Buffer.from(data, encoding) : new Buffer(data, encoding); }
javascript
function toBuffer(data, encoding) { return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ? Buffer.from(data, encoding) : new Buffer(data, encoding); }
[ "function", "toBuffer", "(", "data", ",", "encoding", ")", "{", "return", "(", "typeof", "Buffer", ".", "from", "===", "'function'", "&&", "Buffer", ".", "from", "!==", "Uint8Array", ".", "from", ")", "?", "Buffer", ".", "from", "(", "data", ",", "encoding", ")", ":", "new", "Buffer", "(", "data", ",", "encoding", ")", ";", "}" ]
Converts data into Buffer. @param {ArrayBuffer|string|number[]|Buffer} data Data to convert to a Buffer @param {string} [encoding] String encoding @returns {Buffer}
[ "Converts", "data", "into", "Buffer", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/event-stream/to-buffer.js#L8-L11
train
aws/aws-sdk-js
doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js
function(query) { // create the required interface elements this.out = $('#search-results'); this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out); this.dots = $('<span></span>').appendTo(this.title); this.status = $('<p style="display: none"></p>').appendTo(this.out); this.output = $('<ul class="search"/>').appendTo(this.out); $('#search-progress').text(_('Preparing search...')); this.startPulse(); // index already loaded, the browser was quick! if (this.hasIndex()) this.query(query); else this.deferQuery(query); }
javascript
function(query) { // create the required interface elements this.out = $('#search-results'); this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out); this.dots = $('<span></span>').appendTo(this.title); this.status = $('<p style="display: none"></p>').appendTo(this.out); this.output = $('<ul class="search"/>').appendTo(this.out); $('#search-progress').text(_('Preparing search...')); this.startPulse(); // index already loaded, the browser was quick! if (this.hasIndex()) this.query(query); else this.deferQuery(query); }
[ "function", "(", "query", ")", "{", "this", ".", "out", "=", "$", "(", "'#search-results'", ")", ";", "this", ".", "title", "=", "$", "(", "'<h2>'", "+", "_", "(", "'Searching'", ")", "+", "'</h2>'", ")", ".", "appendTo", "(", "this", ".", "out", ")", ";", "this", ".", "dots", "=", "$", "(", "'<span></span>'", ")", ".", "appendTo", "(", "this", ".", "title", ")", ";", "this", ".", "status", "=", "$", "(", "'<p style=\"display: none\"></p>'", ")", ".", "appendTo", "(", "this", ".", "out", ")", ";", "this", ".", "output", "=", "$", "(", "'<ul class=\"search\"/>'", ")", ".", "appendTo", "(", "this", ".", "out", ")", ";", "$", "(", "'#search-progress'", ")", ".", "text", "(", "_", "(", "'Preparing search...'", ")", ")", ";", "this", ".", "startPulse", "(", ")", ";", "if", "(", "this", ".", "hasIndex", "(", ")", ")", "this", ".", "query", "(", "query", ")", ";", "else", "this", ".", "deferQuery", "(", "query", ")", ";", "}" ]
perform a search for something
[ "perform", "a", "search", "for", "something" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js#L292-L308
train
aws/aws-sdk-js
lib/publisher/configuration.js
resolveMonitoringConfig
function resolveMonitoringConfig() { var config = { port: undefined, clientId: undefined, enabled: undefined, }; if (fromEnvironment(config) || fromConfigFile(config)) return toJSType(config); return toJSType(config); }
javascript
function resolveMonitoringConfig() { var config = { port: undefined, clientId: undefined, enabled: undefined, }; if (fromEnvironment(config) || fromConfigFile(config)) return toJSType(config); return toJSType(config); }
[ "function", "resolveMonitoringConfig", "(", ")", "{", "var", "config", "=", "{", "port", ":", "undefined", ",", "clientId", ":", "undefined", ",", "enabled", ":", "undefined", ",", "}", ";", "if", "(", "fromEnvironment", "(", "config", ")", "||", "fromConfigFile", "(", "config", ")", ")", "return", "toJSType", "(", "config", ")", ";", "return", "toJSType", "(", "config", ")", ";", "}" ]
Resolve client-side monitoring configuration from either environmental variables or shared config file. Configurations from environmental variables have higher priority than those from shared config file. The resolver will try to read the shared config file no matter whether the AWS_SDK_LOAD_CONFIG variable is set. @api private
[ "Resolve", "client", "-", "side", "monitoring", "configuration", "from", "either", "environmental", "variables", "or", "shared", "config", "file", ".", "Configurations", "from", "environmental", "variables", "have", "higher", "priority", "than", "those", "from", "shared", "config", "file", ".", "The", "resolver", "will", "try", "to", "read", "the", "shared", "config", "file", "no", "matter", "whether", "the", "AWS_SDK_LOAD_CONFIG", "variable", "is", "set", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L10-L18
train
aws/aws-sdk-js
lib/publisher/configuration.js
fromEnvironment
function fromEnvironment(config) { config.port = config.port || process.env.AWS_CSM_PORT; config.enabled = config.enabled || process.env.AWS_CSM_ENABLED; config.clientId = config.clientId || process.env.AWS_CSM_CLIENT_ID; return config.port && config.enabled && config.clientId || ['false', '0'].indexOf(config.enabled) >= 0; //no need to read shared config file if explicitely disabled }
javascript
function fromEnvironment(config) { config.port = config.port || process.env.AWS_CSM_PORT; config.enabled = config.enabled || process.env.AWS_CSM_ENABLED; config.clientId = config.clientId || process.env.AWS_CSM_CLIENT_ID; return config.port && config.enabled && config.clientId || ['false', '0'].indexOf(config.enabled) >= 0; //no need to read shared config file if explicitely disabled }
[ "function", "fromEnvironment", "(", "config", ")", "{", "config", ".", "port", "=", "config", ".", "port", "||", "process", ".", "env", ".", "AWS_CSM_PORT", ";", "config", ".", "enabled", "=", "config", ".", "enabled", "||", "process", ".", "env", ".", "AWS_CSM_ENABLED", ";", "config", ".", "clientId", "=", "config", ".", "clientId", "||", "process", ".", "env", ".", "AWS_CSM_CLIENT_ID", ";", "return", "config", ".", "port", "&&", "config", ".", "enabled", "&&", "config", ".", "clientId", "||", "[", "'false'", ",", "'0'", "]", ".", "indexOf", "(", "config", ".", "enabled", ")", ">=", "0", ";", "}" ]
Resolve configurations from environmental variables. @param {object} client side monitoring config object needs to be resolved @returns {boolean} whether resolving configurations is done @api private
[ "Resolve", "configurations", "from", "environmental", "variables", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L26-L32
train
aws/aws-sdk-js
lib/publisher/configuration.js
fromConfigFile
function fromConfigFile(config) { var sharedFileConfig; try { var configFile = AWS.util.iniLoader.loadFrom({ isConfig: true, filename: process.env[AWS.util.sharedConfigFileEnv] }); var sharedFileConfig = configFile[ process.env.AWS_PROFILE || AWS.util.defaultProfile ]; } catch (err) { return false; } if (!sharedFileConfig) return config; config.port = config.port || sharedFileConfig.csm_port; config.enabled = config.enabled || sharedFileConfig.csm_enabled; config.clientId = config.clientId || sharedFileConfig.csm_client_id; return config.port && config.enabled && config.clientId; }
javascript
function fromConfigFile(config) { var sharedFileConfig; try { var configFile = AWS.util.iniLoader.loadFrom({ isConfig: true, filename: process.env[AWS.util.sharedConfigFileEnv] }); var sharedFileConfig = configFile[ process.env.AWS_PROFILE || AWS.util.defaultProfile ]; } catch (err) { return false; } if (!sharedFileConfig) return config; config.port = config.port || sharedFileConfig.csm_port; config.enabled = config.enabled || sharedFileConfig.csm_enabled; config.clientId = config.clientId || sharedFileConfig.csm_client_id; return config.port && config.enabled && config.clientId; }
[ "function", "fromConfigFile", "(", "config", ")", "{", "var", "sharedFileConfig", ";", "try", "{", "var", "configFile", "=", "AWS", ".", "util", ".", "iniLoader", ".", "loadFrom", "(", "{", "isConfig", ":", "true", ",", "filename", ":", "process", ".", "env", "[", "AWS", ".", "util", ".", "sharedConfigFileEnv", "]", "}", ")", ";", "var", "sharedFileConfig", "=", "configFile", "[", "process", ".", "env", ".", "AWS_PROFILE", "||", "AWS", ".", "util", ".", "defaultProfile", "]", ";", "}", "catch", "(", "err", ")", "{", "return", "false", ";", "}", "if", "(", "!", "sharedFileConfig", ")", "return", "config", ";", "config", ".", "port", "=", "config", ".", "port", "||", "sharedFileConfig", ".", "csm_port", ";", "config", ".", "enabled", "=", "config", ".", "enabled", "||", "sharedFileConfig", ".", "csm_enabled", ";", "config", ".", "clientId", "=", "config", ".", "clientId", "||", "sharedFileConfig", ".", "csm_client_id", ";", "return", "config", ".", "port", "&&", "config", ".", "enabled", "&&", "config", ".", "clientId", ";", "}" ]
Resolve cofigurations from shared config file with specified role name @param {object} client side monitoring config object needs to be resolved @returns {boolean} whether resolving configurations is done @api private
[ "Resolve", "cofigurations", "from", "shared", "config", "file", "with", "specified", "role", "name" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L40-L58
train
aws/aws-sdk-js
lib/cloudfront/signer.js
Signer
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
javascript
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
[ "function", "Signer", "(", "keyPairId", ",", "privateKey", ")", "{", "if", "(", "keyPairId", "===", "void", "0", "||", "privateKey", "===", "void", "0", ")", "{", "throw", "new", "Error", "(", "'A key pair ID and private key are required'", ")", ";", "}", "this", ".", "keyPairId", "=", "keyPairId", ";", "this", ".", "privateKey", "=", "privateKey", ";", "}" ]
A signer object can be used to generate signed URLs and cookies for granting access to content on restricted CloudFront distributions. @see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html @param keyPairId [String] (Required) The ID of the CloudFront key pair being used. @param privateKey [String] (Required) A private key in RSA format.
[ "A", "signer", "object", "can", "be", "used", "to", "generate", "signed", "URLs", "and", "cookies", "for", "granting", "access", "to", "content", "on", "restricted", "CloudFront", "distributions", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/cloudfront/signer.js#L105-L112
train
aws/aws-sdk-js
lib/cloudfront/signer.js
function (options, cb) { var signatureHash = 'policy' in options ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(options.url, options.expires, this.keyPairId, this.privateKey); var cookieHash = {}; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { cookieHash['CloudFront-' + key] = signatureHash[key]; } } return handleSuccess(cookieHash, cb); }
javascript
function (options, cb) { var signatureHash = 'policy' in options ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(options.url, options.expires, this.keyPairId, this.privateKey); var cookieHash = {}; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { cookieHash['CloudFront-' + key] = signatureHash[key]; } } return handleSuccess(cookieHash, cb); }
[ "function", "(", "options", ",", "cb", ")", "{", "var", "signatureHash", "=", "'policy'", "in", "options", "?", "signWithCustomPolicy", "(", "options", ".", "policy", ",", "this", ".", "keyPairId", ",", "this", ".", "privateKey", ")", ":", "signWithCannedPolicy", "(", "options", ".", "url", ",", "options", ".", "expires", ",", "this", ".", "keyPairId", ",", "this", ".", "privateKey", ")", ";", "var", "cookieHash", "=", "{", "}", ";", "for", "(", "var", "key", "in", "signatureHash", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "signatureHash", ",", "key", ")", ")", "{", "cookieHash", "[", "'CloudFront-'", "+", "key", "]", "=", "signatureHash", "[", "key", "]", ";", "}", "}", "return", "handleSuccess", "(", "cookieHash", ",", "cb", ")", ";", "}" ]
Create a signed Amazon CloudFront Cookie. @param options [Object] The options to create a signed cookie. @option options url [String] The URL to which the signature will grant access. Required unless you pass in a full policy. @option options expires [Number] A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy. @option options policy [String] A CloudFront JSON policy. Required unless you pass in a url and an expiry time. @param cb [Function] if a callback is provided, this function will pass the hash as the second parameter (after the error parameter) to the callback function. @return [Object] if called synchronously (with no callback), returns the signed cookie parameters. @return [null] nothing is returned if a callback is provided.
[ "Create", "a", "signed", "Amazon", "CloudFront", "Cookie", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/cloudfront/signer.js#L135-L148
train
aws/aws-sdk-js
lib/cloudfront/signer.js
function (options, cb) { try { var resource = getResource(options.url); } catch (err) { return handleError(err, cb); } var parsedUrl = url.parse(options.url, true), signatureHash = Object.prototype.hasOwnProperty.call(options, 'policy') ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(resource, options.expires, this.keyPairId, this.privateKey); parsedUrl.search = null; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { parsedUrl.query[key] = signatureHash[key]; } } try { var signedUrl = determineScheme(options.url) === 'rtmp' ? getRtmpUrl(url.format(parsedUrl)) : url.format(parsedUrl); } catch (err) { return handleError(err, cb); } return handleSuccess(signedUrl, cb); }
javascript
function (options, cb) { try { var resource = getResource(options.url); } catch (err) { return handleError(err, cb); } var parsedUrl = url.parse(options.url, true), signatureHash = Object.prototype.hasOwnProperty.call(options, 'policy') ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(resource, options.expires, this.keyPairId, this.privateKey); parsedUrl.search = null; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { parsedUrl.query[key] = signatureHash[key]; } } try { var signedUrl = determineScheme(options.url) === 'rtmp' ? getRtmpUrl(url.format(parsedUrl)) : url.format(parsedUrl); } catch (err) { return handleError(err, cb); } return handleSuccess(signedUrl, cb); }
[ "function", "(", "options", ",", "cb", ")", "{", "try", "{", "var", "resource", "=", "getResource", "(", "options", ".", "url", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "handleError", "(", "err", ",", "cb", ")", ";", "}", "var", "parsedUrl", "=", "url", ".", "parse", "(", "options", ".", "url", ",", "true", ")", ",", "signatureHash", "=", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "options", ",", "'policy'", ")", "?", "signWithCustomPolicy", "(", "options", ".", "policy", ",", "this", ".", "keyPairId", ",", "this", ".", "privateKey", ")", ":", "signWithCannedPolicy", "(", "resource", ",", "options", ".", "expires", ",", "this", ".", "keyPairId", ",", "this", ".", "privateKey", ")", ";", "parsedUrl", ".", "search", "=", "null", ";", "for", "(", "var", "key", "in", "signatureHash", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "signatureHash", ",", "key", ")", ")", "{", "parsedUrl", ".", "query", "[", "key", "]", "=", "signatureHash", "[", "key", "]", ";", "}", "}", "try", "{", "var", "signedUrl", "=", "determineScheme", "(", "options", ".", "url", ")", "===", "'rtmp'", "?", "getRtmpUrl", "(", "url", ".", "format", "(", "parsedUrl", ")", ")", ":", "url", ".", "format", "(", "parsedUrl", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "handleError", "(", "err", ",", "cb", ")", ";", "}", "return", "handleSuccess", "(", "signedUrl", ",", "cb", ")", ";", "}" ]
Create a signed Amazon CloudFront URL. Keep in mind that URLs meant for use in media/flash players may have different requirements for URL formats (e.g. some require that the extension be removed, some require the file name to be prefixed - mp4:<path>, some require you to add "/cfx/st" into your URL). @param options [Object] The options to create a signed URL. @option options url [String] The URL to which the signature will grant access. Any query params included with the URL should be encoded. Required. @option options expires [Number] A Unix UTC timestamp indicating when the signature should expire. Required unless you pass in a full policy. @option options policy [String] A CloudFront JSON policy. Required unless you pass in a url and an expiry time. @param cb [Function] if a callback is provided, this function will pass the URL as the second parameter (after the error parameter) to the callback function. @return [String] if called synchronously (with no callback), returns the signed URL. @return [null] nothing is returned if a callback is provided.
[ "Create", "a", "signed", "Amazon", "CloudFront", "URL", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/cloudfront/signer.js#L176-L204
train
aws/aws-sdk-js
features/extra/cleanup.js
function(list, iter, callback) { var item = list.shift(); iter(item, function(err) { if (err) return callback(err); else if (list.length) { eachSeries(list, iter, callback); } else { return callback(); } }); }
javascript
function(list, iter, callback) { var item = list.shift(); iter(item, function(err) { if (err) return callback(err); else if (list.length) { eachSeries(list, iter, callback); } else { return callback(); } }); }
[ "function", "(", "list", ",", "iter", ",", "callback", ")", "{", "var", "item", "=", "list", ".", "shift", "(", ")", ";", "iter", "(", "item", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", ";", "else", "if", "(", "list", ".", "length", ")", "{", "eachSeries", "(", "list", ",", "iter", ",", "callback", ")", ";", "}", "else", "{", "return", "callback", "(", ")", ";", "}", "}", ")", ";", "}" ]
Run bucket cleanup serially.
[ "Run", "bucket", "cleanup", "serially", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/cleanup.js#L48-L58
train
aws/aws-sdk-js
features/extra/cleanup.js
function(bucket, callback) { var s3 = new AWS.S3({maxRetries: 100}); var params = { Bucket: bucket }; s3.listObjects(params, function (err, data) { if (err) return callback(err); if (data.Contents.length > 0) { params.Delete = { Objects: [] }; data.Contents.forEach(function (item) { params.Delete.Objects.push({Key: item.Key}); }); s3.deleteObjects(params, callback); } else { callback(); } }); }
javascript
function(bucket, callback) { var s3 = new AWS.S3({maxRetries: 100}); var params = { Bucket: bucket }; s3.listObjects(params, function (err, data) { if (err) return callback(err); if (data.Contents.length > 0) { params.Delete = { Objects: [] }; data.Contents.forEach(function (item) { params.Delete.Objects.push({Key: item.Key}); }); s3.deleteObjects(params, callback); } else { callback(); } }); }
[ "function", "(", "bucket", ",", "callback", ")", "{", "var", "s3", "=", "new", "AWS", ".", "S3", "(", "{", "maxRetries", ":", "100", "}", ")", ";", "var", "params", "=", "{", "Bucket", ":", "bucket", "}", ";", "s3", ".", "listObjects", "(", "params", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "return", "callback", "(", "err", ")", ";", "if", "(", "data", ".", "Contents", ".", "length", ">", "0", ")", "{", "params", ".", "Delete", "=", "{", "Objects", ":", "[", "]", "}", ";", "data", ".", "Contents", ".", "forEach", "(", "function", "(", "item", ")", "{", "params", ".", "Delete", ".", "Objects", ".", "push", "(", "{", "Key", ":", "item", ".", "Key", "}", ")", ";", "}", ")", ";", "s3", ".", "deleteObjects", "(", "params", ",", "callback", ")", ";", "}", "else", "{", "callback", "(", ")", ";", "}", "}", ")", ";", "}" ]
Delete objects.
[ "Delete", "objects", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/cleanup.js#L83-L101
train
aws/aws-sdk-js
lib/credentials/process_credentials.js
ProcessCredentials
function ProcessCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile; this.get(options.callback || AWS.util.fn.noop); }
javascript
function ProcessCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile; this.get(options.callback || AWS.util.fn.noop); }
[ "function", "ProcessCredentials", "(", "options", ")", "{", "AWS", ".", "Credentials", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "this", ".", "filename", "=", "options", ".", "filename", ";", "this", ".", "profile", "=", "options", ".", "profile", "||", "process", ".", "env", ".", "AWS_PROFILE", "||", "AWS", ".", "util", ".", "defaultProfile", ";", "this", ".", "get", "(", "options", ".", "callback", "||", "AWS", ".", "util", ".", "fn", ".", "noop", ")", ";", "}" ]
Creates a new ProcessCredentials object. @param options [map] a set of options @option options profile [String] (AWS_PROFILE env var or 'default') the name of the profile to load. @option options filename [String] ('~/.aws/credentials' or defined by AWS_SHARED_CREDENTIALS_FILE process env var) the filename to use when loading credentials. @option options callback [Function] (err) Credentials are eagerly loaded by the constructor. When the callback is called with no error, the credentials have been loaded successfully.
[ "Creates", "a", "new", "ProcessCredentials", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/process_credentials.js#L59-L67
train
aws/aws-sdk-js
lib/credentials/process_credentials.js
loadViaCredentialProcess
function loadViaCredentialProcess(profile, callback) { proc.exec(profile['credential_process'], function(err, stdOut, stdErr) { if (err) { callback(AWS.util.error( new Error('credential_process returned error'), { code: 'ProcessCredentialsProviderFailure'} ), null); } else { try { var credData = JSON.parse(stdOut); if (credData.Expiration) { var currentTime = AWS.util.date.getDate(); var expireTime = new Date(credData.Expiration); if (expireTime < currentTime) { throw Error('credential_process returned expired credentials'); } } if (credData.Version !== 1) { throw Error('credential_process does not return Version == 1'); } callback(null, credData); } catch (err) { callback(AWS.util.error( new Error(err.message), { code: 'ProcessCredentialsProviderFailure'} ), null); } } }); }
javascript
function loadViaCredentialProcess(profile, callback) { proc.exec(profile['credential_process'], function(err, stdOut, stdErr) { if (err) { callback(AWS.util.error( new Error('credential_process returned error'), { code: 'ProcessCredentialsProviderFailure'} ), null); } else { try { var credData = JSON.parse(stdOut); if (credData.Expiration) { var currentTime = AWS.util.date.getDate(); var expireTime = new Date(credData.Expiration); if (expireTime < currentTime) { throw Error('credential_process returned expired credentials'); } } if (credData.Version !== 1) { throw Error('credential_process does not return Version == 1'); } callback(null, credData); } catch (err) { callback(AWS.util.error( new Error(err.message), { code: 'ProcessCredentialsProviderFailure'} ), null); } } }); }
[ "function", "loadViaCredentialProcess", "(", "profile", ",", "callback", ")", "{", "proc", ".", "exec", "(", "profile", "[", "'credential_process'", "]", ",", "function", "(", "err", ",", "stdOut", ",", "stdErr", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", "'credential_process returned error'", ")", ",", "{", "code", ":", "'ProcessCredentialsProviderFailure'", "}", ")", ",", "null", ")", ";", "}", "else", "{", "try", "{", "var", "credData", "=", "JSON", ".", "parse", "(", "stdOut", ")", ";", "if", "(", "credData", ".", "Expiration", ")", "{", "var", "currentTime", "=", "AWS", ".", "util", ".", "date", ".", "getDate", "(", ")", ";", "var", "expireTime", "=", "new", "Date", "(", "credData", ".", "Expiration", ")", ";", "if", "(", "expireTime", "<", "currentTime", ")", "{", "throw", "Error", "(", "'credential_process returned expired credentials'", ")", ";", "}", "}", "if", "(", "credData", ".", "Version", "!==", "1", ")", "{", "throw", "Error", "(", "'credential_process does not return Version == 1'", ")", ";", "}", "callback", "(", "null", ",", "credData", ")", ";", "}", "catch", "(", "err", ")", "{", "callback", "(", "AWS", ".", "util", ".", "error", "(", "new", "Error", "(", "err", ".", "message", ")", ",", "{", "code", ":", "'ProcessCredentialsProviderFailure'", "}", ")", ",", "null", ")", ";", "}", "}", "}", ")", ";", "}" ]
Executes the credential_process and retrieves credentials from the output @api private @param profile [map] credentials profile @throws ProcessCredentialsProviderFailure
[ "Executes", "the", "credential_process", "and", "retrieves", "credentials", "from", "the", "output" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/process_credentials.js#L136-L166
train
aws/aws-sdk-js
lib/dynamodb/document_client.js
DocumentClient
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
javascript
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
[ "function", "DocumentClient", "(", "options", ")", "{", "var", "self", "=", "this", ";", "self", ".", "options", "=", "options", "||", "{", "}", ";", "self", ".", "configure", "(", "self", ".", "options", ")", ";", "}" ]
Creates a DynamoDB document client with a set of configuration options. @option options params [map] An optional map of parameters to bind to every request sent by this service object. @option options service [AWS.DynamoDB] An optional pre-configured instance of the AWS.DynamoDB service object to use for requests. The object may bound parameters used by the document client. @option options convertEmptyValues [Boolean] set to true if you would like the document client to convert empty values (0-length strings, binary buffers, and sets) to be converted to NULL types when persisting to DynamoDB. @see AWS.DynamoDB.constructor
[ "Creates", "a", "DynamoDB", "document", "client", "with", "a", "set", "of", "configuration", "options", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/document_client.js#L58-L62
train
aws/aws-sdk-js
lib/event-stream/alloc-buffer.js
allocBuffer
function allocBuffer(size) { if (typeof size !== 'number') { throw new Error('size passed to allocBuffer must be a number.'); } var buffer = typeof Buffer.alloc === 'function' ? Buffer.alloc(size) : new Buffer(size); buffer.fill(0); return buffer; }
javascript
function allocBuffer(size) { if (typeof size !== 'number') { throw new Error('size passed to allocBuffer must be a number.'); } var buffer = typeof Buffer.alloc === 'function' ? Buffer.alloc(size) : new Buffer(size); buffer.fill(0); return buffer; }
[ "function", "allocBuffer", "(", "size", ")", "{", "if", "(", "typeof", "size", "!==", "'number'", ")", "{", "throw", "new", "Error", "(", "'size passed to allocBuffer must be a number.'", ")", ";", "}", "var", "buffer", "=", "typeof", "Buffer", ".", "alloc", "===", "'function'", "?", "Buffer", ".", "alloc", "(", "size", ")", ":", "new", "Buffer", "(", "size", ")", ";", "buffer", ".", "fill", "(", "0", ")", ";", "return", "buffer", ";", "}" ]
Allocates a buffer. @param {number} size Number of bytes to allocate for the buffer. @returns {Buffer}
[ "Allocates", "a", "buffer", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/event-stream/alloc-buffer.js#L7-L14
train
aws/aws-sdk-js
scripts/changelog/util.js
addVersionJSONToChangelog
function addVersionJSONToChangelog(version, changes) { if (!changelog) readChangelog(); var entry = '\n\n## ' + version; changes.forEach(function(change) { entry += '\n* ' + change.type + ': ' + change.category + ': ' + change.description; }); var logParts = changelog.split(insertMarker); logParts[0] = logParts[0] .replace(versionMarkerReg, versionMarker.join(version)) + insertMarker; changelog = logParts.join(entry); }
javascript
function addVersionJSONToChangelog(version, changes) { if (!changelog) readChangelog(); var entry = '\n\n## ' + version; changes.forEach(function(change) { entry += '\n* ' + change.type + ': ' + change.category + ': ' + change.description; }); var logParts = changelog.split(insertMarker); logParts[0] = logParts[0] .replace(versionMarkerReg, versionMarker.join(version)) + insertMarker; changelog = logParts.join(entry); }
[ "function", "addVersionJSONToChangelog", "(", "version", ",", "changes", ")", "{", "if", "(", "!", "changelog", ")", "readChangelog", "(", ")", ";", "var", "entry", "=", "'\\n\\n## '", "+", "\\n", ";", "\\n", "version", "changes", ".", "forEach", "(", "function", "(", "change", ")", "{", "entry", "+=", "'\\n* '", "+", "\\n", "+", "change", ".", "type", "+", "': '", "+", "change", ".", "category", "+", "': '", ";", "}", ")", ";", "change", ".", "description", "}" ]
This will not to write to file writeToChangelog must be called after
[ "This", "will", "not", "to", "write", "to", "file", "writeToChangelog", "must", "be", "called", "after" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/scripts/changelog/util.js#L137-L150
train
aws/aws-sdk-js
dist-tools/client-creator.js
ClientCreator
function ClientCreator() { this._metadata = require('../apis/metadata'); this._apisFolderPath = path.join(__dirname, '..', 'apis'); this._clientFolderPath = path.join(__dirname, '..', 'clients'); this._serviceCustomizationsFolderPath = path.join(__dirname, '..', 'lib', 'services'); this._packageJsonPath = path.join(__dirname, '..', 'package.json'); this._apiFileNames = null; }
javascript
function ClientCreator() { this._metadata = require('../apis/metadata'); this._apisFolderPath = path.join(__dirname, '..', 'apis'); this._clientFolderPath = path.join(__dirname, '..', 'clients'); this._serviceCustomizationsFolderPath = path.join(__dirname, '..', 'lib', 'services'); this._packageJsonPath = path.join(__dirname, '..', 'package.json'); this._apiFileNames = null; }
[ "function", "ClientCreator", "(", ")", "{", "this", ".", "_metadata", "=", "require", "(", "'../apis/metadata'", ")", ";", "this", ".", "_apisFolderPath", "=", "path", ".", "join", "(", "__dirname", ",", "'..'", ",", "'apis'", ")", ";", "this", ".", "_clientFolderPath", "=", "path", ".", "join", "(", "__dirname", ",", "'..'", ",", "'clients'", ")", ";", "this", ".", "_serviceCustomizationsFolderPath", "=", "path", ".", "join", "(", "__dirname", ",", "'..'", ",", "'lib'", ",", "'services'", ")", ";", "this", ".", "_packageJsonPath", "=", "path", ".", "join", "(", "__dirname", ",", "'..'", ",", "'package.json'", ")", ";", "this", ".", "_apiFileNames", "=", "null", ";", "}" ]
Generate service clients
[ "Generate", "service", "clients" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/dist-tools/client-creator.js#L5-L12
train
aws/aws-sdk-js
lib/discover_endpoint.js
marshallCustomIdentifiers
function marshallCustomIdentifiers(request, shape) { var identifiers = {}; marshallCustomIdentifiersHelper(identifiers, request.params, shape); return identifiers; }
javascript
function marshallCustomIdentifiers(request, shape) { var identifiers = {}; marshallCustomIdentifiersHelper(identifiers, request.params, shape); return identifiers; }
[ "function", "marshallCustomIdentifiers", "(", "request", ",", "shape", ")", "{", "var", "identifiers", "=", "{", "}", ";", "marshallCustomIdentifiersHelper", "(", "identifiers", ",", "request", ".", "params", ",", "shape", ")", ";", "return", "identifiers", ";", "}" ]
Get custom identifiers for cache key. Identifies custom identifiers by checking each shape's `endpointDiscoveryId` trait. @param [object] request object @param [object] input shape of the given operation's api @api private
[ "Get", "custom", "identifiers", "for", "cache", "key", ".", "Identifies", "custom", "identifiers", "by", "checking", "each", "shape", "s", "endpointDiscoveryId", "trait", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L58-L62
train
aws/aws-sdk-js
lib/discover_endpoint.js
optionalDiscoverEndpoint
function optionalDiscoverEndpoint(request) { var service = request.service; var api = service.api; var operationModel = api.operations ? api.operations[request.operation] : undefined; var inputShape = operationModel ? operationModel.input : undefined; var identifiers = marshallCustomIdentifiers(request, inputShape); var cacheKey = getCacheKey(request); if (Object.keys(identifiers).length > 0) { cacheKey = util.update(cacheKey, identifiers); if (operationModel) cacheKey.operation = operationModel.name; } var endpoints = AWS.endpointCache.get(cacheKey); if (endpoints && endpoints.length === 1 && endpoints[0].Address === '') { //endpoint operation is being made but response not yet received //or endpoint operation just failed in 1 minute return; } else if (endpoints && endpoints.length > 0) { //found endpoint record from cache request.httpRequest.updateEndpoint(endpoints[0].Address); } else { //endpoint record not in cache or outdated. make discovery operation var endpointRequest = service.makeRequest(api.endpointOperation, { Operation: operationModel.name, Identifiers: identifiers, }); addApiVersionHeader(endpointRequest); endpointRequest.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS); endpointRequest.removeListener('retry', AWS.EventListeners.Core.RETRY_CHECK); //put in a placeholder for endpoints already requested, prevent //too much in-flight calls AWS.endpointCache.put(cacheKey, [{ Address: '', CachePeriodInMinutes: 1 }]); endpointRequest.send(function(err, data) { if (data && data.Endpoints) { AWS.endpointCache.put(cacheKey, data.Endpoints); } else if (err) { AWS.endpointCache.put(cacheKey, [{ Address: '', CachePeriodInMinutes: 1 //not to make more endpoint operation in next 1 minute }]); } }); } }
javascript
function optionalDiscoverEndpoint(request) { var service = request.service; var api = service.api; var operationModel = api.operations ? api.operations[request.operation] : undefined; var inputShape = operationModel ? operationModel.input : undefined; var identifiers = marshallCustomIdentifiers(request, inputShape); var cacheKey = getCacheKey(request); if (Object.keys(identifiers).length > 0) { cacheKey = util.update(cacheKey, identifiers); if (operationModel) cacheKey.operation = operationModel.name; } var endpoints = AWS.endpointCache.get(cacheKey); if (endpoints && endpoints.length === 1 && endpoints[0].Address === '') { //endpoint operation is being made but response not yet received //or endpoint operation just failed in 1 minute return; } else if (endpoints && endpoints.length > 0) { //found endpoint record from cache request.httpRequest.updateEndpoint(endpoints[0].Address); } else { //endpoint record not in cache or outdated. make discovery operation var endpointRequest = service.makeRequest(api.endpointOperation, { Operation: operationModel.name, Identifiers: identifiers, }); addApiVersionHeader(endpointRequest); endpointRequest.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS); endpointRequest.removeListener('retry', AWS.EventListeners.Core.RETRY_CHECK); //put in a placeholder for endpoints already requested, prevent //too much in-flight calls AWS.endpointCache.put(cacheKey, [{ Address: '', CachePeriodInMinutes: 1 }]); endpointRequest.send(function(err, data) { if (data && data.Endpoints) { AWS.endpointCache.put(cacheKey, data.Endpoints); } else if (err) { AWS.endpointCache.put(cacheKey, [{ Address: '', CachePeriodInMinutes: 1 //not to make more endpoint operation in next 1 minute }]); } }); } }
[ "function", "optionalDiscoverEndpoint", "(", "request", ")", "{", "var", "service", "=", "request", ".", "service", ";", "var", "api", "=", "service", ".", "api", ";", "var", "operationModel", "=", "api", ".", "operations", "?", "api", ".", "operations", "[", "request", ".", "operation", "]", ":", "undefined", ";", "var", "inputShape", "=", "operationModel", "?", "operationModel", ".", "input", ":", "undefined", ";", "var", "identifiers", "=", "marshallCustomIdentifiers", "(", "request", ",", "inputShape", ")", ";", "var", "cacheKey", "=", "getCacheKey", "(", "request", ")", ";", "if", "(", "Object", ".", "keys", "(", "identifiers", ")", ".", "length", ">", "0", ")", "{", "cacheKey", "=", "util", ".", "update", "(", "cacheKey", ",", "identifiers", ")", ";", "if", "(", "operationModel", ")", "cacheKey", ".", "operation", "=", "operationModel", ".", "name", ";", "}", "var", "endpoints", "=", "AWS", ".", "endpointCache", ".", "get", "(", "cacheKey", ")", ";", "if", "(", "endpoints", "&&", "endpoints", ".", "length", "===", "1", "&&", "endpoints", "[", "0", "]", ".", "Address", "===", "''", ")", "{", "return", ";", "}", "else", "if", "(", "endpoints", "&&", "endpoints", ".", "length", ">", "0", ")", "{", "request", ".", "httpRequest", ".", "updateEndpoint", "(", "endpoints", "[", "0", "]", ".", "Address", ")", ";", "}", "else", "{", "var", "endpointRequest", "=", "service", ".", "makeRequest", "(", "api", ".", "endpointOperation", ",", "{", "Operation", ":", "operationModel", ".", "name", ",", "Identifiers", ":", "identifiers", ",", "}", ")", ";", "addApiVersionHeader", "(", "endpointRequest", ")", ";", "endpointRequest", ".", "removeListener", "(", "'validate'", ",", "AWS", ".", "EventListeners", ".", "Core", ".", "VALIDATE_PARAMETERS", ")", ";", "endpointRequest", ".", "removeListener", "(", "'retry'", ",", "AWS", ".", "EventListeners", ".", "Core", ".", "RETRY_CHECK", ")", ";", "AWS", ".", "endpointCache", ".", "put", "(", "cacheKey", ",", "[", "{", "Address", ":", "''", ",", "CachePeriodInMinutes", ":", "1", "}", "]", ")", ";", "endpointRequest", ".", "send", "(", "function", "(", "err", ",", "data", ")", "{", "if", "(", "data", "&&", "data", ".", "Endpoints", ")", "{", "AWS", ".", "endpointCache", ".", "put", "(", "cacheKey", ",", "data", ".", "Endpoints", ")", ";", "}", "else", "if", "(", "err", ")", "{", "AWS", ".", "endpointCache", ".", "put", "(", "cacheKey", ",", "[", "{", "Address", ":", "''", ",", "CachePeriodInMinutes", ":", "1", "}", "]", ")", ";", "}", "}", ")", ";", "}", "}" ]
Call endpoint discovery operation when it's optional. When endpoint is available in cache then use the cached endpoints. If endpoints are unavailable then use regional endpoints and call endpoint discovery operation asynchronously. This is turned off by default. @param [object] request object @api private
[ "Call", "endpoint", "discovery", "operation", "when", "it", "s", "optional", ".", "When", "endpoint", "is", "available", "in", "cache", "then", "use", "the", "cached", "endpoints", ".", "If", "endpoints", "are", "unavailable", "then", "use", "regional", "endpoints", "and", "call", "endpoint", "discovery", "operation", "asynchronously", ".", "This", "is", "turned", "off", "by", "default", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L72-L118
train
aws/aws-sdk-js
lib/discover_endpoint.js
addApiVersionHeader
function addApiVersionHeader(endpointRequest) { var api = endpointRequest.service.api; var apiVersion = api.apiVersion; if (apiVersion && !endpointRequest.httpRequest.headers['x-amz-api-version']) { endpointRequest.httpRequest.headers['x-amz-api-version'] = apiVersion; } }
javascript
function addApiVersionHeader(endpointRequest) { var api = endpointRequest.service.api; var apiVersion = api.apiVersion; if (apiVersion && !endpointRequest.httpRequest.headers['x-amz-api-version']) { endpointRequest.httpRequest.headers['x-amz-api-version'] = apiVersion; } }
[ "function", "addApiVersionHeader", "(", "endpointRequest", ")", "{", "var", "api", "=", "endpointRequest", ".", "service", ".", "api", ";", "var", "apiVersion", "=", "api", ".", "apiVersion", ";", "if", "(", "apiVersion", "&&", "!", "endpointRequest", ".", "httpRequest", ".", "headers", "[", "'x-amz-api-version'", "]", ")", "{", "endpointRequest", ".", "httpRequest", ".", "headers", "[", "'x-amz-api-version'", "]", "=", "apiVersion", ";", "}", "}" ]
add api version header to endpoint operation @api private
[ "add", "api", "version", "header", "to", "endpoint", "operation" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L210-L216
train
aws/aws-sdk-js
lib/discover_endpoint.js
invalidateCachedEndpoints
function invalidateCachedEndpoints(response) { var error = response.error; var httpResponse = response.httpResponse; if (error && (error.code === 'InvalidEndpointException' || httpResponse.statusCode === 421) ) { var request = response.request; var operations = request.service.api.operations || {}; var inputShape = operations[request.operation] ? operations[request.operation].input : undefined; var identifiers = marshallCustomIdentifiers(request, inputShape); var cacheKey = getCacheKey(request); if (Object.keys(identifiers).length > 0) { cacheKey = util.update(cacheKey, identifiers); if (operations[request.operation]) cacheKey.operation = operations[request.operation].name; } AWS.endpointCache.remove(cacheKey); } }
javascript
function invalidateCachedEndpoints(response) { var error = response.error; var httpResponse = response.httpResponse; if (error && (error.code === 'InvalidEndpointException' || httpResponse.statusCode === 421) ) { var request = response.request; var operations = request.service.api.operations || {}; var inputShape = operations[request.operation] ? operations[request.operation].input : undefined; var identifiers = marshallCustomIdentifiers(request, inputShape); var cacheKey = getCacheKey(request); if (Object.keys(identifiers).length > 0) { cacheKey = util.update(cacheKey, identifiers); if (operations[request.operation]) cacheKey.operation = operations[request.operation].name; } AWS.endpointCache.remove(cacheKey); } }
[ "function", "invalidateCachedEndpoints", "(", "response", ")", "{", "var", "error", "=", "response", ".", "error", ";", "var", "httpResponse", "=", "response", ".", "httpResponse", ";", "if", "(", "error", "&&", "(", "error", ".", "code", "===", "'InvalidEndpointException'", "||", "httpResponse", ".", "statusCode", "===", "421", ")", ")", "{", "var", "request", "=", "response", ".", "request", ";", "var", "operations", "=", "request", ".", "service", ".", "api", ".", "operations", "||", "{", "}", ";", "var", "inputShape", "=", "operations", "[", "request", ".", "operation", "]", "?", "operations", "[", "request", ".", "operation", "]", ".", "input", ":", "undefined", ";", "var", "identifiers", "=", "marshallCustomIdentifiers", "(", "request", ",", "inputShape", ")", ";", "var", "cacheKey", "=", "getCacheKey", "(", "request", ")", ";", "if", "(", "Object", ".", "keys", "(", "identifiers", ")", ".", "length", ">", "0", ")", "{", "cacheKey", "=", "util", ".", "update", "(", "cacheKey", ",", "identifiers", ")", ";", "if", "(", "operations", "[", "request", ".", "operation", "]", ")", "cacheKey", ".", "operation", "=", "operations", "[", "request", ".", "operation", "]", ".", "name", ";", "}", "AWS", ".", "endpointCache", ".", "remove", "(", "cacheKey", ")", ";", "}", "}" ]
If api call gets invalid endpoint exception, SDK should attempt to remove the invalid endpoint from cache. @api private
[ "If", "api", "call", "gets", "invalid", "endpoint", "exception", "SDK", "should", "attempt", "to", "remove", "the", "invalid", "endpoint", "from", "cache", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L223-L240
train
aws/aws-sdk-js
lib/discover_endpoint.js
hasCustomEndpoint
function hasCustomEndpoint(client) { //if set endpoint is set for specific client, enable endpoint discovery will raise an error. if (client._originalConfig && client._originalConfig.endpoint && client._originalConfig.endpointDiscoveryEnabled === true) { throw util.error(new Error(), { code: 'ConfigurationException', message: 'Custom endpoint is supplied; endpointDiscoveryEnabled must not be true.' }); }; var svcConfig = AWS.config[client.serviceIdentifier] || {}; return Boolean(AWS.config.endpoint || svcConfig.endpoint || (client._originalConfig && client._originalConfig.endpoint)); }
javascript
function hasCustomEndpoint(client) { //if set endpoint is set for specific client, enable endpoint discovery will raise an error. if (client._originalConfig && client._originalConfig.endpoint && client._originalConfig.endpointDiscoveryEnabled === true) { throw util.error(new Error(), { code: 'ConfigurationException', message: 'Custom endpoint is supplied; endpointDiscoveryEnabled must not be true.' }); }; var svcConfig = AWS.config[client.serviceIdentifier] || {}; return Boolean(AWS.config.endpoint || svcConfig.endpoint || (client._originalConfig && client._originalConfig.endpoint)); }
[ "function", "hasCustomEndpoint", "(", "client", ")", "{", "if", "(", "client", ".", "_originalConfig", "&&", "client", ".", "_originalConfig", ".", "endpoint", "&&", "client", ".", "_originalConfig", ".", "endpointDiscoveryEnabled", "===", "true", ")", "{", "throw", "util", ".", "error", "(", "new", "Error", "(", ")", ",", "{", "code", ":", "'ConfigurationException'", ",", "message", ":", "'Custom endpoint is supplied; endpointDiscoveryEnabled must not be true.'", "}", ")", ";", "}", ";", "var", "svcConfig", "=", "AWS", ".", "config", "[", "client", ".", "serviceIdentifier", "]", "||", "{", "}", ";", "return", "Boolean", "(", "AWS", ".", "config", ".", "endpoint", "||", "svcConfig", ".", "endpoint", "||", "(", "client", ".", "_originalConfig", "&&", "client", ".", "_originalConfig", ".", "endpoint", ")", ")", ";", "}" ]
If endpoint is explicitly configured, SDK should not do endpoint discovery in anytime. @param [object] client Service client object. @api private
[ "If", "endpoint", "is", "explicitly", "configured", "SDK", "should", "not", "do", "endpoint", "discovery", "in", "anytime", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L247-L257
train
aws/aws-sdk-js
lib/discover_endpoint.js
discoverEndpoint
function discoverEndpoint(request, done) { var service = request.service || {}; if (hasCustomEndpoint(service) || request.isPresigned()) return done(); if (!isEndpointDiscoveryApplicable(request)) return done(); request.httpRequest.appendToUserAgent('endpoint-discovery'); var operations = service.api.operations || {}; var operationModel = operations[request.operation]; var isEndpointDiscoveryRequired = operationModel ? operationModel.endpointDiscoveryRequired : 'NULL'; switch (isEndpointDiscoveryRequired) { case 'OPTIONAL': optionalDiscoverEndpoint(request); request.addNamedListener('INVALIDATE_CACHED_ENDPOINTS', 'extractError', invalidateCachedEndpoints); done(); break; case 'REQUIRED': request.addNamedListener('INVALIDATE_CACHED_ENDPOINTS', 'extractError', invalidateCachedEndpoints); requiredDiscoverEndpoint(request, done); break; case 'NULL': default: done(); break; } }
javascript
function discoverEndpoint(request, done) { var service = request.service || {}; if (hasCustomEndpoint(service) || request.isPresigned()) return done(); if (!isEndpointDiscoveryApplicable(request)) return done(); request.httpRequest.appendToUserAgent('endpoint-discovery'); var operations = service.api.operations || {}; var operationModel = operations[request.operation]; var isEndpointDiscoveryRequired = operationModel ? operationModel.endpointDiscoveryRequired : 'NULL'; switch (isEndpointDiscoveryRequired) { case 'OPTIONAL': optionalDiscoverEndpoint(request); request.addNamedListener('INVALIDATE_CACHED_ENDPOINTS', 'extractError', invalidateCachedEndpoints); done(); break; case 'REQUIRED': request.addNamedListener('INVALIDATE_CACHED_ENDPOINTS', 'extractError', invalidateCachedEndpoints); requiredDiscoverEndpoint(request, done); break; case 'NULL': default: done(); break; } }
[ "function", "discoverEndpoint", "(", "request", ",", "done", ")", "{", "var", "service", "=", "request", ".", "service", "||", "{", "}", ";", "if", "(", "hasCustomEndpoint", "(", "service", ")", "||", "request", ".", "isPresigned", "(", ")", ")", "return", "done", "(", ")", ";", "if", "(", "!", "isEndpointDiscoveryApplicable", "(", "request", ")", ")", "return", "done", "(", ")", ";", "request", ".", "httpRequest", ".", "appendToUserAgent", "(", "'endpoint-discovery'", ")", ";", "var", "operations", "=", "service", ".", "api", ".", "operations", "||", "{", "}", ";", "var", "operationModel", "=", "operations", "[", "request", ".", "operation", "]", ";", "var", "isEndpointDiscoveryRequired", "=", "operationModel", "?", "operationModel", ".", "endpointDiscoveryRequired", ":", "'NULL'", ";", "switch", "(", "isEndpointDiscoveryRequired", ")", "{", "case", "'OPTIONAL'", ":", "optionalDiscoverEndpoint", "(", "request", ")", ";", "request", ".", "addNamedListener", "(", "'INVALIDATE_CACHED_ENDPOINTS'", ",", "'extractError'", ",", "invalidateCachedEndpoints", ")", ";", "done", "(", ")", ";", "break", ";", "case", "'REQUIRED'", ":", "request", ".", "addNamedListener", "(", "'INVALIDATE_CACHED_ENDPOINTS'", ",", "'extractError'", ",", "invalidateCachedEndpoints", ")", ";", "requiredDiscoverEndpoint", "(", "request", ",", "done", ")", ";", "break", ";", "case", "'NULL'", ":", "default", ":", "done", "(", ")", ";", "break", ";", "}", "}" ]
attach endpoint discovery logic to request object @param [object] request @api private
[ "attach", "endpoint", "discovery", "logic", "to", "request", "object" ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L324-L350
train
aws/aws-sdk-js
lib/s3/managed_upload.js
ManagedUpload
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
javascript
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
[ "function", "ManagedUpload", "(", "options", ")", "{", "var", "self", "=", "this", ";", "AWS", ".", "SequentialExecutor", ".", "call", "(", "self", ")", ";", "self", ".", "body", "=", "null", ";", "self", ".", "sliceFn", "=", "null", ";", "self", ".", "callback", "=", "null", ";", "self", ".", "parts", "=", "{", "}", ";", "self", ".", "completeInfo", "=", "[", "]", ";", "self", ".", "fillQueue", "=", "function", "(", ")", "{", "self", ".", "callback", "(", "new", "Error", "(", "'Unsupported body payload '", "+", "typeof", "self", ".", "body", ")", ")", ";", "}", ";", "self", ".", "configure", "(", "options", ")", ";", "}" ]
Creates a managed upload object with a set of configuration options. @note A "Body" parameter is required to be set prior to calling {send}. @option options params [map] a map of parameters to pass to the upload requests. The "Body" parameter is required to be specified either on the service or in the params option. @note ContentMD5 should not be provided when using the managed upload object. Instead, setting "computeChecksums" to true will enable automatic ContentMD5 generation by the managed upload object. @option options queueSize [Number] (4) the size of the concurrent queue manager to upload parts in parallel. Set to 1 for synchronous uploading of parts. Note that the uploader will buffer at most queueSize * partSize bytes into memory at any given time. @option options partSize [Number] (5mb) the size in bytes for each individual part to be uploaded. Adjust the part size to ensure the number of parts does not exceed {maxTotalParts}. See {minPartSize} for the minimum allowed part size. @option options leavePartsOnError [Boolean] (false) whether to abort the multipart upload if an error occurs. Set to true if you want to handle failures manually. @option options service [AWS.S3] an optional S3 service object to use for requests. This object might have bound parameters used by the uploader. @option options tags [Array<map>] The tags to apply to the uploaded object. Each tag should have a `Key` and `Value` keys. @example Creating a default uploader for a stream object var upload = new AWS.S3.ManagedUpload({ params: {Bucket: 'bucket', Key: 'key', Body: stream} }); @example Creating an uploader with concurrency of 1 and partSize of 10mb var upload = new AWS.S3.ManagedUpload({ partSize: 10 * 1024 * 1024, queueSize: 1, params: {Bucket: 'bucket', Key: 'key', Body: stream} }); @example Creating an uploader with tags var upload = new AWS.S3.ManagedUpload({ params: {Bucket: 'bucket', Key: 'key', Body: stream}, tags: [{Key: 'tag1', Value: 'value1'}, {Key: 'tag2', Value: 'value2'}] }); @see send
[ "Creates", "a", "managed", "upload", "object", "with", "a", "set", "of", "configuration", "options", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/s3/managed_upload.js#L81-L94
train
aws/aws-sdk-js
lib/s3/managed_upload.js
function(callback) { var self = this; self.failed = false; self.callback = callback || function(err) { if (err) throw err; }; var runFill = true; if (self.sliceFn) { self.fillQueue = self.fillBuffer; } else if (AWS.util.isNode()) { var Stream = AWS.util.stream.Stream; if (self.body instanceof Stream) { runFill = false; self.fillQueue = self.fillStream; self.partBuffers = []; self.body. on('error', function(err) { self.cleanup(err); }). on('readable', function() { self.fillQueue(); }). on('end', function() { self.isDoneChunking = true; self.numParts = self.totalPartNumbers; self.fillQueue.call(self); if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) { self.finishMultiPart(); } }); } } if (runFill) self.fillQueue.call(self); }
javascript
function(callback) { var self = this; self.failed = false; self.callback = callback || function(err) { if (err) throw err; }; var runFill = true; if (self.sliceFn) { self.fillQueue = self.fillBuffer; } else if (AWS.util.isNode()) { var Stream = AWS.util.stream.Stream; if (self.body instanceof Stream) { runFill = false; self.fillQueue = self.fillStream; self.partBuffers = []; self.body. on('error', function(err) { self.cleanup(err); }). on('readable', function() { self.fillQueue(); }). on('end', function() { self.isDoneChunking = true; self.numParts = self.totalPartNumbers; self.fillQueue.call(self); if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) { self.finishMultiPart(); } }); } } if (runFill) self.fillQueue.call(self); }
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "self", ".", "failed", "=", "false", ";", "self", ".", "callback", "=", "callback", "||", "function", "(", "err", ")", "{", "if", "(", "err", ")", "throw", "err", ";", "}", ";", "var", "runFill", "=", "true", ";", "if", "(", "self", ".", "sliceFn", ")", "{", "self", ".", "fillQueue", "=", "self", ".", "fillBuffer", ";", "}", "else", "if", "(", "AWS", ".", "util", ".", "isNode", "(", ")", ")", "{", "var", "Stream", "=", "AWS", ".", "util", ".", "stream", ".", "Stream", ";", "if", "(", "self", ".", "body", "instanceof", "Stream", ")", "{", "runFill", "=", "false", ";", "self", ".", "fillQueue", "=", "self", ".", "fillStream", ";", "self", ".", "partBuffers", "=", "[", "]", ";", "self", ".", "body", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "self", ".", "cleanup", "(", "err", ")", ";", "}", ")", ".", "on", "(", "'readable'", ",", "function", "(", ")", "{", "self", ".", "fillQueue", "(", ")", ";", "}", ")", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "self", ".", "isDoneChunking", "=", "true", ";", "self", ".", "numParts", "=", "self", ".", "totalPartNumbers", ";", "self", ".", "fillQueue", ".", "call", "(", "self", ")", ";", "if", "(", "self", ".", "isDoneChunking", "&&", "self", ".", "totalPartNumbers", ">=", "1", "&&", "self", ".", "doneParts", "===", "self", ".", "numParts", ")", "{", "self", ".", "finishMultiPart", "(", ")", ";", "}", "}", ")", ";", "}", "}", "if", "(", "runFill", ")", "self", ".", "fillQueue", ".", "call", "(", "self", ")", ";", "}" ]
Initiates the managed upload for the payload. @callback callback function(err, data) @param err [Error] an error or null if no error occurred. @param data [map] The response data from the successful upload: * `Location` (String) the URL of the uploaded object * `ETag` (String) the ETag of the uploaded object * `Bucket` (String) the bucket to which the object was uploaded * `Key` (String) the key to which the object was uploaded @example Sending a managed upload object var params = {Bucket: 'bucket', Key: 'key', Body: stream}; var upload = new AWS.S3.ManagedUpload({params: params}); upload.send(function(err, data) { console.log(err, data); });
[ "Initiates", "the", "managed", "upload", "for", "the", "payload", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/s3/managed_upload.js#L170-L200
train
aws/aws-sdk-js
lib/param_validator.js
ParamValidator
function ParamValidator(validation) { if (validation === true || validation === undefined) { validation = {'min': true}; } this.validation = validation; }
javascript
function ParamValidator(validation) { if (validation === true || validation === undefined) { validation = {'min': true}; } this.validation = validation; }
[ "function", "ParamValidator", "(", "validation", ")", "{", "if", "(", "validation", "===", "true", "||", "validation", "===", "undefined", ")", "{", "validation", "=", "{", "'min'", ":", "true", "}", ";", "}", "this", ".", "validation", "=", "validation", ";", "}" ]
Create a new validator object. @param validation [Boolean|map] whether input parameters should be validated against the operation description before sending the request. Pass a map to enable any of the following specific validation features: * **min** [Boolean] &mdash; Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to `true`. * **max** [Boolean] &mdash; Validates that a value meets the max constraint. * **pattern** [Boolean] &mdash; Validates that a string value matches a regular expression. * **enum** [Boolean] &mdash; Validates that a string value matches one of the allowable enum values.
[ "Create", "a", "new", "validator", "object", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/param_validator.js#L25-L30
train
aws/aws-sdk-js
lib/polly/presigner.js
Signer
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
javascript
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
[ "function", "Signer", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "options", "=", "options", ";", "this", ".", "service", "=", "options", ".", "service", ";", "this", ".", "bindServiceObject", "(", "options", ")", ";", "this", ".", "_operations", "=", "{", "}", ";", "}" ]
Creates a presigner object with a set of configuration options. @option options params [map] An optional map of parameters to bind to every request sent by this service object. @option options service [AWS.Polly] An optional pre-configured instance of the AWS.Polly service object to use for requests. The object may bound parameters used by the presigner. @see AWS.Polly.constructor
[ "Creates", "a", "presigner", "object", "with", "a", "set", "of", "configuration", "options", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/polly/presigner.js#L18-L24
train
aws/aws-sdk-js
scripts/lib/remove-event-stream-ops.js
removeEventStreamOperations
function removeEventStreamOperations(model) { var modifiedModel = false; // loop over all operations var operations = model.operations; var operationNames = Object.keys(operations); for (var i = 0; i < operationNames.length; i++) { var operationName = operationNames[i]; var operation = operations[operationName]; // check input and output shapes var inputShapeName = operation.input && operation.input.shape; var outputShapeName = operation.output && operation.output.shape; var requiresEventStream = false; if (inputShapeName && hasEventStream(model.shapes[inputShapeName], model)) { requiresEventStream = true; } if (requiresEventStream) { modifiedModel = true; // remove the operation from the model console.log('Removing ' + operationName + ' because it depends on event streams on input.'); delete model.operations[operationName]; } } return modifiedModel; }
javascript
function removeEventStreamOperations(model) { var modifiedModel = false; // loop over all operations var operations = model.operations; var operationNames = Object.keys(operations); for (var i = 0; i < operationNames.length; i++) { var operationName = operationNames[i]; var operation = operations[operationName]; // check input and output shapes var inputShapeName = operation.input && operation.input.shape; var outputShapeName = operation.output && operation.output.shape; var requiresEventStream = false; if (inputShapeName && hasEventStream(model.shapes[inputShapeName], model)) { requiresEventStream = true; } if (requiresEventStream) { modifiedModel = true; // remove the operation from the model console.log('Removing ' + operationName + ' because it depends on event streams on input.'); delete model.operations[operationName]; } } return modifiedModel; }
[ "function", "removeEventStreamOperations", "(", "model", ")", "{", "var", "modifiedModel", "=", "false", ";", "var", "operations", "=", "model", ".", "operations", ";", "var", "operationNames", "=", "Object", ".", "keys", "(", "operations", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "operationNames", ".", "length", ";", "i", "++", ")", "{", "var", "operationName", "=", "operationNames", "[", "i", "]", ";", "var", "operation", "=", "operations", "[", "operationName", "]", ";", "var", "inputShapeName", "=", "operation", ".", "input", "&&", "operation", ".", "input", ".", "shape", ";", "var", "outputShapeName", "=", "operation", ".", "output", "&&", "operation", ".", "output", ".", "shape", ";", "var", "requiresEventStream", "=", "false", ";", "if", "(", "inputShapeName", "&&", "hasEventStream", "(", "model", ".", "shapes", "[", "inputShapeName", "]", ",", "model", ")", ")", "{", "requiresEventStream", "=", "true", ";", "}", "if", "(", "requiresEventStream", ")", "{", "modifiedModel", "=", "true", ";", "console", ".", "log", "(", "'Removing '", "+", "operationName", "+", "' because it depends on event streams on input.'", ")", ";", "delete", "model", ".", "operations", "[", "operationName", "]", ";", "}", "}", "return", "modifiedModel", ";", "}" ]
Removes operations from the model if they require event streams. Specifically looks at input and output shapes. @param {Object} model - JSON parsed API model (*.normal.json)
[ "Removes", "operations", "from", "the", "model", "if", "they", "require", "event", "streams", ".", "Specifically", "looks", "at", "input", "and", "output", "shapes", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/scripts/lib/remove-event-stream-ops.js#L6-L31
train
aws/aws-sdk-js
lib/publisher/string-to-buffer.js
stringToBuffer
function stringToBuffer(data) { return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ? Buffer.from(data) : new Buffer(data); }
javascript
function stringToBuffer(data) { return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ? Buffer.from(data) : new Buffer(data); }
[ "function", "stringToBuffer", "(", "data", ")", "{", "return", "(", "typeof", "Buffer", ".", "from", "===", "'function'", "&&", "Buffer", ".", "from", "!==", "Uint8Array", ".", "from", ")", "?", "Buffer", ".", "from", "(", "data", ")", ":", "new", "Buffer", "(", "data", ")", ";", "}" ]
Converts a UTF8 string into a Buffer. @param {string} data Some string to convert to a Buffer @returns {Buffer}
[ "Converts", "a", "UTF8", "string", "into", "a", "Buffer", "." ]
c23e5f0edd150f8885267e5f7c8a564f8e6e8562
https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/string-to-buffer.js#L6-L9
train
exceljs/exceljs
lib/doc/defined-names.js
vGrow
function vGrow(yy, edge) { const c = matrix.findCellAt(sheetName, yy, cell.col); if (!c || !c.mark) { return false; } range[edge] = yy; c.mark = false; return true; }
javascript
function vGrow(yy, edge) { const c = matrix.findCellAt(sheetName, yy, cell.col); if (!c || !c.mark) { return false; } range[edge] = yy; c.mark = false; return true; }
[ "function", "vGrow", "(", "yy", ",", "edge", ")", "{", "const", "c", "=", "matrix", ".", "findCellAt", "(", "sheetName", ",", "yy", ",", "cell", ".", "col", ")", ";", "if", "(", "!", "c", "||", "!", "c", ".", "mark", ")", "{", "return", "false", ";", "}", "range", "[", "edge", "]", "=", "yy", ";", "c", ".", "mark", "=", "false", ";", "return", "true", ";", "}" ]
grow vertical - only one col to worry about
[ "grow", "vertical", "-", "only", "one", "col", "to", "worry", "about" ]
c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2
https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/doc/defined-names.js#L87-L93
train
exceljs/exceljs
lib/doc/defined-names.js
hGrow
function hGrow(xx, edge) { const cells = []; for (y = range.top; y <= range.bottom; y++) { const c = matrix.findCellAt(sheetName, y, xx); if (c && c.mark) { cells.push(c); } else { return false; } } range[edge] = xx; for (let i = 0; i < cells.length; i++) { cells[i].mark = false; } return true; }
javascript
function hGrow(xx, edge) { const cells = []; for (y = range.top; y <= range.bottom; y++) { const c = matrix.findCellAt(sheetName, y, xx); if (c && c.mark) { cells.push(c); } else { return false; } } range[edge] = xx; for (let i = 0; i < cells.length; i++) { cells[i].mark = false; } return true; }
[ "function", "hGrow", "(", "xx", ",", "edge", ")", "{", "const", "cells", "=", "[", "]", ";", "for", "(", "y", "=", "range", ".", "top", ";", "y", "<=", "range", ".", "bottom", ";", "y", "++", ")", "{", "const", "c", "=", "matrix", ".", "findCellAt", "(", "sheetName", ",", "y", ",", "xx", ")", ";", "if", "(", "c", "&&", "c", ".", "mark", ")", "{", "cells", ".", "push", "(", "c", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "range", "[", "edge", "]", "=", "xx", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "cells", ".", "length", ";", "i", "++", ")", "{", "cells", "[", "i", "]", ".", "mark", "=", "false", ";", "}", "return", "true", ";", "}" ]
grow horizontal - ensure all rows can grow
[ "grow", "horizontal", "-", "ensure", "all", "rows", "can", "grow" ]
c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2
https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/doc/defined-names.js#L98-L113
train
exceljs/exceljs
lib/utils/stream-buf.js
function(size) { var buffers; // read min(buffer, size || infinity) if (size) { buffers = []; while (size && this.buffers.length && !this.buffers[0].eod) { var first = this.buffers[0]; var buffer = first.read(size); size -= buffer.length; buffers.push(buffer); if (first.eod && first.full) { this.buffers.shift(); } } return Buffer.concat(buffers); } buffers = this.buffers.map(buf => buf.toBuffer()) .filter(Boolean); this.buffers = []; return Buffer.concat(buffers); }
javascript
function(size) { var buffers; // read min(buffer, size || infinity) if (size) { buffers = []; while (size && this.buffers.length && !this.buffers[0].eod) { var first = this.buffers[0]; var buffer = first.read(size); size -= buffer.length; buffers.push(buffer); if (first.eod && first.full) { this.buffers.shift(); } } return Buffer.concat(buffers); } buffers = this.buffers.map(buf => buf.toBuffer()) .filter(Boolean); this.buffers = []; return Buffer.concat(buffers); }
[ "function", "(", "size", ")", "{", "var", "buffers", ";", "if", "(", "size", ")", "{", "buffers", "=", "[", "]", ";", "while", "(", "size", "&&", "this", ".", "buffers", ".", "length", "&&", "!", "this", ".", "buffers", "[", "0", "]", ".", "eod", ")", "{", "var", "first", "=", "this", ".", "buffers", "[", "0", "]", ";", "var", "buffer", "=", "first", ".", "read", "(", "size", ")", ";", "size", "-=", "buffer", ".", "length", ";", "buffers", ".", "push", "(", "buffer", ")", ";", "if", "(", "first", ".", "eod", "&&", "first", ".", "full", ")", "{", "this", ".", "buffers", ".", "shift", "(", ")", ";", "}", "}", "return", "Buffer", ".", "concat", "(", "buffers", ")", ";", "}", "buffers", "=", "this", ".", "buffers", ".", "map", "(", "buf", "=>", "buf", ".", "toBuffer", "(", ")", ")", ".", "filter", "(", "Boolean", ")", ";", "this", ".", "buffers", "=", "[", "]", ";", "return", "Buffer", ".", "concat", "(", "buffers", ")", ";", "}" ]
readable event readable - some data is now available event data - switch to flowing mode - feeds chunks to handler event end - no more data event close - optional, indicates upstream close event error - duh
[ "readable", "event", "readable", "-", "some", "data", "is", "now", "available", "event", "data", "-", "switch", "to", "flowing", "mode", "-", "feeds", "chunks", "to", "handler", "event", "end", "-", "no", "more", "data", "event", "close", "-", "optional", "indicates", "upstream", "close", "event", "error", "-", "duh" ]
c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2
https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/utils/stream-buf.js#L291-L312
train
LLK/scratch-blocks
core/flyout_base.js
function() { var topBlocks = this.workspace_.getTopBlocks(false); for (var i = 0, block; block = topBlocks[i]; i++) { block.removeSelect(); } }
javascript
function() { var topBlocks = this.workspace_.getTopBlocks(false); for (var i = 0, block; block = topBlocks[i]; i++) { block.removeSelect(); } }
[ "function", "(", ")", "{", "var", "topBlocks", "=", "this", ".", "workspace_", ".", "getTopBlocks", "(", "false", ")", ";", "for", "(", "var", "i", "=", "0", ",", "block", ";", "block", "=", "topBlocks", "[", "i", "]", ";", "i", "++", ")", "{", "block", ".", "removeSelect", "(", ")", ";", "}", "}" ]
IE 11 is an incompetent browser that fails to fire mouseout events. When the mouse is over the background, deselect all blocks.
[ "IE", "11", "is", "an", "incompetent", "browser", "that", "fails", "to", "fire", "mouseout", "events", ".", "When", "the", "mouse", "is", "over", "the", "background", "deselect", "all", "blocks", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/core/flyout_base.js#L563-L568
train
LLK/scratch-blocks
blocks_vertical/vertical_extensions.js
function(menuOptions) { // Add the edit option at the end. menuOptions.push(Blockly.Procedures.makeEditOption(this)); // Find the delete option and update its callback to be specific to // functions. for (var i = 0, option; option = menuOptions[i]; i++) { if (option.text == Blockly.Msg.DELETE_BLOCK) { var input = this.getInput('custom_block'); // this is the root block, not the shadow block. if (input && input.connection && input.connection.targetBlock()) { var procCode = input.connection.targetBlock().getProcCode(); } else { return; } var rootBlock = this; option.callback = function() { var didDelete = Blockly.Procedures.deleteProcedureDefCallback( procCode, rootBlock); if (!didDelete) { // TODO:(#1151) alert('To delete a block definition, first remove all uses of the block'); } }; } } // Find and remove the duplicate option for (var i = 0, option; option = menuOptions[i]; i++) { if (option.text == Blockly.Msg.DUPLICATE) { menuOptions.splice(i, 1); break; } } }
javascript
function(menuOptions) { // Add the edit option at the end. menuOptions.push(Blockly.Procedures.makeEditOption(this)); // Find the delete option and update its callback to be specific to // functions. for (var i = 0, option; option = menuOptions[i]; i++) { if (option.text == Blockly.Msg.DELETE_BLOCK) { var input = this.getInput('custom_block'); // this is the root block, not the shadow block. if (input && input.connection && input.connection.targetBlock()) { var procCode = input.connection.targetBlock().getProcCode(); } else { return; } var rootBlock = this; option.callback = function() { var didDelete = Blockly.Procedures.deleteProcedureDefCallback( procCode, rootBlock); if (!didDelete) { // TODO:(#1151) alert('To delete a block definition, first remove all uses of the block'); } }; } } // Find and remove the duplicate option for (var i = 0, option; option = menuOptions[i]; i++) { if (option.text == Blockly.Msg.DUPLICATE) { menuOptions.splice(i, 1); break; } } }
[ "function", "(", "menuOptions", ")", "{", "menuOptions", ".", "push", "(", "Blockly", ".", "Procedures", ".", "makeEditOption", "(", "this", ")", ")", ";", "for", "(", "var", "i", "=", "0", ",", "option", ";", "option", "=", "menuOptions", "[", "i", "]", ";", "i", "++", ")", "{", "if", "(", "option", ".", "text", "==", "Blockly", ".", "Msg", ".", "DELETE_BLOCK", ")", "{", "var", "input", "=", "this", ".", "getInput", "(", "'custom_block'", ")", ";", "if", "(", "input", "&&", "input", ".", "connection", "&&", "input", ".", "connection", ".", "targetBlock", "(", ")", ")", "{", "var", "procCode", "=", "input", ".", "connection", ".", "targetBlock", "(", ")", ".", "getProcCode", "(", ")", ";", "}", "else", "{", "return", ";", "}", "var", "rootBlock", "=", "this", ";", "option", ".", "callback", "=", "function", "(", ")", "{", "var", "didDelete", "=", "Blockly", ".", "Procedures", ".", "deleteProcedureDefCallback", "(", "procCode", ",", "rootBlock", ")", ";", "if", "(", "!", "didDelete", ")", "{", "alert", "(", "'To delete a block definition, first remove all uses of the block'", ")", ";", "}", "}", ";", "}", "}", "for", "(", "var", "i", "=", "0", ",", "option", ";", "option", "=", "menuOptions", "[", "i", "]", ";", "i", "++", ")", "{", "if", "(", "option", ".", "text", "==", "Blockly", ".", "Msg", ".", "DUPLICATE", ")", "{", "menuOptions", ".", "splice", "(", "i", ",", "1", ")", ";", "break", ";", "}", "}", "}" ]
Add the "edit" option and removes the "duplicate" option from the context menu. @param {!Array.<!Object>} menuOptions List of menu options to edit. @this Blockly.Block
[ "Add", "the", "edit", "option", "and", "removes", "the", "duplicate", "option", "from", "the", "context", "menu", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/vertical_extensions.js#L159-L192
train
LLK/scratch-blocks
blocks_vertical/operators.js
function() { this.jsonInit({ "message0": Blockly.Msg.OPERATORS_MATHOP, "args0": [ { "type": "field_dropdown", "name": "OPERATOR", "options": [ [Blockly.Msg.OPERATORS_MATHOP_ABS, 'abs'], [Blockly.Msg.OPERATORS_MATHOP_FLOOR, 'floor'], [Blockly.Msg.OPERATORS_MATHOP_CEILING, 'ceiling'], [Blockly.Msg.OPERATORS_MATHOP_SQRT, 'sqrt'], [Blockly.Msg.OPERATORS_MATHOP_SIN, 'sin'], [Blockly.Msg.OPERATORS_MATHOP_COS, 'cos'], [Blockly.Msg.OPERATORS_MATHOP_TAN, 'tan'], [Blockly.Msg.OPERATORS_MATHOP_ASIN, 'asin'], [Blockly.Msg.OPERATORS_MATHOP_ACOS, 'acos'], [Blockly.Msg.OPERATORS_MATHOP_ATAN, 'atan'], [Blockly.Msg.OPERATORS_MATHOP_LN, 'ln'], [Blockly.Msg.OPERATORS_MATHOP_LOG, 'log'], [Blockly.Msg.OPERATORS_MATHOP_EEXP, 'e ^'], [Blockly.Msg.OPERATORS_MATHOP_10EXP, '10 ^'] ] }, { "type": "input_value", "name": "NUM" } ], "category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"] }); }
javascript
function() { this.jsonInit({ "message0": Blockly.Msg.OPERATORS_MATHOP, "args0": [ { "type": "field_dropdown", "name": "OPERATOR", "options": [ [Blockly.Msg.OPERATORS_MATHOP_ABS, 'abs'], [Blockly.Msg.OPERATORS_MATHOP_FLOOR, 'floor'], [Blockly.Msg.OPERATORS_MATHOP_CEILING, 'ceiling'], [Blockly.Msg.OPERATORS_MATHOP_SQRT, 'sqrt'], [Blockly.Msg.OPERATORS_MATHOP_SIN, 'sin'], [Blockly.Msg.OPERATORS_MATHOP_COS, 'cos'], [Blockly.Msg.OPERATORS_MATHOP_TAN, 'tan'], [Blockly.Msg.OPERATORS_MATHOP_ASIN, 'asin'], [Blockly.Msg.OPERATORS_MATHOP_ACOS, 'acos'], [Blockly.Msg.OPERATORS_MATHOP_ATAN, 'atan'], [Blockly.Msg.OPERATORS_MATHOP_LN, 'ln'], [Blockly.Msg.OPERATORS_MATHOP_LOG, 'log'], [Blockly.Msg.OPERATORS_MATHOP_EEXP, 'e ^'], [Blockly.Msg.OPERATORS_MATHOP_10EXP, '10 ^'] ] }, { "type": "input_value", "name": "NUM" } ], "category": Blockly.Categories.operators, "extensions": ["colours_operators", "output_number"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"OPERATOR\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_ABS", ",", "'abs'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_FLOOR", ",", "'floor'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_CEILING", ",", "'ceiling'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_SQRT", ",", "'sqrt'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_SIN", ",", "'sin'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_COS", ",", "'cos'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_TAN", ",", "'tan'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_ASIN", ",", "'asin'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_ACOS", ",", "'acos'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_ATAN", ",", "'atan'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_LN", ",", "'ln'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_LOG", ",", "'log'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_EEXP", ",", "'e ^'", "]", ",", "[", "Blockly", ".", "Msg", ".", "OPERATORS_MATHOP_10EXP", ",", "'10 ^'", "]", "]", "}", ",", "{", "\"type\"", ":", "\"input_value\"", ",", "\"name\"", ":", "\"NUM\"", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "operators", ",", "\"extensions\"", ":", "[", "\"colours_operators\"", ",", "\"output_number\"", "]", "}", ")", ";", "}" ]
Block for "advanced" math ops on a number. @this Blockly.Block
[ "Block", "for", "advanced", "math", "ops", "on", "a", "number", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/operators.js#L437-L469
train
LLK/scratch-blocks
blocks_common/colour.js
randomColour
function randomColour() { var num = Math.floor(Math.random() * Math.pow(2, 24)); return '#' + ('00000' + num.toString(16)).substr(-6); }
javascript
function randomColour() { var num = Math.floor(Math.random() * Math.pow(2, 24)); return '#' + ('00000' + num.toString(16)).substr(-6); }
[ "function", "randomColour", "(", ")", "{", "var", "num", "=", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "Math", ".", "pow", "(", "2", ",", "24", ")", ")", ";", "return", "'#'", "+", "(", "'00000'", "+", "num", ".", "toString", "(", "16", ")", ")", ".", "substr", "(", "-", "6", ")", ";", "}" ]
Pick a random colour. @return {string} #RRGGBB for random colour.
[ "Pick", "a", "random", "colour", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_common/colour.js#L37-L40
train
LLK/scratch-blocks
blocks_vertical/looks.js
function() { this.jsonInit({ "message0": Blockly.Msg.LOOKS_CHANGEEFFECTBY, "args0": [ { "type": "field_dropdown", "name": "EFFECT", "options": [ [Blockly.Msg.LOOKS_EFFECT_COLOR, 'COLOR'], [Blockly.Msg.LOOKS_EFFECT_FISHEYE, 'FISHEYE'], [Blockly.Msg.LOOKS_EFFECT_WHIRL, 'WHIRL'], [Blockly.Msg.LOOKS_EFFECT_PIXELATE, 'PIXELATE'], [Blockly.Msg.LOOKS_EFFECT_MOSAIC, 'MOSAIC'], [Blockly.Msg.LOOKS_EFFECT_BRIGHTNESS, 'BRIGHTNESS'], [Blockly.Msg.LOOKS_EFFECT_GHOST, 'GHOST'] ] }, { "type": "input_value", "name": "CHANGE" } ], "category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"] }); }
javascript
function() { this.jsonInit({ "message0": Blockly.Msg.LOOKS_CHANGEEFFECTBY, "args0": [ { "type": "field_dropdown", "name": "EFFECT", "options": [ [Blockly.Msg.LOOKS_EFFECT_COLOR, 'COLOR'], [Blockly.Msg.LOOKS_EFFECT_FISHEYE, 'FISHEYE'], [Blockly.Msg.LOOKS_EFFECT_WHIRL, 'WHIRL'], [Blockly.Msg.LOOKS_EFFECT_PIXELATE, 'PIXELATE'], [Blockly.Msg.LOOKS_EFFECT_MOSAIC, 'MOSAIC'], [Blockly.Msg.LOOKS_EFFECT_BRIGHTNESS, 'BRIGHTNESS'], [Blockly.Msg.LOOKS_EFFECT_GHOST, 'GHOST'] ] }, { "type": "input_value", "name": "CHANGE" } ], "category": Blockly.Categories.looks, "extensions": ["colours_looks", "shape_statement"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "LOOKS_CHANGEEFFECTBY", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"EFFECT\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_COLOR", ",", "'COLOR'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_FISHEYE", ",", "'FISHEYE'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_WHIRL", ",", "'WHIRL'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_PIXELATE", ",", "'PIXELATE'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_MOSAIC", ",", "'MOSAIC'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_BRIGHTNESS", ",", "'BRIGHTNESS'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_EFFECT_GHOST", ",", "'GHOST'", "]", "]", "}", ",", "{", "\"type\"", ":", "\"input_value\"", ",", "\"name\"", ":", "\"CHANGE\"", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "looks", ",", "\"extensions\"", ":", "[", "\"colours_looks\"", ",", "\"shape_statement\"", "]", "}", ")", ";", "}" ]
Block to change graphic effect. @this Blockly.Block
[ "Block", "to", "change", "graphic", "effect", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L168-L193
train
LLK/scratch-blocks
blocks_vertical/looks.js
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "COSTUME", "options": [ ['costume1', 'COSTUME1'], ['costume2', 'COSTUME2'] ] } ], "colour": Blockly.Colours.looks.secondary, "colourSecondary": Blockly.Colours.looks.secondary, "colourTertiary": Blockly.Colours.looks.tertiary, "extensions": ["output_string"] }); }
javascript
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "COSTUME", "options": [ ['costume1', 'COSTUME1'], ['costume2', 'COSTUME2'] ] } ], "colour": Blockly.Colours.looks.secondary, "colourSecondary": Blockly.Colours.looks.secondary, "colourTertiary": Blockly.Colours.looks.tertiary, "extensions": ["output_string"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "\"%1\"", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"COSTUME\"", ",", "\"options\"", ":", "[", "[", "'costume1'", ",", "'COSTUME1'", "]", ",", "[", "'costume2'", ",", "'COSTUME2'", "]", "]", "}", "]", ",", "\"colour\"", ":", "Blockly", ".", "Colours", ".", "looks", ".", "secondary", ",", "\"colourSecondary\"", ":", "Blockly", ".", "Colours", ".", "looks", ".", "secondary", ",", "\"colourTertiary\"", ":", "Blockly", ".", "Colours", ".", "looks", ".", "tertiary", ",", "\"extensions\"", ":", "[", "\"output_string\"", "]", "}", ")", ";", "}" ]
Costumes drop-down menu. @this Blockly.Block
[ "Costumes", "drop", "-", "down", "menu", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L354-L372
train
LLK/scratch-blocks
blocks_vertical/looks.js
function() { this.jsonInit({ "message0": Blockly.Msg.LOOKS_BACKDROPNUMBERNAME, "args0": [ { "type": "field_dropdown", "name": "NUMBER_NAME", "options": [ [Blockly.Msg.LOOKS_NUMBERNAME_NUMBER, 'number'], [Blockly.Msg.LOOKS_NUMBERNAME_NAME, 'name'] ] } ], "category": Blockly.Categories.looks, "checkboxInFlyout": true, "extensions": ["colours_looks", "output_number"] }); }
javascript
function() { this.jsonInit({ "message0": Blockly.Msg.LOOKS_BACKDROPNUMBERNAME, "args0": [ { "type": "field_dropdown", "name": "NUMBER_NAME", "options": [ [Blockly.Msg.LOOKS_NUMBERNAME_NUMBER, 'number'], [Blockly.Msg.LOOKS_NUMBERNAME_NAME, 'name'] ] } ], "category": Blockly.Categories.looks, "checkboxInFlyout": true, "extensions": ["colours_looks", "output_number"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "LOOKS_BACKDROPNUMBERNAME", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"NUMBER_NAME\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "LOOKS_NUMBERNAME_NUMBER", ",", "'number'", "]", ",", "[", "Blockly", ".", "Msg", ".", "LOOKS_NUMBERNAME_NAME", ",", "'name'", "]", "]", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "looks", ",", "\"checkboxInFlyout\"", ":", "true", ",", "\"extensions\"", ":", "[", "\"colours_looks\"", ",", "\"output_number\"", "]", "}", ")", ";", "}" ]
Block to report backdrop's number or name @this Blockly.Block
[ "Block", "to", "report", "backdrop", "s", "number", "or", "name" ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L512-L529
train
LLK/scratch-blocks
blocks_vertical/event.js
function() { this.jsonInit({ "id": "event_whenflagclicked", "message0": Blockly.Msg.EVENT_WHENFLAGCLICKED, "args0": [ { "type": "field_image", "src": Blockly.mainWorkspace.options.pathToMedia + "green-flag.svg", "width": 24, "height": 24, "alt": "flag" } ], "category": Blockly.Categories.event, "extensions": ["colours_event", "shape_hat"] }); }
javascript
function() { this.jsonInit({ "id": "event_whenflagclicked", "message0": Blockly.Msg.EVENT_WHENFLAGCLICKED, "args0": [ { "type": "field_image", "src": Blockly.mainWorkspace.options.pathToMedia + "green-flag.svg", "width": 24, "height": 24, "alt": "flag" } ], "category": Blockly.Categories.event, "extensions": ["colours_event", "shape_hat"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"id\"", ":", "\"event_whenflagclicked\"", ",", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "EVENT_WHENFLAGCLICKED", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_image\"", ",", "\"src\"", ":", "Blockly", ".", "mainWorkspace", ".", "options", ".", "pathToMedia", "+", "\"green-flag.svg\"", ",", "\"width\"", ":", "24", ",", "\"height\"", ":", "24", ",", "\"alt\"", ":", "\"flag\"", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "event", ",", "\"extensions\"", ":", "[", "\"colours_event\"", ",", "\"shape_hat\"", "]", "}", ")", ";", "}" ]
Block for when flag clicked. @this Blockly.Block
[ "Block", "for", "when", "flag", "clicked", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L78-L94
train
LLK/scratch-blocks
blocks_vertical/event.js
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_variable", "name": "BROADCAST_OPTION", "variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE], "variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME } ], "colour": Blockly.Colours.event.secondary, "colourSecondary": Blockly.Colours.event.secondary, "colourTertiary": Blockly.Colours.event.tertiary, "extensions": ["output_string"] }); }
javascript
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_variable", "name": "BROADCAST_OPTION", "variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE], "variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME } ], "colour": Blockly.Colours.event.secondary, "colourSecondary": Blockly.Colours.event.secondary, "colourTertiary": Blockly.Colours.event.tertiary, "extensions": ["output_string"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "\"%1\"", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_variable\"", ",", "\"name\"", ":", "\"BROADCAST_OPTION\"", ",", "\"variableTypes\"", ":", "[", "Blockly", ".", "BROADCAST_MESSAGE_VARIABLE_TYPE", "]", ",", "\"variable\"", ":", "Blockly", ".", "Msg", ".", "DEFAULT_BROADCAST_MESSAGE_NAME", "}", "]", ",", "\"colour\"", ":", "Blockly", ".", "Colours", ".", "event", ".", "secondary", ",", "\"colourSecondary\"", ":", "Blockly", ".", "Colours", ".", "event", ".", "secondary", ",", "\"colourTertiary\"", ":", "Blockly", ".", "Colours", ".", "event", ".", "tertiary", ",", "\"extensions\"", ":", "[", "\"output_string\"", "]", "}", ")", ";", "}" ]
Broadcast drop-down menu. @this Blockly.Block
[ "Broadcast", "drop", "-", "down", "menu", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L205-L221
train
LLK/scratch-blocks
blocks_vertical/event.js
function() { this.jsonInit({ "id": "event_whenkeypressed", "message0": Blockly.Msg.EVENT_WHENKEYPRESSED, "args0": [ { "type": "field_dropdown", "name": "KEY_OPTION", "options": [ [Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'], [Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'], ['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z'], ['0', '0'], ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9'] ] } ], "category": Blockly.Categories.event, "extensions": ["colours_event", "shape_hat"] }); }
javascript
function() { this.jsonInit({ "id": "event_whenkeypressed", "message0": Blockly.Msg.EVENT_WHENKEYPRESSED, "args0": [ { "type": "field_dropdown", "name": "KEY_OPTION", "options": [ [Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'], [Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'], ['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z'], ['0', '0'], ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9'] ] } ], "category": Blockly.Categories.event, "extensions": ["colours_event", "shape_hat"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"id\"", ":", "\"event_whenkeypressed\"", ",", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"KEY_OPTION\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_SPACE", ",", "'space'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_UP", ",", "'up arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_DOWN", ",", "'down arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_RIGHT", ",", "'right arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_LEFT", ",", "'left arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_ANY", ",", "'any'", "]", ",", "[", "'a'", ",", "'a'", "]", ",", "[", "'b'", ",", "'b'", "]", ",", "[", "'c'", ",", "'c'", "]", ",", "[", "'d'", ",", "'d'", "]", ",", "[", "'e'", ",", "'e'", "]", ",", "[", "'f'", ",", "'f'", "]", ",", "[", "'g'", ",", "'g'", "]", ",", "[", "'h'", ",", "'h'", "]", ",", "[", "'i'", ",", "'i'", "]", ",", "[", "'j'", ",", "'j'", "]", ",", "[", "'k'", ",", "'k'", "]", ",", "[", "'l'", ",", "'l'", "]", ",", "[", "'m'", ",", "'m'", "]", ",", "[", "'n'", ",", "'n'", "]", ",", "[", "'o'", ",", "'o'", "]", ",", "[", "'p'", ",", "'p'", "]", ",", "[", "'q'", ",", "'q'", "]", ",", "[", "'r'", ",", "'r'", "]", ",", "[", "'s'", ",", "'s'", "]", ",", "[", "'t'", ",", "'t'", "]", ",", "[", "'u'", ",", "'u'", "]", ",", "[", "'v'", ",", "'v'", "]", ",", "[", "'w'", ",", "'w'", "]", ",", "[", "'x'", ",", "'x'", "]", ",", "[", "'y'", ",", "'y'", "]", ",", "[", "'z'", ",", "'z'", "]", ",", "[", "'0'", ",", "'0'", "]", ",", "[", "'1'", ",", "'1'", "]", ",", "[", "'2'", ",", "'2'", "]", ",", "[", "'3'", ",", "'3'", "]", ",", "[", "'4'", ",", "'4'", "]", ",", "[", "'5'", ",", "'5'", "]", ",", "[", "'6'", ",", "'6'", "]", ",", "[", "'7'", ",", "'7'", "]", ",", "[", "'8'", ",", "'8'", "]", ",", "[", "'9'", ",", "'9'", "]", "]", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "event", ",", "\"extensions\"", ":", "[", "\"colours_event\"", ",", "\"shape_hat\"", "]", "}", ")", ";", "}" ]
Block to send a broadcast. @this Blockly.Block
[ "Block", "to", "send", "a", "broadcast", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L270-L327
train
LLK/scratch-blocks
blocks_vertical/sensing.js
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "KEY_OPTION", "options": [ [Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'], [Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'], ['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z'], ['0', '0'], ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9'] ] } ], "extensions": ["colours_sensing", "output_string"] }); }
javascript
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "KEY_OPTION", "options": [ [Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'], [Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'], [Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'], ['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z'], ['0', '0'], ['1', '1'], ['2', '2'], ['3', '3'], ['4', '4'], ['5', '5'], ['6', '6'], ['7', '7'], ['8', '8'], ['9', '9'] ] } ], "extensions": ["colours_sensing", "output_string"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "\"%1\"", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"KEY_OPTION\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_SPACE", ",", "'space'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_UP", ",", "'up arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_DOWN", ",", "'down arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_RIGHT", ",", "'right arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_LEFT", ",", "'left arrow'", "]", ",", "[", "Blockly", ".", "Msg", ".", "EVENT_WHENKEYPRESSED_ANY", ",", "'any'", "]", ",", "[", "'a'", ",", "'a'", "]", ",", "[", "'b'", ",", "'b'", "]", ",", "[", "'c'", ",", "'c'", "]", ",", "[", "'d'", ",", "'d'", "]", ",", "[", "'e'", ",", "'e'", "]", ",", "[", "'f'", ",", "'f'", "]", ",", "[", "'g'", ",", "'g'", "]", ",", "[", "'h'", ",", "'h'", "]", ",", "[", "'i'", ",", "'i'", "]", ",", "[", "'j'", ",", "'j'", "]", ",", "[", "'k'", ",", "'k'", "]", ",", "[", "'l'", ",", "'l'", "]", ",", "[", "'m'", ",", "'m'", "]", ",", "[", "'n'", ",", "'n'", "]", ",", "[", "'o'", ",", "'o'", "]", ",", "[", "'p'", ",", "'p'", "]", ",", "[", "'q'", ",", "'q'", "]", ",", "[", "'r'", ",", "'r'", "]", ",", "[", "'s'", ",", "'s'", "]", ",", "[", "'t'", ",", "'t'", "]", ",", "[", "'u'", ",", "'u'", "]", ",", "[", "'v'", ",", "'v'", "]", ",", "[", "'w'", ",", "'w'", "]", ",", "[", "'x'", ",", "'x'", "]", ",", "[", "'y'", ",", "'y'", "]", ",", "[", "'z'", ",", "'z'", "]", ",", "[", "'0'", ",", "'0'", "]", ",", "[", "'1'", ",", "'1'", "]", ",", "[", "'2'", ",", "'2'", "]", ",", "[", "'3'", ",", "'3'", "]", ",", "[", "'4'", ",", "'4'", "]", ",", "[", "'5'", ",", "'5'", "]", ",", "[", "'6'", ",", "'6'", "]", ",", "[", "'7'", ",", "'7'", "]", ",", "[", "'8'", ",", "'8'", "]", ",", "[", "'9'", ",", "'9'", "]", "]", "}", "]", ",", "\"extensions\"", ":", "[", "\"colours_sensing\"", ",", "\"output_string\"", "]", "}", ")", ";", "}" ]
Options for Keys @this Blockly.Block
[ "Options", "for", "Keys" ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/sensing.js#L220-L275
train
LLK/scratch-blocks
blocks_vertical/sensing.js
function() { this.jsonInit({ "message0": Blockly.Msg.SENSING_SETDRAGMODE, "args0": [ { "type": "field_dropdown", "name": "DRAG_MODE", "options": [ [Blockly.Msg.SENSING_SETDRAGMODE_DRAGGABLE, 'draggable'], [Blockly.Msg.SENSING_SETDRAGMODE_NOTDRAGGABLE, 'not draggable'] ] } ], "category": Blockly.Categories.sensing, "extensions": ["colours_sensing", "shape_statement"] }); }
javascript
function() { this.jsonInit({ "message0": Blockly.Msg.SENSING_SETDRAGMODE, "args0": [ { "type": "field_dropdown", "name": "DRAG_MODE", "options": [ [Blockly.Msg.SENSING_SETDRAGMODE_DRAGGABLE, 'draggable'], [Blockly.Msg.SENSING_SETDRAGMODE_NOTDRAGGABLE, 'not draggable'] ] } ], "category": Blockly.Categories.sensing, "extensions": ["colours_sensing", "shape_statement"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "SENSING_SETDRAGMODE", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"DRAG_MODE\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "SENSING_SETDRAGMODE_DRAGGABLE", ",", "'draggable'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_SETDRAGMODE_NOTDRAGGABLE", ",", "'not draggable'", "]", "]", "}", "]", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "sensing", ",", "\"extensions\"", ":", "[", "\"colours_sensing\"", ",", "\"shape_statement\"", "]", "}", ")", ";", "}" ]
Block to set drag mode. @this Blockly.Block
[ "Block", "to", "set", "drag", "mode", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/sensing.js#L325-L341
train
LLK/scratch-blocks
blocks_vertical/sensing.js
function() { this.jsonInit({ "message0": Blockly.Msg.SENSING_OF, "args0": [ { "type": "field_dropdown", "name": "PROPERTY", "options": [ [Blockly.Msg.SENSING_OF_XPOSITION, 'x position'], [Blockly.Msg.SENSING_OF_YPOSITION, 'y position'], [Blockly.Msg.SENSING_OF_DIRECTION, 'direction'], [Blockly.Msg.SENSING_OF_COSTUMENUMBER, 'costume #'], [Blockly.Msg.SENSING_OF_COSTUMENAME, 'costume name'], [Blockly.Msg.SENSING_OF_SIZE, 'size'], [Blockly.Msg.SENSING_OF_VOLUME, 'volume'], [Blockly.Msg.SENSING_OF_BACKDROPNUMBER, 'backdrop #'], [Blockly.Msg.SENSING_OF_BACKDROPNAME, 'backdrop name'] ] }, { "type": "input_value", "name": "OBJECT" } ], "output": true, "category": Blockly.Categories.sensing, "outputShape": Blockly.OUTPUT_SHAPE_ROUND, "extensions": ["colours_sensing"] }); }
javascript
function() { this.jsonInit({ "message0": Blockly.Msg.SENSING_OF, "args0": [ { "type": "field_dropdown", "name": "PROPERTY", "options": [ [Blockly.Msg.SENSING_OF_XPOSITION, 'x position'], [Blockly.Msg.SENSING_OF_YPOSITION, 'y position'], [Blockly.Msg.SENSING_OF_DIRECTION, 'direction'], [Blockly.Msg.SENSING_OF_COSTUMENUMBER, 'costume #'], [Blockly.Msg.SENSING_OF_COSTUMENAME, 'costume name'], [Blockly.Msg.SENSING_OF_SIZE, 'size'], [Blockly.Msg.SENSING_OF_VOLUME, 'volume'], [Blockly.Msg.SENSING_OF_BACKDROPNUMBER, 'backdrop #'], [Blockly.Msg.SENSING_OF_BACKDROPNAME, 'backdrop name'] ] }, { "type": "input_value", "name": "OBJECT" } ], "output": true, "category": Blockly.Categories.sensing, "outputShape": Blockly.OUTPUT_SHAPE_ROUND, "extensions": ["colours_sensing"] }); }
[ "function", "(", ")", "{", "this", ".", "jsonInit", "(", "{", "\"message0\"", ":", "Blockly", ".", "Msg", ".", "SENSING_OF", ",", "\"args0\"", ":", "[", "{", "\"type\"", ":", "\"field_dropdown\"", ",", "\"name\"", ":", "\"PROPERTY\"", ",", "\"options\"", ":", "[", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_XPOSITION", ",", "'x position'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_YPOSITION", ",", "'y position'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_DIRECTION", ",", "'direction'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_COSTUMENUMBER", ",", "'costume #'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_COSTUMENAME", ",", "'costume name'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_SIZE", ",", "'size'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_VOLUME", ",", "'volume'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_BACKDROPNUMBER", ",", "'backdrop #'", "]", ",", "[", "Blockly", ".", "Msg", ".", "SENSING_OF_BACKDROPNAME", ",", "'backdrop name'", "]", "]", "}", ",", "{", "\"type\"", ":", "\"input_value\"", ",", "\"name\"", ":", "\"OBJECT\"", "}", "]", ",", "\"output\"", ":", "true", ",", "\"category\"", ":", "Blockly", ".", "Categories", ".", "sensing", ",", "\"outputShape\"", ":", "Blockly", ".", "OUTPUT_SHAPE_ROUND", ",", "\"extensions\"", ":", "[", "\"colours_sensing\"", "]", "}", ")", ";", "}" ]
Block to report properties of sprites. @this Blockly.Block
[ "Block", "to", "report", "properties", "of", "sprites", "." ]
455b2a854435c0a67da1da92320ddc3ec3e2b799
https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/sensing.js#L434-L463
train