id
int32 0
58k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
15,100
|
postmanlabs/postman-collection
|
lib/url-pattern/url-match-pattern.js
|
function (port, protocol) {
var portRegex = this._matchPatternObject.port,
// default port for given protocol
defaultPort = protocol && DEFAULT_PROTOCOL_PORT[protocol];
// return true if both given port and match pattern are absent
if (typeof port === UNDEFINED && typeof portRegex === UNDEFINED) {
return true;
}
// convert integer port to string
(port && typeof port !== STRING) && (port = String(port));
// assign default port or portRegex
!port && (port = defaultPort);
!portRegex && (portRegex = defaultPort);
// matches * or specific port
return (
portRegex === MATCH_ALL ||
portRegex === port
);
}
|
javascript
|
function (port, protocol) {
var portRegex = this._matchPatternObject.port,
// default port for given protocol
defaultPort = protocol && DEFAULT_PROTOCOL_PORT[protocol];
// return true if both given port and match pattern are absent
if (typeof port === UNDEFINED && typeof portRegex === UNDEFINED) {
return true;
}
// convert integer port to string
(port && typeof port !== STRING) && (port = String(port));
// assign default port or portRegex
!port && (port = defaultPort);
!portRegex && (portRegex = defaultPort);
// matches * or specific port
return (
portRegex === MATCH_ALL ||
portRegex === port
);
}
|
[
"function",
"(",
"port",
",",
"protocol",
")",
"{",
"var",
"portRegex",
"=",
"this",
".",
"_matchPatternObject",
".",
"port",
",",
"// default port for given protocol",
"defaultPort",
"=",
"protocol",
"&&",
"DEFAULT_PROTOCOL_PORT",
"[",
"protocol",
"]",
";",
"// return true if both given port and match pattern are absent",
"if",
"(",
"typeof",
"port",
"===",
"UNDEFINED",
"&&",
"typeof",
"portRegex",
"===",
"UNDEFINED",
")",
"{",
"return",
"true",
";",
"}",
"// convert integer port to string",
"(",
"port",
"&&",
"typeof",
"port",
"!==",
"STRING",
")",
"&&",
"(",
"port",
"=",
"String",
"(",
"port",
")",
")",
";",
"// assign default port or portRegex",
"!",
"port",
"&&",
"(",
"port",
"=",
"defaultPort",
")",
";",
"!",
"portRegex",
"&&",
"(",
"portRegex",
"=",
"defaultPort",
")",
";",
"// matches * or specific port",
"return",
"(",
"portRegex",
"===",
"MATCH_ALL",
"||",
"portRegex",
"===",
"port",
")",
";",
"}"
] |
Tests if the current pattern allows the given port.
@param {String} port The port to be checked if the pattern allows.
@param {String} protocol Protocol to refer default port.
@return {Boolean}
|
[
"Tests",
"if",
"the",
"current",
"pattern",
"allows",
"the",
"given",
"port",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/url-pattern/url-match-pattern.js#L210-L233
|
|
15,101
|
postmanlabs/postman-collection
|
lib/collection/item.js
|
function (key) {
// bail out if property protocolProfileBehavior is not set or key is non-string
if (!(typeof this.protocolProfileBehavior === OBJECT && typeof key === STRING)) {
return this;
}
if (this.protocolProfileBehavior.hasOwnProperty(key)) {
delete this.protocolProfileBehavior[key];
}
return this;
}
|
javascript
|
function (key) {
// bail out if property protocolProfileBehavior is not set or key is non-string
if (!(typeof this.protocolProfileBehavior === OBJECT && typeof key === STRING)) {
return this;
}
if (this.protocolProfileBehavior.hasOwnProperty(key)) {
delete this.protocolProfileBehavior[key];
}
return this;
}
|
[
"function",
"(",
"key",
")",
"{",
"// bail out if property protocolProfileBehavior is not set or key is non-string",
"if",
"(",
"!",
"(",
"typeof",
"this",
".",
"protocolProfileBehavior",
"===",
"OBJECT",
"&&",
"typeof",
"key",
"===",
"STRING",
")",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"this",
".",
"protocolProfileBehavior",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"delete",
"this",
".",
"protocolProfileBehavior",
"[",
"key",
"]",
";",
"}",
"return",
"this",
";",
"}"
] |
Unset or delete protocol profile behavior for the current Item.
@example <caption> Unset protocol profile behavior </caption>
item.unsetProtocolProfileBehavior('strictSSL');
@private
@param {String} key - protocol profile behavior name to unset
@returns {Item}
|
[
"Unset",
"or",
"delete",
"protocol",
"profile",
"behavior",
"for",
"the",
"current",
"Item",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/item.js#L264-L275
|
|
15,102
|
postmanlabs/postman-collection
|
lib/collection/item-group.js
|
forEachItem
|
function forEachItem (callback) {
this.items.each(function (item) {
return ItemGroup.isItemGroup(item) ? item.forEachItem(callback) : callback(item, this);
}, this);
}
|
javascript
|
function forEachItem (callback) {
this.items.each(function (item) {
return ItemGroup.isItemGroup(item) ? item.forEachItem(callback) : callback(item, this);
}, this);
}
|
[
"function",
"forEachItem",
"(",
"callback",
")",
"{",
"this",
".",
"items",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"ItemGroup",
".",
"isItemGroup",
"(",
"item",
")",
"?",
"item",
".",
"forEachItem",
"(",
"callback",
")",
":",
"callback",
"(",
"item",
",",
"this",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] |
Calls the callback for each item belonging to itself. If any ItemGroups are encountered,
they will call the callback on their own Items.
@private
@param {Function} callback
|
[
"Calls",
"the",
"callback",
"for",
"each",
"item",
"belonging",
"to",
"itself",
".",
"If",
"any",
"ItemGroups",
"are",
"encountered",
"they",
"will",
"call",
"the",
"callback",
"on",
"their",
"own",
"Items",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/item-group.js#L194-L198
|
15,103
|
postmanlabs/postman-collection
|
lib/collection/item-group.js
|
forEachItemGroup
|
function forEachItemGroup (callback) {
this.items.each(function (item) {
if (ItemGroup.isItemGroup(item)) {
item.forEachItemGroup(callback);
callback(item, this); // eslint-disable-line callback-return
}
}, this);
}
|
javascript
|
function forEachItemGroup (callback) {
this.items.each(function (item) {
if (ItemGroup.isItemGroup(item)) {
item.forEachItemGroup(callback);
callback(item, this); // eslint-disable-line callback-return
}
}, this);
}
|
[
"function",
"forEachItemGroup",
"(",
"callback",
")",
"{",
"this",
".",
"items",
".",
"each",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"ItemGroup",
".",
"isItemGroup",
"(",
"item",
")",
")",
"{",
"item",
".",
"forEachItemGroup",
"(",
"callback",
")",
";",
"callback",
"(",
"item",
",",
"this",
")",
";",
"// eslint-disable-line callback-return",
"}",
"}",
",",
"this",
")",
";",
"}"
] |
Calls the callback for each itemgroup belonging to itself. All ItemGroups encountered will also,
call the callback on their own ItemGroups
@private
@param {Function} callback
|
[
"Calls",
"the",
"callback",
"for",
"each",
"itemgroup",
"belonging",
"to",
"itself",
".",
"All",
"ItemGroups",
"encountered",
"will",
"also",
"call",
"the",
"callback",
"on",
"their",
"own",
"ItemGroups"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/item-group.js#L207-L214
|
15,104
|
postmanlabs/postman-collection
|
lib/collection/item-group.js
|
function (idOrName) {
if (!_.isString(idOrName)) { return; }
var item;
this.items.each(function (eachItem) {
if (eachItem.id === idOrName || eachItem.name === idOrName) {
item = eachItem;
return false; // we found something, so bail out of the for loop.
}
if (ItemGroup.isItemGroup(eachItem)) {
item = eachItem.oneDeep(idOrName);
return !item; // bail out of the for loop if we found anything
}
});
return item;
}
|
javascript
|
function (idOrName) {
if (!_.isString(idOrName)) { return; }
var item;
this.items.each(function (eachItem) {
if (eachItem.id === idOrName || eachItem.name === idOrName) {
item = eachItem;
return false; // we found something, so bail out of the for loop.
}
if (ItemGroup.isItemGroup(eachItem)) {
item = eachItem.oneDeep(idOrName);
return !item; // bail out of the for loop if we found anything
}
});
return item;
}
|
[
"function",
"(",
"idOrName",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"idOrName",
")",
")",
"{",
"return",
";",
"}",
"var",
"item",
";",
"this",
".",
"items",
".",
"each",
"(",
"function",
"(",
"eachItem",
")",
"{",
"if",
"(",
"eachItem",
".",
"id",
"===",
"idOrName",
"||",
"eachItem",
".",
"name",
"===",
"idOrName",
")",
"{",
"item",
"=",
"eachItem",
";",
"return",
"false",
";",
"// we found something, so bail out of the for loop.",
"}",
"if",
"(",
"ItemGroup",
".",
"isItemGroup",
"(",
"eachItem",
")",
")",
"{",
"item",
"=",
"eachItem",
".",
"oneDeep",
"(",
"idOrName",
")",
";",
"return",
"!",
"item",
";",
"// bail out of the for loop if we found anything",
"}",
"}",
")",
";",
"return",
"item",
";",
"}"
] |
Finds the first item with the given name or id in the current ItemGroup.
@param {String} idOrName
|
[
"Finds",
"the",
"first",
"item",
"with",
"the",
"given",
"name",
"or",
"id",
"in",
"the",
"current",
"ItemGroup",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/item-group.js#L221-L239
|
|
15,105
|
postmanlabs/postman-collection
|
lib/collection/item-group.js
|
function (item) {
if (Item.isItem(item) || ItemGroup.isItemGroup(item)) { return item; }
return item && item.item ? new ItemGroup(item) : new Item(item);
}
|
javascript
|
function (item) {
if (Item.isItem(item) || ItemGroup.isItemGroup(item)) { return item; }
return item && item.item ? new ItemGroup(item) : new Item(item);
}
|
[
"function",
"(",
"item",
")",
"{",
"if",
"(",
"Item",
".",
"isItem",
"(",
"item",
")",
"||",
"ItemGroup",
".",
"isItemGroup",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"return",
"item",
"&&",
"item",
".",
"item",
"?",
"new",
"ItemGroup",
"(",
"item",
")",
":",
"new",
"Item",
"(",
"item",
")",
";",
"}"
] |
Iterator function to update an itemgroup's item array with appropriate objects from definition.
@private
@this {ItemGroup}
@param {Object} item - the definition of an item or group
@returns {ItemGroup|Item}
@note
This function is intended to be used in scope of an instance of a {@link ItemGroup).
|
[
"Iterator",
"function",
"to",
"update",
"an",
"itemgroup",
"s",
"item",
"array",
"with",
"appropriate",
"objects",
"from",
"definition",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/item-group.js#L317-L321
|
|
15,106
|
postmanlabs/postman-collection
|
lib/collection/certificate.js
|
function (options) {
// return early if options is empty or invalid
if (!_.isObject(options)) {
return;
}
_.mergeDefined(this, /** @lends Certificate.prototype */ {
/**
* Unique identifier
* @type {String}
*/
id: options.id,
/**
* Name for user reference
* @type {String}
*/
name: options.name,
/**
* List of match pattern
* @type {UrlMatchPatternList}
*/
matches: options.matches && new UrlMatchPatternList({}, options.matches),
/**
* Private Key
* @type {{ src: (string) }}
*/
key: _.isObject(options.key) ? options.key : { src: options.key },
/**
* Certificate
* @type {{ src: (string) }}
*/
cert: _.isObject(options.cert) ? options.cert : { src: options.cert },
/**
* PFX or PKCS12 Certificate
* @type {{ src: (string) }}
*/
pfx: _.isObject(options.pfx) ? options.pfx : { src: options.pfx },
/**
* passphrase
* @type {Object}
*/
passphrase: options.passphrase
});
}
|
javascript
|
function (options) {
// return early if options is empty or invalid
if (!_.isObject(options)) {
return;
}
_.mergeDefined(this, /** @lends Certificate.prototype */ {
/**
* Unique identifier
* @type {String}
*/
id: options.id,
/**
* Name for user reference
* @type {String}
*/
name: options.name,
/**
* List of match pattern
* @type {UrlMatchPatternList}
*/
matches: options.matches && new UrlMatchPatternList({}, options.matches),
/**
* Private Key
* @type {{ src: (string) }}
*/
key: _.isObject(options.key) ? options.key : { src: options.key },
/**
* Certificate
* @type {{ src: (string) }}
*/
cert: _.isObject(options.cert) ? options.cert : { src: options.cert },
/**
* PFX or PKCS12 Certificate
* @type {{ src: (string) }}
*/
pfx: _.isObject(options.pfx) ? options.pfx : { src: options.pfx },
/**
* passphrase
* @type {Object}
*/
passphrase: options.passphrase
});
}
|
[
"function",
"(",
"options",
")",
"{",
"// return early if options is empty or invalid",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"return",
";",
"}",
"_",
".",
"mergeDefined",
"(",
"this",
",",
"/** @lends Certificate.prototype */",
"{",
"/**\n * Unique identifier\n * @type {String}\n */",
"id",
":",
"options",
".",
"id",
",",
"/**\n * Name for user reference\n * @type {String}\n */",
"name",
":",
"options",
".",
"name",
",",
"/**\n * List of match pattern\n * @type {UrlMatchPatternList}\n */",
"matches",
":",
"options",
".",
"matches",
"&&",
"new",
"UrlMatchPatternList",
"(",
"{",
"}",
",",
"options",
".",
"matches",
")",
",",
"/**\n * Private Key\n * @type {{ src: (string) }}\n */",
"key",
":",
"_",
".",
"isObject",
"(",
"options",
".",
"key",
")",
"?",
"options",
".",
"key",
":",
"{",
"src",
":",
"options",
".",
"key",
"}",
",",
"/**\n * Certificate\n * @type {{ src: (string) }}\n */",
"cert",
":",
"_",
".",
"isObject",
"(",
"options",
".",
"cert",
")",
"?",
"options",
".",
"cert",
":",
"{",
"src",
":",
"options",
".",
"cert",
"}",
",",
"/**\n * PFX or PKCS12 Certificate\n * @type {{ src: (string) }}\n */",
"pfx",
":",
"_",
".",
"isObject",
"(",
"options",
".",
"pfx",
")",
"?",
"options",
".",
"pfx",
":",
"{",
"src",
":",
"options",
".",
"pfx",
"}",
",",
"/**\n * passphrase\n * @type {Object}\n */",
"passphrase",
":",
"options",
".",
"passphrase",
"}",
")",
";",
"}"
] |
Updates the certificate with the given properties.
@param {Certificate~definition=} [options] Object with matches, key, cert and passphrase
|
[
"Updates",
"the",
"certificate",
"with",
"the",
"given",
"properties",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/certificate.js#L75-L124
|
|
15,107
|
postmanlabs/postman-collection
|
lib/collection/certificate.js
|
function (url) {
if (_.isEmpty(url)) {
return false;
}
// convert url strings to Url
(typeof url === STRING) && (url = new Url(url));
// this ensures we don't proceed any further for any protocol
// that is not https
if (url.protocol !== HTTPS) {
return false;
}
// test the input url against allowed matches
return this.matches.test(url);
}
|
javascript
|
function (url) {
if (_.isEmpty(url)) {
return false;
}
// convert url strings to Url
(typeof url === STRING) && (url = new Url(url));
// this ensures we don't proceed any further for any protocol
// that is not https
if (url.protocol !== HTTPS) {
return false;
}
// test the input url against allowed matches
return this.matches.test(url);
}
|
[
"function",
"(",
"url",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"url",
")",
")",
"{",
"return",
"false",
";",
"}",
"// convert url strings to Url",
"(",
"typeof",
"url",
"===",
"STRING",
")",
"&&",
"(",
"url",
"=",
"new",
"Url",
"(",
"url",
")",
")",
";",
"// this ensures we don't proceed any further for any protocol",
"// that is not https",
"if",
"(",
"url",
".",
"protocol",
"!==",
"HTTPS",
")",
"{",
"return",
"false",
";",
"}",
"// test the input url against allowed matches",
"return",
"this",
".",
"matches",
".",
"test",
"(",
"url",
")",
";",
"}"
] |
Checks if the certificate can be applied to a given url
@param {String|Url} url The url string for which the certificate is checked for match.
|
[
"Checks",
"if",
"the",
"certificate",
"can",
"be",
"applied",
"to",
"a",
"given",
"url"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/certificate.js#L131-L147
|
|
15,108
|
postmanlabs/postman-collection
|
lib/collection/certificate.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof Certificate) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Certificate._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof Certificate) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Certificate._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"Certificate",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"Certificate",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks if the given object is a Certificate
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"if",
"the",
"given",
"object",
"is",
"a",
"Certificate"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/certificate.js#L189-L192
|
|
15,109
|
postmanlabs/postman-collection
|
lib/collection/property.js
|
function (content, type) {
(Description.isDescription(this.description) ? this.description : (this.description = new Description()))
.update(content, type);
}
|
javascript
|
function (content, type) {
(Description.isDescription(this.description) ? this.description : (this.description = new Description()))
.update(content, type);
}
|
[
"function",
"(",
"content",
",",
"type",
")",
"{",
"(",
"Description",
".",
"isDescription",
"(",
"this",
".",
"description",
")",
"?",
"this",
".",
"description",
":",
"(",
"this",
".",
"description",
"=",
"new",
"Description",
"(",
")",
")",
")",
".",
"update",
"(",
"content",
",",
"type",
")",
";",
"}"
] |
This function allows to describe the property for the purpose of detailed identification or documentation
generation. This function sets or updates the `description` child-property of this property.
@param {String} content The content of the description can be provided here as a string. Note that it is expected
that if the content is formatted in any other way than simple text, it should be specified in the subsequent
`type` parameter.
@param {String=} [type="text/plain"] The type of the content can be one of the values mentioned in
{@link Description.format} enumeration - namely `text/plain`, `text/markdown` or `text/html`.
@example <caption>Add a description to an instance of Collection</caption>
var Collection = require('postman-collection').Collection,
mycollection;
// create a blank collection
myCollection = new Collection();
myCollection.describe('Hey! This is a cool collection.');
console.log(myCollection.description.toString()); // read the description
|
[
"This",
"function",
"allows",
"to",
"describe",
"the",
"property",
"for",
"the",
"purpose",
"of",
"detailed",
"identification",
"or",
"documentation",
"generation",
".",
"This",
"function",
"sets",
"or",
"updates",
"the",
"description",
"child",
"-",
"property",
"of",
"this",
"property",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property.js#L139-L142
|
|
15,110
|
postmanlabs/postman-collection
|
lib/collection/property.js
|
function (scope, overrides, options) {
var ignoreOwnVariables = options && options.ignoreOwnVariables,
variableSourceObj,
variables,
reference;
// ensure you do not substitute variables itself!
reference = this.toJSON();
_.isArray(reference.variable) && (delete reference.variable);
// if `ignoreScopeVariables` is turned on, ignore `.variables` and resolve with only `overrides`
// otherwise find `.variables` on current object or `scope`
if (ignoreOwnVariables) {
return Property.replaceSubstitutionsIn(reference, overrides);
}
// 1. if variables is passed as params, use it or fall back to oneself
// 2. for a source from point (1), and look for `.variables`
// 3. if `.variables` is not found, then rise up the parent to find first .variables
variableSourceObj = scope || this;
do {
variables = variableSourceObj.variables;
variableSourceObj = variableSourceObj.__parent;
} while (!variables && variableSourceObj);
if (!variables) { // worst case = no variable param and none detected in tree or object
throw Error('Unable to resolve variables. Require a List type property for variable auto resolution.');
}
return variables.substitute(reference, overrides);
}
|
javascript
|
function (scope, overrides, options) {
var ignoreOwnVariables = options && options.ignoreOwnVariables,
variableSourceObj,
variables,
reference;
// ensure you do not substitute variables itself!
reference = this.toJSON();
_.isArray(reference.variable) && (delete reference.variable);
// if `ignoreScopeVariables` is turned on, ignore `.variables` and resolve with only `overrides`
// otherwise find `.variables` on current object or `scope`
if (ignoreOwnVariables) {
return Property.replaceSubstitutionsIn(reference, overrides);
}
// 1. if variables is passed as params, use it or fall back to oneself
// 2. for a source from point (1), and look for `.variables`
// 3. if `.variables` is not found, then rise up the parent to find first .variables
variableSourceObj = scope || this;
do {
variables = variableSourceObj.variables;
variableSourceObj = variableSourceObj.__parent;
} while (!variables && variableSourceObj);
if (!variables) { // worst case = no variable param and none detected in tree or object
throw Error('Unable to resolve variables. Require a List type property for variable auto resolution.');
}
return variables.substitute(reference, overrides);
}
|
[
"function",
"(",
"scope",
",",
"overrides",
",",
"options",
")",
"{",
"var",
"ignoreOwnVariables",
"=",
"options",
"&&",
"options",
".",
"ignoreOwnVariables",
",",
"variableSourceObj",
",",
"variables",
",",
"reference",
";",
"// ensure you do not substitute variables itself!",
"reference",
"=",
"this",
".",
"toJSON",
"(",
")",
";",
"_",
".",
"isArray",
"(",
"reference",
".",
"variable",
")",
"&&",
"(",
"delete",
"reference",
".",
"variable",
")",
";",
"// if `ignoreScopeVariables` is turned on, ignore `.variables` and resolve with only `overrides`",
"// otherwise find `.variables` on current object or `scope`",
"if",
"(",
"ignoreOwnVariables",
")",
"{",
"return",
"Property",
".",
"replaceSubstitutionsIn",
"(",
"reference",
",",
"overrides",
")",
";",
"}",
"// 1. if variables is passed as params, use it or fall back to oneself",
"// 2. for a source from point (1), and look for `.variables`",
"// 3. if `.variables` is not found, then rise up the parent to find first .variables",
"variableSourceObj",
"=",
"scope",
"||",
"this",
";",
"do",
"{",
"variables",
"=",
"variableSourceObj",
".",
"variables",
";",
"variableSourceObj",
"=",
"variableSourceObj",
".",
"__parent",
";",
"}",
"while",
"(",
"!",
"variables",
"&&",
"variableSourceObj",
")",
";",
"if",
"(",
"!",
"variables",
")",
"{",
"// worst case = no variable param and none detected in tree or object",
"throw",
"Error",
"(",
"'Unable to resolve variables. Require a List type property for variable auto resolution.'",
")",
";",
"}",
"return",
"variables",
".",
"substitute",
"(",
"reference",
",",
"overrides",
")",
";",
"}"
] |
Returns an object representation of the Property with its variable references substituted.
@example <caption>Resolve an object using variable definitions from itself and its parents</caption>
property.toObjectResolved();
@example <caption>Resolve an object using variable definitions on a different object</caption>
property.toObjectResolved(item);
@example <caption>Resolve an object using variables definitions as a flat list of variables</caption>
property.toObjectResolved(null, [variablesDefinition1, variablesDefinition1], {ignoreOwnVariables: true});
@private
@draft
@param {?Item|ItemGroup=} [scope] - One can specifically provide an item or group with `.variables`. In
the event one is not provided, the variables are taken from this object or one from the parent tree.
@param {Array<Object>} overrides - additional objects to lookup for variable values
@param {Object} [options]
@param {Boolean} [options.ignoreOwnVariables] - if set to true, `.variables` on self(or scope)
will not be used for variable resolution. Only variables in `overrides` will be used for resolution.
@returns {Object|undefined}
@throws {Error} If `variables` cannot be resolved up the parent chain.
|
[
"Returns",
"an",
"object",
"representation",
"of",
"the",
"Property",
"with",
"its",
"variable",
"references",
"substituted",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property.js#L167-L197
|
|
15,111
|
postmanlabs/postman-collection
|
lib/collection/property.js
|
function (str, variables) {
// if there is nothing to replace, we move on
if (!(str && _.isString(str))) { return str; }
// if variables object is not an instance of substitutor then ensure that it is an array so that it becomes
// compatible with the constructor arguments for a substitutor
!Substitutor.isInstance(variables) && !_.isArray(variables) && (variables = _.tail(arguments));
return Substitutor.box(variables, Substitutor.DEFAULT_VARS).parse(str).toString();
}
|
javascript
|
function (str, variables) {
// if there is nothing to replace, we move on
if (!(str && _.isString(str))) { return str; }
// if variables object is not an instance of substitutor then ensure that it is an array so that it becomes
// compatible with the constructor arguments for a substitutor
!Substitutor.isInstance(variables) && !_.isArray(variables) && (variables = _.tail(arguments));
return Substitutor.box(variables, Substitutor.DEFAULT_VARS).parse(str).toString();
}
|
[
"function",
"(",
"str",
",",
"variables",
")",
"{",
"// if there is nothing to replace, we move on",
"if",
"(",
"!",
"(",
"str",
"&&",
"_",
".",
"isString",
"(",
"str",
")",
")",
")",
"{",
"return",
"str",
";",
"}",
"// if variables object is not an instance of substitutor then ensure that it is an array so that it becomes",
"// compatible with the constructor arguments for a substitutor",
"!",
"Substitutor",
".",
"isInstance",
"(",
"variables",
")",
"&&",
"!",
"_",
".",
"isArray",
"(",
"variables",
")",
"&&",
"(",
"variables",
"=",
"_",
".",
"tail",
"(",
"arguments",
")",
")",
";",
"return",
"Substitutor",
".",
"box",
"(",
"variables",
",",
"Substitutor",
".",
"DEFAULT_VARS",
")",
".",
"parse",
"(",
"str",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
This function accepts a string followed by a number of variable sources as arguments. One or more variable
sources can be provided and it will use the one that has the value in left-to-right order.
@param {String} str
@param {VariableList|Object|Array.<VariableList|Object>} variables
@returns {String}
@todo: improve algorithm via variable replacement caching
|
[
"This",
"function",
"accepts",
"a",
"string",
"followed",
"by",
"a",
"number",
"of",
"variable",
"sources",
"as",
"arguments",
".",
"One",
"or",
"more",
"variable",
"sources",
"can",
"be",
"provided",
"and",
"it",
"will",
"use",
"the",
"one",
"that",
"has",
"the",
"value",
"in",
"left",
"-",
"to",
"-",
"right",
"order",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property.js#L218-L226
|
|
15,112
|
postmanlabs/postman-collection
|
lib/collection/property.js
|
function (obj, variables, mutate) {
// if there is nothing to replace, we move on
if (!(obj && _.isObject(obj))) {
return obj;
}
// convert the variables to a substitutor object (will not reconvert if already substitutor)
variables = Substitutor.box(variables, Substitutor.DEFAULT_VARS);
var customizer = function (objectValue, sourceValue) {
objectValue = objectValue || {};
if (!_.isString(sourceValue)) {
_.forOwn(sourceValue, function (value, key) {
sourceValue[key] = customizer(objectValue[key], value);
});
return sourceValue;
}
return this.replaceSubstitutions(sourceValue, variables);
}.bind(this);
return _.mergeWith(mutate ? obj : {}, obj, customizer);
}
|
javascript
|
function (obj, variables, mutate) {
// if there is nothing to replace, we move on
if (!(obj && _.isObject(obj))) {
return obj;
}
// convert the variables to a substitutor object (will not reconvert if already substitutor)
variables = Substitutor.box(variables, Substitutor.DEFAULT_VARS);
var customizer = function (objectValue, sourceValue) {
objectValue = objectValue || {};
if (!_.isString(sourceValue)) {
_.forOwn(sourceValue, function (value, key) {
sourceValue[key] = customizer(objectValue[key], value);
});
return sourceValue;
}
return this.replaceSubstitutions(sourceValue, variables);
}.bind(this);
return _.mergeWith(mutate ? obj : {}, obj, customizer);
}
|
[
"function",
"(",
"obj",
",",
"variables",
",",
"mutate",
")",
"{",
"// if there is nothing to replace, we move on",
"if",
"(",
"!",
"(",
"obj",
"&&",
"_",
".",
"isObject",
"(",
"obj",
")",
")",
")",
"{",
"return",
"obj",
";",
"}",
"// convert the variables to a substitutor object (will not reconvert if already substitutor)",
"variables",
"=",
"Substitutor",
".",
"box",
"(",
"variables",
",",
"Substitutor",
".",
"DEFAULT_VARS",
")",
";",
"var",
"customizer",
"=",
"function",
"(",
"objectValue",
",",
"sourceValue",
")",
"{",
"objectValue",
"=",
"objectValue",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"sourceValue",
")",
")",
"{",
"_",
".",
"forOwn",
"(",
"sourceValue",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"sourceValue",
"[",
"key",
"]",
"=",
"customizer",
"(",
"objectValue",
"[",
"key",
"]",
",",
"value",
")",
";",
"}",
")",
";",
"return",
"sourceValue",
";",
"}",
"return",
"this",
".",
"replaceSubstitutions",
"(",
"sourceValue",
",",
"variables",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"return",
"_",
".",
"mergeWith",
"(",
"mutate",
"?",
"obj",
":",
"{",
"}",
",",
"obj",
",",
"customizer",
")",
";",
"}"
] |
This function accepts an object followed by a number of variable sources as arguments. One or more variable
sources can be provided and it will use the one that has the value in left-to-right order.
@param {Object} obj
@param {Array.<VariableList|Object>} variables
@param {Boolean=} [mutate=false]
@returns {Object}
|
[
"This",
"function",
"accepts",
"an",
"object",
"followed",
"by",
"a",
"number",
"of",
"variable",
"sources",
"as",
"arguments",
".",
"One",
"or",
"more",
"variable",
"sources",
"can",
"be",
"provided",
"and",
"it",
"will",
"use",
"the",
"one",
"that",
"has",
"the",
"value",
"in",
"left",
"-",
"to",
"-",
"right",
"order",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property.js#L237-L260
|
|
15,113
|
postmanlabs/postman-collection
|
lib/collection/proxy-config.js
|
function (options) {
if (!_.isObject(options)) {
return;
}
var parsedUrl,
port = _.get(options, 'port') >> 0;
if (_.isString(options.host)) {
parsedUrl = nodeUrl.parse(options.host);
// we want to strip the protocol, but if protocol is not present then parsedUrl.hostname will be null
this.host = parsedUrl.protocol ? parsedUrl.hostname : options.host;
}
_.isString(options.match) && (this.match = new UrlMatchPattern(options.match));
_.isString(_.get(options, 'match.pattern')) && (this.match = new UrlMatchPattern(options.match.pattern));
port && (this.port = port);
_.isBoolean(options.tunnel) && (this.tunnel = options.tunnel);
// todo: Add update method in parent class Property and call that here
_.isBoolean(options.disabled) && (this.disabled = options.disabled);
_.isBoolean(options.authenticate) && (this.authenticate = options.authenticate);
_.isString(options.username) && (this.username = options.username);
_.isString(options.password) && (this.password = options.password);
}
|
javascript
|
function (options) {
if (!_.isObject(options)) {
return;
}
var parsedUrl,
port = _.get(options, 'port') >> 0;
if (_.isString(options.host)) {
parsedUrl = nodeUrl.parse(options.host);
// we want to strip the protocol, but if protocol is not present then parsedUrl.hostname will be null
this.host = parsedUrl.protocol ? parsedUrl.hostname : options.host;
}
_.isString(options.match) && (this.match = new UrlMatchPattern(options.match));
_.isString(_.get(options, 'match.pattern')) && (this.match = new UrlMatchPattern(options.match.pattern));
port && (this.port = port);
_.isBoolean(options.tunnel) && (this.tunnel = options.tunnel);
// todo: Add update method in parent class Property and call that here
_.isBoolean(options.disabled) && (this.disabled = options.disabled);
_.isBoolean(options.authenticate) && (this.authenticate = options.authenticate);
_.isString(options.username) && (this.username = options.username);
_.isString(options.password) && (this.password = options.password);
}
|
[
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"return",
";",
"}",
"var",
"parsedUrl",
",",
"port",
"=",
"_",
".",
"get",
"(",
"options",
",",
"'port'",
")",
">>",
"0",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"options",
".",
"host",
")",
")",
"{",
"parsedUrl",
"=",
"nodeUrl",
".",
"parse",
"(",
"options",
".",
"host",
")",
";",
"// we want to strip the protocol, but if protocol is not present then parsedUrl.hostname will be null",
"this",
".",
"host",
"=",
"parsedUrl",
".",
"protocol",
"?",
"parsedUrl",
".",
"hostname",
":",
"options",
".",
"host",
";",
"}",
"_",
".",
"isString",
"(",
"options",
".",
"match",
")",
"&&",
"(",
"this",
".",
"match",
"=",
"new",
"UrlMatchPattern",
"(",
"options",
".",
"match",
")",
")",
";",
"_",
".",
"isString",
"(",
"_",
".",
"get",
"(",
"options",
",",
"'match.pattern'",
")",
")",
"&&",
"(",
"this",
".",
"match",
"=",
"new",
"UrlMatchPattern",
"(",
"options",
".",
"match",
".",
"pattern",
")",
")",
";",
"port",
"&&",
"(",
"this",
".",
"port",
"=",
"port",
")",
";",
"_",
".",
"isBoolean",
"(",
"options",
".",
"tunnel",
")",
"&&",
"(",
"this",
".",
"tunnel",
"=",
"options",
".",
"tunnel",
")",
";",
"// todo: Add update method in parent class Property and call that here",
"_",
".",
"isBoolean",
"(",
"options",
".",
"disabled",
")",
"&&",
"(",
"this",
".",
"disabled",
"=",
"options",
".",
"disabled",
")",
";",
"_",
".",
"isBoolean",
"(",
"options",
".",
"authenticate",
")",
"&&",
"(",
"this",
".",
"authenticate",
"=",
"options",
".",
"authenticate",
")",
";",
"_",
".",
"isString",
"(",
"options",
".",
"username",
")",
"&&",
"(",
"this",
".",
"username",
"=",
"options",
".",
"username",
")",
";",
"_",
".",
"isString",
"(",
"options",
".",
"password",
")",
"&&",
"(",
"this",
".",
"password",
"=",
"options",
".",
"password",
")",
";",
"}"
] |
Updates the properties of the proxy object based on the options provided.
@param {ProxyConfig~definition} options The proxy object structure.
|
[
"Updates",
"the",
"properties",
"of",
"the",
"proxy",
"object",
"based",
"on",
"the",
"options",
"provided",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/proxy-config.js#L130-L153
|
|
15,114
|
postmanlabs/postman-collection
|
lib/collection/proxy-config.js
|
function (protocols) {
if (!protocols) {
return;
}
var updatedProtocols,
hostAndPath = _.split(this.match.pattern, PROTOCOL_HOST_SEPARATOR)[1];
if (!hostAndPath) {
return;
}
updatedProtocols = _.intersection(ALLOWED_PROTOCOLS, _.castArray(protocols));
_.isEmpty(updatedProtocols) && (updatedProtocols = ALLOWED_PROTOCOLS);
this.match.update({
pattern: updatedProtocols.join(PROTOCOL_DELIMITER) + PROTOCOL_HOST_SEPARATOR + hostAndPath
});
}
|
javascript
|
function (protocols) {
if (!protocols) {
return;
}
var updatedProtocols,
hostAndPath = _.split(this.match.pattern, PROTOCOL_HOST_SEPARATOR)[1];
if (!hostAndPath) {
return;
}
updatedProtocols = _.intersection(ALLOWED_PROTOCOLS, _.castArray(protocols));
_.isEmpty(updatedProtocols) && (updatedProtocols = ALLOWED_PROTOCOLS);
this.match.update({
pattern: updatedProtocols.join(PROTOCOL_DELIMITER) + PROTOCOL_HOST_SEPARATOR + hostAndPath
});
}
|
[
"function",
"(",
"protocols",
")",
"{",
"if",
"(",
"!",
"protocols",
")",
"{",
"return",
";",
"}",
"var",
"updatedProtocols",
",",
"hostAndPath",
"=",
"_",
".",
"split",
"(",
"this",
".",
"match",
".",
"pattern",
",",
"PROTOCOL_HOST_SEPARATOR",
")",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"hostAndPath",
")",
"{",
"return",
";",
"}",
"updatedProtocols",
"=",
"_",
".",
"intersection",
"(",
"ALLOWED_PROTOCOLS",
",",
"_",
".",
"castArray",
"(",
"protocols",
")",
")",
";",
"_",
".",
"isEmpty",
"(",
"updatedProtocols",
")",
"&&",
"(",
"updatedProtocols",
"=",
"ALLOWED_PROTOCOLS",
")",
";",
"this",
".",
"match",
".",
"update",
"(",
"{",
"pattern",
":",
"updatedProtocols",
".",
"join",
"(",
"PROTOCOL_DELIMITER",
")",
"+",
"PROTOCOL_HOST_SEPARATOR",
"+",
"hostAndPath",
"}",
")",
";",
"}"
] |
Updates the protocols in the match pattern
@param {Array.<String>} protocols The array of protocols
|
[
"Updates",
"the",
"protocols",
"in",
"the",
"match",
"pattern"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/proxy-config.js#L160-L178
|
|
15,115
|
postmanlabs/postman-collection
|
lib/collection/proxy-config.js
|
function () {
var auth = E;
// Add authentication method to URL if the same is requested. We do it this way because
// this is how `postman-request` library accepts auth credentials in its proxy configuration.
if (this.authenticate) {
auth = (this.username || E);
if (this.password) {
auth += (COLON + (this.password || E));
}
if (auth) {
auth += AUTH_CREDENTIALS_SEPARATOR;
}
}
return DEFAULT_PROTOCOL + PROTOCOL_HOST_SEPARATOR + auth + this.host + COLON + this.port;
}
|
javascript
|
function () {
var auth = E;
// Add authentication method to URL if the same is requested. We do it this way because
// this is how `postman-request` library accepts auth credentials in its proxy configuration.
if (this.authenticate) {
auth = (this.username || E);
if (this.password) {
auth += (COLON + (this.password || E));
}
if (auth) {
auth += AUTH_CREDENTIALS_SEPARATOR;
}
}
return DEFAULT_PROTOCOL + PROTOCOL_HOST_SEPARATOR + auth + this.host + COLON + this.port;
}
|
[
"function",
"(",
")",
"{",
"var",
"auth",
"=",
"E",
";",
"// Add authentication method to URL if the same is requested. We do it this way because",
"// this is how `postman-request` library accepts auth credentials in its proxy configuration.",
"if",
"(",
"this",
".",
"authenticate",
")",
"{",
"auth",
"=",
"(",
"this",
".",
"username",
"||",
"E",
")",
";",
"if",
"(",
"this",
".",
"password",
")",
"{",
"auth",
"+=",
"(",
"COLON",
"+",
"(",
"this",
".",
"password",
"||",
"E",
")",
")",
";",
"}",
"if",
"(",
"auth",
")",
"{",
"auth",
"+=",
"AUTH_CREDENTIALS_SEPARATOR",
";",
"}",
"}",
"return",
"DEFAULT_PROTOCOL",
"+",
"PROTOCOL_HOST_SEPARATOR",
"+",
"auth",
"+",
"this",
".",
"host",
"+",
"COLON",
"+",
"this",
".",
"port",
";",
"}"
] |
Returns the proxy server url.
@returns {String}
|
[
"Returns",
"the",
"proxy",
"server",
"url",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/proxy-config.js#L208-L226
|
|
15,116
|
postmanlabs/postman-collection
|
lib/collection/header-list.js
|
function () {
if (!this.count()) { return 0; }
var raw = this.reduce(function (acc, header) {
// unparse header only if it has a valid key and is not disabled
if (header && !header.disabled) {
// *( header-field CRLF )
acc += Header.unparseSingle(header) + CRLF;
}
return acc;
}, E);
return raw.length;
}
|
javascript
|
function () {
if (!this.count()) { return 0; }
var raw = this.reduce(function (acc, header) {
// unparse header only if it has a valid key and is not disabled
if (header && !header.disabled) {
// *( header-field CRLF )
acc += Header.unparseSingle(header) + CRLF;
}
return acc;
}, E);
return raw.length;
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"count",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"var",
"raw",
"=",
"this",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"header",
")",
"{",
"// unparse header only if it has a valid key and is not disabled",
"if",
"(",
"header",
"&&",
"!",
"header",
".",
"disabled",
")",
"{",
"// *( header-field CRLF )",
"acc",
"+=",
"Header",
".",
"unparseSingle",
"(",
"header",
")",
"+",
"CRLF",
";",
"}",
"return",
"acc",
";",
"}",
",",
"E",
")",
";",
"return",
"raw",
".",
"length",
";",
"}"
] |
Gets size of a list of headers excluding standard header prefix.
@returns {Number}
|
[
"Gets",
"size",
"of",
"a",
"list",
"of",
"headers",
"excluding",
"standard",
"header",
"prefix",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header-list.js#L32-L46
|
|
15,117
|
postmanlabs/postman-collection
|
lib/collection/header-list.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof HeaderList) ||
_.inSuperChain(obj.constructor, PROP_NAME, HeaderList._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof HeaderList) ||
_.inSuperChain(obj.constructor, PROP_NAME, HeaderList._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"HeaderList",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"PROP_NAME",
",",
"HeaderList",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks if the given object is a HeaderList
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"if",
"the",
"given",
"object",
"is",
"a",
"HeaderList"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header-list.js#L64-L67
|
|
15,118
|
postmanlabs/postman-collection
|
lib/collection/event.js
|
function (definition) {
if (!definition) {
return;
}
var result,
script = definition.script;
if (Script.isScript(script)) {
result = script;
}
else if (_.isArray(script) || _.isString(script)) {
result = new Script({ exec: script });
}
else if (_.isObject(script)) {
result = new Script(script);
}
_.mergeDefined(this, /** @lends Event.prototype */ {
/**
* Name of the event that this instance is intended to listen to.
* @type {String}
*/
listen: _.isString(definition.listen) ? definition.listen.toLowerCase() : undefined,
/**
* The script that is to be executed when this event is triggered.
* @type {Script}
*/
script: result
});
}
|
javascript
|
function (definition) {
if (!definition) {
return;
}
var result,
script = definition.script;
if (Script.isScript(script)) {
result = script;
}
else if (_.isArray(script) || _.isString(script)) {
result = new Script({ exec: script });
}
else if (_.isObject(script)) {
result = new Script(script);
}
_.mergeDefined(this, /** @lends Event.prototype */ {
/**
* Name of the event that this instance is intended to listen to.
* @type {String}
*/
listen: _.isString(definition.listen) ? definition.listen.toLowerCase() : undefined,
/**
* The script that is to be executed when this event is triggered.
* @type {Script}
*/
script: result
});
}
|
[
"function",
"(",
"definition",
")",
"{",
"if",
"(",
"!",
"definition",
")",
"{",
"return",
";",
"}",
"var",
"result",
",",
"script",
"=",
"definition",
".",
"script",
";",
"if",
"(",
"Script",
".",
"isScript",
"(",
"script",
")",
")",
"{",
"result",
"=",
"script",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isArray",
"(",
"script",
")",
"||",
"_",
".",
"isString",
"(",
"script",
")",
")",
"{",
"result",
"=",
"new",
"Script",
"(",
"{",
"exec",
":",
"script",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"script",
")",
")",
"{",
"result",
"=",
"new",
"Script",
"(",
"script",
")",
";",
"}",
"_",
".",
"mergeDefined",
"(",
"this",
",",
"/** @lends Event.prototype */",
"{",
"/**\n * Name of the event that this instance is intended to listen to.\n * @type {String}\n */",
"listen",
":",
"_",
".",
"isString",
"(",
"definition",
".",
"listen",
")",
"?",
"definition",
".",
"listen",
".",
"toLowerCase",
"(",
")",
":",
"undefined",
",",
"/**\n * The script that is to be executed when this event is triggered.\n * @type {Script}\n */",
"script",
":",
"result",
"}",
")",
";",
"}"
] |
Update an event.
@param {Event~definition} definition
|
[
"Update",
"an",
"event",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/event.js#L45-L76
|
|
15,119
|
postmanlabs/postman-collection
|
lib/collection/description.js
|
function (content, type) {
_.isObject(content) && ((type = content.type), (content = content.content));
_.assign(this, /** @lends Description.prototype */ {
/**
* The raw content of the description
*
* @type {String}
*/
content: content,
/**
* The mime-type of the description.
*
* @type {String}
*/
type: type || DEFAULT_MIMETYPE
});
}
|
javascript
|
function (content, type) {
_.isObject(content) && ((type = content.type), (content = content.content));
_.assign(this, /** @lends Description.prototype */ {
/**
* The raw content of the description
*
* @type {String}
*/
content: content,
/**
* The mime-type of the description.
*
* @type {String}
*/
type: type || DEFAULT_MIMETYPE
});
}
|
[
"function",
"(",
"content",
",",
"type",
")",
"{",
"_",
".",
"isObject",
"(",
"content",
")",
"&&",
"(",
"(",
"type",
"=",
"content",
".",
"type",
")",
",",
"(",
"content",
"=",
"content",
".",
"content",
")",
")",
";",
"_",
".",
"assign",
"(",
"this",
",",
"/** @lends Description.prototype */",
"{",
"/**\n * The raw content of the description\n *\n * @type {String}\n */",
"content",
":",
"content",
",",
"/**\n * The mime-type of the description.\n *\n * @type {String}\n */",
"type",
":",
"type",
"||",
"DEFAULT_MIMETYPE",
"}",
")",
";",
"}"
] |
Updates the content of this description property.
@param {String|Description~definition} content
@param {String=} [type]
@todo parse version of description
|
[
"Updates",
"the",
"content",
"of",
"this",
"description",
"property",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/description.js#L88-L105
|
|
15,120
|
postmanlabs/postman-collection
|
lib/collection/description.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof Description) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Description._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof Description) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Description._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"Description",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"Description",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks whether a property is an instance of Description object.
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"whether",
"a",
"property",
"is",
"an",
"instance",
"of",
"Description",
"object",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/description.js#L182-L185
|
|
15,121
|
postmanlabs/postman-collection
|
lib/collection/event-list.js
|
function (name) {
var all;
// we first procure all matching events from this list
all = this.listenersOwn(name);
this.eachParent(function (parent) {
var parentEvents;
// we check that the parent is not immediate mother. then we check whether the non immediate mother has a
// valid `events` store and only if this store has events with specified listener, we push them to the
// array we are compiling for return
(parent !== this.__parent) && EventList.isEventList(parent.events) &&
(parentEvents = parent.events.listenersOwn(name)) && parentEvents.length &&
all.unshift.apply(all, parentEvents); // eslint-disable-line prefer-spread
}, this);
return all;
}
|
javascript
|
function (name) {
var all;
// we first procure all matching events from this list
all = this.listenersOwn(name);
this.eachParent(function (parent) {
var parentEvents;
// we check that the parent is not immediate mother. then we check whether the non immediate mother has a
// valid `events` store and only if this store has events with specified listener, we push them to the
// array we are compiling for return
(parent !== this.__parent) && EventList.isEventList(parent.events) &&
(parentEvents = parent.events.listenersOwn(name)) && parentEvents.length &&
all.unshift.apply(all, parentEvents); // eslint-disable-line prefer-spread
}, this);
return all;
}
|
[
"function",
"(",
"name",
")",
"{",
"var",
"all",
";",
"// we first procure all matching events from this list",
"all",
"=",
"this",
".",
"listenersOwn",
"(",
"name",
")",
";",
"this",
".",
"eachParent",
"(",
"function",
"(",
"parent",
")",
"{",
"var",
"parentEvents",
";",
"// we check that the parent is not immediate mother. then we check whether the non immediate mother has a",
"// valid `events` store and only if this store has events with specified listener, we push them to the",
"// array we are compiling for return",
"(",
"parent",
"!==",
"this",
".",
"__parent",
")",
"&&",
"EventList",
".",
"isEventList",
"(",
"parent",
".",
"events",
")",
"&&",
"(",
"parentEvents",
"=",
"parent",
".",
"events",
".",
"listenersOwn",
"(",
"name",
")",
")",
"&&",
"parentEvents",
".",
"length",
"&&",
"all",
".",
"unshift",
".",
"apply",
"(",
"all",
",",
"parentEvents",
")",
";",
"// eslint-disable-line prefer-spread",
"}",
",",
"this",
")",
";",
"return",
"all",
";",
"}"
] |
Returns an array of listeners filtered by the listener name
@note
If one needs to access disabled events, use {@link PropertyList#all} or
any other similar {@link PropertyList} method.
@param {String} name
@returns {Array<Event>}
|
[
"Returns",
"an",
"array",
"of",
"listeners",
"filtered",
"by",
"the",
"listener",
"name"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/event-list.js#L36-L54
|
|
15,122
|
postmanlabs/postman-collection
|
lib/collection/event-list.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof EventList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', EventList._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof EventList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', EventList._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"EventList",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"EventList",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks if the given object is an EventList.
@param {*} obj
@returns {boolean}
|
[
"Checks",
"if",
"the",
"given",
"object",
"is",
"an",
"EventList",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/event-list.js#L85-L88
|
|
15,123
|
postmanlabs/postman-collection
|
lib/collection/header.js
|
function (options) {
/**
* The header Key
* @type {String}
* @todo avoid headers with falsy key.
*/
this.key = _.get(options, 'key') || E;
/**
* The header value
* @type {String}
*/
this.value = _.get(options, 'value') || E;
/**
* Indicates whether the header was added by internal SDK operations, such as authorizing a request.
* @type {*|boolean}
*/
_.has(options, 'system') && (this.system = options.system);
/**
* Indicates whether the header should be .
* @type {*|boolean}
* @todo figure out whether this should be in property.js
*/
_.has(options, 'disabled') && (this.disabled = options.disabled);
}
|
javascript
|
function (options) {
/**
* The header Key
* @type {String}
* @todo avoid headers with falsy key.
*/
this.key = _.get(options, 'key') || E;
/**
* The header value
* @type {String}
*/
this.value = _.get(options, 'value') || E;
/**
* Indicates whether the header was added by internal SDK operations, such as authorizing a request.
* @type {*|boolean}
*/
_.has(options, 'system') && (this.system = options.system);
/**
* Indicates whether the header should be .
* @type {*|boolean}
* @todo figure out whether this should be in property.js
*/
_.has(options, 'disabled') && (this.disabled = options.disabled);
}
|
[
"function",
"(",
"options",
")",
"{",
"/**\n * The header Key\n * @type {String}\n * @todo avoid headers with falsy key.\n */",
"this",
".",
"key",
"=",
"_",
".",
"get",
"(",
"options",
",",
"'key'",
")",
"||",
"E",
";",
"/**\n * The header value\n * @type {String}\n */",
"this",
".",
"value",
"=",
"_",
".",
"get",
"(",
"options",
",",
"'value'",
")",
"||",
"E",
";",
"/**\n * Indicates whether the header was added by internal SDK operations, such as authorizing a request.\n * @type {*|boolean}\n */",
"_",
".",
"has",
"(",
"options",
",",
"'system'",
")",
"&&",
"(",
"this",
".",
"system",
"=",
"options",
".",
"system",
")",
";",
"/**\n * Indicates whether the header should be .\n * @type {*|boolean}\n * @todo figure out whether this should be in property.js\n */",
"_",
".",
"has",
"(",
"options",
",",
"'disabled'",
")",
"&&",
"(",
"this",
".",
"disabled",
"=",
"options",
".",
"disabled",
")",
";",
"}"
] |
Assigns the given properties to the Header
@param {Object} options
@todo check for allowed characters in header key-value or store encoded.
|
[
"Assigns",
"the",
"given",
"properties",
"to",
"the",
"Header"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header.js#L102-L128
|
|
15,124
|
postmanlabs/postman-collection
|
lib/collection/header.js
|
function (header) {
if (!_.isString(header)) { return { key: E, value: E }; }
var index = header.indexOf(HEADER_KV_SEPARATOR),
key,
value;
(index < 0) && (index = header.length);
key = header.substr(0, index);
value = header.substr(index + 1);
return {
key: _.trim(key),
value: _.trim(value)
};
}
|
javascript
|
function (header) {
if (!_.isString(header)) { return { key: E, value: E }; }
var index = header.indexOf(HEADER_KV_SEPARATOR),
key,
value;
(index < 0) && (index = header.length);
key = header.substr(0, index);
value = header.substr(index + 1);
return {
key: _.trim(key),
value: _.trim(value)
};
}
|
[
"function",
"(",
"header",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"header",
")",
")",
"{",
"return",
"{",
"key",
":",
"E",
",",
"value",
":",
"E",
"}",
";",
"}",
"var",
"index",
"=",
"header",
".",
"indexOf",
"(",
"HEADER_KV_SEPARATOR",
")",
",",
"key",
",",
"value",
";",
"(",
"index",
"<",
"0",
")",
"&&",
"(",
"index",
"=",
"header",
".",
"length",
")",
";",
"key",
"=",
"header",
".",
"substr",
"(",
"0",
",",
"index",
")",
";",
"value",
"=",
"header",
".",
"substr",
"(",
"index",
"+",
"1",
")",
";",
"return",
"{",
"key",
":",
"_",
".",
"trim",
"(",
"key",
")",
",",
"value",
":",
"_",
".",
"trim",
"(",
"value",
")",
"}",
";",
"}"
] |
Parses a single Header.
@param {String} header
@returns {{key: string, value: string}}
|
[
"Parses",
"a",
"single",
"Header",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header.js#L198-L214
|
|
15,125
|
postmanlabs/postman-collection
|
lib/collection/header.js
|
function (header) {
if (!_.isObject(header)) { return E; }
return header.key + HEADER_KV_SEPARATOR + SPC + header.value;
}
|
javascript
|
function (header) {
if (!_.isObject(header)) { return E; }
return header.key + HEADER_KV_SEPARATOR + SPC + header.value;
}
|
[
"function",
"(",
"header",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"header",
")",
")",
"{",
"return",
"E",
";",
"}",
"return",
"header",
".",
"key",
"+",
"HEADER_KV_SEPARATOR",
"+",
"SPC",
"+",
"header",
".",
"value",
";",
"}"
] |
Unparses a single Header.
@param {String} header
@returns {String}
|
[
"Unparses",
"a",
"single",
"Header",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header.js#L238-L241
|
|
15,126
|
postmanlabs/postman-collection
|
lib/collection/header.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof Header) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Header._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof Header) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Header._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"Header",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"Header",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Check whether an object is an instance of PostmanHeader.
@param {*} obj
@returns {Boolean}
|
[
"Check",
"whether",
"an",
"object",
"is",
"an",
"instance",
"of",
"PostmanHeader",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/header.js#L249-L252
|
|
15,127
|
postmanlabs/postman-collection
|
lib/collection/variable.js
|
function () {
var value = this.valueOf();
// returns empty string if the value is
// null or undefined or does not implement a toString
return (!_.isNil(value) && _.isFunction(value.toString)) ? value.toString() : E;
}
|
javascript
|
function () {
var value = this.valueOf();
// returns empty string if the value is
// null or undefined or does not implement a toString
return (!_.isNil(value) && _.isFunction(value.toString)) ? value.toString() : E;
}
|
[
"function",
"(",
")",
"{",
"var",
"value",
"=",
"this",
".",
"valueOf",
"(",
")",
";",
"// returns empty string if the value is",
"// null or undefined or does not implement a toString",
"return",
"(",
"!",
"_",
".",
"isNil",
"(",
"value",
")",
"&&",
"_",
".",
"isFunction",
"(",
"value",
".",
"toString",
")",
")",
"?",
"value",
".",
"toString",
"(",
")",
":",
"E",
";",
"}"
] |
Returns the stringified value of the variable.
@returns {String}
|
[
"Returns",
"the",
"stringified",
"value",
"of",
"the",
"variable",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable.js#L109-L115
|
|
15,128
|
postmanlabs/postman-collection
|
lib/collection/variable.js
|
function (typeName, _noCast) {
!_.isNil(typeName) && (typeName = typeName.toString().toLowerCase()); // sanitize
if (!Variable.types[typeName]) {
return this.type || ANY; // @todo: throw new Error('Invalid variable type.');
}
// set type if it is valid
this.type = typeName;
// 1. get the current value
// 2. set the new type if it is valid and cast the stored value
// 3. then set the interstitial value
var interstitialCastValue;
// do not touch value functions
if (!(_noCast || _.isFunction(this.value))) {
interstitialCastValue = this.get();
this.set(interstitialCastValue);
interstitialCastValue = null; // just a precaution
}
return this.type;
}
|
javascript
|
function (typeName, _noCast) {
!_.isNil(typeName) && (typeName = typeName.toString().toLowerCase()); // sanitize
if (!Variable.types[typeName]) {
return this.type || ANY; // @todo: throw new Error('Invalid variable type.');
}
// set type if it is valid
this.type = typeName;
// 1. get the current value
// 2. set the new type if it is valid and cast the stored value
// 3. then set the interstitial value
var interstitialCastValue;
// do not touch value functions
if (!(_noCast || _.isFunction(this.value))) {
interstitialCastValue = this.get();
this.set(interstitialCastValue);
interstitialCastValue = null; // just a precaution
}
return this.type;
}
|
[
"function",
"(",
"typeName",
",",
"_noCast",
")",
"{",
"!",
"_",
".",
"isNil",
"(",
"typeName",
")",
"&&",
"(",
"typeName",
"=",
"typeName",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"// sanitize",
"if",
"(",
"!",
"Variable",
".",
"types",
"[",
"typeName",
"]",
")",
"{",
"return",
"this",
".",
"type",
"||",
"ANY",
";",
"// @todo: throw new Error('Invalid variable type.');",
"}",
"// set type if it is valid",
"this",
".",
"type",
"=",
"typeName",
";",
"// 1. get the current value",
"// 2. set the new type if it is valid and cast the stored value",
"// 3. then set the interstitial value",
"var",
"interstitialCastValue",
";",
"// do not touch value functions",
"if",
"(",
"!",
"(",
"_noCast",
"||",
"_",
".",
"isFunction",
"(",
"this",
".",
"value",
")",
")",
")",
"{",
"interstitialCastValue",
"=",
"this",
".",
"get",
"(",
")",
";",
"this",
".",
"set",
"(",
"interstitialCastValue",
")",
";",
"interstitialCastValue",
"=",
"null",
";",
"// just a precaution",
"}",
"return",
"this",
".",
"type",
";",
"}"
] |
Sets or gets the type of the value.
@param {String} typeName
@param {Boolean} _noCast
@returns {String} - returns the current type of the variable from the list of {@link Variable.types}
|
[
"Sets",
"or",
"gets",
"the",
"type",
"of",
"the",
"value",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable.js#L161-L183
|
|
15,129
|
postmanlabs/postman-collection
|
lib/collection/variable.js
|
function (options) {
if (!_.isObject(options)) {
return;
}
// set type and value.
// @note that we cannot update the key, once created during construction
options.hasOwnProperty('type') && this.valueType(options.type, options.hasOwnProperty('value'));
options.hasOwnProperty('value') && this.set(options.value);
options.hasOwnProperty('system') && (this.system = options.system);
options.hasOwnProperty('disabled') && (this.disabled = options.disabled);
}
|
javascript
|
function (options) {
if (!_.isObject(options)) {
return;
}
// set type and value.
// @note that we cannot update the key, once created during construction
options.hasOwnProperty('type') && this.valueType(options.type, options.hasOwnProperty('value'));
options.hasOwnProperty('value') && this.set(options.value);
options.hasOwnProperty('system') && (this.system = options.system);
options.hasOwnProperty('disabled') && (this.disabled = options.disabled);
}
|
[
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"return",
";",
"}",
"// set type and value.",
"// @note that we cannot update the key, once created during construction",
"options",
".",
"hasOwnProperty",
"(",
"'type'",
")",
"&&",
"this",
".",
"valueType",
"(",
"options",
".",
"type",
",",
"options",
".",
"hasOwnProperty",
"(",
"'value'",
")",
")",
";",
"options",
".",
"hasOwnProperty",
"(",
"'value'",
")",
"&&",
"this",
".",
"set",
"(",
"options",
".",
"value",
")",
";",
"options",
".",
"hasOwnProperty",
"(",
"'system'",
")",
"&&",
"(",
"this",
".",
"system",
"=",
"options",
".",
"system",
")",
";",
"options",
".",
"hasOwnProperty",
"(",
"'disabled'",
")",
"&&",
"(",
"this",
".",
"disabled",
"=",
"options",
".",
"disabled",
")",
";",
"}"
] |
Updates the type and value of a variable from an object or JSON definition of the variable.
@param {Variable~definition} options
|
[
"Updates",
"the",
"type",
"and",
"value",
"of",
"a",
"variable",
"from",
"an",
"object",
"or",
"JSON",
"definition",
"of",
"the",
"variable",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable.js#L190-L200
|
|
15,130
|
postmanlabs/postman-collection
|
lib/collection/variable.js
|
function (val) {
var value;
try {
value = JSON.parse(val);
}
catch (e) {
value = undefined;
}
return Array.isArray(value) ? value : undefined;
}
|
javascript
|
function (val) {
var value;
try {
value = JSON.parse(val);
}
catch (e) {
value = undefined;
}
return Array.isArray(value) ? value : undefined;
}
|
[
"function",
"(",
"val",
")",
"{",
"var",
"value",
";",
"try",
"{",
"value",
"=",
"JSON",
".",
"parse",
"(",
"val",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"value",
"=",
"undefined",
";",
"}",
"return",
"Array",
".",
"isArray",
"(",
"value",
")",
"?",
"value",
":",
"undefined",
";",
"}"
] |
A "array" type value stores Array data format
@param {String} val
@returns {Object}
|
[
"A",
"array",
"type",
"value",
"stores",
"Array",
"data",
"format"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable.js#L314-L325
|
|
15,131
|
postmanlabs/postman-collection
|
lib/collection/cookie-list.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof CookieList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', CookieList._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof CookieList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', CookieList._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"CookieList",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"CookieList",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks if the given object is a CookieList
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"if",
"the",
"given",
"object",
"is",
"a",
"CookieList"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/cookie-list.js#L40-L43
|
|
15,132
|
postmanlabs/postman-collection
|
lib/collection/version.js
|
function (value) {
// extract the version logic and in case it failes and value passed is an object, we use that assuming parsed
// value has been sent.
var ver = semver.parse(value) || value || {};
_.assign(this, /** @lends Version.prototype */ {
/**
* The raw URL string. If {@link Version#set} is called with a string parameter, the string is saved here
* before parsing various Version components.
*
* @type {String}
*/
raw: ver.raw,
/**
* @type {String}
*/
major: ver.major,
/**
* @type {String}
*/
minor: ver.minor,
/**
* @type {String}
*/
patch: ver.patch,
/**
* @type {String}
*/
prerelease: ver.prerelease && ver.prerelease.join && ver.prerelease.join() || ver.prerelease,
/**
* @type {String}
*/
build: ver.build && ver.build.join && ver.build.join() || ver.build,
/**
* @type {String}
*/
string: ver.version
});
}
|
javascript
|
function (value) {
// extract the version logic and in case it failes and value passed is an object, we use that assuming parsed
// value has been sent.
var ver = semver.parse(value) || value || {};
_.assign(this, /** @lends Version.prototype */ {
/**
* The raw URL string. If {@link Version#set} is called with a string parameter, the string is saved here
* before parsing various Version components.
*
* @type {String}
*/
raw: ver.raw,
/**
* @type {String}
*/
major: ver.major,
/**
* @type {String}
*/
minor: ver.minor,
/**
* @type {String}
*/
patch: ver.patch,
/**
* @type {String}
*/
prerelease: ver.prerelease && ver.prerelease.join && ver.prerelease.join() || ver.prerelease,
/**
* @type {String}
*/
build: ver.build && ver.build.join && ver.build.join() || ver.build,
/**
* @type {String}
*/
string: ver.version
});
}
|
[
"function",
"(",
"value",
")",
"{",
"// extract the version logic and in case it failes and value passed is an object, we use that assuming parsed",
"// value has been sent.",
"var",
"ver",
"=",
"semver",
".",
"parse",
"(",
"value",
")",
"||",
"value",
"||",
"{",
"}",
";",
"_",
".",
"assign",
"(",
"this",
",",
"/** @lends Version.prototype */",
"{",
"/**\n * The raw URL string. If {@link Version#set} is called with a string parameter, the string is saved here\n * before parsing various Version components.\n *\n * @type {String}\n */",
"raw",
":",
"ver",
".",
"raw",
",",
"/**\n * @type {String}\n */",
"major",
":",
"ver",
".",
"major",
",",
"/**\n * @type {String}\n */",
"minor",
":",
"ver",
".",
"minor",
",",
"/**\n * @type {String}\n */",
"patch",
":",
"ver",
".",
"patch",
",",
"/**\n * @type {String}\n */",
"prerelease",
":",
"ver",
".",
"prerelease",
"&&",
"ver",
".",
"prerelease",
".",
"join",
"&&",
"ver",
".",
"prerelease",
".",
"join",
"(",
")",
"||",
"ver",
".",
"prerelease",
",",
"/**\n * @type {String}\n */",
"build",
":",
"ver",
".",
"build",
"&&",
"ver",
".",
"build",
".",
"join",
"&&",
"ver",
".",
"build",
".",
"join",
"(",
")",
"||",
"ver",
".",
"build",
",",
"/**\n * @type {String}\n */",
"string",
":",
"ver",
".",
"version",
"}",
")",
";",
"}"
] |
Set the version value as string or object with separate components of version
@draft
@param {object|string} value
|
[
"Set",
"the",
"version",
"value",
"as",
"string",
"or",
"object",
"with",
"separate",
"components",
"of",
"version"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/version.js#L31-L75
|
|
15,133
|
postmanlabs/postman-collection
|
lib/collection/property-base.js
|
function (options, iterator) {
_.isFunction(options) && (iterator = options, options = {});
if (!_.isFunction(iterator) || !_.isObject(options)) { return; }
var parent = this.parent(),
grandparent = parent && _.isFunction(parent.parent) && parent.parent();
while (parent && (grandparent || options.withRoot)) {
iterator(parent);
parent = grandparent;
grandparent = grandparent && _.isFunction(grandparent.parent) && grandparent.parent();
}
}
|
javascript
|
function (options, iterator) {
_.isFunction(options) && (iterator = options, options = {});
if (!_.isFunction(iterator) || !_.isObject(options)) { return; }
var parent = this.parent(),
grandparent = parent && _.isFunction(parent.parent) && parent.parent();
while (parent && (grandparent || options.withRoot)) {
iterator(parent);
parent = grandparent;
grandparent = grandparent && _.isFunction(grandparent.parent) && grandparent.parent();
}
}
|
[
"function",
"(",
"options",
",",
"iterator",
")",
"{",
"_",
".",
"isFunction",
"(",
"options",
")",
"&&",
"(",
"iterator",
"=",
"options",
",",
"options",
"=",
"{",
"}",
")",
";",
"if",
"(",
"!",
"_",
".",
"isFunction",
"(",
"iterator",
")",
"||",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"return",
";",
"}",
"var",
"parent",
"=",
"this",
".",
"parent",
"(",
")",
",",
"grandparent",
"=",
"parent",
"&&",
"_",
".",
"isFunction",
"(",
"parent",
".",
"parent",
")",
"&&",
"parent",
".",
"parent",
"(",
")",
";",
"while",
"(",
"parent",
"&&",
"(",
"grandparent",
"||",
"options",
".",
"withRoot",
")",
")",
"{",
"iterator",
"(",
"parent",
")",
";",
"parent",
"=",
"grandparent",
";",
"grandparent",
"=",
"grandparent",
"&&",
"_",
".",
"isFunction",
"(",
"grandparent",
".",
"parent",
")",
"&&",
"grandparent",
".",
"parent",
"(",
")",
";",
"}",
"}"
] |
Invokes the given iterator for every parent in the parent chain of the given element.
@param {?Object|Boolean} [options={}] - A set of options for the parent chain traversal.
@param {?Boolean} [options.withRoot=false] - Set to true to include the collection object as well.
@param {Function} iterator - The function to call for every parent in the ancestry chain.
@todo Cache the results
|
[
"Invokes",
"the",
"given",
"iterator",
"for",
"every",
"parent",
"in",
"the",
"parent",
"chain",
"of",
"the",
"given",
"element",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-base.js#L45-L57
|
|
15,134
|
postmanlabs/postman-collection
|
lib/collection/property-base.js
|
function (property, customizer) {
var owner = this.findParentContaining(property, customizer);
return owner ? owner[property] : undefined;
}
|
javascript
|
function (property, customizer) {
var owner = this.findParentContaining(property, customizer);
return owner ? owner[property] : undefined;
}
|
[
"function",
"(",
"property",
",",
"customizer",
")",
"{",
"var",
"owner",
"=",
"this",
".",
"findParentContaining",
"(",
"property",
",",
"customizer",
")",
";",
"return",
"owner",
"?",
"owner",
"[",
"property",
"]",
":",
"undefined",
";",
"}"
] |
Tries to find the given property locally, and then proceeds to lookup in each parent,
going up the chain as necessary. Lookup will continue until `customizer` returns a truthy value. If used
without a customizer, the lookup will stop at the first parent that contains the property.
@param {String} property
@param {Function} [customizer]
@returns {*|undefined}
|
[
"Tries",
"to",
"find",
"the",
"given",
"property",
"locally",
"and",
"then",
"proceeds",
"to",
"lookup",
"in",
"each",
"parent",
"going",
"up",
"the",
"chain",
"as",
"necessary",
".",
"Lookup",
"will",
"continue",
"until",
"customizer",
"returns",
"a",
"truthy",
"value",
".",
"If",
"used",
"without",
"a",
"customizer",
"the",
"lookup",
"will",
"stop",
"at",
"the",
"first",
"parent",
"that",
"contains",
"the",
"property",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-base.js#L69-L72
|
|
15,135
|
postmanlabs/postman-collection
|
lib/collection/property-base.js
|
function (property, customizer) {
var parent = this;
// if customizer is present test with it
if (customizer) {
customizer = customizer.bind(this);
do {
// else check for existence
if (customizer(parent)) {
return parent;
}
parent = parent.__parent;
} while (parent);
}
// else check for existence
else {
do {
if (parent[property]) {
return parent;
}
parent = parent.__parent;
} while (parent);
}
}
|
javascript
|
function (property, customizer) {
var parent = this;
// if customizer is present test with it
if (customizer) {
customizer = customizer.bind(this);
do {
// else check for existence
if (customizer(parent)) {
return parent;
}
parent = parent.__parent;
} while (parent);
}
// else check for existence
else {
do {
if (parent[property]) {
return parent;
}
parent = parent.__parent;
} while (parent);
}
}
|
[
"function",
"(",
"property",
",",
"customizer",
")",
"{",
"var",
"parent",
"=",
"this",
";",
"// if customizer is present test with it",
"if",
"(",
"customizer",
")",
"{",
"customizer",
"=",
"customizer",
".",
"bind",
"(",
"this",
")",
";",
"do",
"{",
"// else check for existence",
"if",
"(",
"customizer",
"(",
"parent",
")",
")",
"{",
"return",
"parent",
";",
"}",
"parent",
"=",
"parent",
".",
"__parent",
";",
"}",
"while",
"(",
"parent",
")",
";",
"}",
"// else check for existence",
"else",
"{",
"do",
"{",
"if",
"(",
"parent",
"[",
"property",
"]",
")",
"{",
"return",
"parent",
";",
"}",
"parent",
"=",
"parent",
".",
"__parent",
";",
"}",
"while",
"(",
"parent",
")",
";",
"}",
"}"
] |
Looks up the closest parent which has a truthy value for the given property. Lookup will continue
until `customizer` returns a truthy value. If used without a customizer,
the lookup will stop at the first parent that contains the property.
@param {String} property
@param {Function} [customizer]
@returns {PropertyBase|undefined}
@private
|
[
"Looks",
"up",
"the",
"closest",
"parent",
"which",
"has",
"a",
"truthy",
"value",
"for",
"the",
"given",
"property",
".",
"Lookup",
"will",
"continue",
"until",
"customizer",
"returns",
"a",
"truthy",
"value",
".",
"If",
"used",
"without",
"a",
"customizer",
"the",
"lookup",
"will",
"stop",
"at",
"the",
"first",
"parent",
"that",
"contains",
"the",
"property",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-base.js#L85-L112
|
|
15,136
|
postmanlabs/postman-collection
|
lib/collection/property-base.js
|
function () {
return arguments.length ? _.pick(this._, Array.prototype.slice.apply(arguments)) : _.cloneDeep(this._);
}
|
javascript
|
function () {
return arguments.length ? _.pick(this._, Array.prototype.slice.apply(arguments)) : _.cloneDeep(this._);
}
|
[
"function",
"(",
")",
"{",
"return",
"arguments",
".",
"length",
"?",
"_",
".",
"pick",
"(",
"this",
".",
"_",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
")",
":",
"_",
".",
"cloneDeep",
"(",
"this",
".",
"_",
")",
";",
"}"
] |
Returns the meta keys associated with the property
@returns {*}
|
[
"Returns",
"the",
"meta",
"keys",
"associated",
"with",
"the",
"property"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-base.js#L154-L156
|
|
15,137
|
postmanlabs/postman-collection
|
lib/collection/script.js
|
function (options) {
// no splitting is being done here, as string scripts are split right before assignment below anyway
(_.isString(options) || _.isArray(options)) && (options = { exec: options });
if (!options) { return; } // in case definition object is missing, there is no point moving forward
// create the request property
/**
* @augments {Script.prototype}
* @type {string}
*/
this.type = options.type || 'text/javascript';
options.hasOwnProperty('src') && (
/**
* @augments {Script.prototype}
* @type {Url}
*/
this.src = new Url(options.src)
);
if (!this.src && options.hasOwnProperty('exec')) { // eslint-disable-line no-prototype-builtins
/**
* @augments {Script.prototype}
* @type {Array<string>}
*/
this.exec = _.isString(options.exec) ? options.exec.split(SCRIPT_NEWLINE_PATTERN) :
_.isArray(options.exec) ? options.exec : undefined;
}
}
|
javascript
|
function (options) {
// no splitting is being done here, as string scripts are split right before assignment below anyway
(_.isString(options) || _.isArray(options)) && (options = { exec: options });
if (!options) { return; } // in case definition object is missing, there is no point moving forward
// create the request property
/**
* @augments {Script.prototype}
* @type {string}
*/
this.type = options.type || 'text/javascript';
options.hasOwnProperty('src') && (
/**
* @augments {Script.prototype}
* @type {Url}
*/
this.src = new Url(options.src)
);
if (!this.src && options.hasOwnProperty('exec')) { // eslint-disable-line no-prototype-builtins
/**
* @augments {Script.prototype}
* @type {Array<string>}
*/
this.exec = _.isString(options.exec) ? options.exec.split(SCRIPT_NEWLINE_PATTERN) :
_.isArray(options.exec) ? options.exec : undefined;
}
}
|
[
"function",
"(",
"options",
")",
"{",
"// no splitting is being done here, as string scripts are split right before assignment below anyway",
"(",
"_",
".",
"isString",
"(",
"options",
")",
"||",
"_",
".",
"isArray",
"(",
"options",
")",
")",
"&&",
"(",
"options",
"=",
"{",
"exec",
":",
"options",
"}",
")",
";",
"if",
"(",
"!",
"options",
")",
"{",
"return",
";",
"}",
"// in case definition object is missing, there is no point moving forward",
"// create the request property",
"/**\n * @augments {Script.prototype}\n * @type {string}\n */",
"this",
".",
"type",
"=",
"options",
".",
"type",
"||",
"'text/javascript'",
";",
"options",
".",
"hasOwnProperty",
"(",
"'src'",
")",
"&&",
"(",
"/**\n * @augments {Script.prototype}\n * @type {Url}\n */",
"this",
".",
"src",
"=",
"new",
"Url",
"(",
"options",
".",
"src",
")",
")",
";",
"if",
"(",
"!",
"this",
".",
"src",
"&&",
"options",
".",
"hasOwnProperty",
"(",
"'exec'",
")",
")",
"{",
"// eslint-disable-line no-prototype-builtins",
"/**\n * @augments {Script.prototype}\n * @type {Array<string>}\n */",
"this",
".",
"exec",
"=",
"_",
".",
"isString",
"(",
"options",
".",
"exec",
")",
"?",
"options",
".",
"exec",
".",
"split",
"(",
"SCRIPT_NEWLINE_PATTERN",
")",
":",
"_",
".",
"isArray",
"(",
"options",
".",
"exec",
")",
"?",
"options",
".",
"exec",
":",
"undefined",
";",
"}",
"}"
] |
Updates the properties of a Script.
@param {Object} [options]
@param {String} [options.type] Script type
@param {String} [options.src] Script source url
@param {String[]|String} [options.exec] Script to execute
|
[
"Updates",
"the",
"properties",
"of",
"a",
"Script",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/script.js#L52-L81
|
|
15,138
|
postmanlabs/postman-collection
|
lib/collection/proxy-config-list.js
|
function (url) {
// url must be either string or an instance of url.
if (!_.isString(url) && !Url.isUrl(url)) {
return;
}
// @todo - use a fixed-length cacheing of regexes in future
return this.find(function (proxyConfig) {
return !proxyConfig.disabled && proxyConfig.test(url);
});
}
|
javascript
|
function (url) {
// url must be either string or an instance of url.
if (!_.isString(url) && !Url.isUrl(url)) {
return;
}
// @todo - use a fixed-length cacheing of regexes in future
return this.find(function (proxyConfig) {
return !proxyConfig.disabled && proxyConfig.test(url);
});
}
|
[
"function",
"(",
"url",
")",
"{",
"// url must be either string or an instance of url.",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"url",
")",
"&&",
"!",
"Url",
".",
"isUrl",
"(",
"url",
")",
")",
"{",
"return",
";",
"}",
"// @todo - use a fixed-length cacheing of regexes in future",
"return",
"this",
".",
"find",
"(",
"function",
"(",
"proxyConfig",
")",
"{",
"return",
"!",
"proxyConfig",
".",
"disabled",
"&&",
"proxyConfig",
".",
"test",
"(",
"url",
")",
";",
"}",
")",
";",
"}"
] |
Matches and gets the proxy config for the particular url.
@returns {ProxyConfig~definition} The matched proxyConfig object
@param {URL=} [url] The url for which the proxy config needs to be fetched
|
[
"Matches",
"and",
"gets",
"the",
"proxy",
"config",
"for",
"the",
"particular",
"url",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/proxy-config-list.js#L37-L48
|
|
15,139
|
postmanlabs/postman-collection
|
lib/collection/proxy-config-list.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof ProxyConfigList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', ProxyConfigList._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof ProxyConfigList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', ProxyConfigList._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"ProxyConfigList",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"ProxyConfigList",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks whether an object is a ProxyConfigList
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"whether",
"an",
"object",
"is",
"a",
"ProxyConfigList"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/proxy-config-list.js#L68-L71
|
|
15,140
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (item, before) {
if (!_.isObject(item)) { return; } // do not proceed on empty param
var duplicate = this.indexOf(item),
index;
// remove from previous list
PropertyList.isPropertyList(item[__PARENT]) && (item[__PARENT] !== this) && item[__PARENT].remove(item);
// inject the parent reference
_.assignHidden(item, __PARENT, this);
// ensure that we do not double insert things into member array
(duplicate > -1) && this.members.splice(duplicate, 1);
// find the position of the reference element
before && (before = this.indexOf(before));
// inject to the members array ata position or at the end in case no item is there for reference
(before > -1) ? this.members.splice(before, 0, item) : this.members.push(item);
// store reference by id, so create the index string. we first ensure that the index value is truthy and then
// recheck that the string conversion of the same is truthy as well.
if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
// desensitise case, if the property needs it to be
this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());
// if multiple values are allowed, the reference may contain an array of items, mapped to an index.
if (this._postman_listAllowsMultipleValues && this.reference.hasOwnProperty(index)) {
// if the value is not an array, convert it to an array.
!_.isArray(this.reference[index]) && (this.reference[index] = [this.reference[index]]);
// add the item to the array of items corresponding to this index
this.reference[index].push(item);
}
else {
this.reference[index] = item;
}
}
}
|
javascript
|
function (item, before) {
if (!_.isObject(item)) { return; } // do not proceed on empty param
var duplicate = this.indexOf(item),
index;
// remove from previous list
PropertyList.isPropertyList(item[__PARENT]) && (item[__PARENT] !== this) && item[__PARENT].remove(item);
// inject the parent reference
_.assignHidden(item, __PARENT, this);
// ensure that we do not double insert things into member array
(duplicate > -1) && this.members.splice(duplicate, 1);
// find the position of the reference element
before && (before = this.indexOf(before));
// inject to the members array ata position or at the end in case no item is there for reference
(before > -1) ? this.members.splice(before, 0, item) : this.members.push(item);
// store reference by id, so create the index string. we first ensure that the index value is truthy and then
// recheck that the string conversion of the same is truthy as well.
if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
// desensitise case, if the property needs it to be
this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());
// if multiple values are allowed, the reference may contain an array of items, mapped to an index.
if (this._postman_listAllowsMultipleValues && this.reference.hasOwnProperty(index)) {
// if the value is not an array, convert it to an array.
!_.isArray(this.reference[index]) && (this.reference[index] = [this.reference[index]]);
// add the item to the array of items corresponding to this index
this.reference[index].push(item);
}
else {
this.reference[index] = item;
}
}
}
|
[
"function",
"(",
"item",
",",
"before",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"item",
")",
")",
"{",
"return",
";",
"}",
"// do not proceed on empty param",
"var",
"duplicate",
"=",
"this",
".",
"indexOf",
"(",
"item",
")",
",",
"index",
";",
"// remove from previous list",
"PropertyList",
".",
"isPropertyList",
"(",
"item",
"[",
"__PARENT",
"]",
")",
"&&",
"(",
"item",
"[",
"__PARENT",
"]",
"!==",
"this",
")",
"&&",
"item",
"[",
"__PARENT",
"]",
".",
"remove",
"(",
"item",
")",
";",
"// inject the parent reference",
"_",
".",
"assignHidden",
"(",
"item",
",",
"__PARENT",
",",
"this",
")",
";",
"// ensure that we do not double insert things into member array",
"(",
"duplicate",
">",
"-",
"1",
")",
"&&",
"this",
".",
"members",
".",
"splice",
"(",
"duplicate",
",",
"1",
")",
";",
"// find the position of the reference element",
"before",
"&&",
"(",
"before",
"=",
"this",
".",
"indexOf",
"(",
"before",
")",
")",
";",
"// inject to the members array ata position or at the end in case no item is there for reference",
"(",
"before",
">",
"-",
"1",
")",
"?",
"this",
".",
"members",
".",
"splice",
"(",
"before",
",",
"0",
",",
"item",
")",
":",
"this",
".",
"members",
".",
"push",
"(",
"item",
")",
";",
"// store reference by id, so create the index string. we first ensure that the index value is truthy and then",
"// recheck that the string conversion of the same is truthy as well.",
"if",
"(",
"(",
"index",
"=",
"item",
"[",
"this",
".",
"_postman_listIndexKey",
"]",
")",
"&&",
"(",
"index",
"=",
"String",
"(",
"index",
")",
")",
")",
"{",
"// desensitise case, if the property needs it to be",
"this",
".",
"_postman_listIndexCaseInsensitive",
"&&",
"(",
"index",
"=",
"index",
".",
"toLowerCase",
"(",
")",
")",
";",
"// if multiple values are allowed, the reference may contain an array of items, mapped to an index.",
"if",
"(",
"this",
".",
"_postman_listAllowsMultipleValues",
"&&",
"this",
".",
"reference",
".",
"hasOwnProperty",
"(",
"index",
")",
")",
"{",
"// if the value is not an array, convert it to an array.",
"!",
"_",
".",
"isArray",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
")",
"&&",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
"=",
"[",
"this",
".",
"reference",
"[",
"index",
"]",
"]",
")",
";",
"// add the item to the array of items corresponding to this index",
"this",
".",
"reference",
"[",
"index",
"]",
".",
"push",
"(",
"item",
")",
";",
"}",
"else",
"{",
"this",
".",
"reference",
"[",
"index",
"]",
"=",
"item",
";",
"}",
"}",
"}"
] |
Insert an element at the end of this list. When a reference member specified via second parameter is found, the
member is inserted at an index before the reference member.
@param {PropertyList.Type} item
@param {PropertyList.Type|String} [before]
|
[
"Insert",
"an",
"element",
"at",
"the",
"end",
"of",
"this",
"list",
".",
"When",
"a",
"reference",
"member",
"specified",
"via",
"second",
"parameter",
"is",
"found",
"the",
"member",
"is",
"inserted",
"at",
"an",
"index",
"before",
"the",
"reference",
"member",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L103-L141
|
|
15,141
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (item) {
// do not proceed on empty param, but empty strings are in fact valid.
// eslint-disable-next-line lodash/prefer-is-nil
if (_.isNull(item) || _.isUndefined(item) || _.isNaN(item)) { return; }
// create new instance of the item based on the type specified if it is not already
this.insert((item.constructor === this.Type) ? item :
// if the property has a create static function, use it.
// eslint-disable-next-line prefer-spread
(_.has(this.Type, 'create') ? this.Type.create.apply(this.Type, arguments) : new this.Type(item)));
}
|
javascript
|
function (item) {
// do not proceed on empty param, but empty strings are in fact valid.
// eslint-disable-next-line lodash/prefer-is-nil
if (_.isNull(item) || _.isUndefined(item) || _.isNaN(item)) { return; }
// create new instance of the item based on the type specified if it is not already
this.insert((item.constructor === this.Type) ? item :
// if the property has a create static function, use it.
// eslint-disable-next-line prefer-spread
(_.has(this.Type, 'create') ? this.Type.create.apply(this.Type, arguments) : new this.Type(item)));
}
|
[
"function",
"(",
"item",
")",
"{",
"// do not proceed on empty param, but empty strings are in fact valid.",
"// eslint-disable-next-line lodash/prefer-is-nil",
"if",
"(",
"_",
".",
"isNull",
"(",
"item",
")",
"||",
"_",
".",
"isUndefined",
"(",
"item",
")",
"||",
"_",
".",
"isNaN",
"(",
"item",
")",
")",
"{",
"return",
";",
"}",
"// create new instance of the item based on the type specified if it is not already",
"this",
".",
"insert",
"(",
"(",
"item",
".",
"constructor",
"===",
"this",
".",
"Type",
")",
"?",
"item",
":",
"// if the property has a create static function, use it.",
"// eslint-disable-next-line prefer-spread",
"(",
"_",
".",
"has",
"(",
"this",
".",
"Type",
",",
"'create'",
")",
"?",
"this",
".",
"Type",
".",
"create",
".",
"apply",
"(",
"this",
".",
"Type",
",",
"arguments",
")",
":",
"new",
"this",
".",
"Type",
"(",
"item",
")",
")",
")",
";",
"}"
] |
Add an item or item definition to this list.
@param {Object|PropertyList.Type} item
@todo
- remove item from original parent if already it has a parent
- validate that the original parent's constructor matches this parent's constructor
|
[
"Add",
"an",
"item",
"or",
"item",
"definition",
"to",
"this",
"list",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L181-L191
|
|
15,142
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (item) {
// do not proceed on empty param, but empty strings are in fact valid.
if (_.isNil(item) || _.isNaN(item)) { return null; }
var indexer = this._postman_listIndexKey,
existing = this.one(item[indexer]);
if (existing) {
if (!_.isFunction(existing.update)) {
throw new Error('collection: unable to upsert into a list of Type that does not support .update()');
}
existing.update(item);
return false;
}
// since there is no existing item, just add a new one
this.add(item);
return true; // indicate added
}
|
javascript
|
function (item) {
// do not proceed on empty param, but empty strings are in fact valid.
if (_.isNil(item) || _.isNaN(item)) { return null; }
var indexer = this._postman_listIndexKey,
existing = this.one(item[indexer]);
if (existing) {
if (!_.isFunction(existing.update)) {
throw new Error('collection: unable to upsert into a list of Type that does not support .update()');
}
existing.update(item);
return false;
}
// since there is no existing item, just add a new one
this.add(item);
return true; // indicate added
}
|
[
"function",
"(",
"item",
")",
"{",
"// do not proceed on empty param, but empty strings are in fact valid.",
"if",
"(",
"_",
".",
"isNil",
"(",
"item",
")",
"||",
"_",
".",
"isNaN",
"(",
"item",
")",
")",
"{",
"return",
"null",
";",
"}",
"var",
"indexer",
"=",
"this",
".",
"_postman_listIndexKey",
",",
"existing",
"=",
"this",
".",
"one",
"(",
"item",
"[",
"indexer",
"]",
")",
";",
"if",
"(",
"existing",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isFunction",
"(",
"existing",
".",
"update",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'collection: unable to upsert into a list of Type that does not support .update()'",
")",
";",
"}",
"existing",
".",
"update",
"(",
"item",
")",
";",
"return",
"false",
";",
"}",
"// since there is no existing item, just add a new one",
"this",
".",
"add",
"(",
"item",
")",
";",
"return",
"true",
";",
"// indicate added",
"}"
] |
Add an item or update an existing item
@param {PropertyList~Type} item
@returns {?Boolean}
|
[
"Add",
"an",
"item",
"or",
"update",
"an",
"existing",
"item"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L200-L218
|
|
15,143
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (predicate, context) {
var match; // to be used if predicate is an ID
!context && (context = this);
if (_.isString(predicate)) {
// if predicate is id, then create a function to remove that
// need to take care of case sensitivity as well :/
match = this._postman_listIndexCaseInsensitive ? predicate.toLowerCase() : predicate;
predicate = function (item) {
var id = item[this._postman_listIndexKey];
this._postman_listIndexCaseInsensitive && (id = id.toLowerCase());
return id === match;
}.bind(this);
}
else if (predicate instanceof this.Type) {
// in case an object reference is sent, prepare it for removal using direct reference comparison
match = predicate;
predicate = function (item) {
return (item === match);
};
}
_.isFunction(predicate) && _.remove(this.members, function (item) {
var index;
if (predicate.apply(context, arguments)) {
if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());
if (this._postman_listAllowsMultipleValues && _.isArray(this.reference[index])) {
// since we have an array of multiple values, remove only the value for which the
// predicate returned truthy. If the array becomes empty, just delete it.
_.remove(this.reference[index], function (each) {
return each === item;
});
// If the array becomes empty, remove it
(this.reference[index].length === 0) && (delete this.reference[index]);
// If the array contains only one element, remove the array, and assign the element
// as the reference value
(this.reference[index].length === 1) && (this.reference[index] = this.reference[index][0]);
}
else {
delete this.reference[index];
}
}
delete item[__PARENT]; // unlink from its parent
return true;
}
}.bind(this));
}
|
javascript
|
function (predicate, context) {
var match; // to be used if predicate is an ID
!context && (context = this);
if (_.isString(predicate)) {
// if predicate is id, then create a function to remove that
// need to take care of case sensitivity as well :/
match = this._postman_listIndexCaseInsensitive ? predicate.toLowerCase() : predicate;
predicate = function (item) {
var id = item[this._postman_listIndexKey];
this._postman_listIndexCaseInsensitive && (id = id.toLowerCase());
return id === match;
}.bind(this);
}
else if (predicate instanceof this.Type) {
// in case an object reference is sent, prepare it for removal using direct reference comparison
match = predicate;
predicate = function (item) {
return (item === match);
};
}
_.isFunction(predicate) && _.remove(this.members, function (item) {
var index;
if (predicate.apply(context, arguments)) {
if ((index = item[this._postman_listIndexKey]) && (index = String(index))) {
this._postman_listIndexCaseInsensitive && (index = index.toLowerCase());
if (this._postman_listAllowsMultipleValues && _.isArray(this.reference[index])) {
// since we have an array of multiple values, remove only the value for which the
// predicate returned truthy. If the array becomes empty, just delete it.
_.remove(this.reference[index], function (each) {
return each === item;
});
// If the array becomes empty, remove it
(this.reference[index].length === 0) && (delete this.reference[index]);
// If the array contains only one element, remove the array, and assign the element
// as the reference value
(this.reference[index].length === 1) && (this.reference[index] = this.reference[index][0]);
}
else {
delete this.reference[index];
}
}
delete item[__PARENT]; // unlink from its parent
return true;
}
}.bind(this));
}
|
[
"function",
"(",
"predicate",
",",
"context",
")",
"{",
"var",
"match",
";",
"// to be used if predicate is an ID",
"!",
"context",
"&&",
"(",
"context",
"=",
"this",
")",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"predicate",
")",
")",
"{",
"// if predicate is id, then create a function to remove that",
"// need to take care of case sensitivity as well :/",
"match",
"=",
"this",
".",
"_postman_listIndexCaseInsensitive",
"?",
"predicate",
".",
"toLowerCase",
"(",
")",
":",
"predicate",
";",
"predicate",
"=",
"function",
"(",
"item",
")",
"{",
"var",
"id",
"=",
"item",
"[",
"this",
".",
"_postman_listIndexKey",
"]",
";",
"this",
".",
"_postman_listIndexCaseInsensitive",
"&&",
"(",
"id",
"=",
"id",
".",
"toLowerCase",
"(",
")",
")",
";",
"return",
"id",
"===",
"match",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"}",
"else",
"if",
"(",
"predicate",
"instanceof",
"this",
".",
"Type",
")",
"{",
"// in case an object reference is sent, prepare it for removal using direct reference comparison",
"match",
"=",
"predicate",
";",
"predicate",
"=",
"function",
"(",
"item",
")",
"{",
"return",
"(",
"item",
"===",
"match",
")",
";",
"}",
";",
"}",
"_",
".",
"isFunction",
"(",
"predicate",
")",
"&&",
"_",
".",
"remove",
"(",
"this",
".",
"members",
",",
"function",
"(",
"item",
")",
"{",
"var",
"index",
";",
"if",
"(",
"predicate",
".",
"apply",
"(",
"context",
",",
"arguments",
")",
")",
"{",
"if",
"(",
"(",
"index",
"=",
"item",
"[",
"this",
".",
"_postman_listIndexKey",
"]",
")",
"&&",
"(",
"index",
"=",
"String",
"(",
"index",
")",
")",
")",
"{",
"this",
".",
"_postman_listIndexCaseInsensitive",
"&&",
"(",
"index",
"=",
"index",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"this",
".",
"_postman_listAllowsMultipleValues",
"&&",
"_",
".",
"isArray",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
")",
")",
"{",
"// since we have an array of multiple values, remove only the value for which the",
"// predicate returned truthy. If the array becomes empty, just delete it.",
"_",
".",
"remove",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
",",
"function",
"(",
"each",
")",
"{",
"return",
"each",
"===",
"item",
";",
"}",
")",
";",
"// If the array becomes empty, remove it",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
".",
"length",
"===",
"0",
")",
"&&",
"(",
"delete",
"this",
".",
"reference",
"[",
"index",
"]",
")",
";",
"// If the array contains only one element, remove the array, and assign the element",
"// as the reference value",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
".",
"length",
"===",
"1",
")",
"&&",
"(",
"this",
".",
"reference",
"[",
"index",
"]",
"=",
"this",
".",
"reference",
"[",
"index",
"]",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"delete",
"this",
".",
"reference",
"[",
"index",
"]",
";",
"}",
"}",
"delete",
"item",
"[",
"__PARENT",
"]",
";",
"// unlink from its parent",
"return",
"true",
";",
"}",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Removes all elements from the PropertyList for which the predicate returns truthy.
@param {Function|String|Type} predicate
@param {Object} context Optional context to bind the predicate to.
|
[
"Removes",
"all",
"elements",
"from",
"the",
"PropertyList",
"for",
"which",
"the",
"predicate",
"returns",
"truthy",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L226-L277
|
|
15,144
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function () {
// we unlink every member from it's parent (assuming this is their parent)
this.all().forEach(PropertyList._unlinkItemFromParent);
this.members.length = 0; // remove all items from list
// now we remove all items from index reference
Object.keys(this.reference).forEach(function (key) {
delete this.reference[key];
}.bind(this));
}
|
javascript
|
function () {
// we unlink every member from it's parent (assuming this is their parent)
this.all().forEach(PropertyList._unlinkItemFromParent);
this.members.length = 0; // remove all items from list
// now we remove all items from index reference
Object.keys(this.reference).forEach(function (key) {
delete this.reference[key];
}.bind(this));
}
|
[
"function",
"(",
")",
"{",
"// we unlink every member from it's parent (assuming this is their parent)",
"this",
".",
"all",
"(",
")",
".",
"forEach",
"(",
"PropertyList",
".",
"_unlinkItemFromParent",
")",
";",
"this",
".",
"members",
".",
"length",
"=",
"0",
";",
"// remove all items from list",
"// now we remove all items from index reference",
"Object",
".",
"keys",
"(",
"this",
".",
"reference",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"delete",
"this",
".",
"reference",
"[",
"key",
"]",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Removes all items in the list
|
[
"Removes",
"all",
"items",
"in",
"the",
"list"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L282-L292
|
|
15,145
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (items) {
// if Type supports parsing of string headers then do it before adding it.
_.isString(items) && _.isFunction(this.Type.parse) && (items = this.Type.parse(items));
// add a single item or an array of items.
_.forEach(_.isArray(items) ? items :
// if population is not an array, we send this as single item in an array or send each property separately
// if the core Type supports Type.create
((_.isPlainObject(items) && _.has(this.Type, 'create')) ? items : [items]), this.add.bind(this));
}
|
javascript
|
function (items) {
// if Type supports parsing of string headers then do it before adding it.
_.isString(items) && _.isFunction(this.Type.parse) && (items = this.Type.parse(items));
// add a single item or an array of items.
_.forEach(_.isArray(items) ? items :
// if population is not an array, we send this as single item in an array or send each property separately
// if the core Type supports Type.create
((_.isPlainObject(items) && _.has(this.Type, 'create')) ? items : [items]), this.add.bind(this));
}
|
[
"function",
"(",
"items",
")",
"{",
"// if Type supports parsing of string headers then do it before adding it.",
"_",
".",
"isString",
"(",
"items",
")",
"&&",
"_",
".",
"isFunction",
"(",
"this",
".",
"Type",
".",
"parse",
")",
"&&",
"(",
"items",
"=",
"this",
".",
"Type",
".",
"parse",
"(",
"items",
")",
")",
";",
"// add a single item or an array of items.",
"_",
".",
"forEach",
"(",
"_",
".",
"isArray",
"(",
"items",
")",
"?",
"items",
":",
"// if population is not an array, we send this as single item in an array or send each property separately",
"// if the core Type supports Type.create",
"(",
"(",
"_",
".",
"isPlainObject",
"(",
"items",
")",
"&&",
"_",
".",
"has",
"(",
"this",
".",
"Type",
",",
"'create'",
")",
")",
"?",
"items",
":",
"[",
"items",
"]",
")",
",",
"this",
".",
"add",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Load one or more items
@param {Object|Array} items
|
[
"Load",
"one",
"or",
"more",
"items"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L299-L307
|
|
15,146
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (source, prune) {
var members = PropertyList.isPropertyList(source) ? source.members : source,
list = this,
indexer = list._postman_listIndexKey,
sourceKeys = {}; // keeps track of added / updated keys for later exclusion
if (!_.isArray(members)) {
return;
}
members.forEach(function (item) {
if (!(item && item.hasOwnProperty(indexer))) { return; }
list.upsert(item);
sourceKeys[item[indexer]] = true;
});
// now remove any variable that is not in source object
// @note - using direct `this.reference` list of keys here so that we can mutate the list while iterating
// on it
if (prune) {
_.forEach(list.reference, function (value, key) {
if (sourceKeys.hasOwnProperty(key)) { return; } // de not delete if source obj has this variable
list.remove(key); // use PropertyList functions to remove so that the .members array is cleared too
});
}
}
|
javascript
|
function (source, prune) {
var members = PropertyList.isPropertyList(source) ? source.members : source,
list = this,
indexer = list._postman_listIndexKey,
sourceKeys = {}; // keeps track of added / updated keys for later exclusion
if (!_.isArray(members)) {
return;
}
members.forEach(function (item) {
if (!(item && item.hasOwnProperty(indexer))) { return; }
list.upsert(item);
sourceKeys[item[indexer]] = true;
});
// now remove any variable that is not in source object
// @note - using direct `this.reference` list of keys here so that we can mutate the list while iterating
// on it
if (prune) {
_.forEach(list.reference, function (value, key) {
if (sourceKeys.hasOwnProperty(key)) { return; } // de not delete if source obj has this variable
list.remove(key); // use PropertyList functions to remove so that the .members array is cleared too
});
}
}
|
[
"function",
"(",
"source",
",",
"prune",
")",
"{",
"var",
"members",
"=",
"PropertyList",
".",
"isPropertyList",
"(",
"source",
")",
"?",
"source",
".",
"members",
":",
"source",
",",
"list",
"=",
"this",
",",
"indexer",
"=",
"list",
".",
"_postman_listIndexKey",
",",
"sourceKeys",
"=",
"{",
"}",
";",
"// keeps track of added / updated keys for later exclusion",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"members",
")",
")",
"{",
"return",
";",
"}",
"members",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"(",
"item",
"&&",
"item",
".",
"hasOwnProperty",
"(",
"indexer",
")",
")",
")",
"{",
"return",
";",
"}",
"list",
".",
"upsert",
"(",
"item",
")",
";",
"sourceKeys",
"[",
"item",
"[",
"indexer",
"]",
"]",
"=",
"true",
";",
"}",
")",
";",
"// now remove any variable that is not in source object",
"// @note - using direct `this.reference` list of keys here so that we can mutate the list while iterating",
"// on it",
"if",
"(",
"prune",
")",
"{",
"_",
".",
"forEach",
"(",
"list",
".",
"reference",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"sourceKeys",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
";",
"}",
"// de not delete if source obj has this variable",
"list",
".",
"remove",
"(",
"key",
")",
";",
"// use PropertyList functions to remove so that the .members array is cleared too",
"}",
")",
";",
"}",
"}"
] |
Add or update values from a source list.
@param {PropertyList|Array} source
@param {Boolean} [prune=false] Setting this to `true` will cause the extra items from the list to be deleted
|
[
"Add",
"or",
"update",
"values",
"from",
"a",
"source",
"list",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L325-L350
|
|
15,147
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (id) {
var val = this.reference[this._postman_listIndexCaseInsensitive ? String(id).toLowerCase() : id];
if (this._postman_listAllowsMultipleValues && Array.isArray(val)) {
return val.length ? val[val.length - 1] : undefined;
}
return val;
}
|
javascript
|
function (id) {
var val = this.reference[this._postman_listIndexCaseInsensitive ? String(id).toLowerCase() : id];
if (this._postman_listAllowsMultipleValues && Array.isArray(val)) {
return val.length ? val[val.length - 1] : undefined;
}
return val;
}
|
[
"function",
"(",
"id",
")",
"{",
"var",
"val",
"=",
"this",
".",
"reference",
"[",
"this",
".",
"_postman_listIndexCaseInsensitive",
"?",
"String",
"(",
"id",
")",
".",
"toLowerCase",
"(",
")",
":",
"id",
"]",
";",
"if",
"(",
"this",
".",
"_postman_listAllowsMultipleValues",
"&&",
"Array",
".",
"isArray",
"(",
"val",
")",
")",
"{",
"return",
"val",
".",
"length",
"?",
"val",
"[",
"val",
".",
"length",
"-",
"1",
"]",
":",
"undefined",
";",
"}",
"return",
"val",
";",
"}"
] |
Get Item in this list by `ID` reference. If multiple values are allowed, the last value is returned.
@param {String} id
@returns {PropertyList.Type}
|
[
"Get",
"Item",
"in",
"this",
"list",
"by",
"ID",
"reference",
".",
"If",
"multiple",
"values",
"are",
"allowed",
"the",
"last",
"value",
"is",
"returned",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L367-L375
|
|
15,148
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (iterator, context) {
_.forEach(this.members, _.isFunction(iterator) ? iterator.bind(context || this.__parent) : iterator);
}
|
javascript
|
function (iterator, context) {
_.forEach(this.members, _.isFunction(iterator) ? iterator.bind(context || this.__parent) : iterator);
}
|
[
"function",
"(",
"iterator",
",",
"context",
")",
"{",
"_",
".",
"forEach",
"(",
"this",
".",
"members",
",",
"_",
".",
"isFunction",
"(",
"iterator",
")",
"?",
"iterator",
".",
"bind",
"(",
"context",
"||",
"this",
".",
"__parent",
")",
":",
"iterator",
")",
";",
"}"
] |
Iterate on each item of this list.
@param {Function} iterator
@param {Object} context
|
[
"Iterate",
"on",
"each",
"item",
"of",
"this",
"list",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L397-L399
|
|
15,149
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (rule, context) {
return _.find(this.members, _.isFunction(rule) && _.isObject(context) ? rule.bind(context) : rule);
}
|
javascript
|
function (rule, context) {
return _.find(this.members, _.isFunction(rule) && _.isObject(context) ? rule.bind(context) : rule);
}
|
[
"function",
"(",
"rule",
",",
"context",
")",
"{",
"return",
"_",
".",
"find",
"(",
"this",
".",
"members",
",",
"_",
".",
"isFunction",
"(",
"rule",
")",
"&&",
"_",
".",
"isObject",
"(",
"context",
")",
"?",
"rule",
".",
"bind",
"(",
"context",
")",
":",
"rule",
")",
";",
"}"
] |
Find an item within the item group
@param {Function} rule
@param {Object} [context]
@returns {Item|ItemGroup}
|
[
"Find",
"an",
"item",
"within",
"the",
"item",
"group"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L416-L418
|
|
15,150
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (iterator, context) {
return _.map(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator);
}
|
javascript
|
function (iterator, context) {
return _.map(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator);
}
|
[
"function",
"(",
"iterator",
",",
"context",
")",
"{",
"return",
"_",
".",
"map",
"(",
"this",
".",
"members",
",",
"_",
".",
"isFunction",
"(",
"iterator",
")",
"?",
"iterator",
".",
"bind",
"(",
"context",
"||",
"this",
")",
":",
"iterator",
")",
";",
"}"
] |
Iterates over the property list.
@param {Function} iterator Function to call on each item.
@param {Object} context Optional context, defaults to the PropertyList itself.
|
[
"Iterates",
"over",
"the",
"property",
"list",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L426-L428
|
|
15,151
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (iterator, accumulator, context) {
return _.reduce(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator, accumulator);
}
|
javascript
|
function (iterator, accumulator, context) {
return _.reduce(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator, accumulator);
}
|
[
"function",
"(",
"iterator",
",",
"accumulator",
",",
"context",
")",
"{",
"return",
"_",
".",
"reduce",
"(",
"this",
".",
"members",
",",
"_",
".",
"isFunction",
"(",
"iterator",
")",
"?",
"iterator",
".",
"bind",
"(",
"context",
"||",
"this",
")",
":",
"iterator",
",",
"accumulator",
")",
";",
"}"
] |
Iterates over the property list and accumulates the result.
@param {Function} iterator Function to call on each item.
@param {*} accumulator Accumulator initial value
@param {Object} context Optional context, defaults to the PropertyList itself.
|
[
"Iterates",
"over",
"the",
"property",
"list",
"and",
"accumulates",
"the",
"result",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L437-L439
|
|
15,152
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (item) {
return this.members.indexOf(_.isString(item) ? (item = this.one(item)) : item);
}
|
javascript
|
function (item) {
return this.members.indexOf(_.isString(item) ? (item = this.one(item)) : item);
}
|
[
"function",
"(",
"item",
")",
"{",
"return",
"this",
".",
"members",
".",
"indexOf",
"(",
"_",
".",
"isString",
"(",
"item",
")",
"?",
"(",
"item",
"=",
"this",
".",
"one",
"(",
"item",
")",
")",
":",
"item",
")",
";",
"}"
] |
Find the index of an item in this list
@param {String|Object} item
@returns {Number}
|
[
"Find",
"the",
"index",
"of",
"an",
"item",
"in",
"this",
"list"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L466-L468
|
|
15,153
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (item, value) {
var match,
val,
i;
match = _.isString(item) ?
this.reference[this._postman_listIndexCaseInsensitive ? item.toLowerCase() : item] :
this.filter(function (member) {
return member === item;
});
// If we don't have a match, there's nothing to do
if (!match) { return false; }
// if no value is provided, just check if item exists
if (arguments.length === 1) {
return Boolean(_.isArray(match) ? match.length : match);
}
// If this property allows multiple values and we get an array, we need to iterate through it and see
// if any element matches.
if (this._postman_listAllowsMultipleValues && _.isArray(match)) {
for (i = 0; i < match.length; i++) {
// use the value of the current element
val = _.isFunction(match[i].valueOf) ? match[i].valueOf() : match[i];
if (val === value) { return true; }
}
// no matches were found, so return false here.
return false;
}
// We didn't have an array, so just check if the matched value equals the provided value.
_.isFunction(match.valueOf) && (match = match.valueOf());
return match === value;
}
|
javascript
|
function (item, value) {
var match,
val,
i;
match = _.isString(item) ?
this.reference[this._postman_listIndexCaseInsensitive ? item.toLowerCase() : item] :
this.filter(function (member) {
return member === item;
});
// If we don't have a match, there's nothing to do
if (!match) { return false; }
// if no value is provided, just check if item exists
if (arguments.length === 1) {
return Boolean(_.isArray(match) ? match.length : match);
}
// If this property allows multiple values and we get an array, we need to iterate through it and see
// if any element matches.
if (this._postman_listAllowsMultipleValues && _.isArray(match)) {
for (i = 0; i < match.length; i++) {
// use the value of the current element
val = _.isFunction(match[i].valueOf) ? match[i].valueOf() : match[i];
if (val === value) { return true; }
}
// no matches were found, so return false here.
return false;
}
// We didn't have an array, so just check if the matched value equals the provided value.
_.isFunction(match.valueOf) && (match = match.valueOf());
return match === value;
}
|
[
"function",
"(",
"item",
",",
"value",
")",
"{",
"var",
"match",
",",
"val",
",",
"i",
";",
"match",
"=",
"_",
".",
"isString",
"(",
"item",
")",
"?",
"this",
".",
"reference",
"[",
"this",
".",
"_postman_listIndexCaseInsensitive",
"?",
"item",
".",
"toLowerCase",
"(",
")",
":",
"item",
"]",
":",
"this",
".",
"filter",
"(",
"function",
"(",
"member",
")",
"{",
"return",
"member",
"===",
"item",
";",
"}",
")",
";",
"// If we don't have a match, there's nothing to do",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"false",
";",
"}",
"// if no value is provided, just check if item exists",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"return",
"Boolean",
"(",
"_",
".",
"isArray",
"(",
"match",
")",
"?",
"match",
".",
"length",
":",
"match",
")",
";",
"}",
"// If this property allows multiple values and we get an array, we need to iterate through it and see",
"// if any element matches.",
"if",
"(",
"this",
".",
"_postman_listAllowsMultipleValues",
"&&",
"_",
".",
"isArray",
"(",
"match",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"match",
".",
"length",
";",
"i",
"++",
")",
"{",
"// use the value of the current element",
"val",
"=",
"_",
".",
"isFunction",
"(",
"match",
"[",
"i",
"]",
".",
"valueOf",
")",
"?",
"match",
"[",
"i",
"]",
".",
"valueOf",
"(",
")",
":",
"match",
"[",
"i",
"]",
";",
"if",
"(",
"val",
"===",
"value",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// no matches were found, so return false here.",
"return",
"false",
";",
"}",
"// We didn't have an array, so just check if the matched value equals the provided value.",
"_",
".",
"isFunction",
"(",
"match",
".",
"valueOf",
")",
"&&",
"(",
"match",
"=",
"match",
".",
"valueOf",
"(",
")",
")",
";",
"return",
"match",
"===",
"value",
";",
"}"
] |
Check whether an item exists in this list
@param {String|PropertyList.Type} item
@param {*=} value
@returns {Boolean}
|
[
"Check",
"whether",
"an",
"item",
"exists",
"in",
"this",
"list"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L477-L515
|
|
15,154
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (iterator, context) {
// validate parameters
if (!_.isFunction(iterator)) { return; }
!context && (context = this);
var parent = this.__parent,
prev;
// iterate till there is no parent
while (parent) {
// call iterator with the parent and previous parent
iterator.call(context, parent, prev);
// update references
prev = parent;
parent = parent.__parent;
}
}
|
javascript
|
function (iterator, context) {
// validate parameters
if (!_.isFunction(iterator)) { return; }
!context && (context = this);
var parent = this.__parent,
prev;
// iterate till there is no parent
while (parent) {
// call iterator with the parent and previous parent
iterator.call(context, parent, prev);
// update references
prev = parent;
parent = parent.__parent;
}
}
|
[
"function",
"(",
"iterator",
",",
"context",
")",
"{",
"// validate parameters",
"if",
"(",
"!",
"_",
".",
"isFunction",
"(",
"iterator",
")",
")",
"{",
"return",
";",
"}",
"!",
"context",
"&&",
"(",
"context",
"=",
"this",
")",
";",
"var",
"parent",
"=",
"this",
".",
"__parent",
",",
"prev",
";",
"// iterate till there is no parent",
"while",
"(",
"parent",
")",
"{",
"// call iterator with the parent and previous parent",
"iterator",
".",
"call",
"(",
"context",
",",
"parent",
",",
"prev",
")",
";",
"// update references",
"prev",
"=",
"parent",
";",
"parent",
"=",
"parent",
".",
"__parent",
";",
"}",
"}"
] |
Iterates over all parents of the property list
@param {Function} iterator
@param {Object=} [context]
|
[
"Iterates",
"over",
"all",
"parents",
"of",
"the",
"property",
"list"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L523-L540
|
|
15,155
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (excludeDisabled, caseSensitive, multiValue, sanitizeKeys) {
var obj = {}, // create transformation data accumulator
// gather all the switches of the list
key = this._postman_listIndexKey,
sanitiseKeys = this._postman_sanitizeKeys || sanitizeKeys,
sensitive = !this._postman_listIndexCaseInsensitive || caseSensitive,
multivalue = this._postman_listAllowsMultipleValues || multiValue;
// iterate on each member to create the transformation object
this.each(function (member) {
// Bail out for the current member if ANY of the conditions below is true:
// 1. The member is falsy.
// 2. The member does not have the specified property list index key.
// 3. The member is disabled and disabled properties have to be ignored.
// 4. The member has a falsy key, and sanitize is true.
if (!member || !member.hasOwnProperty(key) || (excludeDisabled && member.disabled) ||
(sanitiseKeys && !member[key])) {
return;
}
// based on case sensitivity settings, we get the property name of the item
var prop = sensitive ? member[key] : String(member[key]).toLowerCase();
// now, if transformation object already has a member with same property name, we either overwrite it or
// append to an array of values based on multi-value support
if (multivalue && obj.hasOwnProperty(prop)) {
(!Array.isArray(obj[prop])) && (obj[prop] = [obj[prop]]);
obj[prop].push(member.valueOf());
}
else {
obj[prop] = member.valueOf();
}
});
return obj;
}
|
javascript
|
function (excludeDisabled, caseSensitive, multiValue, sanitizeKeys) {
var obj = {}, // create transformation data accumulator
// gather all the switches of the list
key = this._postman_listIndexKey,
sanitiseKeys = this._postman_sanitizeKeys || sanitizeKeys,
sensitive = !this._postman_listIndexCaseInsensitive || caseSensitive,
multivalue = this._postman_listAllowsMultipleValues || multiValue;
// iterate on each member to create the transformation object
this.each(function (member) {
// Bail out for the current member if ANY of the conditions below is true:
// 1. The member is falsy.
// 2. The member does not have the specified property list index key.
// 3. The member is disabled and disabled properties have to be ignored.
// 4. The member has a falsy key, and sanitize is true.
if (!member || !member.hasOwnProperty(key) || (excludeDisabled && member.disabled) ||
(sanitiseKeys && !member[key])) {
return;
}
// based on case sensitivity settings, we get the property name of the item
var prop = sensitive ? member[key] : String(member[key]).toLowerCase();
// now, if transformation object already has a member with same property name, we either overwrite it or
// append to an array of values based on multi-value support
if (multivalue && obj.hasOwnProperty(prop)) {
(!Array.isArray(obj[prop])) && (obj[prop] = [obj[prop]]);
obj[prop].push(member.valueOf());
}
else {
obj[prop] = member.valueOf();
}
});
return obj;
}
|
[
"function",
"(",
"excludeDisabled",
",",
"caseSensitive",
",",
"multiValue",
",",
"sanitizeKeys",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
",",
"// create transformation data accumulator",
"// gather all the switches of the list",
"key",
"=",
"this",
".",
"_postman_listIndexKey",
",",
"sanitiseKeys",
"=",
"this",
".",
"_postman_sanitizeKeys",
"||",
"sanitizeKeys",
",",
"sensitive",
"=",
"!",
"this",
".",
"_postman_listIndexCaseInsensitive",
"||",
"caseSensitive",
",",
"multivalue",
"=",
"this",
".",
"_postman_listAllowsMultipleValues",
"||",
"multiValue",
";",
"// iterate on each member to create the transformation object",
"this",
".",
"each",
"(",
"function",
"(",
"member",
")",
"{",
"// Bail out for the current member if ANY of the conditions below is true:",
"// 1. The member is falsy.",
"// 2. The member does not have the specified property list index key.",
"// 3. The member is disabled and disabled properties have to be ignored.",
"// 4. The member has a falsy key, and sanitize is true.",
"if",
"(",
"!",
"member",
"||",
"!",
"member",
".",
"hasOwnProperty",
"(",
"key",
")",
"||",
"(",
"excludeDisabled",
"&&",
"member",
".",
"disabled",
")",
"||",
"(",
"sanitiseKeys",
"&&",
"!",
"member",
"[",
"key",
"]",
")",
")",
"{",
"return",
";",
"}",
"// based on case sensitivity settings, we get the property name of the item",
"var",
"prop",
"=",
"sensitive",
"?",
"member",
"[",
"key",
"]",
":",
"String",
"(",
"member",
"[",
"key",
"]",
")",
".",
"toLowerCase",
"(",
")",
";",
"// now, if transformation object already has a member with same property name, we either overwrite it or",
"// append to an array of values based on multi-value support",
"if",
"(",
"multivalue",
"&&",
"obj",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"(",
"!",
"Array",
".",
"isArray",
"(",
"obj",
"[",
"prop",
"]",
")",
")",
"&&",
"(",
"obj",
"[",
"prop",
"]",
"=",
"[",
"obj",
"[",
"prop",
"]",
"]",
")",
";",
"obj",
"[",
"prop",
"]",
".",
"push",
"(",
"member",
".",
"valueOf",
"(",
")",
")",
";",
"}",
"else",
"{",
"obj",
"[",
"prop",
"]",
"=",
"member",
".",
"valueOf",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"obj",
";",
"}"
] |
Converts a list of Properties into an object where key is `_postman_propertyIndexKey` and value is determined
by the `valueOf` function
@param {?Boolean} [excludeDisabled=false] - When set to true, disabled properties are excluded from the resultant
object.
@param {?Boolean} [caseSensitive] - When set to true, properties are treated strictly as per their original
case. The default value for this property also depends on the case insensitivity definition of the current
property.
@param {?Boolean} [multiValue=false] - When set to true, only the first value of a multi valued property is
returned.
@param {Boolean} [sanitizeKeys=false] - When set to true, properties with falsy keys are removed.
@todo Change the function signature to an object of options instead of the current structure.
@return {Object}
|
[
"Converts",
"a",
"list",
"of",
"Properties",
"into",
"an",
"object",
"where",
"key",
"is",
"_postman_propertyIndexKey",
"and",
"value",
"is",
"determined",
"by",
"the",
"valueOf",
"function"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L557-L593
|
|
15,156
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function () {
if (this.Type.unparse) {
return this.Type.unparse(this.members);
}
return this.constructor ? this.constructor.prototype.toString.call(this) : '';
}
|
javascript
|
function () {
if (this.Type.unparse) {
return this.Type.unparse(this.members);
}
return this.constructor ? this.constructor.prototype.toString.call(this) : '';
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"Type",
".",
"unparse",
")",
"{",
"return",
"this",
".",
"Type",
".",
"unparse",
"(",
"this",
".",
"members",
")",
";",
"}",
"return",
"this",
".",
"constructor",
"?",
"this",
".",
"constructor",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"this",
")",
":",
"''",
";",
"}"
] |
Adds ability to convert a list to a string provided it's underlying format has unparse function defined.
@return {String}
|
[
"Adds",
"ability",
"to",
"convert",
"a",
"list",
"to",
"a",
"string",
"provided",
"it",
"s",
"underlying",
"format",
"has",
"unparse",
"function",
"defined",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L600-L606
|
|
15,157
|
postmanlabs/postman-collection
|
lib/collection/property-list.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof PropertyList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', PropertyList._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof PropertyList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', PropertyList._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"PropertyList",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"PropertyList",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks whether an object is a PropertyList
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"whether",
"an",
"object",
"is",
"a",
"PropertyList"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/property-list.js#L676-L679
|
|
15,158
|
postmanlabs/postman-collection
|
lib/collection/request-auth.js
|
function (options, type) {
// update must have options
if (!_.isObject(options)) { return; }
// validate type parameter and/or choose default from existing type.
if (!RequestAuth.isValidType(type)) { type = this.type; }
var parameters = this[type];
// in case the type holder is not created, we create one and send the population variables
if (!VariableList.isVariableList(parameters)) {
// @todo optimise the handling of legacy object type auth parameters
parameters = this[type] = new VariableList(this);
parameters._postman_requestAuthType = type;
}
// we simply assimilate the new options either it is an array or an object
if (_.isArray(options) || VariableList.isVariableList(options)) {
parameters.assimilate(options);
}
else {
parameters.syncFromObject(options, false, false); // params: no need to track and no need to prune
}
}
|
javascript
|
function (options, type) {
// update must have options
if (!_.isObject(options)) { return; }
// validate type parameter and/or choose default from existing type.
if (!RequestAuth.isValidType(type)) { type = this.type; }
var parameters = this[type];
// in case the type holder is not created, we create one and send the population variables
if (!VariableList.isVariableList(parameters)) {
// @todo optimise the handling of legacy object type auth parameters
parameters = this[type] = new VariableList(this);
parameters._postman_requestAuthType = type;
}
// we simply assimilate the new options either it is an array or an object
if (_.isArray(options) || VariableList.isVariableList(options)) {
parameters.assimilate(options);
}
else {
parameters.syncFromObject(options, false, false); // params: no need to track and no need to prune
}
}
|
[
"function",
"(",
"options",
",",
"type",
")",
"{",
"// update must have options",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"return",
";",
"}",
"// validate type parameter and/or choose default from existing type.",
"if",
"(",
"!",
"RequestAuth",
".",
"isValidType",
"(",
"type",
")",
")",
"{",
"type",
"=",
"this",
".",
"type",
";",
"}",
"var",
"parameters",
"=",
"this",
"[",
"type",
"]",
";",
"// in case the type holder is not created, we create one and send the population variables",
"if",
"(",
"!",
"VariableList",
".",
"isVariableList",
"(",
"parameters",
")",
")",
"{",
"// @todo optimise the handling of legacy object type auth parameters",
"parameters",
"=",
"this",
"[",
"type",
"]",
"=",
"new",
"VariableList",
"(",
"this",
")",
";",
"parameters",
".",
"_postman_requestAuthType",
"=",
"type",
";",
"}",
"// we simply assimilate the new options either it is an array or an object",
"if",
"(",
"_",
".",
"isArray",
"(",
"options",
")",
"||",
"VariableList",
".",
"isVariableList",
"(",
"options",
")",
")",
"{",
"parameters",
".",
"assimilate",
"(",
"options",
")",
";",
"}",
"else",
"{",
"parameters",
".",
"syncFromObject",
"(",
"options",
",",
"false",
",",
"false",
")",
";",
"// params: no need to track and no need to prune",
"}",
"}"
] |
Update the parameters of a specific authentication type. If none is provided then it uses the one marked as to be
used.
@param {VariableList|Array|Object} options
@param {String=} [type=this.type]
|
[
"Update",
"the",
"parameters",
"of",
"a",
"specific",
"authentication",
"type",
".",
"If",
"none",
"is",
"provided",
"then",
"it",
"uses",
"the",
"one",
"marked",
"as",
"to",
"be",
"used",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request-auth.js#L74-L96
|
|
15,159
|
postmanlabs/postman-collection
|
lib/collection/request-auth.js
|
function (type) {
if (!(RequestAuth.isValidType(type) && VariableList.isVariableList(this[type]))) {
return;
}
// clear the variable list
this[type].clear();
// if it is not a currently selected auth type, do not delete the variable list, but simply delete it
if (type !== this.type) {
delete this[type];
}
}
|
javascript
|
function (type) {
if (!(RequestAuth.isValidType(type) && VariableList.isVariableList(this[type]))) {
return;
}
// clear the variable list
this[type].clear();
// if it is not a currently selected auth type, do not delete the variable list, but simply delete it
if (type !== this.type) {
delete this[type];
}
}
|
[
"function",
"(",
"type",
")",
"{",
"if",
"(",
"!",
"(",
"RequestAuth",
".",
"isValidType",
"(",
"type",
")",
"&&",
"VariableList",
".",
"isVariableList",
"(",
"this",
"[",
"type",
"]",
")",
")",
")",
"{",
"return",
";",
"}",
"// clear the variable list",
"this",
"[",
"type",
"]",
".",
"clear",
"(",
")",
";",
"// if it is not a currently selected auth type, do not delete the variable list, but simply delete it",
"if",
"(",
"type",
"!==",
"this",
".",
"type",
")",
"{",
"delete",
"this",
"[",
"type",
"]",
";",
"}",
"}"
] |
Clears the definition of an auth type.
@param {String} type
|
[
"Clears",
"the",
"definition",
"of",
"an",
"auth",
"type",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request-auth.js#L149-L161
|
|
15,160
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (url) {
!url && (url = E);
var parsedUrl = _.isString(url) ? Url.parse(url) : url,
auth = parsedUrl.auth,
protocol = parsedUrl.protocol,
port = parsedUrl.port,
path = parsedUrl.path,
hash = parsedUrl.hash,
host = parsedUrl.host,
query = parsedUrl.query,
variable = parsedUrl.variable;
// convert object based query string to array
// @todo: create a key value parser
if (query) {
if (_.isString(query)) {
query = QueryParam.parse(query);
}
if (!_.isArray(query) && _.keys(query).length) {
query = _.map(_.keys(query), function (key) {
return {
key: key,
value: query[key]
};
});
}
}
// backward compatibility with path variables being storing thins with `id`
if (_.isArray(variable)) {
variable = _.map(variable, function (v) {
_.isObject(v) && (v.key = v.key || v.id); // @todo Remove once path variables are deprecated
return v;
});
}
// expand string path name
if (_.isString(path)) {
path && (path = path.replace(regexes.trimPath, MATCH_1)); // remove leading slash for valid path
// if path is blank string, we set it to undefined, if '/' then single blank string array
path = path ? (path === PATH_SEPARATOR ? [E] : path.split(PATH_SEPARATOR)) : undefined;
}
// expand host string
_.isString(host) && (host = host.split(regexes.splitDomain));
_.assign(this, /** @lends Url.prototype */ {
/**
* @type {String}
*/
auth: auth,
/**
* @type {String}
*/
protocol: protocol,
/**
* @type {String}
*/
port: port || undefined,
/**
* @type {Array<String>}
*/
path: path,
/**
* @type {String}
*/
hash: hash || undefined,
/**
* @type {Array<String>}
*/
host: host,
/**
* @type {PropertyList<QueryParam>}
*/
query: new PropertyList(QueryParam, this, query || []),
/**
* @type {VariableList}
*/
variables: new VariableList(this, variable || [])
});
}
|
javascript
|
function (url) {
!url && (url = E);
var parsedUrl = _.isString(url) ? Url.parse(url) : url,
auth = parsedUrl.auth,
protocol = parsedUrl.protocol,
port = parsedUrl.port,
path = parsedUrl.path,
hash = parsedUrl.hash,
host = parsedUrl.host,
query = parsedUrl.query,
variable = parsedUrl.variable;
// convert object based query string to array
// @todo: create a key value parser
if (query) {
if (_.isString(query)) {
query = QueryParam.parse(query);
}
if (!_.isArray(query) && _.keys(query).length) {
query = _.map(_.keys(query), function (key) {
return {
key: key,
value: query[key]
};
});
}
}
// backward compatibility with path variables being storing thins with `id`
if (_.isArray(variable)) {
variable = _.map(variable, function (v) {
_.isObject(v) && (v.key = v.key || v.id); // @todo Remove once path variables are deprecated
return v;
});
}
// expand string path name
if (_.isString(path)) {
path && (path = path.replace(regexes.trimPath, MATCH_1)); // remove leading slash for valid path
// if path is blank string, we set it to undefined, if '/' then single blank string array
path = path ? (path === PATH_SEPARATOR ? [E] : path.split(PATH_SEPARATOR)) : undefined;
}
// expand host string
_.isString(host) && (host = host.split(regexes.splitDomain));
_.assign(this, /** @lends Url.prototype */ {
/**
* @type {String}
*/
auth: auth,
/**
* @type {String}
*/
protocol: protocol,
/**
* @type {String}
*/
port: port || undefined,
/**
* @type {Array<String>}
*/
path: path,
/**
* @type {String}
*/
hash: hash || undefined,
/**
* @type {Array<String>}
*/
host: host,
/**
* @type {PropertyList<QueryParam>}
*/
query: new PropertyList(QueryParam, this, query || []),
/**
* @type {VariableList}
*/
variables: new VariableList(this, variable || [])
});
}
|
[
"function",
"(",
"url",
")",
"{",
"!",
"url",
"&&",
"(",
"url",
"=",
"E",
")",
";",
"var",
"parsedUrl",
"=",
"_",
".",
"isString",
"(",
"url",
")",
"?",
"Url",
".",
"parse",
"(",
"url",
")",
":",
"url",
",",
"auth",
"=",
"parsedUrl",
".",
"auth",
",",
"protocol",
"=",
"parsedUrl",
".",
"protocol",
",",
"port",
"=",
"parsedUrl",
".",
"port",
",",
"path",
"=",
"parsedUrl",
".",
"path",
",",
"hash",
"=",
"parsedUrl",
".",
"hash",
",",
"host",
"=",
"parsedUrl",
".",
"host",
",",
"query",
"=",
"parsedUrl",
".",
"query",
",",
"variable",
"=",
"parsedUrl",
".",
"variable",
";",
"// convert object based query string to array",
"// @todo: create a key value parser",
"if",
"(",
"query",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"query",
")",
")",
"{",
"query",
"=",
"QueryParam",
".",
"parse",
"(",
"query",
")",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"query",
")",
"&&",
"_",
".",
"keys",
"(",
"query",
")",
".",
"length",
")",
"{",
"query",
"=",
"_",
".",
"map",
"(",
"_",
".",
"keys",
"(",
"query",
")",
",",
"function",
"(",
"key",
")",
"{",
"return",
"{",
"key",
":",
"key",
",",
"value",
":",
"query",
"[",
"key",
"]",
"}",
";",
"}",
")",
";",
"}",
"}",
"// backward compatibility with path variables being storing thins with `id`",
"if",
"(",
"_",
".",
"isArray",
"(",
"variable",
")",
")",
"{",
"variable",
"=",
"_",
".",
"map",
"(",
"variable",
",",
"function",
"(",
"v",
")",
"{",
"_",
".",
"isObject",
"(",
"v",
")",
"&&",
"(",
"v",
".",
"key",
"=",
"v",
".",
"key",
"||",
"v",
".",
"id",
")",
";",
"// @todo Remove once path variables are deprecated",
"return",
"v",
";",
"}",
")",
";",
"}",
"// expand string path name",
"if",
"(",
"_",
".",
"isString",
"(",
"path",
")",
")",
"{",
"path",
"&&",
"(",
"path",
"=",
"path",
".",
"replace",
"(",
"regexes",
".",
"trimPath",
",",
"MATCH_1",
")",
")",
";",
"// remove leading slash for valid path",
"// if path is blank string, we set it to undefined, if '/' then single blank string array",
"path",
"=",
"path",
"?",
"(",
"path",
"===",
"PATH_SEPARATOR",
"?",
"[",
"E",
"]",
":",
"path",
".",
"split",
"(",
"PATH_SEPARATOR",
")",
")",
":",
"undefined",
";",
"}",
"// expand host string",
"_",
".",
"isString",
"(",
"host",
")",
"&&",
"(",
"host",
"=",
"host",
".",
"split",
"(",
"regexes",
".",
"splitDomain",
")",
")",
";",
"_",
".",
"assign",
"(",
"this",
",",
"/** @lends Url.prototype */",
"{",
"/**\n * @type {String}\n */",
"auth",
":",
"auth",
",",
"/**\n * @type {String}\n */",
"protocol",
":",
"protocol",
",",
"/**\n * @type {String}\n */",
"port",
":",
"port",
"||",
"undefined",
",",
"/**\n * @type {Array<String>}\n */",
"path",
":",
"path",
",",
"/**\n * @type {String}\n */",
"hash",
":",
"hash",
"||",
"undefined",
",",
"/**\n * @type {Array<String>}\n */",
"host",
":",
"host",
",",
"/**\n * @type {PropertyList<QueryParam>}\n */",
"query",
":",
"new",
"PropertyList",
"(",
"QueryParam",
",",
"this",
",",
"query",
"||",
"[",
"]",
")",
",",
"/**\n * @type {VariableList}\n */",
"variables",
":",
"new",
"VariableList",
"(",
"this",
",",
"variable",
"||",
"[",
"]",
")",
"}",
")",
";",
"}"
] |
Set a URL.
@draft
@param {String|Object} url
|
[
"Set",
"a",
"URL",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L68-L156
|
|
15,161
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (params) {
params = _.isString(params) ? QueryParam.parse(params) : params;
this.query.populate(params);
}
|
javascript
|
function (params) {
params = _.isString(params) ? QueryParam.parse(params) : params;
this.query.populate(params);
}
|
[
"function",
"(",
"params",
")",
"{",
"params",
"=",
"_",
".",
"isString",
"(",
"params",
")",
"?",
"QueryParam",
".",
"parse",
"(",
"params",
")",
":",
"params",
";",
"this",
".",
"query",
".",
"populate",
"(",
"params",
")",
";",
"}"
] |
Add query parameters to the URL.
@param {Object|String} params Key value pairs to add to the URL.
|
[
"Add",
"query",
"parameters",
"to",
"the",
"URL",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L163-L166
|
|
15,162
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (params) {
params = _.isArray(params) ? _.map(params, function (param) {
return param.key ? param.key : param;
}) : [params];
this.query.remove(function (param) {
return _.includes(params, param.key);
});
}
|
javascript
|
function (params) {
params = _.isArray(params) ? _.map(params, function (param) {
return param.key ? param.key : param;
}) : [params];
this.query.remove(function (param) {
return _.includes(params, param.key);
});
}
|
[
"function",
"(",
"params",
")",
"{",
"params",
"=",
"_",
".",
"isArray",
"(",
"params",
")",
"?",
"_",
".",
"map",
"(",
"params",
",",
"function",
"(",
"param",
")",
"{",
"return",
"param",
".",
"key",
"?",
"param",
".",
"key",
":",
"param",
";",
"}",
")",
":",
"[",
"params",
"]",
";",
"this",
".",
"query",
".",
"remove",
"(",
"function",
"(",
"param",
")",
"{",
"return",
"_",
".",
"includes",
"(",
"params",
",",
"param",
".",
"key",
")",
";",
"}",
")",
";",
"}"
] |
Removes query parameters from the URL.
@param {Array<QueryParam>|Array<String>|String} params Params should be an array of strings, or an array of
actual query parameters, or a string containing the parameter key.
@note Input should *not* be a query string.
|
[
"Removes",
"query",
"parameters",
"from",
"the",
"URL",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L175-L182
|
|
15,163
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (encode) {
if (!this.query.count()) {
return E;
}
if (typeof encode === OBJECT) { // @todo discontinue in v4
return QueryParam.unparse(this.query.all(), encode);
}
return QueryParam.unparse(this.query.all(), { encode: encode });
}
|
javascript
|
function (encode) {
if (!this.query.count()) {
return E;
}
if (typeof encode === OBJECT) { // @todo discontinue in v4
return QueryParam.unparse(this.query.all(), encode);
}
return QueryParam.unparse(this.query.all(), { encode: encode });
}
|
[
"function",
"(",
"encode",
")",
"{",
"if",
"(",
"!",
"this",
".",
"query",
".",
"count",
"(",
")",
")",
"{",
"return",
"E",
";",
"}",
"if",
"(",
"typeof",
"encode",
"===",
"OBJECT",
")",
"{",
"// @todo discontinue in v4",
"return",
"QueryParam",
".",
"unparse",
"(",
"this",
".",
"query",
".",
"all",
"(",
")",
",",
"encode",
")",
";",
"}",
"return",
"QueryParam",
".",
"unparse",
"(",
"this",
".",
"query",
".",
"all",
"(",
")",
",",
"{",
"encode",
":",
"encode",
"}",
")",
";",
"}"
] |
Returns the stringified query string for this URL.
@param {?Boolean} [encode=false] - Enables URL encoding when processing the query string
@returns {String}
@deprecated since v3.4.6, drop support for `encode`
@note Deprecated variant of this function is as follows:
- param {?Object} [options={}]
- param {?Boolean} options.encode - Enables URL encoding when processing the query string.
- param {?Boolean} options.ignoreDisabled - Prevents disabled query parameters from showing up in the unparsed
|
[
"Returns",
"the",
"stringified",
"query",
"string",
"for",
"this",
"URL",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L290-L300
|
|
15,164
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (encodeQuery) {
var path = this.getPath();
// check count first so that, we can ensure that ba `?` is always appended, even if a blank query string exists
if (this.query.count()) {
path += (QUERY_SEPARATOR + this.getQueryString(encodeQuery));
}
return path;
}
|
javascript
|
function (encodeQuery) {
var path = this.getPath();
// check count first so that, we can ensure that ba `?` is always appended, even if a blank query string exists
if (this.query.count()) {
path += (QUERY_SEPARATOR + this.getQueryString(encodeQuery));
}
return path;
}
|
[
"function",
"(",
"encodeQuery",
")",
"{",
"var",
"path",
"=",
"this",
".",
"getPath",
"(",
")",
";",
"// check count first so that, we can ensure that ba `?` is always appended, even if a blank query string exists",
"if",
"(",
"this",
".",
"query",
".",
"count",
"(",
")",
")",
"{",
"path",
"+=",
"(",
"QUERY_SEPARATOR",
"+",
"this",
".",
"getQueryString",
"(",
"encodeQuery",
")",
")",
";",
"}",
"return",
"path",
";",
"}"
] |
Returns the complete path, including the query string.
@param {?Boolean} [encodeQuery=false] - when set to `true` the query string part will be URL encoded
@returns {*|string}
@example /something/postman?hi=notbye
@deprecated since v3.4.6, drop support for `encodeQuery`
|
[
"Returns",
"the",
"complete",
"path",
"including",
"the",
"query",
"string",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L312-L321
|
|
15,165
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function () {
if (!this.host) {
return E;
}
return _.isArray(this.host) ? this.host.join(DOMAIN_SEPARATOR) : this.host.toString();
}
|
javascript
|
function () {
if (!this.host) {
return E;
}
return _.isArray(this.host) ? this.host.join(DOMAIN_SEPARATOR) : this.host.toString();
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"host",
")",
"{",
"return",
"E",
";",
"}",
"return",
"_",
".",
"isArray",
"(",
"this",
".",
"host",
")",
"?",
"this",
".",
"host",
".",
"join",
"(",
"DOMAIN_SEPARATOR",
")",
":",
"this",
".",
"host",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns the host part of the URL
@returns {string}
|
[
"Returns",
"the",
"host",
"part",
"of",
"the",
"URL"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L328-L334
|
|
15,166
|
postmanlabs/postman-collection
|
lib/collection/url.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof Url) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Url._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof Url) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Url._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"Url",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"Url",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Checks whether an object is a Url
@param {*} obj
@returns {Boolean}
|
[
"Checks",
"whether",
"an",
"object",
"is",
"a",
"Url"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/url.js#L474-L477
|
|
15,167
|
postmanlabs/postman-collection
|
lib/collection/query-param.js
|
function (param) {
_.assign(this, /** @lends QueryParam.prototype */ _.isString(param) ? QueryParam.parseSingle(param) : {
key: _.get(param, 'key'), // we do not replace falsey with blank string since null has a meaning
value: _.get(param, 'value')
});
_.has(param, 'system') && (this.system = param.system);
}
|
javascript
|
function (param) {
_.assign(this, /** @lends QueryParam.prototype */ _.isString(param) ? QueryParam.parseSingle(param) : {
key: _.get(param, 'key'), // we do not replace falsey with blank string since null has a meaning
value: _.get(param, 'value')
});
_.has(param, 'system') && (this.system = param.system);
}
|
[
"function",
"(",
"param",
")",
"{",
"_",
".",
"assign",
"(",
"this",
",",
"/** @lends QueryParam.prototype */",
"_",
".",
"isString",
"(",
"param",
")",
"?",
"QueryParam",
".",
"parseSingle",
"(",
"param",
")",
":",
"{",
"key",
":",
"_",
".",
"get",
"(",
"param",
",",
"'key'",
")",
",",
"// we do not replace falsey with blank string since null has a meaning",
"value",
":",
"_",
".",
"get",
"(",
"param",
",",
"'value'",
")",
"}",
")",
";",
"_",
".",
"has",
"(",
"param",
",",
"'system'",
")",
"&&",
"(",
"this",
".",
"system",
"=",
"param",
".",
"system",
")",
";",
"}"
] |
Updates the key and value of the query parameter
@param {String|Object} param
@param {String} param.key
@param {String=} [param.value]
|
[
"Updates",
"the",
"key",
"and",
"value",
"of",
"the",
"query",
"parameter"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/query-param.js#L59-L65
|
|
15,168
|
postmanlabs/postman-collection
|
lib/collection/query-param.js
|
function (query) {
return _.isString(query) ? query.split(AMPERSAND).map(QueryParam.parseSingle) : [];
}
|
javascript
|
function (query) {
return _.isString(query) ? query.split(AMPERSAND).map(QueryParam.parseSingle) : [];
}
|
[
"function",
"(",
"query",
")",
"{",
"return",
"_",
".",
"isString",
"(",
"query",
")",
"?",
"query",
".",
"split",
"(",
"AMPERSAND",
")",
".",
"map",
"(",
"QueryParam",
".",
"parseSingle",
")",
":",
"[",
"]",
";",
"}"
] |
Parse a query string into an array of objects, where each object contains a key and a value.
@param {String} query
@returns {Array}
|
[
"Parse",
"a",
"query",
"string",
"into",
"an",
"array",
"of",
"objects",
"where",
"each",
"object",
"contains",
"a",
"key",
"and",
"a",
"value",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/query-param.js#L102-L104
|
|
15,169
|
postmanlabs/postman-collection
|
lib/collection/query-param.js
|
function (param, idx, all) {
// helps handle weird edge cases such as "/get?a=b&&"
if (param === EMPTY && // if param is empty
_.isNumber(idx) && // this and the next condition ensures that this is part of a map call
_.isArray(all) &&
idx !== (all && (all.length - 1))) { // not last parameter in the array
return { key: null, value: null };
}
var index = (typeof param === STRING) ? param.indexOf(EQUALS) : -1,
paramObj = {};
// this means that there was no value for this key (not even blank, so we store this info) and the value is set
// to null
if (index < 0) {
paramObj.key = param.substr(0, param.length);
paramObj.value = null;
}
else {
paramObj.key = param.substr(0, index);
paramObj.value = param.substr(index + 1);
}
return paramObj;
}
|
javascript
|
function (param, idx, all) {
// helps handle weird edge cases such as "/get?a=b&&"
if (param === EMPTY && // if param is empty
_.isNumber(idx) && // this and the next condition ensures that this is part of a map call
_.isArray(all) &&
idx !== (all && (all.length - 1))) { // not last parameter in the array
return { key: null, value: null };
}
var index = (typeof param === STRING) ? param.indexOf(EQUALS) : -1,
paramObj = {};
// this means that there was no value for this key (not even blank, so we store this info) and the value is set
// to null
if (index < 0) {
paramObj.key = param.substr(0, param.length);
paramObj.value = null;
}
else {
paramObj.key = param.substr(0, index);
paramObj.value = param.substr(index + 1);
}
return paramObj;
}
|
[
"function",
"(",
"param",
",",
"idx",
",",
"all",
")",
"{",
"// helps handle weird edge cases such as \"/get?a=b&&\"",
"if",
"(",
"param",
"===",
"EMPTY",
"&&",
"// if param is empty",
"_",
".",
"isNumber",
"(",
"idx",
")",
"&&",
"// this and the next condition ensures that this is part of a map call",
"_",
".",
"isArray",
"(",
"all",
")",
"&&",
"idx",
"!==",
"(",
"all",
"&&",
"(",
"all",
".",
"length",
"-",
"1",
")",
")",
")",
"{",
"// not last parameter in the array",
"return",
"{",
"key",
":",
"null",
",",
"value",
":",
"null",
"}",
";",
"}",
"var",
"index",
"=",
"(",
"typeof",
"param",
"===",
"STRING",
")",
"?",
"param",
".",
"indexOf",
"(",
"EQUALS",
")",
":",
"-",
"1",
",",
"paramObj",
"=",
"{",
"}",
";",
"// this means that there was no value for this key (not even blank, so we store this info) and the value is set",
"// to null",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"paramObj",
".",
"key",
"=",
"param",
".",
"substr",
"(",
"0",
",",
"param",
".",
"length",
")",
";",
"paramObj",
".",
"value",
"=",
"null",
";",
"}",
"else",
"{",
"paramObj",
".",
"key",
"=",
"param",
".",
"substr",
"(",
"0",
",",
"index",
")",
";",
"paramObj",
".",
"value",
"=",
"param",
".",
"substr",
"(",
"index",
"+",
"1",
")",
";",
"}",
"return",
"paramObj",
";",
"}"
] |
Parses a single query parameter.
@param {String} param
@param {Number} idx
@param {String[]} all - array of all params, in case this is being called while parsing multiple params.
@returns {{key: string|null, value: string|null}}
|
[
"Parses",
"a",
"single",
"query",
"parameter",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/query-param.js#L114-L138
|
|
15,170
|
postmanlabs/postman-collection
|
lib/collection/query-param.js
|
function (obj, encode) {
if (!obj) { return EMPTY; }
var key = obj.key,
value = obj.value;
if (value === undefined) {
return EMPTY;
}
if (key === null) {
key = EMPTY;
}
if (value === null) {
return encode ? urlEncoder.encode(key) : key;
}
if (encode) {
key = urlEncoder.encode(key);
value = urlEncoder.encode(value);
}
return key + EQUALS + value;
}
|
javascript
|
function (obj, encode) {
if (!obj) { return EMPTY; }
var key = obj.key,
value = obj.value;
if (value === undefined) {
return EMPTY;
}
if (key === null) {
key = EMPTY;
}
if (value === null) {
return encode ? urlEncoder.encode(key) : key;
}
if (encode) {
key = urlEncoder.encode(key);
value = urlEncoder.encode(value);
}
return key + EQUALS + value;
}
|
[
"function",
"(",
"obj",
",",
"encode",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
"EMPTY",
";",
"}",
"var",
"key",
"=",
"obj",
".",
"key",
",",
"value",
"=",
"obj",
".",
"value",
";",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"return",
"EMPTY",
";",
"}",
"if",
"(",
"key",
"===",
"null",
")",
"{",
"key",
"=",
"EMPTY",
";",
"}",
"if",
"(",
"value",
"===",
"null",
")",
"{",
"return",
"encode",
"?",
"urlEncoder",
".",
"encode",
"(",
"key",
")",
":",
"key",
";",
"}",
"if",
"(",
"encode",
")",
"{",
"key",
"=",
"urlEncoder",
".",
"encode",
"(",
"key",
")",
";",
"value",
"=",
"urlEncoder",
".",
"encode",
"(",
"value",
")",
";",
"}",
"return",
"key",
"+",
"EQUALS",
"+",
"value",
";",
"}"
] |
Takes a query param and converts to string
@param {Object} obj
@param {Boolean} encode
@returns {String}
@deprecated since v3.4.6, drop support for `encode`
|
[
"Takes",
"a",
"query",
"param",
"and",
"converts",
"to",
"string"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/query-param.js#L194-L218
|
|
15,171
|
postmanlabs/postman-collection
|
lib/content-info/index.js
|
function (response) {
var contentType = response.headers.get(HEADERS.CONTENT_TYPE),
contentDisposition = response.headers.get(HEADERS.CONTENT_DISPOSITION),
mimeInfo = getMimeInfo(contentType, response.stream || response.body),
fileName = getFileNameFromDispositionHeader(contentDisposition),
fileExtension = mimeInfo.extension,
/**
* @typedef Response~ResponseContentInfo
*
* @property {String} mimeType sanitized mime type
* @property {String} mimeFormat format for the identified mime type
* @property {String} charset the normalized character set
* @property {String} fileExtension extension identified from the mime type
* @property {String} fileName file name extracted from disposition header
*/
contentInfo = {};
// if file name is not present in the content disposition headers, use a default file name
if (!fileName) {
fileName = DEFAULT_RESPONSE_FILENAME;
// add extension to default if present
fileExtension && (fileName += (DOT + fileExtension));
}
// create a compacted list of content info from mime info and file name
mimeInfo.mimeType && (contentInfo.mimeType = mimeInfo.mimeType);
mimeInfo.mimeFormat && (contentInfo.mimeFormat = mimeInfo.mimeFormat);
mimeInfo.charset && (contentInfo.charset = mimeInfo.charset);
fileExtension && (contentInfo.fileExtension = fileExtension);
fileName && (contentInfo.fileName = fileName);
return contentInfo;
}
|
javascript
|
function (response) {
var contentType = response.headers.get(HEADERS.CONTENT_TYPE),
contentDisposition = response.headers.get(HEADERS.CONTENT_DISPOSITION),
mimeInfo = getMimeInfo(contentType, response.stream || response.body),
fileName = getFileNameFromDispositionHeader(contentDisposition),
fileExtension = mimeInfo.extension,
/**
* @typedef Response~ResponseContentInfo
*
* @property {String} mimeType sanitized mime type
* @property {String} mimeFormat format for the identified mime type
* @property {String} charset the normalized character set
* @property {String} fileExtension extension identified from the mime type
* @property {String} fileName file name extracted from disposition header
*/
contentInfo = {};
// if file name is not present in the content disposition headers, use a default file name
if (!fileName) {
fileName = DEFAULT_RESPONSE_FILENAME;
// add extension to default if present
fileExtension && (fileName += (DOT + fileExtension));
}
// create a compacted list of content info from mime info and file name
mimeInfo.mimeType && (contentInfo.mimeType = mimeInfo.mimeType);
mimeInfo.mimeFormat && (contentInfo.mimeFormat = mimeInfo.mimeFormat);
mimeInfo.charset && (contentInfo.charset = mimeInfo.charset);
fileExtension && (contentInfo.fileExtension = fileExtension);
fileName && (contentInfo.fileName = fileName);
return contentInfo;
}
|
[
"function",
"(",
"response",
")",
"{",
"var",
"contentType",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"HEADERS",
".",
"CONTENT_TYPE",
")",
",",
"contentDisposition",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"HEADERS",
".",
"CONTENT_DISPOSITION",
")",
",",
"mimeInfo",
"=",
"getMimeInfo",
"(",
"contentType",
",",
"response",
".",
"stream",
"||",
"response",
".",
"body",
")",
",",
"fileName",
"=",
"getFileNameFromDispositionHeader",
"(",
"contentDisposition",
")",
",",
"fileExtension",
"=",
"mimeInfo",
".",
"extension",
",",
"/**\n * @typedef Response~ResponseContentInfo\n *\n * @property {String} mimeType sanitized mime type\n * @property {String} mimeFormat format for the identified mime type\n * @property {String} charset the normalized character set\n * @property {String} fileExtension extension identified from the mime type\n * @property {String} fileName file name extracted from disposition header\n */",
"contentInfo",
"=",
"{",
"}",
";",
"// if file name is not present in the content disposition headers, use a default file name",
"if",
"(",
"!",
"fileName",
")",
"{",
"fileName",
"=",
"DEFAULT_RESPONSE_FILENAME",
";",
"// add extension to default if present",
"fileExtension",
"&&",
"(",
"fileName",
"+=",
"(",
"DOT",
"+",
"fileExtension",
")",
")",
";",
"}",
"// create a compacted list of content info from mime info and file name",
"mimeInfo",
".",
"mimeType",
"&&",
"(",
"contentInfo",
".",
"mimeType",
"=",
"mimeInfo",
".",
"mimeType",
")",
";",
"mimeInfo",
".",
"mimeFormat",
"&&",
"(",
"contentInfo",
".",
"mimeFormat",
"=",
"mimeInfo",
".",
"mimeFormat",
")",
";",
"mimeInfo",
".",
"charset",
"&&",
"(",
"contentInfo",
".",
"charset",
"=",
"mimeInfo",
".",
"charset",
")",
";",
"fileExtension",
"&&",
"(",
"contentInfo",
".",
"fileExtension",
"=",
"fileExtension",
")",
";",
"fileName",
"&&",
"(",
"contentInfo",
".",
"fileName",
"=",
"fileName",
")",
";",
"return",
"contentInfo",
";",
"}"
] |
Extracts content related information from response.
Includes response mime information, character set and file name.
@private
@param {Response} response - response instance
@returns {Response~ResponseContentInfo} - Return contentInfo of the response
|
[
"Extracts",
"content",
"related",
"information",
"from",
"response",
".",
"Includes",
"response",
"mime",
"information",
"character",
"set",
"and",
"file",
"name",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/content-info/index.js#L335-L369
|
|
15,172
|
postmanlabs/postman-collection
|
lib/collection/collection.js
|
function () {
var json = ItemGroup.prototype.toJSON.apply(this);
// move ids and stuff from root level to `info` object
json.info = {
_postman_id: this.id,
name: this.name,
version: this.version,
schema: SCHEMA_URL
};
delete json.id;
delete json.name;
delete json.version;
if (json.hasOwnProperty('description')) {
json.info.description = this.description;
delete json.description;
}
return json;
}
|
javascript
|
function () {
var json = ItemGroup.prototype.toJSON.apply(this);
// move ids and stuff from root level to `info` object
json.info = {
_postman_id: this.id,
name: this.name,
version: this.version,
schema: SCHEMA_URL
};
delete json.id;
delete json.name;
delete json.version;
if (json.hasOwnProperty('description')) {
json.info.description = this.description;
delete json.description;
}
return json;
}
|
[
"function",
"(",
")",
"{",
"var",
"json",
"=",
"ItemGroup",
".",
"prototype",
".",
"toJSON",
".",
"apply",
"(",
"this",
")",
";",
"// move ids and stuff from root level to `info` object",
"json",
".",
"info",
"=",
"{",
"_postman_id",
":",
"this",
".",
"id",
",",
"name",
":",
"this",
".",
"name",
",",
"version",
":",
"this",
".",
"version",
",",
"schema",
":",
"SCHEMA_URL",
"}",
";",
"delete",
"json",
".",
"id",
";",
"delete",
"json",
".",
"name",
";",
"delete",
"json",
".",
"version",
";",
"if",
"(",
"json",
".",
"hasOwnProperty",
"(",
"'description'",
")",
")",
"{",
"json",
".",
"info",
".",
"description",
"=",
"this",
".",
"description",
";",
"delete",
"json",
".",
"description",
";",
"}",
"return",
"json",
";",
"}"
] |
Convert the collection to JSON compatible plain object
@returns {Object}
|
[
"Convert",
"the",
"collection",
"to",
"JSON",
"compatible",
"plain",
"object"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/collection.js#L193-L214
|
|
15,173
|
postmanlabs/postman-collection
|
lib/util.js
|
function (child, base) {
Object.defineProperty(child, 'super_', {
value: _.isFunction(base) ? base : _.noop,
configurable: false,
enumerable: false,
writable: false
});
child.prototype = Object.create((_.isFunction(base) ? base.prototype : base), {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
return child;
}
|
javascript
|
function (child, base) {
Object.defineProperty(child, 'super_', {
value: _.isFunction(base) ? base : _.noop,
configurable: false,
enumerable: false,
writable: false
});
child.prototype = Object.create((_.isFunction(base) ? base.prototype : base), {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
return child;
}
|
[
"function",
"(",
"child",
",",
"base",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"child",
",",
"'super_'",
",",
"{",
"value",
":",
"_",
".",
"isFunction",
"(",
"base",
")",
"?",
"base",
":",
"_",
".",
"noop",
",",
"configurable",
":",
"false",
",",
"enumerable",
":",
"false",
",",
"writable",
":",
"false",
"}",
")",
";",
"child",
".",
"prototype",
"=",
"Object",
".",
"create",
"(",
"(",
"_",
".",
"isFunction",
"(",
"base",
")",
"?",
"base",
".",
"prototype",
":",
"base",
")",
",",
"{",
"constructor",
":",
"{",
"value",
":",
"child",
",",
"enumerable",
":",
"false",
",",
"writable",
":",
"true",
",",
"configurable",
":",
"true",
"}",
"}",
")",
";",
"return",
"child",
";",
"}"
] |
Creates an inheritance relation between the child and the parent, adding a 'super_' attribute to the
child, and setting up the child prototype.
@param {Function} child - The target object to create parent references for,.
@param {Function} base - The parent association to assign to the provided child definition.
@returns {*}
|
[
"Creates",
"an",
"inheritance",
"relation",
"between",
"the",
"child",
"and",
"the",
"parent",
"adding",
"a",
"super_",
"attribute",
"to",
"the",
"child",
"and",
"setting",
"up",
"the",
"child",
"prototype",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L24-L41
|
|
15,174
|
postmanlabs/postman-collection
|
lib/util.js
|
function (obj, name, Prop, fallback) {
return _.has(obj, name) ? (new Prop(obj[name])) : fallback;
}
|
javascript
|
function (obj, name, Prop, fallback) {
return _.has(obj, name) ? (new Prop(obj[name])) : fallback;
}
|
[
"function",
"(",
"obj",
",",
"name",
",",
"Prop",
",",
"fallback",
")",
"{",
"return",
"_",
".",
"has",
"(",
"obj",
",",
"name",
")",
"?",
"(",
"new",
"Prop",
"(",
"obj",
"[",
"name",
"]",
")",
")",
":",
"fallback",
";",
"}"
] |
Creates a property on an object, with the given type.
@param {Object} obj
@param {String} name
@param {Property} Prop
@param {*} [fallback]
@returns {Prop|undefined}
|
[
"Creates",
"a",
"property",
"on",
"an",
"object",
"with",
"the",
"given",
"type",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L110-L112
|
|
15,175
|
postmanlabs/postman-collection
|
lib/util.js
|
function (target, source) {
var key;
for (key in source) {
if (source.hasOwnProperty(key) && !_.isUndefined(source[key])) {
target[key] = source[key];
}
}
return target;
}
|
javascript
|
function (target, source) {
var key;
for (key in source) {
if (source.hasOwnProperty(key) && !_.isUndefined(source[key])) {
target[key] = source[key];
}
}
return target;
}
|
[
"function",
"(",
"target",
",",
"source",
")",
"{",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"source",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"!",
"_",
".",
"isUndefined",
"(",
"source",
"[",
"key",
"]",
")",
")",
"{",
"target",
"[",
"key",
"]",
"=",
"source",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"target",
";",
"}"
] |
Merges defined keys from the target object onto the source object.
@param {Object} target
@param {Object} source
@returns {Object}
|
[
"Merges",
"defined",
"keys",
"from",
"the",
"target",
"object",
"onto",
"the",
"source",
"object",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L121-L131
|
|
15,176
|
postmanlabs/postman-collection
|
lib/util.js
|
function (obj, prop, def) {
return _.has(obj, prop) ? obj[prop] : def;
}
|
javascript
|
function (obj, prop, def) {
return _.has(obj, prop) ? obj[prop] : def;
}
|
[
"function",
"(",
"obj",
",",
"prop",
",",
"def",
")",
"{",
"return",
"_",
".",
"has",
"(",
"obj",
",",
"prop",
")",
"?",
"obj",
"[",
"prop",
"]",
":",
"def",
";",
"}"
] |
Returns the value of a property if defined in object, else the default
@param {Object} obj
@param {String} prop
@param {*=} def
@returns {*}
|
[
"Returns",
"the",
"value",
"of",
"a",
"property",
"if",
"defined",
"in",
"object",
"else",
"the",
"default"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L142-L144
|
|
15,177
|
postmanlabs/postman-collection
|
lib/util.js
|
function (obj) {
return _.cloneDeepWith(obj, function (value) {
// falls back to default deepclone if object does not have explicit toJSON().
if (value && _.isFunction(value.toJSON)) {
return value.toJSON();
}
});
}
|
javascript
|
function (obj) {
return _.cloneDeepWith(obj, function (value) {
// falls back to default deepclone if object does not have explicit toJSON().
if (value && _.isFunction(value.toJSON)) {
return value.toJSON();
}
});
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"_",
".",
"cloneDeepWith",
"(",
"obj",
",",
"function",
"(",
"value",
")",
"{",
"// falls back to default deepclone if object does not have explicit toJSON().",
"if",
"(",
"value",
"&&",
"_",
".",
"isFunction",
"(",
"value",
".",
"toJSON",
")",
")",
"{",
"return",
"value",
".",
"toJSON",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a clone of an object, but uses the toJSON method if available.
@param {Object} obj
@returns {*}
|
[
"Creates",
"a",
"clone",
"of",
"an",
"object",
"but",
"uses",
"the",
"toJSON",
"method",
"if",
"available",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L152-L159
|
|
15,178
|
postmanlabs/postman-collection
|
lib/util.js
|
function (obj, key, value) {
return obj ? ((obj[key] === value) || _.inSuperChain(obj.super_, key, value)) : false;
}
|
javascript
|
function (obj, key, value) {
return obj ? ((obj[key] === value) || _.inSuperChain(obj.super_, key, value)) : false;
}
|
[
"function",
"(",
"obj",
",",
"key",
",",
"value",
")",
"{",
"return",
"obj",
"?",
"(",
"(",
"obj",
"[",
"key",
"]",
"===",
"value",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"super_",
",",
"key",
",",
"value",
")",
")",
":",
"false",
";",
"}"
] |
Returns the match of a value of a property by traversing the prototype
@param {Object} obj
@param {String} key
@param {*} value
@returns {Boolean}
|
[
"Returns",
"the",
"match",
"of",
"a",
"value",
"of",
"a",
"property",
"by",
"traversing",
"the",
"prototype"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/util.js#L170-L172
|
|
15,179
|
postmanlabs/postman-collection
|
lib/collection/cookie.js
|
function (obj) {
return Boolean(obj) && ((obj instanceof Cookie) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Cookie._postman_propertyName));
}
|
javascript
|
function (obj) {
return Boolean(obj) && ((obj instanceof Cookie) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Cookie._postman_propertyName));
}
|
[
"function",
"(",
"obj",
")",
"{",
"return",
"Boolean",
"(",
"obj",
")",
"&&",
"(",
"(",
"obj",
"instanceof",
"Cookie",
")",
"||",
"_",
".",
"inSuperChain",
"(",
"obj",
".",
"constructor",
",",
"'_postman_propertyName'",
",",
"Cookie",
".",
"_postman_propertyName",
")",
")",
";",
"}"
] |
Check whether an object is an instance of PostmanCookie.
@param {*} obj
@returns {Boolean}
|
[
"Check",
"whether",
"an",
"object",
"is",
"an",
"instance",
"of",
"PostmanCookie",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/cookie.js#L242-L245
|
|
15,180
|
postmanlabs/postman-collection
|
lib/collection/cookie.js
|
function (str) {
if (!_.isString(str)) {
return str;
}
var obj = {},
pairs = str.split(PAIR_SPLIT_REGEX),
nameval;
nameval = Cookie.splitParam(pairs.shift()); // The first kvp is the name and value
obj.key = nameval.key;
obj.value = nameval.value;
pairs.forEach(function (pair) {
var keyval = Cookie.splitParam(pair),
value = keyval.value,
keyLower = keyval.key.toLowerCase();
if (cookieAttributes[keyLower]) {
obj[cookieAttributes[keyLower]] = value;
}
else {
obj.extensions = obj.extensions || [];
obj.extensions.push(keyval);
}
});
// Handle the hostOnly flag
if (!obj.domain) {
obj.hostOnly = true;
}
return obj;
}
|
javascript
|
function (str) {
if (!_.isString(str)) {
return str;
}
var obj = {},
pairs = str.split(PAIR_SPLIT_REGEX),
nameval;
nameval = Cookie.splitParam(pairs.shift()); // The first kvp is the name and value
obj.key = nameval.key;
obj.value = nameval.value;
pairs.forEach(function (pair) {
var keyval = Cookie.splitParam(pair),
value = keyval.value,
keyLower = keyval.key.toLowerCase();
if (cookieAttributes[keyLower]) {
obj[cookieAttributes[keyLower]] = value;
}
else {
obj.extensions = obj.extensions || [];
obj.extensions.push(keyval);
}
});
// Handle the hostOnly flag
if (!obj.domain) {
obj.hostOnly = true;
}
return obj;
}
|
[
"function",
"(",
"str",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"str",
")",
")",
"{",
"return",
"str",
";",
"}",
"var",
"obj",
"=",
"{",
"}",
",",
"pairs",
"=",
"str",
".",
"split",
"(",
"PAIR_SPLIT_REGEX",
")",
",",
"nameval",
";",
"nameval",
"=",
"Cookie",
".",
"splitParam",
"(",
"pairs",
".",
"shift",
"(",
")",
")",
";",
"// The first kvp is the name and value",
"obj",
".",
"key",
"=",
"nameval",
".",
"key",
";",
"obj",
".",
"value",
"=",
"nameval",
".",
"value",
";",
"pairs",
".",
"forEach",
"(",
"function",
"(",
"pair",
")",
"{",
"var",
"keyval",
"=",
"Cookie",
".",
"splitParam",
"(",
"pair",
")",
",",
"value",
"=",
"keyval",
".",
"value",
",",
"keyLower",
"=",
"keyval",
".",
"key",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"cookieAttributes",
"[",
"keyLower",
"]",
")",
"{",
"obj",
"[",
"cookieAttributes",
"[",
"keyLower",
"]",
"]",
"=",
"value",
";",
"}",
"else",
"{",
"obj",
".",
"extensions",
"=",
"obj",
".",
"extensions",
"||",
"[",
"]",
";",
"obj",
".",
"extensions",
".",
"push",
"(",
"keyval",
")",
";",
"}",
"}",
")",
";",
"// Handle the hostOnly flag",
"if",
"(",
"!",
"obj",
".",
"domain",
")",
"{",
"obj",
".",
"hostOnly",
"=",
"true",
";",
"}",
"return",
"obj",
";",
"}"
] |
Cookie header parser
@param {String} str
@returns {*} A plain cookie options object, use it to create a new Cookie
|
[
"Cookie",
"header",
"parser"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/cookie.js#L253-L284
|
|
15,181
|
postmanlabs/postman-collection
|
lib/collection/cookie.js
|
function (param) {
var split = param.split('='),
key, value;
key = split[0].trim();
value = (split[1]) ? split[1].trim() : true;
if (_.isString(value) && value[0] === '"') {
value = value.slice(1, -1);
}
return { key: key, value: value };
}
|
javascript
|
function (param) {
var split = param.split('='),
key, value;
key = split[0].trim();
value = (split[1]) ? split[1].trim() : true;
if (_.isString(value) && value[0] === '"') {
value = value.slice(1, -1);
}
return { key: key, value: value };
}
|
[
"function",
"(",
"param",
")",
"{",
"var",
"split",
"=",
"param",
".",
"split",
"(",
"'='",
")",
",",
"key",
",",
"value",
";",
"key",
"=",
"split",
"[",
"0",
"]",
".",
"trim",
"(",
")",
";",
"value",
"=",
"(",
"split",
"[",
"1",
"]",
")",
"?",
"split",
"[",
"1",
"]",
".",
"trim",
"(",
")",
":",
"true",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"value",
")",
"&&",
"value",
"[",
"0",
"]",
"===",
"'\"'",
")",
"{",
"value",
"=",
"value",
".",
"slice",
"(",
"1",
",",
"-",
"1",
")",
";",
"}",
"return",
"{",
"key",
":",
"key",
",",
"value",
":",
"value",
"}",
";",
"}"
] |
Splits a Cookie parameter into a key and a value
@private
@param {String} param
@returns {{key: *, value: (boolean|*)}}
|
[
"Splits",
"a",
"Cookie",
"parameter",
"into",
"a",
"key",
"and",
"a",
"value"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/cookie.js#L293-L304
|
|
15,182
|
postmanlabs/postman-collection
|
lib/collection/request-body.js
|
function (options) {
_.isString(options) && (options = { mode: 'raw', raw: options });
if (!options.mode) { return; } // need a valid mode @todo raise error?
var mode = RequestBody.MODES[options.mode.toString().toLowerCase()] || RequestBody.MODES.raw,
urlencoded = options.urlencoded,
formdata = options.formdata,
graphql = options.graphql,
file = options.file,
raw = options.raw;
// Handle URL Encoded data
if (options.urlencoded) {
_.isString(options.urlencoded) && (urlencoded = QueryParam.parse(options.urlencoded));
// @todo: The fallback in the ternary expression will never be hit, as urlencoded points to
// @todo: options.urlencoded
urlencoded = urlencoded ? new PropertyList(QueryParam, this, urlencoded) :
new PropertyList(QueryParam, this, []);
}
// Handle Form data
if (options.formdata) {
// @todo: The fallback in the ternary expression will never be hit, as formdata points to
// @todo: options.formdata
formdata = formdata ? new PropertyList(FormParam, this, options.formdata) :
new PropertyList(FormParam, this, []);
}
// Handle GraphQL data
if (options.graphql) {
graphql = {
query: graphql.query,
operationName: graphql.operationName,
variables: graphql.variables
};
}
_.isString(options.file) && (file = { src: file });
// If mode is raw but options does not give raw content, set it to empty string
(mode === RequestBody.MODES.raw && !raw) && (raw = '');
// If mode is urlencoded but options does not provide any content, set it to an empty property list
(mode === RequestBody.MODES.urlencoded && !urlencoded) && (urlencoded = new PropertyList(QueryParam, this, []));
// If mode is formdata but options does not provide any content, set it to an empty property list
(mode === RequestBody.MODES.formdata && !formdata) && (formdata = new PropertyList(FormParam, this, []));
// If mode is graphql but options does not provide any content, set empty query
(mode === RequestBody.MODES.graphql && !graphql) && (graphql = {});
_.assign(this, /** @lends RequestBody.prototype */ {
/**
* Indicates the type of request data to use.
*
* @type {String}
*/
mode: mode,
/**
* If the request has raw body data associated with it, the data is held in this field.
*
* @type {String}
*/
raw: raw,
/**
* Any URL encoded body params go here.
*
* @type {PropertyList<QueryParam>}
*/
urlencoded: urlencoded,
/**
* Form data parameters for this request are held in this field.
*
* @type {PropertyList<FormParam>}
*/
formdata: formdata,
/**
* Holds a reference to a file which should be read as the RequestBody. It can be a file path (when used
* with Node) or a unique ID (when used with the browser).
*
* @note The reference stored here should be resolved by a resolver function (which should be provided to
* the Postman Runtime).
*/
file: file,
/**
* If the request has raw graphql data associated with it, the data is held in this field.
*
* @type {Object}
*/
graphql: graphql,
/**
* Indicates whether to include body in request or not.
*
* @type {Boolean}
*/
disabled: options.disabled
});
}
|
javascript
|
function (options) {
_.isString(options) && (options = { mode: 'raw', raw: options });
if (!options.mode) { return; } // need a valid mode @todo raise error?
var mode = RequestBody.MODES[options.mode.toString().toLowerCase()] || RequestBody.MODES.raw,
urlencoded = options.urlencoded,
formdata = options.formdata,
graphql = options.graphql,
file = options.file,
raw = options.raw;
// Handle URL Encoded data
if (options.urlencoded) {
_.isString(options.urlencoded) && (urlencoded = QueryParam.parse(options.urlencoded));
// @todo: The fallback in the ternary expression will never be hit, as urlencoded points to
// @todo: options.urlencoded
urlencoded = urlencoded ? new PropertyList(QueryParam, this, urlencoded) :
new PropertyList(QueryParam, this, []);
}
// Handle Form data
if (options.formdata) {
// @todo: The fallback in the ternary expression will never be hit, as formdata points to
// @todo: options.formdata
formdata = formdata ? new PropertyList(FormParam, this, options.formdata) :
new PropertyList(FormParam, this, []);
}
// Handle GraphQL data
if (options.graphql) {
graphql = {
query: graphql.query,
operationName: graphql.operationName,
variables: graphql.variables
};
}
_.isString(options.file) && (file = { src: file });
// If mode is raw but options does not give raw content, set it to empty string
(mode === RequestBody.MODES.raw && !raw) && (raw = '');
// If mode is urlencoded but options does not provide any content, set it to an empty property list
(mode === RequestBody.MODES.urlencoded && !urlencoded) && (urlencoded = new PropertyList(QueryParam, this, []));
// If mode is formdata but options does not provide any content, set it to an empty property list
(mode === RequestBody.MODES.formdata && !formdata) && (formdata = new PropertyList(FormParam, this, []));
// If mode is graphql but options does not provide any content, set empty query
(mode === RequestBody.MODES.graphql && !graphql) && (graphql = {});
_.assign(this, /** @lends RequestBody.prototype */ {
/**
* Indicates the type of request data to use.
*
* @type {String}
*/
mode: mode,
/**
* If the request has raw body data associated with it, the data is held in this field.
*
* @type {String}
*/
raw: raw,
/**
* Any URL encoded body params go here.
*
* @type {PropertyList<QueryParam>}
*/
urlencoded: urlencoded,
/**
* Form data parameters for this request are held in this field.
*
* @type {PropertyList<FormParam>}
*/
formdata: formdata,
/**
* Holds a reference to a file which should be read as the RequestBody. It can be a file path (when used
* with Node) or a unique ID (when used with the browser).
*
* @note The reference stored here should be resolved by a resolver function (which should be provided to
* the Postman Runtime).
*/
file: file,
/**
* If the request has raw graphql data associated with it, the data is held in this field.
*
* @type {Object}
*/
graphql: graphql,
/**
* Indicates whether to include body in request or not.
*
* @type {Boolean}
*/
disabled: options.disabled
});
}
|
[
"function",
"(",
"options",
")",
"{",
"_",
".",
"isString",
"(",
"options",
")",
"&&",
"(",
"options",
"=",
"{",
"mode",
":",
"'raw'",
",",
"raw",
":",
"options",
"}",
")",
";",
"if",
"(",
"!",
"options",
".",
"mode",
")",
"{",
"return",
";",
"}",
"// need a valid mode @todo raise error?",
"var",
"mode",
"=",
"RequestBody",
".",
"MODES",
"[",
"options",
".",
"mode",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
"]",
"||",
"RequestBody",
".",
"MODES",
".",
"raw",
",",
"urlencoded",
"=",
"options",
".",
"urlencoded",
",",
"formdata",
"=",
"options",
".",
"formdata",
",",
"graphql",
"=",
"options",
".",
"graphql",
",",
"file",
"=",
"options",
".",
"file",
",",
"raw",
"=",
"options",
".",
"raw",
";",
"// Handle URL Encoded data",
"if",
"(",
"options",
".",
"urlencoded",
")",
"{",
"_",
".",
"isString",
"(",
"options",
".",
"urlencoded",
")",
"&&",
"(",
"urlencoded",
"=",
"QueryParam",
".",
"parse",
"(",
"options",
".",
"urlencoded",
")",
")",
";",
"// @todo: The fallback in the ternary expression will never be hit, as urlencoded points to",
"// @todo: options.urlencoded",
"urlencoded",
"=",
"urlencoded",
"?",
"new",
"PropertyList",
"(",
"QueryParam",
",",
"this",
",",
"urlencoded",
")",
":",
"new",
"PropertyList",
"(",
"QueryParam",
",",
"this",
",",
"[",
"]",
")",
";",
"}",
"// Handle Form data",
"if",
"(",
"options",
".",
"formdata",
")",
"{",
"// @todo: The fallback in the ternary expression will never be hit, as formdata points to",
"// @todo: options.formdata",
"formdata",
"=",
"formdata",
"?",
"new",
"PropertyList",
"(",
"FormParam",
",",
"this",
",",
"options",
".",
"formdata",
")",
":",
"new",
"PropertyList",
"(",
"FormParam",
",",
"this",
",",
"[",
"]",
")",
";",
"}",
"// Handle GraphQL data",
"if",
"(",
"options",
".",
"graphql",
")",
"{",
"graphql",
"=",
"{",
"query",
":",
"graphql",
".",
"query",
",",
"operationName",
":",
"graphql",
".",
"operationName",
",",
"variables",
":",
"graphql",
".",
"variables",
"}",
";",
"}",
"_",
".",
"isString",
"(",
"options",
".",
"file",
")",
"&&",
"(",
"file",
"=",
"{",
"src",
":",
"file",
"}",
")",
";",
"// If mode is raw but options does not give raw content, set it to empty string",
"(",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"raw",
"&&",
"!",
"raw",
")",
"&&",
"(",
"raw",
"=",
"''",
")",
";",
"// If mode is urlencoded but options does not provide any content, set it to an empty property list",
"(",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"urlencoded",
"&&",
"!",
"urlencoded",
")",
"&&",
"(",
"urlencoded",
"=",
"new",
"PropertyList",
"(",
"QueryParam",
",",
"this",
",",
"[",
"]",
")",
")",
";",
"// If mode is formdata but options does not provide any content, set it to an empty property list",
"(",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"formdata",
"&&",
"!",
"formdata",
")",
"&&",
"(",
"formdata",
"=",
"new",
"PropertyList",
"(",
"FormParam",
",",
"this",
",",
"[",
"]",
")",
")",
";",
"// If mode is graphql but options does not provide any content, set empty query",
"(",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"graphql",
"&&",
"!",
"graphql",
")",
"&&",
"(",
"graphql",
"=",
"{",
"}",
")",
";",
"_",
".",
"assign",
"(",
"this",
",",
"/** @lends RequestBody.prototype */",
"{",
"/**\n * Indicates the type of request data to use.\n *\n * @type {String}\n */",
"mode",
":",
"mode",
",",
"/**\n * If the request has raw body data associated with it, the data is held in this field.\n *\n * @type {String}\n */",
"raw",
":",
"raw",
",",
"/**\n * Any URL encoded body params go here.\n *\n * @type {PropertyList<QueryParam>}\n */",
"urlencoded",
":",
"urlencoded",
",",
"/**\n * Form data parameters for this request are held in this field.\n *\n * @type {PropertyList<FormParam>}\n */",
"formdata",
":",
"formdata",
",",
"/**\n * Holds a reference to a file which should be read as the RequestBody. It can be a file path (when used\n * with Node) or a unique ID (when used with the browser).\n *\n * @note The reference stored here should be resolved by a resolver function (which should be provided to\n * the Postman Runtime).\n */",
"file",
":",
"file",
",",
"/**\n * If the request has raw graphql data associated with it, the data is held in this field.\n *\n * @type {Object}\n */",
"graphql",
":",
"graphql",
",",
"/**\n * Indicates whether to include body in request or not.\n *\n * @type {Boolean}\n */",
"disabled",
":",
"options",
".",
"disabled",
"}",
")",
";",
"}"
] |
Set the content of this request data
@param {Object} options
|
[
"Set",
"the",
"content",
"of",
"this",
"request",
"data"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request-body.js#L36-L140
|
|
15,183
|
postmanlabs/postman-collection
|
lib/collection/request-body.js
|
function () {
// Formdata. Goodluck.
if (this.mode === RequestBody.MODES.formdata || this.mode === RequestBody.MODES.file) {
// @todo: implement this, check if we need to return undefined or something.
return EMPTY;
}
if (this.mode === RequestBody.MODES.urlencoded) {
return PropertyList.isPropertyList(this.urlencoded) ? QueryParam.unparse(this.urlencoded.all()) :
((this.urlencoded && _.isFunction(this.urlencoded.toString)) ? this.urlencoded.toString() : EMPTY);
}
if (this.mode === RequestBody.MODES.raw) {
return (this.raw && _.isFunction(this.raw.toString)) ? this.raw.toString() : EMPTY;
}
return EMPTY;
}
|
javascript
|
function () {
// Formdata. Goodluck.
if (this.mode === RequestBody.MODES.formdata || this.mode === RequestBody.MODES.file) {
// @todo: implement this, check if we need to return undefined or something.
return EMPTY;
}
if (this.mode === RequestBody.MODES.urlencoded) {
return PropertyList.isPropertyList(this.urlencoded) ? QueryParam.unparse(this.urlencoded.all()) :
((this.urlencoded && _.isFunction(this.urlencoded.toString)) ? this.urlencoded.toString() : EMPTY);
}
if (this.mode === RequestBody.MODES.raw) {
return (this.raw && _.isFunction(this.raw.toString)) ? this.raw.toString() : EMPTY;
}
return EMPTY;
}
|
[
"function",
"(",
")",
"{",
"// Formdata. Goodluck.",
"if",
"(",
"this",
".",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"formdata",
"||",
"this",
".",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"file",
")",
"{",
"// @todo: implement this, check if we need to return undefined or something.",
"return",
"EMPTY",
";",
"}",
"if",
"(",
"this",
".",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"urlencoded",
")",
"{",
"return",
"PropertyList",
".",
"isPropertyList",
"(",
"this",
".",
"urlencoded",
")",
"?",
"QueryParam",
".",
"unparse",
"(",
"this",
".",
"urlencoded",
".",
"all",
"(",
")",
")",
":",
"(",
"(",
"this",
".",
"urlencoded",
"&&",
"_",
".",
"isFunction",
"(",
"this",
".",
"urlencoded",
".",
"toString",
")",
")",
"?",
"this",
".",
"urlencoded",
".",
"toString",
"(",
")",
":",
"EMPTY",
")",
";",
"}",
"if",
"(",
"this",
".",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"raw",
")",
"{",
"return",
"(",
"this",
".",
"raw",
"&&",
"_",
".",
"isFunction",
"(",
"this",
".",
"raw",
".",
"toString",
")",
")",
"?",
"this",
".",
"raw",
".",
"toString",
"(",
")",
":",
"EMPTY",
";",
"}",
"return",
"EMPTY",
";",
"}"
] |
Stringifies and returns the request body.
@note FormData is not supported yet.
@returns {*}
|
[
"Stringifies",
"and",
"returns",
"the",
"request",
"body",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request-body.js#L148-L165
|
|
15,184
|
postmanlabs/postman-collection
|
lib/collection/request-body.js
|
function () {
var mode = this.mode,
data = mode && this[mode];
// bail out if there's no data for the selected mode
if (!data) {
return true;
}
// Handle file mode
// @note this is a legacy exception. ideally every individual data mode
// in future would declare its "empty state".
if (mode === RequestBody.MODES.file) {
return !(data.src || data.content);
}
if (_.isString(data)) {
return (data.length === 0);
}
if (_.isFunction(data.count)) { // handle for property lists
return (data.count() === 0);
}
return _.isEmpty(data); // catch all for remaining data modes
}
|
javascript
|
function () {
var mode = this.mode,
data = mode && this[mode];
// bail out if there's no data for the selected mode
if (!data) {
return true;
}
// Handle file mode
// @note this is a legacy exception. ideally every individual data mode
// in future would declare its "empty state".
if (mode === RequestBody.MODES.file) {
return !(data.src || data.content);
}
if (_.isString(data)) {
return (data.length === 0);
}
if (_.isFunction(data.count)) { // handle for property lists
return (data.count() === 0);
}
return _.isEmpty(data); // catch all for remaining data modes
}
|
[
"function",
"(",
")",
"{",
"var",
"mode",
"=",
"this",
".",
"mode",
",",
"data",
"=",
"mode",
"&&",
"this",
"[",
"mode",
"]",
";",
"// bail out if there's no data for the selected mode",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"true",
";",
"}",
"// Handle file mode",
"// @note this is a legacy exception. ideally every individual data mode",
"// in future would declare its \"empty state\".",
"if",
"(",
"mode",
"===",
"RequestBody",
".",
"MODES",
".",
"file",
")",
"{",
"return",
"!",
"(",
"data",
".",
"src",
"||",
"data",
".",
"content",
")",
";",
"}",
"if",
"(",
"_",
".",
"isString",
"(",
"data",
")",
")",
"{",
"return",
"(",
"data",
".",
"length",
"===",
"0",
")",
";",
"}",
"if",
"(",
"_",
".",
"isFunction",
"(",
"data",
".",
"count",
")",
")",
"{",
"// handle for property lists",
"return",
"(",
"data",
".",
"count",
"(",
")",
"===",
"0",
")",
";",
"}",
"return",
"_",
".",
"isEmpty",
"(",
"data",
")",
";",
"// catch all for remaining data modes",
"}"
] |
If the request body is set to a mode, but does not contain data, then we should not be sending it.
@returns {Boolean}
|
[
"If",
"the",
"request",
"body",
"is",
"set",
"to",
"a",
"mode",
"but",
"does",
"not",
"contain",
"data",
"then",
"we",
"should",
"not",
"be",
"sending",
"it",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request-body.js#L172-L197
|
|
15,185
|
postmanlabs/postman-collection
|
lib/superstring/index.js
|
function (regex, fn) {
var replacements = 0; // maintain a count of tokens replaced
// to ensure we do not perform needless operations in the replacement, we use multiple replacement functions
// after validating the parameters
this.value = (this.value.replace(regex, _.isFunction(fn) ? function () {
replacements += 1;
return fn.apply(this, arguments);
} : function () { // this case is returned when replacer is not a function (ensures we do not need to check it)
replacements += 1;
return fn;
}));
this.replacements = replacements; // store the last replacements
replacements && (this.substitutions += 1); // if any replacement is done, count that some substitution was made
return this;
}
|
javascript
|
function (regex, fn) {
var replacements = 0; // maintain a count of tokens replaced
// to ensure we do not perform needless operations in the replacement, we use multiple replacement functions
// after validating the parameters
this.value = (this.value.replace(regex, _.isFunction(fn) ? function () {
replacements += 1;
return fn.apply(this, arguments);
} : function () { // this case is returned when replacer is not a function (ensures we do not need to check it)
replacements += 1;
return fn;
}));
this.replacements = replacements; // store the last replacements
replacements && (this.substitutions += 1); // if any replacement is done, count that some substitution was made
return this;
}
|
[
"function",
"(",
"regex",
",",
"fn",
")",
"{",
"var",
"replacements",
"=",
"0",
";",
"// maintain a count of tokens replaced",
"// to ensure we do not perform needless operations in the replacement, we use multiple replacement functions",
"// after validating the parameters",
"this",
".",
"value",
"=",
"(",
"this",
".",
"value",
".",
"replace",
"(",
"regex",
",",
"_",
".",
"isFunction",
"(",
"fn",
")",
"?",
"function",
"(",
")",
"{",
"replacements",
"+=",
"1",
";",
"return",
"fn",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
":",
"function",
"(",
")",
"{",
"// this case is returned when replacer is not a function (ensures we do not need to check it)",
"replacements",
"+=",
"1",
";",
"return",
"fn",
";",
"}",
")",
")",
";",
"this",
".",
"replacements",
"=",
"replacements",
";",
"// store the last replacements",
"replacements",
"&&",
"(",
"this",
".",
"substitutions",
"+=",
"1",
")",
";",
"// if any replacement is done, count that some substitution was made",
"return",
"this",
";",
"}"
] |
Equivalent to string replace but performs additional tracking of the number of tokens replaced
@param {RegExp|String} regex
@param {Function|String} fn
@returns {SuperString}
|
[
"Equivalent",
"to",
"string",
"replace",
"but",
"performs",
"additional",
"tracking",
"of",
"the",
"number",
"of",
"tokens",
"replaced"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/superstring/index.js#L40-L56
|
|
15,186
|
postmanlabs/postman-collection
|
lib/superstring/index.js
|
function (key) {
var arr = this.variables,
obj,
value,
i,
ii;
for (i = 0, ii = arr.length; i < ii; i++) {
obj = arr[i];
// ensure that the item is an object
if (!(obj && _.isObject(obj))) {
continue;
}
// in case the object is a postman variable list, we give special attention
if (obj.constructor._postman_propertyName === 'VariableList') {
value = obj.oneNormalizedVariable(key);
if (value && !value.disabled) {
return value;
}
}
// else we return the value from the plain object
else if (obj.hasOwnProperty(key)) {
return obj[key];
}
}
}
|
javascript
|
function (key) {
var arr = this.variables,
obj,
value,
i,
ii;
for (i = 0, ii = arr.length; i < ii; i++) {
obj = arr[i];
// ensure that the item is an object
if (!(obj && _.isObject(obj))) {
continue;
}
// in case the object is a postman variable list, we give special attention
if (obj.constructor._postman_propertyName === 'VariableList') {
value = obj.oneNormalizedVariable(key);
if (value && !value.disabled) {
return value;
}
}
// else we return the value from the plain object
else if (obj.hasOwnProperty(key)) {
return obj[key];
}
}
}
|
[
"function",
"(",
"key",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"variables",
",",
"obj",
",",
"value",
",",
"i",
",",
"ii",
";",
"for",
"(",
"i",
"=",
"0",
",",
"ii",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"obj",
"=",
"arr",
"[",
"i",
"]",
";",
"// ensure that the item is an object",
"if",
"(",
"!",
"(",
"obj",
"&&",
"_",
".",
"isObject",
"(",
"obj",
")",
")",
")",
"{",
"continue",
";",
"}",
"// in case the object is a postman variable list, we give special attention",
"if",
"(",
"obj",
".",
"constructor",
".",
"_postman_propertyName",
"===",
"'VariableList'",
")",
"{",
"value",
"=",
"obj",
".",
"oneNormalizedVariable",
"(",
"key",
")",
";",
"if",
"(",
"value",
"&&",
"!",
"value",
".",
"disabled",
")",
"{",
"return",
"value",
";",
"}",
"}",
"// else we return the value from the plain object",
"else",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"return",
"obj",
"[",
"key",
"]",
";",
"}",
"}",
"}"
] |
Find a key from the array of variable objects provided to the substitutor
@param {String} key
@returns {*}
|
[
"Find",
"a",
"key",
"from",
"the",
"array",
"of",
"variable",
"objects",
"provided",
"to",
"the",
"substitutor"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/superstring/index.js#L93-L120
|
|
15,187
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function (options) {
// Nothing to do
if (!options) { return; }
// The existing url is updated.
_.has(options, 'url') && this.url.update(options.url);
// The existing list of headers must be cleared before adding the given headers to it.
options.header && this.headers.repopulate(options.header);
// Only update the method if one is provided.
_.has(options, 'method') && (this.method = _.isNil(options.method) ?
DEFAULT_REQ_METHOD : String(options.method).toUpperCase());
// The rest of the properties are not assumed to exist so we merge in the defined ones.
_.mergeDefined(this, /** @lends Request.prototype */ {
/**
* @type {RequestBody|undefined}
*/
body: _.createDefined(options, 'body', RequestBody),
// auth is a special case, empty RequestAuth should not be created for falsy values
// to allow inheritance from parent
/**
* @type {RequestAuth}
*/
auth: options.auth ? new RequestAuth(options.auth) : undefined,
/**
* @type {ProxyConfig}
*/
proxy: options.proxy && new ProxyConfig(options.proxy),
/**
* @type {Certificate|undefined}
*/
certificate: options.certificate && new Certificate(options.certificate)
});
}
|
javascript
|
function (options) {
// Nothing to do
if (!options) { return; }
// The existing url is updated.
_.has(options, 'url') && this.url.update(options.url);
// The existing list of headers must be cleared before adding the given headers to it.
options.header && this.headers.repopulate(options.header);
// Only update the method if one is provided.
_.has(options, 'method') && (this.method = _.isNil(options.method) ?
DEFAULT_REQ_METHOD : String(options.method).toUpperCase());
// The rest of the properties are not assumed to exist so we merge in the defined ones.
_.mergeDefined(this, /** @lends Request.prototype */ {
/**
* @type {RequestBody|undefined}
*/
body: _.createDefined(options, 'body', RequestBody),
// auth is a special case, empty RequestAuth should not be created for falsy values
// to allow inheritance from parent
/**
* @type {RequestAuth}
*/
auth: options.auth ? new RequestAuth(options.auth) : undefined,
/**
* @type {ProxyConfig}
*/
proxy: options.proxy && new ProxyConfig(options.proxy),
/**
* @type {Certificate|undefined}
*/
certificate: options.certificate && new Certificate(options.certificate)
});
}
|
[
"function",
"(",
"options",
")",
"{",
"// Nothing to do",
"if",
"(",
"!",
"options",
")",
"{",
"return",
";",
"}",
"// The existing url is updated.",
"_",
".",
"has",
"(",
"options",
",",
"'url'",
")",
"&&",
"this",
".",
"url",
".",
"update",
"(",
"options",
".",
"url",
")",
";",
"// The existing list of headers must be cleared before adding the given headers to it.",
"options",
".",
"header",
"&&",
"this",
".",
"headers",
".",
"repopulate",
"(",
"options",
".",
"header",
")",
";",
"// Only update the method if one is provided.",
"_",
".",
"has",
"(",
"options",
",",
"'method'",
")",
"&&",
"(",
"this",
".",
"method",
"=",
"_",
".",
"isNil",
"(",
"options",
".",
"method",
")",
"?",
"DEFAULT_REQ_METHOD",
":",
"String",
"(",
"options",
".",
"method",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"// The rest of the properties are not assumed to exist so we merge in the defined ones.",
"_",
".",
"mergeDefined",
"(",
"this",
",",
"/** @lends Request.prototype */",
"{",
"/**\n * @type {RequestBody|undefined}\n */",
"body",
":",
"_",
".",
"createDefined",
"(",
"options",
",",
"'body'",
",",
"RequestBody",
")",
",",
"// auth is a special case, empty RequestAuth should not be created for falsy values",
"// to allow inheritance from parent",
"/**\n * @type {RequestAuth}\n */",
"auth",
":",
"options",
".",
"auth",
"?",
"new",
"RequestAuth",
"(",
"options",
".",
"auth",
")",
":",
"undefined",
",",
"/**\n * @type {ProxyConfig}\n */",
"proxy",
":",
"options",
".",
"proxy",
"&&",
"new",
"ProxyConfig",
"(",
"options",
".",
"proxy",
")",
",",
"/**\n * @type {Certificate|undefined}\n */",
"certificate",
":",
"options",
".",
"certificate",
"&&",
"new",
"Certificate",
"(",
"options",
".",
"certificate",
")",
"}",
")",
";",
"}"
] |
Updates the different properties of the request.
@param {Request~definition} options
|
[
"Updates",
"the",
"different",
"properties",
"of",
"the",
"request",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L138-L176
|
|
15,188
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function (type, options) {
if (_.isObject(type) && _.isNil(options)) {
type = options.type;
options = _.omit(options, 'type');
}
// null = delete request
if (type === null) {
_.has(this, 'auth') && (delete this.auth);
return;
}
if (!RequestAuth.isValidType(type)) {
return;
}
// create a new authentication data
if (!this.auth) {
this.auth = new RequestAuth(null, this);
}
else {
this.auth.clear(type);
}
this.auth.use(type, options);
}
|
javascript
|
function (type, options) {
if (_.isObject(type) && _.isNil(options)) {
type = options.type;
options = _.omit(options, 'type');
}
// null = delete request
if (type === null) {
_.has(this, 'auth') && (delete this.auth);
return;
}
if (!RequestAuth.isValidType(type)) {
return;
}
// create a new authentication data
if (!this.auth) {
this.auth = new RequestAuth(null, this);
}
else {
this.auth.clear(type);
}
this.auth.use(type, options);
}
|
[
"function",
"(",
"type",
",",
"options",
")",
"{",
"if",
"(",
"_",
".",
"isObject",
"(",
"type",
")",
"&&",
"_",
".",
"isNil",
"(",
"options",
")",
")",
"{",
"type",
"=",
"options",
".",
"type",
";",
"options",
"=",
"_",
".",
"omit",
"(",
"options",
",",
"'type'",
")",
";",
"}",
"// null = delete request",
"if",
"(",
"type",
"===",
"null",
")",
"{",
"_",
".",
"has",
"(",
"this",
",",
"'auth'",
")",
"&&",
"(",
"delete",
"this",
".",
"auth",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"RequestAuth",
".",
"isValidType",
"(",
"type",
")",
")",
"{",
"return",
";",
"}",
"// create a new authentication data",
"if",
"(",
"!",
"this",
".",
"auth",
")",
"{",
"this",
".",
"auth",
"=",
"new",
"RequestAuth",
"(",
"null",
",",
"this",
")",
";",
"}",
"else",
"{",
"this",
".",
"auth",
".",
"clear",
"(",
"type",
")",
";",
"}",
"this",
".",
"auth",
".",
"use",
"(",
"type",
",",
"options",
")",
";",
"}"
] |
Sets authentication method for the request
@param {?String|RequestAuth~definition} type
@param {VariableList~definition=} [options]
@note This function was previously (in v2 of SDK) used to clone request and populate headers. Now it is used to
only set auth information to request
@note that ItemGroup#authorizeUsing depends on this function
|
[
"Sets",
"authentication",
"method",
"for",
"the",
"request"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L189-L214
|
|
15,189
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
getHeaders
|
function getHeaders (options) {
!options && (options = {});
// @note: options.multiValue will not be respected since, Header._postman_propertyAllowsMultipleValues
// gets higher precedence in PropertyLists~toObject.
// @todo: sanitizeKeys for headers by default.
return this.headers.toObject(options.enabled, !options.ignoreCase, options.multiValue, options.sanitizeKeys);
}
|
javascript
|
function getHeaders (options) {
!options && (options = {});
// @note: options.multiValue will not be respected since, Header._postman_propertyAllowsMultipleValues
// gets higher precedence in PropertyLists~toObject.
// @todo: sanitizeKeys for headers by default.
return this.headers.toObject(options.enabled, !options.ignoreCase, options.multiValue, options.sanitizeKeys);
}
|
[
"function",
"getHeaders",
"(",
"options",
")",
"{",
"!",
"options",
"&&",
"(",
"options",
"=",
"{",
"}",
")",
";",
"// @note: options.multiValue will not be respected since, Header._postman_propertyAllowsMultipleValues",
"// gets higher precedence in PropertyLists~toObject.",
"// @todo: sanitizeKeys for headers by default.",
"return",
"this",
".",
"headers",
".",
"toObject",
"(",
"options",
".",
"enabled",
",",
"!",
"options",
".",
"ignoreCase",
",",
"options",
".",
"multiValue",
",",
"options",
".",
"sanitizeKeys",
")",
";",
"}"
] |
Returns an object where the key is a header name and value is the header value.
@param {Object=} options
@param {Boolean} options.ignoreCase When set to "true", will ensure that all the header keys are lower case.
@param {Boolean} options.enabled Only get the enabled headers
@param {Boolean} options.multiValue When set to "true", duplicate header values will be stored in an array
@param {Boolean} options.sanitizeKeys When set to "true", headers with falsy keys are removed
@returns {Object}
@note If multiple headers are present in the same collection with same name, but different case
(E.g "x-forward-port" and "X-Forward-Port", and `options.ignoreCase` is set to true,
the values will be stored in an array.
|
[
"Returns",
"an",
"object",
"where",
"the",
"key",
"is",
"a",
"header",
"name",
"and",
"value",
"is",
"the",
"header",
"value",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L229-L236
|
15,190
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function (toRemove, options) {
toRemove = _.isString(toRemove) ? toRemove : toRemove.key;
options = options || {};
if (!toRemove) { // Nothing to remove :(
return;
}
options.ignoreCase && (toRemove = toRemove.toLowerCase());
this.headers.remove(function (header) {
var key = options.ignoreCase ? header.key.toLowerCase() : header.key;
return key === toRemove;
});
}
|
javascript
|
function (toRemove, options) {
toRemove = _.isString(toRemove) ? toRemove : toRemove.key;
options = options || {};
if (!toRemove) { // Nothing to remove :(
return;
}
options.ignoreCase && (toRemove = toRemove.toLowerCase());
this.headers.remove(function (header) {
var key = options.ignoreCase ? header.key.toLowerCase() : header.key;
return key === toRemove;
});
}
|
[
"function",
"(",
"toRemove",
",",
"options",
")",
"{",
"toRemove",
"=",
"_",
".",
"isString",
"(",
"toRemove",
")",
"?",
"toRemove",
":",
"toRemove",
".",
"key",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"toRemove",
")",
"{",
"// Nothing to remove :(",
"return",
";",
"}",
"options",
".",
"ignoreCase",
"&&",
"(",
"toRemove",
"=",
"toRemove",
".",
"toLowerCase",
"(",
")",
")",
";",
"this",
".",
"headers",
".",
"remove",
"(",
"function",
"(",
"header",
")",
"{",
"var",
"key",
"=",
"options",
".",
"ignoreCase",
"?",
"header",
".",
"key",
".",
"toLowerCase",
"(",
")",
":",
"header",
".",
"key",
";",
"return",
"key",
"===",
"toRemove",
";",
"}",
")",
";",
"}"
] |
Removes a header from the request.
@param {String|Header} toRemove A header object to remove, or a string containing the header key.
@param {Object} options
@param {Boolean} options.ignoreCase If set to true, ignores case while removing the header.
|
[
"Removes",
"a",
"header",
"from",
"the",
"request",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L265-L280
|
|
15,191
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function (header) {
if (!(header && header.key)) { return; } // if no valid header is provided, do nothing
var existing = this.headers.find({ key: header.key });
if (!existing) {
return this.headers.add(header);
}
existing.value = header.value;
}
|
javascript
|
function (header) {
if (!(header && header.key)) { return; } // if no valid header is provided, do nothing
var existing = this.headers.find({ key: header.key });
if (!existing) {
return this.headers.add(header);
}
existing.value = header.value;
}
|
[
"function",
"(",
"header",
")",
"{",
"if",
"(",
"!",
"(",
"header",
"&&",
"header",
".",
"key",
")",
")",
"{",
"return",
";",
"}",
"// if no valid header is provided, do nothing",
"var",
"existing",
"=",
"this",
".",
"headers",
".",
"find",
"(",
"{",
"key",
":",
"header",
".",
"key",
"}",
")",
";",
"if",
"(",
"!",
"existing",
")",
"{",
"return",
"this",
".",
"headers",
".",
"add",
"(",
"header",
")",
";",
"}",
"existing",
".",
"value",
"=",
"header",
".",
"value",
";",
"}"
] |
Updates or inserts the given header.
@param {Object} header
|
[
"Updates",
"or",
"inserts",
"the",
"given",
"header",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L287-L297
|
|
15,192
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function () {
var contentLength = this.headers.get(CONTENT_LENGTH),
requestTarget = this.url.getPathWithQuery(),
bodyString,
sizeInfo = {
body: 0,
header: 0,
total: 0,
source: SIZE_SOURCE.computed
};
// if 'Content-Length' header is present, we take body as declared by
// the client(postman-request or user-defined). else we need to compute the same.
if (contentLength && util.isNumeric(contentLength)) {
sizeInfo.body = parseInt(contentLength, 10);
sizeInfo.source = SIZE_SOURCE.contentLength;
}
// otherwise, if body is defined, we calculate the length of the body
else if (this.body) {
// @note body.toString() returns E for formdata or file mode
bodyString = this.body.toString();
sizeInfo.body = supportsBuffer ? Buffer.byteLength(bodyString) : bodyString.length;
}
// https://tools.ietf.org/html/rfc7230#section-3
// HTTP-message = start-line (request-line / status-line)
// *( header-field CRLF )
// CRLF
// [ message-body ]
// request-line = method SP request-target SP HTTP-version CRLF
sizeInfo.header = (this.method + SP + requestTarget + SP + HTTP_X_X + CRLF + CRLF).length +
this.headers.contentSize();
// compute the approximate total body size by adding size of header and body
sizeInfo.total = (sizeInfo.body || 0) + (sizeInfo.header || 0);
return sizeInfo;
}
|
javascript
|
function () {
var contentLength = this.headers.get(CONTENT_LENGTH),
requestTarget = this.url.getPathWithQuery(),
bodyString,
sizeInfo = {
body: 0,
header: 0,
total: 0,
source: SIZE_SOURCE.computed
};
// if 'Content-Length' header is present, we take body as declared by
// the client(postman-request or user-defined). else we need to compute the same.
if (contentLength && util.isNumeric(contentLength)) {
sizeInfo.body = parseInt(contentLength, 10);
sizeInfo.source = SIZE_SOURCE.contentLength;
}
// otherwise, if body is defined, we calculate the length of the body
else if (this.body) {
// @note body.toString() returns E for formdata or file mode
bodyString = this.body.toString();
sizeInfo.body = supportsBuffer ? Buffer.byteLength(bodyString) : bodyString.length;
}
// https://tools.ietf.org/html/rfc7230#section-3
// HTTP-message = start-line (request-line / status-line)
// *( header-field CRLF )
// CRLF
// [ message-body ]
// request-line = method SP request-target SP HTTP-version CRLF
sizeInfo.header = (this.method + SP + requestTarget + SP + HTTP_X_X + CRLF + CRLF).length +
this.headers.contentSize();
// compute the approximate total body size by adding size of header and body
sizeInfo.total = (sizeInfo.body || 0) + (sizeInfo.header || 0);
return sizeInfo;
}
|
[
"function",
"(",
")",
"{",
"var",
"contentLength",
"=",
"this",
".",
"headers",
".",
"get",
"(",
"CONTENT_LENGTH",
")",
",",
"requestTarget",
"=",
"this",
".",
"url",
".",
"getPathWithQuery",
"(",
")",
",",
"bodyString",
",",
"sizeInfo",
"=",
"{",
"body",
":",
"0",
",",
"header",
":",
"0",
",",
"total",
":",
"0",
",",
"source",
":",
"SIZE_SOURCE",
".",
"computed",
"}",
";",
"// if 'Content-Length' header is present, we take body as declared by",
"// the client(postman-request or user-defined). else we need to compute the same.",
"if",
"(",
"contentLength",
"&&",
"util",
".",
"isNumeric",
"(",
"contentLength",
")",
")",
"{",
"sizeInfo",
".",
"body",
"=",
"parseInt",
"(",
"contentLength",
",",
"10",
")",
";",
"sizeInfo",
".",
"source",
"=",
"SIZE_SOURCE",
".",
"contentLength",
";",
"}",
"// otherwise, if body is defined, we calculate the length of the body",
"else",
"if",
"(",
"this",
".",
"body",
")",
"{",
"// @note body.toString() returns E for formdata or file mode",
"bodyString",
"=",
"this",
".",
"body",
".",
"toString",
"(",
")",
";",
"sizeInfo",
".",
"body",
"=",
"supportsBuffer",
"?",
"Buffer",
".",
"byteLength",
"(",
"bodyString",
")",
":",
"bodyString",
".",
"length",
";",
"}",
"// https://tools.ietf.org/html/rfc7230#section-3",
"// HTTP-message = start-line (request-line / status-line)",
"// *( header-field CRLF )",
"// CRLF",
"// [ message-body ]",
"// request-line = method SP request-target SP HTTP-version CRLF",
"sizeInfo",
".",
"header",
"=",
"(",
"this",
".",
"method",
"+",
"SP",
"+",
"requestTarget",
"+",
"SP",
"+",
"HTTP_X_X",
"+",
"CRLF",
"+",
"CRLF",
")",
".",
"length",
"+",
"this",
".",
"headers",
".",
"contentSize",
"(",
")",
";",
"// compute the approximate total body size by adding size of header and body",
"sizeInfo",
".",
"total",
"=",
"(",
"sizeInfo",
".",
"body",
"||",
"0",
")",
"+",
"(",
"sizeInfo",
".",
"header",
"||",
"0",
")",
";",
"return",
"sizeInfo",
";",
"}"
] |
Get the request size by computing the headers and body or using the
actual content length header once the request is sent.
@returns {Object}
|
[
"Get",
"the",
"request",
"size",
"by",
"computing",
"the",
"headers",
"and",
"body",
"or",
"using",
"the",
"actual",
"content",
"length",
"header",
"once",
"the",
"request",
"is",
"sent",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L324-L360
|
|
15,193
|
postmanlabs/postman-collection
|
lib/collection/request.js
|
function () {
var obj = PropertyBase.toJSON(this);
// remove header array if blank
if (_.isArray(obj.header) && !obj.header.length) {
delete obj.header;
}
return obj;
}
|
javascript
|
function () {
var obj = PropertyBase.toJSON(this);
// remove header array if blank
if (_.isArray(obj.header) && !obj.header.length) {
delete obj.header;
}
return obj;
}
|
[
"function",
"(",
")",
"{",
"var",
"obj",
"=",
"PropertyBase",
".",
"toJSON",
"(",
"this",
")",
";",
"// remove header array if blank",
"if",
"(",
"_",
".",
"isArray",
"(",
"obj",
".",
"header",
")",
"&&",
"!",
"obj",
".",
"header",
".",
"length",
")",
"{",
"delete",
"obj",
".",
"header",
";",
"}",
"return",
"obj",
";",
"}"
] |
Converts the Request to a plain JavaScript object, which is also how the request is
represented in a collection file.
@returns {{url: (*|string), method: *, header: (undefined|*), body: *, auth: *, certificate: *}}
|
[
"Converts",
"the",
"Request",
"to",
"a",
"plain",
"JavaScript",
"object",
"which",
"is",
"also",
"how",
"the",
"request",
"is",
"represented",
"in",
"a",
"collection",
"file",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/request.js#L368-L377
|
|
15,194
|
postmanlabs/postman-collection
|
lib/collection/variable-scope.js
|
function (excludeDisabled, caseSensitive) {
// if the scope has no layers, we simply export the contents of primary store
if (!this._layers) {
return this.values.toObject(excludeDisabled, caseSensitive);
}
var mergedLayers = {};
_.forEachRight(this._layers, function (layer) {
_.assign(mergedLayers, layer.toObject(excludeDisabled, caseSensitive));
});
return _.assign(mergedLayers, this.values.toObject(excludeDisabled, caseSensitive));
}
|
javascript
|
function (excludeDisabled, caseSensitive) {
// if the scope has no layers, we simply export the contents of primary store
if (!this._layers) {
return this.values.toObject(excludeDisabled, caseSensitive);
}
var mergedLayers = {};
_.forEachRight(this._layers, function (layer) {
_.assign(mergedLayers, layer.toObject(excludeDisabled, caseSensitive));
});
return _.assign(mergedLayers, this.values.toObject(excludeDisabled, caseSensitive));
}
|
[
"function",
"(",
"excludeDisabled",
",",
"caseSensitive",
")",
"{",
"// if the scope has no layers, we simply export the contents of primary store",
"if",
"(",
"!",
"this",
".",
"_layers",
")",
"{",
"return",
"this",
".",
"values",
".",
"toObject",
"(",
"excludeDisabled",
",",
"caseSensitive",
")",
";",
"}",
"var",
"mergedLayers",
"=",
"{",
"}",
";",
"_",
".",
"forEachRight",
"(",
"this",
".",
"_layers",
",",
"function",
"(",
"layer",
")",
"{",
"_",
".",
"assign",
"(",
"mergedLayers",
",",
"layer",
".",
"toObject",
"(",
"excludeDisabled",
",",
"caseSensitive",
")",
")",
";",
"}",
")",
";",
"return",
"_",
".",
"assign",
"(",
"mergedLayers",
",",
"this",
".",
"values",
".",
"toObject",
"(",
"excludeDisabled",
",",
"caseSensitive",
")",
")",
";",
"}"
] |
Converts a list of Variables into an object where key is `_postman_propertyIndexKey` and value is determined
by the `valueOf` function
@param {Boolean} excludeDisabled
@param {Boolean} caseSensitive
@return {Object}
|
[
"Converts",
"a",
"list",
"of",
"Variables",
"into",
"an",
"object",
"where",
"key",
"is",
"_postman_propertyIndexKey",
"and",
"value",
"is",
"determined",
"by",
"the",
"valueOf",
"function"
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable-scope.js#L178-L191
|
|
15,195
|
postmanlabs/postman-collection
|
lib/collection/variable-scope.js
|
function (key) {
var variable = this.values.oneNormalizedVariable(key),
i,
ii;
// if a variable does not exist in local scope, we search all the layers and return the first occurrence.
if (!(variable || !this._layers)) {
for (i = 0, ii = this._layers.length; i < ii; i++) {
variable = this._layers[i].oneNormalizedVariable(key);
if (variable && !variable.disabled) { break; }
}
}
return (variable && !variable.disabled) ? variable.valueOf() : undefined;
}
|
javascript
|
function (key) {
var variable = this.values.oneNormalizedVariable(key),
i,
ii;
// if a variable does not exist in local scope, we search all the layers and return the first occurrence.
if (!(variable || !this._layers)) {
for (i = 0, ii = this._layers.length; i < ii; i++) {
variable = this._layers[i].oneNormalizedVariable(key);
if (variable && !variable.disabled) { break; }
}
}
return (variable && !variable.disabled) ? variable.valueOf() : undefined;
}
|
[
"function",
"(",
"key",
")",
"{",
"var",
"variable",
"=",
"this",
".",
"values",
".",
"oneNormalizedVariable",
"(",
"key",
")",
",",
"i",
",",
"ii",
";",
"// if a variable does not exist in local scope, we search all the layers and return the first occurrence.",
"if",
"(",
"!",
"(",
"variable",
"||",
"!",
"this",
".",
"_layers",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"ii",
"=",
"this",
".",
"_layers",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"variable",
"=",
"this",
".",
"_layers",
"[",
"i",
"]",
".",
"oneNormalizedVariable",
"(",
"key",
")",
";",
"if",
"(",
"variable",
"&&",
"!",
"variable",
".",
"disabled",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"(",
"variable",
"&&",
"!",
"variable",
".",
"disabled",
")",
"?",
"variable",
".",
"valueOf",
"(",
")",
":",
"undefined",
";",
"}"
] |
Fetches a variable from the current scope or from parent scopes if present.
@param {String} key - The name of the variable to get.
@returns {*} The value of the specified variable across scopes.
|
[
"Fetches",
"a",
"variable",
"from",
"the",
"current",
"scope",
"or",
"from",
"parent",
"scopes",
"if",
"present",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable-scope.js#L211-L225
|
|
15,196
|
postmanlabs/postman-collection
|
lib/collection/variable-scope.js
|
function (key, value, type) {
var variable = this.values.oneNormalizedVariable(key),
update = { // create an object that will be used as setter
key: key,
value: value
};
_.isString(type) && (update.type = type);
// If a variable by the name key exists, update it's value and return.
// @note adds new variable if existing is disabled. Disabled variables are not updated.
if (variable && !variable.disabled) {
variable.update(update);
}
else {
this.values.add(update);
}
// track the change if mutation tracking is enabled
this._postman_enableTracking && this.mutations.track(MUTATIONS.SET, key, value);
}
|
javascript
|
function (key, value, type) {
var variable = this.values.oneNormalizedVariable(key),
update = { // create an object that will be used as setter
key: key,
value: value
};
_.isString(type) && (update.type = type);
// If a variable by the name key exists, update it's value and return.
// @note adds new variable if existing is disabled. Disabled variables are not updated.
if (variable && !variable.disabled) {
variable.update(update);
}
else {
this.values.add(update);
}
// track the change if mutation tracking is enabled
this._postman_enableTracking && this.mutations.track(MUTATIONS.SET, key, value);
}
|
[
"function",
"(",
"key",
",",
"value",
",",
"type",
")",
"{",
"var",
"variable",
"=",
"this",
".",
"values",
".",
"oneNormalizedVariable",
"(",
"key",
")",
",",
"update",
"=",
"{",
"// create an object that will be used as setter",
"key",
":",
"key",
",",
"value",
":",
"value",
"}",
";",
"_",
".",
"isString",
"(",
"type",
")",
"&&",
"(",
"update",
".",
"type",
"=",
"type",
")",
";",
"// If a variable by the name key exists, update it's value and return.",
"// @note adds new variable if existing is disabled. Disabled variables are not updated.",
"if",
"(",
"variable",
"&&",
"!",
"variable",
".",
"disabled",
")",
"{",
"variable",
".",
"update",
"(",
"update",
")",
";",
"}",
"else",
"{",
"this",
".",
"values",
".",
"add",
"(",
"update",
")",
";",
"}",
"// track the change if mutation tracking is enabled",
"this",
".",
"_postman_enableTracking",
"&&",
"this",
".",
"mutations",
".",
"track",
"(",
"MUTATIONS",
".",
"SET",
",",
"key",
",",
"value",
")",
";",
"}"
] |
Creates a new variable, or updates an existing one.
@param {String} key - The name of the variable to set.
@param {*} value - The value of the variable to be set.
@param {Variable.types} [type] - Optionally, the value of the variable can be set to a type
|
[
"Creates",
"a",
"new",
"variable",
"or",
"updates",
"an",
"existing",
"one",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable-scope.js#L234-L255
|
|
15,197
|
postmanlabs/postman-collection
|
lib/collection/variable-scope.js
|
function (key) {
var lastDisabledVariable;
this.values.remove(function (variable) {
// bail out if variable name didn't match
if (variable.key !== key) {
return false;
}
// don't delete disabled variables
if (variable.disabled) {
lastDisabledVariable = variable;
return false;
}
// delete all enabled variables
return true;
});
// restore the reference with the last disabled variable
if (lastDisabledVariable) {
this.values.reference[key] = lastDisabledVariable;
}
// track the change if mutation tracking is enabled
this._postman_enableTracking && this.mutations.track(MUTATIONS.UNSET, key);
}
|
javascript
|
function (key) {
var lastDisabledVariable;
this.values.remove(function (variable) {
// bail out if variable name didn't match
if (variable.key !== key) {
return false;
}
// don't delete disabled variables
if (variable.disabled) {
lastDisabledVariable = variable;
return false;
}
// delete all enabled variables
return true;
});
// restore the reference with the last disabled variable
if (lastDisabledVariable) {
this.values.reference[key] = lastDisabledVariable;
}
// track the change if mutation tracking is enabled
this._postman_enableTracking && this.mutations.track(MUTATIONS.UNSET, key);
}
|
[
"function",
"(",
"key",
")",
"{",
"var",
"lastDisabledVariable",
";",
"this",
".",
"values",
".",
"remove",
"(",
"function",
"(",
"variable",
")",
"{",
"// bail out if variable name didn't match",
"if",
"(",
"variable",
".",
"key",
"!==",
"key",
")",
"{",
"return",
"false",
";",
"}",
"// don't delete disabled variables",
"if",
"(",
"variable",
".",
"disabled",
")",
"{",
"lastDisabledVariable",
"=",
"variable",
";",
"return",
"false",
";",
"}",
"// delete all enabled variables",
"return",
"true",
";",
"}",
")",
";",
"// restore the reference with the last disabled variable",
"if",
"(",
"lastDisabledVariable",
")",
"{",
"this",
".",
"values",
".",
"reference",
"[",
"key",
"]",
"=",
"lastDisabledVariable",
";",
"}",
"// track the change if mutation tracking is enabled",
"this",
".",
"_postman_enableTracking",
"&&",
"this",
".",
"mutations",
".",
"track",
"(",
"MUTATIONS",
".",
"UNSET",
",",
"key",
")",
";",
"}"
] |
Removes the variable with the specified name.
@param {String} key
|
[
"Removes",
"the",
"variable",
"with",
"the",
"specified",
"name",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable-scope.js#L262-L288
|
|
15,198
|
postmanlabs/postman-collection
|
lib/collection/variable-scope.js
|
function () {
var obj = PropertyBase.toJSON(this);
// @todo - remove this when pluralisation is complete
if (obj.value) {
obj.values = obj.value;
delete obj.value;
}
// ensure that the concept of layers is not exported as JSON. JSON cannot retain references and this will end up
// being a pointless object post JSONification.
if (obj._layers) {
delete obj._layers;
}
// ensure that tracking flag is not serialized
// otherwise, it is very easy to let tracking trickle to many instances leading to a snowball effect
if (obj._postman_enableTracking) {
delete obj._postman_enableTracking;
}
return obj;
}
|
javascript
|
function () {
var obj = PropertyBase.toJSON(this);
// @todo - remove this when pluralisation is complete
if (obj.value) {
obj.values = obj.value;
delete obj.value;
}
// ensure that the concept of layers is not exported as JSON. JSON cannot retain references and this will end up
// being a pointless object post JSONification.
if (obj._layers) {
delete obj._layers;
}
// ensure that tracking flag is not serialized
// otherwise, it is very easy to let tracking trickle to many instances leading to a snowball effect
if (obj._postman_enableTracking) {
delete obj._postman_enableTracking;
}
return obj;
}
|
[
"function",
"(",
")",
"{",
"var",
"obj",
"=",
"PropertyBase",
".",
"toJSON",
"(",
"this",
")",
";",
"// @todo - remove this when pluralisation is complete",
"if",
"(",
"obj",
".",
"value",
")",
"{",
"obj",
".",
"values",
"=",
"obj",
".",
"value",
";",
"delete",
"obj",
".",
"value",
";",
"}",
"// ensure that the concept of layers is not exported as JSON. JSON cannot retain references and this will end up",
"// being a pointless object post JSONification.",
"if",
"(",
"obj",
".",
"_layers",
")",
"{",
"delete",
"obj",
".",
"_layers",
";",
"}",
"// ensure that tracking flag is not serialized",
"// otherwise, it is very easy to let tracking trickle to many instances leading to a snowball effect",
"if",
"(",
"obj",
".",
"_postman_enableTracking",
")",
"{",
"delete",
"obj",
".",
"_postman_enableTracking",
";",
"}",
"return",
"obj",
";",
"}"
] |
Convert this variable scope into a JSON serialisable object. Useful to transport or store, environment and
globals as a whole.
@returns {Object}
|
[
"Convert",
"this",
"variable",
"scope",
"into",
"a",
"JSON",
"serialisable",
"object",
".",
"Useful",
"to",
"transport",
"or",
"store",
"environment",
"and",
"globals",
"as",
"a",
"whole",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/variable-scope.js#L391-L413
|
|
15,199
|
postmanlabs/postman-collection
|
lib/collection/response.js
|
function () {
if (!this._details || this._details.code !== this.code) {
this._details = _.clone(httpReasons.lookup(this.code));
this._details.code = this.code;
this._details.standardName = this._details.name;
}
return _.clone(this._details);
}
|
javascript
|
function () {
if (!this._details || this._details.code !== this.code) {
this._details = _.clone(httpReasons.lookup(this.code));
this._details.code = this.code;
this._details.standardName = this._details.name;
}
return _.clone(this._details);
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_details",
"||",
"this",
".",
"_details",
".",
"code",
"!==",
"this",
".",
"code",
")",
"{",
"this",
".",
"_details",
"=",
"_",
".",
"clone",
"(",
"httpReasons",
".",
"lookup",
"(",
"this",
".",
"code",
")",
")",
";",
"this",
".",
"_details",
".",
"code",
"=",
"this",
".",
"code",
";",
"this",
".",
"_details",
".",
"standardName",
"=",
"this",
".",
"_details",
".",
"name",
";",
"}",
"return",
"_",
".",
"clone",
"(",
"this",
".",
"_details",
")",
";",
"}"
] |
Creates a JSON representation of the current response details, and returns it.
@returns {Object} A set of response details, including the custom server reason.
@private
|
[
"Creates",
"a",
"JSON",
"representation",
"of",
"the",
"current",
"response",
"details",
"and",
"returns",
"it",
"."
] |
1cacd38a98c82f86d3f6c61d16a57465bbd78b63
|
https://github.com/postmanlabs/postman-collection/blob/1cacd38a98c82f86d3f6c61d16a57465bbd78b63/lib/collection/response.js#L292-L299
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.