_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q44600 | train | function (mutation) {
// bail out for empty or unsupported mutations
if (!(mutation && isPrimitiveMutation(mutation))) {
return;
}
// if autoCompact is set, we need to compact while adding
if (this.autoCompact) {
this.addAndCompact(mutation);
... | javascript | {
"resource": ""
} | |
q44601 | train | function (mutation) {
// for `set` and `unset` mutations the key to compact with is the `keyPath`
var key = mutation[0];
// convert `keyPath` to a string
key = Array.isArray(key) ? key.join('.') : key;
this.compacted[key] = mutation;
} | javascript | {
"resource": ""
} | |
q44602 | train | function (instruction) {
// @todo: use argument spread here once we drop support for node v4
var payload = Array.prototype.slice.call(arguments, 1);
// invalid call
if (!(instruction && payload)) {
return;
}
// unknown instruction
if (!(instruction =... | javascript | {
"resource": ""
} | |
q44603 | train | function (target) {
if (!(target && target.applyMutation)) {
return;
}
var applyIndividualMutation = function applyIndividualMutation (mutation) {
applyMutation(target, mutation);
};
// mutations move from `stream` to `compacted`, so we apply the compact... | javascript | {
"resource": ""
} | |
q44604 | train | function (options) {
_.has(options, 'pattern') && (_.isString(options.pattern) && !_.isEmpty(options.pattern)) &&
(this.pattern = options.pattern);
// create a match pattern and store it on cache
this._matchPatternObject = this.createMatchPattern();
} | javascript | {
"resource": ""
} | |
q44605 | train | function () {
var matchPattern = this.pattern,
// Check the match pattern of sanity and split it into protocol, host and path
match = matchPattern.match(regexes.patternSplit);
if (!match) {
// This ensures it is a invalid match pattern
return;
}
... | javascript | {
"resource": ""
} | |
q44606 | train | function (pattern) {
// Escape everything except ? and *.
pattern = pattern.replace(regexes.escapeMatcher, regexes.escapeMatchReplacement);
pattern = pattern.replace(regexes.questionmarkMatcher, regexes.questionmarkReplacment);
pattern = pattern.replace(regexes.starMatcher, regexes.starR... | javascript | {
"resource": ""
} | |
q44607 | train | function (protocol) {
var matchRegexObject = this._matchPatternObject;
return _.includes(ALLOWED_PROTOCOLS, protocol) &&
(_.includes(matchRegexObject.protocols, MATCH_ALL) || _.includes(matchRegexObject.protocols, protocol));
} | javascript | {
"resource": ""
} | |
q44608 | train | function (host) {
/*
* For Host match, we are considering the port with the host, hence we are using getRemote() instead of getHost()
* We need to address three cases for the host urlStr
* 1. * It matches all the host + protocol, hence we are not having any parsing logic for it.
... | javascript | {
"resource": ""
} | |
q44609 | train | 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 && typeo... | javascript | {
"resource": ""
} | |
q44610 | train | 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.p... | javascript | {
"resource": ""
} | |
q44611 | forEachItem | train | function forEachItem (callback) {
this.items.each(function (item) {
return ItemGroup.isItemGroup(item) ? item.forEachItem(callback) : callback(item, this);
}, this);
} | javascript | {
"resource": ""
} |
q44612 | forEachItemGroup | train | 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 | {
"resource": ""
} |
q44613 | train | 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 lo... | javascript | {
"resource": ""
} | |
q44614 | train | function (item) {
if (Item.isItem(item) || ItemGroup.isItemGroup(item)) { return item; }
return item && item.item ? new ItemGroup(item) : new Item(item);
} | javascript | {
"resource": ""
} | |
q44615 | train | function (options) {
// return early if options is empty or invalid
if (!_.isObject(options)) {
return;
}
_.mergeDefined(this, /** @lends Certificate.prototype */ {
/**
* Unique identifier
* @type {String}
*/
id:... | javascript | {
"resource": ""
} | |
q44616 | train | 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) {
... | javascript | {
"resource": ""
} | |
q44617 | train | function (obj) {
return Boolean(obj) && ((obj instanceof Certificate) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Certificate._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44618 | train | function (content, type) {
(Description.isDescription(this.description) ? this.description : (this.description = new Description()))
.update(content, type);
} | javascript | {
"resource": ""
} | |
q44619 | train | 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) ... | javascript | {
"resource": ""
} | |
q44620 | train | 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 substit... | javascript | {
"resource": ""
} | |
q44621 | train | 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, Substi... | javascript | {
"resource": ""
} | |
q44622 | train | 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 no... | javascript | {
"resource": ""
} | |
q44623 | train | function (protocols) {
if (!protocols) {
return;
}
var updatedProtocols,
hostAndPath = _.split(this.match.pattern, PROTOCOL_HOST_SEPARATOR)[1];
if (!hostAndPath) {
return;
}
updatedProtocols = _.intersection(ALLOWED_PROTOCOLS, _.cast... | javascript | {
"resource": ""
} | |
q44624 | train | 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);
... | javascript | {
"resource": ""
} | |
q44625 | train | 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(... | javascript | {
"resource": ""
} | |
q44626 | train | function (obj) {
return Boolean(obj) && ((obj instanceof HeaderList) ||
_.inSuperChain(obj.constructor, PROP_NAME, HeaderList._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44627 | train | 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:... | javascript | {
"resource": ""
} | |
q44628 | train | 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:... | javascript | {
"resource": ""
} | |
q44629 | train | function (obj) {
return Boolean(obj) && ((obj instanceof Description) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Description._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44630 | train | 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 m... | javascript | {
"resource": ""
} | |
q44631 | train | function (obj) {
return Boolean(obj) && ((obj instanceof EventList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', EventList._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44632 | train | 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;... | javascript | {
"resource": ""
} | |
q44633 | train | 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);
... | javascript | {
"resource": ""
} | |
q44634 | train | function (header) {
if (!_.isObject(header)) { return E; }
return header.key + HEADER_KV_SEPARATOR + SPC + header.value;
} | javascript | {
"resource": ""
} | |
q44635 | train | function (obj) {
return Boolean(obj) && ((obj instanceof Header) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Header._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44636 | train | 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 | {
"resource": ""
} | |
q44637 | train | 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 = ty... | javascript | {
"resource": ""
} | |
q44638 | train | 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.... | javascript | {
"resource": ""
} | |
q44639 | train | function (val) {
var value;
try {
value = JSON.parse(val);
}
catch (e) {
value = undefined;
}
return Array.isArray(value) ? value : undefined;
} | javascript | {
"resource": ""
} | |
q44640 | train | function (obj) {
return Boolean(obj) && ((obj instanceof CookieList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', CookieList._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44641 | train | 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 ... | javascript | {
"resource": ""
} | |
q44642 | train | 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 && ... | javascript | {
"resource": ""
} | |
q44643 | train | function (property, customizer) {
var owner = this.findParentContaining(property, customizer);
return owner ? owner[property] : undefined;
} | javascript | {
"resource": ""
} | |
q44644 | train | 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 pare... | javascript | {
"resource": ""
} | |
q44645 | train | function () {
return arguments.length ? _.pick(this._, Array.prototype.slice.apply(arguments)) : _.cloneDeep(this._);
} | javascript | {
"resource": ""
} | |
q44646 | train | 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 for... | javascript | {
"resource": ""
} | |
q44647 | train | 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 &&... | javascript | {
"resource": ""
} | |
q44648 | train | function (obj) {
return Boolean(obj) && ((obj instanceof ProxyConfigList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', ProxyConfigList._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44649 | train | 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);
... | javascript | {
"resource": ""
} | |
q44650 | train | 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 a... | javascript | {
"resource": ""
} | |
q44651 | train | 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... | javascript | {
"resource": ""
} | |
q44652 | train | 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 =... | javascript | {
"resource": ""
} | |
q44653 | train | 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).fo... | javascript | {
"resource": ""
} | |
q44654 | train | 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 populati... | javascript | {
"resource": ""
} | |
q44655 | train | 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)) {
... | javascript | {
"resource": ""
} | |
q44656 | train | 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 | {
"resource": ""
} | |
q44657 | train | function (iterator, context) {
_.forEach(this.members, _.isFunction(iterator) ? iterator.bind(context || this.__parent) : iterator);
} | javascript | {
"resource": ""
} | |
q44658 | train | function (rule, context) {
return _.find(this.members, _.isFunction(rule) && _.isObject(context) ? rule.bind(context) : rule);
} | javascript | {
"resource": ""
} | |
q44659 | train | function (iterator, context) {
return _.map(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator);
} | javascript | {
"resource": ""
} | |
q44660 | train | function (iterator, accumulator, context) {
return _.reduce(this.members, _.isFunction(iterator) ? iterator.bind(context || this) : iterator, accumulator);
} | javascript | {
"resource": ""
} | |
q44661 | train | function (item) {
return this.members.indexOf(_.isString(item) ? (item = this.one(item)) : item);
} | javascript | {
"resource": ""
} | |
q44662 | train | 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;
});
//... | javascript | {
"resource": ""
} | |
q44663 | train | 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 an... | javascript | {
"resource": ""
} | |
q44664 | train | 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,
sensi... | javascript | {
"resource": ""
} | |
q44665 | train | function () {
if (this.Type.unparse) {
return this.Type.unparse(this.members);
}
return this.constructor ? this.constructor.prototype.toString.call(this) : '';
} | javascript | {
"resource": ""
} | |
q44666 | train | function (obj) {
return Boolean(obj) && ((obj instanceof PropertyList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', PropertyList._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44667 | train | 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 h... | javascript | {
"resource": ""
} | |
q44668 | train | 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
... | javascript | {
"resource": ""
} | |
q44669 | train | 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.... | javascript | {
"resource": ""
} | |
q44670 | train | function (params) {
params = _.isString(params) ? QueryParam.parse(params) : params;
this.query.populate(params);
} | javascript | {
"resource": ""
} | |
q44671 | train | 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 | {
"resource": ""
} | |
q44672 | train | 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 | {
"resource": ""
} | |
q44673 | train | 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 | {
"resource": ""
} | |
q44674 | train | function () {
if (!this.host) {
return E;
}
return _.isArray(this.host) ? this.host.join(DOMAIN_SEPARATOR) : this.host.toString();
} | javascript | {
"resource": ""
} | |
q44675 | train | function (obj) {
return Boolean(obj) && ((obj instanceof Url) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Url._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44676 | train | 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, 'syste... | javascript | {
"resource": ""
} | |
q44677 | train | function (query) {
return _.isString(query) ? query.split(AMPERSAND).map(QueryParam.parseSingle) : [];
} | javascript | {
"resource": ""
} | |
q44678 | train | 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))... | javascript | {
"resource": ""
} | |
q44679 | train | 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 ? urlEn... | javascript | {
"resource": ""
} | |
q44680 | train | 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(conte... | javascript | {
"resource": ""
} | |
q44681 | train | 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.... | javascript | {
"resource": ""
} | |
q44682 | train | 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), ... | javascript | {
"resource": ""
} | |
q44683 | train | function (obj, name, Prop, fallback) {
return _.has(obj, name) ? (new Prop(obj[name])) : fallback;
} | javascript | {
"resource": ""
} | |
q44684 | train | function (target, source) {
var key;
for (key in source) {
if (source.hasOwnProperty(key) && !_.isUndefined(source[key])) {
target[key] = source[key];
}
}
return target;
} | javascript | {
"resource": ""
} | |
q44685 | train | function (obj, prop, def) {
return _.has(obj, prop) ? obj[prop] : def;
} | javascript | {
"resource": ""
} | |
q44686 | train | 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 | {
"resource": ""
} | |
q44687 | train | function (obj, key, value) {
return obj ? ((obj[key] === value) || _.inSuperChain(obj.super_, key, value)) : false;
} | javascript | {
"resource": ""
} | |
q44688 | train | function (obj) {
return Boolean(obj) && ((obj instanceof Cookie) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Cookie._postman_propertyName));
} | javascript | {
"resource": ""
} | |
q44689 | train | 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 = n... | javascript | {
"resource": ""
} | |
q44690 | train | 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 | {
"resource": ""
} | |
q44691 | train | 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... | javascript | {
"resource": ""
} | |
q44692 | train | 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.urlencode... | javascript | {
"resource": ""
} | |
q44693 | train | 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
//... | javascript | {
"resource": ""
} | |
q44694 | train | 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) ? ... | javascript | {
"resource": ""
} | |
q44695 | train | 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;
... | javascript | {
"resource": ""
} | |
q44696 | train | 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.r... | javascript | {
"resource": ""
} | |
q44697 | train | 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;
}
... | javascript | {
"resource": ""
} | |
q44698 | getHeaders | train | 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.head... | javascript | {
"resource": ""
} |
q44699 | train | 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 (h... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.