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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,900 | panuhorsmalahti/gulp-tslint | index.js | function () {
// Throw error
if (options && errorFiles.length > 0) {
var failuresToOutput = allFailures;
var ignoreFailureCount = 0;
// If error count is limited, calculate number of errors not shown and slice reportLimit
// number of errors to be included in the error.
if (options.reportLimit > 0) {
ignoreFailureCount = allFailures.length - options.reportLimit;
failuresToOutput = allFailures.slice(0, options.reportLimit);
}
// Always use the proseErrorFormat for the error.
var failureOutput = failuresToOutput.map(function (failure) {
return proseErrorFormat(failure);
}).join(", ");
var errorOutput = "Failed to lint: ";
if (options.summarizeFailureOutput) {
errorOutput += failuresToOutput.length + " errors.";
}
else {
errorOutput += failureOutput + ".";
}
if (ignoreFailureCount > 0) {
errorOutput += " (" + ignoreFailureCount + " other errors not shown.)";
}
if (options.emitError === true) {
return this.emit("error", new PluginError("gulp-tslint", errorOutput));
}
else if (options.summarizeFailureOutput) {
log(errorOutput);
}
}
// Notify through that we're done
this.emit("end");
} | javascript | function () {
// Throw error
if (options && errorFiles.length > 0) {
var failuresToOutput = allFailures;
var ignoreFailureCount = 0;
// If error count is limited, calculate number of errors not shown and slice reportLimit
// number of errors to be included in the error.
if (options.reportLimit > 0) {
ignoreFailureCount = allFailures.length - options.reportLimit;
failuresToOutput = allFailures.slice(0, options.reportLimit);
}
// Always use the proseErrorFormat for the error.
var failureOutput = failuresToOutput.map(function (failure) {
return proseErrorFormat(failure);
}).join(", ");
var errorOutput = "Failed to lint: ";
if (options.summarizeFailureOutput) {
errorOutput += failuresToOutput.length + " errors.";
}
else {
errorOutput += failureOutput + ".";
}
if (ignoreFailureCount > 0) {
errorOutput += " (" + ignoreFailureCount + " other errors not shown.)";
}
if (options.emitError === true) {
return this.emit("error", new PluginError("gulp-tslint", errorOutput));
}
else if (options.summarizeFailureOutput) {
log(errorOutput);
}
}
// Notify through that we're done
this.emit("end");
} | [
"function",
"(",
")",
"{",
"// Throw error",
"if",
"(",
"options",
"&&",
"errorFiles",
".",
"length",
">",
"0",
")",
"{",
"var",
"failuresToOutput",
"=",
"allFailures",
";",
"var",
"ignoreFailureCount",
"=",
"0",
";",
"// If error count is limited, calculate number of errors not shown and slice reportLimit",
"// number of errors to be included in the error.",
"if",
"(",
"options",
".",
"reportLimit",
">",
"0",
")",
"{",
"ignoreFailureCount",
"=",
"allFailures",
".",
"length",
"-",
"options",
".",
"reportLimit",
";",
"failuresToOutput",
"=",
"allFailures",
".",
"slice",
"(",
"0",
",",
"options",
".",
"reportLimit",
")",
";",
"}",
"// Always use the proseErrorFormat for the error.",
"var",
"failureOutput",
"=",
"failuresToOutput",
".",
"map",
"(",
"function",
"(",
"failure",
")",
"{",
"return",
"proseErrorFormat",
"(",
"failure",
")",
";",
"}",
")",
".",
"join",
"(",
"\", \"",
")",
";",
"var",
"errorOutput",
"=",
"\"Failed to lint: \"",
";",
"if",
"(",
"options",
".",
"summarizeFailureOutput",
")",
"{",
"errorOutput",
"+=",
"failuresToOutput",
".",
"length",
"+",
"\" errors.\"",
";",
"}",
"else",
"{",
"errorOutput",
"+=",
"failureOutput",
"+",
"\".\"",
";",
"}",
"if",
"(",
"ignoreFailureCount",
">",
"0",
")",
"{",
"errorOutput",
"+=",
"\" (\"",
"+",
"ignoreFailureCount",
"+",
"\" other errors not shown.)\"",
";",
"}",
"if",
"(",
"options",
".",
"emitError",
"===",
"true",
")",
"{",
"return",
"this",
".",
"emit",
"(",
"\"error\"",
",",
"new",
"PluginError",
"(",
"\"gulp-tslint\"",
",",
"errorOutput",
")",
")",
";",
"}",
"else",
"if",
"(",
"options",
".",
"summarizeFailureOutput",
")",
"{",
"log",
"(",
"errorOutput",
")",
";",
"}",
"}",
"// Notify through that we're done",
"this",
".",
"emit",
"(",
"\"end\"",
")",
";",
"}"
] | After reporting on all files, throw the error. | [
"After",
"reporting",
"on",
"all",
"files",
"throw",
"the",
"error",
"."
] | bdea3ff458044129f40df91874efc07866e68b65 | https://github.com/panuhorsmalahti/gulp-tslint/blob/bdea3ff458044129f40df91874efc07866e68b65/index.js#L179-L213 | |
20,901 | itemslide/itemslide.github.io | src/navigation.js | touchend | function touchend(e) {
if (isDown) {
isDown = false;
var touch;
if (e.type == 'touchend') //Check for touch event or mousemove
touch = getTouch(e);
else
touch = e;
$(window).off('mousemove touchmove', mousemove); //Stop listening for the mousemove event
//Check if vertical panning (swipe out) or horizontal panning (carousel swipe)
//Vertical PANNING
if (vertical_pan && options.swipe_out) {
//HAPPENS WHEN SWIPEOUT
vertical_pan = false; //Back to false for mousewheel (Vertical pan has finished so enable mousewheel scrolling)
swipeOut();
return;
} //Veritcal Pan
else if ($el.end_animation && !options.disable_slide) { //if finished animation of sliding and swiping is not disabled
//Calculate deltaTime for calculation of velocity
var deltaTime = (Date.now() - swipeStartTime);
//Verify delta is > 0 to avoid divide by 0 error
deltaTime++;
vars.velocity = -(touch.pageX - startPointX) / deltaTime;
if (vars.velocity > 0) { //Set direction
vars.direction = 1; //PAN LEFT
} else {
vars.direction = -1;
}
vars.distanceFromStart = (touch.pageX - startPointX) * vars.direction * -1; //Yaaa SOOO
var landingSlideIndex = anim.getLandingSlideIndex(vars.velocity * options.swipe_sensitivity - $el.translate3d().x);
//TAP is when deltaX is less or equal to 12px
if (vars.distanceFromStart > 6) {
anim.gotoSlideByIndex(landingSlideIndex);
return;
}
} //Regular horizontal pan until here
//TAP - click to slide
$el.trigger({
type: "clickSlide",
slide: $el.savedSlideIndex
});
if ($el.savedSlideIndex != vars.currentIndex && !options.disable_clicktoslide) { //If this occurs then its a tap
e.preventDefault();
anim.gotoSlideByIndex($el.savedSlideIndex);
}
//TAP until here
}
} | javascript | function touchend(e) {
if (isDown) {
isDown = false;
var touch;
if (e.type == 'touchend') //Check for touch event or mousemove
touch = getTouch(e);
else
touch = e;
$(window).off('mousemove touchmove', mousemove); //Stop listening for the mousemove event
//Check if vertical panning (swipe out) or horizontal panning (carousel swipe)
//Vertical PANNING
if (vertical_pan && options.swipe_out) {
//HAPPENS WHEN SWIPEOUT
vertical_pan = false; //Back to false for mousewheel (Vertical pan has finished so enable mousewheel scrolling)
swipeOut();
return;
} //Veritcal Pan
else if ($el.end_animation && !options.disable_slide) { //if finished animation of sliding and swiping is not disabled
//Calculate deltaTime for calculation of velocity
var deltaTime = (Date.now() - swipeStartTime);
//Verify delta is > 0 to avoid divide by 0 error
deltaTime++;
vars.velocity = -(touch.pageX - startPointX) / deltaTime;
if (vars.velocity > 0) { //Set direction
vars.direction = 1; //PAN LEFT
} else {
vars.direction = -1;
}
vars.distanceFromStart = (touch.pageX - startPointX) * vars.direction * -1; //Yaaa SOOO
var landingSlideIndex = anim.getLandingSlideIndex(vars.velocity * options.swipe_sensitivity - $el.translate3d().x);
//TAP is when deltaX is less or equal to 12px
if (vars.distanceFromStart > 6) {
anim.gotoSlideByIndex(landingSlideIndex);
return;
}
} //Regular horizontal pan until here
//TAP - click to slide
$el.trigger({
type: "clickSlide",
slide: $el.savedSlideIndex
});
if ($el.savedSlideIndex != vars.currentIndex && !options.disable_clicktoslide) { //If this occurs then its a tap
e.preventDefault();
anim.gotoSlideByIndex($el.savedSlideIndex);
}
//TAP until here
}
} | [
"function",
"touchend",
"(",
"e",
")",
"{",
"if",
"(",
"isDown",
")",
"{",
"isDown",
"=",
"false",
";",
"var",
"touch",
";",
"if",
"(",
"e",
".",
"type",
"==",
"'touchend'",
")",
"//Check for touch event or mousemove",
"touch",
"=",
"getTouch",
"(",
"e",
")",
";",
"else",
"touch",
"=",
"e",
";",
"$",
"(",
"window",
")",
".",
"off",
"(",
"'mousemove touchmove'",
",",
"mousemove",
")",
";",
"//Stop listening for the mousemove event",
"//Check if vertical panning (swipe out) or horizontal panning (carousel swipe)",
"//Vertical PANNING",
"if",
"(",
"vertical_pan",
"&&",
"options",
".",
"swipe_out",
")",
"{",
"//HAPPENS WHEN SWIPEOUT",
"vertical_pan",
"=",
"false",
";",
"//Back to false for mousewheel (Vertical pan has finished so enable mousewheel scrolling)",
"swipeOut",
"(",
")",
";",
"return",
";",
"}",
"//Veritcal Pan",
"else",
"if",
"(",
"$el",
".",
"end_animation",
"&&",
"!",
"options",
".",
"disable_slide",
")",
"{",
"//if finished animation of sliding and swiping is not disabled",
"//Calculate deltaTime for calculation of velocity",
"var",
"deltaTime",
"=",
"(",
"Date",
".",
"now",
"(",
")",
"-",
"swipeStartTime",
")",
";",
"//Verify delta is > 0 to avoid divide by 0 error",
"deltaTime",
"++",
";",
"vars",
".",
"velocity",
"=",
"-",
"(",
"touch",
".",
"pageX",
"-",
"startPointX",
")",
"/",
"deltaTime",
";",
"if",
"(",
"vars",
".",
"velocity",
">",
"0",
")",
"{",
"//Set direction",
"vars",
".",
"direction",
"=",
"1",
";",
"//PAN LEFT",
"}",
"else",
"{",
"vars",
".",
"direction",
"=",
"-",
"1",
";",
"}",
"vars",
".",
"distanceFromStart",
"=",
"(",
"touch",
".",
"pageX",
"-",
"startPointX",
")",
"*",
"vars",
".",
"direction",
"*",
"-",
"1",
";",
"//Yaaa SOOO",
"var",
"landingSlideIndex",
"=",
"anim",
".",
"getLandingSlideIndex",
"(",
"vars",
".",
"velocity",
"*",
"options",
".",
"swipe_sensitivity",
"-",
"$el",
".",
"translate3d",
"(",
")",
".",
"x",
")",
";",
"//TAP is when deltaX is less or equal to 12px",
"if",
"(",
"vars",
".",
"distanceFromStart",
">",
"6",
")",
"{",
"anim",
".",
"gotoSlideByIndex",
"(",
"landingSlideIndex",
")",
";",
"return",
";",
"}",
"}",
"//Regular horizontal pan until here",
"//TAP - click to slide",
"$el",
".",
"trigger",
"(",
"{",
"type",
":",
"\"clickSlide\"",
",",
"slide",
":",
"$el",
".",
"savedSlideIndex",
"}",
")",
";",
"if",
"(",
"$el",
".",
"savedSlideIndex",
"!=",
"vars",
".",
"currentIndex",
"&&",
"!",
"options",
".",
"disable_clicktoslide",
")",
"{",
"//If this occurs then its a tap",
"e",
".",
"preventDefault",
"(",
")",
";",
"anim",
".",
"gotoSlideByIndex",
"(",
"$el",
".",
"savedSlideIndex",
")",
";",
"}",
"//TAP until here",
"}",
"}"
] | END OF MOUSEMOVE | [
"END",
"OF",
"MOUSEMOVE"
] | e18300b40722e27ea69bb39e2691122f4b78acdb | https://github.com/itemslide/itemslide.github.io/blob/e18300b40722e27ea69bb39e2691122f4b78acdb/src/navigation.js#L201-L269 |
20,902 | jieter/Leaflet-semicircle | piechart/Pie.js | function (map) {
this._parts = [];
var startAngle = 0;
var stopAngle = 0;
this.addTo(map);
for (var i = 0; i < this.count(); i++) {
var normalized = this._normalize(this._data[i].num);
stopAngle = normalized * 360 + startAngle;
// set start/stop Angle and color for semicircle
var options = L.extend({
startAngle: startAngle,
stopAngle: stopAngle,
radius: this.options.radius,
fillColor: this._color(i),
color: this._color(i)
}, this.options.sliceOptions);
this._data[i].slice = L.semiCircle(
this._latlng,
L.Util.extend({}, options, this.options.pathOptions)
).addTo(this);
if (this.options.labels) {
this._createLabel(normalized, this._data[i].label, this._data[i].slice);
}
startAngle = stopAngle;
}
return this;
} | javascript | function (map) {
this._parts = [];
var startAngle = 0;
var stopAngle = 0;
this.addTo(map);
for (var i = 0; i < this.count(); i++) {
var normalized = this._normalize(this._data[i].num);
stopAngle = normalized * 360 + startAngle;
// set start/stop Angle and color for semicircle
var options = L.extend({
startAngle: startAngle,
stopAngle: stopAngle,
radius: this.options.radius,
fillColor: this._color(i),
color: this._color(i)
}, this.options.sliceOptions);
this._data[i].slice = L.semiCircle(
this._latlng,
L.Util.extend({}, options, this.options.pathOptions)
).addTo(this);
if (this.options.labels) {
this._createLabel(normalized, this._data[i].label, this._data[i].slice);
}
startAngle = stopAngle;
}
return this;
} | [
"function",
"(",
"map",
")",
"{",
"this",
".",
"_parts",
"=",
"[",
"]",
";",
"var",
"startAngle",
"=",
"0",
";",
"var",
"stopAngle",
"=",
"0",
";",
"this",
".",
"addTo",
"(",
"map",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"count",
"(",
")",
";",
"i",
"++",
")",
"{",
"var",
"normalized",
"=",
"this",
".",
"_normalize",
"(",
"this",
".",
"_data",
"[",
"i",
"]",
".",
"num",
")",
";",
"stopAngle",
"=",
"normalized",
"*",
"360",
"+",
"startAngle",
";",
"// set start/stop Angle and color for semicircle",
"var",
"options",
"=",
"L",
".",
"extend",
"(",
"{",
"startAngle",
":",
"startAngle",
",",
"stopAngle",
":",
"stopAngle",
",",
"radius",
":",
"this",
".",
"options",
".",
"radius",
",",
"fillColor",
":",
"this",
".",
"_color",
"(",
"i",
")",
",",
"color",
":",
"this",
".",
"_color",
"(",
"i",
")",
"}",
",",
"this",
".",
"options",
".",
"sliceOptions",
")",
";",
"this",
".",
"_data",
"[",
"i",
"]",
".",
"slice",
"=",
"L",
".",
"semiCircle",
"(",
"this",
".",
"_latlng",
",",
"L",
".",
"Util",
".",
"extend",
"(",
"{",
"}",
",",
"options",
",",
"this",
".",
"options",
".",
"pathOptions",
")",
")",
".",
"addTo",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"options",
".",
"labels",
")",
"{",
"this",
".",
"_createLabel",
"(",
"normalized",
",",
"this",
".",
"_data",
"[",
"i",
"]",
".",
"label",
",",
"this",
".",
"_data",
"[",
"i",
"]",
".",
"slice",
")",
";",
"}",
"startAngle",
"=",
"stopAngle",
";",
"}",
"return",
"this",
";",
"}"
] | layer implementation. | [
"layer",
"implementation",
"."
] | 53b4b6c7b93f49c6e95fece63310b8697e77b365 | https://github.com/jieter/Leaflet-semicircle/blob/53b4b6c7b93f49c6e95fece63310b8697e77b365/piechart/Pie.js#L114-L147 | |
20,903 | emberjs/ember-mocha | vendor/ember-mocha/ember-mocha-adapter.js | complete | function complete(e) {
clearTimeout(doneTimeout);
if (!done) { return; }
var d = done;
done = null;
if (e) {
// test failure
if (!(e instanceof Error)) {
e = new Error(e);
}
d(e);
} else {
// test passed
d();
}
} | javascript | function complete(e) {
clearTimeout(doneTimeout);
if (!done) { return; }
var d = done;
done = null;
if (e) {
// test failure
if (!(e instanceof Error)) {
e = new Error(e);
}
d(e);
} else {
// test passed
d();
}
} | [
"function",
"complete",
"(",
"e",
")",
"{",
"clearTimeout",
"(",
"doneTimeout",
")",
";",
"if",
"(",
"!",
"done",
")",
"{",
"return",
";",
"}",
"var",
"d",
"=",
"done",
";",
"done",
"=",
"null",
";",
"if",
"(",
"e",
")",
"{",
"// test failure",
"if",
"(",
"!",
"(",
"e",
"instanceof",
"Error",
")",
")",
"{",
"e",
"=",
"new",
"Error",
"(",
"e",
")",
";",
"}",
"d",
"(",
"e",
")",
";",
"}",
"else",
"{",
"// test passed",
"d",
"(",
")",
";",
"}",
"}"
] | Called whenever an async test passes or fails. if `e` is passed, that means the test failed with exception `e` | [
"Called",
"whenever",
"an",
"async",
"test",
"passes",
"or",
"fails",
".",
"if",
"e",
"is",
"passed",
"that",
"means",
"the",
"test",
"failed",
"with",
"exception",
"e"
] | 196ed7ee0ba98385b01ffdccf5a01da581b02580 | https://github.com/emberjs/ember-mocha/blob/196ed7ee0ba98385b01ffdccf5a01da581b02580/vendor/ember-mocha/ember-mocha-adapter.js#L83-L98 |
20,904 | evothings/phonegap-estimotebeacons | examples/beacon-finder/www/js/screen-live-development.js | parseConnectAddress | function parseConnectAddress(address)
{
var url = address.trim();
if (!url.match('^https?://[A-Z0-9\.]*.*$'))
{
// Add protocol.
url = 'http://' + url;
}
if (url.match('^https?://[0-9\.]*$') &&
!url.match('^https?://[0-9\.]*:[0-9]*$'))
{
// Add port to numeric ip address.
url = url + ':4042';
}
return url;
} | javascript | function parseConnectAddress(address)
{
var url = address.trim();
if (!url.match('^https?://[A-Z0-9\.]*.*$'))
{
// Add protocol.
url = 'http://' + url;
}
if (url.match('^https?://[0-9\.]*$') &&
!url.match('^https?://[0-9\.]*:[0-9]*$'))
{
// Add port to numeric ip address.
url = url + ':4042';
}
return url;
} | [
"function",
"parseConnectAddress",
"(",
"address",
")",
"{",
"var",
"url",
"=",
"address",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"url",
".",
"match",
"(",
"'^https?://[A-Z0-9\\.]*.*$'",
")",
")",
"{",
"// Add protocol.",
"url",
"=",
"'http://'",
"+",
"url",
";",
"}",
"if",
"(",
"url",
".",
"match",
"(",
"'^https?://[0-9\\.]*$'",
")",
"&&",
"!",
"url",
".",
"match",
"(",
"'^https?://[0-9\\.]*:[0-9]*$'",
")",
")",
"{",
"// Add port to numeric ip address.",
"url",
"=",
"url",
"+",
"':4042'",
";",
"}",
"return",
"url",
";",
"}"
] | Add protocol and port if needed. | [
"Add",
"protocol",
"and",
"port",
"if",
"needed",
"."
] | eed09405b5435a0b9e76e9094f52350991c51b91 | https://github.com/evothings/phonegap-estimotebeacons/blob/eed09405b5435a0b9e76e9094f52350991c51b91/examples/beacon-finder/www/js/screen-live-development.js#L13-L31 |
20,905 | evothings/phonegap-estimotebeacons | plugin/src/js/EstimoteBeacons.js | helper_createTriggerObject | function helper_createTriggerObject(trigger)
{
var triggerObject = {};
triggerObject.triggerIdentifier = trigger.identifier;
triggerObject.rules = [];
for (var i = 0; i < trigger.rules.length; ++i)
{
var rule = trigger.rules[i];
triggerObject.rules.push({
ruleType: rule.ruleType,
ruleIdentifier: rule.ruleIdentifier,
nearableIdentifier: rule.nearableIdentifier,
nearableType: rule.nearableType });
}
return triggerObject;
} | javascript | function helper_createTriggerObject(trigger)
{
var triggerObject = {};
triggerObject.triggerIdentifier = trigger.identifier;
triggerObject.rules = [];
for (var i = 0; i < trigger.rules.length; ++i)
{
var rule = trigger.rules[i];
triggerObject.rules.push({
ruleType: rule.ruleType,
ruleIdentifier: rule.ruleIdentifier,
nearableIdentifier: rule.nearableIdentifier,
nearableType: rule.nearableType });
}
return triggerObject;
} | [
"function",
"helper_createTriggerObject",
"(",
"trigger",
")",
"{",
"var",
"triggerObject",
"=",
"{",
"}",
";",
"triggerObject",
".",
"triggerIdentifier",
"=",
"trigger",
".",
"identifier",
";",
"triggerObject",
".",
"rules",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"trigger",
".",
"rules",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"rule",
"=",
"trigger",
".",
"rules",
"[",
"i",
"]",
";",
"triggerObject",
".",
"rules",
".",
"push",
"(",
"{",
"ruleType",
":",
"rule",
".",
"ruleType",
",",
"ruleIdentifier",
":",
"rule",
".",
"ruleIdentifier",
",",
"nearableIdentifier",
":",
"rule",
".",
"nearableIdentifier",
",",
"nearableType",
":",
"rule",
".",
"nearableType",
"}",
")",
";",
"}",
"return",
"triggerObject",
";",
"}"
] | Helper function that creates an internal 'lightweight'
trigger object sent to the native side.
@private | [
"Helper",
"function",
"that",
"creates",
"an",
"internal",
"lightweight",
"trigger",
"object",
"sent",
"to",
"the",
"native",
"side",
"."
] | eed09405b5435a0b9e76e9094f52350991c51b91 | https://github.com/evothings/phonegap-estimotebeacons/blob/eed09405b5435a0b9e76e9094f52350991c51b91/plugin/src/js/EstimoteBeacons.js#L1517-L1535 |
20,906 | evothings/phonegap-estimotebeacons | plugin/src/js/EstimoteBeacons.js | helper_updateTriggerRule | function helper_updateTriggerRule(trigger, event)
{
var rule = trigger.ruleTable[event.ruleIdentifier];
if (rule && rule.ruleUpdateFunction)
{
rule.ruleUpdateFunction(rule, event.nearable, event);
helper_updateRuleState(
event.triggerIdentifier,
event.ruleIdentifier,
rule.state);
}
} | javascript | function helper_updateTriggerRule(trigger, event)
{
var rule = trigger.ruleTable[event.ruleIdentifier];
if (rule && rule.ruleUpdateFunction)
{
rule.ruleUpdateFunction(rule, event.nearable, event);
helper_updateRuleState(
event.triggerIdentifier,
event.ruleIdentifier,
rule.state);
}
} | [
"function",
"helper_updateTriggerRule",
"(",
"trigger",
",",
"event",
")",
"{",
"var",
"rule",
"=",
"trigger",
".",
"ruleTable",
"[",
"event",
".",
"ruleIdentifier",
"]",
";",
"if",
"(",
"rule",
"&&",
"rule",
".",
"ruleUpdateFunction",
")",
"{",
"rule",
".",
"ruleUpdateFunction",
"(",
"rule",
",",
"event",
".",
"nearable",
",",
"event",
")",
";",
"helper_updateRuleState",
"(",
"event",
".",
"triggerIdentifier",
",",
"event",
".",
"ruleIdentifier",
",",
"rule",
".",
"state",
")",
";",
"}",
"}"
] | Helper function that calls the update function of the rule
related to the event and then updates the native rule state.
@private | [
"Helper",
"function",
"that",
"calls",
"the",
"update",
"function",
"of",
"the",
"rule",
"related",
"to",
"the",
"event",
"and",
"then",
"updates",
"the",
"native",
"rule",
"state",
"."
] | eed09405b5435a0b9e76e9094f52350991c51b91 | https://github.com/evothings/phonegap-estimotebeacons/blob/eed09405b5435a0b9e76e9094f52350991c51b91/plugin/src/js/EstimoteBeacons.js#L1542-L1553 |
20,907 | evothings/phonegap-estimotebeacons | plugin/src/js/EstimoteBeacons.js | helper_updateRuleState | function helper_updateRuleState(triggerIdentifier, ruleIdentifier, state)
{
exec(null,
null,
'EstimoteBeacons',
'triggers_updateRuleState',
[triggerIdentifier, ruleIdentifier, state]
);
} | javascript | function helper_updateRuleState(triggerIdentifier, ruleIdentifier, state)
{
exec(null,
null,
'EstimoteBeacons',
'triggers_updateRuleState',
[triggerIdentifier, ruleIdentifier, state]
);
} | [
"function",
"helper_updateRuleState",
"(",
"triggerIdentifier",
",",
"ruleIdentifier",
",",
"state",
")",
"{",
"exec",
"(",
"null",
",",
"null",
",",
"'EstimoteBeacons'",
",",
"'triggers_updateRuleState'",
",",
"[",
"triggerIdentifier",
",",
"ruleIdentifier",
",",
"state",
"]",
")",
";",
"}"
] | Helper function used to update the state of a native rule
during an update event.
@param event Event object passed to the event update function.
@param state true if rule holds, false if rule does not hold.
@private | [
"Helper",
"function",
"used",
"to",
"update",
"the",
"state",
"of",
"a",
"native",
"rule",
"during",
"an",
"update",
"event",
"."
] | eed09405b5435a0b9e76e9094f52350991c51b91 | https://github.com/evothings/phonegap-estimotebeacons/blob/eed09405b5435a0b9e76e9094f52350991c51b91/plugin/src/js/EstimoteBeacons.js#L1562-L1570 |
20,908 | thedersen/backbone.validation | dist/backbone-validation.js | function(model, attrs) {
attrs = attrs || _.keys(_.result(model, 'validation') || {});
return _.reduce(attrs, function(memo, key) {
memo[key] = void 0;
return memo;
}, {});
} | javascript | function(model, attrs) {
attrs = attrs || _.keys(_.result(model, 'validation') || {});
return _.reduce(attrs, function(memo, key) {
memo[key] = void 0;
return memo;
}, {});
} | [
"function",
"(",
"model",
",",
"attrs",
")",
"{",
"attrs",
"=",
"attrs",
"||",
"_",
".",
"keys",
"(",
"_",
".",
"result",
"(",
"model",
",",
"'validation'",
")",
"||",
"{",
"}",
")",
";",
"return",
"_",
".",
"reduce",
"(",
"attrs",
",",
"function",
"(",
"memo",
",",
"key",
")",
"{",
"memo",
"[",
"key",
"]",
"=",
"void",
"0",
";",
"return",
"memo",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Returns an object with undefined properties for all attributes on the model that has defined one or more validation rules. | [
"Returns",
"an",
"object",
"with",
"undefined",
"properties",
"for",
"all",
"attributes",
"on",
"the",
"model",
"that",
"has",
"defined",
"one",
"or",
"more",
"validation",
"rules",
"."
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L109-L115 | |
20,909 | thedersen/backbone.validation | dist/backbone-validation.js | function(attr, value) {
var self = this,
result = {},
error;
if(_.isObject(attr)){
_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if(error){
result[key] = error;
}
});
return _.isEmpty(result) ? undefined : result;
}
else {
return validateAttr(this, attr, value, _.extend({}, this.attributes));
}
} | javascript | function(attr, value) {
var self = this,
result = {},
error;
if(_.isObject(attr)){
_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if(error){
result[key] = error;
}
});
return _.isEmpty(result) ? undefined : result;
}
else {
return validateAttr(this, attr, value, _.extend({}, this.attributes));
}
} | [
"function",
"(",
"attr",
",",
"value",
")",
"{",
"var",
"self",
"=",
"this",
",",
"result",
"=",
"{",
"}",
",",
"error",
";",
"if",
"(",
"_",
".",
"isObject",
"(",
"attr",
")",
")",
"{",
"_",
".",
"each",
"(",
"attr",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"error",
"=",
"self",
".",
"preValidate",
"(",
"key",
",",
"value",
")",
";",
"if",
"(",
"error",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"error",
";",
"}",
"}",
")",
";",
"return",
"_",
".",
"isEmpty",
"(",
"result",
")",
"?",
"undefined",
":",
"result",
";",
"}",
"else",
"{",
"return",
"validateAttr",
"(",
"this",
",",
"attr",
",",
"value",
",",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"attributes",
")",
")",
";",
"}",
"}"
] | Check whether or not a value, or a hash of values passes validation without updating the model | [
"Check",
"whether",
"or",
"not",
"a",
"value",
"or",
"a",
"hash",
"of",
"values",
"passes",
"validation",
"without",
"updating",
"the",
"model"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L217-L235 | |
20,910 | thedersen/backbone.validation | dist/backbone-validation.js | function(view, model, options) {
if (model.associatedViews) {
model.associatedViews.push(view);
} else {
model.associatedViews = [view];
}
_.extend(model, mixin(view, options));
} | javascript | function(view, model, options) {
if (model.associatedViews) {
model.associatedViews.push(view);
} else {
model.associatedViews = [view];
}
_.extend(model, mixin(view, options));
} | [
"function",
"(",
"view",
",",
"model",
",",
"options",
")",
"{",
"if",
"(",
"model",
".",
"associatedViews",
")",
"{",
"model",
".",
"associatedViews",
".",
"push",
"(",
"view",
")",
";",
"}",
"else",
"{",
"model",
".",
"associatedViews",
"=",
"[",
"view",
"]",
";",
"}",
"_",
".",
"extend",
"(",
"model",
",",
"mixin",
"(",
"view",
",",
"options",
")",
")",
";",
"}"
] | Helper to mix in validation on a model. Stores the view in the associated views array. | [
"Helper",
"to",
"mix",
"in",
"validation",
"on",
"a",
"model",
".",
"Stores",
"the",
"view",
"in",
"the",
"associated",
"views",
"array",
"."
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L328-L335 | |
20,911 | thedersen/backbone.validation | dist/backbone-validation.js | function(model, view) {
if (view && model.associatedViews && model.associatedViews.length > 1){
model.associatedViews = _.without(model.associatedViews, view);
} else {
delete model.validate;
delete model.preValidate;
delete model.isValid;
delete model.associatedViews;
}
} | javascript | function(model, view) {
if (view && model.associatedViews && model.associatedViews.length > 1){
model.associatedViews = _.without(model.associatedViews, view);
} else {
delete model.validate;
delete model.preValidate;
delete model.isValid;
delete model.associatedViews;
}
} | [
"function",
"(",
"model",
",",
"view",
")",
"{",
"if",
"(",
"view",
"&&",
"model",
".",
"associatedViews",
"&&",
"model",
".",
"associatedViews",
".",
"length",
">",
"1",
")",
"{",
"model",
".",
"associatedViews",
"=",
"_",
".",
"without",
"(",
"model",
".",
"associatedViews",
",",
"view",
")",
";",
"}",
"else",
"{",
"delete",
"model",
".",
"validate",
";",
"delete",
"model",
".",
"preValidate",
";",
"delete",
"model",
".",
"isValid",
";",
"delete",
"model",
".",
"associatedViews",
";",
"}",
"}"
] | Removes view from associated views of the model or the methods added to a model if no view or single view provided | [
"Removes",
"view",
"from",
"associated",
"views",
"of",
"the",
"model",
"or",
"the",
"methods",
"added",
"to",
"a",
"model",
"if",
"no",
"view",
"or",
"single",
"view",
"provided"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L339-L348 | |
20,912 | thedersen/backbone.validation | dist/backbone-validation.js | function(view, options) {
options = _.extend({}, defaultOptions, defaultCallbacks, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(typeof model === 'undefined' && typeof collection === 'undefined'){
throw 'Before you execute the binding your view must have a model or a collection.\n' +
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
}
if(model) {
bindModel(view, model, options);
}
else if(collection) {
collection.each(function(model){
bindModel(view, model, options);
});
collection.bind('add', collectionAdd, {view: view, options: options});
collection.bind('remove', collectionRemove);
}
} | javascript | function(view, options) {
options = _.extend({}, defaultOptions, defaultCallbacks, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(typeof model === 'undefined' && typeof collection === 'undefined'){
throw 'Before you execute the binding your view must have a model or a collection.\n' +
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
}
if(model) {
bindModel(view, model, options);
}
else if(collection) {
collection.each(function(model){
bindModel(view, model, options);
});
collection.bind('add', collectionAdd, {view: view, options: options});
collection.bind('remove', collectionRemove);
}
} | [
"function",
"(",
"view",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"defaultOptions",
",",
"defaultCallbacks",
",",
"options",
")",
";",
"var",
"model",
"=",
"options",
".",
"model",
"||",
"view",
".",
"model",
",",
"collection",
"=",
"options",
".",
"collection",
"||",
"view",
".",
"collection",
";",
"if",
"(",
"typeof",
"model",
"===",
"'undefined'",
"&&",
"typeof",
"collection",
"===",
"'undefined'",
")",
"{",
"throw",
"'Before you execute the binding your view must have a model or a collection.\\n'",
"+",
"'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.'",
";",
"}",
"if",
"(",
"model",
")",
"{",
"bindModel",
"(",
"view",
",",
"model",
",",
"options",
")",
";",
"}",
"else",
"if",
"(",
"collection",
")",
"{",
"collection",
".",
"each",
"(",
"function",
"(",
"model",
")",
"{",
"bindModel",
"(",
"view",
",",
"model",
",",
"options",
")",
";",
"}",
")",
";",
"collection",
".",
"bind",
"(",
"'add'",
",",
"collectionAdd",
",",
"{",
"view",
":",
"view",
",",
"options",
":",
"options",
"}",
")",
";",
"collection",
".",
"bind",
"(",
"'remove'",
",",
"collectionRemove",
")",
";",
"}",
"}"
] | Hooks up validation on a view with a model or collection | [
"Hooks",
"up",
"validation",
"on",
"a",
"view",
"with",
"a",
"model",
"or",
"collection"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L375-L396 | |
20,913 | thedersen/backbone.validation | dist/backbone-validation.js | function(view, options) {
options = _.extend({}, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(model) {
unbindModel(model, view);
}
else if(collection) {
collection.each(function(model){
unbindModel(model, view);
});
collection.unbind('add', collectionAdd);
collection.unbind('remove', collectionRemove);
}
} | javascript | function(view, options) {
options = _.extend({}, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(model) {
unbindModel(model, view);
}
else if(collection) {
collection.each(function(model){
unbindModel(model, view);
});
collection.unbind('add', collectionAdd);
collection.unbind('remove', collectionRemove);
}
} | [
"function",
"(",
"view",
",",
"options",
")",
"{",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"options",
")",
";",
"var",
"model",
"=",
"options",
".",
"model",
"||",
"view",
".",
"model",
",",
"collection",
"=",
"options",
".",
"collection",
"||",
"view",
".",
"collection",
";",
"if",
"(",
"model",
")",
"{",
"unbindModel",
"(",
"model",
",",
"view",
")",
";",
"}",
"else",
"if",
"(",
"collection",
")",
"{",
"collection",
".",
"each",
"(",
"function",
"(",
"model",
")",
"{",
"unbindModel",
"(",
"model",
",",
"view",
")",
";",
"}",
")",
";",
"collection",
".",
"unbind",
"(",
"'add'",
",",
"collectionAdd",
")",
";",
"collection",
".",
"unbind",
"(",
"'remove'",
",",
"collectionRemove",
")",
";",
"}",
"}"
] | Removes validation from a view with a model or collection | [
"Removes",
"validation",
"from",
"a",
"view",
"with",
"a",
"model",
"or",
"collection"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L400-L415 | |
20,914 | thedersen/backbone.validation | dist/backbone-validation.js | function(view, attr, error, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.addClass('invalid')
.attr('data-error', error);
} | javascript | function(view, attr, error, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.addClass('invalid')
.attr('data-error', error);
} | [
"function",
"(",
"view",
",",
"attr",
",",
"error",
",",
"selector",
")",
"{",
"view",
".",
"$",
"(",
"'['",
"+",
"selector",
"+",
"'~=\"'",
"+",
"attr",
"+",
"'\"]'",
")",
".",
"addClass",
"(",
"'invalid'",
")",
".",
"attr",
"(",
"'data-error'",
",",
"error",
")",
";",
"}"
] | Gets called when a field in the view becomes invalid. Adds a error message. Should be overridden with custom functionality. | [
"Gets",
"called",
"when",
"a",
"field",
"in",
"the",
"view",
"becomes",
"invalid",
".",
"Adds",
"a",
"error",
"message",
".",
"Should",
"be",
"overridden",
"with",
"custom",
"functionality",
"."
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L441-L445 | |
20,915 | thedersen/backbone.validation | dist/backbone-validation.js | function(attrName) {
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
}).replace(/_/g, ' ');
} | javascript | function(attrName) {
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
}).replace(/_/g, ' ');
} | [
"function",
"(",
"attrName",
")",
"{",
"return",
"attrName",
".",
"replace",
"(",
"/",
"(?:^\\w|[A-Z]|\\b\\w)",
"/",
"g",
",",
"function",
"(",
"match",
",",
"index",
")",
"{",
"return",
"index",
"===",
"0",
"?",
"match",
".",
"toUpperCase",
"(",
")",
":",
"' '",
"+",
"match",
".",
"toLowerCase",
"(",
")",
";",
"}",
")",
".",
"replace",
"(",
"/",
"_",
"/",
"g",
",",
"' '",
")",
";",
"}"
] | Converts attributeName or attribute_name to Attribute name | [
"Converts",
"attributeName",
"or",
"attribute_name",
"to",
"Attribute",
"name"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L510-L514 | |
20,916 | thedersen/backbone.validation | dist/backbone-validation.js | function(value){
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
} | javascript | function(value){
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
} | [
"function",
"(",
"value",
")",
"{",
"return",
"_",
".",
"isNumber",
"(",
"value",
")",
"||",
"(",
"_",
".",
"isString",
"(",
"value",
")",
"&&",
"value",
".",
"match",
"(",
"defaultPatterns",
".",
"number",
")",
")",
";",
"}"
] | Determines whether or not a value is a number | [
"Determines",
"whether",
"or",
"not",
"a",
"value",
"is",
"a",
"number"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L569-L571 | |
20,917 | thedersen/backbone.validation | dist/backbone-validation.js | function(value, attr, fn, model, computed) {
if(_.isString(fn)){
fn = model[fn];
}
return fn.call(model, value, attr, computed);
} | javascript | function(value, attr, fn, model, computed) {
if(_.isString(fn)){
fn = model[fn];
}
return fn.call(model, value, attr, computed);
} | [
"function",
"(",
"value",
",",
"attr",
",",
"fn",
",",
"model",
",",
"computed",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"fn",
")",
")",
"{",
"fn",
"=",
"model",
"[",
"fn",
"]",
";",
"}",
"return",
"fn",
".",
"call",
"(",
"model",
",",
"value",
",",
"attr",
",",
"computed",
")",
";",
"}"
] | Function validator Lets you implement a custom function used for validation | [
"Function",
"validator",
"Lets",
"you",
"implement",
"a",
"custom",
"function",
"used",
"for",
"validation"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L581-L586 | |
20,918 | thedersen/backbone.validation | dist/backbone-validation.js | function(value, attr, minValue, model) {
if (!isNumber(value) || value < minValue) {
return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
}
} | javascript | function(value, attr, minValue, model) {
if (!isNumber(value) || value < minValue) {
return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
}
} | [
"function",
"(",
"value",
",",
"attr",
",",
"minValue",
",",
"model",
")",
"{",
"if",
"(",
"!",
"isNumber",
"(",
"value",
")",
"||",
"value",
"<",
"minValue",
")",
"{",
"return",
"this",
".",
"format",
"(",
"defaultMessages",
".",
"min",
",",
"this",
".",
"formatLabel",
"(",
"attr",
",",
"model",
")",
",",
"minValue",
")",
";",
"}",
"}"
] | Min validator Validates that the value has to be a number and equal to or greater than the min value specified | [
"Min",
"validator",
"Validates",
"that",
"the",
"value",
"has",
"to",
"be",
"a",
"number",
"and",
"equal",
"to",
"or",
"greater",
"than",
"the",
"min",
"value",
"specified"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L613-L617 | |
20,919 | thedersen/backbone.validation | dist/backbone-validation.js | function(value, attr, length, model) {
if (!_.isString(value) || value.length !== length) {
return this.format(defaultMessages.length, this.formatLabel(attr, model), length);
}
} | javascript | function(value, attr, length, model) {
if (!_.isString(value) || value.length !== length) {
return this.format(defaultMessages.length, this.formatLabel(attr, model), length);
}
} | [
"function",
"(",
"value",
",",
"attr",
",",
"length",
",",
"model",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"value",
")",
"||",
"value",
".",
"length",
"!==",
"length",
")",
"{",
"return",
"this",
".",
"format",
"(",
"defaultMessages",
".",
"length",
",",
"this",
".",
"formatLabel",
"(",
"attr",
",",
"model",
")",
",",
"length",
")",
";",
"}",
"}"
] | Length validator Validates that the value has to be a string with length equal to the length value specified | [
"Length",
"validator",
"Validates",
"that",
"the",
"value",
"has",
"to",
"be",
"a",
"string",
"with",
"length",
"equal",
"to",
"the",
"length",
"value",
"specified"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L640-L644 | |
20,920 | thedersen/backbone.validation | dist/backbone-validation.js | function(value, attr, values, model) {
if(!_.include(values, value)){
return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', '));
}
} | javascript | function(value, attr, values, model) {
if(!_.include(values, value)){
return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', '));
}
} | [
"function",
"(",
"value",
",",
"attr",
",",
"values",
",",
"model",
")",
"{",
"if",
"(",
"!",
"_",
".",
"include",
"(",
"values",
",",
"value",
")",
")",
"{",
"return",
"this",
".",
"format",
"(",
"defaultMessages",
".",
"oneOf",
",",
"this",
".",
"formatLabel",
"(",
"attr",
",",
"model",
")",
",",
"values",
".",
"join",
"(",
"', '",
")",
")",
";",
"}",
"}"
] | One of validator Validates that the value has to be equal to one of the elements in the specified array. Case sensitive matching | [
"One",
"of",
"validator",
"Validates",
"that",
"the",
"value",
"has",
"to",
"be",
"equal",
"to",
"one",
"of",
"the",
"elements",
"in",
"the",
"specified",
"array",
".",
"Case",
"sensitive",
"matching"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L676-L680 | |
20,921 | thedersen/backbone.validation | dist/backbone-validation.js | function(value, attr, equalTo, model, computed) {
if(value !== computed[equalTo]) {
return this.format(defaultMessages.equalTo, this.formatLabel(attr, model), this.formatLabel(equalTo, model));
}
} | javascript | function(value, attr, equalTo, model, computed) {
if(value !== computed[equalTo]) {
return this.format(defaultMessages.equalTo, this.formatLabel(attr, model), this.formatLabel(equalTo, model));
}
} | [
"function",
"(",
"value",
",",
"attr",
",",
"equalTo",
",",
"model",
",",
"computed",
")",
"{",
"if",
"(",
"value",
"!==",
"computed",
"[",
"equalTo",
"]",
")",
"{",
"return",
"this",
".",
"format",
"(",
"defaultMessages",
".",
"equalTo",
",",
"this",
".",
"formatLabel",
"(",
"attr",
",",
"model",
")",
",",
"this",
".",
"formatLabel",
"(",
"equalTo",
",",
"model",
")",
")",
";",
"}",
"}"
] | Equal to validator Validates that the value has to be equal to the value of the attribute with the name specified | [
"Equal",
"to",
"validator",
"Validates",
"that",
"the",
"value",
"has",
"to",
"be",
"equal",
"to",
"the",
"value",
"of",
"the",
"attribute",
"with",
"the",
"name",
"specified"
] | 0ab7e3073841d9ed9dee96d38001cd5830bfe096 | https://github.com/thedersen/backbone.validation/blob/0ab7e3073841d9ed9dee96d38001cd5830bfe096/dist/backbone-validation.js#L685-L689 | |
20,922 | balor/connect-memcached | lib/connect-memcached.js | MemcachedStore | function MemcachedStore(options) {
options = options || {};
Store.call(this, options);
this.prefix = options.prefix || "";
this.ttl = options.ttl;
if (!options.client) {
if (!options.hosts) {
options.hosts = "127.0.0.1:11211";
}
if (options.secret) {
(this.crypto = require("crypto")), (this.secret = options.secret);
}
if (options.algorithm) {
this.algorithm = options.algorithm;
}
options.client = new Memcached(options.hosts, options);
}
this.client = options.client;
} | javascript | function MemcachedStore(options) {
options = options || {};
Store.call(this, options);
this.prefix = options.prefix || "";
this.ttl = options.ttl;
if (!options.client) {
if (!options.hosts) {
options.hosts = "127.0.0.1:11211";
}
if (options.secret) {
(this.crypto = require("crypto")), (this.secret = options.secret);
}
if (options.algorithm) {
this.algorithm = options.algorithm;
}
options.client = new Memcached(options.hosts, options);
}
this.client = options.client;
} | [
"function",
"MemcachedStore",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Store",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"prefix",
"=",
"options",
".",
"prefix",
"||",
"\"\"",
";",
"this",
".",
"ttl",
"=",
"options",
".",
"ttl",
";",
"if",
"(",
"!",
"options",
".",
"client",
")",
"{",
"if",
"(",
"!",
"options",
".",
"hosts",
")",
"{",
"options",
".",
"hosts",
"=",
"\"127.0.0.1:11211\"",
";",
"}",
"if",
"(",
"options",
".",
"secret",
")",
"{",
"(",
"this",
".",
"crypto",
"=",
"require",
"(",
"\"crypto\"",
")",
")",
",",
"(",
"this",
".",
"secret",
"=",
"options",
".",
"secret",
")",
";",
"}",
"if",
"(",
"options",
".",
"algorithm",
")",
"{",
"this",
".",
"algorithm",
"=",
"options",
".",
"algorithm",
";",
"}",
"options",
".",
"client",
"=",
"new",
"Memcached",
"(",
"options",
".",
"hosts",
",",
"options",
")",
";",
"}",
"this",
".",
"client",
"=",
"options",
".",
"client",
";",
"}"
] | Initialize MemcachedStore with the given `options`.
@param {Object} options
@api public | [
"Initialize",
"MemcachedStore",
"with",
"the",
"given",
"options",
"."
] | 5116ea30a6d15e7373de7d47cadc9fb5dd56cdf9 | https://github.com/balor/connect-memcached/blob/5116ea30a6d15e7373de7d47cadc9fb5dd56cdf9/lib/connect-memcached.js#L32-L53 |
20,923 | postcss/postcss-selector-parser | src/tokenize.js | consumeWord | function consumeWord (css, start) {
let next = start;
let code;
do {
code = css.charCodeAt(next);
if (wordDelimiters[code]) {
return next - 1;
} else if (code === t.backslash) {
next = consumeEscape(css, next) + 1;
} else {
// All other characters are part of the word
next++;
}
} while (next < css.length);
return next - 1;
} | javascript | function consumeWord (css, start) {
let next = start;
let code;
do {
code = css.charCodeAt(next);
if (wordDelimiters[code]) {
return next - 1;
} else if (code === t.backslash) {
next = consumeEscape(css, next) + 1;
} else {
// All other characters are part of the word
next++;
}
} while (next < css.length);
return next - 1;
} | [
"function",
"consumeWord",
"(",
"css",
",",
"start",
")",
"{",
"let",
"next",
"=",
"start",
";",
"let",
"code",
";",
"do",
"{",
"code",
"=",
"css",
".",
"charCodeAt",
"(",
"next",
")",
";",
"if",
"(",
"wordDelimiters",
"[",
"code",
"]",
")",
"{",
"return",
"next",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"code",
"===",
"t",
".",
"backslash",
")",
"{",
"next",
"=",
"consumeEscape",
"(",
"css",
",",
"next",
")",
"+",
"1",
";",
"}",
"else",
"{",
"// All other characters are part of the word",
"next",
"++",
";",
"}",
"}",
"while",
"(",
"next",
"<",
"css",
".",
"length",
")",
";",
"return",
"next",
"-",
"1",
";",
"}"
] | Returns the last index of the bar css word
@param {string} css The string in which the word begins
@param {number} start The index into the string where word's first letter occurs | [
"Returns",
"the",
"last",
"index",
"of",
"the",
"bar",
"css",
"word"
] | 190f9bc0bf22ad02102e974b17c5e6989a069b8c | https://github.com/postcss/postcss-selector-parser/blob/190f9bc0bf22ad02102e974b17c5e6989a069b8c/src/tokenize.js#L50-L65 |
20,924 | postcss/postcss-selector-parser | src/tokenize.js | consumeEscape | function consumeEscape (css, start) {
let next = start;
let code = css.charCodeAt(next + 1);
if (unescapable[code]) {
// just consume the escape char
} else if (hex[code]) {
let hexDigits = 0;
// consume up to 6 hex chars
do {
next++;
hexDigits++;
code = css.charCodeAt(next + 1);
} while (hex[code] && hexDigits < 6);
// if fewer than 6 hex chars, a trailing space ends the escape
if (hexDigits < 6 && code === t.space) {
next++;
}
} else {
// the next char is part of the current word
next++;
}
return next;
} | javascript | function consumeEscape (css, start) {
let next = start;
let code = css.charCodeAt(next + 1);
if (unescapable[code]) {
// just consume the escape char
} else if (hex[code]) {
let hexDigits = 0;
// consume up to 6 hex chars
do {
next++;
hexDigits++;
code = css.charCodeAt(next + 1);
} while (hex[code] && hexDigits < 6);
// if fewer than 6 hex chars, a trailing space ends the escape
if (hexDigits < 6 && code === t.space) {
next++;
}
} else {
// the next char is part of the current word
next++;
}
return next;
} | [
"function",
"consumeEscape",
"(",
"css",
",",
"start",
")",
"{",
"let",
"next",
"=",
"start",
";",
"let",
"code",
"=",
"css",
".",
"charCodeAt",
"(",
"next",
"+",
"1",
")",
";",
"if",
"(",
"unescapable",
"[",
"code",
"]",
")",
"{",
"// just consume the escape char",
"}",
"else",
"if",
"(",
"hex",
"[",
"code",
"]",
")",
"{",
"let",
"hexDigits",
"=",
"0",
";",
"// consume up to 6 hex chars",
"do",
"{",
"next",
"++",
";",
"hexDigits",
"++",
";",
"code",
"=",
"css",
".",
"charCodeAt",
"(",
"next",
"+",
"1",
")",
";",
"}",
"while",
"(",
"hex",
"[",
"code",
"]",
"&&",
"hexDigits",
"<",
"6",
")",
";",
"// if fewer than 6 hex chars, a trailing space ends the escape",
"if",
"(",
"hexDigits",
"<",
"6",
"&&",
"code",
"===",
"t",
".",
"space",
")",
"{",
"next",
"++",
";",
"}",
"}",
"else",
"{",
"// the next char is part of the current word",
"next",
"++",
";",
"}",
"return",
"next",
";",
"}"
] | Returns the last index of the escape sequence
@param {string} css The string in which the sequence begins
@param {number} start The index into the string where escape character (`\`) occurs. | [
"Returns",
"the",
"last",
"index",
"of",
"the",
"escape",
"sequence"
] | 190f9bc0bf22ad02102e974b17c5e6989a069b8c | https://github.com/postcss/postcss-selector-parser/blob/190f9bc0bf22ad02102e974b17c5e6989a069b8c/src/tokenize.js#L72-L94 |
20,925 | BohdanTkachenko/webpack-split-by-path | index.js | findMatchingBucket | function findMatchingBucket(mod, ignore, bucketsContext) {
var match = null;
if (!mod.resource) {
return match;
}
var resourcePath = mod.resource;
for (var i in ignore) {
if (ignore[i].test(resourcePath)) {
return match;
}
}
bucketsContext.some(function (bucket) {
return bucket.path.some(function (path) {
if (path.test(resourcePath)) {
match = bucket;
return true;
}
});
});
return match;
} | javascript | function findMatchingBucket(mod, ignore, bucketsContext) {
var match = null;
if (!mod.resource) {
return match;
}
var resourcePath = mod.resource;
for (var i in ignore) {
if (ignore[i].test(resourcePath)) {
return match;
}
}
bucketsContext.some(function (bucket) {
return bucket.path.some(function (path) {
if (path.test(resourcePath)) {
match = bucket;
return true;
}
});
});
return match;
} | [
"function",
"findMatchingBucket",
"(",
"mod",
",",
"ignore",
",",
"bucketsContext",
")",
"{",
"var",
"match",
"=",
"null",
";",
"if",
"(",
"!",
"mod",
".",
"resource",
")",
"{",
"return",
"match",
";",
"}",
"var",
"resourcePath",
"=",
"mod",
".",
"resource",
";",
"for",
"(",
"var",
"i",
"in",
"ignore",
")",
"{",
"if",
"(",
"ignore",
"[",
"i",
"]",
".",
"test",
"(",
"resourcePath",
")",
")",
"{",
"return",
"match",
";",
"}",
"}",
"bucketsContext",
".",
"some",
"(",
"function",
"(",
"bucket",
")",
"{",
"return",
"bucket",
".",
"path",
".",
"some",
"(",
"function",
"(",
"path",
")",
"{",
"if",
"(",
"path",
".",
"test",
"(",
"resourcePath",
")",
")",
"{",
"match",
"=",
"bucket",
";",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"match",
";",
"}"
] | test the target module whether it matches one of the user specified
bucket paths
@param {Module} mod
@param {String[]} ignore
@param {Bucket[]} bucketsContext
@returns {Bucket} | [
"test",
"the",
"target",
"module",
"whether",
"it",
"matches",
"one",
"of",
"the",
"user",
"specified",
"bucket",
"paths"
] | a05adb83177e9309f900019019b63f29b7e18a08 | https://github.com/BohdanTkachenko/webpack-split-by-path/blob/a05adb83177e9309f900019019b63f29b7e18a08/index.js#L156-L180 |
20,926 | node-js-libs/node.io | lib/node.io/process_master.js | function () {
if (job.pull_requests < worker_count) {
return false;
}
for (var i = 0; i < worker_count; i++) {
if (!job.worker_complete[i]) {
return false;
}
}
return true;
} | javascript | function () {
if (job.pull_requests < worker_count) {
return false;
}
for (var i = 0; i < worker_count; i++) {
if (!job.worker_complete[i]) {
return false;
}
}
return true;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"job",
".",
"pull_requests",
"<",
"worker_count",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"worker_count",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"job",
".",
"worker_complete",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Provide a method to check if workers are complete | [
"Provide",
"a",
"method",
"to",
"check",
"if",
"workers",
"are",
"complete"
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/process_master.js#L64-L74 | |
20,927 | node-js-libs/node.io | lib/node.io/process_master.js | function () {
//Check if any input was added dynamically
if (job.input.length > 0) {
job.is_complete = false;
return false;
}
//Wait for workers or instances that are still working
return worker_count > 0 ? areWorkersComplete() : job.instances <= 0;
} | javascript | function () {
//Check if any input was added dynamically
if (job.input.length > 0) {
job.is_complete = false;
return false;
}
//Wait for workers or instances that are still working
return worker_count > 0 ? areWorkersComplete() : job.instances <= 0;
} | [
"function",
"(",
")",
"{",
"//Check if any input was added dynamically",
"if",
"(",
"job",
".",
"input",
".",
"length",
">",
"0",
")",
"{",
"job",
".",
"is_complete",
"=",
"false",
";",
"return",
"false",
";",
"}",
"//Wait for workers or instances that are still working",
"return",
"worker_count",
">",
"0",
"?",
"areWorkersComplete",
"(",
")",
":",
"job",
".",
"instances",
"<=",
"0",
";",
"}"
] | No input? We might be done.. | [
"No",
"input?",
"We",
"might",
"be",
"done",
".."
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/process_master.js#L123-L132 | |
20,928 | node-js-libs/node.io | lib/node.io/processor.js | function (options, start_as_slave) {
isSlave = start_as_slave && !process.env._CHILD_ID_;
isMaster = !start_as_slave && !process.env._CHILD_ID_;
this.options = options || {};
this.jobs = {};
} | javascript | function (options, start_as_slave) {
isSlave = start_as_slave && !process.env._CHILD_ID_;
isMaster = !start_as_slave && !process.env._CHILD_ID_;
this.options = options || {};
this.jobs = {};
} | [
"function",
"(",
"options",
",",
"start_as_slave",
")",
"{",
"isSlave",
"=",
"start_as_slave",
"&&",
"!",
"process",
".",
"env",
".",
"_CHILD_ID_",
";",
"isMaster",
"=",
"!",
"start_as_slave",
"&&",
"!",
"process",
".",
"env",
".",
"_CHILD_ID_",
";",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"jobs",
"=",
"{",
"}",
";",
"}"
] | Create a new Processor with the specified options.
@param {Object} options (optional)
@param {Bool} start_as_slave (optional)
@api public | [
"Create",
"a",
"new",
"Processor",
"with",
"the",
"specified",
"options",
"."
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/processor.js#L25-L31 | |
20,929 | node-js-libs/node.io | lib/node.io/processor.js | function (job_name, job_obj) {
//If we're capturing output, we need to explicitly override job.output()
if (isMaster && capture_output) {
var output = [];
job_obj.output = function (out) {
if (out instanceof Array && job_obj.options.flatten) {
for (var i = 0, l = out.length; i < l; i++) {
output.push(out[i]);
}
} else {
output.push(out);
}
};
var old_callback = callback;
callback = function (err) {
old_callback(err, output);
};
}
//Are we distributing work?
fork = job_obj.options.fork;
//Initialise the processor
processor.init(function () {
//Start the job
if (isMaster) {
processor.startJob(job_name, job_obj, callback);
}
});
} | javascript | function (job_name, job_obj) {
//If we're capturing output, we need to explicitly override job.output()
if (isMaster && capture_output) {
var output = [];
job_obj.output = function (out) {
if (out instanceof Array && job_obj.options.flatten) {
for (var i = 0, l = out.length; i < l; i++) {
output.push(out[i]);
}
} else {
output.push(out);
}
};
var old_callback = callback;
callback = function (err) {
old_callback(err, output);
};
}
//Are we distributing work?
fork = job_obj.options.fork;
//Initialise the processor
processor.init(function () {
//Start the job
if (isMaster) {
processor.startJob(job_name, job_obj, callback);
}
});
} | [
"function",
"(",
"job_name",
",",
"job_obj",
")",
"{",
"//If we're capturing output, we need to explicitly override job.output()",
"if",
"(",
"isMaster",
"&&",
"capture_output",
")",
"{",
"var",
"output",
"=",
"[",
"]",
";",
"job_obj",
".",
"output",
"=",
"function",
"(",
"out",
")",
"{",
"if",
"(",
"out",
"instanceof",
"Array",
"&&",
"job_obj",
".",
"options",
".",
"flatten",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"out",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"output",
".",
"push",
"(",
"out",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"output",
".",
"push",
"(",
"out",
")",
";",
"}",
"}",
";",
"var",
"old_callback",
"=",
"callback",
";",
"callback",
"=",
"function",
"(",
"err",
")",
"{",
"old_callback",
"(",
"err",
",",
"output",
")",
";",
"}",
";",
"}",
"//Are we distributing work?",
"fork",
"=",
"job_obj",
".",
"options",
".",
"fork",
";",
"//Initialise the processor",
"processor",
".",
"init",
"(",
"function",
"(",
")",
"{",
"//Start the job",
"if",
"(",
"isMaster",
")",
"{",
"processor",
".",
"startJob",
"(",
"job_name",
",",
"job_obj",
",",
"callback",
")",
";",
"}",
"}",
")",
";",
"}"
] | Callback for once we've loaded the job | [
"Callback",
"for",
"once",
"we",
"ve",
"loaded",
"the",
"job"
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/processor.js#L73-L105 | |
20,930 | node-js-libs/node.io | lib/node.io/io.js | function (path) {
if (path[path.length - 1] === '/') {
path = path.substr(0, path.length - 1);
}
return path;
} | javascript | function (path) {
if (path[path.length - 1] === '/') {
path = path.substr(0, path.length - 1);
}
return path;
} | [
"function",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"===",
"'/'",
")",
"{",
"path",
"=",
"path",
".",
"substr",
"(",
"0",
",",
"path",
".",
"length",
"-",
"1",
")",
";",
"}",
"return",
"path",
";",
"}"
] | Trim trailing slash | [
"Trim",
"trailing",
"slash"
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/io.js#L96-L101 | |
20,931 | node-js-libs/node.io | lib/node.io/utils.js | function (msg, type) {
var cmd = type;
switch (type) {
case 'info':
msg = '\x1B[33mINFO\x1B[0m: ' + msg;
break;
case 'debug':
cmd = 'info';
msg = '\x1B[36mDEBUG\x1B[0m: ' + msg;
break;
case 'error':
case 'fatal':
cmd = 'error';
msg = '\x1B[31mERROR\x1B[0m: ' + msg;
break;
case 'ok':
cmd = 'info';
msg = '\x1B[32mOK\x1B[0m: ' + msg;
break;
case 'bold':
cmd = 'info';
msg = '\x1B[33mINFO\x1B[0m: \x1B[1m' + msg + '\x1B[0m';
break;
}
console[cmd](msg); //Write output according to status severity
if (type === 'fatal') {
process.exit(1);
}
} | javascript | function (msg, type) {
var cmd = type;
switch (type) {
case 'info':
msg = '\x1B[33mINFO\x1B[0m: ' + msg;
break;
case 'debug':
cmd = 'info';
msg = '\x1B[36mDEBUG\x1B[0m: ' + msg;
break;
case 'error':
case 'fatal':
cmd = 'error';
msg = '\x1B[31mERROR\x1B[0m: ' + msg;
break;
case 'ok':
cmd = 'info';
msg = '\x1B[32mOK\x1B[0m: ' + msg;
break;
case 'bold':
cmd = 'info';
msg = '\x1B[33mINFO\x1B[0m: \x1B[1m' + msg + '\x1B[0m';
break;
}
console[cmd](msg); //Write output according to status severity
if (type === 'fatal') {
process.exit(1);
}
} | [
"function",
"(",
"msg",
",",
"type",
")",
"{",
"var",
"cmd",
"=",
"type",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'info'",
":",
"msg",
"=",
"'\\x1B[33mINFO\\x1B[0m: '",
"+",
"msg",
";",
"break",
";",
"case",
"'debug'",
":",
"cmd",
"=",
"'info'",
";",
"msg",
"=",
"'\\x1B[36mDEBUG\\x1B[0m: '",
"+",
"msg",
";",
"break",
";",
"case",
"'error'",
":",
"case",
"'fatal'",
":",
"cmd",
"=",
"'error'",
";",
"msg",
"=",
"'\\x1B[31mERROR\\x1B[0m: '",
"+",
"msg",
";",
"break",
";",
"case",
"'ok'",
":",
"cmd",
"=",
"'info'",
";",
"msg",
"=",
"'\\x1B[32mOK\\x1B[0m: '",
"+",
"msg",
";",
"break",
";",
"case",
"'bold'",
":",
"cmd",
"=",
"'info'",
";",
"msg",
"=",
"'\\x1B[33mINFO\\x1B[0m: \\x1B[1m'",
"+",
"msg",
"+",
"'\\x1B[0m'",
";",
"break",
";",
"}",
"console",
"[",
"cmd",
"]",
"(",
"msg",
")",
";",
"//Write output according to status severity\r",
"if",
"(",
"type",
"===",
"'fatal'",
")",
"{",
"process",
".",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] | Outputs a styled message to the console.
@param {String} msg
@param {String} type (optional)
@api public | [
"Outputs",
"a",
"styled",
"message",
"to",
"the",
"console",
"."
] | 000b51b46ff9658754d9f4a566d4b8d65f06b5be | https://github.com/node-js-libs/node.io/blob/000b51b46ff9658754d9f4a566d4b8d65f06b5be/lib/node.io/utils.js#L18-L52 | |
20,932 | nickjj/manifest-revision-webpack-plugin | index.js | function (output, options) {
this.output = output;
this.options = options;
// Set sane defaults for any options.
this.options.rootAssetPath = options.rootAssetPath || './';
this.options.ignorePaths = options.ignorePaths || [];
this.options.extensionsRegex = options.extensionsRegex || null;
this.options.format = options.format || 'general';
} | javascript | function (output, options) {
this.output = output;
this.options = options;
// Set sane defaults for any options.
this.options.rootAssetPath = options.rootAssetPath || './';
this.options.ignorePaths = options.ignorePaths || [];
this.options.extensionsRegex = options.extensionsRegex || null;
this.options.format = options.format || 'general';
} | [
"function",
"(",
"output",
",",
"options",
")",
"{",
"this",
".",
"output",
"=",
"output",
";",
"this",
".",
"options",
"=",
"options",
";",
"// Set sane defaults for any options.",
"this",
".",
"options",
".",
"rootAssetPath",
"=",
"options",
".",
"rootAssetPath",
"||",
"'./'",
";",
"this",
".",
"options",
".",
"ignorePaths",
"=",
"options",
".",
"ignorePaths",
"||",
"[",
"]",
";",
"this",
".",
"options",
".",
"extensionsRegex",
"=",
"options",
".",
"extensionsRegex",
"||",
"null",
";",
"this",
".",
"options",
".",
"format",
"=",
"options",
".",
"format",
"||",
"'general'",
";",
"}"
] | Produce a much slimmer version of webpack stats containing only information
that you would be interested in when creating an asset manifest.
@param {string} output - The output file path.
@param {object} options - Options to configure this plugin. | [
"Produce",
"a",
"much",
"slimmer",
"version",
"of",
"webpack",
"stats",
"containing",
"only",
"information",
"that",
"you",
"would",
"be",
"interested",
"in",
"when",
"creating",
"an",
"asset",
"manifest",
"."
] | 86f0b98fd795cc48c621c3ac32bf217f101703c3 | https://github.com/nickjj/manifest-revision-webpack-plugin/blob/86f0b98fd795cc48c621c3ac32bf217f101703c3/index.js#L16-L25 | |
20,933 | fex-team/fis-command-release | lib/deploy.js | createDeployTasks | function createDeployTasks(depolyConfs, files, flaten){
var tasks = flaten ? [] : {};
fis.util.map(files, function(subpath, file) {
fis.util.map(depolyConfs, function(name, depolyConf) {
var target = flaten? tasks : (tasks[name] = tasks[name] || []);
depolyConf.forEach(function(d) {
if(
file.release &&
file.release.indexOf(d.from) === 0 && //relate to replaceFrom
fis.util.filter(file.release, d.include, d.exclude)
) {
target.push({dest : d, file : file });
}
});
});
});
return tasks;
} | javascript | function createDeployTasks(depolyConfs, files, flaten){
var tasks = flaten ? [] : {};
fis.util.map(files, function(subpath, file) {
fis.util.map(depolyConfs, function(name, depolyConf) {
var target = flaten? tasks : (tasks[name] = tasks[name] || []);
depolyConf.forEach(function(d) {
if(
file.release &&
file.release.indexOf(d.from) === 0 && //relate to replaceFrom
fis.util.filter(file.release, d.include, d.exclude)
) {
target.push({dest : d, file : file });
}
});
});
});
return tasks;
} | [
"function",
"createDeployTasks",
"(",
"depolyConfs",
",",
"files",
",",
"flaten",
")",
"{",
"var",
"tasks",
"=",
"flaten",
"?",
"[",
"]",
":",
"{",
"}",
";",
"fis",
".",
"util",
".",
"map",
"(",
"files",
",",
"function",
"(",
"subpath",
",",
"file",
")",
"{",
"fis",
".",
"util",
".",
"map",
"(",
"depolyConfs",
",",
"function",
"(",
"name",
",",
"depolyConf",
")",
"{",
"var",
"target",
"=",
"flaten",
"?",
"tasks",
":",
"(",
"tasks",
"[",
"name",
"]",
"=",
"tasks",
"[",
"name",
"]",
"||",
"[",
"]",
")",
";",
"depolyConf",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"if",
"(",
"file",
".",
"release",
"&&",
"file",
".",
"release",
".",
"indexOf",
"(",
"d",
".",
"from",
")",
"===",
"0",
"&&",
"//relate to replaceFrom",
"fis",
".",
"util",
".",
"filter",
"(",
"file",
".",
"release",
",",
"d",
".",
"include",
",",
"d",
".",
"exclude",
")",
")",
"{",
"target",
".",
"push",
"(",
"{",
"dest",
":",
"d",
",",
"file",
":",
"file",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"tasks",
";",
"}"
] | create task for files
@param {[type]} deploy config
@param {[type]} files
@param {[type]} tasks should wrap with deploy name or not
@return {[type]} | [
"create",
"task",
"for",
"files"
] | 64dc5ad4971d22a950f6b1e61146a21d9d6161eb | https://github.com/fex-team/fis-command-release/blob/64dc5ad4971d22a950f6b1e61146a21d9d6161eb/lib/deploy.js#L200-L220 |
20,934 | nikhilk/node-tensorflow | src/tensor.js | flattenList | function flattenList(list) {
// Make a copy, so the original tensor is not modified.
list = [].concat(list);
// Note that i must be checked against the length of the list each time through the loop, as the
// list is modified within the iterations.
for (let i = 0; i < list.length; i++) {
if (Array.isArray(list[i])) {
// Replace the item with the flattened version of the item (using the ... operator).
// Replace with the items and backtrack 1 position
list.splice(i, 1, ...list[i]);
// Decrement i to look at the element again; we'll keep looking at this i index, until
// the most deeply nested item has been flattened.
i--;
}
}
return list;
} | javascript | function flattenList(list) {
// Make a copy, so the original tensor is not modified.
list = [].concat(list);
// Note that i must be checked against the length of the list each time through the loop, as the
// list is modified within the iterations.
for (let i = 0; i < list.length; i++) {
if (Array.isArray(list[i])) {
// Replace the item with the flattened version of the item (using the ... operator).
// Replace with the items and backtrack 1 position
list.splice(i, 1, ...list[i]);
// Decrement i to look at the element again; we'll keep looking at this i index, until
// the most deeply nested item has been flattened.
i--;
}
}
return list;
} | [
"function",
"flattenList",
"(",
"list",
")",
"{",
"// Make a copy, so the original tensor is not modified.",
"list",
"=",
"[",
"]",
".",
"concat",
"(",
"list",
")",
";",
"// Note that i must be checked against the length of the list each time through the loop, as the",
"// list is modified within the iterations.",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"list",
"[",
"i",
"]",
")",
")",
"{",
"// Replace the item with the flattened version of the item (using the ... operator).",
"// Replace with the items and backtrack 1 position",
"list",
".",
"splice",
"(",
"i",
",",
"1",
",",
"...",
"list",
"[",
"i",
"]",
")",
";",
"// Decrement i to look at the element again; we'll keep looking at this i index, until",
"// the most deeply nested item has been flattened.",
"i",
"--",
";",
"}",
"}",
"return",
"list",
";",
"}"
] | Flatten the list. This is only relevant for multi-dimensional tensors. | [
"Flatten",
"the",
"list",
".",
"This",
"is",
"only",
"relevant",
"for",
"multi",
"-",
"dimensional",
"tensors",
"."
] | db0b0db423f0b8354d29819129c13ed3c8475971 | https://github.com/nikhilk/node-tensorflow/blob/db0b0db423f0b8354d29819129c13ed3c8475971/src/tensor.js#L135-L154 |
20,935 | node4good/formage | lib/controllers.js | upsertDocumentController | function upsertDocumentController(req, res) {
var modelName = req.params.modelName,
id = req.params.documentId,
user = req.admin_user,
data = _.extend({}, req.body, req.files),
modelConfig = registry.models[modelName],
form;
polymorphGetDocument(modelConfig.model, modelConfig.is_single, id).then(
function createTheForm(document) {
var action = document ? 'update' : 'create';
var docType = document && document._doc.__t;
if (docType) modelConfig = registry.models[docType];
var FormType = modelConfig.options.form;
if (!user.hasPermissions(modelConfig.modelName, action)) throw new Error('unauthorized');
form = new FormType(modelConfig.options, modelConfig.model, document, data);
return form.save();
}
).then(
function (document) {
modelConfig.options.post(document);
return form;
},
function (err) {
err.modelConfig = modelConfig;
err.form = form;
if (!form) throw err;
form.errors = form.errors || {};
if (err.name == 'ValidationError') {
form.errors = _.merge(form.errors, err.errors);
} else if (err.name === 'MongoError' && err.code == 11000) {
form.errors.exception = err;
err.name = "Duplicate";
var msg = '{' + err.err.split('$').pop().split('{').pop();
var ObjectID = /ObjectId\(\'(\w+)\'\)/.exec(msg);
err.fields = '\n<br />';
err.fields += (ObjectID.length == 2) ? '<a href="' + ObjectID[1] + '" target="_blank">Click to open duplicate document</a>' :
msg;
} else {
form.errors.exception = err;
}
if (_.isEmpty(form.errors)) return form;
throw err;
}
).then(
function (form) {
res._debug_form = form;
var response = form.instance.toJSON();
response.id = response.id || form.instance._id;
response.label = response.label || form.instance.name || form.instance.title || form.instance.toString();
return response;
}
).then(
function (response) {
res.json(200, response);
},
function (err) {
err.form = res._debug_form;
res.json(422, err);
}
).end();
} | javascript | function upsertDocumentController(req, res) {
var modelName = req.params.modelName,
id = req.params.documentId,
user = req.admin_user,
data = _.extend({}, req.body, req.files),
modelConfig = registry.models[modelName],
form;
polymorphGetDocument(modelConfig.model, modelConfig.is_single, id).then(
function createTheForm(document) {
var action = document ? 'update' : 'create';
var docType = document && document._doc.__t;
if (docType) modelConfig = registry.models[docType];
var FormType = modelConfig.options.form;
if (!user.hasPermissions(modelConfig.modelName, action)) throw new Error('unauthorized');
form = new FormType(modelConfig.options, modelConfig.model, document, data);
return form.save();
}
).then(
function (document) {
modelConfig.options.post(document);
return form;
},
function (err) {
err.modelConfig = modelConfig;
err.form = form;
if (!form) throw err;
form.errors = form.errors || {};
if (err.name == 'ValidationError') {
form.errors = _.merge(form.errors, err.errors);
} else if (err.name === 'MongoError' && err.code == 11000) {
form.errors.exception = err;
err.name = "Duplicate";
var msg = '{' + err.err.split('$').pop().split('{').pop();
var ObjectID = /ObjectId\(\'(\w+)\'\)/.exec(msg);
err.fields = '\n<br />';
err.fields += (ObjectID.length == 2) ? '<a href="' + ObjectID[1] + '" target="_blank">Click to open duplicate document</a>' :
msg;
} else {
form.errors.exception = err;
}
if (_.isEmpty(form.errors)) return form;
throw err;
}
).then(
function (form) {
res._debug_form = form;
var response = form.instance.toJSON();
response.id = response.id || form.instance._id;
response.label = response.label || form.instance.name || form.instance.title || form.instance.toString();
return response;
}
).then(
function (response) {
res.json(200, response);
},
function (err) {
err.form = res._debug_form;
res.json(422, err);
}
).end();
} | [
"function",
"upsertDocumentController",
"(",
"req",
",",
"res",
")",
"{",
"var",
"modelName",
"=",
"req",
".",
"params",
".",
"modelName",
",",
"id",
"=",
"req",
".",
"params",
".",
"documentId",
",",
"user",
"=",
"req",
".",
"admin_user",
",",
"data",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"req",
".",
"body",
",",
"req",
".",
"files",
")",
",",
"modelConfig",
"=",
"registry",
".",
"models",
"[",
"modelName",
"]",
",",
"form",
";",
"polymorphGetDocument",
"(",
"modelConfig",
".",
"model",
",",
"modelConfig",
".",
"is_single",
",",
"id",
")",
".",
"then",
"(",
"function",
"createTheForm",
"(",
"document",
")",
"{",
"var",
"action",
"=",
"document",
"?",
"'update'",
":",
"'create'",
";",
"var",
"docType",
"=",
"document",
"&&",
"document",
".",
"_doc",
".",
"__t",
";",
"if",
"(",
"docType",
")",
"modelConfig",
"=",
"registry",
".",
"models",
"[",
"docType",
"]",
";",
"var",
"FormType",
"=",
"modelConfig",
".",
"options",
".",
"form",
";",
"if",
"(",
"!",
"user",
".",
"hasPermissions",
"(",
"modelConfig",
".",
"modelName",
",",
"action",
")",
")",
"throw",
"new",
"Error",
"(",
"'unauthorized'",
")",
";",
"form",
"=",
"new",
"FormType",
"(",
"modelConfig",
".",
"options",
",",
"modelConfig",
".",
"model",
",",
"document",
",",
"data",
")",
";",
"return",
"form",
".",
"save",
"(",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"document",
")",
"{",
"modelConfig",
".",
"options",
".",
"post",
"(",
"document",
")",
";",
"return",
"form",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"err",
".",
"modelConfig",
"=",
"modelConfig",
";",
"err",
".",
"form",
"=",
"form",
";",
"if",
"(",
"!",
"form",
")",
"throw",
"err",
";",
"form",
".",
"errors",
"=",
"form",
".",
"errors",
"||",
"{",
"}",
";",
"if",
"(",
"err",
".",
"name",
"==",
"'ValidationError'",
")",
"{",
"form",
".",
"errors",
"=",
"_",
".",
"merge",
"(",
"form",
".",
"errors",
",",
"err",
".",
"errors",
")",
";",
"}",
"else",
"if",
"(",
"err",
".",
"name",
"===",
"'MongoError'",
"&&",
"err",
".",
"code",
"==",
"11000",
")",
"{",
"form",
".",
"errors",
".",
"exception",
"=",
"err",
";",
"err",
".",
"name",
"=",
"\"Duplicate\"",
";",
"var",
"msg",
"=",
"'{'",
"+",
"err",
".",
"err",
".",
"split",
"(",
"'$'",
")",
".",
"pop",
"(",
")",
".",
"split",
"(",
"'{'",
")",
".",
"pop",
"(",
")",
";",
"var",
"ObjectID",
"=",
"/",
"ObjectId\\(\\'(\\w+)\\'\\)",
"/",
".",
"exec",
"(",
"msg",
")",
";",
"err",
".",
"fields",
"=",
"'\\n<br />'",
";",
"err",
".",
"fields",
"+=",
"(",
"ObjectID",
".",
"length",
"==",
"2",
")",
"?",
"'<a href=\"'",
"+",
"ObjectID",
"[",
"1",
"]",
"+",
"'\" target=\"_blank\">Click to open duplicate document</a>'",
":",
"msg",
";",
"}",
"else",
"{",
"form",
".",
"errors",
".",
"exception",
"=",
"err",
";",
"}",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"form",
".",
"errors",
")",
")",
"return",
"form",
";",
"throw",
"err",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"form",
")",
"{",
"res",
".",
"_debug_form",
"=",
"form",
";",
"var",
"response",
"=",
"form",
".",
"instance",
".",
"toJSON",
"(",
")",
";",
"response",
".",
"id",
"=",
"response",
".",
"id",
"||",
"form",
".",
"instance",
".",
"_id",
";",
"response",
".",
"label",
"=",
"response",
".",
"label",
"||",
"form",
".",
"instance",
".",
"name",
"||",
"form",
".",
"instance",
".",
"title",
"||",
"form",
".",
"instance",
".",
"toString",
"(",
")",
";",
"return",
"response",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"res",
".",
"json",
"(",
"200",
",",
"response",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"err",
".",
"form",
"=",
"res",
".",
"_debug_form",
";",
"res",
".",
"json",
"(",
"422",
",",
"err",
")",
";",
"}",
")",
".",
"end",
"(",
")",
";",
"}"
] | In use by related-model-modal | [
"In",
"use",
"by",
"related",
"-",
"model",
"-",
"modal"
] | 9a6f4b6478402050940262507034b4545a2b4bbf | https://github.com/node4good/formage/blob/9a6f4b6478402050940262507034b4545a2b4bbf/lib/controllers.js#L122-L184 |
20,936 | jamesdbloom/mockserver-client-node | mockServerClient.js | function (pathOrRequestMatcher, type) {
if (type) {
var typeEnum = ['EXPECTATIONS', 'LOG', 'ALL'];
if (typeEnum.indexOf(type) === -1) {
throw new Error("\"" + (type || "undefined") + "\" is not a supported value for \"type\" parameter only " + typeEnum + " are allowed values");
}
}
return makeRequest(host, port, "/clear" + (type ? "?type=" + type : ""), addDefaultRequestMatcherHeaders(pathOrRequestMatcher));
} | javascript | function (pathOrRequestMatcher, type) {
if (type) {
var typeEnum = ['EXPECTATIONS', 'LOG', 'ALL'];
if (typeEnum.indexOf(type) === -1) {
throw new Error("\"" + (type || "undefined") + "\" is not a supported value for \"type\" parameter only " + typeEnum + " are allowed values");
}
}
return makeRequest(host, port, "/clear" + (type ? "?type=" + type : ""), addDefaultRequestMatcherHeaders(pathOrRequestMatcher));
} | [
"function",
"(",
"pathOrRequestMatcher",
",",
"type",
")",
"{",
"if",
"(",
"type",
")",
"{",
"var",
"typeEnum",
"=",
"[",
"'EXPECTATIONS'",
",",
"'LOG'",
",",
"'ALL'",
"]",
";",
"if",
"(",
"typeEnum",
".",
"indexOf",
"(",
"type",
")",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"\\\"\"",
"+",
"(",
"type",
"||",
"\"undefined\"",
")",
"+",
"\"\\\" is not a supported value for \\\"type\\\" parameter only \"",
"+",
"typeEnum",
"+",
"\" are allowed values\"",
")",
";",
"}",
"}",
"return",
"makeRequest",
"(",
"host",
",",
"port",
",",
"\"/clear\"",
"+",
"(",
"type",
"?",
"\"?type=\"",
"+",
"type",
":",
"\"\"",
")",
",",
"addDefaultRequestMatcherHeaders",
"(",
"pathOrRequestMatcher",
")",
")",
";",
"}"
] | Clear all recorded requests, expectations and logs that match the specified path
@param pathOrRequestMatcher if a string is passed in the value will be treated as the path to
decide what to clear, however if an object is passed
in the value will be treated as a full request matcher object
@param type the type to clear 'EXPECTATIONS', 'LOG' or 'ALL', defaults to 'ALL' if not specified | [
"Clear",
"all",
"recorded",
"requests",
"expectations",
"and",
"logs",
"that",
"match",
"the",
"specified",
"path"
] | bd135bbbd53c9547599def7559f149752f24a21a | https://github.com/jamesdbloom/mockserver-client-node/blob/bd135bbbd53c9547599def7559f149752f24a21a/mockServerClient.js#L505-L513 | |
20,937 | jamesdbloom/mockserver-client-node | mockServerClient.js | function (ports) {
if (!Array.isArray(ports)) {
throw new Error("ports parameter must be an array but found: " + JSON.stringify(ports));
}
return makeRequest(host, port, "/bind", {ports: ports});
} | javascript | function (ports) {
if (!Array.isArray(ports)) {
throw new Error("ports parameter must be an array but found: " + JSON.stringify(ports));
}
return makeRequest(host, port, "/bind", {ports: ports});
} | [
"function",
"(",
"ports",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"ports",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"ports parameter must be an array but found: \"",
"+",
"JSON",
".",
"stringify",
"(",
"ports",
")",
")",
";",
"}",
"return",
"makeRequest",
"(",
"host",
",",
"port",
",",
"\"/bind\"",
",",
"{",
"ports",
":",
"ports",
"}",
")",
";",
"}"
] | Add new ports the server is bound to and listening on
@param ports array of ports to bind to, use 0 to bind to any free port | [
"Add",
"new",
"ports",
"the",
"server",
"is",
"bound",
"to",
"and",
"listening",
"on"
] | bd135bbbd53c9547599def7559f149752f24a21a | https://github.com/jamesdbloom/mockserver-client-node/blob/bd135bbbd53c9547599def7559f149752f24a21a/mockServerClient.js#L519-L524 | |
20,938 | postmanlabs/postman-collection-transformer | lib/common/v1.js | function (data, legacy) {
if (!data) { return; }
var head,
headers = [],
statusValue = !legacy,
match = regexes.header.exec(data),
property = legacy ? 'enabled' : 'disabled';
data = data.toString().replace(regexes.fold, '$1');
while (match) {
head = {
key: match[1],
value: match[3].replace(regexes.trim, '$1')
};
if (_.startsWith(head.key, headersCommentPrefix)) {
head[property] = statusValue;
head.key = head.key.replace(headersCommentPrefix, '').trim();
}
headers.push(head);
match = regexes.header.exec(data);
}
return headers;
} | javascript | function (data, legacy) {
if (!data) { return; }
var head,
headers = [],
statusValue = !legacy,
match = regexes.header.exec(data),
property = legacy ? 'enabled' : 'disabled';
data = data.toString().replace(regexes.fold, '$1');
while (match) {
head = {
key: match[1],
value: match[3].replace(regexes.trim, '$1')
};
if (_.startsWith(head.key, headersCommentPrefix)) {
head[property] = statusValue;
head.key = head.key.replace(headersCommentPrefix, '').trim();
}
headers.push(head);
match = regexes.header.exec(data);
}
return headers;
} | [
"function",
"(",
"data",
",",
"legacy",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
";",
"}",
"var",
"head",
",",
"headers",
"=",
"[",
"]",
",",
"statusValue",
"=",
"!",
"legacy",
",",
"match",
"=",
"regexes",
".",
"header",
".",
"exec",
"(",
"data",
")",
",",
"property",
"=",
"legacy",
"?",
"'enabled'",
":",
"'disabled'",
";",
"data",
"=",
"data",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"regexes",
".",
"fold",
",",
"'$1'",
")",
";",
"while",
"(",
"match",
")",
"{",
"head",
"=",
"{",
"key",
":",
"match",
"[",
"1",
"]",
",",
"value",
":",
"match",
"[",
"3",
"]",
".",
"replace",
"(",
"regexes",
".",
"trim",
",",
"'$1'",
")",
"}",
";",
"if",
"(",
"_",
".",
"startsWith",
"(",
"head",
".",
"key",
",",
"headersCommentPrefix",
")",
")",
"{",
"head",
"[",
"property",
"]",
"=",
"statusValue",
";",
"head",
".",
"key",
"=",
"head",
".",
"key",
".",
"replace",
"(",
"headersCommentPrefix",
",",
"''",
")",
".",
"trim",
"(",
")",
";",
"}",
"headers",
".",
"push",
"(",
"head",
")",
";",
"match",
"=",
"regexes",
".",
"header",
".",
"exec",
"(",
"data",
")",
";",
"}",
"return",
"headers",
";",
"}"
] | Parses a string of headers to an object.
@param {String} data - A string of newline concatenated header key-value pairs.
@param {?Boolean} [legacy] - A flag to indicate whether the parsing is being done for v1 normalization or v1 to
v2 conversion.
@returns {Object[]|*} - The parsed list of header key-value pair objects.
@private | [
"Parses",
"a",
"string",
"of",
"headers",
"to",
"an",
"object",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/common/v1.js#L33-L60 | |
20,939 | postmanlabs/postman-collection-transformer | lib/index.js | function (collection, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
return callback(new Error('Output version not specified or invalid: ' + options.outputVersion));
}
if (!options.inputVersion || !semver.valid(options.inputVersion, true)) {
return callback(new Error('Input version not specified or invalid: ' + options.inputVersion));
}
return converter.convert(collection, options, callback);
} | javascript | function (collection, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
return callback(new Error('Output version not specified or invalid: ' + options.outputVersion));
}
if (!options.inputVersion || !semver.valid(options.inputVersion, true)) {
return callback(new Error('Input version not specified or invalid: ' + options.inputVersion));
}
return converter.convert(collection, options, callback);
} | [
"function",
"(",
"collection",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"options",
".",
"outputVersion",
"||",
"!",
"semver",
".",
"valid",
"(",
"options",
".",
"outputVersion",
",",
"true",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Output version not specified or invalid: '",
"+",
"options",
".",
"outputVersion",
")",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"inputVersion",
"||",
"!",
"semver",
".",
"valid",
"(",
"options",
".",
"inputVersion",
",",
"true",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Input version not specified or invalid: '",
"+",
"options",
".",
"inputVersion",
")",
")",
";",
"}",
"return",
"converter",
".",
"convert",
"(",
"collection",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Converts a Collection between different versions, based on the given input.
@param {Object} collection - The collection object to be converted.
@param {Object} options - The set of conversion options.
@param {String} options.outputVersion - The version to convert to.
@param {String} options.inputVersion - The version to convert from.
@param {Function} callback - The function invoked to mark the completion of the conversion process. | [
"Converts",
"a",
"Collection",
"between",
"different",
"versions",
"based",
"on",
"the",
"given",
"input",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/index.js#L18-L27 | |
20,940 | postmanlabs/postman-collection-transformer | lib/index.js | function (object, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
return callback(new Error('Output version not specified or invalid: ' + options.outputVersion));
}
if (!options.inputVersion || !semver.valid(options.inputVersion, true)) {
return callback(new Error('Input version not specified or invalid: ' + options.inputVersion));
}
return converter.convertSingle(object, options, callback);
} | javascript | function (object, options, callback) {
if (!options.outputVersion || !semver.valid(options.outputVersion, true)) {
return callback(new Error('Output version not specified or invalid: ' + options.outputVersion));
}
if (!options.inputVersion || !semver.valid(options.inputVersion, true)) {
return callback(new Error('Input version not specified or invalid: ' + options.inputVersion));
}
return converter.convertSingle(object, options, callback);
} | [
"function",
"(",
"object",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"options",
".",
"outputVersion",
"||",
"!",
"semver",
".",
"valid",
"(",
"options",
".",
"outputVersion",
",",
"true",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Output version not specified or invalid: '",
"+",
"options",
".",
"outputVersion",
")",
")",
";",
"}",
"if",
"(",
"!",
"options",
".",
"inputVersion",
"||",
"!",
"semver",
".",
"valid",
"(",
"options",
".",
"inputVersion",
",",
"true",
")",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Input version not specified or invalid: '",
"+",
"options",
".",
"inputVersion",
")",
")",
";",
"}",
"return",
"converter",
".",
"convertSingle",
"(",
"object",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Converts a single V1 request to a V2 Item, or a V2 item to a single V1 request.
@param {Object} object - A V1 request or a V2 item.
@param {Object} options - The set of options for response conversion.
@param {String} options.outputVersion - The version to convert to.
@param {String} options.inputVersion - The version to convert from.
@param {Function} callback - The function invoked to mark the completion of the conversion process. | [
"Converts",
"a",
"single",
"V1",
"request",
"to",
"a",
"V2",
"Item",
"or",
"a",
"V2",
"item",
"to",
"a",
"single",
"V1",
"request",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/index.js#L67-L76 | |
20,941 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (entityV1, options) {
if (!entityV1) { return; }
var auth,
params,
mapper,
currentHelper,
helperAttributes,
prioritizeV2 = this.options.prioritizeV2;
// if prioritize v2 is true, use auth as the source of truth
if (util.notLegacy(entityV1, 'auth') || (entityV1.auth && prioritizeV2)) {
return util.sanitizeAuthArray(entityV1, options);
}
if ((entityV1.currentHelper === null) || (entityV1.currentHelper === 'normal')) { return null; }
currentHelper = entityV1.currentHelper;
helperAttributes = entityV1.helperAttributes;
// if noDefaults is false and there is no currentHelper, bail out
if (!(currentHelper || this.options.noDefaults)) { return; }
// if there is a currentHelper without helperAttributes, bail out.
if (currentHelper && !helperAttributes) { return this.options.noDefaults ? undefined : null; }
!currentHelper && (currentHelper = authIdMap[helperAttributes && helperAttributes.id]);
auth = { type: v1Common.authMap[currentHelper] };
mapper = util.authMappersFromLegacy[currentHelper];
// @todo: Change this to support custom auth helpers
mapper && helperAttributes && (params = mapper(helperAttributes)) && (auth[auth.type] = params);
return util.authMapToArray({ auth: auth }, options);
} | javascript | function (entityV1, options) {
if (!entityV1) { return; }
var auth,
params,
mapper,
currentHelper,
helperAttributes,
prioritizeV2 = this.options.prioritizeV2;
// if prioritize v2 is true, use auth as the source of truth
if (util.notLegacy(entityV1, 'auth') || (entityV1.auth && prioritizeV2)) {
return util.sanitizeAuthArray(entityV1, options);
}
if ((entityV1.currentHelper === null) || (entityV1.currentHelper === 'normal')) { return null; }
currentHelper = entityV1.currentHelper;
helperAttributes = entityV1.helperAttributes;
// if noDefaults is false and there is no currentHelper, bail out
if (!(currentHelper || this.options.noDefaults)) { return; }
// if there is a currentHelper without helperAttributes, bail out.
if (currentHelper && !helperAttributes) { return this.options.noDefaults ? undefined : null; }
!currentHelper && (currentHelper = authIdMap[helperAttributes && helperAttributes.id]);
auth = { type: v1Common.authMap[currentHelper] };
mapper = util.authMappersFromLegacy[currentHelper];
// @todo: Change this to support custom auth helpers
mapper && helperAttributes && (params = mapper(helperAttributes)) && (auth[auth.type] = params);
return util.authMapToArray({ auth: auth }, options);
} | [
"function",
"(",
"entityV1",
",",
"options",
")",
"{",
"if",
"(",
"!",
"entityV1",
")",
"{",
"return",
";",
"}",
"var",
"auth",
",",
"params",
",",
"mapper",
",",
"currentHelper",
",",
"helperAttributes",
",",
"prioritizeV2",
"=",
"this",
".",
"options",
".",
"prioritizeV2",
";",
"// if prioritize v2 is true, use auth as the source of truth",
"if",
"(",
"util",
".",
"notLegacy",
"(",
"entityV1",
",",
"'auth'",
")",
"||",
"(",
"entityV1",
".",
"auth",
"&&",
"prioritizeV2",
")",
")",
"{",
"return",
"util",
".",
"sanitizeAuthArray",
"(",
"entityV1",
",",
"options",
")",
";",
"}",
"if",
"(",
"(",
"entityV1",
".",
"currentHelper",
"===",
"null",
")",
"||",
"(",
"entityV1",
".",
"currentHelper",
"===",
"'normal'",
")",
")",
"{",
"return",
"null",
";",
"}",
"currentHelper",
"=",
"entityV1",
".",
"currentHelper",
";",
"helperAttributes",
"=",
"entityV1",
".",
"helperAttributes",
";",
"// if noDefaults is false and there is no currentHelper, bail out",
"if",
"(",
"!",
"(",
"currentHelper",
"||",
"this",
".",
"options",
".",
"noDefaults",
")",
")",
"{",
"return",
";",
"}",
"// if there is a currentHelper without helperAttributes, bail out.",
"if",
"(",
"currentHelper",
"&&",
"!",
"helperAttributes",
")",
"{",
"return",
"this",
".",
"options",
".",
"noDefaults",
"?",
"undefined",
":",
"null",
";",
"}",
"!",
"currentHelper",
"&&",
"(",
"currentHelper",
"=",
"authIdMap",
"[",
"helperAttributes",
"&&",
"helperAttributes",
".",
"id",
"]",
")",
";",
"auth",
"=",
"{",
"type",
":",
"v1Common",
".",
"authMap",
"[",
"currentHelper",
"]",
"}",
";",
"mapper",
"=",
"util",
".",
"authMappersFromLegacy",
"[",
"currentHelper",
"]",
";",
"// @todo: Change this to support custom auth helpers",
"mapper",
"&&",
"helperAttributes",
"&&",
"(",
"params",
"=",
"mapper",
"(",
"helperAttributes",
")",
")",
"&&",
"(",
"auth",
"[",
"auth",
".",
"type",
"]",
"=",
"params",
")",
";",
"return",
"util",
".",
"authMapToArray",
"(",
"{",
"auth",
":",
"auth",
"}",
",",
"options",
")",
";",
"}"
] | Normalizes inherited v1 auth manifests.
@param {Object} entityV1 - A v1 compliant wrapped auth manifest.
@param {?Object} options - The set of options for the current auth cleansing operation.
@param {?Boolean} [options.includeNoauth=false] - When set to true, noauth is set to ''.
@returns {Object} - A v1 compliant set of auth helper attributes. | [
"Normalizes",
"inherited",
"v1",
"auth",
"manifests",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L63-L95 | |
20,942 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (requestV1) {
if (!requestV1) { return; }
var mode = requestV1.dataMode,
noDefaults = this.options.noDefaults,
retainEmptyValues = this.options.retainEmptyValues;
if ((!mode || mode === 'binary') && !noDefaults) {
return retainEmptyValues ? [] : undefined;
}
if (!requestV1.data) { return; }
_.isArray(requestV1.data) && _.forEach(requestV1.data, function (datum) {
if (datum.type === 'file' && (_.has(datum, 'value') || !noDefaults)) {
datum.value = (_.isString(datum.value) || _.isArray(datum.value)) ? datum.value : null;
}
util.cleanEmptyValue(datum, 'description', retainEmptyValues);
});
return requestV1.data;
} | javascript | function (requestV1) {
if (!requestV1) { return; }
var mode = requestV1.dataMode,
noDefaults = this.options.noDefaults,
retainEmptyValues = this.options.retainEmptyValues;
if ((!mode || mode === 'binary') && !noDefaults) {
return retainEmptyValues ? [] : undefined;
}
if (!requestV1.data) { return; }
_.isArray(requestV1.data) && _.forEach(requestV1.data, function (datum) {
if (datum.type === 'file' && (_.has(datum, 'value') || !noDefaults)) {
datum.value = (_.isString(datum.value) || _.isArray(datum.value)) ? datum.value : null;
}
util.cleanEmptyValue(datum, 'description', retainEmptyValues);
});
return requestV1.data;
} | [
"function",
"(",
"requestV1",
")",
"{",
"if",
"(",
"!",
"requestV1",
")",
"{",
"return",
";",
"}",
"var",
"mode",
"=",
"requestV1",
".",
"dataMode",
",",
"noDefaults",
"=",
"this",
".",
"options",
".",
"noDefaults",
",",
"retainEmptyValues",
"=",
"this",
".",
"options",
".",
"retainEmptyValues",
";",
"if",
"(",
"(",
"!",
"mode",
"||",
"mode",
"===",
"'binary'",
")",
"&&",
"!",
"noDefaults",
")",
"{",
"return",
"retainEmptyValues",
"?",
"[",
"]",
":",
"undefined",
";",
"}",
"if",
"(",
"!",
"requestV1",
".",
"data",
")",
"{",
"return",
";",
"}",
"_",
".",
"isArray",
"(",
"requestV1",
".",
"data",
")",
"&&",
"_",
".",
"forEach",
"(",
"requestV1",
".",
"data",
",",
"function",
"(",
"datum",
")",
"{",
"if",
"(",
"datum",
".",
"type",
"===",
"'file'",
"&&",
"(",
"_",
".",
"has",
"(",
"datum",
",",
"'value'",
")",
"||",
"!",
"noDefaults",
")",
")",
"{",
"datum",
".",
"value",
"=",
"(",
"_",
".",
"isString",
"(",
"datum",
".",
"value",
")",
"||",
"_",
".",
"isArray",
"(",
"datum",
".",
"value",
")",
")",
"?",
"datum",
".",
"value",
":",
"null",
";",
"}",
"util",
".",
"cleanEmptyValue",
"(",
"datum",
",",
"'description'",
",",
"retainEmptyValues",
")",
";",
"}",
")",
";",
"return",
"requestV1",
".",
"data",
";",
"}"
] | Sanitizes request v1 data.
@param {Object} requestV1 - The wrapper v1 request object around the data list to be sanitized.
@returns {Object[]} - The normalized list of request body parameters. | [
"Sanitizes",
"request",
"v1",
"data",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L149-L170 | |
20,943 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (requestV1) {
if (!requestV1) { return; }
if (requestV1.headers && _.isEmpty(requestV1.headerData)) {
// this converts a newline concatenated string of headers to an array, so there are no descriptions
return v1Common.parseHeaders(requestV1.headers, true);
}
// however, if non empty headerData already exists, sanitize it.
return normalizeEntities(requestV1.headerData, this.options);
} | javascript | function (requestV1) {
if (!requestV1) { return; }
if (requestV1.headers && _.isEmpty(requestV1.headerData)) {
// this converts a newline concatenated string of headers to an array, so there are no descriptions
return v1Common.parseHeaders(requestV1.headers, true);
}
// however, if non empty headerData already exists, sanitize it.
return normalizeEntities(requestV1.headerData, this.options);
} | [
"function",
"(",
"requestV1",
")",
"{",
"if",
"(",
"!",
"requestV1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"requestV1",
".",
"headers",
"&&",
"_",
".",
"isEmpty",
"(",
"requestV1",
".",
"headerData",
")",
")",
"{",
"// this converts a newline concatenated string of headers to an array, so there are no descriptions",
"return",
"v1Common",
".",
"parseHeaders",
"(",
"requestV1",
".",
"headers",
",",
"true",
")",
";",
"}",
"// however, if non empty headerData already exists, sanitize it.",
"return",
"normalizeEntities",
"(",
"requestV1",
".",
"headerData",
",",
"this",
".",
"options",
")",
";",
"}"
] | Normalizes a list of header data from the incoming raw v1 request.
@param {Object} requestV1 - The raw v1 request object.
@returns {Object[]} - The normalized list of header datum values. | [
"Normalizes",
"a",
"list",
"of",
"header",
"data",
"from",
"the",
"incoming",
"raw",
"v1",
"request",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L178-L187 | |
20,944 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (responseV1) {
var self = this;
// if noDefaults is true, do not replace the id
// else
// if id is falsy, replace the id
// if retainIds is false, replace the id
!((self.options.retainIds && responseV1.id) || self.options.noDefaults) && (responseV1.id = util.uid());
// the true in the next line ensures that we don't recursively go on processing responses in a request.
responseV1.request = self.request(responseV1.request, undefined, true);
!responseV1.language && (responseV1.language = 'Text');
!responseV1.previewType && (responseV1.previewType = 'html');
_.isEmpty(responseV1.cookies) && (delete responseV1.cookies);
return responseV1;
} | javascript | function (responseV1) {
var self = this;
// if noDefaults is true, do not replace the id
// else
// if id is falsy, replace the id
// if retainIds is false, replace the id
!((self.options.retainIds && responseV1.id) || self.options.noDefaults) && (responseV1.id = util.uid());
// the true in the next line ensures that we don't recursively go on processing responses in a request.
responseV1.request = self.request(responseV1.request, undefined, true);
!responseV1.language && (responseV1.language = 'Text');
!responseV1.previewType && (responseV1.previewType = 'html');
_.isEmpty(responseV1.cookies) && (delete responseV1.cookies);
return responseV1;
} | [
"function",
"(",
"responseV1",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// if noDefaults is true, do not replace the id",
"// else",
"// if id is falsy, replace the id",
"// if retainIds is false, replace the id",
"!",
"(",
"(",
"self",
".",
"options",
".",
"retainIds",
"&&",
"responseV1",
".",
"id",
")",
"||",
"self",
".",
"options",
".",
"noDefaults",
")",
"&&",
"(",
"responseV1",
".",
"id",
"=",
"util",
".",
"uid",
"(",
")",
")",
";",
"// the true in the next line ensures that we don't recursively go on processing responses in a request.",
"responseV1",
".",
"request",
"=",
"self",
".",
"request",
"(",
"responseV1",
".",
"request",
",",
"undefined",
",",
"true",
")",
";",
"!",
"responseV1",
".",
"language",
"&&",
"(",
"responseV1",
".",
"language",
"=",
"'Text'",
")",
";",
"!",
"responseV1",
".",
"previewType",
"&&",
"(",
"responseV1",
".",
"previewType",
"=",
"'html'",
")",
";",
"_",
".",
"isEmpty",
"(",
"responseV1",
".",
"cookies",
")",
"&&",
"(",
"delete",
"responseV1",
".",
"cookies",
")",
";",
"return",
"responseV1",
";",
"}"
] | Normalizes a potentially raw v1 response object.
@param {Object} responseV1 - The potentially raw v1 response object.
@returns {Object} - The normalized v1 response object. | [
"Normalizes",
"a",
"potentially",
"raw",
"v1",
"response",
"object",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L356-L374 | |
20,945 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (collectionV1) {
if (_.isEmpty(collectionV1 && collectionV1.folders)) { return; }
var auth,
events,
variables,
self = this,
order,
foldersOrder,
retainEmpty = self.options.retainEmptyValues,
varOpts = { noDefaults: self.options.noDefaults };
_.forEach(collectionV1.folders, function (folder) {
if (!folder) { return; }
// if noDefaults is true, do not replace the id
// else
// if id is falsy, replace the id
// if retainIds is false, replace the id
!((self.options.retainIds && folder.id) || self.options.noDefaults) && (folder.id = util.uid());
util.cleanEmptyValue(folder, 'description', retainEmpty);
auth = self.auth(folder);
!_.isEmpty((order = self.order(folder))) && (folder.order = order);
!_.isEmpty((foldersOrder = self.folders_order(folder))) && (folder.folders_order = foldersOrder);
(auth || (auth === null)) && (folder.auth = auth);
(events = self.events(folder)) && (folder.events = events);
(variables = self.variables(folder, varOpts)) && (folder.variables = variables);
});
return _.compact(collectionV1.folders);
} | javascript | function (collectionV1) {
if (_.isEmpty(collectionV1 && collectionV1.folders)) { return; }
var auth,
events,
variables,
self = this,
order,
foldersOrder,
retainEmpty = self.options.retainEmptyValues,
varOpts = { noDefaults: self.options.noDefaults };
_.forEach(collectionV1.folders, function (folder) {
if (!folder) { return; }
// if noDefaults is true, do not replace the id
// else
// if id is falsy, replace the id
// if retainIds is false, replace the id
!((self.options.retainIds && folder.id) || self.options.noDefaults) && (folder.id = util.uid());
util.cleanEmptyValue(folder, 'description', retainEmpty);
auth = self.auth(folder);
!_.isEmpty((order = self.order(folder))) && (folder.order = order);
!_.isEmpty((foldersOrder = self.folders_order(folder))) && (folder.folders_order = foldersOrder);
(auth || (auth === null)) && (folder.auth = auth);
(events = self.events(folder)) && (folder.events = events);
(variables = self.variables(folder, varOpts)) && (folder.variables = variables);
});
return _.compact(collectionV1.folders);
} | [
"function",
"(",
"collectionV1",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"collectionV1",
"&&",
"collectionV1",
".",
"folders",
")",
")",
"{",
"return",
";",
"}",
"var",
"auth",
",",
"events",
",",
"variables",
",",
"self",
"=",
"this",
",",
"order",
",",
"foldersOrder",
",",
"retainEmpty",
"=",
"self",
".",
"options",
".",
"retainEmptyValues",
",",
"varOpts",
"=",
"{",
"noDefaults",
":",
"self",
".",
"options",
".",
"noDefaults",
"}",
";",
"_",
".",
"forEach",
"(",
"collectionV1",
".",
"folders",
",",
"function",
"(",
"folder",
")",
"{",
"if",
"(",
"!",
"folder",
")",
"{",
"return",
";",
"}",
"// if noDefaults is true, do not replace the id",
"// else",
"// if id is falsy, replace the id",
"// if retainIds is false, replace the id",
"!",
"(",
"(",
"self",
".",
"options",
".",
"retainIds",
"&&",
"folder",
".",
"id",
")",
"||",
"self",
".",
"options",
".",
"noDefaults",
")",
"&&",
"(",
"folder",
".",
"id",
"=",
"util",
".",
"uid",
"(",
")",
")",
";",
"util",
".",
"cleanEmptyValue",
"(",
"folder",
",",
"'description'",
",",
"retainEmpty",
")",
";",
"auth",
"=",
"self",
".",
"auth",
"(",
"folder",
")",
";",
"!",
"_",
".",
"isEmpty",
"(",
"(",
"order",
"=",
"self",
".",
"order",
"(",
"folder",
")",
")",
")",
"&&",
"(",
"folder",
".",
"order",
"=",
"order",
")",
";",
"!",
"_",
".",
"isEmpty",
"(",
"(",
"foldersOrder",
"=",
"self",
".",
"folders_order",
"(",
"folder",
")",
")",
")",
"&&",
"(",
"folder",
".",
"folders_order",
"=",
"foldersOrder",
")",
";",
"(",
"auth",
"||",
"(",
"auth",
"===",
"null",
")",
")",
"&&",
"(",
"folder",
".",
"auth",
"=",
"auth",
")",
";",
"(",
"events",
"=",
"self",
".",
"events",
"(",
"folder",
")",
")",
"&&",
"(",
"folder",
".",
"events",
"=",
"events",
")",
";",
"(",
"variables",
"=",
"self",
".",
"variables",
"(",
"folder",
",",
"varOpts",
")",
")",
"&&",
"(",
"folder",
".",
"variables",
"=",
"variables",
")",
";",
"}",
")",
";",
"return",
"_",
".",
"compact",
"(",
"collectionV1",
".",
"folders",
")",
";",
"}"
] | Normalizes a potentially raw v1 folders list.
@param {Object} collectionV1 - The potentially raw v1 collection object.
@returns {Object[]} - The normalized v1 collection folders list. | [
"Normalizes",
"a",
"potentially",
"raw",
"v1",
"folders",
"list",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L414-L447 | |
20,946 | postmanlabs/postman-collection-transformer | lib/normalizers/v1.js | function (request, options, callback) {
var err,
normalized,
builders = new Builders(options);
// At this stage, mutate will not be passed ordinarily. Hence, the falsy nature of options.mutate can be used
// to selectively clone the request.
options && !options.mutate && (request = _.cloneDeep(request));
try { normalized = builders.request(request); }
catch (e) { err = e; }
if (callback) { return callback(err, normalized); }
if (err) { throw err; }
return normalized;
} | javascript | function (request, options, callback) {
var err,
normalized,
builders = new Builders(options);
// At this stage, mutate will not be passed ordinarily. Hence, the falsy nature of options.mutate can be used
// to selectively clone the request.
options && !options.mutate && (request = _.cloneDeep(request));
try { normalized = builders.request(request); }
catch (e) { err = e; }
if (callback) { return callback(err, normalized); }
if (err) { throw err; }
return normalized;
} | [
"function",
"(",
"request",
",",
"options",
",",
"callback",
")",
"{",
"var",
"err",
",",
"normalized",
",",
"builders",
"=",
"new",
"Builders",
"(",
"options",
")",
";",
"// At this stage, mutate will not be passed ordinarily. Hence, the falsy nature of options.mutate can be used",
"// to selectively clone the request.",
"options",
"&&",
"!",
"options",
".",
"mutate",
"&&",
"(",
"request",
"=",
"_",
".",
"cloneDeep",
"(",
"request",
")",
")",
";",
"try",
"{",
"normalized",
"=",
"builders",
".",
"request",
"(",
"request",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"err",
"=",
"e",
";",
"}",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"err",
",",
"normalized",
")",
";",
"}",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"return",
"normalized",
";",
"}"
] | Normalizes a single v1 request.
@param {Object} request - The v1 request to be normalized.
@param {Object} options - The set of options for the current normalization.
@param {?Boolean} [options.mutate=false] - When set to true, normalization is done in place.
@param {?Boolean} [options.noDefaults=false] - When set to true, sensible defaults are not added.
@param {?Boolean} [options.prioritizeV2=false] - When set to true, v2 style properties are checked first.
@param {?Boolean} [options.retainEmptyValues=false] - When set to true, empty values are set to '' instead of
being removed.
@param {Function} callback - A function that is invoked when the normalization has completed.
@returns {*} | [
"Normalizes",
"a",
"single",
"v1",
"request",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/v1.js#L483-L500 | |
20,947 | postmanlabs/postman-collection-transformer | lib/converters/index.js | function (inputVersion, outputVersion) {
var converter;
inputVersion = semver.clean(inputVersion);
outputVersion = semver.clean(outputVersion);
for (converter in this.converters) {
// eslint-disable-next-line no-prototype-builtins
converter = this.converters.hasOwnProperty(converter) && this.converters[converter];
if (converter && semver.eq(converter.input, inputVersion) && semver.eq(converter.output, outputVersion)) {
return generateConverter(converter);
}
}
} | javascript | function (inputVersion, outputVersion) {
var converter;
inputVersion = semver.clean(inputVersion);
outputVersion = semver.clean(outputVersion);
for (converter in this.converters) {
// eslint-disable-next-line no-prototype-builtins
converter = this.converters.hasOwnProperty(converter) && this.converters[converter];
if (converter && semver.eq(converter.input, inputVersion) && semver.eq(converter.output, outputVersion)) {
return generateConverter(converter);
}
}
} | [
"function",
"(",
"inputVersion",
",",
"outputVersion",
")",
"{",
"var",
"converter",
";",
"inputVersion",
"=",
"semver",
".",
"clean",
"(",
"inputVersion",
")",
";",
"outputVersion",
"=",
"semver",
".",
"clean",
"(",
"outputVersion",
")",
";",
"for",
"(",
"converter",
"in",
"this",
".",
"converters",
")",
"{",
"// eslint-disable-next-line no-prototype-builtins",
"converter",
"=",
"this",
".",
"converters",
".",
"hasOwnProperty",
"(",
"converter",
")",
"&&",
"this",
".",
"converters",
"[",
"converter",
"]",
";",
"if",
"(",
"converter",
"&&",
"semver",
".",
"eq",
"(",
"converter",
".",
"input",
",",
"inputVersion",
")",
"&&",
"semver",
".",
"eq",
"(",
"converter",
".",
"output",
",",
"outputVersion",
")",
")",
"{",
"return",
"generateConverter",
"(",
"converter",
")",
";",
"}",
"}",
"}"
] | Fetches a converter for the given input and output versions
@param {String} inputVersion - The version to convert from.
@param {String} outputVersion - The version to convert to.
@returns {Converter} - A converter for the given set of options. | [
"Fetches",
"a",
"converter",
"for",
"the",
"given",
"input",
"and",
"output",
"versions"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/index.js#L73-L86 | |
20,948 | postmanlabs/postman-collection-transformer | lib/converters/index.js | function (collection, options, callback) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
if (!chosenConverter) {
return callback(new Error('no conversion path found'));
}
return chosenConverter.convert(collection, options, callback);
} | javascript | function (collection, options, callback) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
if (!chosenConverter) {
return callback(new Error('no conversion path found'));
}
return chosenConverter.convert(collection, options, callback);
} | [
"function",
"(",
"collection",
",",
"options",
",",
"callback",
")",
"{",
"var",
"chosenConverter",
"=",
"this",
".",
"getConverter",
"(",
"options",
".",
"inputVersion",
",",
"options",
".",
"outputVersion",
")",
";",
"if",
"(",
"!",
"chosenConverter",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'no conversion path found'",
")",
")",
";",
"}",
"return",
"chosenConverter",
".",
"convert",
"(",
"collection",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Picks the appropriate converter and converts the given collection.
@param {Object} collection - The collection to be converted.
@param {Object} options - The set of options for request conversion.
@param {Function} callback - The function to be invoked after the completion of conversion process. | [
"Picks",
"the",
"appropriate",
"converter",
"and",
"converts",
"the",
"given",
"collection",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/index.js#L95-L103 | |
20,949 | postmanlabs/postman-collection-transformer | lib/converters/index.js | function (object, options, callback) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
if (!chosenConverter) {
return callback(new Error('no conversion path found'));
}
return chosenConverter.convertSingle(object, options, callback);
} | javascript | function (object, options, callback) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
if (!chosenConverter) {
return callback(new Error('no conversion path found'));
}
return chosenConverter.convertSingle(object, options, callback);
} | [
"function",
"(",
"object",
",",
"options",
",",
"callback",
")",
"{",
"var",
"chosenConverter",
"=",
"this",
".",
"getConverter",
"(",
"options",
".",
"inputVersion",
",",
"options",
".",
"outputVersion",
")",
";",
"if",
"(",
"!",
"chosenConverter",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'no conversion path found'",
")",
")",
";",
"}",
"return",
"chosenConverter",
".",
"convertSingle",
"(",
"object",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Picks the appropriate converter and converts the given object.
@param {Object} object - A single V1 request or a V2 Item.
@param {Object} options - The set of options for request conversion.
@param {Function} callback - The function to be invoked after the completion of conversion process. | [
"Picks",
"the",
"appropriate",
"converter",
"and",
"converts",
"the",
"given",
"object",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/index.js#L112-L120 | |
20,950 | postmanlabs/postman-collection-transformer | lib/converters/index.js | function (options) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
return chosenConverter.create(options);
} | javascript | function (options) {
var chosenConverter = this.getConverter(options.inputVersion, options.outputVersion);
return chosenConverter.create(options);
} | [
"function",
"(",
"options",
")",
"{",
"var",
"chosenConverter",
"=",
"this",
".",
"getConverter",
"(",
"options",
".",
"inputVersion",
",",
"options",
".",
"outputVersion",
")",
";",
"return",
"chosenConverter",
".",
"create",
"(",
"options",
")",
";",
"}"
] | Returns a builder, which can be used to convert individual requests, etc.
@param {Object} options - The set of options for builder creation.
@returns {Function} - The builder for the given set of options. | [
"Returns",
"a",
"builder",
"which",
"can",
"be",
"used",
"to",
"convert",
"individual",
"requests",
"etc",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/index.js#L146-L150 | |
20,951 | postmanlabs/postman-collection-transformer | lib/normalizers/index.js | function (collection, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalize(collection, options, callback);
} | javascript | function (collection, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalize(collection, options, callback);
} | [
"function",
"(",
"collection",
",",
"options",
",",
"callback",
")",
"{",
"var",
"version",
";",
"if",
"(",
"!",
"options",
"||",
"!",
"(",
"version",
"=",
"semver",
".",
"valid",
"(",
"options",
".",
"normalizeVersion",
",",
"true",
")",
")",
"||",
"!",
"normalizers",
"[",
"version",
"]",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Version not specified or invalid: '",
"+",
"options",
".",
"normalizeVersion",
")",
")",
";",
"}",
"return",
"normalizers",
"[",
"version",
"]",
".",
"normalize",
"(",
"collection",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Accepts the arguments for normalization and invokes the appropriate normalizer with them.
@param {Object} collection - The plain collection JSON to be normalized.
@param {Object} options - A set of options for the current normalization.
@param {String} options.normalizeVersion - The base collection schema version for which to normalize.
@param {?Boolean} [options.mutate=false] - When set to true, normalization is done in place.
@param {?Boolean} [options.noDefaults=false] - When set to true, sensible defaults are not added.
@param {?Boolean} [options.prioritizeV2=false] - When set to true, v2 style properties are checked first.
@param {?Boolean} [options.retainEmptyValues=false] - When set to true, empty values are set to '' instead of
being removed.
@param {Function} callback - A function invoked to indicate the completion of the normalization process.
@returns {*} | [
"Accepts",
"the",
"arguments",
"for",
"normalization",
"and",
"invokes",
"the",
"appropriate",
"normalizer",
"with",
"them",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/index.js#L24-L32 | |
20,952 | postmanlabs/postman-collection-transformer | lib/normalizers/index.js | function (object, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalizeSingle(object, options, callback);
} | javascript | function (object, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalizeSingle(object, options, callback);
} | [
"function",
"(",
"object",
",",
"options",
",",
"callback",
")",
"{",
"var",
"version",
";",
"if",
"(",
"!",
"options",
"||",
"!",
"(",
"version",
"=",
"semver",
".",
"valid",
"(",
"options",
".",
"normalizeVersion",
",",
"true",
")",
")",
"||",
"!",
"normalizers",
"[",
"version",
"]",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Version not specified or invalid: '",
"+",
"options",
".",
"normalizeVersion",
")",
")",
";",
"}",
"return",
"normalizers",
"[",
"version",
"]",
".",
"normalizeSingle",
"(",
"object",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Normalizes a single request or item as per the provided version.
@param {Object} object - The entity to be normalized.
@param {Object} options - The set of options to be applied to the current normalization.
@param {String} options.normalizeVersion - The base collection schema version for which to normalize.
@param {?Boolean} [options.mutate=false] - When set to true, normalization is done in place.
@param {?Boolean} [options.noDefaults=false] - When set to true, sensible defaults are not added.
@param {?Boolean} [options.prioritizeV2=false] - When set to true, v2 style properties are checked first.
@param {?Boolean} [options.retainEmptyValues=false] - When set to true, empty values are set to '' instead of
being removed.
@param {Function} callback - The function invoked when the normalization has completed. | [
"Normalizes",
"a",
"single",
"request",
"or",
"item",
"as",
"per",
"the",
"provided",
"version",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/index.js#L47-L55 | |
20,953 | postmanlabs/postman-collection-transformer | lib/normalizers/index.js | function (response, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalizeResponse(response, options, callback);
} | javascript | function (response, options, callback) {
var version;
if (!options || !(version = semver.valid(options.normalizeVersion, true)) || !normalizers[version]) {
return callback(new Error('Version not specified or invalid: ' + options.normalizeVersion));
}
return normalizers[version].normalizeResponse(response, options, callback);
} | [
"function",
"(",
"response",
",",
"options",
",",
"callback",
")",
"{",
"var",
"version",
";",
"if",
"(",
"!",
"options",
"||",
"!",
"(",
"version",
"=",
"semver",
".",
"valid",
"(",
"options",
".",
"normalizeVersion",
",",
"true",
")",
")",
"||",
"!",
"normalizers",
"[",
"version",
"]",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Version not specified or invalid: '",
"+",
"options",
".",
"normalizeVersion",
")",
")",
";",
"}",
"return",
"normalizers",
"[",
"version",
"]",
".",
"normalizeResponse",
"(",
"response",
",",
"options",
",",
"callback",
")",
";",
"}"
] | Normalizes a single response as per the provided version.
@param {Object} response - The response to be normalized.
@param {Object} options - The set of options to be applied to the current normalization.
@param {String} options.normalizeVersion - The base collection schema version for which to normalize.
@param {?Boolean} [options.mutate=false] - When set to true, normalization is done in place.
@param {?Boolean} [options.noDefaults=false] - When set to true, sensible defaults are not added.
@param {?Boolean} [options.prioritizeV2=false] - When set to true, v2 style properties are checked first.
@param {?Boolean} [options.retainEmptyValues=false] - When set to true, empty values are set to '' instead of
being removed.
@param {Function} callback - The function invoked when the normalization has completed. | [
"Normalizes",
"a",
"single",
"response",
"as",
"per",
"the",
"provided",
"version",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/normalizers/index.js#L70-L78 | |
20,954 | postmanlabs/postman-collection-transformer | lib/util.js | function () {
var n,
r,
E = '',
H = '-'; // r = result , n = numeric variable for positional checks
// if "n" is not 9 or 14 or 19 or 24 return a random number or 4
// if "n" is not 15 generate a random number from 0 to 15
// `(n ^ 20 ? 16 : 4)` := unless "n" is 20, in which case a random number from 8 to 11 otherwise 4
//
// in other cases (if "n" is 9,14,19,24) insert "-"
// eslint-disable-next-line curly
for (r = n = E; n++ < 36; r += n * 51 & 52 ? (n ^ 15 ? 8 ^ rnd() * (n ^ 20 ? 16 : 4) : 4).toString(16) : H);
return r;
} | javascript | function () {
var n,
r,
E = '',
H = '-'; // r = result , n = numeric variable for positional checks
// if "n" is not 9 or 14 or 19 or 24 return a random number or 4
// if "n" is not 15 generate a random number from 0 to 15
// `(n ^ 20 ? 16 : 4)` := unless "n" is 20, in which case a random number from 8 to 11 otherwise 4
//
// in other cases (if "n" is 9,14,19,24) insert "-"
// eslint-disable-next-line curly
for (r = n = E; n++ < 36; r += n * 51 & 52 ? (n ^ 15 ? 8 ^ rnd() * (n ^ 20 ? 16 : 4) : 4).toString(16) : H);
return r;
} | [
"function",
"(",
")",
"{",
"var",
"n",
",",
"r",
",",
"E",
"=",
"''",
",",
"H",
"=",
"'-'",
";",
"// r = result , n = numeric variable for positional checks",
"// if \"n\" is not 9 or 14 or 19 or 24 return a random number or 4",
"// if \"n\" is not 15 generate a random number from 0 to 15",
"// `(n ^ 20 ? 16 : 4)` := unless \"n\" is 20, in which case a random number from 8 to 11 otherwise 4",
"//",
"// in other cases (if \"n\" is 9,14,19,24) insert \"-\"",
"// eslint-disable-next-line curly",
"for",
"(",
"r",
"=",
"n",
"=",
"E",
";",
"n",
"++",
"<",
"36",
";",
"r",
"+=",
"n",
"*",
"51",
"&",
"52",
"?",
"(",
"n",
"^",
"15",
"?",
"8",
"^",
"rnd",
"(",
")",
"*",
"(",
"n",
"^",
"20",
"?",
"16",
":",
"4",
")",
":",
"4",
")",
".",
"toString",
"(",
"16",
")",
":",
"H",
")",
";",
"return",
"r",
";",
"}"
] | Returns unique GUID on every call as per pseudo-number RFC4122 standards.
@type {function}
@returns {string} | [
"Returns",
"unique",
"GUID",
"on",
"every",
"call",
"as",
"per",
"pseudo",
"-",
"number",
"RFC4122",
"standards",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L20-L35 | |
20,955 | postmanlabs/postman-collection-transformer | lib/util.js | function (entity, options, modifiers) {
!options && (options = {});
var self = this,
noDefaults = options.noDefaults,
isV1 = modifiers && modifiers.isV1,
retainEmpty = options.retainEmptyValues,
source = entity && (entity.variables || entity.variable || (isV1 && entity.pathVariableData)),
fallback = options.fallback && options.fallback.values,
result = _.map(source || fallback, function (item) {
var result = {
id: (noDefaults || item.id) ? item.id : self.uid(),
key: item.key || item.id,
value: item.value,
type: (item.type === 'text' ? 'string' : item.type) || self.typeMap[typeof item.value] || 'any'
};
item.disabled && (result.disabled = true);
if (item.description) { result.description = item.description; }
else if (retainEmpty) { result.description = null; }
return result;
});
if (result.length) { return result; }
} | javascript | function (entity, options, modifiers) {
!options && (options = {});
var self = this,
noDefaults = options.noDefaults,
isV1 = modifiers && modifiers.isV1,
retainEmpty = options.retainEmptyValues,
source = entity && (entity.variables || entity.variable || (isV1 && entity.pathVariableData)),
fallback = options.fallback && options.fallback.values,
result = _.map(source || fallback, function (item) {
var result = {
id: (noDefaults || item.id) ? item.id : self.uid(),
key: item.key || item.id,
value: item.value,
type: (item.type === 'text' ? 'string' : item.type) || self.typeMap[typeof item.value] || 'any'
};
item.disabled && (result.disabled = true);
if (item.description) { result.description = item.description; }
else if (retainEmpty) { result.description = null; }
return result;
});
if (result.length) { return result; }
} | [
"function",
"(",
"entity",
",",
"options",
",",
"modifiers",
")",
"{",
"!",
"options",
"&&",
"(",
"options",
"=",
"{",
"}",
")",
";",
"var",
"self",
"=",
"this",
",",
"noDefaults",
"=",
"options",
".",
"noDefaults",
",",
"isV1",
"=",
"modifiers",
"&&",
"modifiers",
".",
"isV1",
",",
"retainEmpty",
"=",
"options",
".",
"retainEmptyValues",
",",
"source",
"=",
"entity",
"&&",
"(",
"entity",
".",
"variables",
"||",
"entity",
".",
"variable",
"||",
"(",
"isV1",
"&&",
"entity",
".",
"pathVariableData",
")",
")",
",",
"fallback",
"=",
"options",
".",
"fallback",
"&&",
"options",
".",
"fallback",
".",
"values",
",",
"result",
"=",
"_",
".",
"map",
"(",
"source",
"||",
"fallback",
",",
"function",
"(",
"item",
")",
"{",
"var",
"result",
"=",
"{",
"id",
":",
"(",
"noDefaults",
"||",
"item",
".",
"id",
")",
"?",
"item",
".",
"id",
":",
"self",
".",
"uid",
"(",
")",
",",
"key",
":",
"item",
".",
"key",
"||",
"item",
".",
"id",
",",
"value",
":",
"item",
".",
"value",
",",
"type",
":",
"(",
"item",
".",
"type",
"===",
"'text'",
"?",
"'string'",
":",
"item",
".",
"type",
")",
"||",
"self",
".",
"typeMap",
"[",
"typeof",
"item",
".",
"value",
"]",
"||",
"'any'",
"}",
";",
"item",
".",
"disabled",
"&&",
"(",
"result",
".",
"disabled",
"=",
"true",
")",
";",
"if",
"(",
"item",
".",
"description",
")",
"{",
"result",
".",
"description",
"=",
"item",
".",
"description",
";",
"}",
"else",
"if",
"(",
"retainEmpty",
")",
"{",
"result",
".",
"description",
"=",
"null",
";",
"}",
"return",
"result",
";",
"}",
")",
";",
"if",
"(",
"result",
".",
"length",
")",
"{",
"return",
"result",
";",
"}",
"}"
] | A generic utility method to sanitize variable transformations across collection formats.
@param {Object} entity - A generic object that could contain variable data.
@param {?Object} options - The set of options for variable handling.
@param {?Object} options.fallback - The fallback values to be used if no variables are present.
@param {?Boolean} options.noDefaults - When set to true, id will be retained.
@param {?Boolean} options.retainEmptyValues - When set to true, empty property values will be set to ''
instead of being deleted.
@param {Object} [modifiers] - A set of behavioral modifiers for variable handling.
@param {Boolean} [modifiers.isV1=false] - When set to true, looks for the pathVariableData property as well.
@returns {Object[]} - The set of sanitized entity level variables. | [
"A",
"generic",
"utility",
"method",
"to",
"sanitize",
"variable",
"transformations",
"across",
"collection",
"formats",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L58-L84 | |
20,956 | postmanlabs/postman-collection-transformer | lib/util.js | function (entity, options) {
!options && (options = {});
var auth = entity && entity.auth;
if (auth === null) { return null; } // eslint-disable-line security/detect-possible-timing-attacks
if (!(auth && auth.type)) { return; }
if (auth.type === 'noauth') {
return options.excludeNoauth ? null : { type: 'noauth' };
}
return auth;
} | javascript | function (entity, options) {
!options && (options = {});
var auth = entity && entity.auth;
if (auth === null) { return null; } // eslint-disable-line security/detect-possible-timing-attacks
if (!(auth && auth.type)) { return; }
if (auth.type === 'noauth') {
return options.excludeNoauth ? null : { type: 'noauth' };
}
return auth;
} | [
"function",
"(",
"entity",
",",
"options",
")",
"{",
"!",
"options",
"&&",
"(",
"options",
"=",
"{",
"}",
")",
";",
"var",
"auth",
"=",
"entity",
"&&",
"entity",
".",
"auth",
";",
"if",
"(",
"auth",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// eslint-disable-line security/detect-possible-timing-attacks",
"if",
"(",
"!",
"(",
"auth",
"&&",
"auth",
".",
"type",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"auth",
".",
"type",
"===",
"'noauth'",
")",
"{",
"return",
"options",
".",
"excludeNoauth",
"?",
"null",
":",
"{",
"type",
":",
"'noauth'",
"}",
";",
"}",
"return",
"auth",
";",
"}"
] | Performs auth cleansing common to all sorts of auth transformations.
@param {Object} entity - The wrapped auth entity to be cleaned.
@param {?Object} options - The set of options for the current auth cleansing operation.
@param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
@returns {Object|*} - The processed auth data. | [
"Performs",
"auth",
"cleansing",
"common",
"to",
"all",
"sorts",
"of",
"auth",
"transformations",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L94-L106 | |
20,957 | postmanlabs/postman-collection-transformer | lib/util.js | function (entity, options) {
var type,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
result[type] = _.transform(auth[type], function (result, param) {
result[param.key] = param.value;
}, {});
}
return result;
} | javascript | function (entity, options) {
var type,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
result[type] = _.transform(auth[type], function (result, param) {
result[param.key] = param.value;
}, {});
}
return result;
} | [
"function",
"(",
"entity",
",",
"options",
")",
"{",
"var",
"type",
",",
"result",
",",
"self",
"=",
"this",
",",
"auth",
"=",
"self",
".",
"cleanAuth",
"(",
"entity",
",",
"options",
")",
";",
"if",
"(",
"!",
"auth",
")",
"{",
"return",
"auth",
";",
"}",
"result",
"=",
"{",
"type",
":",
"(",
"type",
"=",
"auth",
".",
"type",
")",
"}",
";",
"if",
"(",
"type",
"!==",
"'noauth'",
")",
"{",
"result",
"[",
"type",
"]",
"=",
"_",
".",
"transform",
"(",
"auth",
"[",
"type",
"]",
",",
"function",
"(",
"result",
",",
"param",
")",
"{",
"result",
"[",
"param",
".",
"key",
"]",
"=",
"param",
".",
"value",
";",
"}",
",",
"{",
"}",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Transforms an array of auth params to their object equivalent.
@param {Object} entity - The wrapper object for the array of auth params.
@param {?Object} options - The set of options for the current auth cleansing operation.
@param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
@returns {*} | [
"Transforms",
"an",
"array",
"of",
"auth",
"params",
"to",
"their",
"object",
"equivalent",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L124-L141 | |
20,958 | postmanlabs/postman-collection-transformer | lib/util.js | function (entity, options) {
var type,
params,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
// @todo: Handle all non _ prefixed properties, ala request bodies
params = _.map(auth[type], function (value, key) {
return {
key: key,
value: value,
type: self.typeMap[typeof value] || 'any'
};
});
params.length && (result[type] = params);
}
return result;
} | javascript | function (entity, options) {
var type,
params,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
// @todo: Handle all non _ prefixed properties, ala request bodies
params = _.map(auth[type], function (value, key) {
return {
key: key,
value: value,
type: self.typeMap[typeof value] || 'any'
};
});
params.length && (result[type] = params);
}
return result;
} | [
"function",
"(",
"entity",
",",
"options",
")",
"{",
"var",
"type",
",",
"params",
",",
"result",
",",
"self",
"=",
"this",
",",
"auth",
"=",
"self",
".",
"cleanAuth",
"(",
"entity",
",",
"options",
")",
";",
"if",
"(",
"!",
"auth",
")",
"{",
"return",
"auth",
";",
"}",
"result",
"=",
"{",
"type",
":",
"(",
"type",
"=",
"auth",
".",
"type",
")",
"}",
";",
"if",
"(",
"type",
"!==",
"'noauth'",
")",
"{",
"// @todo: Handle all non _ prefixed properties, ala request bodies",
"params",
"=",
"_",
".",
"map",
"(",
"auth",
"[",
"type",
"]",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"return",
"{",
"key",
":",
"key",
",",
"value",
":",
"value",
",",
"type",
":",
"self",
".",
"typeMap",
"[",
"typeof",
"value",
"]",
"||",
"'any'",
"}",
";",
"}",
")",
";",
"params",
".",
"length",
"&&",
"(",
"result",
"[",
"type",
"]",
"=",
"params",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Transforms an object of auth params to their array equivalent.
@param {Object} entity - The wrapper object for the array of auth params.
@param {?Object} options - The set of options for the current auth cleansing operation.
@param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
@returns {*} | [
"Transforms",
"an",
"object",
"of",
"auth",
"params",
"to",
"their",
"array",
"equivalent",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L151-L176 | |
20,959 | postmanlabs/postman-collection-transformer | lib/util.js | function (entity, options) {
var type,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
result[type] = _.map(auth[type], function (param) {
return {
key: param.key,
value: param.value,
type: (param.type === 'text' ? 'string' : param.type) || self.typeMap[typeof param.value] || 'any'
};
});
}
return result;
} | javascript | function (entity, options) {
var type,
result,
self = this,
auth = self.cleanAuth(entity, options);
if (!auth) { return auth; }
result = { type: (type = auth.type) };
if (type !== 'noauth') {
result[type] = _.map(auth[type], function (param) {
return {
key: param.key,
value: param.value,
type: (param.type === 'text' ? 'string' : param.type) || self.typeMap[typeof param.value] || 'any'
};
});
}
return result;
} | [
"function",
"(",
"entity",
",",
"options",
")",
"{",
"var",
"type",
",",
"result",
",",
"self",
"=",
"this",
",",
"auth",
"=",
"self",
".",
"cleanAuth",
"(",
"entity",
",",
"options",
")",
";",
"if",
"(",
"!",
"auth",
")",
"{",
"return",
"auth",
";",
"}",
"result",
"=",
"{",
"type",
":",
"(",
"type",
"=",
"auth",
".",
"type",
")",
"}",
";",
"if",
"(",
"type",
"!==",
"'noauth'",
")",
"{",
"result",
"[",
"type",
"]",
"=",
"_",
".",
"map",
"(",
"auth",
"[",
"type",
"]",
",",
"function",
"(",
"param",
")",
"{",
"return",
"{",
"key",
":",
"param",
".",
"key",
",",
"value",
":",
"param",
".",
"value",
",",
"type",
":",
"(",
"param",
".",
"type",
"===",
"'text'",
"?",
"'string'",
":",
"param",
".",
"type",
")",
"||",
"self",
".",
"typeMap",
"[",
"typeof",
"param",
".",
"value",
"]",
"||",
"'any'",
"}",
";",
"}",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Sanitizes a collection SDK compliant auth list.
@param {Object} entity - The wrapper entity for the auth manifest.
@param {?Object} options - The set of options for the current auth cleansing operation.
@param {?Boolean} [options.excludeNoauth=false] - When set to true, noauth is set to null.
@returns {Object[]} - An array of raw collection SDK compliant auth parameters. | [
"Sanitizes",
"a",
"collection",
"SDK",
"compliant",
"auth",
"list",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L186-L207 | |
20,960 | postmanlabs/postman-collection-transformer | lib/util.js | function (entityV1, type) {
if (!entityV1) { return; }
switch (type) {
case 'event':
return !(entityV1.tests || entityV1.preRequestScript);
case 'auth':
return _.has(entityV1, 'auth') && !(_.has(entityV1, 'currentHelper') || entityV1.helperAttributes);
default:
return true;
}
} | javascript | function (entityV1, type) {
if (!entityV1) { return; }
switch (type) {
case 'event':
return !(entityV1.tests || entityV1.preRequestScript);
case 'auth':
return _.has(entityV1, 'auth') && !(_.has(entityV1, 'currentHelper') || entityV1.helperAttributes);
default:
return true;
}
} | [
"function",
"(",
"entityV1",
",",
"type",
")",
"{",
"if",
"(",
"!",
"entityV1",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"'event'",
":",
"return",
"!",
"(",
"entityV1",
".",
"tests",
"||",
"entityV1",
".",
"preRequestScript",
")",
";",
"case",
"'auth'",
":",
"return",
"_",
".",
"has",
"(",
"entityV1",
",",
"'auth'",
")",
"&&",
"!",
"(",
"_",
".",
"has",
"(",
"entityV1",
",",
"'currentHelper'",
")",
"||",
"entityV1",
".",
"helperAttributes",
")",
";",
"default",
":",
"return",
"true",
";",
"}",
"}"
] | A helper function to determine if the provided v1 entity has legacy properties.
@private
@param {Object} entityV1 - The v1 entity to be checked for the presence of legacy properties.
@param {String} type - The type of property to be adjudged against.
@returns {Boolean|*} - A flag to indicate the legacy property status of the passed v1 entity. | [
"A",
"helper",
"function",
"to",
"determine",
"if",
"the",
"provided",
"v1",
"entity",
"has",
"legacy",
"properties",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L217-L228 | |
20,961 | postmanlabs/postman-collection-transformer | lib/util.js | function (source, destination) {
var behavior = source && source.protocolProfileBehavior;
if (!(behavior && typeof behavior === 'object')) { return false; }
destination && (destination.protocolProfileBehavior = behavior);
return true;
} | javascript | function (source, destination) {
var behavior = source && source.protocolProfileBehavior;
if (!(behavior && typeof behavior === 'object')) { return false; }
destination && (destination.protocolProfileBehavior = behavior);
return true;
} | [
"function",
"(",
"source",
",",
"destination",
")",
"{",
"var",
"behavior",
"=",
"source",
"&&",
"source",
".",
"protocolProfileBehavior",
";",
"if",
"(",
"!",
"(",
"behavior",
"&&",
"typeof",
"behavior",
"===",
"'object'",
")",
")",
"{",
"return",
"false",
";",
"}",
"destination",
"&&",
"(",
"destination",
".",
"protocolProfileBehavior",
"=",
"behavior",
")",
";",
"return",
"true",
";",
"}"
] | Validate protocolProfileBehavior property's value.
@param {Object} source - A generic object that could contain the protocolProfileBehavior property.
@param {?Object} destination - The destination object that needs the addition of protocolProfileBehavior.
@returns {Boolean} - A Boolean value to decide whether to include the property or not. | [
"Validate",
"protocolProfileBehavior",
"property",
"s",
"value",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/util.js#L441-L449 | |
20,962 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (collectionV1) {
var info = {
_postman_id: collectionV1.id || util.uid(),
name: collectionV1.name
};
if (collectionV1.description) { info.description = collectionV1.description; }
else if (this.options.retainEmptyValues) { info.description = null; }
info.schema = constants.SCHEMA_V2_URL;
return info;
} | javascript | function (collectionV1) {
var info = {
_postman_id: collectionV1.id || util.uid(),
name: collectionV1.name
};
if (collectionV1.description) { info.description = collectionV1.description; }
else if (this.options.retainEmptyValues) { info.description = null; }
info.schema = constants.SCHEMA_V2_URL;
return info;
} | [
"function",
"(",
"collectionV1",
")",
"{",
"var",
"info",
"=",
"{",
"_postman_id",
":",
"collectionV1",
".",
"id",
"||",
"util",
".",
"uid",
"(",
")",
",",
"name",
":",
"collectionV1",
".",
"name",
"}",
";",
"if",
"(",
"collectionV1",
".",
"description",
")",
"{",
"info",
".",
"description",
"=",
"collectionV1",
".",
"description",
";",
"}",
"else",
"if",
"(",
"this",
".",
"options",
".",
"retainEmptyValues",
")",
"{",
"info",
".",
"description",
"=",
"null",
";",
"}",
"info",
".",
"schema",
"=",
"constants",
".",
"SCHEMA_V2_URL",
";",
"return",
"info",
";",
"}"
] | Constructs a V2 compatible "info" object from a V1 Postman Collection
@param {Object} collectionV1 - A v1 collection to derive collection metadata from.
@returns {Object} - The resultant v2 info object. | [
"Constructs",
"a",
"V2",
"compatible",
"info",
"object",
"from",
"a",
"V1",
"Postman",
"Collection"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L79-L91 | |
20,963 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (requestV1) {
var queryParams = [],
pathVariables = [],
traversedVars = {},
queryParamAltered,
traversedQueryParams = {},
parsed = util.urlparse(requestV1.url),
retainEmpty = this.options.retainEmptyValues;
// Merge query params
_.forEach(requestV1.queryParams, function (queryParam) {
(queryParam.enabled === false) && (queryParam.disabled = true);
delete queryParam.enabled;
util.cleanEmptyValue(queryParam, 'description', retainEmpty);
if (_.has(queryParam, 'equals')) {
if (queryParam.equals) {
(queryParam.value === null) && (queryParam.value = '');
queryParamAltered = true;
}
else {
// = is not appended when the value is null
(queryParam.value === '') && (queryParam.value = null);
queryParamAltered = true;
}
delete queryParam.equals;
}
queryParams.push(queryParam);
traversedQueryParams[queryParam.key] = true;
});
// parsed query params are taken from the url, so no descriptions are available from them
_.forEach(parsed.query, function (queryParam) {
!traversedQueryParams[queryParam.key] && queryParams.push(queryParam);
});
// Merge path variables
_.forEach(requestV1.pathVariableData, function (pathVariable) {
pathVariable = _.clone(pathVariable);
util.cleanEmptyValue(pathVariable, 'description', retainEmpty);
pathVariables.push(pathVariable);
traversedVars[pathVariable.key] = true;
});
// pathVariables in v1 are of the form {foo: bar}, so no descriptions can be obtained from them
_.forEach(requestV1.pathVariables, function (value, id) {
!traversedVars[id] && pathVariables.push({
value: value,
id: id
});
});
!_.isEmpty(queryParams) && (parsed.query = queryParams);
!_.isEmpty(pathVariables) && (parsed.variable = pathVariables);
// If the query params have been altered, update the raw stringified URL
queryParamAltered && (parsed.raw = util.urlunparse(parsed));
// return the objectified URL only if query param or path variable descriptions are present, string otherwise
return (parsed.query || parsed.variable) ? parsed : (parsed.raw || requestV1.url);
} | javascript | function (requestV1) {
var queryParams = [],
pathVariables = [],
traversedVars = {},
queryParamAltered,
traversedQueryParams = {},
parsed = util.urlparse(requestV1.url),
retainEmpty = this.options.retainEmptyValues;
// Merge query params
_.forEach(requestV1.queryParams, function (queryParam) {
(queryParam.enabled === false) && (queryParam.disabled = true);
delete queryParam.enabled;
util.cleanEmptyValue(queryParam, 'description', retainEmpty);
if (_.has(queryParam, 'equals')) {
if (queryParam.equals) {
(queryParam.value === null) && (queryParam.value = '');
queryParamAltered = true;
}
else {
// = is not appended when the value is null
(queryParam.value === '') && (queryParam.value = null);
queryParamAltered = true;
}
delete queryParam.equals;
}
queryParams.push(queryParam);
traversedQueryParams[queryParam.key] = true;
});
// parsed query params are taken from the url, so no descriptions are available from them
_.forEach(parsed.query, function (queryParam) {
!traversedQueryParams[queryParam.key] && queryParams.push(queryParam);
});
// Merge path variables
_.forEach(requestV1.pathVariableData, function (pathVariable) {
pathVariable = _.clone(pathVariable);
util.cleanEmptyValue(pathVariable, 'description', retainEmpty);
pathVariables.push(pathVariable);
traversedVars[pathVariable.key] = true;
});
// pathVariables in v1 are of the form {foo: bar}, so no descriptions can be obtained from them
_.forEach(requestV1.pathVariables, function (value, id) {
!traversedVars[id] && pathVariables.push({
value: value,
id: id
});
});
!_.isEmpty(queryParams) && (parsed.query = queryParams);
!_.isEmpty(pathVariables) && (parsed.variable = pathVariables);
// If the query params have been altered, update the raw stringified URL
queryParamAltered && (parsed.raw = util.urlunparse(parsed));
// return the objectified URL only if query param or path variable descriptions are present, string otherwise
return (parsed.query || parsed.variable) ? parsed : (parsed.raw || requestV1.url);
} | [
"function",
"(",
"requestV1",
")",
"{",
"var",
"queryParams",
"=",
"[",
"]",
",",
"pathVariables",
"=",
"[",
"]",
",",
"traversedVars",
"=",
"{",
"}",
",",
"queryParamAltered",
",",
"traversedQueryParams",
"=",
"{",
"}",
",",
"parsed",
"=",
"util",
".",
"urlparse",
"(",
"requestV1",
".",
"url",
")",
",",
"retainEmpty",
"=",
"this",
".",
"options",
".",
"retainEmptyValues",
";",
"// Merge query params",
"_",
".",
"forEach",
"(",
"requestV1",
".",
"queryParams",
",",
"function",
"(",
"queryParam",
")",
"{",
"(",
"queryParam",
".",
"enabled",
"===",
"false",
")",
"&&",
"(",
"queryParam",
".",
"disabled",
"=",
"true",
")",
";",
"delete",
"queryParam",
".",
"enabled",
";",
"util",
".",
"cleanEmptyValue",
"(",
"queryParam",
",",
"'description'",
",",
"retainEmpty",
")",
";",
"if",
"(",
"_",
".",
"has",
"(",
"queryParam",
",",
"'equals'",
")",
")",
"{",
"if",
"(",
"queryParam",
".",
"equals",
")",
"{",
"(",
"queryParam",
".",
"value",
"===",
"null",
")",
"&&",
"(",
"queryParam",
".",
"value",
"=",
"''",
")",
";",
"queryParamAltered",
"=",
"true",
";",
"}",
"else",
"{",
"// = is not appended when the value is null",
"(",
"queryParam",
".",
"value",
"===",
"''",
")",
"&&",
"(",
"queryParam",
".",
"value",
"=",
"null",
")",
";",
"queryParamAltered",
"=",
"true",
";",
"}",
"delete",
"queryParam",
".",
"equals",
";",
"}",
"queryParams",
".",
"push",
"(",
"queryParam",
")",
";",
"traversedQueryParams",
"[",
"queryParam",
".",
"key",
"]",
"=",
"true",
";",
"}",
")",
";",
"// parsed query params are taken from the url, so no descriptions are available from them",
"_",
".",
"forEach",
"(",
"parsed",
".",
"query",
",",
"function",
"(",
"queryParam",
")",
"{",
"!",
"traversedQueryParams",
"[",
"queryParam",
".",
"key",
"]",
"&&",
"queryParams",
".",
"push",
"(",
"queryParam",
")",
";",
"}",
")",
";",
"// Merge path variables",
"_",
".",
"forEach",
"(",
"requestV1",
".",
"pathVariableData",
",",
"function",
"(",
"pathVariable",
")",
"{",
"pathVariable",
"=",
"_",
".",
"clone",
"(",
"pathVariable",
")",
";",
"util",
".",
"cleanEmptyValue",
"(",
"pathVariable",
",",
"'description'",
",",
"retainEmpty",
")",
";",
"pathVariables",
".",
"push",
"(",
"pathVariable",
")",
";",
"traversedVars",
"[",
"pathVariable",
".",
"key",
"]",
"=",
"true",
";",
"}",
")",
";",
"// pathVariables in v1 are of the form {foo: bar}, so no descriptions can be obtained from them",
"_",
".",
"forEach",
"(",
"requestV1",
".",
"pathVariables",
",",
"function",
"(",
"value",
",",
"id",
")",
"{",
"!",
"traversedVars",
"[",
"id",
"]",
"&&",
"pathVariables",
".",
"push",
"(",
"{",
"value",
":",
"value",
",",
"id",
":",
"id",
"}",
")",
";",
"}",
")",
";",
"!",
"_",
".",
"isEmpty",
"(",
"queryParams",
")",
"&&",
"(",
"parsed",
".",
"query",
"=",
"queryParams",
")",
";",
"!",
"_",
".",
"isEmpty",
"(",
"pathVariables",
")",
"&&",
"(",
"parsed",
".",
"variable",
"=",
"pathVariables",
")",
";",
"// If the query params have been altered, update the raw stringified URL",
"queryParamAltered",
"&&",
"(",
"parsed",
".",
"raw",
"=",
"util",
".",
"urlunparse",
"(",
"parsed",
")",
")",
";",
"// return the objectified URL only if query param or path variable descriptions are present, string otherwise",
"return",
"(",
"parsed",
".",
"query",
"||",
"parsed",
".",
"variable",
")",
"?",
"parsed",
":",
"(",
"parsed",
".",
"raw",
"||",
"requestV1",
".",
"url",
")",
";",
"}"
] | Constructs a V2 compatible URL object from a V1 request
@param {Object} requestV1 - The source v1 request to extract the URL from.
@returns {String|Object} - The resultant URL. | [
"Constructs",
"a",
"V2",
"compatible",
"URL",
"object",
"from",
"a",
"V1",
"request"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L112-L174 | |
20,964 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (requestV1) {
if (_.isArray(requestV1.headers)) {
return requestV1.headers;
}
var headers = [],
traversed = {},
headerData = requestV1.headerData || [],
retainEmpty = this.options.retainEmptyValues;
_.forEach(headerData, function (header) {
if (_.startsWith(header.key, headersCommentPrefix) || (header.enabled === false)) {
header.disabled = true;
header.key = header.key.replace(headersCommentPrefix, '').trim();
}
// prevent empty header descriptions from showing up in converted results. This keeps the collections clean
util.cleanEmptyValue(header, 'description', retainEmpty);
delete header.enabled;
headers.push(header); // @todo Improve this sequence to account for multi-valued headers
traversed[header.key] = true;
});
// requestV1.headers is a string, so no descriptions can be obtained from it
_.forEach(v1Common.parseHeaders(requestV1.headers), function (header) {
!traversed[header.key] && headers.push(header);
});
return headers;
} | javascript | function (requestV1) {
if (_.isArray(requestV1.headers)) {
return requestV1.headers;
}
var headers = [],
traversed = {},
headerData = requestV1.headerData || [],
retainEmpty = this.options.retainEmptyValues;
_.forEach(headerData, function (header) {
if (_.startsWith(header.key, headersCommentPrefix) || (header.enabled === false)) {
header.disabled = true;
header.key = header.key.replace(headersCommentPrefix, '').trim();
}
// prevent empty header descriptions from showing up in converted results. This keeps the collections clean
util.cleanEmptyValue(header, 'description', retainEmpty);
delete header.enabled;
headers.push(header); // @todo Improve this sequence to account for multi-valued headers
traversed[header.key] = true;
});
// requestV1.headers is a string, so no descriptions can be obtained from it
_.forEach(v1Common.parseHeaders(requestV1.headers), function (header) {
!traversed[header.key] && headers.push(header);
});
return headers;
} | [
"function",
"(",
"requestV1",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"requestV1",
".",
"headers",
")",
")",
"{",
"return",
"requestV1",
".",
"headers",
";",
"}",
"var",
"headers",
"=",
"[",
"]",
",",
"traversed",
"=",
"{",
"}",
",",
"headerData",
"=",
"requestV1",
".",
"headerData",
"||",
"[",
"]",
",",
"retainEmpty",
"=",
"this",
".",
"options",
".",
"retainEmptyValues",
";",
"_",
".",
"forEach",
"(",
"headerData",
",",
"function",
"(",
"header",
")",
"{",
"if",
"(",
"_",
".",
"startsWith",
"(",
"header",
".",
"key",
",",
"headersCommentPrefix",
")",
"||",
"(",
"header",
".",
"enabled",
"===",
"false",
")",
")",
"{",
"header",
".",
"disabled",
"=",
"true",
";",
"header",
".",
"key",
"=",
"header",
".",
"key",
".",
"replace",
"(",
"headersCommentPrefix",
",",
"''",
")",
".",
"trim",
"(",
")",
";",
"}",
"// prevent empty header descriptions from showing up in converted results. This keeps the collections clean",
"util",
".",
"cleanEmptyValue",
"(",
"header",
",",
"'description'",
",",
"retainEmpty",
")",
";",
"delete",
"header",
".",
"enabled",
";",
"headers",
".",
"push",
"(",
"header",
")",
";",
"// @todo Improve this sequence to account for multi-valued headers",
"traversed",
"[",
"header",
".",
"key",
"]",
"=",
"true",
";",
"}",
")",
";",
"// requestV1.headers is a string, so no descriptions can be obtained from it",
"_",
".",
"forEach",
"(",
"v1Common",
".",
"parseHeaders",
"(",
"requestV1",
".",
"headers",
")",
",",
"function",
"(",
"header",
")",
"{",
"!",
"traversed",
"[",
"header",
".",
"key",
"]",
"&&",
"headers",
".",
"push",
"(",
"header",
")",
";",
"}",
")",
";",
"return",
"headers",
";",
"}"
] | Constructs an array of Key-Values from a raw HTTP Header string.
@param {Object} requestV1 - The v1 request to extract header information from.
@returns {Object[]} - A list of header definition objects. | [
"Constructs",
"an",
"array",
"of",
"Key",
"-",
"Values",
"from",
"a",
"raw",
"HTTP",
"Header",
"string",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L192-L223 | |
20,965 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (requestV1) {
var modes = {
urlencoded: 'urlencoded',
params: 'formdata',
raw: 'raw',
binary: 'file'
},
data = {},
rawModeData,
dataMode = modes[requestV1.dataMode],
retainEmpty = this.options.retainEmptyValues;
// set null body if neither data|rawModeData nor dataMode is set, or if the dataMode is explicitly set to null
// The explicit null check is added to ensure that body is not set in case the dataMode was set to null by the
// app, but `data` or `rawModeData` was not empty
if ((!dataMode && _.isEmpty(requestV1.data) && _.isEmpty(requestV1.rawModeData)) ||
requestV1.dataMode === null) {
return retainEmpty ? null : undefined;
}
// set `rawModeData` if its a string
if (_.isString(requestV1.rawModeData)) {
rawModeData = requestV1.rawModeData;
}
// check if `rawModeData` is an array like: ['rawModeData']
else if (Array.isArray(requestV1.rawModeData) &&
requestV1.rawModeData.length === 1 &&
_.isString(requestV1.rawModeData[0])) {
rawModeData = requestV1.rawModeData[0];
}
// set data.mode.
// if dataMode is not set, infer from data or rawModeData
// at this point either data or rawModeData is set
if (dataMode) {
data.mode = dataMode;
}
// set `formdata` if rawModeData is not set and data is an array
// `data` takes higher precedence over `rawModeData`.
else if (!rawModeData && Array.isArray(requestV1.data || requestV1.rawModeData)) {
data.mode = 'formdata';
}
// set `raw` mode as default
else {
data.mode = 'raw';
}
if (data.mode === 'raw') {
if (rawModeData) {
data[data.mode] = rawModeData;
}
else if (_.isString(requestV1.data)) {
data[data.mode] = requestV1.data;
}
else {
data[data.mode] = ''; // empty string instead of retainEmpty check to have parity with other modes.
}
}
else if (data.mode === 'file') {
data[data.mode] = { src: rawModeData }; // rawModeData can be string or undefined.
}
else {
// parse data for formdata or urlencoded data modes.
// `rawModeData` is checked in case its of type `data`.
data[data.mode] = parseFormData(requestV1.data || requestV1.rawModeData, retainEmpty);
}
if (requestV1.dataDisabled) { data.disabled = true; }
else if (retainEmpty) { data.disabled = false; }
return data;
} | javascript | function (requestV1) {
var modes = {
urlencoded: 'urlencoded',
params: 'formdata',
raw: 'raw',
binary: 'file'
},
data = {},
rawModeData,
dataMode = modes[requestV1.dataMode],
retainEmpty = this.options.retainEmptyValues;
// set null body if neither data|rawModeData nor dataMode is set, or if the dataMode is explicitly set to null
// The explicit null check is added to ensure that body is not set in case the dataMode was set to null by the
// app, but `data` or `rawModeData` was not empty
if ((!dataMode && _.isEmpty(requestV1.data) && _.isEmpty(requestV1.rawModeData)) ||
requestV1.dataMode === null) {
return retainEmpty ? null : undefined;
}
// set `rawModeData` if its a string
if (_.isString(requestV1.rawModeData)) {
rawModeData = requestV1.rawModeData;
}
// check if `rawModeData` is an array like: ['rawModeData']
else if (Array.isArray(requestV1.rawModeData) &&
requestV1.rawModeData.length === 1 &&
_.isString(requestV1.rawModeData[0])) {
rawModeData = requestV1.rawModeData[0];
}
// set data.mode.
// if dataMode is not set, infer from data or rawModeData
// at this point either data or rawModeData is set
if (dataMode) {
data.mode = dataMode;
}
// set `formdata` if rawModeData is not set and data is an array
// `data` takes higher precedence over `rawModeData`.
else if (!rawModeData && Array.isArray(requestV1.data || requestV1.rawModeData)) {
data.mode = 'formdata';
}
// set `raw` mode as default
else {
data.mode = 'raw';
}
if (data.mode === 'raw') {
if (rawModeData) {
data[data.mode] = rawModeData;
}
else if (_.isString(requestV1.data)) {
data[data.mode] = requestV1.data;
}
else {
data[data.mode] = ''; // empty string instead of retainEmpty check to have parity with other modes.
}
}
else if (data.mode === 'file') {
data[data.mode] = { src: rawModeData }; // rawModeData can be string or undefined.
}
else {
// parse data for formdata or urlencoded data modes.
// `rawModeData` is checked in case its of type `data`.
data[data.mode] = parseFormData(requestV1.data || requestV1.rawModeData, retainEmpty);
}
if (requestV1.dataDisabled) { data.disabled = true; }
else if (retainEmpty) { data.disabled = false; }
return data;
} | [
"function",
"(",
"requestV1",
")",
"{",
"var",
"modes",
"=",
"{",
"urlencoded",
":",
"'urlencoded'",
",",
"params",
":",
"'formdata'",
",",
"raw",
":",
"'raw'",
",",
"binary",
":",
"'file'",
"}",
",",
"data",
"=",
"{",
"}",
",",
"rawModeData",
",",
"dataMode",
"=",
"modes",
"[",
"requestV1",
".",
"dataMode",
"]",
",",
"retainEmpty",
"=",
"this",
".",
"options",
".",
"retainEmptyValues",
";",
"// set null body if neither data|rawModeData nor dataMode is set, or if the dataMode is explicitly set to null",
"// The explicit null check is added to ensure that body is not set in case the dataMode was set to null by the",
"// app, but `data` or `rawModeData` was not empty",
"if",
"(",
"(",
"!",
"dataMode",
"&&",
"_",
".",
"isEmpty",
"(",
"requestV1",
".",
"data",
")",
"&&",
"_",
".",
"isEmpty",
"(",
"requestV1",
".",
"rawModeData",
")",
")",
"||",
"requestV1",
".",
"dataMode",
"===",
"null",
")",
"{",
"return",
"retainEmpty",
"?",
"null",
":",
"undefined",
";",
"}",
"// set `rawModeData` if its a string",
"if",
"(",
"_",
".",
"isString",
"(",
"requestV1",
".",
"rawModeData",
")",
")",
"{",
"rawModeData",
"=",
"requestV1",
".",
"rawModeData",
";",
"}",
"// check if `rawModeData` is an array like: ['rawModeData']",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"requestV1",
".",
"rawModeData",
")",
"&&",
"requestV1",
".",
"rawModeData",
".",
"length",
"===",
"1",
"&&",
"_",
".",
"isString",
"(",
"requestV1",
".",
"rawModeData",
"[",
"0",
"]",
")",
")",
"{",
"rawModeData",
"=",
"requestV1",
".",
"rawModeData",
"[",
"0",
"]",
";",
"}",
"// set data.mode.",
"// if dataMode is not set, infer from data or rawModeData",
"// at this point either data or rawModeData is set",
"if",
"(",
"dataMode",
")",
"{",
"data",
".",
"mode",
"=",
"dataMode",
";",
"}",
"// set `formdata` if rawModeData is not set and data is an array",
"// `data` takes higher precedence over `rawModeData`.",
"else",
"if",
"(",
"!",
"rawModeData",
"&&",
"Array",
".",
"isArray",
"(",
"requestV1",
".",
"data",
"||",
"requestV1",
".",
"rawModeData",
")",
")",
"{",
"data",
".",
"mode",
"=",
"'formdata'",
";",
"}",
"// set `raw` mode as default",
"else",
"{",
"data",
".",
"mode",
"=",
"'raw'",
";",
"}",
"if",
"(",
"data",
".",
"mode",
"===",
"'raw'",
")",
"{",
"if",
"(",
"rawModeData",
")",
"{",
"data",
"[",
"data",
".",
"mode",
"]",
"=",
"rawModeData",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"requestV1",
".",
"data",
")",
")",
"{",
"data",
"[",
"data",
".",
"mode",
"]",
"=",
"requestV1",
".",
"data",
";",
"}",
"else",
"{",
"data",
"[",
"data",
".",
"mode",
"]",
"=",
"''",
";",
"// empty string instead of retainEmpty check to have parity with other modes.",
"}",
"}",
"else",
"if",
"(",
"data",
".",
"mode",
"===",
"'file'",
")",
"{",
"data",
"[",
"data",
".",
"mode",
"]",
"=",
"{",
"src",
":",
"rawModeData",
"}",
";",
"// rawModeData can be string or undefined.",
"}",
"else",
"{",
"// parse data for formdata or urlencoded data modes.",
"// `rawModeData` is checked in case its of type `data`.",
"data",
"[",
"data",
".",
"mode",
"]",
"=",
"parseFormData",
"(",
"requestV1",
".",
"data",
"||",
"requestV1",
".",
"rawModeData",
",",
"retainEmpty",
")",
";",
"}",
"if",
"(",
"requestV1",
".",
"dataDisabled",
")",
"{",
"data",
".",
"disabled",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"retainEmpty",
")",
"{",
"data",
".",
"disabled",
"=",
"false",
";",
"}",
"return",
"data",
";",
"}"
] | Constructs a V2 Request compatible "body" object from a V1 Postman request
@param {Object} requestV1 - The v1 request to extract the body from.
@returns {{mode: *, content: (*|string)}} | [
"Constructs",
"a",
"V2",
"Request",
"compatible",
"body",
"object",
"from",
"a",
"V1",
"Postman",
"request"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L231-L302 | |
20,966 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (entityV1) {
if (!entityV1) { return; }
// if prioritizeV2 is true, events is used as the source of truth
if ((util.notLegacy(entityV1, 'event') || this.options.prioritizeV2) && !_.isEmpty(entityV1.events)) {
// in v1, `events` is regarded as the source of truth if it exists, so handle that first and bail out.
// @todo: Improve this to order prerequest events before test events
_.forEach(entityV1.events, function (event) {
!event.listen && (event.listen = 'test');
if (event.script) {
!event.script.type && (event.script.type = 'text/javascript');
// @todo: Add support for src
_.isString(event.script.exec) && (event.script.exec = event.script.exec.split('\n'));
}
});
return entityV1.events;
}
var events = [];
// @todo: Extract both flows below into a common method
if (entityV1.tests) {
events.push({
listen: 'test',
script: {
type: 'text/javascript',
exec: _.isString(entityV1.tests) ?
entityV1.tests.split('\n') :
entityV1.tests
}
});
}
if (entityV1.preRequestScript) {
events.push({
listen: 'prerequest',
script: {
type: 'text/javascript',
exec: _.isString(entityV1.preRequestScript) ?
entityV1.preRequestScript.split('\n') :
entityV1.preRequestScript
}
});
}
return events.length ? events : undefined;
} | javascript | function (entityV1) {
if (!entityV1) { return; }
// if prioritizeV2 is true, events is used as the source of truth
if ((util.notLegacy(entityV1, 'event') || this.options.prioritizeV2) && !_.isEmpty(entityV1.events)) {
// in v1, `events` is regarded as the source of truth if it exists, so handle that first and bail out.
// @todo: Improve this to order prerequest events before test events
_.forEach(entityV1.events, function (event) {
!event.listen && (event.listen = 'test');
if (event.script) {
!event.script.type && (event.script.type = 'text/javascript');
// @todo: Add support for src
_.isString(event.script.exec) && (event.script.exec = event.script.exec.split('\n'));
}
});
return entityV1.events;
}
var events = [];
// @todo: Extract both flows below into a common method
if (entityV1.tests) {
events.push({
listen: 'test',
script: {
type: 'text/javascript',
exec: _.isString(entityV1.tests) ?
entityV1.tests.split('\n') :
entityV1.tests
}
});
}
if (entityV1.preRequestScript) {
events.push({
listen: 'prerequest',
script: {
type: 'text/javascript',
exec: _.isString(entityV1.preRequestScript) ?
entityV1.preRequestScript.split('\n') :
entityV1.preRequestScript
}
});
}
return events.length ? events : undefined;
} | [
"function",
"(",
"entityV1",
")",
"{",
"if",
"(",
"!",
"entityV1",
")",
"{",
"return",
";",
"}",
"// if prioritizeV2 is true, events is used as the source of truth",
"if",
"(",
"(",
"util",
".",
"notLegacy",
"(",
"entityV1",
",",
"'event'",
")",
"||",
"this",
".",
"options",
".",
"prioritizeV2",
")",
"&&",
"!",
"_",
".",
"isEmpty",
"(",
"entityV1",
".",
"events",
")",
")",
"{",
"// in v1, `events` is regarded as the source of truth if it exists, so handle that first and bail out.",
"// @todo: Improve this to order prerequest events before test events",
"_",
".",
"forEach",
"(",
"entityV1",
".",
"events",
",",
"function",
"(",
"event",
")",
"{",
"!",
"event",
".",
"listen",
"&&",
"(",
"event",
".",
"listen",
"=",
"'test'",
")",
";",
"if",
"(",
"event",
".",
"script",
")",
"{",
"!",
"event",
".",
"script",
".",
"type",
"&&",
"(",
"event",
".",
"script",
".",
"type",
"=",
"'text/javascript'",
")",
";",
"// @todo: Add support for src",
"_",
".",
"isString",
"(",
"event",
".",
"script",
".",
"exec",
")",
"&&",
"(",
"event",
".",
"script",
".",
"exec",
"=",
"event",
".",
"script",
".",
"exec",
".",
"split",
"(",
"'\\n'",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"entityV1",
".",
"events",
";",
"}",
"var",
"events",
"=",
"[",
"]",
";",
"// @todo: Extract both flows below into a common method",
"if",
"(",
"entityV1",
".",
"tests",
")",
"{",
"events",
".",
"push",
"(",
"{",
"listen",
":",
"'test'",
",",
"script",
":",
"{",
"type",
":",
"'text/javascript'",
",",
"exec",
":",
"_",
".",
"isString",
"(",
"entityV1",
".",
"tests",
")",
"?",
"entityV1",
".",
"tests",
".",
"split",
"(",
"'\\n'",
")",
":",
"entityV1",
".",
"tests",
"}",
"}",
")",
";",
"}",
"if",
"(",
"entityV1",
".",
"preRequestScript",
")",
"{",
"events",
".",
"push",
"(",
"{",
"listen",
":",
"'prerequest'",
",",
"script",
":",
"{",
"type",
":",
"'text/javascript'",
",",
"exec",
":",
"_",
".",
"isString",
"(",
"entityV1",
".",
"preRequestScript",
")",
"?",
"entityV1",
".",
"preRequestScript",
".",
"split",
"(",
"'\\n'",
")",
":",
"entityV1",
".",
"preRequestScript",
"}",
"}",
")",
";",
"}",
"return",
"events",
".",
"length",
"?",
"events",
":",
"undefined",
";",
"}"
] | Constructs a V2 "events" object from a V1 Postman Request
@param {Object} entityV1 - The v1 entity to extract script information from.
@returns {Object[]|*} | [
"Constructs",
"a",
"V2",
"events",
"object",
"from",
"a",
"V1",
"Postman",
"Request"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L310-L358 | |
20,967 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (requestV1) {
var self = this,
request = {},
retainEmpty = self.options.retainEmptyValues,
units = ['auth', 'method', 'header', 'body', 'url'];
units.forEach(function (unit) {
request[unit] = self[unit](requestV1);
});
if (requestV1.description) { request.description = requestV1.description; }
else if (retainEmpty) { request.description = null; }
return request;
} | javascript | function (requestV1) {
var self = this,
request = {},
retainEmpty = self.options.retainEmptyValues,
units = ['auth', 'method', 'header', 'body', 'url'];
units.forEach(function (unit) {
request[unit] = self[unit](requestV1);
});
if (requestV1.description) { request.description = requestV1.description; }
else if (retainEmpty) { request.description = null; }
return request;
} | [
"function",
"(",
"requestV1",
")",
"{",
"var",
"self",
"=",
"this",
",",
"request",
"=",
"{",
"}",
",",
"retainEmpty",
"=",
"self",
".",
"options",
".",
"retainEmptyValues",
",",
"units",
"=",
"[",
"'auth'",
",",
"'method'",
",",
"'header'",
",",
"'body'",
",",
"'url'",
"]",
";",
"units",
".",
"forEach",
"(",
"function",
"(",
"unit",
")",
"{",
"request",
"[",
"unit",
"]",
"=",
"self",
"[",
"unit",
"]",
"(",
"requestV1",
")",
";",
"}",
")",
";",
"if",
"(",
"requestV1",
".",
"description",
")",
"{",
"request",
".",
"description",
"=",
"requestV1",
".",
"description",
";",
"}",
"else",
"if",
"(",
"retainEmpty",
")",
"{",
"request",
".",
"description",
"=",
"null",
";",
"}",
"return",
"request",
";",
"}"
] | Creates a V2 format request from a V1 Postman Collection Request
@param {Object} requestV1 - The v1 request to be transformed.
@returns {Object} - The converted v2 request. | [
"Creates",
"a",
"V2",
"format",
"request",
"from",
"a",
"V1",
"Postman",
"Collection",
"Request"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L409-L423 | |
20,968 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (cookieV1) {
return {
expires: (new Date(cookieV1.expirationDate * 1000)).toString(),
hostOnly: cookieV1.hostOnly,
httpOnly: cookieV1.httpOnly,
domain: cookieV1.domain,
path: cookieV1.path,
secure: cookieV1.secure,
session: cookieV1.session,
value: cookieV1.value,
key: cookieV1.name
};
} | javascript | function (cookieV1) {
return {
expires: (new Date(cookieV1.expirationDate * 1000)).toString(),
hostOnly: cookieV1.hostOnly,
httpOnly: cookieV1.httpOnly,
domain: cookieV1.domain,
path: cookieV1.path,
secure: cookieV1.secure,
session: cookieV1.session,
value: cookieV1.value,
key: cookieV1.name
};
} | [
"function",
"(",
"cookieV1",
")",
"{",
"return",
"{",
"expires",
":",
"(",
"new",
"Date",
"(",
"cookieV1",
".",
"expirationDate",
"*",
"1000",
")",
")",
".",
"toString",
"(",
")",
",",
"hostOnly",
":",
"cookieV1",
".",
"hostOnly",
",",
"httpOnly",
":",
"cookieV1",
".",
"httpOnly",
",",
"domain",
":",
"cookieV1",
".",
"domain",
",",
"path",
":",
"cookieV1",
".",
"path",
",",
"secure",
":",
"cookieV1",
".",
"secure",
",",
"session",
":",
"cookieV1",
".",
"session",
",",
"value",
":",
"cookieV1",
".",
"value",
",",
"key",
":",
"cookieV1",
".",
"name",
"}",
";",
"}"
] | Converts a V1 cookie to a V2 cookie.
@param {Object} cookieV1 - The v1 cookie object to convert.
@returns {{expires: string, hostOnly: *, httpOnly: *, domain: *, path: *, secure: *, session: *, value: *}} | [
"Converts",
"a",
"V1",
"cookie",
"to",
"a",
"V2",
"cookie",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L431-L443 | |
20,969 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (responseV1) {
var self = this,
associatedRequestId;
if (responseV1.requestObject) {
if (_.isString(responseV1.requestObject)) {
try {
return JSON.parse(responseV1.requestObject);
}
catch (e) {
// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable
associatedRequestId = responseV1.requestObject;
}
}
else {
return responseV1.requestObject;
}
}
if (responseV1.request) {
if (_.isString(responseV1.request)) {
try {
return JSON.parse(responseV1.request);
}
catch (e) {
// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable
associatedRequestId = responseV1.request;
}
}
else {
return responseV1.request;
}
}
// we have a request ID
return associatedRequestId && _.get(self, ['cache', associatedRequestId]);
} | javascript | function (responseV1) {
var self = this,
associatedRequestId;
if (responseV1.requestObject) {
if (_.isString(responseV1.requestObject)) {
try {
return JSON.parse(responseV1.requestObject);
}
catch (e) {
// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable
associatedRequestId = responseV1.requestObject;
}
}
else {
return responseV1.requestObject;
}
}
if (responseV1.request) {
if (_.isString(responseV1.request)) {
try {
return JSON.parse(responseV1.request);
}
catch (e) {
// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable
associatedRequestId = responseV1.request;
}
}
else {
return responseV1.request;
}
}
// we have a request ID
return associatedRequestId && _.get(self, ['cache', associatedRequestId]);
} | [
"function",
"(",
"responseV1",
")",
"{",
"var",
"self",
"=",
"this",
",",
"associatedRequestId",
";",
"if",
"(",
"responseV1",
".",
"requestObject",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"responseV1",
".",
"requestObject",
")",
")",
"{",
"try",
"{",
"return",
"JSON",
".",
"parse",
"(",
"responseV1",
".",
"requestObject",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable",
"associatedRequestId",
"=",
"responseV1",
".",
"requestObject",
";",
"}",
"}",
"else",
"{",
"return",
"responseV1",
".",
"requestObject",
";",
"}",
"}",
"if",
"(",
"responseV1",
".",
"request",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"responseV1",
".",
"request",
")",
")",
"{",
"try",
"{",
"return",
"JSON",
".",
"parse",
"(",
"responseV1",
".",
"request",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// if there was an error parsing it as JSON, it's probably an ID, so store it in the ID variable",
"associatedRequestId",
"=",
"responseV1",
".",
"request",
";",
"}",
"}",
"else",
"{",
"return",
"responseV1",
".",
"request",
";",
"}",
"}",
"// we have a request ID",
"return",
"associatedRequestId",
"&&",
"_",
".",
"get",
"(",
"self",
",",
"[",
"'cache'",
",",
"associatedRequestId",
"]",
")",
";",
"}"
] | Gets the saved request for the given response, and handles edge cases between Apps & Sync
Handles a lot of edge cases, so the code is not very clean.
The Flow followed here is:
If responseV1.requestObject is present
If it is a string
Try parsing it as JSON
If parsed,
return it
else
It is a request ID
If responseV1.request is present
If it is a string
Try parsing it as JSON
If parsed,
return it
else
It is a request ID
Look up the collection for the request ID and return it, or return undefined.
@param {Object} responseV1 - The v1 response to be converted.
@returns {Object} - The converted saved request, in v2 format. | [
"Gets",
"the",
"saved",
"request",
"for",
"the",
"given",
"response",
"and",
"handles",
"edge",
"cases",
"between",
"Apps",
"&",
"Sync"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L471-L507 | |
20,970 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (responseV1) {
var response = {},
self = this,
originalRequest;
originalRequest = self.savedRequest(responseV1);
// add ids to the v2 result only if both: the id and retainIds are truthy.
// this prevents successive exports to v2 from being overwhelmed by id diffs
self.options.retainIds && (response.id = responseV1.id || util.uid());
response.name = responseV1.name || 'response';
response.originalRequest = originalRequest ? self.request(originalRequest) : undefined;
response.status = responseV1.responseCode && responseV1.responseCode.name || undefined;
response.code = responseV1.responseCode && responseV1.responseCode.code || undefined;
response._postman_previewlanguage = responseV1.language;
response._postman_previewtype = responseV1.previewType;
response.header = responseV1.headers;
response.cookie = _.map(responseV1.cookies, function (cookie) {
return self.cookie(cookie);
});
response.responseTime = responseV1.time;
response.body = responseV1.text;
return response;
} | javascript | function (responseV1) {
var response = {},
self = this,
originalRequest;
originalRequest = self.savedRequest(responseV1);
// add ids to the v2 result only if both: the id and retainIds are truthy.
// this prevents successive exports to v2 from being overwhelmed by id diffs
self.options.retainIds && (response.id = responseV1.id || util.uid());
response.name = responseV1.name || 'response';
response.originalRequest = originalRequest ? self.request(originalRequest) : undefined;
response.status = responseV1.responseCode && responseV1.responseCode.name || undefined;
response.code = responseV1.responseCode && responseV1.responseCode.code || undefined;
response._postman_previewlanguage = responseV1.language;
response._postman_previewtype = responseV1.previewType;
response.header = responseV1.headers;
response.cookie = _.map(responseV1.cookies, function (cookie) {
return self.cookie(cookie);
});
response.responseTime = responseV1.time;
response.body = responseV1.text;
return response;
} | [
"function",
"(",
"responseV1",
")",
"{",
"var",
"response",
"=",
"{",
"}",
",",
"self",
"=",
"this",
",",
"originalRequest",
";",
"originalRequest",
"=",
"self",
".",
"savedRequest",
"(",
"responseV1",
")",
";",
"// add ids to the v2 result only if both: the id and retainIds are truthy.",
"// this prevents successive exports to v2 from being overwhelmed by id diffs",
"self",
".",
"options",
".",
"retainIds",
"&&",
"(",
"response",
".",
"id",
"=",
"responseV1",
".",
"id",
"||",
"util",
".",
"uid",
"(",
")",
")",
";",
"response",
".",
"name",
"=",
"responseV1",
".",
"name",
"||",
"'response'",
";",
"response",
".",
"originalRequest",
"=",
"originalRequest",
"?",
"self",
".",
"request",
"(",
"originalRequest",
")",
":",
"undefined",
";",
"response",
".",
"status",
"=",
"responseV1",
".",
"responseCode",
"&&",
"responseV1",
".",
"responseCode",
".",
"name",
"||",
"undefined",
";",
"response",
".",
"code",
"=",
"responseV1",
".",
"responseCode",
"&&",
"responseV1",
".",
"responseCode",
".",
"code",
"||",
"undefined",
";",
"response",
".",
"_postman_previewlanguage",
"=",
"responseV1",
".",
"language",
";",
"response",
".",
"_postman_previewtype",
"=",
"responseV1",
".",
"previewType",
";",
"response",
".",
"header",
"=",
"responseV1",
".",
"headers",
";",
"response",
".",
"cookie",
"=",
"_",
".",
"map",
"(",
"responseV1",
".",
"cookies",
",",
"function",
"(",
"cookie",
")",
"{",
"return",
"self",
".",
"cookie",
"(",
"cookie",
")",
";",
"}",
")",
";",
"response",
".",
"responseTime",
"=",
"responseV1",
".",
"time",
";",
"response",
".",
"body",
"=",
"responseV1",
".",
"text",
";",
"return",
"response",
";",
"}"
] | Since a V2 response contains the entire associated request that was sent, creating the response means it
also must use the V1 request.
@param {Object} responseV1 - The response object to convert from v1 to v2.
@returns {Object} - The v2 response object. | [
"Since",
"a",
"V2",
"response",
"contains",
"the",
"entire",
"associated",
"request",
"that",
"was",
"sent",
"creating",
"the",
"response",
"means",
"it",
"also",
"must",
"use",
"the",
"V1",
"request",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L516-L541 | |
20,971 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (requestV1) {
if (!requestV1) { return; }
var self = this,
units = ['request', 'response'],
variable = self.variable(requestV1),
item = {
name: requestV1.name || '', // Inline building to avoid additional function call
event: self.event(requestV1)
};
self.options.retainIds && (item._postman_id = requestV1.id || util.uid());
// add protocolProfileBehavior property from requestV1 to the item
util.addProtocolProfileBehavior(requestV1, item);
units.forEach(function (unit) {
item[unit] = self[unit](requestV1);
});
variable && variable.length && (item.variable = variable);
return item;
} | javascript | function (requestV1) {
if (!requestV1) { return; }
var self = this,
units = ['request', 'response'],
variable = self.variable(requestV1),
item = {
name: requestV1.name || '', // Inline building to avoid additional function call
event: self.event(requestV1)
};
self.options.retainIds && (item._postman_id = requestV1.id || util.uid());
// add protocolProfileBehavior property from requestV1 to the item
util.addProtocolProfileBehavior(requestV1, item);
units.forEach(function (unit) {
item[unit] = self[unit](requestV1);
});
variable && variable.length && (item.variable = variable);
return item;
} | [
"function",
"(",
"requestV1",
")",
"{",
"if",
"(",
"!",
"requestV1",
")",
"{",
"return",
";",
"}",
"var",
"self",
"=",
"this",
",",
"units",
"=",
"[",
"'request'",
",",
"'response'",
"]",
",",
"variable",
"=",
"self",
".",
"variable",
"(",
"requestV1",
")",
",",
"item",
"=",
"{",
"name",
":",
"requestV1",
".",
"name",
"||",
"''",
",",
"// Inline building to avoid additional function call",
"event",
":",
"self",
".",
"event",
"(",
"requestV1",
")",
"}",
";",
"self",
".",
"options",
".",
"retainIds",
"&&",
"(",
"item",
".",
"_postman_id",
"=",
"requestV1",
".",
"id",
"||",
"util",
".",
"uid",
"(",
")",
")",
";",
"// add protocolProfileBehavior property from requestV1 to the item",
"util",
".",
"addProtocolProfileBehavior",
"(",
"requestV1",
",",
"item",
")",
";",
"units",
".",
"forEach",
"(",
"function",
"(",
"unit",
")",
"{",
"item",
"[",
"unit",
"]",
"=",
"self",
"[",
"unit",
"]",
"(",
"requestV1",
")",
";",
"}",
")",
";",
"variable",
"&&",
"variable",
".",
"length",
"&&",
"(",
"item",
".",
"variable",
"=",
"variable",
")",
";",
"return",
"item",
";",
"}"
] | Creates a V2 compatible ``item`` from a V1 Postman Collection Request
@param {Object} requestV1 - Postman collection V1 request.
@returns {Object} - The converted request object, in v2 format. | [
"Creates",
"a",
"V2",
"compatible",
"item",
"from",
"a",
"V1",
"Postman",
"Collection",
"Request"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L564-L586 | |
20,972 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (collectionV1) {
var self = this,
items = [],
itemGroupCache = {},
retainEmpty = self.options.retainEmptyValues;
// Read all folder data, and prep it so that we can throw subfolders in the right places
itemGroupCache = _.reduce(collectionV1.folders, function (accumulator, folder) {
if (!folder) { return accumulator; }
var auth = self.auth(folder),
event = self.event(folder),
variable = self.variable(folder),
result = {
name: folder.name,
item: []
};
self.options.retainIds && (result._postman_id = folder.id || util.uid());
if (folder.description) { result.description = folder.description; }
else if (retainEmpty) { result.description = null; }
(auth || (auth === null)) && (result.auth = auth);
event && (result.event = event);
variable && variable.length && (result.variable = variable);
accumulator[folder.id] = result;
return accumulator;
}, {});
// Populate each ItemGroup with subfolders
_.forEach(collectionV1.folders, function (folderV1) {
if (!folderV1) { return; }
var itemGroup = itemGroupCache[folderV1.id],
hasSubfolders = folderV1.folders_order && folderV1.folders_order.length,
hasRequests = folderV1.order && folderV1.order.length;
// Add subfolders
hasSubfolders && _.forEach(folderV1.folders_order, function (subFolderId) {
if (!itemGroupCache[subFolderId]) {
// todo: figure out what to do when a collection contains a subfolder ID,
// but the subfolder is not actually there.
return;
}
itemGroupCache[subFolderId]._postman_isSubFolder = true;
itemGroup.item.push(itemGroupCache[subFolderId]);
});
// Add items
hasRequests && _.forEach(folderV1.order, function (requestId) {
if (!self.cache[requestId]) {
// todo: what do we do here??
return;
}
itemGroup.item.push(self.singleItem(self.cache[requestId]));
});
});
// This compromises some self-healing, which was originally present, but the performance cost of
// doing self-healing the right way is high, so we directly rely on collectionV1.folders_order
// The self-healing way would be to iterate over itemGroupCache directly, but preserving the right order
// becomes a pain in that case.
_.forEach(_.uniq(collectionV1.folders_order || _.map(collectionV1.folders, 'id')), function (folderId) {
var itemGroup = itemGroupCache[folderId];
itemGroup && !_.get(itemGroup, '_postman_isSubFolder') && items.push(itemGroup);
});
// This is useful later
self.itemGroupCache = itemGroupCache;
return _.compact(items);
} | javascript | function (collectionV1) {
var self = this,
items = [],
itemGroupCache = {},
retainEmpty = self.options.retainEmptyValues;
// Read all folder data, and prep it so that we can throw subfolders in the right places
itemGroupCache = _.reduce(collectionV1.folders, function (accumulator, folder) {
if (!folder) { return accumulator; }
var auth = self.auth(folder),
event = self.event(folder),
variable = self.variable(folder),
result = {
name: folder.name,
item: []
};
self.options.retainIds && (result._postman_id = folder.id || util.uid());
if (folder.description) { result.description = folder.description; }
else if (retainEmpty) { result.description = null; }
(auth || (auth === null)) && (result.auth = auth);
event && (result.event = event);
variable && variable.length && (result.variable = variable);
accumulator[folder.id] = result;
return accumulator;
}, {});
// Populate each ItemGroup with subfolders
_.forEach(collectionV1.folders, function (folderV1) {
if (!folderV1) { return; }
var itemGroup = itemGroupCache[folderV1.id],
hasSubfolders = folderV1.folders_order && folderV1.folders_order.length,
hasRequests = folderV1.order && folderV1.order.length;
// Add subfolders
hasSubfolders && _.forEach(folderV1.folders_order, function (subFolderId) {
if (!itemGroupCache[subFolderId]) {
// todo: figure out what to do when a collection contains a subfolder ID,
// but the subfolder is not actually there.
return;
}
itemGroupCache[subFolderId]._postman_isSubFolder = true;
itemGroup.item.push(itemGroupCache[subFolderId]);
});
// Add items
hasRequests && _.forEach(folderV1.order, function (requestId) {
if (!self.cache[requestId]) {
// todo: what do we do here??
return;
}
itemGroup.item.push(self.singleItem(self.cache[requestId]));
});
});
// This compromises some self-healing, which was originally present, but the performance cost of
// doing self-healing the right way is high, so we directly rely on collectionV1.folders_order
// The self-healing way would be to iterate over itemGroupCache directly, but preserving the right order
// becomes a pain in that case.
_.forEach(_.uniq(collectionV1.folders_order || _.map(collectionV1.folders, 'id')), function (folderId) {
var itemGroup = itemGroupCache[folderId];
itemGroup && !_.get(itemGroup, '_postman_isSubFolder') && items.push(itemGroup);
});
// This is useful later
self.itemGroupCache = itemGroupCache;
return _.compact(items);
} | [
"function",
"(",
"collectionV1",
")",
"{",
"var",
"self",
"=",
"this",
",",
"items",
"=",
"[",
"]",
",",
"itemGroupCache",
"=",
"{",
"}",
",",
"retainEmpty",
"=",
"self",
".",
"options",
".",
"retainEmptyValues",
";",
"// Read all folder data, and prep it so that we can throw subfolders in the right places",
"itemGroupCache",
"=",
"_",
".",
"reduce",
"(",
"collectionV1",
".",
"folders",
",",
"function",
"(",
"accumulator",
",",
"folder",
")",
"{",
"if",
"(",
"!",
"folder",
")",
"{",
"return",
"accumulator",
";",
"}",
"var",
"auth",
"=",
"self",
".",
"auth",
"(",
"folder",
")",
",",
"event",
"=",
"self",
".",
"event",
"(",
"folder",
")",
",",
"variable",
"=",
"self",
".",
"variable",
"(",
"folder",
")",
",",
"result",
"=",
"{",
"name",
":",
"folder",
".",
"name",
",",
"item",
":",
"[",
"]",
"}",
";",
"self",
".",
"options",
".",
"retainIds",
"&&",
"(",
"result",
".",
"_postman_id",
"=",
"folder",
".",
"id",
"||",
"util",
".",
"uid",
"(",
")",
")",
";",
"if",
"(",
"folder",
".",
"description",
")",
"{",
"result",
".",
"description",
"=",
"folder",
".",
"description",
";",
"}",
"else",
"if",
"(",
"retainEmpty",
")",
"{",
"result",
".",
"description",
"=",
"null",
";",
"}",
"(",
"auth",
"||",
"(",
"auth",
"===",
"null",
")",
")",
"&&",
"(",
"result",
".",
"auth",
"=",
"auth",
")",
";",
"event",
"&&",
"(",
"result",
".",
"event",
"=",
"event",
")",
";",
"variable",
"&&",
"variable",
".",
"length",
"&&",
"(",
"result",
".",
"variable",
"=",
"variable",
")",
";",
"accumulator",
"[",
"folder",
".",
"id",
"]",
"=",
"result",
";",
"return",
"accumulator",
";",
"}",
",",
"{",
"}",
")",
";",
"// Populate each ItemGroup with subfolders",
"_",
".",
"forEach",
"(",
"collectionV1",
".",
"folders",
",",
"function",
"(",
"folderV1",
")",
"{",
"if",
"(",
"!",
"folderV1",
")",
"{",
"return",
";",
"}",
"var",
"itemGroup",
"=",
"itemGroupCache",
"[",
"folderV1",
".",
"id",
"]",
",",
"hasSubfolders",
"=",
"folderV1",
".",
"folders_order",
"&&",
"folderV1",
".",
"folders_order",
".",
"length",
",",
"hasRequests",
"=",
"folderV1",
".",
"order",
"&&",
"folderV1",
".",
"order",
".",
"length",
";",
"// Add subfolders",
"hasSubfolders",
"&&",
"_",
".",
"forEach",
"(",
"folderV1",
".",
"folders_order",
",",
"function",
"(",
"subFolderId",
")",
"{",
"if",
"(",
"!",
"itemGroupCache",
"[",
"subFolderId",
"]",
")",
"{",
"// todo: figure out what to do when a collection contains a subfolder ID,",
"// but the subfolder is not actually there.",
"return",
";",
"}",
"itemGroupCache",
"[",
"subFolderId",
"]",
".",
"_postman_isSubFolder",
"=",
"true",
";",
"itemGroup",
".",
"item",
".",
"push",
"(",
"itemGroupCache",
"[",
"subFolderId",
"]",
")",
";",
"}",
")",
";",
"// Add items",
"hasRequests",
"&&",
"_",
".",
"forEach",
"(",
"folderV1",
".",
"order",
",",
"function",
"(",
"requestId",
")",
"{",
"if",
"(",
"!",
"self",
".",
"cache",
"[",
"requestId",
"]",
")",
"{",
"// todo: what do we do here??",
"return",
";",
"}",
"itemGroup",
".",
"item",
".",
"push",
"(",
"self",
".",
"singleItem",
"(",
"self",
".",
"cache",
"[",
"requestId",
"]",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"// This compromises some self-healing, which was originally present, but the performance cost of",
"// doing self-healing the right way is high, so we directly rely on collectionV1.folders_order",
"// The self-healing way would be to iterate over itemGroupCache directly, but preserving the right order",
"// becomes a pain in that case.",
"_",
".",
"forEach",
"(",
"_",
".",
"uniq",
"(",
"collectionV1",
".",
"folders_order",
"||",
"_",
".",
"map",
"(",
"collectionV1",
".",
"folders",
",",
"'id'",
")",
")",
",",
"function",
"(",
"folderId",
")",
"{",
"var",
"itemGroup",
"=",
"itemGroupCache",
"[",
"folderId",
"]",
";",
"itemGroup",
"&&",
"!",
"_",
".",
"get",
"(",
"itemGroup",
",",
"'_postman_isSubFolder'",
")",
"&&",
"items",
".",
"push",
"(",
"itemGroup",
")",
";",
"}",
")",
";",
"// This is useful later",
"self",
".",
"itemGroupCache",
"=",
"itemGroupCache",
";",
"return",
"_",
".",
"compact",
"(",
"items",
")",
";",
"}"
] | Constructs an array of Items & ItemGroups compatible with the V2 format.
@param {Object} collectionV1 - The v1 collection to derive folder information from.
@returns {Object[]} - The list of item group definitions. | [
"Constructs",
"an",
"array",
"of",
"Items",
"&",
"ItemGroups",
"compatible",
"with",
"the",
"V2",
"format",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L594-L672 | |
20,973 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (collectionV1) {
var self = this,
requestsCache = _.keyBy(collectionV1.requests, 'id'),
allRequests = _.map(collectionV1.requests, 'id'),
result;
self.cache = requestsCache;
result = self.itemGroups(collectionV1);
_.forEach(_.intersection(collectionV1.order, allRequests), function (requestId) {
var request = self.singleItem(requestsCache[requestId]);
request && (result.push(request));
});
return result;
} | javascript | function (collectionV1) {
var self = this,
requestsCache = _.keyBy(collectionV1.requests, 'id'),
allRequests = _.map(collectionV1.requests, 'id'),
result;
self.cache = requestsCache;
result = self.itemGroups(collectionV1);
_.forEach(_.intersection(collectionV1.order, allRequests), function (requestId) {
var request = self.singleItem(requestsCache[requestId]);
request && (result.push(request));
});
return result;
} | [
"function",
"(",
"collectionV1",
")",
"{",
"var",
"self",
"=",
"this",
",",
"requestsCache",
"=",
"_",
".",
"keyBy",
"(",
"collectionV1",
".",
"requests",
",",
"'id'",
")",
",",
"allRequests",
"=",
"_",
".",
"map",
"(",
"collectionV1",
".",
"requests",
",",
"'id'",
")",
",",
"result",
";",
"self",
".",
"cache",
"=",
"requestsCache",
";",
"result",
"=",
"self",
".",
"itemGroups",
"(",
"collectionV1",
")",
";",
"_",
".",
"forEach",
"(",
"_",
".",
"intersection",
"(",
"collectionV1",
".",
"order",
",",
"allRequests",
")",
",",
"function",
"(",
"requestId",
")",
"{",
"var",
"request",
"=",
"self",
".",
"singleItem",
"(",
"requestsCache",
"[",
"requestId",
"]",
")",
";",
"request",
"&&",
"(",
"result",
".",
"push",
"(",
"request",
")",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Creates a V2 compatible array of items from a V1 Postman Collection
@param {Object} collectionV1 - A Postman Collection object in the V1 format.
@returns {Object[]} - The list of item groups (folders) in v2 format. | [
"Creates",
"a",
"V2",
"compatible",
"array",
"of",
"items",
"from",
"a",
"V1",
"Postman",
"Collection"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L680-L696 | |
20,974 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (request, options, callback) {
var builders = new Builders(options),
converted,
err;
try {
converted = builders.singleItem(_.cloneDeep(request));
}
catch (e) {
err = e;
}
if (callback) {
return callback(err, converted);
}
if (err) {
throw err;
}
return converted;
} | javascript | function (request, options, callback) {
var builders = new Builders(options),
converted,
err;
try {
converted = builders.singleItem(_.cloneDeep(request));
}
catch (e) {
err = e;
}
if (callback) {
return callback(err, converted);
}
if (err) {
throw err;
}
return converted;
} | [
"function",
"(",
"request",
",",
"options",
",",
"callback",
")",
"{",
"var",
"builders",
"=",
"new",
"Builders",
"(",
"options",
")",
",",
"converted",
",",
"err",
";",
"try",
"{",
"converted",
"=",
"builders",
".",
"singleItem",
"(",
"_",
".",
"cloneDeep",
"(",
"request",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"err",
"=",
"e",
";",
"}",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"err",
",",
"converted",
")",
";",
"}",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"return",
"converted",
";",
"}"
] | Converts a single V1 request to a V2 item.
@param {Object} request - The v1 request to convert to v2.
@param {Object} options - The set of options for v1 -> v2 conversion.
@param {Function} callback - The function to be invoked when the conversion has completed. | [
"Converts",
"a",
"single",
"V1",
"request",
"to",
"a",
"V2",
"item",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L711-L732 | |
20,975 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v2.js | function (response, options, callback) {
var builders = new Builders(options),
converted,
err;
try {
converted = builders.singleResponse(_.cloneDeep(response));
}
catch (e) {
err = e;
}
if (callback) {
return callback(err, converted);
}
if (err) {
throw err;
}
return converted;
} | javascript | function (response, options, callback) {
var builders = new Builders(options),
converted,
err;
try {
converted = builders.singleResponse(_.cloneDeep(response));
}
catch (e) {
err = e;
}
if (callback) {
return callback(err, converted);
}
if (err) {
throw err;
}
return converted;
} | [
"function",
"(",
"response",
",",
"options",
",",
"callback",
")",
"{",
"var",
"builders",
"=",
"new",
"Builders",
"(",
"options",
")",
",",
"converted",
",",
"err",
";",
"try",
"{",
"converted",
"=",
"builders",
".",
"singleResponse",
"(",
"_",
".",
"cloneDeep",
"(",
"response",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"err",
"=",
"e",
";",
"}",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"err",
",",
"converted",
")",
";",
"}",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"return",
"converted",
";",
"}"
] | Converts a single V1 Response to a V2 Response.
@param {Object} response - The v1 response to convert to v2.
@param {Object} options - The set of options for v1 -> v2 conversion.
@param {Function} callback - The function to be invoked when the conversion has completed. | [
"Converts",
"a",
"single",
"V1",
"Response",
"to",
"a",
"V2",
"Response",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v2.js#L741-L762 | |
20,976 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v21.js | function (collectionV1) {
var info = Builders.super_.prototype.info.call(this, collectionV1);
info.schema = constants.SCHEMA_V2_1_0_URL;
return info;
} | javascript | function (collectionV1) {
var info = Builders.super_.prototype.info.call(this, collectionV1);
info.schema = constants.SCHEMA_V2_1_0_URL;
return info;
} | [
"function",
"(",
"collectionV1",
")",
"{",
"var",
"info",
"=",
"Builders",
".",
"super_",
".",
"prototype",
".",
"info",
".",
"call",
"(",
"this",
",",
"collectionV1",
")",
";",
"info",
".",
"schema",
"=",
"constants",
".",
"SCHEMA_V2_1_0_URL",
";",
"return",
"info",
";",
"}"
] | Derives v2.1.0 collection info from a v1.0.0 collection object.
@param {Object} collectionV1 - The v1.0.0 collection object to be converted to v2.1.0.
@return {Object} - The compiled v2.x collection info manifest. | [
"Derives",
"v2",
".",
"1",
".",
"0",
"collection",
"info",
"from",
"a",
"v1",
".",
"0",
".",
"0",
"collection",
"object",
"."
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v21.js#L25-L31 | |
20,977 | postmanlabs/postman-collection-transformer | lib/converters/v1.0.0/converter-v1-to-v21.js | function (requestV1) {
var v21Url = Builders.super_.prototype.url.call(this, requestV1);
return _.isString(v21Url) ? url.parse(v21Url) : v21Url;
} | javascript | function (requestV1) {
var v21Url = Builders.super_.prototype.url.call(this, requestV1);
return _.isString(v21Url) ? url.parse(v21Url) : v21Url;
} | [
"function",
"(",
"requestV1",
")",
"{",
"var",
"v21Url",
"=",
"Builders",
".",
"super_",
".",
"prototype",
".",
"url",
".",
"call",
"(",
"this",
",",
"requestV1",
")",
";",
"return",
"_",
".",
"isString",
"(",
"v21Url",
")",
"?",
"url",
".",
"parse",
"(",
"v21Url",
")",
":",
"v21Url",
";",
"}"
] | Converts collection request urls from v1.0.0 to v2.1.0
@param {Object} requestV1 - The v1.0.0 request url to be converted to v2.1.0.
@return {Object} - The objectified v2.1.0 compliant URL. | [
"Converts",
"collection",
"request",
"urls",
"from",
"v1",
".",
"0",
".",
"0",
"to",
"v2",
".",
"1",
".",
"0"
] | 5aef67c842651e7ad0851882f81f2fe48c0d7802 | https://github.com/postmanlabs/postman-collection-transformer/blob/5aef67c842651e7ad0851882f81f2fe48c0d7802/lib/converters/v1.0.0/converter-v1-to-v21.js#L39-L43 | |
20,978 | PingPlusPlus/pingpp-nodejs | lib/PingppResource.js | PingppResource | function PingppResource(pingpp, urlData) {
this._pingpp = pingpp;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(pingpp.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(function(methodName) {
this[methodName] = PingppResource.BASIC_METHODS[methodName];
}, this);
}
this.initialize.apply(this, arguments);
} | javascript | function PingppResource(pingpp, urlData) {
this._pingpp = pingpp;
this._urlData = urlData || {};
this.basePath = utils.makeURLInterpolator(pingpp.getApiField('basePath'));
this.path = utils.makeURLInterpolator(this.path);
if (this.includeBasic) {
this.includeBasic.forEach(function(methodName) {
this[methodName] = PingppResource.BASIC_METHODS[methodName];
}, this);
}
this.initialize.apply(this, arguments);
} | [
"function",
"PingppResource",
"(",
"pingpp",
",",
"urlData",
")",
"{",
"this",
".",
"_pingpp",
"=",
"pingpp",
";",
"this",
".",
"_urlData",
"=",
"urlData",
"||",
"{",
"}",
";",
"this",
".",
"basePath",
"=",
"utils",
".",
"makeURLInterpolator",
"(",
"pingpp",
".",
"getApiField",
"(",
"'basePath'",
")",
")",
";",
"this",
".",
"path",
"=",
"utils",
".",
"makeURLInterpolator",
"(",
"this",
".",
"path",
")",
";",
"if",
"(",
"this",
".",
"includeBasic",
")",
"{",
"this",
".",
"includeBasic",
".",
"forEach",
"(",
"function",
"(",
"methodName",
")",
"{",
"this",
"[",
"methodName",
"]",
"=",
"PingppResource",
".",
"BASIC_METHODS",
"[",
"methodName",
"]",
";",
"}",
",",
"this",
")",
";",
"}",
"this",
".",
"initialize",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}"
] | Encapsulates request logic for a Pingpp Resource | [
"Encapsulates",
"request",
"logic",
"for",
"a",
"Pingpp",
"Resource"
] | f2a44d9e7441f581d2e34cc3f1ab1c4ef557ba7c | https://github.com/PingPlusPlus/pingpp-nodejs/blob/f2a44d9e7441f581d2e34cc3f1ab1c4ef557ba7c/lib/PingppResource.js#L23-L37 |
20,979 | component/merge-descriptors | index.js | merge | function merge (dest, src, redefine) {
if (!dest) {
throw new TypeError('argument dest is required')
}
if (!src) {
throw new TypeError('argument src is required')
}
if (redefine === undefined) {
// Default to true
redefine = true
}
Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName (name) {
if (!redefine && hasOwnProperty.call(dest, name)) {
// Skip descriptor
return
}
// Copy descriptor
var descriptor = Object.getOwnPropertyDescriptor(src, name)
Object.defineProperty(dest, name, descriptor)
})
return dest
} | javascript | function merge (dest, src, redefine) {
if (!dest) {
throw new TypeError('argument dest is required')
}
if (!src) {
throw new TypeError('argument src is required')
}
if (redefine === undefined) {
// Default to true
redefine = true
}
Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName (name) {
if (!redefine && hasOwnProperty.call(dest, name)) {
// Skip descriptor
return
}
// Copy descriptor
var descriptor = Object.getOwnPropertyDescriptor(src, name)
Object.defineProperty(dest, name, descriptor)
})
return dest
} | [
"function",
"merge",
"(",
"dest",
",",
"src",
",",
"redefine",
")",
"{",
"if",
"(",
"!",
"dest",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'argument dest is required'",
")",
"}",
"if",
"(",
"!",
"src",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'argument src is required'",
")",
"}",
"if",
"(",
"redefine",
"===",
"undefined",
")",
"{",
"// Default to true",
"redefine",
"=",
"true",
"}",
"Object",
".",
"getOwnPropertyNames",
"(",
"src",
")",
".",
"forEach",
"(",
"function",
"forEachOwnPropertyName",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"redefine",
"&&",
"hasOwnProperty",
".",
"call",
"(",
"dest",
",",
"name",
")",
")",
"{",
"// Skip descriptor",
"return",
"}",
"// Copy descriptor",
"var",
"descriptor",
"=",
"Object",
".",
"getOwnPropertyDescriptor",
"(",
"src",
",",
"name",
")",
"Object",
".",
"defineProperty",
"(",
"dest",
",",
"name",
",",
"descriptor",
")",
"}",
")",
"return",
"dest",
"}"
] | Merge the property descriptors of `src` into `dest`
@param {object} dest Object to add descriptors to
@param {object} src Object to clone descriptors from
@param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
@returns {object} Reference to dest
@public | [
"Merge",
"the",
"property",
"descriptors",
"of",
"src",
"into",
"dest"
] | dec51af1c9e3c1ee30e2258d7de9f676f5d30771 | https://github.com/component/merge-descriptors/blob/dec51af1c9e3c1ee30e2258d7de9f676f5d30771/index.js#L34-L60 |
20,980 | restify/clients | lib/helpers/timings.js | getTimings | function getTimings (eventTimes) {
return {
// There is no DNS lookup with IP address, can be null
dnsLookup: getHrTimeDurationInMs(
eventTimes.startAt,
eventTimes.dnsLookupAt
),
tcpConnection: getHrTimeDurationInMs(
eventTimes.dnsLookupAt || eventTimes.startAt,
eventTimes.tcpConnectionAt
),
// There is no TLS handshake without https, can be null
tlsHandshake: getHrTimeDurationInMs(
eventTimes.tcpConnectionAt,
eventTimes.tlsHandshakeAt
),
firstByte: getHrTimeDurationInMs((
// There is no TLS/TCP Connection with keep-alive connection
eventTimes.tlsHandshakeAt || eventTimes.tcpConnectionAt ||
eventTimes.startAt),
eventTimes.firstByteAt
),
contentTransfer: getHrTimeDurationInMs(
eventTimes.firstByteAt,
eventTimes.endAt
),
total: getHrTimeDurationInMs(eventTimes.startAt, eventTimes.endAt)
};
} | javascript | function getTimings (eventTimes) {
return {
// There is no DNS lookup with IP address, can be null
dnsLookup: getHrTimeDurationInMs(
eventTimes.startAt,
eventTimes.dnsLookupAt
),
tcpConnection: getHrTimeDurationInMs(
eventTimes.dnsLookupAt || eventTimes.startAt,
eventTimes.tcpConnectionAt
),
// There is no TLS handshake without https, can be null
tlsHandshake: getHrTimeDurationInMs(
eventTimes.tcpConnectionAt,
eventTimes.tlsHandshakeAt
),
firstByte: getHrTimeDurationInMs((
// There is no TLS/TCP Connection with keep-alive connection
eventTimes.tlsHandshakeAt || eventTimes.tcpConnectionAt ||
eventTimes.startAt),
eventTimes.firstByteAt
),
contentTransfer: getHrTimeDurationInMs(
eventTimes.firstByteAt,
eventTimes.endAt
),
total: getHrTimeDurationInMs(eventTimes.startAt, eventTimes.endAt)
};
} | [
"function",
"getTimings",
"(",
"eventTimes",
")",
"{",
"return",
"{",
"// There is no DNS lookup with IP address, can be null",
"dnsLookup",
":",
"getHrTimeDurationInMs",
"(",
"eventTimes",
".",
"startAt",
",",
"eventTimes",
".",
"dnsLookupAt",
")",
",",
"tcpConnection",
":",
"getHrTimeDurationInMs",
"(",
"eventTimes",
".",
"dnsLookupAt",
"||",
"eventTimes",
".",
"startAt",
",",
"eventTimes",
".",
"tcpConnectionAt",
")",
",",
"// There is no TLS handshake without https, can be null",
"tlsHandshake",
":",
"getHrTimeDurationInMs",
"(",
"eventTimes",
".",
"tcpConnectionAt",
",",
"eventTimes",
".",
"tlsHandshakeAt",
")",
",",
"firstByte",
":",
"getHrTimeDurationInMs",
"(",
"(",
"// There is no TLS/TCP Connection with keep-alive connection",
"eventTimes",
".",
"tlsHandshakeAt",
"||",
"eventTimes",
".",
"tcpConnectionAt",
"||",
"eventTimes",
".",
"startAt",
")",
",",
"eventTimes",
".",
"firstByteAt",
")",
",",
"contentTransfer",
":",
"getHrTimeDurationInMs",
"(",
"eventTimes",
".",
"firstByteAt",
",",
"eventTimes",
".",
"endAt",
")",
",",
"total",
":",
"getHrTimeDurationInMs",
"(",
"eventTimes",
".",
"startAt",
",",
"eventTimes",
".",
"endAt",
")",
"}",
";",
"}"
] | Calculates HTTP timings
@function getTimings
@param {Object} eventTimes - Timings
@param {Number} eventTimes.startAt - Request started
@param {Number|undefined} eventTimes.dnsLookupAt - DNS resolved
@param {Number} eventTimes.tcpConnectionAt - TCP connection estabilished
@param {Number|undefined} eventTimes.tlsHandshakeAt - TLS handshake finished
@param {Number} eventTimes.firstByteAt - First byte arrived
@param {Number} eventTimes.endAt - Request ended
@returns {Object} timings - { dnsLookup, tcpConnection, tlsHandshake,
firstByte, contentTransfer, total } | [
"Calculates",
"HTTP",
"timings"
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/timings.js#L38-L66 |
20,981 | restify/clients | lib/index.js | normalizeOptions | function normalizeOptions(options) {
var opts = {};
if (typeof options === 'string') {
opts = {
url: options
};
} else if (_.isPlainObject(options)) {
opts = _.clone(options);
}
return opts;
} | javascript | function normalizeOptions(options) {
var opts = {};
if (typeof options === 'string') {
opts = {
url: options
};
} else if (_.isPlainObject(options)) {
opts = _.clone(options);
}
return opts;
} | [
"function",
"normalizeOptions",
"(",
"options",
")",
"{",
"var",
"opts",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"{",
"opts",
"=",
"{",
"url",
":",
"options",
"}",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isPlainObject",
"(",
"options",
")",
")",
"{",
"opts",
"=",
"_",
".",
"clone",
"(",
"options",
")",
";",
"}",
"return",
"opts",
";",
"}"
] | normalize options. if options is a string, treat it as a url. otherwise
clone it and return a new copy.
@private
@function normalizeOptions
@param {Object | String} options a url string or options object
@returns {Object} | [
"normalize",
"options",
".",
"if",
"options",
"is",
"a",
"string",
"treat",
"it",
"as",
"a",
"url",
".",
"otherwise",
"clone",
"it",
"and",
"return",
"a",
"new",
"copy",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/index.js#L104-L117 |
20,982 | restify/clients | lib/helpers/bunyan.js | clientReq | function clientReq(req) {
if (!req) {
return (req);
}
var host;
try {
host = req.host.split(':')[0];
} catch (e) {
host = false;
}
return ({
method: req ? req.method : false,
url: req ? req.path : false,
address: host,
port: req ? req.port : false,
headers: req ? req.headers : false
});
} | javascript | function clientReq(req) {
if (!req) {
return (req);
}
var host;
try {
host = req.host.split(':')[0];
} catch (e) {
host = false;
}
return ({
method: req ? req.method : false,
url: req ? req.path : false,
address: host,
port: req ? req.port : false,
headers: req ? req.headers : false
});
} | [
"function",
"clientReq",
"(",
"req",
")",
"{",
"if",
"(",
"!",
"req",
")",
"{",
"return",
"(",
"req",
")",
";",
"}",
"var",
"host",
";",
"try",
"{",
"host",
"=",
"req",
".",
"host",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"host",
"=",
"false",
";",
"}",
"return",
"(",
"{",
"method",
":",
"req",
"?",
"req",
".",
"method",
":",
"false",
",",
"url",
":",
"req",
"?",
"req",
".",
"path",
":",
"false",
",",
"address",
":",
"host",
",",
"port",
":",
"req",
"?",
"req",
".",
"port",
":",
"false",
",",
"headers",
":",
"req",
"?",
"req",
".",
"headers",
":",
"false",
"}",
")",
";",
"}"
] | a request serializer. returns a stripped down object for logging.
@private
@function clientReq
@param {Object} req the request object
@returns {Object} | [
"a",
"request",
"serializer",
".",
"returns",
"a",
"stripped",
"down",
"object",
"for",
"logging",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/bunyan.js#L225-L245 |
20,983 | restify/clients | lib/helpers/bunyan.js | clientRes | function clientRes(res) {
if (!res || !res.statusCode) {
return (res);
}
return ({
statusCode: res.statusCode,
headers: res.headers
});
} | javascript | function clientRes(res) {
if (!res || !res.statusCode) {
return (res);
}
return ({
statusCode: res.statusCode,
headers: res.headers
});
} | [
"function",
"clientRes",
"(",
"res",
")",
"{",
"if",
"(",
"!",
"res",
"||",
"!",
"res",
".",
"statusCode",
")",
"{",
"return",
"(",
"res",
")",
";",
"}",
"return",
"(",
"{",
"statusCode",
":",
"res",
".",
"statusCode",
",",
"headers",
":",
"res",
".",
"headers",
"}",
")",
";",
"}"
] | a response serializer. returns a stripped down object for logging.
@private
@function clientRes
@param {Object} res the response object
@returns {Object} | [
"a",
"response",
"serializer",
".",
"returns",
"a",
"stripped",
"down",
"object",
"for",
"logging",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/bunyan.js#L255-L264 |
20,984 | restify/clients | lib/helpers/bunyan.js | createLogger | function createLogger(name) {
return (bunyan.createLogger({
name: name,
serializers: SERIALIZERS,
streams: [
{
level: 'warn',
stream: process.stderr
},
{
level: 'debug',
type: 'raw',
stream: new RequestCaptureStream({
stream: process.stderr
})
}
]
}));
} | javascript | function createLogger(name) {
return (bunyan.createLogger({
name: name,
serializers: SERIALIZERS,
streams: [
{
level: 'warn',
stream: process.stderr
},
{
level: 'debug',
type: 'raw',
stream: new RequestCaptureStream({
stream: process.stderr
})
}
]
}));
} | [
"function",
"createLogger",
"(",
"name",
")",
"{",
"return",
"(",
"bunyan",
".",
"createLogger",
"(",
"{",
"name",
":",
"name",
",",
"serializers",
":",
"SERIALIZERS",
",",
"streams",
":",
"[",
"{",
"level",
":",
"'warn'",
",",
"stream",
":",
"process",
".",
"stderr",
"}",
",",
"{",
"level",
":",
"'debug'",
",",
"type",
":",
"'raw'",
",",
"stream",
":",
"new",
"RequestCaptureStream",
"(",
"{",
"stream",
":",
"process",
".",
"stderr",
"}",
")",
"}",
"]",
"}",
")",
")",
";",
"}"
] | create a bunyan logger
@public
@function createLogger
@param {String} name of the logger
@returns {Object} bunyan logger | [
"create",
"a",
"bunyan",
"logger"
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/bunyan.js#L311-L329 |
20,985 | restify/clients | lib/HttpClient.js | isProxyForURL | function isProxyForURL(noProxy, address) {
// wildcard
if (noProxy === '*') {
return (null);
}
// otherwise, parse the noProxy value to see if it applies to the URL
if (noProxy !== null) {
var noProxyItem, hostname, port, noProxyItemParts,
noProxyHost, noProxyPort, noProxyList;
// canonicalize the hostname
/* JSSTYLED */
hostname = address.hostname.replace(/^\.*/, '.').toLowerCase();
noProxyList = noProxy.split(',');
for (var i = 0, len = noProxyList.length; i < len; i++) {
noProxyItem = noProxyList[i].trim().toLowerCase();
// no_proxy can be granular at the port level
if (noProxyItem.indexOf(':') > -1) {
noProxyItemParts = noProxyItem.split(':', 2);
/* JSSTYLED */
noProxyHost = noProxyItemParts[0].replace(/^\.*/, '.');
noProxyPort = noProxyItemParts[1];
port = address.port ||
(address.protocol === 'https:' ? '443' : '80');
// match - ports are same and host ends with no_proxy entry.
if (port === noProxyPort &&
hostname.indexOf(noProxyHost) ===
hostname.length - noProxyHost.length) {
return (null);
}
} else {
/* JSSTYLED */
noProxyItem = noProxyItem.replace(/^\.*/, '.');
var isMatchedAt = hostname.indexOf(noProxyItem);
if (isMatchedAt > -1 &&
isMatchedAt === hostname.length - noProxyItem.length) {
return (null);
}
}
}
}
return (true);
} | javascript | function isProxyForURL(noProxy, address) {
// wildcard
if (noProxy === '*') {
return (null);
}
// otherwise, parse the noProxy value to see if it applies to the URL
if (noProxy !== null) {
var noProxyItem, hostname, port, noProxyItemParts,
noProxyHost, noProxyPort, noProxyList;
// canonicalize the hostname
/* JSSTYLED */
hostname = address.hostname.replace(/^\.*/, '.').toLowerCase();
noProxyList = noProxy.split(',');
for (var i = 0, len = noProxyList.length; i < len; i++) {
noProxyItem = noProxyList[i].trim().toLowerCase();
// no_proxy can be granular at the port level
if (noProxyItem.indexOf(':') > -1) {
noProxyItemParts = noProxyItem.split(':', 2);
/* JSSTYLED */
noProxyHost = noProxyItemParts[0].replace(/^\.*/, '.');
noProxyPort = noProxyItemParts[1];
port = address.port ||
(address.protocol === 'https:' ? '443' : '80');
// match - ports are same and host ends with no_proxy entry.
if (port === noProxyPort &&
hostname.indexOf(noProxyHost) ===
hostname.length - noProxyHost.length) {
return (null);
}
} else {
/* JSSTYLED */
noProxyItem = noProxyItem.replace(/^\.*/, '.');
var isMatchedAt = hostname.indexOf(noProxyItem);
if (isMatchedAt > -1 &&
isMatchedAt === hostname.length - noProxyItem.length) {
return (null);
}
}
}
}
return (true);
} | [
"function",
"isProxyForURL",
"(",
"noProxy",
",",
"address",
")",
"{",
"// wildcard",
"if",
"(",
"noProxy",
"===",
"'*'",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"// otherwise, parse the noProxy value to see if it applies to the URL",
"if",
"(",
"noProxy",
"!==",
"null",
")",
"{",
"var",
"noProxyItem",
",",
"hostname",
",",
"port",
",",
"noProxyItemParts",
",",
"noProxyHost",
",",
"noProxyPort",
",",
"noProxyList",
";",
"// canonicalize the hostname",
"/* JSSTYLED */",
"hostname",
"=",
"address",
".",
"hostname",
".",
"replace",
"(",
"/",
"^\\.*",
"/",
",",
"'.'",
")",
".",
"toLowerCase",
"(",
")",
";",
"noProxyList",
"=",
"noProxy",
".",
"split",
"(",
"','",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"noProxyList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"noProxyItem",
"=",
"noProxyList",
"[",
"i",
"]",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"// no_proxy can be granular at the port level",
"if",
"(",
"noProxyItem",
".",
"indexOf",
"(",
"':'",
")",
">",
"-",
"1",
")",
"{",
"noProxyItemParts",
"=",
"noProxyItem",
".",
"split",
"(",
"':'",
",",
"2",
")",
";",
"/* JSSTYLED */",
"noProxyHost",
"=",
"noProxyItemParts",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"^\\.*",
"/",
",",
"'.'",
")",
";",
"noProxyPort",
"=",
"noProxyItemParts",
"[",
"1",
"]",
";",
"port",
"=",
"address",
".",
"port",
"||",
"(",
"address",
".",
"protocol",
"===",
"'https:'",
"?",
"'443'",
":",
"'80'",
")",
";",
"// match - ports are same and host ends with no_proxy entry.",
"if",
"(",
"port",
"===",
"noProxyPort",
"&&",
"hostname",
".",
"indexOf",
"(",
"noProxyHost",
")",
"===",
"hostname",
".",
"length",
"-",
"noProxyHost",
".",
"length",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"}",
"else",
"{",
"/* JSSTYLED */",
"noProxyItem",
"=",
"noProxyItem",
".",
"replace",
"(",
"/",
"^\\.*",
"/",
",",
"'.'",
")",
";",
"var",
"isMatchedAt",
"=",
"hostname",
".",
"indexOf",
"(",
"noProxyItem",
")",
";",
"if",
"(",
"isMatchedAt",
">",
"-",
"1",
"&&",
"isMatchedAt",
"===",
"hostname",
".",
"length",
"-",
"noProxyItem",
".",
"length",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"}",
"}",
"}",
"return",
"(",
"true",
")",
";",
"}"
] | Check if url is excluded by the no_proxy environment variable | [
"Check",
"if",
"url",
"is",
"excluded",
"by",
"the",
"no_proxy",
"environment",
"variable"
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/HttpClient.js#L551-L598 |
20,986 | restify/clients | lib/helpers/errors.js | createHttpErr | function createHttpErr(statusCode, opts, req) {
assert.number(statusCode, 'statusCode');
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
return restifyErrors.makeErrFromCode(statusCode, {
info: errInfo
});
} | javascript | function createHttpErr(statusCode, opts, req) {
assert.number(statusCode, 'statusCode');
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
return restifyErrors.makeErrFromCode(statusCode, {
info: errInfo
});
} | [
"function",
"createHttpErr",
"(",
"statusCode",
",",
"opts",
",",
"req",
")",
"{",
"assert",
".",
"number",
"(",
"statusCode",
",",
"'statusCode'",
")",
";",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"object",
"(",
"req",
",",
"'req'",
")",
";",
"var",
"errInfo",
"=",
"createErrInfo",
"(",
"opts",
",",
"req",
")",
";",
"return",
"restifyErrors",
".",
"makeErrFromCode",
"(",
"statusCode",
",",
"{",
"info",
":",
"errInfo",
"}",
")",
";",
"}"
] | build an http error for a request that has a corresponding http status code
on the response.
@private
@function createHttpErr
@param {Object} statusCode response status code
@param {Object} opts options object for a request
@param {Object} req the request object
@returns {verror.VError} | [
"build",
"an",
"http",
"error",
"for",
"a",
"request",
"that",
"has",
"a",
"corresponding",
"http",
"status",
"code",
"on",
"the",
"response",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/errors.js#L84-L94 |
20,987 | restify/clients | lib/helpers/errors.js | createRequestTimeoutErr | function createRequestTimeoutErr(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
var errMsg = [
opts.method,
'request to',
errInfo.fullUrl,
'failed to complete within',
opts.requestTimeout + 'ms'
].join(' ');
return new ERR_CTOR.RequestTimeoutError({
info: _.assign(errInfo, {
requestTimeout: opts.requestTimeout
})
}, '%s', errMsg);
} | javascript | function createRequestTimeoutErr(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
var errMsg = [
opts.method,
'request to',
errInfo.fullUrl,
'failed to complete within',
opts.requestTimeout + 'ms'
].join(' ');
return new ERR_CTOR.RequestTimeoutError({
info: _.assign(errInfo, {
requestTimeout: opts.requestTimeout
})
}, '%s', errMsg);
} | [
"function",
"createRequestTimeoutErr",
"(",
"opts",
",",
"req",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"object",
"(",
"req",
",",
"'req'",
")",
";",
"var",
"errInfo",
"=",
"createErrInfo",
"(",
"opts",
",",
"req",
")",
";",
"var",
"errMsg",
"=",
"[",
"opts",
".",
"method",
",",
"'request to'",
",",
"errInfo",
".",
"fullUrl",
",",
"'failed to complete within'",
",",
"opts",
".",
"requestTimeout",
"+",
"'ms'",
"]",
".",
"join",
"(",
"' '",
")",
";",
"return",
"new",
"ERR_CTOR",
".",
"RequestTimeoutError",
"(",
"{",
"info",
":",
"_",
".",
"assign",
"(",
"errInfo",
",",
"{",
"requestTimeout",
":",
"opts",
".",
"requestTimeout",
"}",
")",
"}",
",",
"'%s'",
",",
"errMsg",
")",
";",
"}"
] | build a request timeout error for a request that failed to complete within
the specified timeout period.
@private
@function createRequestTimeoutErr
@param {Object} opts options object for a request
@param {Object} req the request object
@returns {verror.VError} RequestTimeoutError | [
"build",
"a",
"request",
"timeout",
"error",
"for",
"a",
"request",
"that",
"failed",
"to",
"complete",
"within",
"the",
"specified",
"timeout",
"period",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/errors.js#L106-L124 |
20,988 | restify/clients | lib/helpers/errors.js | createTooManyRedirectsErr | function createTooManyRedirectsErr(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
var errMsg = [
'aborted',
opts.method,
'request to',
errInfo.fullUrl,
'after',
opts.redirects,
'redirects'
].join(' ');
return new ERR_CTOR.TooManyRedirectsError({
info: _.assign(errInfo, {
// add additional context relevant for redirects
numRedirects: opts.redirects,
maxRedirects: opts.maxRedirects
})
}, '%s', errMsg);
} | javascript | function createTooManyRedirectsErr(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
var errInfo = createErrInfo(opts, req);
var errMsg = [
'aborted',
opts.method,
'request to',
errInfo.fullUrl,
'after',
opts.redirects,
'redirects'
].join(' ');
return new ERR_CTOR.TooManyRedirectsError({
info: _.assign(errInfo, {
// add additional context relevant for redirects
numRedirects: opts.redirects,
maxRedirects: opts.maxRedirects
})
}, '%s', errMsg);
} | [
"function",
"createTooManyRedirectsErr",
"(",
"opts",
",",
"req",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"object",
"(",
"req",
",",
"'req'",
")",
";",
"var",
"errInfo",
"=",
"createErrInfo",
"(",
"opts",
",",
"req",
")",
";",
"var",
"errMsg",
"=",
"[",
"'aborted'",
",",
"opts",
".",
"method",
",",
"'request to'",
",",
"errInfo",
".",
"fullUrl",
",",
"'after'",
",",
"opts",
".",
"redirects",
",",
"'redirects'",
"]",
".",
"join",
"(",
"' '",
")",
";",
"return",
"new",
"ERR_CTOR",
".",
"TooManyRedirectsError",
"(",
"{",
"info",
":",
"_",
".",
"assign",
"(",
"errInfo",
",",
"{",
"// add additional context relevant for redirects",
"numRedirects",
":",
"opts",
".",
"redirects",
",",
"maxRedirects",
":",
"opts",
".",
"maxRedirects",
"}",
")",
"}",
",",
"'%s'",
",",
"errMsg",
")",
";",
"}"
] | build a redirect error for a request that encountered too many redirects
when attempting to follow redirects.
@private
@function createRequestTimeoutErr
@param {Object} opts options object for a request
@param {Object} req the request object
@returns {verror.VError} RequestTimeoutError | [
"build",
"a",
"redirect",
"error",
"for",
"a",
"request",
"that",
"encountered",
"too",
"many",
"redirects",
"when",
"attempting",
"to",
"follow",
"redirects",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/errors.js#L136-L158 |
20,989 | restify/clients | lib/helpers/errors.js | createErrInfo | function createErrInfo(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
return {
// port and address can both be unpopulated - fall back on null so
// that they can both be null (instead of req.remoteAddress
// defaulting to undefined)
address: req.remoteAddress || null,
fullUrl: fullRequestUrl(opts),
method: opts.method,
port: opts.port
};
} | javascript | function createErrInfo(opts, req) {
assert.object(opts, 'opts');
assert.object(req, 'req');
return {
// port and address can both be unpopulated - fall back on null so
// that they can both be null (instead of req.remoteAddress
// defaulting to undefined)
address: req.remoteAddress || null,
fullUrl: fullRequestUrl(opts),
method: opts.method,
port: opts.port
};
} | [
"function",
"createErrInfo",
"(",
"opts",
",",
"req",
")",
"{",
"assert",
".",
"object",
"(",
"opts",
",",
"'opts'",
")",
";",
"assert",
".",
"object",
"(",
"req",
",",
"'req'",
")",
";",
"return",
"{",
"// port and address can both be unpopulated - fall back on null so",
"// that they can both be null (instead of req.remoteAddress",
"// defaulting to undefined)",
"address",
":",
"req",
".",
"remoteAddress",
"||",
"null",
",",
"fullUrl",
":",
"fullRequestUrl",
"(",
"opts",
")",
",",
"method",
":",
"opts",
".",
"method",
",",
"port",
":",
"opts",
".",
"port",
"}",
";",
"}"
] | create an info object for use with verror given the opts object used to
issue the original request, along with the request object itself.
@private
@function createErrInfo
@param {Object} opts an options object
@param {Object} req a request object
@returns {Object} | [
"create",
"an",
"info",
"object",
"for",
"use",
"with",
"verror",
"given",
"the",
"opts",
"object",
"used",
"to",
"issue",
"the",
"original",
"request",
"along",
"with",
"the",
"request",
"object",
"itself",
"."
] | ccb78a98bb5977db6a108cbdb52a5336ded07638 | https://github.com/restify/clients/blob/ccb78a98bb5977db6a108cbdb52a5336ded07638/lib/helpers/errors.js#L218-L231 |
20,990 | npm/fstream | lib/writer.js | Writer | function Writer (props, current) {
var self = this
if (typeof props === 'string') {
props = { path: props }
}
// polymorphism.
// call fstream.Writer(dir) to get a DirWriter object, etc.
var type = getType(props)
var ClassType = Writer
switch (type) {
case 'Directory':
ClassType = DirWriter
break
case 'File':
ClassType = FileWriter
break
case 'Link':
case 'SymbolicLink':
ClassType = LinkWriter
break
case null:
default:
// Don't know yet what type to create, so we wrap in a proxy.
ClassType = ProxyWriter
break
}
if (!(self instanceof ClassType)) return new ClassType(props)
// now get down to business.
Abstract.call(self)
if (!props.path) self.error('Must provide a path', null, true)
// props is what we want to set.
// set some convenience properties as well.
self.type = props.type
self.props = props
self.depth = props.depth || 0
self.clobber = props.clobber === false ? props.clobber : true
self.parent = props.parent || null
self.root = props.root || (props.parent && props.parent.root) || self
self._path = self.path = path.resolve(props.path)
if (process.platform === 'win32') {
self.path = self._path = self.path.replace(/\?/g, '_')
if (self._path.length >= 260) {
self._swallowErrors = true
self._path = '\\\\?\\' + self.path.replace(/\//g, '\\')
}
}
self.basename = path.basename(props.path)
self.dirname = path.dirname(props.path)
self.linkpath = props.linkpath || null
props.parent = props.root = null
// console.error("\n\n\n%s setting size to", props.path, props.size)
self.size = props.size
if (typeof props.mode === 'string') {
props.mode = parseInt(props.mode, 8)
}
self.readable = false
self.writable = true
// buffer until ready, or while handling another entry
self._buffer = []
self.ready = false
self.filter = typeof props.filter === 'function' ? props.filter : null
// start the ball rolling.
// this checks what's there already, and then calls
// self._create() to call the impl-specific creation stuff.
self._stat(current)
} | javascript | function Writer (props, current) {
var self = this
if (typeof props === 'string') {
props = { path: props }
}
// polymorphism.
// call fstream.Writer(dir) to get a DirWriter object, etc.
var type = getType(props)
var ClassType = Writer
switch (type) {
case 'Directory':
ClassType = DirWriter
break
case 'File':
ClassType = FileWriter
break
case 'Link':
case 'SymbolicLink':
ClassType = LinkWriter
break
case null:
default:
// Don't know yet what type to create, so we wrap in a proxy.
ClassType = ProxyWriter
break
}
if (!(self instanceof ClassType)) return new ClassType(props)
// now get down to business.
Abstract.call(self)
if (!props.path) self.error('Must provide a path', null, true)
// props is what we want to set.
// set some convenience properties as well.
self.type = props.type
self.props = props
self.depth = props.depth || 0
self.clobber = props.clobber === false ? props.clobber : true
self.parent = props.parent || null
self.root = props.root || (props.parent && props.parent.root) || self
self._path = self.path = path.resolve(props.path)
if (process.platform === 'win32') {
self.path = self._path = self.path.replace(/\?/g, '_')
if (self._path.length >= 260) {
self._swallowErrors = true
self._path = '\\\\?\\' + self.path.replace(/\//g, '\\')
}
}
self.basename = path.basename(props.path)
self.dirname = path.dirname(props.path)
self.linkpath = props.linkpath || null
props.parent = props.root = null
// console.error("\n\n\n%s setting size to", props.path, props.size)
self.size = props.size
if (typeof props.mode === 'string') {
props.mode = parseInt(props.mode, 8)
}
self.readable = false
self.writable = true
// buffer until ready, or while handling another entry
self._buffer = []
self.ready = false
self.filter = typeof props.filter === 'function' ? props.filter : null
// start the ball rolling.
// this checks what's there already, and then calls
// self._create() to call the impl-specific creation stuff.
self._stat(current)
} | [
"function",
"Writer",
"(",
"props",
",",
"current",
")",
"{",
"var",
"self",
"=",
"this",
"if",
"(",
"typeof",
"props",
"===",
"'string'",
")",
"{",
"props",
"=",
"{",
"path",
":",
"props",
"}",
"}",
"// polymorphism.",
"// call fstream.Writer(dir) to get a DirWriter object, etc.",
"var",
"type",
"=",
"getType",
"(",
"props",
")",
"var",
"ClassType",
"=",
"Writer",
"switch",
"(",
"type",
")",
"{",
"case",
"'Directory'",
":",
"ClassType",
"=",
"DirWriter",
"break",
"case",
"'File'",
":",
"ClassType",
"=",
"FileWriter",
"break",
"case",
"'Link'",
":",
"case",
"'SymbolicLink'",
":",
"ClassType",
"=",
"LinkWriter",
"break",
"case",
"null",
":",
"default",
":",
"// Don't know yet what type to create, so we wrap in a proxy.",
"ClassType",
"=",
"ProxyWriter",
"break",
"}",
"if",
"(",
"!",
"(",
"self",
"instanceof",
"ClassType",
")",
")",
"return",
"new",
"ClassType",
"(",
"props",
")",
"// now get down to business.",
"Abstract",
".",
"call",
"(",
"self",
")",
"if",
"(",
"!",
"props",
".",
"path",
")",
"self",
".",
"error",
"(",
"'Must provide a path'",
",",
"null",
",",
"true",
")",
"// props is what we want to set.",
"// set some convenience properties as well.",
"self",
".",
"type",
"=",
"props",
".",
"type",
"self",
".",
"props",
"=",
"props",
"self",
".",
"depth",
"=",
"props",
".",
"depth",
"||",
"0",
"self",
".",
"clobber",
"=",
"props",
".",
"clobber",
"===",
"false",
"?",
"props",
".",
"clobber",
":",
"true",
"self",
".",
"parent",
"=",
"props",
".",
"parent",
"||",
"null",
"self",
".",
"root",
"=",
"props",
".",
"root",
"||",
"(",
"props",
".",
"parent",
"&&",
"props",
".",
"parent",
".",
"root",
")",
"||",
"self",
"self",
".",
"_path",
"=",
"self",
".",
"path",
"=",
"path",
".",
"resolve",
"(",
"props",
".",
"path",
")",
"if",
"(",
"process",
".",
"platform",
"===",
"'win32'",
")",
"{",
"self",
".",
"path",
"=",
"self",
".",
"_path",
"=",
"self",
".",
"path",
".",
"replace",
"(",
"/",
"\\?",
"/",
"g",
",",
"'_'",
")",
"if",
"(",
"self",
".",
"_path",
".",
"length",
">=",
"260",
")",
"{",
"self",
".",
"_swallowErrors",
"=",
"true",
"self",
".",
"_path",
"=",
"'\\\\\\\\?\\\\'",
"+",
"self",
".",
"path",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'\\\\'",
")",
"}",
"}",
"self",
".",
"basename",
"=",
"path",
".",
"basename",
"(",
"props",
".",
"path",
")",
"self",
".",
"dirname",
"=",
"path",
".",
"dirname",
"(",
"props",
".",
"path",
")",
"self",
".",
"linkpath",
"=",
"props",
".",
"linkpath",
"||",
"null",
"props",
".",
"parent",
"=",
"props",
".",
"root",
"=",
"null",
"// console.error(\"\\n\\n\\n%s setting size to\", props.path, props.size)",
"self",
".",
"size",
"=",
"props",
".",
"size",
"if",
"(",
"typeof",
"props",
".",
"mode",
"===",
"'string'",
")",
"{",
"props",
".",
"mode",
"=",
"parseInt",
"(",
"props",
".",
"mode",
",",
"8",
")",
"}",
"self",
".",
"readable",
"=",
"false",
"self",
".",
"writable",
"=",
"true",
"// buffer until ready, or while handling another entry",
"self",
".",
"_buffer",
"=",
"[",
"]",
"self",
".",
"ready",
"=",
"false",
"self",
".",
"filter",
"=",
"typeof",
"props",
".",
"filter",
"===",
"'function'",
"?",
"props",
".",
"filter",
":",
"null",
"// start the ball rolling.",
"// this checks what's there already, and then calls",
"// self._create() to call the impl-specific creation stuff.",
"self",
".",
"_stat",
"(",
"current",
")",
"}"
] | props is the desired state. current is optionally the current stat, provided here so that subclasses can avoid statting the target more than necessary. | [
"props",
"is",
"the",
"desired",
"state",
".",
"current",
"is",
"optionally",
"the",
"current",
"stat",
"provided",
"here",
"so",
"that",
"subclasses",
"can",
"avoid",
"statting",
"the",
"target",
"more",
"than",
"necessary",
"."
] | 1e4527ffe8688d4f5325283d7cf2cf2d61f14c6b | https://github.com/npm/fstream/blob/1e4527ffe8688d4f5325283d7cf2cf2d61f14c6b/lib/writer.js#L26-L107 |
20,991 | Jam3/touches | index.js | getTargetTouch | function getTargetTouch (touches, target) {
return Array.prototype.slice.call(touches).filter(function (t) {
return t.target === target
})[0] || touches[0]
} | javascript | function getTargetTouch (touches, target) {
return Array.prototype.slice.call(touches).filter(function (t) {
return t.target === target
})[0] || touches[0]
} | [
"function",
"getTargetTouch",
"(",
"touches",
",",
"target",
")",
"{",
"return",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"touches",
")",
".",
"filter",
"(",
"function",
"(",
"t",
")",
"{",
"return",
"t",
".",
"target",
"===",
"target",
"}",
")",
"[",
"0",
"]",
"||",
"touches",
"[",
"0",
"]",
"}"
] | since we are adding events to a parent we can't rely on targetTouches | [
"since",
"we",
"are",
"adding",
"events",
"to",
"a",
"parent",
"we",
"can",
"t",
"rely",
"on",
"targetTouches"
] | c0efd9c43c26c31d54bf8cdb9ee7ce9b22c95eae | https://github.com/Jam3/touches/blob/c0efd9c43c26c31d54bf8cdb9ee7ce9b22c95eae/index.js#L107-L111 |
20,992 | patik/within-viewport | demo/inc/demo.js | function () {
// Scroll or window resize
$(window).on('resize scrollstop', _updateBoxes);
// User entry
$('input[type="number"]').on('keyup change click', events.onBoundaryChange); // 'click' is for spinners on input[number] control
// Boundary toggle
$showBoundsCheck.on('change', events.onBoundaryToggle);
// Nudge controls
// Only certain combinations of browsers/OSes allow capturing arrow key strokes, unfortunately
// Windows: Firefox, Trident, Safari, Opera; Mac: Chrome, Safari, Opera; Not Firefox
if ((navigator.oscpu && /Windows/.test(navigator.oscpu) && /Firefox|Trident|Safari|Presto/.test(navigator.userAgent)) || (/Macintosh/.test(navigator.userAgent) && /Chrome|Safari|Presto/.test(navigator.userAgent))) {
$('#thresholds p').show();
$('body').on('keydown', events.onNudge);
}
// Controls toggler
$('#toggler').on('click', events.onControlsToggle);
} | javascript | function () {
// Scroll or window resize
$(window).on('resize scrollstop', _updateBoxes);
// User entry
$('input[type="number"]').on('keyup change click', events.onBoundaryChange); // 'click' is for spinners on input[number] control
// Boundary toggle
$showBoundsCheck.on('change', events.onBoundaryToggle);
// Nudge controls
// Only certain combinations of browsers/OSes allow capturing arrow key strokes, unfortunately
// Windows: Firefox, Trident, Safari, Opera; Mac: Chrome, Safari, Opera; Not Firefox
if ((navigator.oscpu && /Windows/.test(navigator.oscpu) && /Firefox|Trident|Safari|Presto/.test(navigator.userAgent)) || (/Macintosh/.test(navigator.userAgent) && /Chrome|Safari|Presto/.test(navigator.userAgent))) {
$('#thresholds p').show();
$('body').on('keydown', events.onNudge);
}
// Controls toggler
$('#toggler').on('click', events.onControlsToggle);
} | [
"function",
"(",
")",
"{",
"// Scroll or window resize",
"$",
"(",
"window",
")",
".",
"on",
"(",
"'resize scrollstop'",
",",
"_updateBoxes",
")",
";",
"// User entry",
"$",
"(",
"'input[type=\"number\"]'",
")",
".",
"on",
"(",
"'keyup change click'",
",",
"events",
".",
"onBoundaryChange",
")",
";",
"// 'click' is for spinners on input[number] control",
"// Boundary toggle",
"$showBoundsCheck",
".",
"on",
"(",
"'change'",
",",
"events",
".",
"onBoundaryToggle",
")",
";",
"// Nudge controls",
"// Only certain combinations of browsers/OSes allow capturing arrow key strokes, unfortunately",
"// Windows: Firefox, Trident, Safari, Opera; Mac: Chrome, Safari, Opera; Not Firefox",
"if",
"(",
"(",
"navigator",
".",
"oscpu",
"&&",
"/",
"Windows",
"/",
".",
"test",
"(",
"navigator",
".",
"oscpu",
")",
"&&",
"/",
"Firefox|Trident|Safari|Presto",
"/",
".",
"test",
"(",
"navigator",
".",
"userAgent",
")",
")",
"||",
"(",
"/",
"Macintosh",
"/",
".",
"test",
"(",
"navigator",
".",
"userAgent",
")",
"&&",
"/",
"Chrome|Safari|Presto",
"/",
".",
"test",
"(",
"navigator",
".",
"userAgent",
")",
")",
")",
"{",
"$",
"(",
"'#thresholds p'",
")",
".",
"show",
"(",
")",
";",
"$",
"(",
"'body'",
")",
".",
"on",
"(",
"'keydown'",
",",
"events",
".",
"onNudge",
")",
";",
"}",
"// Controls toggler",
"$",
"(",
"'#toggler'",
")",
".",
"on",
"(",
"'click'",
",",
"events",
".",
"onControlsToggle",
")",
";",
"}"
] | Setup event listeners | [
"Setup",
"event",
"listeners"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L57-L76 | |
20,993 | patik/within-viewport | demo/inc/demo.js | function (evt) {
var target = evt.target;
var val = parseInt(target.value, 10);
var id = target.id;
// Positive value was entered (negative values are allowed, but the boundaries would be off screen)
if (val > 0) {
if ($showBoundsCheck.is(':checked')) {
$('.boundary-' + id).show();
_drawBound(id, val);
}
else {
$('.boundary-' + id).hide();
}
}
// Hide boundaries
else {
$('.boundary-' + id).hide();
}
// Update the page
withinviewport.defaults[id] = val;
_updateBoxes();
_toggleBoundaryToggle();
} | javascript | function (evt) {
var target = evt.target;
var val = parseInt(target.value, 10);
var id = target.id;
// Positive value was entered (negative values are allowed, but the boundaries would be off screen)
if (val > 0) {
if ($showBoundsCheck.is(':checked')) {
$('.boundary-' + id).show();
_drawBound(id, val);
}
else {
$('.boundary-' + id).hide();
}
}
// Hide boundaries
else {
$('.boundary-' + id).hide();
}
// Update the page
withinviewport.defaults[id] = val;
_updateBoxes();
_toggleBoundaryToggle();
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"target",
"=",
"evt",
".",
"target",
";",
"var",
"val",
"=",
"parseInt",
"(",
"target",
".",
"value",
",",
"10",
")",
";",
"var",
"id",
"=",
"target",
".",
"id",
";",
"// Positive value was entered (negative values are allowed, but the boundaries would be off screen)",
"if",
"(",
"val",
">",
"0",
")",
"{",
"if",
"(",
"$showBoundsCheck",
".",
"is",
"(",
"':checked'",
")",
")",
"{",
"$",
"(",
"'.boundary-'",
"+",
"id",
")",
".",
"show",
"(",
")",
";",
"_drawBound",
"(",
"id",
",",
"val",
")",
";",
"}",
"else",
"{",
"$",
"(",
"'.boundary-'",
"+",
"id",
")",
".",
"hide",
"(",
")",
";",
"}",
"}",
"// Hide boundaries",
"else",
"{",
"$",
"(",
"'.boundary-'",
"+",
"id",
")",
".",
"hide",
"(",
")",
";",
"}",
"// Update the page",
"withinviewport",
".",
"defaults",
"[",
"id",
"]",
"=",
"val",
";",
"_updateBoxes",
"(",
")",
";",
"_toggleBoundaryToggle",
"(",
")",
";",
"}"
] | When a boundary value changes | [
"When",
"a",
"boundary",
"value",
"changes"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L79-L103 | |
20,994 | patik/within-viewport | demo/inc/demo.js | function (evt) {
// Ignore input fields
if ($(evt.target).is('input')) {
return true;
}
if (evt.shiftKey && 37 <= evt.keyCode && evt.keyCode <= 40) {
var key = 'key' + evt.keyCode;
var scrollVals = {
key38: [0, -1],
key37: [-1, 0],
key39: [1, 0],
key40: [0, 1]
};
window.scrollBy(scrollVals[key][0], scrollVals[key][1]);
evt.preventDefault();
}
} | javascript | function (evt) {
// Ignore input fields
if ($(evt.target).is('input')) {
return true;
}
if (evt.shiftKey && 37 <= evt.keyCode && evt.keyCode <= 40) {
var key = 'key' + evt.keyCode;
var scrollVals = {
key38: [0, -1],
key37: [-1, 0],
key39: [1, 0],
key40: [0, 1]
};
window.scrollBy(scrollVals[key][0], scrollVals[key][1]);
evt.preventDefault();
}
} | [
"function",
"(",
"evt",
")",
"{",
"// Ignore input fields",
"if",
"(",
"$",
"(",
"evt",
".",
"target",
")",
".",
"is",
"(",
"'input'",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"evt",
".",
"shiftKey",
"&&",
"37",
"<=",
"evt",
".",
"keyCode",
"&&",
"evt",
".",
"keyCode",
"<=",
"40",
")",
"{",
"var",
"key",
"=",
"'key'",
"+",
"evt",
".",
"keyCode",
";",
"var",
"scrollVals",
"=",
"{",
"key38",
":",
"[",
"0",
",",
"-",
"1",
"]",
",",
"key37",
":",
"[",
"-",
"1",
",",
"0",
"]",
",",
"key39",
":",
"[",
"1",
",",
"0",
"]",
",",
"key40",
":",
"[",
"0",
",",
"1",
"]",
"}",
";",
"window",
".",
"scrollBy",
"(",
"scrollVals",
"[",
"key",
"]",
"[",
"0",
"]",
",",
"scrollVals",
"[",
"key",
"]",
"[",
"1",
"]",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"}",
"}"
] | When shift + arrow key is pressed, nudge the page by 1px | [
"When",
"shift",
"+",
"arrow",
"key",
"is",
"pressed",
"nudge",
"the",
"page",
"by",
"1px"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L119-L137 | |
20,995 | patik/within-viewport | demo/inc/demo.js | _drawBound | function _drawBound (side, dist) {
dist += 'px';
switch (side) {
case 'top':
$('.boundary-top').css({
top: dist,
height: dist,
marginTop: '-' + dist
});
break;
case 'right':
$('.boundary-right').css({
right: dist,
width: dist,
marginRight: '-' + dist
});
break;
case 'bottom':
$('.boundary-bottom').css({
bottom: dist,
height: dist,
marginBottom: '-' + dist
});
break;
case 'left':
$('.boundary-left').css({
left: dist,
width: dist,
marginLeft: '-' + dist
});
break;
default:
break;
}
} | javascript | function _drawBound (side, dist) {
dist += 'px';
switch (side) {
case 'top':
$('.boundary-top').css({
top: dist,
height: dist,
marginTop: '-' + dist
});
break;
case 'right':
$('.boundary-right').css({
right: dist,
width: dist,
marginRight: '-' + dist
});
break;
case 'bottom':
$('.boundary-bottom').css({
bottom: dist,
height: dist,
marginBottom: '-' + dist
});
break;
case 'left':
$('.boundary-left').css({
left: dist,
width: dist,
marginLeft: '-' + dist
});
break;
default:
break;
}
} | [
"function",
"_drawBound",
"(",
"side",
",",
"dist",
")",
"{",
"dist",
"+=",
"'px'",
";",
"switch",
"(",
"side",
")",
"{",
"case",
"'top'",
":",
"$",
"(",
"'.boundary-top'",
")",
".",
"css",
"(",
"{",
"top",
":",
"dist",
",",
"height",
":",
"dist",
",",
"marginTop",
":",
"'-'",
"+",
"dist",
"}",
")",
";",
"break",
";",
"case",
"'right'",
":",
"$",
"(",
"'.boundary-right'",
")",
".",
"css",
"(",
"{",
"right",
":",
"dist",
",",
"width",
":",
"dist",
",",
"marginRight",
":",
"'-'",
"+",
"dist",
"}",
")",
";",
"break",
";",
"case",
"'bottom'",
":",
"$",
"(",
"'.boundary-bottom'",
")",
".",
"css",
"(",
"{",
"bottom",
":",
"dist",
",",
"height",
":",
"dist",
",",
"marginBottom",
":",
"'-'",
"+",
"dist",
"}",
")",
";",
"break",
";",
"case",
"'left'",
":",
"$",
"(",
"'.boundary-left'",
")",
".",
"css",
"(",
"{",
"left",
":",
"dist",
",",
"width",
":",
"dist",
",",
"marginLeft",
":",
"'-'",
"+",
"dist",
"}",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] | Overlay a boundary line on the viewport when one is set by the user | [
"Overlay",
"a",
"boundary",
"line",
"on",
"the",
"viewport",
"when",
"one",
"is",
"set",
"by",
"the",
"user"
] | a0dde75426e8f0e0b31efb296308ea2a4f458d1e | https://github.com/patik/within-viewport/blob/a0dde75426e8f0e0b31efb296308ea2a4f458d1e/demo/inc/demo.js#L177-L215 |
20,996 | nodejitsu/jitsu | lib/jitsu/commands/apps.js | viewCloud | function viewCloud(app) {
if (!app.config || !app.config.cloud) {
jitsu.log.error('Error: The app ' + app.name.magenta + ' don\'t have any cloud config.');
jitsu.log.error('You need deploy your app before get any cloud config.');
return callback(new Error());
}
jitsu.log.info('Viewing cloud info for ' + name.magenta);
jitsu.inspect.putObject(app.config.cloud[0]);
callback(null, app);
} | javascript | function viewCloud(app) {
if (!app.config || !app.config.cloud) {
jitsu.log.error('Error: The app ' + app.name.magenta + ' don\'t have any cloud config.');
jitsu.log.error('You need deploy your app before get any cloud config.');
return callback(new Error());
}
jitsu.log.info('Viewing cloud info for ' + name.magenta);
jitsu.inspect.putObject(app.config.cloud[0]);
callback(null, app);
} | [
"function",
"viewCloud",
"(",
"app",
")",
"{",
"if",
"(",
"!",
"app",
".",
"config",
"||",
"!",
"app",
".",
"config",
".",
"cloud",
")",
"{",
"jitsu",
".",
"log",
".",
"error",
"(",
"'Error: The app '",
"+",
"app",
".",
"name",
".",
"magenta",
"+",
"' don\\'t have any cloud config.'",
")",
";",
"jitsu",
".",
"log",
".",
"error",
"(",
"'You need deploy your app before get any cloud config.'",
")",
";",
"return",
"callback",
"(",
"new",
"Error",
"(",
")",
")",
";",
"}",
"jitsu",
".",
"log",
".",
"info",
"(",
"'Viewing cloud info for '",
"+",
"name",
".",
"magenta",
")",
";",
"jitsu",
".",
"inspect",
".",
"putObject",
"(",
"app",
".",
"config",
".",
"cloud",
"[",
"0",
"]",
")",
";",
"callback",
"(",
"null",
",",
"app",
")",
";",
"}"
] | Print the cloud information for the app and respond. | [
"Print",
"the",
"cloud",
"information",
"for",
"the",
"app",
"and",
"respond",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L937-L946 |
20,997 | nodejitsu/jitsu | lib/jitsu/commands/apps.js | setCloud | function setCloud(app) {
drones = drones || app.maxDrones;
ram = ram || (app.config.cloud ? app.config.cloud[0].ram : 256);
var cloud = {
datacenter: datacenter,
provider: provider,
drones: drones,
ram: ram
};
if (app.state === 'started') {
jitsu.log.info('App currently deployed to the cloud with:')
jitsu.inspect.putObject(app.config.cloud[0]);
}
jitsu.log.info('Deploying application to the cloud with:')
jitsu.inspect.putObject(cloud);
async.series({
//
// 1. Fetch the endpoints so that we can properly
// tell the user what datacenter they are in later.
//
endpoints: function getEndpoints(next) {
jitsu.apps.endpoints(next);
},
//
// 2. Start the app with the specified cloud information.
//
start: function start(next) {
jitsu.apps.datacenter(name, cloud, next);
}
}, function (err, result) {
if (err) {
jitsu.log.error('Error starting ' + name.magenta);
return callback(err);
}
var endpoints = result.endpoints,
tld = result.endpoints[provider][datacenter];
jitsu.log.info('App ' + name.magenta + ' is now started');
jitsu.log.info(('http://' + app.subdomain + tld.replace('api', '')).magenta + ' on Port ' + '80'.magenta);
callback(null, app);
});
} | javascript | function setCloud(app) {
drones = drones || app.maxDrones;
ram = ram || (app.config.cloud ? app.config.cloud[0].ram : 256);
var cloud = {
datacenter: datacenter,
provider: provider,
drones: drones,
ram: ram
};
if (app.state === 'started') {
jitsu.log.info('App currently deployed to the cloud with:')
jitsu.inspect.putObject(app.config.cloud[0]);
}
jitsu.log.info('Deploying application to the cloud with:')
jitsu.inspect.putObject(cloud);
async.series({
//
// 1. Fetch the endpoints so that we can properly
// tell the user what datacenter they are in later.
//
endpoints: function getEndpoints(next) {
jitsu.apps.endpoints(next);
},
//
// 2. Start the app with the specified cloud information.
//
start: function start(next) {
jitsu.apps.datacenter(name, cloud, next);
}
}, function (err, result) {
if (err) {
jitsu.log.error('Error starting ' + name.magenta);
return callback(err);
}
var endpoints = result.endpoints,
tld = result.endpoints[provider][datacenter];
jitsu.log.info('App ' + name.magenta + ' is now started');
jitsu.log.info(('http://' + app.subdomain + tld.replace('api', '')).magenta + ' on Port ' + '80'.magenta);
callback(null, app);
});
} | [
"function",
"setCloud",
"(",
"app",
")",
"{",
"drones",
"=",
"drones",
"||",
"app",
".",
"maxDrones",
";",
"ram",
"=",
"ram",
"||",
"(",
"app",
".",
"config",
".",
"cloud",
"?",
"app",
".",
"config",
".",
"cloud",
"[",
"0",
"]",
".",
"ram",
":",
"256",
")",
";",
"var",
"cloud",
"=",
"{",
"datacenter",
":",
"datacenter",
",",
"provider",
":",
"provider",
",",
"drones",
":",
"drones",
",",
"ram",
":",
"ram",
"}",
";",
"if",
"(",
"app",
".",
"state",
"===",
"'started'",
")",
"{",
"jitsu",
".",
"log",
".",
"info",
"(",
"'App currently deployed to the cloud with:'",
")",
"jitsu",
".",
"inspect",
".",
"putObject",
"(",
"app",
".",
"config",
".",
"cloud",
"[",
"0",
"]",
")",
";",
"}",
"jitsu",
".",
"log",
".",
"info",
"(",
"'Deploying application to the cloud with:'",
")",
"jitsu",
".",
"inspect",
".",
"putObject",
"(",
"cloud",
")",
";",
"async",
".",
"series",
"(",
"{",
"//",
"// 1. Fetch the endpoints so that we can properly",
"// tell the user what datacenter they are in later.",
"//",
"endpoints",
":",
"function",
"getEndpoints",
"(",
"next",
")",
"{",
"jitsu",
".",
"apps",
".",
"endpoints",
"(",
"next",
")",
";",
"}",
",",
"//",
"// 2. Start the app with the specified cloud information.",
"//",
"start",
":",
"function",
"start",
"(",
"next",
")",
"{",
"jitsu",
".",
"apps",
".",
"datacenter",
"(",
"name",
",",
"cloud",
",",
"next",
")",
";",
"}",
"}",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"jitsu",
".",
"log",
".",
"error",
"(",
"'Error starting '",
"+",
"name",
".",
"magenta",
")",
";",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"var",
"endpoints",
"=",
"result",
".",
"endpoints",
",",
"tld",
"=",
"result",
".",
"endpoints",
"[",
"provider",
"]",
"[",
"datacenter",
"]",
";",
"jitsu",
".",
"log",
".",
"info",
"(",
"'App '",
"+",
"name",
".",
"magenta",
"+",
"' is now started'",
")",
";",
"jitsu",
".",
"log",
".",
"info",
"(",
"(",
"'http://'",
"+",
"app",
".",
"subdomain",
"+",
"tld",
".",
"replace",
"(",
"'api'",
",",
"''",
")",
")",
".",
"magenta",
"+",
"' on Port '",
"+",
"'80'",
".",
"magenta",
")",
";",
"callback",
"(",
"null",
",",
"app",
")",
";",
"}",
")",
";",
"}"
] | 1. Print what cloud app is deployed in now. 2. Print new cloud app will be deployed to. 3. Start the app in the specified cloud. | [
"1",
".",
"Print",
"what",
"cloud",
"app",
"is",
"deployed",
"in",
"now",
".",
"2",
".",
"Print",
"new",
"cloud",
"app",
"will",
"be",
"deployed",
"to",
".",
"3",
".",
"Start",
"the",
"app",
"in",
"the",
"specified",
"cloud",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L953-L999 |
20,998 | nodejitsu/jitsu | lib/jitsu/commands/apps.js | viewApp | function viewApp() {
jitsu.log.info('Fetching app ' + name.magenta);
jitsu.apps.view(name, function (err, app) {
if (err) {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
jitsu.log.help('Try running ' + 'jitsu deploy'.magenta);
return callback({});
}
return provider && datacenter
? setCloud(app)
: viewCloud(app);
});
} | javascript | function viewApp() {
jitsu.log.info('Fetching app ' + name.magenta);
jitsu.apps.view(name, function (err, app) {
if (err) {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
jitsu.log.help('Try running ' + 'jitsu deploy'.magenta);
return callback({});
}
return provider && datacenter
? setCloud(app)
: viewCloud(app);
});
} | [
"function",
"viewApp",
"(",
")",
"{",
"jitsu",
".",
"log",
".",
"info",
"(",
"'Fetching app '",
"+",
"name",
".",
"magenta",
")",
";",
"jitsu",
".",
"apps",
".",
"view",
"(",
"name",
",",
"function",
"(",
"err",
",",
"app",
")",
"{",
"if",
"(",
"err",
")",
"{",
"jitsu",
".",
"log",
".",
"error",
"(",
"'App '",
"+",
"name",
".",
"magenta",
"+",
"' doesn\\'t exist on Nodejitsu yet!'",
")",
";",
"jitsu",
".",
"log",
".",
"help",
"(",
"'Try running '",
"+",
"'jitsu deploy'",
".",
"magenta",
")",
";",
"return",
"callback",
"(",
"{",
"}",
")",
";",
"}",
"return",
"provider",
"&&",
"datacenter",
"?",
"setCloud",
"(",
"app",
")",
":",
"viewCloud",
"(",
"app",
")",
";",
"}",
")",
";",
"}"
] | Retreive the app and call `setCloud` or `viewCloud` depending on what arguments have been passed. | [
"Retreive",
"the",
"app",
"and",
"call",
"setCloud",
"or",
"viewCloud",
"depending",
"on",
"what",
"arguments",
"have",
"been",
"passed",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L1005-L1018 |
20,999 | nodejitsu/jitsu | lib/jitsu/commands/apps.js | readApp | function readApp(next) {
jitsu.package.read(process.cwd(), function (err, pkg) {
if (err) {
callback(err);
}
name = pkg.name;
next();
});
} | javascript | function readApp(next) {
jitsu.package.read(process.cwd(), function (err, pkg) {
if (err) {
callback(err);
}
name = pkg.name;
next();
});
} | [
"function",
"readApp",
"(",
"next",
")",
"{",
"jitsu",
".",
"package",
".",
"read",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"function",
"(",
"err",
",",
"pkg",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"name",
"=",
"pkg",
".",
"name",
";",
"next",
"(",
")",
";",
"}",
")",
";",
"}"
] | Read the app from the current directory. | [
"Read",
"the",
"app",
"from",
"the",
"current",
"directory",
"."
] | b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917 | https://github.com/nodejitsu/jitsu/blob/b4a40605cb5b888ff13fc0b0f1cfa252ad0dd917/lib/jitsu/commands/apps.js#L1023-L1032 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.