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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,100 | jacomyal/sigma.js | src/captors/sigma.captors.touch.js | _handleLeave | function _handleLeave(e) {
if (_settings('touchEnabled')) {
_downTouches = e.touches;
var inertiaRatio = _settings('touchInertiaRatio');
if (_movingTimeoutId) {
_isMoving = false;
clearTimeout(_movingTimeoutId);
}
switch (_touchMode) {
case 2:
if (e.touches.length === 1) {
_handleStart(e);
e.preventDefault();
break;
}
/* falls through */
case 1:
_camera.isMoving = false;
_self.dispatchEvent('stopDrag');
if (_isMoving) {
_doubleTap = false;
sigma.misc.animation.camera(
_camera,
{
x: _camera.x +
inertiaRatio * (_camera.x - _lastCameraX),
y: _camera.y +
inertiaRatio * (_camera.y - _lastCameraY)
},
{
easing: 'quadraticOut',
duration: _settings('touchInertiaDuration')
}
);
}
_isMoving = false;
_touchMode = 0;
break;
}
}
} | javascript | function _handleLeave(e) {
if (_settings('touchEnabled')) {
_downTouches = e.touches;
var inertiaRatio = _settings('touchInertiaRatio');
if (_movingTimeoutId) {
_isMoving = false;
clearTimeout(_movingTimeoutId);
}
switch (_touchMode) {
case 2:
if (e.touches.length === 1) {
_handleStart(e);
e.preventDefault();
break;
}
/* falls through */
case 1:
_camera.isMoving = false;
_self.dispatchEvent('stopDrag');
if (_isMoving) {
_doubleTap = false;
sigma.misc.animation.camera(
_camera,
{
x: _camera.x +
inertiaRatio * (_camera.x - _lastCameraX),
y: _camera.y +
inertiaRatio * (_camera.y - _lastCameraY)
},
{
easing: 'quadraticOut',
duration: _settings('touchInertiaDuration')
}
);
}
_isMoving = false;
_touchMode = 0;
break;
}
}
} | [
"function",
"_handleLeave",
"(",
"e",
")",
"{",
"if",
"(",
"_settings",
"(",
"'touchEnabled'",
")",
")",
"{",
"_downTouches",
"=",
"e",
".",
"touches",
";",
"var",
"inertiaRatio",
"=",
"_settings",
"(",
"'touchInertiaRatio'",
")",
";",
"if",
"(",
"_movingTimeoutId",
")",
"{",
"_isMoving",
"=",
"false",
";",
"clearTimeout",
"(",
"_movingTimeoutId",
")",
";",
"}",
"switch",
"(",
"_touchMode",
")",
"{",
"case",
"2",
":",
"if",
"(",
"e",
".",
"touches",
".",
"length",
"===",
"1",
")",
"{",
"_handleStart",
"(",
"e",
")",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"break",
";",
"}",
"/* falls through */",
"case",
"1",
":",
"_camera",
".",
"isMoving",
"=",
"false",
";",
"_self",
".",
"dispatchEvent",
"(",
"'stopDrag'",
")",
";",
"if",
"(",
"_isMoving",
")",
"{",
"_doubleTap",
"=",
"false",
";",
"sigma",
".",
"misc",
".",
"animation",
".",
"camera",
"(",
"_camera",
",",
"{",
"x",
":",
"_camera",
".",
"x",
"+",
"inertiaRatio",
"*",
"(",
"_camera",
".",
"x",
"-",
"_lastCameraX",
")",
",",
"y",
":",
"_camera",
".",
"y",
"+",
"inertiaRatio",
"*",
"(",
"_camera",
".",
"y",
"-",
"_lastCameraY",
")",
"}",
",",
"{",
"easing",
":",
"'quadraticOut'",
",",
"duration",
":",
"_settings",
"(",
"'touchInertiaDuration'",
")",
"}",
")",
";",
"}",
"_isMoving",
"=",
"false",
";",
"_touchMode",
"=",
"0",
";",
"break",
";",
"}",
"}",
"}"
] | The handler listening to the 'touchend', 'touchcancel' and 'touchleave'
event. It will update the touch mode if there are still at least one
finger, and stop dragging else.
@param {event} e A touch event. | [
"The",
"handler",
"listening",
"to",
"the",
"touchend",
"touchcancel",
"and",
"touchleave",
"event",
".",
"It",
"will",
"update",
"the",
"touch",
"mode",
"if",
"there",
"are",
"still",
"at",
"least",
"one",
"finger",
"and",
"stop",
"dragging",
"else",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/captors/sigma.captors.touch.js#L172-L217 |
6,101 | jacomyal/sigma.js | src/captors/sigma.captors.touch.js | _doubleTapHandler | function _doubleTapHandler(e) {
var pos,
ratio,
animation;
if (e.touches && e.touches.length === 1 && _settings('touchEnabled')) {
_doubleTap = true;
ratio = 1 / _settings('doubleClickZoomingRatio');
pos = position(e.touches[0]);
_self.dispatchEvent('doubleclick',
sigma.utils.mouseCoords(e, pos.x, pos.y));
if (_settings('doubleClickEnabled')) {
pos = _camera.cameraPosition(
pos.x - sigma.utils.getCenter(e).x,
pos.y - sigma.utils.getCenter(e).y,
true
);
animation = {
duration: _settings('doubleClickZoomDuration'),
onComplete: function() {
_doubleTap = false;
}
};
sigma.utils.zoomTo(_camera, pos.x, pos.y, ratio, animation);
}
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
e.stopPropagation();
return false;
}
} | javascript | function _doubleTapHandler(e) {
var pos,
ratio,
animation;
if (e.touches && e.touches.length === 1 && _settings('touchEnabled')) {
_doubleTap = true;
ratio = 1 / _settings('doubleClickZoomingRatio');
pos = position(e.touches[0]);
_self.dispatchEvent('doubleclick',
sigma.utils.mouseCoords(e, pos.x, pos.y));
if (_settings('doubleClickEnabled')) {
pos = _camera.cameraPosition(
pos.x - sigma.utils.getCenter(e).x,
pos.y - sigma.utils.getCenter(e).y,
true
);
animation = {
duration: _settings('doubleClickZoomDuration'),
onComplete: function() {
_doubleTap = false;
}
};
sigma.utils.zoomTo(_camera, pos.x, pos.y, ratio, animation);
}
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
e.stopPropagation();
return false;
}
} | [
"function",
"_doubleTapHandler",
"(",
"e",
")",
"{",
"var",
"pos",
",",
"ratio",
",",
"animation",
";",
"if",
"(",
"e",
".",
"touches",
"&&",
"e",
".",
"touches",
".",
"length",
"===",
"1",
"&&",
"_settings",
"(",
"'touchEnabled'",
")",
")",
"{",
"_doubleTap",
"=",
"true",
";",
"ratio",
"=",
"1",
"/",
"_settings",
"(",
"'doubleClickZoomingRatio'",
")",
";",
"pos",
"=",
"position",
"(",
"e",
".",
"touches",
"[",
"0",
"]",
")",
";",
"_self",
".",
"dispatchEvent",
"(",
"'doubleclick'",
",",
"sigma",
".",
"utils",
".",
"mouseCoords",
"(",
"e",
",",
"pos",
".",
"x",
",",
"pos",
".",
"y",
")",
")",
";",
"if",
"(",
"_settings",
"(",
"'doubleClickEnabled'",
")",
")",
"{",
"pos",
"=",
"_camera",
".",
"cameraPosition",
"(",
"pos",
".",
"x",
"-",
"sigma",
".",
"utils",
".",
"getCenter",
"(",
"e",
")",
".",
"x",
",",
"pos",
".",
"y",
"-",
"sigma",
".",
"utils",
".",
"getCenter",
"(",
"e",
")",
".",
"y",
",",
"true",
")",
";",
"animation",
"=",
"{",
"duration",
":",
"_settings",
"(",
"'doubleClickZoomDuration'",
")",
",",
"onComplete",
":",
"function",
"(",
")",
"{",
"_doubleTap",
"=",
"false",
";",
"}",
"}",
";",
"sigma",
".",
"utils",
".",
"zoomTo",
"(",
"_camera",
",",
"pos",
".",
"x",
",",
"pos",
".",
"y",
",",
"ratio",
",",
"animation",
")",
";",
"}",
"if",
"(",
"e",
".",
"preventDefault",
")",
"e",
".",
"preventDefault",
"(",
")",
";",
"else",
"e",
".",
"returnValue",
"=",
"false",
";",
"e",
".",
"stopPropagation",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] | The handler listening to the double tap custom event. It will
basically zoom into the graph.
@param {event} e A touch event. | [
"The",
"handler",
"listening",
"to",
"the",
"double",
"tap",
"custom",
"event",
".",
"It",
"will",
"basically",
"zoom",
"into",
"the",
"graph",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/captors/sigma.captors.touch.js#L369-L408 |
6,102 | jacomyal/sigma.js | plugins/sigma.parsers.gexf/gexf-parser.js | Edge | function Edge(properties) {
// Possible Properties
var edge = {
id: properties.id,
type: properties.type || 'undirected',
label: properties.label || '',
source: properties.source,
target: properties.target,
weight: +properties.weight || 1.0
};
if (properties.viz)
edge.viz = properties.viz;
if (properties.attributes)
edge.attributes = properties.attributes;
return edge;
} | javascript | function Edge(properties) {
// Possible Properties
var edge = {
id: properties.id,
type: properties.type || 'undirected',
label: properties.label || '',
source: properties.source,
target: properties.target,
weight: +properties.weight || 1.0
};
if (properties.viz)
edge.viz = properties.viz;
if (properties.attributes)
edge.attributes = properties.attributes;
return edge;
} | [
"function",
"Edge",
"(",
"properties",
")",
"{",
"// Possible Properties",
"var",
"edge",
"=",
"{",
"id",
":",
"properties",
".",
"id",
",",
"type",
":",
"properties",
".",
"type",
"||",
"'undirected'",
",",
"label",
":",
"properties",
".",
"label",
"||",
"''",
",",
"source",
":",
"properties",
".",
"source",
",",
"target",
":",
"properties",
".",
"target",
",",
"weight",
":",
"+",
"properties",
".",
"weight",
"||",
"1.0",
"}",
";",
"if",
"(",
"properties",
".",
"viz",
")",
"edge",
".",
"viz",
"=",
"properties",
".",
"viz",
";",
"if",
"(",
"properties",
".",
"attributes",
")",
"edge",
".",
"attributes",
"=",
"properties",
".",
"attributes",
";",
"return",
"edge",
";",
"}"
] | Edge structure.
A function returning an object guarded with default value.
@param {object} properties The edge properties.
@return {object} The guarded edge object. | [
"Edge",
"structure",
".",
"A",
"function",
"returning",
"an",
"object",
"guarded",
"with",
"default",
"value",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.parsers.gexf/gexf-parser.js#L170-L189 |
6,103 | jacomyal/sigma.js | plugins/sigma.parsers.gexf/gexf-parser.js | _data | function _data(model, node_or_edge) {
var data = {};
var attvalues_els = node_or_edge.getElementsByTagName('attvalue');
// Getting Node Indicated Attributes
var ah = _helpers.nodeListToHash(attvalues_els, function(el) {
var attributes = _helpers.namedNodeMapToObject(el.attributes);
var key = attributes.id || attributes['for'];
// Returning object
return {key: key, value: attributes.value};
});
// Iterating through model
model.map(function(a) {
// Default value?
data[a.id] = !(a.id in ah) && 'defaultValue' in a ?
_helpers.enforceType(a.type, a.defaultValue) :
_helpers.enforceType(a.type, ah[a.id]);
});
return data;
} | javascript | function _data(model, node_or_edge) {
var data = {};
var attvalues_els = node_or_edge.getElementsByTagName('attvalue');
// Getting Node Indicated Attributes
var ah = _helpers.nodeListToHash(attvalues_els, function(el) {
var attributes = _helpers.namedNodeMapToObject(el.attributes);
var key = attributes.id || attributes['for'];
// Returning object
return {key: key, value: attributes.value};
});
// Iterating through model
model.map(function(a) {
// Default value?
data[a.id] = !(a.id in ah) && 'defaultValue' in a ?
_helpers.enforceType(a.type, a.defaultValue) :
_helpers.enforceType(a.type, ah[a.id]);
});
return data;
} | [
"function",
"_data",
"(",
"model",
",",
"node_or_edge",
")",
"{",
"var",
"data",
"=",
"{",
"}",
";",
"var",
"attvalues_els",
"=",
"node_or_edge",
".",
"getElementsByTagName",
"(",
"'attvalue'",
")",
";",
"// Getting Node Indicated Attributes",
"var",
"ah",
"=",
"_helpers",
".",
"nodeListToHash",
"(",
"attvalues_els",
",",
"function",
"(",
"el",
")",
"{",
"var",
"attributes",
"=",
"_helpers",
".",
"namedNodeMapToObject",
"(",
"el",
".",
"attributes",
")",
";",
"var",
"key",
"=",
"attributes",
".",
"id",
"||",
"attributes",
"[",
"'for'",
"]",
";",
"// Returning object",
"return",
"{",
"key",
":",
"key",
",",
"value",
":",
"attributes",
".",
"value",
"}",
";",
"}",
")",
";",
"// Iterating through model",
"model",
".",
"map",
"(",
"function",
"(",
"a",
")",
"{",
"// Default value?",
"data",
"[",
"a",
".",
"id",
"]",
"=",
"!",
"(",
"a",
".",
"id",
"in",
"ah",
")",
"&&",
"'defaultValue'",
"in",
"a",
"?",
"_helpers",
".",
"enforceType",
"(",
"a",
".",
"type",
",",
"a",
".",
"defaultValue",
")",
":",
"_helpers",
".",
"enforceType",
"(",
"a",
".",
"type",
",",
"ah",
"[",
"a",
".",
"id",
"]",
")",
";",
"}",
")",
";",
"return",
"data",
";",
"}"
] | Data from nodes or edges | [
"Data",
"from",
"nodes",
"or",
"edges"
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.parsers.gexf/gexf-parser.js#L271-L297 |
6,104 | jacomyal/sigma.js | plugins/sigma.parsers.gexf/gexf-parser.js | _nodeViz | function _nodeViz(node) {
var viz = {};
// Color
var color_el = _helpers.getFirstElementByTagNS(node, 'viz', 'color');
if (color_el) {
var color = ['r', 'g', 'b', 'a'].map(function(c) {
return color_el.getAttribute(c);
});
viz.color = _helpers.getRGB(color);
}
// Position
var pos_el = _helpers.getFirstElementByTagNS(node, 'viz', 'position');
if (pos_el) {
viz.position = {};
['x', 'y', 'z'].map(function(p) {
viz.position[p] = +pos_el.getAttribute(p);
});
}
// Size
var size_el = _helpers.getFirstElementByTagNS(node, 'viz', 'size');
if (size_el)
viz.size = +size_el.getAttribute('value');
// Shape
var shape_el = _helpers.getFirstElementByTagNS(node, 'viz', 'shape');
if (shape_el)
viz.shape = shape_el.getAttribute('value');
return viz;
} | javascript | function _nodeViz(node) {
var viz = {};
// Color
var color_el = _helpers.getFirstElementByTagNS(node, 'viz', 'color');
if (color_el) {
var color = ['r', 'g', 'b', 'a'].map(function(c) {
return color_el.getAttribute(c);
});
viz.color = _helpers.getRGB(color);
}
// Position
var pos_el = _helpers.getFirstElementByTagNS(node, 'viz', 'position');
if (pos_el) {
viz.position = {};
['x', 'y', 'z'].map(function(p) {
viz.position[p] = +pos_el.getAttribute(p);
});
}
// Size
var size_el = _helpers.getFirstElementByTagNS(node, 'viz', 'size');
if (size_el)
viz.size = +size_el.getAttribute('value');
// Shape
var shape_el = _helpers.getFirstElementByTagNS(node, 'viz', 'shape');
if (shape_el)
viz.shape = shape_el.getAttribute('value');
return viz;
} | [
"function",
"_nodeViz",
"(",
"node",
")",
"{",
"var",
"viz",
"=",
"{",
"}",
";",
"// Color",
"var",
"color_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"node",
",",
"'viz'",
",",
"'color'",
")",
";",
"if",
"(",
"color_el",
")",
"{",
"var",
"color",
"=",
"[",
"'r'",
",",
"'g'",
",",
"'b'",
",",
"'a'",
"]",
".",
"map",
"(",
"function",
"(",
"c",
")",
"{",
"return",
"color_el",
".",
"getAttribute",
"(",
"c",
")",
";",
"}",
")",
";",
"viz",
".",
"color",
"=",
"_helpers",
".",
"getRGB",
"(",
"color",
")",
";",
"}",
"// Position",
"var",
"pos_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"node",
",",
"'viz'",
",",
"'position'",
")",
";",
"if",
"(",
"pos_el",
")",
"{",
"viz",
".",
"position",
"=",
"{",
"}",
";",
"[",
"'x'",
",",
"'y'",
",",
"'z'",
"]",
".",
"map",
"(",
"function",
"(",
"p",
")",
"{",
"viz",
".",
"position",
"[",
"p",
"]",
"=",
"+",
"pos_el",
".",
"getAttribute",
"(",
"p",
")",
";",
"}",
")",
";",
"}",
"// Size",
"var",
"size_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"node",
",",
"'viz'",
",",
"'size'",
")",
";",
"if",
"(",
"size_el",
")",
"viz",
".",
"size",
"=",
"+",
"size_el",
".",
"getAttribute",
"(",
"'value'",
")",
";",
"// Shape",
"var",
"shape_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"node",
",",
"'viz'",
",",
"'shape'",
")",
";",
"if",
"(",
"shape_el",
")",
"viz",
".",
"shape",
"=",
"shape_el",
".",
"getAttribute",
"(",
"'value'",
")",
";",
"return",
"viz",
";",
"}"
] | Viz information from nodes | [
"Viz",
"information",
"from",
"nodes"
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.parsers.gexf/gexf-parser.js#L328-L364 |
6,105 | jacomyal/sigma.js | plugins/sigma.parsers.gexf/gexf-parser.js | _edgeViz | function _edgeViz(edge) {
var viz = {};
// Color
var color_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'color');
if (color_el) {
var color = ['r', 'g', 'b', 'a'].map(function(c) {
return color_el.getAttribute(c);
});
viz.color = _helpers.getRGB(color);
}
// Shape
var shape_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'shape');
if (shape_el)
viz.shape = shape_el.getAttribute('value');
// Thickness
var thick_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'thickness');
if (thick_el)
viz.thickness = +thick_el.getAttribute('value');
return viz;
} | javascript | function _edgeViz(edge) {
var viz = {};
// Color
var color_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'color');
if (color_el) {
var color = ['r', 'g', 'b', 'a'].map(function(c) {
return color_el.getAttribute(c);
});
viz.color = _helpers.getRGB(color);
}
// Shape
var shape_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'shape');
if (shape_el)
viz.shape = shape_el.getAttribute('value');
// Thickness
var thick_el = _helpers.getFirstElementByTagNS(edge, 'viz', 'thickness');
if (thick_el)
viz.thickness = +thick_el.getAttribute('value');
return viz;
} | [
"function",
"_edgeViz",
"(",
"edge",
")",
"{",
"var",
"viz",
"=",
"{",
"}",
";",
"// Color",
"var",
"color_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"edge",
",",
"'viz'",
",",
"'color'",
")",
";",
"if",
"(",
"color_el",
")",
"{",
"var",
"color",
"=",
"[",
"'r'",
",",
"'g'",
",",
"'b'",
",",
"'a'",
"]",
".",
"map",
"(",
"function",
"(",
"c",
")",
"{",
"return",
"color_el",
".",
"getAttribute",
"(",
"c",
")",
";",
"}",
")",
";",
"viz",
".",
"color",
"=",
"_helpers",
".",
"getRGB",
"(",
"color",
")",
";",
"}",
"// Shape",
"var",
"shape_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"edge",
",",
"'viz'",
",",
"'shape'",
")",
";",
"if",
"(",
"shape_el",
")",
"viz",
".",
"shape",
"=",
"shape_el",
".",
"getAttribute",
"(",
"'value'",
")",
";",
"// Thickness",
"var",
"thick_el",
"=",
"_helpers",
".",
"getFirstElementByTagNS",
"(",
"edge",
",",
"'viz'",
",",
"'thickness'",
")",
";",
"if",
"(",
"thick_el",
")",
"viz",
".",
"thickness",
"=",
"+",
"thick_el",
".",
"getAttribute",
"(",
"'value'",
")",
";",
"return",
"viz",
";",
"}"
] | Viz information from edges | [
"Viz",
"information",
"from",
"edges"
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.parsers.gexf/gexf-parser.js#L395-L420 |
6,106 | jacomyal/sigma.js | plugins/sigma.parsers.gexf/gexf-parser.js | fetchAndParse | function fetchAndParse(gexf_url, callback) {
if (typeof callback === 'function') {
return fetch(gexf_url, function(gexf) {
callback(Graph(gexf));
});
} else
return Graph(fetch(gexf_url));
} | javascript | function fetchAndParse(gexf_url, callback) {
if (typeof callback === 'function') {
return fetch(gexf_url, function(gexf) {
callback(Graph(gexf));
});
} else
return Graph(fetch(gexf_url));
} | [
"function",
"fetchAndParse",
"(",
"gexf_url",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"return",
"fetch",
"(",
"gexf_url",
",",
"function",
"(",
"gexf",
")",
"{",
"callback",
"(",
"Graph",
"(",
"gexf",
")",
")",
";",
"}",
")",
";",
"}",
"else",
"return",
"Graph",
"(",
"fetch",
"(",
"gexf_url",
")",
")",
";",
"}"
] | Fetch and parse the GEXF File | [
"Fetch",
"and",
"parse",
"the",
"GEXF",
"File"
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.parsers.gexf/gexf-parser.js#L521-L528 |
6,107 | jacomyal/sigma.js | plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js | calculateOffset | function calculateOffset(element) {
var style = window.getComputedStyle(element);
var getCssProperty = function(prop) {
return parseInt(style.getPropertyValue(prop).replace('px', '')) || 0;
};
return {
left: element.getBoundingClientRect().left + getCssProperty('padding-left'),
top: element.getBoundingClientRect().top + getCssProperty('padding-top')
};
} | javascript | function calculateOffset(element) {
var style = window.getComputedStyle(element);
var getCssProperty = function(prop) {
return parseInt(style.getPropertyValue(prop).replace('px', '')) || 0;
};
return {
left: element.getBoundingClientRect().left + getCssProperty('padding-left'),
top: element.getBoundingClientRect().top + getCssProperty('padding-top')
};
} | [
"function",
"calculateOffset",
"(",
"element",
")",
"{",
"var",
"style",
"=",
"window",
".",
"getComputedStyle",
"(",
"element",
")",
";",
"var",
"getCssProperty",
"=",
"function",
"(",
"prop",
")",
"{",
"return",
"parseInt",
"(",
"style",
".",
"getPropertyValue",
"(",
"prop",
")",
".",
"replace",
"(",
"'px'",
",",
"''",
")",
")",
"||",
"0",
";",
"}",
";",
"return",
"{",
"left",
":",
"element",
".",
"getBoundingClientRect",
"(",
")",
".",
"left",
"+",
"getCssProperty",
"(",
"'padding-left'",
")",
",",
"top",
":",
"element",
".",
"getBoundingClientRect",
"(",
")",
".",
"top",
"+",
"getCssProperty",
"(",
"'padding-top'",
")",
"}",
";",
"}"
] | Calculates the global offset of the given element more accurately than element.offsetTop and element.offsetLeft. | [
"Calculates",
"the",
"global",
"offset",
"of",
"the",
"given",
"element",
"more",
"accurately",
"than",
"element",
".",
"offsetTop",
"and",
"element",
".",
"offsetLeft",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js#L96-L105 |
6,108 | jacomyal/sigma.js | plugins/sigma.layout.forceAtlas2/worker.js | function(e) {
switch (e.data.action) {
case 'start':
init(
new Float32Array(e.data.nodes),
new Float32Array(e.data.edges),
e.data.config
);
// First iteration(s)
run(W.settings.startingIterations);
break;
case 'loop':
NodeMatrix = new Float32Array(e.data.nodes);
run(W.settings.iterationsPerRender);
break;
case 'config':
// Merging new settings
configure(e.data.config);
break;
case 'kill':
// Deleting context for garbage collection
__emptyObject(W);
NodeMatrix = null;
EdgeMatrix = null;
RegionMatrix = null;
self.removeEventListener('message', listener);
break;
default:
}
} | javascript | function(e) {
switch (e.data.action) {
case 'start':
init(
new Float32Array(e.data.nodes),
new Float32Array(e.data.edges),
e.data.config
);
// First iteration(s)
run(W.settings.startingIterations);
break;
case 'loop':
NodeMatrix = new Float32Array(e.data.nodes);
run(W.settings.iterationsPerRender);
break;
case 'config':
// Merging new settings
configure(e.data.config);
break;
case 'kill':
// Deleting context for garbage collection
__emptyObject(W);
NodeMatrix = null;
EdgeMatrix = null;
RegionMatrix = null;
self.removeEventListener('message', listener);
break;
default:
}
} | [
"function",
"(",
"e",
")",
"{",
"switch",
"(",
"e",
".",
"data",
".",
"action",
")",
"{",
"case",
"'start'",
":",
"init",
"(",
"new",
"Float32Array",
"(",
"e",
".",
"data",
".",
"nodes",
")",
",",
"new",
"Float32Array",
"(",
"e",
".",
"data",
".",
"edges",
")",
",",
"e",
".",
"data",
".",
"config",
")",
";",
"// First iteration(s)",
"run",
"(",
"W",
".",
"settings",
".",
"startingIterations",
")",
";",
"break",
";",
"case",
"'loop'",
":",
"NodeMatrix",
"=",
"new",
"Float32Array",
"(",
"e",
".",
"data",
".",
"nodes",
")",
";",
"run",
"(",
"W",
".",
"settings",
".",
"iterationsPerRender",
")",
";",
"break",
";",
"case",
"'config'",
":",
"// Merging new settings",
"configure",
"(",
"e",
".",
"data",
".",
"config",
")",
";",
"break",
";",
"case",
"'kill'",
":",
"// Deleting context for garbage collection",
"__emptyObject",
"(",
"W",
")",
";",
"NodeMatrix",
"=",
"null",
";",
"EdgeMatrix",
"=",
"null",
";",
"RegionMatrix",
"=",
"null",
";",
"self",
".",
"removeEventListener",
"(",
"'message'",
",",
"listener",
")",
";",
"break",
";",
"default",
":",
"}",
"}"
] | On supervisor message | [
"On",
"supervisor",
"message"
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/plugins/sigma.layout.forceAtlas2/worker.js#L993-L1029 |
|
6,109 | jacomyal/sigma.js | src/conrad.js | _dispatch | function _dispatch(events, data) {
var i,
j,
i_end,
j_end,
event,
eventName,
eArray = Array.isArray(events) ?
events :
events.split(/ /);
data = data === undefined ? {} : data;
for (i = 0, i_end = eArray.length; i !== i_end; i += 1) {
eventName = eArray[i];
if (_handlers[eventName]) {
event = {
type: eventName,
data: data || {}
};
for (j = 0, j_end = _handlers[eventName].length; j !== j_end; j += 1)
try {
_handlers[eventName][j].handler(event);
} catch (e) {}
}
}
} | javascript | function _dispatch(events, data) {
var i,
j,
i_end,
j_end,
event,
eventName,
eArray = Array.isArray(events) ?
events :
events.split(/ /);
data = data === undefined ? {} : data;
for (i = 0, i_end = eArray.length; i !== i_end; i += 1) {
eventName = eArray[i];
if (_handlers[eventName]) {
event = {
type: eventName,
data: data || {}
};
for (j = 0, j_end = _handlers[eventName].length; j !== j_end; j += 1)
try {
_handlers[eventName][j].handler(event);
} catch (e) {}
}
}
} | [
"function",
"_dispatch",
"(",
"events",
",",
"data",
")",
"{",
"var",
"i",
",",
"j",
",",
"i_end",
",",
"j_end",
",",
"event",
",",
"eventName",
",",
"eArray",
"=",
"Array",
".",
"isArray",
"(",
"events",
")",
"?",
"events",
":",
"events",
".",
"split",
"(",
"/",
" ",
"/",
")",
";",
"data",
"=",
"data",
"===",
"undefined",
"?",
"{",
"}",
":",
"data",
";",
"for",
"(",
"i",
"=",
"0",
",",
"i_end",
"=",
"eArray",
".",
"length",
";",
"i",
"!==",
"i_end",
";",
"i",
"+=",
"1",
")",
"{",
"eventName",
"=",
"eArray",
"[",
"i",
"]",
";",
"if",
"(",
"_handlers",
"[",
"eventName",
"]",
")",
"{",
"event",
"=",
"{",
"type",
":",
"eventName",
",",
"data",
":",
"data",
"||",
"{",
"}",
"}",
";",
"for",
"(",
"j",
"=",
"0",
",",
"j_end",
"=",
"_handlers",
"[",
"eventName",
"]",
".",
"length",
";",
"j",
"!==",
"j_end",
";",
"j",
"+=",
"1",
")",
"try",
"{",
"_handlers",
"[",
"eventName",
"]",
"[",
"j",
"]",
".",
"handler",
"(",
"event",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] | Executes each handler bound to the event.
@param {string} events The name of the event (or the events separated
by spaces).
@param {?Object} data The content of the event (optional).
@return {Object} Returns conrad. | [
"Executes",
"each",
"handler",
"bound",
"to",
"the",
"event",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L225-L253 |
6,110 | jacomyal/sigma.js | src/conrad.js | _activateJob | function _activateJob(job) {
var l = _sortedByPriorityJobs.length;
// Add the job to the running jobs:
_runningJobs[job.id] = job;
job.status = 'running';
// Add the job to the priorities:
if (l) {
job.weightTime = _sortedByPriorityJobs[l - 1].weightTime;
job.currentTime = job.weightTime * (job.weight || 1);
}
// Initialize the job and dispatch:
job.startTime = __dateNow();
_dispatch('jobStarted', __clone(job));
_sortedByPriorityJobs.push(job);
} | javascript | function _activateJob(job) {
var l = _sortedByPriorityJobs.length;
// Add the job to the running jobs:
_runningJobs[job.id] = job;
job.status = 'running';
// Add the job to the priorities:
if (l) {
job.weightTime = _sortedByPriorityJobs[l - 1].weightTime;
job.currentTime = job.weightTime * (job.weight || 1);
}
// Initialize the job and dispatch:
job.startTime = __dateNow();
_dispatch('jobStarted', __clone(job));
_sortedByPriorityJobs.push(job);
} | [
"function",
"_activateJob",
"(",
"job",
")",
"{",
"var",
"l",
"=",
"_sortedByPriorityJobs",
".",
"length",
";",
"// Add the job to the running jobs:",
"_runningJobs",
"[",
"job",
".",
"id",
"]",
"=",
"job",
";",
"job",
".",
"status",
"=",
"'running'",
";",
"// Add the job to the priorities:",
"if",
"(",
"l",
")",
"{",
"job",
".",
"weightTime",
"=",
"_sortedByPriorityJobs",
"[",
"l",
"-",
"1",
"]",
".",
"weightTime",
";",
"job",
".",
"currentTime",
"=",
"job",
".",
"weightTime",
"*",
"(",
"job",
".",
"weight",
"||",
"1",
")",
";",
"}",
"// Initialize the job and dispatch:",
"job",
".",
"startTime",
"=",
"__dateNow",
"(",
")",
";",
"_dispatch",
"(",
"'jobStarted'",
",",
"__clone",
"(",
"job",
")",
")",
";",
"_sortedByPriorityJobs",
".",
"push",
"(",
"job",
")",
";",
"}"
] | Activates a job, by adding it to the _runningJobs object and the
_sortedByPriorityJobs array. It also initializes its currentTime value.
@param {Object} job The job to activate. | [
"Activates",
"a",
"job",
"by",
"adding",
"it",
"to",
"the",
"_runningJobs",
"object",
"and",
"the",
"_sortedByPriorityJobs",
"array",
".",
"It",
"also",
"initializes",
"its",
"currentTime",
"value",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L306-L324 |
6,111 | jacomyal/sigma.js | src/conrad.js | _addJob | function _addJob(v1, v2) {
var i,
l,
o;
// Array of jobs:
if (Array.isArray(v1)) {
// Keep conrad to start until the last job is added:
_noStart = true;
for (i = 0, l = v1.length; i < l; i++)
_addJob(v1[i].id, __extend(v1[i], v2));
_noStart = false;
if (!_isRunning) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
} else if (typeof v1 === 'object') {
// One job (object):
if (typeof v1.id === 'string')
_addJob(v1.id, v1);
// Hash of jobs:
else {
// Keep conrad to start until the last job is added:
_noStart = true;
for (i in v1)
if (typeof v1[i] === 'function')
_addJob(i, __extend({
job: v1[i]
}, v2));
else
_addJob(i, __extend(v1[i], v2));
_noStart = false;
if (!_isRunning) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
}
// One job (string, *):
} else if (typeof v1 === 'string') {
if (_hasJob(v1))
throw new Error(
'[conrad.addJob] Job with id "' + v1 + '" already exists.'
);
// One job (string, function):
if (typeof v2 === 'function') {
o = {
id: v1,
done: 0,
time: 0,
status: 'waiting',
currentTime: 0,
averageTime: 0,
weightTime: 0,
job: v2
};
// One job (string, object):
} else if (typeof v2 === 'object') {
o = __extend(
{
id: v1,
done: 0,
time: 0,
status: 'waiting',
currentTime: 0,
averageTime: 0,
weightTime: 0
},
v2
);
// If none of those cases, throw an error:
} else
throw new Error('[conrad.addJob] Wrong arguments.');
// Effectively add the job:
_jobs[v1] = o;
_dispatch('jobAdded', __clone(o));
// Check if the loop has to be started:
if (!_isRunning && !_noStart) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
// If none of those cases, throw an error:
} else
throw new Error('[conrad.addJob] Wrong arguments.');
return this;
} | javascript | function _addJob(v1, v2) {
var i,
l,
o;
// Array of jobs:
if (Array.isArray(v1)) {
// Keep conrad to start until the last job is added:
_noStart = true;
for (i = 0, l = v1.length; i < l; i++)
_addJob(v1[i].id, __extend(v1[i], v2));
_noStart = false;
if (!_isRunning) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
} else if (typeof v1 === 'object') {
// One job (object):
if (typeof v1.id === 'string')
_addJob(v1.id, v1);
// Hash of jobs:
else {
// Keep conrad to start until the last job is added:
_noStart = true;
for (i in v1)
if (typeof v1[i] === 'function')
_addJob(i, __extend({
job: v1[i]
}, v2));
else
_addJob(i, __extend(v1[i], v2));
_noStart = false;
if (!_isRunning) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
}
// One job (string, *):
} else if (typeof v1 === 'string') {
if (_hasJob(v1))
throw new Error(
'[conrad.addJob] Job with id "' + v1 + '" already exists.'
);
// One job (string, function):
if (typeof v2 === 'function') {
o = {
id: v1,
done: 0,
time: 0,
status: 'waiting',
currentTime: 0,
averageTime: 0,
weightTime: 0,
job: v2
};
// One job (string, object):
} else if (typeof v2 === 'object') {
o = __extend(
{
id: v1,
done: 0,
time: 0,
status: 'waiting',
currentTime: 0,
averageTime: 0,
weightTime: 0
},
v2
);
// If none of those cases, throw an error:
} else
throw new Error('[conrad.addJob] Wrong arguments.');
// Effectively add the job:
_jobs[v1] = o;
_dispatch('jobAdded', __clone(o));
// Check if the loop has to be started:
if (!_isRunning && !_noStart) {
// Update the _lastFrameTime:
_lastFrameTime = __dateNow();
_dispatch('start');
_loop();
}
// If none of those cases, throw an error:
} else
throw new Error('[conrad.addJob] Wrong arguments.');
return this;
} | [
"function",
"_addJob",
"(",
"v1",
",",
"v2",
")",
"{",
"var",
"i",
",",
"l",
",",
"o",
";",
"// Array of jobs:",
"if",
"(",
"Array",
".",
"isArray",
"(",
"v1",
")",
")",
"{",
"// Keep conrad to start until the last job is added:",
"_noStart",
"=",
"true",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"v1",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"_addJob",
"(",
"v1",
"[",
"i",
"]",
".",
"id",
",",
"__extend",
"(",
"v1",
"[",
"i",
"]",
",",
"v2",
")",
")",
";",
"_noStart",
"=",
"false",
";",
"if",
"(",
"!",
"_isRunning",
")",
"{",
"// Update the _lastFrameTime:",
"_lastFrameTime",
"=",
"__dateNow",
"(",
")",
";",
"_dispatch",
"(",
"'start'",
")",
";",
"_loop",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"typeof",
"v1",
"===",
"'object'",
")",
"{",
"// One job (object):",
"if",
"(",
"typeof",
"v1",
".",
"id",
"===",
"'string'",
")",
"_addJob",
"(",
"v1",
".",
"id",
",",
"v1",
")",
";",
"// Hash of jobs:",
"else",
"{",
"// Keep conrad to start until the last job is added:",
"_noStart",
"=",
"true",
";",
"for",
"(",
"i",
"in",
"v1",
")",
"if",
"(",
"typeof",
"v1",
"[",
"i",
"]",
"===",
"'function'",
")",
"_addJob",
"(",
"i",
",",
"__extend",
"(",
"{",
"job",
":",
"v1",
"[",
"i",
"]",
"}",
",",
"v2",
")",
")",
";",
"else",
"_addJob",
"(",
"i",
",",
"__extend",
"(",
"v1",
"[",
"i",
"]",
",",
"v2",
")",
")",
";",
"_noStart",
"=",
"false",
";",
"if",
"(",
"!",
"_isRunning",
")",
"{",
"// Update the _lastFrameTime:",
"_lastFrameTime",
"=",
"__dateNow",
"(",
")",
";",
"_dispatch",
"(",
"'start'",
")",
";",
"_loop",
"(",
")",
";",
"}",
"}",
"// One job (string, *):",
"}",
"else",
"if",
"(",
"typeof",
"v1",
"===",
"'string'",
")",
"{",
"if",
"(",
"_hasJob",
"(",
"v1",
")",
")",
"throw",
"new",
"Error",
"(",
"'[conrad.addJob] Job with id \"'",
"+",
"v1",
"+",
"'\" already exists.'",
")",
";",
"// One job (string, function):",
"if",
"(",
"typeof",
"v2",
"===",
"'function'",
")",
"{",
"o",
"=",
"{",
"id",
":",
"v1",
",",
"done",
":",
"0",
",",
"time",
":",
"0",
",",
"status",
":",
"'waiting'",
",",
"currentTime",
":",
"0",
",",
"averageTime",
":",
"0",
",",
"weightTime",
":",
"0",
",",
"job",
":",
"v2",
"}",
";",
"// One job (string, object):",
"}",
"else",
"if",
"(",
"typeof",
"v2",
"===",
"'object'",
")",
"{",
"o",
"=",
"__extend",
"(",
"{",
"id",
":",
"v1",
",",
"done",
":",
"0",
",",
"time",
":",
"0",
",",
"status",
":",
"'waiting'",
",",
"currentTime",
":",
"0",
",",
"averageTime",
":",
"0",
",",
"weightTime",
":",
"0",
"}",
",",
"v2",
")",
";",
"// If none of those cases, throw an error:",
"}",
"else",
"throw",
"new",
"Error",
"(",
"'[conrad.addJob] Wrong arguments.'",
")",
";",
"// Effectively add the job:",
"_jobs",
"[",
"v1",
"]",
"=",
"o",
";",
"_dispatch",
"(",
"'jobAdded'",
",",
"__clone",
"(",
"o",
")",
")",
";",
"// Check if the loop has to be started:",
"if",
"(",
"!",
"_isRunning",
"&&",
"!",
"_noStart",
")",
"{",
"// Update the _lastFrameTime:",
"_lastFrameTime",
"=",
"__dateNow",
"(",
")",
";",
"_dispatch",
"(",
"'start'",
")",
";",
"_loop",
"(",
")",
";",
"}",
"// If none of those cases, throw an error:",
"}",
"else",
"throw",
"new",
"Error",
"(",
"'[conrad.addJob] Wrong arguments.'",
")",
";",
"return",
"this",
";",
"}"
] | Adds one or more jobs, and starts the loop if no job was running before. A
job is at least a unique string "id" and a function, and there are some
parameters that you can specify for each job to modify the way conrad will
execute it. If a job is added with the "id" of another job that is waiting
or still running, an error will be thrown.
When a job is added, it is referenced in the _jobs object, by its id.
Then, if it has to be executed right now, it will be also referenced in
the _runningJobs object. If it has to wait, then it will be added into the
_waitingJobs object, until it can start.
Keep reading this documentation to see how to call this method.
@return {Object} Returns conrad.
Adding one job:
***************
Basically, a job is defined by its string id and a function (the job). It
is also possible to add some parameters:
> conrad.addJob('myJobId', myJobFunction);
> conrad.addJob('myJobId', {
> job: myJobFunction,
> someParameter: someValue
> });
> conrad.addJob({
> id: 'myJobId',
> job: myJobFunction,
> someParameter: someValue
> });
Adding several jobs:
********************
When adding several jobs at the same time, it is possible to specify
parameters for each one individually or for all:
> conrad.addJob([
> {
> id: 'myJobId1',
> job: myJobFunction1,
> someParameter1: someValue1
> },
> {
> id: 'myJobId2',
> job: myJobFunction2,
> someParameter2: someValue2
> }
> ], {
> someCommonParameter: someCommonValue
> });
> conrad.addJob({
> myJobId1: {,
> job: myJobFunction1,
> someParameter1: someValue1
> },
> myJobId2: {,
> job: myJobFunction2,
> someParameter2: someValue2
> }
> }, {
> someCommonParameter: someCommonValue
> });
> conrad.addJob({
> myJobId1: myJobFunction1,
> myJobId2: myJobFunction2
> }, {
> someCommonParameter: someCommonValue
> });
Recognized parameters:
**********************
Here is the exhaustive list of every accepted parameters:
{?Function} end A callback to execute when the job is ended. It is
not executed if the job is killed instead of ended
"naturally".
{?Integer} count The number of time the job has to be executed.
{?Number} weight If specified, the job will be executed as it was
added "weight" times.
{?String} after The id of another job (eventually not added yet).
If specified, this job will start only when the
specified "after" job is ended. | [
"Adds",
"one",
"or",
"more",
"jobs",
"and",
"starts",
"the",
"loop",
"if",
"no",
"job",
"was",
"running",
"before",
".",
"A",
"job",
"is",
"at",
"least",
"a",
"unique",
"string",
"id",
"and",
"a",
"function",
"and",
"there",
"are",
"some",
"parameters",
"that",
"you",
"can",
"specify",
"for",
"each",
"job",
"to",
"modify",
"the",
"way",
"conrad",
"will",
"execute",
"it",
".",
"If",
"a",
"job",
"is",
"added",
"with",
"the",
"id",
"of",
"another",
"job",
"that",
"is",
"waiting",
"or",
"still",
"running",
"an",
"error",
"will",
"be",
"thrown",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L473-L579 |
6,112 | jacomyal/sigma.js | src/conrad.js | _killJob | function _killJob(v1) {
var i,
l,
k,
a,
job,
found = false;
// Array of job ids:
if (Array.isArray(v1))
for (i = 0, l = v1.length; i < l; i++)
_killJob(v1[i]);
// One job's id:
else if (typeof v1 === 'string') {
a = [_runningJobs, _waitingJobs, _jobs];
// Remove the job from the hashes:
for (i = 0, l = a.length; i < l; i++)
if (v1 in a[i]) {
job = a[i][v1];
if (_parameters.history) {
job.status = 'done';
_doneJobs.push(job);
}
_dispatch('jobEnded', __clone(job));
delete a[i][v1];
if (typeof job.end === 'function')
job.end();
found = true;
}
// Remove the priorities array:
a = _sortedByPriorityJobs;
for (i = 0, l = a.length; i < l; i++)
if (a[i].id === v1) {
a.splice(i, 1);
break;
}
if (!found)
throw new Error('[conrad.killJob] Job "' + v1 + '" not found.');
// If none of those cases, throw an error:
} else
throw new Error('[conrad.killJob] Wrong arguments.');
return this;
} | javascript | function _killJob(v1) {
var i,
l,
k,
a,
job,
found = false;
// Array of job ids:
if (Array.isArray(v1))
for (i = 0, l = v1.length; i < l; i++)
_killJob(v1[i]);
// One job's id:
else if (typeof v1 === 'string') {
a = [_runningJobs, _waitingJobs, _jobs];
// Remove the job from the hashes:
for (i = 0, l = a.length; i < l; i++)
if (v1 in a[i]) {
job = a[i][v1];
if (_parameters.history) {
job.status = 'done';
_doneJobs.push(job);
}
_dispatch('jobEnded', __clone(job));
delete a[i][v1];
if (typeof job.end === 'function')
job.end();
found = true;
}
// Remove the priorities array:
a = _sortedByPriorityJobs;
for (i = 0, l = a.length; i < l; i++)
if (a[i].id === v1) {
a.splice(i, 1);
break;
}
if (!found)
throw new Error('[conrad.killJob] Job "' + v1 + '" not found.');
// If none of those cases, throw an error:
} else
throw new Error('[conrad.killJob] Wrong arguments.');
return this;
} | [
"function",
"_killJob",
"(",
"v1",
")",
"{",
"var",
"i",
",",
"l",
",",
"k",
",",
"a",
",",
"job",
",",
"found",
"=",
"false",
";",
"// Array of job ids:",
"if",
"(",
"Array",
".",
"isArray",
"(",
"v1",
")",
")",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"v1",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"_killJob",
"(",
"v1",
"[",
"i",
"]",
")",
";",
"// One job's id:",
"else",
"if",
"(",
"typeof",
"v1",
"===",
"'string'",
")",
"{",
"a",
"=",
"[",
"_runningJobs",
",",
"_waitingJobs",
",",
"_jobs",
"]",
";",
"// Remove the job from the hashes:",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"if",
"(",
"v1",
"in",
"a",
"[",
"i",
"]",
")",
"{",
"job",
"=",
"a",
"[",
"i",
"]",
"[",
"v1",
"]",
";",
"if",
"(",
"_parameters",
".",
"history",
")",
"{",
"job",
".",
"status",
"=",
"'done'",
";",
"_doneJobs",
".",
"push",
"(",
"job",
")",
";",
"}",
"_dispatch",
"(",
"'jobEnded'",
",",
"__clone",
"(",
"job",
")",
")",
";",
"delete",
"a",
"[",
"i",
"]",
"[",
"v1",
"]",
";",
"if",
"(",
"typeof",
"job",
".",
"end",
"===",
"'function'",
")",
"job",
".",
"end",
"(",
")",
";",
"found",
"=",
"true",
";",
"}",
"// Remove the priorities array:",
"a",
"=",
"_sortedByPriorityJobs",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"if",
"(",
"a",
"[",
"i",
"]",
".",
"id",
"===",
"v1",
")",
"{",
"a",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"break",
";",
"}",
"if",
"(",
"!",
"found",
")",
"throw",
"new",
"Error",
"(",
"'[conrad.killJob] Job \"'",
"+",
"v1",
"+",
"'\" not found.'",
")",
";",
"// If none of those cases, throw an error:",
"}",
"else",
"throw",
"new",
"Error",
"(",
"'[conrad.killJob] Wrong arguments.'",
")",
";",
"return",
"this",
";",
"}"
] | Kills one or more jobs, indicated by their ids. It is only possible to
kill running jobs or waiting jobs. If you try to kill a job that does not
exist or that is already killed, a warning will be thrown.
@param {Array|String} v1 A string job id or an array of job ids.
@return {Object} Returns conrad. | [
"Kills",
"one",
"or",
"more",
"jobs",
"indicated",
"by",
"their",
"ids",
".",
"It",
"is",
"only",
"possible",
"to",
"kill",
"running",
"jobs",
"or",
"waiting",
"jobs",
".",
"If",
"you",
"try",
"to",
"kill",
"a",
"job",
"that",
"does",
"not",
"exist",
"or",
"that",
"is",
"already",
"killed",
"a",
"warning",
"will",
"be",
"thrown",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L589-L641 |
6,113 | jacomyal/sigma.js | src/conrad.js | _killAll | function _killAll() {
var k,
jobs = __extend(_jobs, _runningJobs, _waitingJobs);
// Take every jobs and push them into the _doneJobs object:
if (_parameters.history)
for (k in jobs) {
jobs[k].status = 'done';
_doneJobs.push(jobs[k]);
if (typeof jobs[k].end === 'function')
jobs[k].end();
}
// Reinitialize the different jobs lists:
_jobs = {};
_waitingJobs = {};
_runningJobs = {};
_sortedByPriorityJobs = [];
// In case some jobs are added right after the kill:
_isRunning = false;
return this;
} | javascript | function _killAll() {
var k,
jobs = __extend(_jobs, _runningJobs, _waitingJobs);
// Take every jobs and push them into the _doneJobs object:
if (_parameters.history)
for (k in jobs) {
jobs[k].status = 'done';
_doneJobs.push(jobs[k]);
if (typeof jobs[k].end === 'function')
jobs[k].end();
}
// Reinitialize the different jobs lists:
_jobs = {};
_waitingJobs = {};
_runningJobs = {};
_sortedByPriorityJobs = [];
// In case some jobs are added right after the kill:
_isRunning = false;
return this;
} | [
"function",
"_killAll",
"(",
")",
"{",
"var",
"k",
",",
"jobs",
"=",
"__extend",
"(",
"_jobs",
",",
"_runningJobs",
",",
"_waitingJobs",
")",
";",
"// Take every jobs and push them into the _doneJobs object:",
"if",
"(",
"_parameters",
".",
"history",
")",
"for",
"(",
"k",
"in",
"jobs",
")",
"{",
"jobs",
"[",
"k",
"]",
".",
"status",
"=",
"'done'",
";",
"_doneJobs",
".",
"push",
"(",
"jobs",
"[",
"k",
"]",
")",
";",
"if",
"(",
"typeof",
"jobs",
"[",
"k",
"]",
".",
"end",
"===",
"'function'",
")",
"jobs",
"[",
"k",
"]",
".",
"end",
"(",
")",
";",
"}",
"// Reinitialize the different jobs lists:",
"_jobs",
"=",
"{",
"}",
";",
"_waitingJobs",
"=",
"{",
"}",
";",
"_runningJobs",
"=",
"{",
"}",
";",
"_sortedByPriorityJobs",
"=",
"[",
"]",
";",
"// In case some jobs are added right after the kill:",
"_isRunning",
"=",
"false",
";",
"return",
"this",
";",
"}"
] | Kills every running, waiting, and just added jobs.
@return {Object} Returns conrad. | [
"Kills",
"every",
"running",
"waiting",
"and",
"just",
"added",
"jobs",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L648-L672 |
6,114 | jacomyal/sigma.js | src/conrad.js | _hasJob | function _hasJob(id) {
var job = _jobs[id] || _runningJobs[id] || _waitingJobs[id];
return job ? __extend(job) : null;
} | javascript | function _hasJob(id) {
var job = _jobs[id] || _runningJobs[id] || _waitingJobs[id];
return job ? __extend(job) : null;
} | [
"function",
"_hasJob",
"(",
"id",
")",
"{",
"var",
"job",
"=",
"_jobs",
"[",
"id",
"]",
"||",
"_runningJobs",
"[",
"id",
"]",
"||",
"_waitingJobs",
"[",
"id",
"]",
";",
"return",
"job",
"?",
"__extend",
"(",
"job",
")",
":",
"null",
";",
"}"
] | Returns true if a job with the specified id is currently running or
waiting, and false else.
@param {String} id The id of the job.
@return {?Object} Returns the job object if it exists. | [
"Returns",
"true",
"if",
"a",
"job",
"with",
"the",
"specified",
"id",
"is",
"currently",
"running",
"or",
"waiting",
"and",
"false",
"else",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L681-L684 |
6,115 | jacomyal/sigma.js | src/conrad.js | _settings | function _settings(v1, v2) {
var o;
if (typeof a1 === 'string' && arguments.length === 1)
return _parameters[a1];
else {
o = (typeof a1 === 'object' && arguments.length === 1) ?
a1 || {} :
{};
if (typeof a1 === 'string')
o[a1] = a2;
for (var k in o)
if (o[k] !== undefined)
_parameters[k] = o[k];
else
delete _parameters[k];
return this;
}
} | javascript | function _settings(v1, v2) {
var o;
if (typeof a1 === 'string' && arguments.length === 1)
return _parameters[a1];
else {
o = (typeof a1 === 'object' && arguments.length === 1) ?
a1 || {} :
{};
if (typeof a1 === 'string')
o[a1] = a2;
for (var k in o)
if (o[k] !== undefined)
_parameters[k] = o[k];
else
delete _parameters[k];
return this;
}
} | [
"function",
"_settings",
"(",
"v1",
",",
"v2",
")",
"{",
"var",
"o",
";",
"if",
"(",
"typeof",
"a1",
"===",
"'string'",
"&&",
"arguments",
".",
"length",
"===",
"1",
")",
"return",
"_parameters",
"[",
"a1",
"]",
";",
"else",
"{",
"o",
"=",
"(",
"typeof",
"a1",
"===",
"'object'",
"&&",
"arguments",
".",
"length",
"===",
"1",
")",
"?",
"a1",
"||",
"{",
"}",
":",
"{",
"}",
";",
"if",
"(",
"typeof",
"a1",
"===",
"'string'",
")",
"o",
"[",
"a1",
"]",
"=",
"a2",
";",
"for",
"(",
"var",
"k",
"in",
"o",
")",
"if",
"(",
"o",
"[",
"k",
"]",
"!==",
"undefined",
")",
"_parameters",
"[",
"k",
"]",
"=",
"o",
"[",
"k",
"]",
";",
"else",
"delete",
"_parameters",
"[",
"k",
"]",
";",
"return",
"this",
";",
"}",
"}"
] | This method will set the setting specified by "v1" to the value specified
by "v2" if both are given, and else return the current value of the
settings "v1".
@param {String} v1 The name of the property.
@param {?*} v2 Eventually, a value to set to the specified
property.
@return {Object|*} Returns the specified settings value if "v2" is not
given, and conrad else. | [
"This",
"method",
"will",
"set",
"the",
"setting",
"specified",
"by",
"v1",
"to",
"the",
"value",
"specified",
"by",
"v2",
"if",
"both",
"are",
"given",
"and",
"else",
"return",
"the",
"current",
"value",
"of",
"the",
"settings",
"v1",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L697-L717 |
6,116 | jacomyal/sigma.js | src/conrad.js | _getStats | function _getStats(v1, v2) {
var a,
k,
i,
l,
stats,
pattern,
isPatternString;
if (!arguments.length) {
stats = [];
for (k in _jobs)
stats.push(_jobs[k]);
for (k in _waitingJobs)
stats.push(_waitingJobs[k]);
for (k in _runningJobs)
stats.push(_runningJobs[k]);
stats = stats.concat(_doneJobs);
}
if (typeof v1 === 'string')
switch (v1) {
case 'waiting':
stats = __objectValues(_waitingJobs);
break;
case 'running':
stats = __objectValues(_runningJobs);
break;
case 'done':
stats = _doneJobs;
break;
default:
pattern = v1;
}
if (v1 instanceof RegExp)
pattern = v1;
if (!pattern && (typeof v2 === 'string' || v2 instanceof RegExp))
pattern = v2;
// Filter jobs if a pattern is given:
if (pattern) {
isPatternString = typeof pattern === 'string';
if (stats instanceof Array) {
a = stats;
} else if (typeof stats === 'object') {
a = [];
for (k in stats)
a = a.concat(stats[k]);
} else {
a = [];
for (k in _jobs)
a.push(_jobs[k]);
for (k in _waitingJobs)
a.push(_waitingJobs[k]);
for (k in _runningJobs)
a.push(_runningJobs[k]);
a = a.concat(_doneJobs);
}
stats = [];
for (i = 0, l = a.length; i < l; i++)
if (isPatternString ? a[i].id === pattern : a[i].id.match(pattern))
stats.push(a[i]);
}
return __clone(stats);
} | javascript | function _getStats(v1, v2) {
var a,
k,
i,
l,
stats,
pattern,
isPatternString;
if (!arguments.length) {
stats = [];
for (k in _jobs)
stats.push(_jobs[k]);
for (k in _waitingJobs)
stats.push(_waitingJobs[k]);
for (k in _runningJobs)
stats.push(_runningJobs[k]);
stats = stats.concat(_doneJobs);
}
if (typeof v1 === 'string')
switch (v1) {
case 'waiting':
stats = __objectValues(_waitingJobs);
break;
case 'running':
stats = __objectValues(_runningJobs);
break;
case 'done':
stats = _doneJobs;
break;
default:
pattern = v1;
}
if (v1 instanceof RegExp)
pattern = v1;
if (!pattern && (typeof v2 === 'string' || v2 instanceof RegExp))
pattern = v2;
// Filter jobs if a pattern is given:
if (pattern) {
isPatternString = typeof pattern === 'string';
if (stats instanceof Array) {
a = stats;
} else if (typeof stats === 'object') {
a = [];
for (k in stats)
a = a.concat(stats[k]);
} else {
a = [];
for (k in _jobs)
a.push(_jobs[k]);
for (k in _waitingJobs)
a.push(_waitingJobs[k]);
for (k in _runningJobs)
a.push(_runningJobs[k]);
a = a.concat(_doneJobs);
}
stats = [];
for (i = 0, l = a.length; i < l; i++)
if (isPatternString ? a[i].id === pattern : a[i].id.match(pattern))
stats.push(a[i]);
}
return __clone(stats);
} | [
"function",
"_getStats",
"(",
"v1",
",",
"v2",
")",
"{",
"var",
"a",
",",
"k",
",",
"i",
",",
"l",
",",
"stats",
",",
"pattern",
",",
"isPatternString",
";",
"if",
"(",
"!",
"arguments",
".",
"length",
")",
"{",
"stats",
"=",
"[",
"]",
";",
"for",
"(",
"k",
"in",
"_jobs",
")",
"stats",
".",
"push",
"(",
"_jobs",
"[",
"k",
"]",
")",
";",
"for",
"(",
"k",
"in",
"_waitingJobs",
")",
"stats",
".",
"push",
"(",
"_waitingJobs",
"[",
"k",
"]",
")",
";",
"for",
"(",
"k",
"in",
"_runningJobs",
")",
"stats",
".",
"push",
"(",
"_runningJobs",
"[",
"k",
"]",
")",
";",
"stats",
"=",
"stats",
".",
"concat",
"(",
"_doneJobs",
")",
";",
"}",
"if",
"(",
"typeof",
"v1",
"===",
"'string'",
")",
"switch",
"(",
"v1",
")",
"{",
"case",
"'waiting'",
":",
"stats",
"=",
"__objectValues",
"(",
"_waitingJobs",
")",
";",
"break",
";",
"case",
"'running'",
":",
"stats",
"=",
"__objectValues",
"(",
"_runningJobs",
")",
";",
"break",
";",
"case",
"'done'",
":",
"stats",
"=",
"_doneJobs",
";",
"break",
";",
"default",
":",
"pattern",
"=",
"v1",
";",
"}",
"if",
"(",
"v1",
"instanceof",
"RegExp",
")",
"pattern",
"=",
"v1",
";",
"if",
"(",
"!",
"pattern",
"&&",
"(",
"typeof",
"v2",
"===",
"'string'",
"||",
"v2",
"instanceof",
"RegExp",
")",
")",
"pattern",
"=",
"v2",
";",
"// Filter jobs if a pattern is given:",
"if",
"(",
"pattern",
")",
"{",
"isPatternString",
"=",
"typeof",
"pattern",
"===",
"'string'",
";",
"if",
"(",
"stats",
"instanceof",
"Array",
")",
"{",
"a",
"=",
"stats",
";",
"}",
"else",
"if",
"(",
"typeof",
"stats",
"===",
"'object'",
")",
"{",
"a",
"=",
"[",
"]",
";",
"for",
"(",
"k",
"in",
"stats",
")",
"a",
"=",
"a",
".",
"concat",
"(",
"stats",
"[",
"k",
"]",
")",
";",
"}",
"else",
"{",
"a",
"=",
"[",
"]",
";",
"for",
"(",
"k",
"in",
"_jobs",
")",
"a",
".",
"push",
"(",
"_jobs",
"[",
"k",
"]",
")",
";",
"for",
"(",
"k",
"in",
"_waitingJobs",
")",
"a",
".",
"push",
"(",
"_waitingJobs",
"[",
"k",
"]",
")",
";",
"for",
"(",
"k",
"in",
"_runningJobs",
")",
"a",
".",
"push",
"(",
"_runningJobs",
"[",
"k",
"]",
")",
";",
"a",
"=",
"a",
".",
"concat",
"(",
"_doneJobs",
")",
";",
"}",
"stats",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"if",
"(",
"isPatternString",
"?",
"a",
"[",
"i",
"]",
".",
"id",
"===",
"pattern",
":",
"a",
"[",
"i",
"]",
".",
"id",
".",
"match",
"(",
"pattern",
")",
")",
"stats",
".",
"push",
"(",
"a",
"[",
"i",
"]",
")",
";",
"}",
"return",
"__clone",
"(",
"stats",
")",
";",
"}"
] | Returns a snapshot of every data about jobs that wait to be started, are
currently running or are done.
It is possible to get only running, waiting or done jobs by giving
"running", "waiting" or "done" as fist argument.
It is also possible to get every job with a specified id by giving it as
first argument. Also, using a RegExp instead of an id will return every
jobs whose ids match the RegExp. And these two last use cases work as well
by giving before "running", "waiting" or "done".
@return {Array} The array of the matching jobs.
Some call examples:
*******************
> conrad.getStats('running')
> conrad.getStats('waiting')
> conrad.getStats('done')
> conrad.getStats('myJob')
> conrad.getStats(/test/)
> conrad.getStats('running', 'myRunningJob')
> conrad.getStats('running', /test/) | [
"Returns",
"a",
"snapshot",
"of",
"every",
"data",
"about",
"jobs",
"that",
"wait",
"to",
"be",
"started",
"are",
"currently",
"running",
"or",
"are",
"done",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L764-L842 |
6,117 | jacomyal/sigma.js | src/conrad.js | __clone | function __clone(item) {
var result, i, k, l;
if (!item)
return item;
if (Array.isArray(item)) {
result = [];
for (i = 0, l = item.length; i < l; i++)
result.push(__clone(item[i]));
} else if (typeof item === 'object') {
result = {};
for (i in item)
result[i] = __clone(item[i]);
} else
result = item;
return result;
} | javascript | function __clone(item) {
var result, i, k, l;
if (!item)
return item;
if (Array.isArray(item)) {
result = [];
for (i = 0, l = item.length; i < l; i++)
result.push(__clone(item[i]));
} else if (typeof item === 'object') {
result = {};
for (i in item)
result[i] = __clone(item[i]);
} else
result = item;
return result;
} | [
"function",
"__clone",
"(",
"item",
")",
"{",
"var",
"result",
",",
"i",
",",
"k",
",",
"l",
";",
"if",
"(",
"!",
"item",
")",
"return",
"item",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"item",
")",
")",
"{",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
",",
"l",
"=",
"item",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"result",
".",
"push",
"(",
"__clone",
"(",
"item",
"[",
"i",
"]",
")",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"item",
"===",
"'object'",
")",
"{",
"result",
"=",
"{",
"}",
";",
"for",
"(",
"i",
"in",
"item",
")",
"result",
"[",
"i",
"]",
"=",
"__clone",
"(",
"item",
"[",
"i",
"]",
")",
";",
"}",
"else",
"result",
"=",
"item",
";",
"return",
"result",
";",
"}"
] | This function simply clones an object. This object must contain only
objects, arrays and immutable values. Since it is not public, it does not
deal with cyclic references, DOM elements and instantiated objects - so
use it carefully.
@param {Object} The object to clone.
@return {Object} The clone. | [
"This",
"function",
"simply",
"clones",
"an",
"object",
".",
"This",
"object",
"must",
"contain",
"only",
"objects",
"arrays",
"and",
"immutable",
"values",
".",
"Since",
"it",
"is",
"not",
"public",
"it",
"does",
"not",
"deal",
"with",
"cyclic",
"references",
"DOM",
"elements",
"and",
"instantiated",
"objects",
"-",
"so",
"use",
"it",
"carefully",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L902-L920 |
6,118 | jacomyal/sigma.js | src/conrad.js | __objectValues | function __objectValues(o) {
var k,
a = [];
for (k in o)
a.push(o[k]);
return a;
} | javascript | function __objectValues(o) {
var k,
a = [];
for (k in o)
a.push(o[k]);
return a;
} | [
"function",
"__objectValues",
"(",
"o",
")",
"{",
"var",
"k",
",",
"a",
"=",
"[",
"]",
";",
"for",
"(",
"k",
"in",
"o",
")",
"a",
".",
"push",
"(",
"o",
"[",
"k",
"]",
")",
";",
"return",
"a",
";",
"}"
] | Returns an array containing the values of an object.
@param {Object} The object.
@return {Array} The array of values. | [
"Returns",
"an",
"array",
"containing",
"the",
"values",
"of",
"an",
"object",
"."
] | c49589f2419ca98542fd21b82b926dea21bb9fef | https://github.com/jacomyal/sigma.js/blob/c49589f2419ca98542fd21b82b926dea21bb9fef/src/conrad.js#L928-L936 |
6,119 | typicode/hotel | src/cli/daemon.js | start | function start() {
const node = process.execPath
const daemonFile = path.join(__dirname, '../daemon')
const startupFile = startup.getFile('hotel')
startup.create('hotel', node, [daemonFile], common.logFile)
// Save startup file path in ~/.hotel
// Will be used later by uninstall script
mkdirp.sync(common.hotelDir)
fs.writeFileSync(common.startupFile, startupFile)
console.log(`Started http://localhost:${conf.port}`)
} | javascript | function start() {
const node = process.execPath
const daemonFile = path.join(__dirname, '../daemon')
const startupFile = startup.getFile('hotel')
startup.create('hotel', node, [daemonFile], common.logFile)
// Save startup file path in ~/.hotel
// Will be used later by uninstall script
mkdirp.sync(common.hotelDir)
fs.writeFileSync(common.startupFile, startupFile)
console.log(`Started http://localhost:${conf.port}`)
} | [
"function",
"start",
"(",
")",
"{",
"const",
"node",
"=",
"process",
".",
"execPath",
"const",
"daemonFile",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'../daemon'",
")",
"const",
"startupFile",
"=",
"startup",
".",
"getFile",
"(",
"'hotel'",
")",
"startup",
".",
"create",
"(",
"'hotel'",
",",
"node",
",",
"[",
"daemonFile",
"]",
",",
"common",
".",
"logFile",
")",
"// Save startup file path in ~/.hotel",
"// Will be used later by uninstall script",
"mkdirp",
".",
"sync",
"(",
"common",
".",
"hotelDir",
")",
"fs",
".",
"writeFileSync",
"(",
"common",
".",
"startupFile",
",",
"startupFile",
")",
"console",
".",
"log",
"(",
"`",
"${",
"conf",
".",
"port",
"}",
"`",
")",
"}"
] | Start daemon in background | [
"Start",
"daemon",
"in",
"background"
] | cd4711ad46573f0cdeb59a839aa9f34b43172df5 | https://github.com/typicode/hotel/blob/cd4711ad46573f0cdeb59a839aa9f34b43172df5/src/cli/daemon.js#L15-L28 |
6,120 | marcj/css-element-queries | src/ElementQueries.js | queueQuery | function queueQuery(selector, mode, property, value) {
if (typeof(allQueries[selector]) === 'undefined') {
allQueries[selector] = [];
// add animation to trigger animationstart event, so we know exactly when a element appears in the DOM
var id = idToSelectorMapping.length;
cssStyleElement.innerHTML += '\n' + selector + ' {animation: 0.1s element-queries;}';
cssStyleElement.innerHTML += '\n' + selector + ' > .resize-sensor {min-width: '+id+'px;}';
idToSelectorMapping.push(selector);
}
allQueries[selector].push({
mode: mode,
property: property,
value: value
});
} | javascript | function queueQuery(selector, mode, property, value) {
if (typeof(allQueries[selector]) === 'undefined') {
allQueries[selector] = [];
// add animation to trigger animationstart event, so we know exactly when a element appears in the DOM
var id = idToSelectorMapping.length;
cssStyleElement.innerHTML += '\n' + selector + ' {animation: 0.1s element-queries;}';
cssStyleElement.innerHTML += '\n' + selector + ' > .resize-sensor {min-width: '+id+'px;}';
idToSelectorMapping.push(selector);
}
allQueries[selector].push({
mode: mode,
property: property,
value: value
});
} | [
"function",
"queueQuery",
"(",
"selector",
",",
"mode",
",",
"property",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"(",
"allQueries",
"[",
"selector",
"]",
")",
"===",
"'undefined'",
")",
"{",
"allQueries",
"[",
"selector",
"]",
"=",
"[",
"]",
";",
"// add animation to trigger animationstart event, so we know exactly when a element appears in the DOM",
"var",
"id",
"=",
"idToSelectorMapping",
".",
"length",
";",
"cssStyleElement",
".",
"innerHTML",
"+=",
"'\\n'",
"+",
"selector",
"+",
"' {animation: 0.1s element-queries;}'",
";",
"cssStyleElement",
".",
"innerHTML",
"+=",
"'\\n'",
"+",
"selector",
"+",
"' > .resize-sensor {min-width: '",
"+",
"id",
"+",
"'px;}'",
";",
"idToSelectorMapping",
".",
"push",
"(",
"selector",
")",
";",
"}",
"allQueries",
"[",
"selector",
"]",
".",
"push",
"(",
"{",
"mode",
":",
"mode",
",",
"property",
":",
"property",
",",
"value",
":",
"value",
"}",
")",
";",
"}"
] | Stores rules to the selector that should be applied once resized.
@param {String} selector
@param {String} mode min|max
@param {String} property width|height
@param {String} value | [
"Stores",
"rules",
"to",
"the",
"selector",
"that",
"should",
"be",
"applied",
"once",
"resized",
"."
] | 31cabb56fb2af08470159251f6e535e2c3577758 | https://github.com/marcj/css-element-queries/blob/31cabb56fb2af08470159251f6e535e2c3577758/src/ElementQueries.js#L190-L206 |
6,121 | marcj/css-element-queries | src/ElementQueries.js | findElementQueriesElements | function findElementQueriesElements(container) {
var query = getQuery(container);
for (var selector in allQueries) if (allQueries.hasOwnProperty(selector)) {
// find all elements based on the extract query selector from the element query rule
var elements = query(selector, container);
for (var i = 0, j = elements.length; i < j; i++) {
setupElement(elements[i], selector);
}
}
} | javascript | function findElementQueriesElements(container) {
var query = getQuery(container);
for (var selector in allQueries) if (allQueries.hasOwnProperty(selector)) {
// find all elements based on the extract query selector from the element query rule
var elements = query(selector, container);
for (var i = 0, j = elements.length; i < j; i++) {
setupElement(elements[i], selector);
}
}
} | [
"function",
"findElementQueriesElements",
"(",
"container",
")",
"{",
"var",
"query",
"=",
"getQuery",
"(",
"container",
")",
";",
"for",
"(",
"var",
"selector",
"in",
"allQueries",
")",
"if",
"(",
"allQueries",
".",
"hasOwnProperty",
"(",
"selector",
")",
")",
"{",
"// find all elements based on the extract query selector from the element query rule",
"var",
"elements",
"=",
"query",
"(",
"selector",
",",
"container",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"j",
"=",
"elements",
".",
"length",
";",
"i",
"<",
"j",
";",
"i",
"++",
")",
"{",
"setupElement",
"(",
"elements",
"[",
"i",
"]",
",",
"selector",
")",
";",
"}",
"}",
"}"
] | If animationStart didn't catch a new element in the DOM, we can manually search for it | [
"If",
"animationStart",
"didn",
"t",
"catch",
"a",
"new",
"element",
"in",
"the",
"DOM",
"we",
"can",
"manually",
"search",
"for",
"it"
] | 31cabb56fb2af08470159251f6e535e2c3577758 | https://github.com/marcj/css-element-queries/blob/31cabb56fb2af08470159251f6e535e2c3577758/src/ElementQueries.js#L224-L235 |
6,122 | TypeStrong/typedoc | scripts/rebuild_specs.js | getFiles | function getFiles(base, dir = '', results = []) {
const files = fs.readdirSync(path.join(base, dir));
for (const file of files) {
const relativeToBase = path.join(dir, file);
if (fs.statSync(path.join(base, relativeToBase)).isDirectory()) {
getFiles(base, relativeToBase, results);
} else {
results.push(relativeToBase);
}
}
return results;
} | javascript | function getFiles(base, dir = '', results = []) {
const files = fs.readdirSync(path.join(base, dir));
for (const file of files) {
const relativeToBase = path.join(dir, file);
if (fs.statSync(path.join(base, relativeToBase)).isDirectory()) {
getFiles(base, relativeToBase, results);
} else {
results.push(relativeToBase);
}
}
return results;
} | [
"function",
"getFiles",
"(",
"base",
",",
"dir",
"=",
"''",
",",
"results",
"=",
"[",
"]",
")",
"{",
"const",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"path",
".",
"join",
"(",
"base",
",",
"dir",
")",
")",
";",
"for",
"(",
"const",
"file",
"of",
"files",
")",
"{",
"const",
"relativeToBase",
"=",
"path",
".",
"join",
"(",
"dir",
",",
"file",
")",
";",
"if",
"(",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"base",
",",
"relativeToBase",
")",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"getFiles",
"(",
"base",
",",
"relativeToBase",
",",
"results",
")",
";",
"}",
"else",
"{",
"results",
".",
"push",
"(",
"relativeToBase",
")",
";",
"}",
"}",
"return",
"results",
";",
"}"
] | Rewrite GitHub urls
Avoiding sync methods here is... difficult.
@param {string} base
@param {string} dir
@param {string[]} results
@returns {string[]} | [
"Rewrite",
"GitHub",
"urls",
"Avoiding",
"sync",
"methods",
"here",
"is",
"...",
"difficult",
"."
] | 185ca2fdbf489325edb9880ca90668372232ce03 | https://github.com/TypeStrong/typedoc/blob/185ca2fdbf489325edb9880ca90668372232ce03/scripts/rebuild_specs.js#L66-L77 |
6,123 | hiloteam/Hilo | build/amd/hilo-amd.js | function(font){
var me = this;
if(me.font !== font){
me.font = font;
me._fontHeight = Text.measureFontHeight(font);
}
return me;
} | javascript | function(font){
var me = this;
if(me.font !== font){
me.font = font;
me._fontHeight = Text.measureFontHeight(font);
}
return me;
} | [
"function",
"(",
"font",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"me",
".",
"font",
"!==",
"font",
")",
"{",
"me",
".",
"font",
"=",
"font",
";",
"me",
".",
"_fontHeight",
"=",
"Text",
".",
"measureFontHeight",
"(",
"font",
")",
";",
"}",
"return",
"me",
";",
"}"
] | read-only
@language=en
Set text CSS font style.
@param {String} font Text CSS font style to set.
@returns {Text} the Text object, chained call supported. | [
"read",
"-",
"only"
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/amd/hilo-amd.js#L4577-L4585 |
|
6,124 | hiloteam/Hilo | build/amd/hilo-amd.js | rotateX | function rotateX(x, y, z, ca, sa) {//rotate x
return {
x: x,
y: y * ca - z * sa,
z: y * sa + z * ca
};
} | javascript | function rotateX(x, y, z, ca, sa) {//rotate x
return {
x: x,
y: y * ca - z * sa,
z: y * sa + z * ca
};
} | [
"function",
"rotateX",
"(",
"x",
",",
"y",
",",
"z",
",",
"ca",
",",
"sa",
")",
"{",
"//rotate x",
"return",
"{",
"x",
":",
"x",
",",
"y",
":",
"y",
"*",
"ca",
"-",
"z",
"*",
"sa",
",",
"z",
":",
"y",
"*",
"sa",
"+",
"z",
"*",
"ca",
"}",
";",
"}"
] | Rotate the axis. | [
"Rotate",
"the",
"axis",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/amd/hilo-amd.js#L7627-L7633 |
6,125 | hiloteam/Hilo | build/physics/physics.js | function(p1, p2, r1, r2)
{
var mindist = r1 + r2;
var delta = vsub(p2, p1);
var distsq = vlengthsq(delta);
if(distsq >= mindist*mindist) return;
var dist = Math.sqrt(distsq);
// Allocate and initialize the contact.
return new Contact(
vadd(p1, vmult(delta, 0.5 + (r1 - 0.5*mindist)/(dist ? dist : Infinity))),
(dist ? vmult(delta, 1/dist) : new Vect(1, 0)),
dist - mindist,
0
);
} | javascript | function(p1, p2, r1, r2)
{
var mindist = r1 + r2;
var delta = vsub(p2, p1);
var distsq = vlengthsq(delta);
if(distsq >= mindist*mindist) return;
var dist = Math.sqrt(distsq);
// Allocate and initialize the contact.
return new Contact(
vadd(p1, vmult(delta, 0.5 + (r1 - 0.5*mindist)/(dist ? dist : Infinity))),
(dist ? vmult(delta, 1/dist) : new Vect(1, 0)),
dist - mindist,
0
);
} | [
"function",
"(",
"p1",
",",
"p2",
",",
"r1",
",",
"r2",
")",
"{",
"var",
"mindist",
"=",
"r1",
"+",
"r2",
";",
"var",
"delta",
"=",
"vsub",
"(",
"p2",
",",
"p1",
")",
";",
"var",
"distsq",
"=",
"vlengthsq",
"(",
"delta",
")",
";",
"if",
"(",
"distsq",
">=",
"mindist",
"*",
"mindist",
")",
"return",
";",
"var",
"dist",
"=",
"Math",
".",
"sqrt",
"(",
"distsq",
")",
";",
"// Allocate and initialize the contact.",
"return",
"new",
"Contact",
"(",
"vadd",
"(",
"p1",
",",
"vmult",
"(",
"delta",
",",
"0.5",
"+",
"(",
"r1",
"-",
"0.5",
"*",
"mindist",
")",
"/",
"(",
"dist",
"?",
"dist",
":",
"Infinity",
")",
")",
")",
",",
"(",
"dist",
"?",
"vmult",
"(",
"delta",
",",
"1",
"/",
"dist",
")",
":",
"new",
"Vect",
"(",
"1",
",",
"0",
")",
")",
",",
"dist",
"-",
"mindist",
",",
"0",
")",
";",
"}"
] | Add contact points for circle to circle collisions. Used by several collision tests. | [
"Add",
"contact",
"points",
"for",
"circle",
"to",
"circle",
"collisions",
".",
"Used",
"by",
"several",
"collision",
"tests",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L3247-L3263 |
|
6,126 | hiloteam/Hilo | build/physics/physics.js | function(circ1, circ2)
{
var contact = circle2circleQuery(circ1.tc, circ2.tc, circ1.r, circ2.r);
return contact ? [contact] : NONE;
} | javascript | function(circ1, circ2)
{
var contact = circle2circleQuery(circ1.tc, circ2.tc, circ1.r, circ2.r);
return contact ? [contact] : NONE;
} | [
"function",
"(",
"circ1",
",",
"circ2",
")",
"{",
"var",
"contact",
"=",
"circle2circleQuery",
"(",
"circ1",
".",
"tc",
",",
"circ2",
".",
"tc",
",",
"circ1",
".",
"r",
",",
"circ2",
".",
"r",
")",
";",
"return",
"contact",
"?",
"[",
"contact",
"]",
":",
"NONE",
";",
"}"
] | Collide circle shapes. | [
"Collide",
"circle",
"shapes",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L3266-L3270 |
|
6,127 | hiloteam/Hilo | build/physics/physics.js | function(poly1, poly2, n, dist)
{
var arr = [];
var verts1 = poly1.tVerts;
for(var i=0; i<verts1.length; i+=2){
var vx = verts1[i];
var vy = verts1[i+1];
if(poly2.containsVert(vx, vy)){
arr.push(new Contact(new Vect(vx, vy), n, dist, hashPair(poly1.hashid, i>>1)));
}
}
var verts2 = poly2.tVerts;
for(var i=0; i<verts2.length; i+=2){
var vx = verts2[i];
var vy = verts2[i+1];
if(poly1.containsVert(vx, vy)){
arr.push(new Contact(new Vect(vx, vy), n, dist, hashPair(poly2.hashid, i>>1)));
}
}
return (arr.length ? arr : findVertsFallback(poly1, poly2, n, dist));
} | javascript | function(poly1, poly2, n, dist)
{
var arr = [];
var verts1 = poly1.tVerts;
for(var i=0; i<verts1.length; i+=2){
var vx = verts1[i];
var vy = verts1[i+1];
if(poly2.containsVert(vx, vy)){
arr.push(new Contact(new Vect(vx, vy), n, dist, hashPair(poly1.hashid, i>>1)));
}
}
var verts2 = poly2.tVerts;
for(var i=0; i<verts2.length; i+=2){
var vx = verts2[i];
var vy = verts2[i+1];
if(poly1.containsVert(vx, vy)){
arr.push(new Contact(new Vect(vx, vy), n, dist, hashPair(poly2.hashid, i>>1)));
}
}
return (arr.length ? arr : findVertsFallback(poly1, poly2, n, dist));
} | [
"function",
"(",
"poly1",
",",
"poly2",
",",
"n",
",",
"dist",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"var",
"verts1",
"=",
"poly1",
".",
"tVerts",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"verts1",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"var",
"vx",
"=",
"verts1",
"[",
"i",
"]",
";",
"var",
"vy",
"=",
"verts1",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"poly2",
".",
"containsVert",
"(",
"vx",
",",
"vy",
")",
")",
"{",
"arr",
".",
"push",
"(",
"new",
"Contact",
"(",
"new",
"Vect",
"(",
"vx",
",",
"vy",
")",
",",
"n",
",",
"dist",
",",
"hashPair",
"(",
"poly1",
".",
"hashid",
",",
"i",
">>",
"1",
")",
")",
")",
";",
"}",
"}",
"var",
"verts2",
"=",
"poly2",
".",
"tVerts",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"verts2",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"var",
"vx",
"=",
"verts2",
"[",
"i",
"]",
";",
"var",
"vy",
"=",
"verts2",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"poly1",
".",
"containsVert",
"(",
"vx",
",",
"vy",
")",
")",
"{",
"arr",
".",
"push",
"(",
"new",
"Contact",
"(",
"new",
"Vect",
"(",
"vx",
",",
"vy",
")",
",",
"n",
",",
"dist",
",",
"hashPair",
"(",
"poly2",
".",
"hashid",
",",
"i",
">>",
"1",
")",
")",
")",
";",
"}",
"}",
"return",
"(",
"arr",
".",
"length",
"?",
"arr",
":",
"findVertsFallback",
"(",
"poly1",
",",
"poly2",
",",
"n",
",",
"dist",
")",
")",
";",
"}"
] | Add contacts for penetrating vertexes. | [
"Add",
"contacts",
"for",
"penetrating",
"vertexes",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L3353-L3376 |
|
6,128 | hiloteam/Hilo | build/physics/physics.js | function(poly1, poly2)
{
var mini1 = findMSA(poly2, poly1.tPlanes);
if(mini1 == -1) return NONE;
var min1 = last_MSA_min;
var mini2 = findMSA(poly1, poly2.tPlanes);
if(mini2 == -1) return NONE;
var min2 = last_MSA_min;
// There is overlap, find the penetrating verts
if(min1 > min2)
return findVerts(poly1, poly2, poly1.tPlanes[mini1].n, min1);
else
return findVerts(poly1, poly2, vneg(poly2.tPlanes[mini2].n), min2);
} | javascript | function(poly1, poly2)
{
var mini1 = findMSA(poly2, poly1.tPlanes);
if(mini1 == -1) return NONE;
var min1 = last_MSA_min;
var mini2 = findMSA(poly1, poly2.tPlanes);
if(mini2 == -1) return NONE;
var min2 = last_MSA_min;
// There is overlap, find the penetrating verts
if(min1 > min2)
return findVerts(poly1, poly2, poly1.tPlanes[mini1].n, min1);
else
return findVerts(poly1, poly2, vneg(poly2.tPlanes[mini2].n), min2);
} | [
"function",
"(",
"poly1",
",",
"poly2",
")",
"{",
"var",
"mini1",
"=",
"findMSA",
"(",
"poly2",
",",
"poly1",
".",
"tPlanes",
")",
";",
"if",
"(",
"mini1",
"==",
"-",
"1",
")",
"return",
"NONE",
";",
"var",
"min1",
"=",
"last_MSA_min",
";",
"var",
"mini2",
"=",
"findMSA",
"(",
"poly1",
",",
"poly2",
".",
"tPlanes",
")",
";",
"if",
"(",
"mini2",
"==",
"-",
"1",
")",
"return",
"NONE",
";",
"var",
"min2",
"=",
"last_MSA_min",
";",
"// There is overlap, find the penetrating verts",
"if",
"(",
"min1",
">",
"min2",
")",
"return",
"findVerts",
"(",
"poly1",
",",
"poly2",
",",
"poly1",
".",
"tPlanes",
"[",
"mini1",
"]",
".",
"n",
",",
"min1",
")",
";",
"else",
"return",
"findVerts",
"(",
"poly1",
",",
"poly2",
",",
"vneg",
"(",
"poly2",
".",
"tPlanes",
"[",
"mini2",
"]",
".",
"n",
")",
",",
"min2",
")",
";",
"}"
] | Collide poly shapes together. | [
"Collide",
"poly",
"shapes",
"together",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L3379-L3394 |
|
6,129 | hiloteam/Hilo | build/physics/physics.js | function(arr, seg, poly, pDist, coef)
{
var dta = vcross(seg.tn, seg.ta);
var dtb = vcross(seg.tn, seg.tb);
var n = vmult(seg.tn, coef);
var verts = poly.tVerts;
for(var i=0; i<verts.length; i+=2){
var vx = verts[i];
var vy = verts[i+1];
if(vdot2(vx, vy, n.x, n.y) < vdot(seg.tn, seg.ta)*coef + seg.r){
var dt = vcross2(seg.tn.x, seg.tn.y, vx, vy);
if(dta >= dt && dt >= dtb){
arr.push(new Contact(new Vect(vx, vy), n, pDist, hashPair(poly.hashid, i)));
}
}
}
} | javascript | function(arr, seg, poly, pDist, coef)
{
var dta = vcross(seg.tn, seg.ta);
var dtb = vcross(seg.tn, seg.tb);
var n = vmult(seg.tn, coef);
var verts = poly.tVerts;
for(var i=0; i<verts.length; i+=2){
var vx = verts[i];
var vy = verts[i+1];
if(vdot2(vx, vy, n.x, n.y) < vdot(seg.tn, seg.ta)*coef + seg.r){
var dt = vcross2(seg.tn.x, seg.tn.y, vx, vy);
if(dta >= dt && dt >= dtb){
arr.push(new Contact(new Vect(vx, vy), n, pDist, hashPair(poly.hashid, i)));
}
}
}
} | [
"function",
"(",
"arr",
",",
"seg",
",",
"poly",
",",
"pDist",
",",
"coef",
")",
"{",
"var",
"dta",
"=",
"vcross",
"(",
"seg",
".",
"tn",
",",
"seg",
".",
"ta",
")",
";",
"var",
"dtb",
"=",
"vcross",
"(",
"seg",
".",
"tn",
",",
"seg",
".",
"tb",
")",
";",
"var",
"n",
"=",
"vmult",
"(",
"seg",
".",
"tn",
",",
"coef",
")",
";",
"var",
"verts",
"=",
"poly",
".",
"tVerts",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"verts",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"var",
"vx",
"=",
"verts",
"[",
"i",
"]",
";",
"var",
"vy",
"=",
"verts",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"vdot2",
"(",
"vx",
",",
"vy",
",",
"n",
".",
"x",
",",
"n",
".",
"y",
")",
"<",
"vdot",
"(",
"seg",
".",
"tn",
",",
"seg",
".",
"ta",
")",
"*",
"coef",
"+",
"seg",
".",
"r",
")",
"{",
"var",
"dt",
"=",
"vcross2",
"(",
"seg",
".",
"tn",
".",
"x",
",",
"seg",
".",
"tn",
".",
"y",
",",
"vx",
",",
"vy",
")",
";",
"if",
"(",
"dta",
">=",
"dt",
"&&",
"dt",
">=",
"dtb",
")",
"{",
"arr",
".",
"push",
"(",
"new",
"Contact",
"(",
"new",
"Vect",
"(",
"vx",
",",
"vy",
")",
",",
"n",
",",
"pDist",
",",
"hashPair",
"(",
"poly",
".",
"hashid",
",",
"i",
")",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Identify vertexes that have penetrated the segment. | [
"Identify",
"vertexes",
"that",
"have",
"penetrated",
"the",
"segment",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L3405-L3422 |
|
6,130 | hiloteam/Hilo | build/physics/physics.js | function(a, b, r1, r2, k1, k2)
{
// calculate mass matrix
// If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross...
var k11, k12, k21, k22;
var m_sum = a.m_inv + b.m_inv;
// start with I*m_sum
k11 = m_sum; k12 = 0;
k21 = 0; k22 = m_sum;
// add the influence from r1
var a_i_inv = a.i_inv;
var r1xsq = r1.x * r1.x * a_i_inv;
var r1ysq = r1.y * r1.y * a_i_inv;
var r1nxy = -r1.x * r1.y * a_i_inv;
k11 += r1ysq; k12 += r1nxy;
k21 += r1nxy; k22 += r1xsq;
// add the influnce from r2
var b_i_inv = b.i_inv;
var r2xsq = r2.x * r2.x * b_i_inv;
var r2ysq = r2.y * r2.y * b_i_inv;
var r2nxy = -r2.x * r2.y * b_i_inv;
k11 += r2ysq; k12 += r2nxy;
k21 += r2nxy; k22 += r2xsq;
// invert
var determinant = k11*k22 - k12*k21;
assertSoft(determinant !== 0, "Unsolvable constraint.");
var det_inv = 1/determinant;
k1.x = k22*det_inv; k1.y = -k12*det_inv;
k2.x = -k21*det_inv; k2.y = k11*det_inv;
} | javascript | function(a, b, r1, r2, k1, k2)
{
// calculate mass matrix
// If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross...
var k11, k12, k21, k22;
var m_sum = a.m_inv + b.m_inv;
// start with I*m_sum
k11 = m_sum; k12 = 0;
k21 = 0; k22 = m_sum;
// add the influence from r1
var a_i_inv = a.i_inv;
var r1xsq = r1.x * r1.x * a_i_inv;
var r1ysq = r1.y * r1.y * a_i_inv;
var r1nxy = -r1.x * r1.y * a_i_inv;
k11 += r1ysq; k12 += r1nxy;
k21 += r1nxy; k22 += r1xsq;
// add the influnce from r2
var b_i_inv = b.i_inv;
var r2xsq = r2.x * r2.x * b_i_inv;
var r2ysq = r2.y * r2.y * b_i_inv;
var r2nxy = -r2.x * r2.y * b_i_inv;
k11 += r2ysq; k12 += r2nxy;
k21 += r2nxy; k22 += r2xsq;
// invert
var determinant = k11*k22 - k12*k21;
assertSoft(determinant !== 0, "Unsolvable constraint.");
var det_inv = 1/determinant;
k1.x = k22*det_inv; k1.y = -k12*det_inv;
k2.x = -k21*det_inv; k2.y = k11*det_inv;
} | [
"function",
"(",
"a",
",",
"b",
",",
"r1",
",",
"r2",
",",
"k1",
",",
"k2",
")",
"{",
"// calculate mass matrix",
"// If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross...",
"var",
"k11",
",",
"k12",
",",
"k21",
",",
"k22",
";",
"var",
"m_sum",
"=",
"a",
".",
"m_inv",
"+",
"b",
".",
"m_inv",
";",
"// start with I*m_sum",
"k11",
"=",
"m_sum",
";",
"k12",
"=",
"0",
";",
"k21",
"=",
"0",
";",
"k22",
"=",
"m_sum",
";",
"// add the influence from r1",
"var",
"a_i_inv",
"=",
"a",
".",
"i_inv",
";",
"var",
"r1xsq",
"=",
"r1",
".",
"x",
"*",
"r1",
".",
"x",
"*",
"a_i_inv",
";",
"var",
"r1ysq",
"=",
"r1",
".",
"y",
"*",
"r1",
".",
"y",
"*",
"a_i_inv",
";",
"var",
"r1nxy",
"=",
"-",
"r1",
".",
"x",
"*",
"r1",
".",
"y",
"*",
"a_i_inv",
";",
"k11",
"+=",
"r1ysq",
";",
"k12",
"+=",
"r1nxy",
";",
"k21",
"+=",
"r1nxy",
";",
"k22",
"+=",
"r1xsq",
";",
"// add the influnce from r2",
"var",
"b_i_inv",
"=",
"b",
".",
"i_inv",
";",
"var",
"r2xsq",
"=",
"r2",
".",
"x",
"*",
"r2",
".",
"x",
"*",
"b_i_inv",
";",
"var",
"r2ysq",
"=",
"r2",
".",
"y",
"*",
"r2",
".",
"y",
"*",
"b_i_inv",
";",
"var",
"r2nxy",
"=",
"-",
"r2",
".",
"x",
"*",
"r2",
".",
"y",
"*",
"b_i_inv",
";",
"k11",
"+=",
"r2ysq",
";",
"k12",
"+=",
"r2nxy",
";",
"k21",
"+=",
"r2nxy",
";",
"k22",
"+=",
"r2xsq",
";",
"// invert",
"var",
"determinant",
"=",
"k11",
"*",
"k22",
"-",
"k12",
"*",
"k21",
";",
"assertSoft",
"(",
"determinant",
"!==",
"0",
",",
"\"Unsolvable constraint.\"",
")",
";",
"var",
"det_inv",
"=",
"1",
"/",
"determinant",
";",
"k1",
".",
"x",
"=",
"k22",
"*",
"det_inv",
";",
"k1",
".",
"y",
"=",
"-",
"k12",
"*",
"det_inv",
";",
"k2",
".",
"x",
"=",
"-",
"k21",
"*",
"det_inv",
";",
"k2",
".",
"y",
"=",
"k11",
"*",
"det_inv",
";",
"}"
] | k1 and k2 are modified by the function to contain the outputs. | [
"k1",
"and",
"k2",
"are",
"modified",
"by",
"the",
"function",
"to",
"contain",
"the",
"outputs",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/build/physics/physics.js#L5083-L5118 |
|
6,131 | hiloteam/Hilo | tools/jsdoc-toolkit-2.4.0/app/frame/Opt.js | function(args, optNames) {
var opt = {"_": []}; // the unnamed option allows multiple values
for (var i = 0; i < args.length; i++) {
var arg = new String(args[i]);
var name;
var value;
if (arg.charAt(0) == "-") {
if (arg.charAt(1) == "-") { // it's a longname like --foo
arg = arg.substring(2);
var m = arg.split("=");
name = m.shift();
value = m.shift();
if (typeof value == "undefined") value = true;
for (var n in optNames) { // convert it to a shortname
if (name == optNames[n]) {
name = n;
}
}
}
else { // it's a shortname like -f
arg = arg.substring(1);
var m = arg.split("=");
name = m.shift();
value = m.shift();
if (typeof value == "undefined") value = true;
for (var n in optNames) { // find the matching key
if (name == n || name+'[]' == n) {
name = n;
break;
}
}
}
if (name.match(/(.+)\[\]$/)) { // it's an array type like n[]
name = RegExp.$1;
if (!opt[name]) opt[name] = [];
}
if (opt[name] && opt[name].push) {
opt[name].push(value);
}
else {
opt[name] = value;
}
}
else { // not associated with any optname
opt._.push(args[i]);
}
}
return opt;
} | javascript | function(args, optNames) {
var opt = {"_": []}; // the unnamed option allows multiple values
for (var i = 0; i < args.length; i++) {
var arg = new String(args[i]);
var name;
var value;
if (arg.charAt(0) == "-") {
if (arg.charAt(1) == "-") { // it's a longname like --foo
arg = arg.substring(2);
var m = arg.split("=");
name = m.shift();
value = m.shift();
if (typeof value == "undefined") value = true;
for (var n in optNames) { // convert it to a shortname
if (name == optNames[n]) {
name = n;
}
}
}
else { // it's a shortname like -f
arg = arg.substring(1);
var m = arg.split("=");
name = m.shift();
value = m.shift();
if (typeof value == "undefined") value = true;
for (var n in optNames) { // find the matching key
if (name == n || name+'[]' == n) {
name = n;
break;
}
}
}
if (name.match(/(.+)\[\]$/)) { // it's an array type like n[]
name = RegExp.$1;
if (!opt[name]) opt[name] = [];
}
if (opt[name] && opt[name].push) {
opt[name].push(value);
}
else {
opt[name] = value;
}
}
else { // not associated with any optname
opt._.push(args[i]);
}
}
return opt;
} | [
"function",
"(",
"args",
",",
"optNames",
")",
"{",
"var",
"opt",
"=",
"{",
"\"_\"",
":",
"[",
"]",
"}",
";",
"// the unnamed option allows multiple values",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"arg",
"=",
"new",
"String",
"(",
"args",
"[",
"i",
"]",
")",
";",
"var",
"name",
";",
"var",
"value",
";",
"if",
"(",
"arg",
".",
"charAt",
"(",
"0",
")",
"==",
"\"-\"",
")",
"{",
"if",
"(",
"arg",
".",
"charAt",
"(",
"1",
")",
"==",
"\"-\"",
")",
"{",
"// it's a longname like --foo",
"arg",
"=",
"arg",
".",
"substring",
"(",
"2",
")",
";",
"var",
"m",
"=",
"arg",
".",
"split",
"(",
"\"=\"",
")",
";",
"name",
"=",
"m",
".",
"shift",
"(",
")",
";",
"value",
"=",
"m",
".",
"shift",
"(",
")",
";",
"if",
"(",
"typeof",
"value",
"==",
"\"undefined\"",
")",
"value",
"=",
"true",
";",
"for",
"(",
"var",
"n",
"in",
"optNames",
")",
"{",
"// convert it to a shortname",
"if",
"(",
"name",
"==",
"optNames",
"[",
"n",
"]",
")",
"{",
"name",
"=",
"n",
";",
"}",
"}",
"}",
"else",
"{",
"// it's a shortname like -f",
"arg",
"=",
"arg",
".",
"substring",
"(",
"1",
")",
";",
"var",
"m",
"=",
"arg",
".",
"split",
"(",
"\"=\"",
")",
";",
"name",
"=",
"m",
".",
"shift",
"(",
")",
";",
"value",
"=",
"m",
".",
"shift",
"(",
")",
";",
"if",
"(",
"typeof",
"value",
"==",
"\"undefined\"",
")",
"value",
"=",
"true",
";",
"for",
"(",
"var",
"n",
"in",
"optNames",
")",
"{",
"// find the matching key",
"if",
"(",
"name",
"==",
"n",
"||",
"name",
"+",
"'[]'",
"==",
"n",
")",
"{",
"name",
"=",
"n",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"name",
".",
"match",
"(",
"/",
"(.+)\\[\\]$",
"/",
")",
")",
"{",
"// it's an array type like n[]",
"name",
"=",
"RegExp",
".",
"$1",
";",
"if",
"(",
"!",
"opt",
"[",
"name",
"]",
")",
"opt",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"opt",
"[",
"name",
"]",
"&&",
"opt",
"[",
"name",
"]",
".",
"push",
")",
"{",
"opt",
"[",
"name",
"]",
".",
"push",
"(",
"value",
")",
";",
"}",
"else",
"{",
"opt",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"}",
"else",
"{",
"// not associated with any optname",
"opt",
".",
"_",
".",
"push",
"(",
"args",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"opt",
";",
"}"
] | Get commandline option values.
@param {Array} args Commandline arguments. Like ["-a=xml", "-b", "--class=new", "--debug"]
@param {object} optNames Map short names to long names. Like {a:"accept", b:"backtrace", c:"class", d:"debug"}.
@return {object} Short names and values. Like {a:"xml", b:true, c:"new", d:true} | [
"Get",
"commandline",
"option",
"values",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/tools/jsdoc-toolkit-2.4.0/app/frame/Opt.js#L9-L60 |
|
6,132 | hiloteam/Hilo | tools/jsdoc-toolkit-2.4.0/app/run.js | function(/**Array*/ path) {
if (path.constructor != Array) path = path.split(/[\\\/]/);
var make = "";
for (var i = 0, l = path.length; i < l; i++) {
make += path[i] + SYS.slash;
if (! IO.exists(make)) {
IO.makeDir(make);
}
}
} | javascript | function(/**Array*/ path) {
if (path.constructor != Array) path = path.split(/[\\\/]/);
var make = "";
for (var i = 0, l = path.length; i < l; i++) {
make += path[i] + SYS.slash;
if (! IO.exists(make)) {
IO.makeDir(make);
}
}
} | [
"function",
"(",
"/**Array*/",
"path",
")",
"{",
"if",
"(",
"path",
".",
"constructor",
"!=",
"Array",
")",
"path",
"=",
"path",
".",
"split",
"(",
"/",
"[\\\\\\/]",
"/",
")",
";",
"var",
"make",
"=",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"path",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"make",
"+=",
"path",
"[",
"i",
"]",
"+",
"SYS",
".",
"slash",
";",
"if",
"(",
"!",
"IO",
".",
"exists",
"(",
"make",
")",
")",
"{",
"IO",
".",
"makeDir",
"(",
"make",
")",
";",
"}",
"}",
"}"
] | Creates a series of nested directories. | [
"Creates",
"a",
"series",
"of",
"nested",
"directories",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/tools/jsdoc-toolkit-2.4.0/app/run.js#L220-L229 |
|
6,133 | hiloteam/Hilo | tools/jsdoc-toolkit-2.4.0/app/run.js | function(path) {
if (!path) return;
for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++)
if (/\.js$/i.test(lib[i])) load(lib[i]);
} | javascript | function(path) {
if (!path) return;
for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++)
if (/\.js$/i.test(lib[i])) load(lib[i]);
} | [
"function",
"(",
"path",
")",
"{",
"if",
"(",
"!",
"path",
")",
"return",
";",
"for",
"(",
"var",
"lib",
"=",
"IO",
".",
"ls",
"(",
"SYS",
".",
"pwd",
"+",
"path",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"lib",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"/",
"\\.js$",
"/",
"i",
".",
"test",
"(",
"lib",
"[",
"i",
"]",
")",
")",
"load",
"(",
"lib",
"[",
"i",
"]",
")",
";",
"}"
] | Loads all scripts from the given directory path. | [
"Loads",
"all",
"scripts",
"from",
"the",
"given",
"directory",
"path",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/tools/jsdoc-toolkit-2.4.0/app/run.js#L336-L341 |
|
6,134 | hiloteam/Hilo | tools/jsdoc-toolkit-2.4.0/app/frame/Link.js | Link | function Link() {
this.alias = "";
this.src = "";
this.file = "";
this.text = "";
this.innerName = "";
this.classLink = false;
this.targetName = "";
this.target = function(targetName) {
if (defined(targetName)) this.targetName = targetName;
return this;
}
this.inner = function(inner) {
if (defined(inner)) this.innerName = inner;
return this;
}
this.withText = function(text) {
if (defined(text)) this.text = text;
return this;
}
this.toSrc = function(filename) {
if (defined(filename)) this.src = filename;
return this;
}
this.toSymbol = function(alias) {
if (defined(alias)) this.alias = new String(alias);
return this;
}
this.toClass = function(alias) {
this.classLink = true;
return this.toSymbol(alias);
}
this.toFile = function(file) {
if (defined(file)) this.file = file;
return this;
}
this.toString = function() {
var linkString;
var thisLink = this;
if (this.alias) {
linkString = this.alias.replace(/(^|[^a-z$0-9_#.:^-])([|a-z$0-9_#.:^-]+)($|[^a-z$0-9_#.:^-])/i,
function(match, prematch, symbolName, postmatch) {
var symbolNames = symbolName.split("|");
var links = [];
for (var i = 0, l = symbolNames.length; i < l; i++) {
thisLink.alias = symbolNames[i];
links.push(thisLink._makeSymbolLink(symbolNames[i]));
}
return prematch+links.join("|")+postmatch;
}
);
}
else if (this.src) {
linkString = thisLink._makeSrcLink(this.src);
}
else if (this.file) {
linkString = thisLink._makeFileLink(this.file);
}
return linkString;
}
} | javascript | function Link() {
this.alias = "";
this.src = "";
this.file = "";
this.text = "";
this.innerName = "";
this.classLink = false;
this.targetName = "";
this.target = function(targetName) {
if (defined(targetName)) this.targetName = targetName;
return this;
}
this.inner = function(inner) {
if (defined(inner)) this.innerName = inner;
return this;
}
this.withText = function(text) {
if (defined(text)) this.text = text;
return this;
}
this.toSrc = function(filename) {
if (defined(filename)) this.src = filename;
return this;
}
this.toSymbol = function(alias) {
if (defined(alias)) this.alias = new String(alias);
return this;
}
this.toClass = function(alias) {
this.classLink = true;
return this.toSymbol(alias);
}
this.toFile = function(file) {
if (defined(file)) this.file = file;
return this;
}
this.toString = function() {
var linkString;
var thisLink = this;
if (this.alias) {
linkString = this.alias.replace(/(^|[^a-z$0-9_#.:^-])([|a-z$0-9_#.:^-]+)($|[^a-z$0-9_#.:^-])/i,
function(match, prematch, symbolName, postmatch) {
var symbolNames = symbolName.split("|");
var links = [];
for (var i = 0, l = symbolNames.length; i < l; i++) {
thisLink.alias = symbolNames[i];
links.push(thisLink._makeSymbolLink(symbolNames[i]));
}
return prematch+links.join("|")+postmatch;
}
);
}
else if (this.src) {
linkString = thisLink._makeSrcLink(this.src);
}
else if (this.file) {
linkString = thisLink._makeFileLink(this.file);
}
return linkString;
}
} | [
"function",
"Link",
"(",
")",
"{",
"this",
".",
"alias",
"=",
"\"\"",
";",
"this",
".",
"src",
"=",
"\"\"",
";",
"this",
".",
"file",
"=",
"\"\"",
";",
"this",
".",
"text",
"=",
"\"\"",
";",
"this",
".",
"innerName",
"=",
"\"\"",
";",
"this",
".",
"classLink",
"=",
"false",
";",
"this",
".",
"targetName",
"=",
"\"\"",
";",
"this",
".",
"target",
"=",
"function",
"(",
"targetName",
")",
"{",
"if",
"(",
"defined",
"(",
"targetName",
")",
")",
"this",
".",
"targetName",
"=",
"targetName",
";",
"return",
"this",
";",
"}",
"this",
".",
"inner",
"=",
"function",
"(",
"inner",
")",
"{",
"if",
"(",
"defined",
"(",
"inner",
")",
")",
"this",
".",
"innerName",
"=",
"inner",
";",
"return",
"this",
";",
"}",
"this",
".",
"withText",
"=",
"function",
"(",
"text",
")",
"{",
"if",
"(",
"defined",
"(",
"text",
")",
")",
"this",
".",
"text",
"=",
"text",
";",
"return",
"this",
";",
"}",
"this",
".",
"toSrc",
"=",
"function",
"(",
"filename",
")",
"{",
"if",
"(",
"defined",
"(",
"filename",
")",
")",
"this",
".",
"src",
"=",
"filename",
";",
"return",
"this",
";",
"}",
"this",
".",
"toSymbol",
"=",
"function",
"(",
"alias",
")",
"{",
"if",
"(",
"defined",
"(",
"alias",
")",
")",
"this",
".",
"alias",
"=",
"new",
"String",
"(",
"alias",
")",
";",
"return",
"this",
";",
"}",
"this",
".",
"toClass",
"=",
"function",
"(",
"alias",
")",
"{",
"this",
".",
"classLink",
"=",
"true",
";",
"return",
"this",
".",
"toSymbol",
"(",
"alias",
")",
";",
"}",
"this",
".",
"toFile",
"=",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"defined",
"(",
"file",
")",
")",
"this",
".",
"file",
"=",
"file",
";",
"return",
"this",
";",
"}",
"this",
".",
"toString",
"=",
"function",
"(",
")",
"{",
"var",
"linkString",
";",
"var",
"thisLink",
"=",
"this",
";",
"if",
"(",
"this",
".",
"alias",
")",
"{",
"linkString",
"=",
"this",
".",
"alias",
".",
"replace",
"(",
"/",
"(^|[^a-z$0-9_#.:^-])([|a-z$0-9_#.:^-]+)($|[^a-z$0-9_#.:^-])",
"/",
"i",
",",
"function",
"(",
"match",
",",
"prematch",
",",
"symbolName",
",",
"postmatch",
")",
"{",
"var",
"symbolNames",
"=",
"symbolName",
".",
"split",
"(",
"\"|\"",
")",
";",
"var",
"links",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"symbolNames",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"thisLink",
".",
"alias",
"=",
"symbolNames",
"[",
"i",
"]",
";",
"links",
".",
"push",
"(",
"thisLink",
".",
"_makeSymbolLink",
"(",
"symbolNames",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"prematch",
"+",
"links",
".",
"join",
"(",
"\"|\"",
")",
"+",
"postmatch",
";",
"}",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"src",
")",
"{",
"linkString",
"=",
"thisLink",
".",
"_makeSrcLink",
"(",
"this",
".",
"src",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"file",
")",
"{",
"linkString",
"=",
"thisLink",
".",
"_makeFileLink",
"(",
"this",
".",
"file",
")",
";",
"}",
"return",
"linkString",
";",
"}",
"}"
] | Handle the creation of HTML links to documented symbols.
@constructor | [
"Handle",
"the",
"creation",
"of",
"HTML",
"links",
"to",
"documented",
"symbols",
"."
] | 491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea | https://github.com/hiloteam/Hilo/blob/491c8d6358b3dccbd1ca7b5562dc3a2777a7cfea/tools/jsdoc-toolkit-2.4.0/app/frame/Link.js#L4-L68 |
6,135 | react-native-community/react-native-svg | index.web.js | prepare | function prepare(props) {
const {
translate,
scale,
rotation,
skewX,
skewY,
originX,
originY,
fontFamily,
fontSize,
fontWeight,
fontStyle,
style,
...clean
} = props;
const transform = [];
if (originX != null || originY != null) {
transform.push(`translate(${originX || 0}, ${originY || 0})`);
}
if (translate != null) {
transform.push(`translate(${translate})`);
}
if (scale != null) {
transform.push(`scale(${scale})`);
}
// rotation maps to rotate, not to collide with the text rotate attribute (which acts per glyph rather than block)
if (rotation != null) {
transform.push(`rotate(${rotation})`);
}
if (skewX != null) {
transform.push(`skewX(${skewX})`);
}
if (skewY != null) {
transform.push(`skewY(${skewY})`);
}
if (originX != null || originY != null) {
transform.push(`translate(${-originX || 0}, ${-originY || 0})`);
}
if (transform.length) {
clean.transform = transform.join(' ');
}
const styles = {};
if (fontFamily != null) {
styles.fontFamily = fontFamily;
}
if (fontSize != null) {
styles.fontSize = fontSize;
}
if (fontWeight != null) {
styles.fontWeight = fontWeight;
}
if (fontStyle != null) {
styles.fontStyle = fontStyle;
}
clean.style = resolve(style, styles);
return clean;
} | javascript | function prepare(props) {
const {
translate,
scale,
rotation,
skewX,
skewY,
originX,
originY,
fontFamily,
fontSize,
fontWeight,
fontStyle,
style,
...clean
} = props;
const transform = [];
if (originX != null || originY != null) {
transform.push(`translate(${originX || 0}, ${originY || 0})`);
}
if (translate != null) {
transform.push(`translate(${translate})`);
}
if (scale != null) {
transform.push(`scale(${scale})`);
}
// rotation maps to rotate, not to collide with the text rotate attribute (which acts per glyph rather than block)
if (rotation != null) {
transform.push(`rotate(${rotation})`);
}
if (skewX != null) {
transform.push(`skewX(${skewX})`);
}
if (skewY != null) {
transform.push(`skewY(${skewY})`);
}
if (originX != null || originY != null) {
transform.push(`translate(${-originX || 0}, ${-originY || 0})`);
}
if (transform.length) {
clean.transform = transform.join(' ');
}
const styles = {};
if (fontFamily != null) {
styles.fontFamily = fontFamily;
}
if (fontSize != null) {
styles.fontSize = fontSize;
}
if (fontWeight != null) {
styles.fontWeight = fontWeight;
}
if (fontStyle != null) {
styles.fontStyle = fontStyle;
}
clean.style = resolve(style, styles);
return clean;
} | [
"function",
"prepare",
"(",
"props",
")",
"{",
"const",
"{",
"translate",
",",
"scale",
",",
"rotation",
",",
"skewX",
",",
"skewY",
",",
"originX",
",",
"originY",
",",
"fontFamily",
",",
"fontSize",
",",
"fontWeight",
",",
"fontStyle",
",",
"style",
",",
"...",
"clean",
"}",
"=",
"props",
";",
"const",
"transform",
"=",
"[",
"]",
";",
"if",
"(",
"originX",
"!=",
"null",
"||",
"originY",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"originX",
"||",
"0",
"}",
"${",
"originY",
"||",
"0",
"}",
"`",
")",
";",
"}",
"if",
"(",
"translate",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"translate",
"}",
"`",
")",
";",
"}",
"if",
"(",
"scale",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"scale",
"}",
"`",
")",
";",
"}",
"// rotation maps to rotate, not to collide with the text rotate attribute (which acts per glyph rather than block)",
"if",
"(",
"rotation",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"rotation",
"}",
"`",
")",
";",
"}",
"if",
"(",
"skewX",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"skewX",
"}",
"`",
")",
";",
"}",
"if",
"(",
"skewY",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"skewY",
"}",
"`",
")",
";",
"}",
"if",
"(",
"originX",
"!=",
"null",
"||",
"originY",
"!=",
"null",
")",
"{",
"transform",
".",
"push",
"(",
"`",
"${",
"-",
"originX",
"||",
"0",
"}",
"${",
"-",
"originY",
"||",
"0",
"}",
"`",
")",
";",
"}",
"if",
"(",
"transform",
".",
"length",
")",
"{",
"clean",
".",
"transform",
"=",
"transform",
".",
"join",
"(",
"' '",
")",
";",
"}",
"const",
"styles",
"=",
"{",
"}",
";",
"if",
"(",
"fontFamily",
"!=",
"null",
")",
"{",
"styles",
".",
"fontFamily",
"=",
"fontFamily",
";",
"}",
"if",
"(",
"fontSize",
"!=",
"null",
")",
"{",
"styles",
".",
"fontSize",
"=",
"fontSize",
";",
"}",
"if",
"(",
"fontWeight",
"!=",
"null",
")",
"{",
"styles",
".",
"fontWeight",
"=",
"fontWeight",
";",
"}",
"if",
"(",
"fontStyle",
"!=",
"null",
")",
"{",
"styles",
".",
"fontStyle",
"=",
"fontStyle",
";",
"}",
"clean",
".",
"style",
"=",
"resolve",
"(",
"style",
",",
"styles",
")",
";",
"return",
"clean",
";",
"}"
] | `react-native-svg` supports additional props that aren't defined in the spec.
This function replaces them in a spec conforming manner.
@param {Object} props Properties given to us.
@returns {Object} Cleaned object.
@private | [
"react",
"-",
"native",
"-",
"svg",
"supports",
"additional",
"props",
"that",
"aren",
"t",
"defined",
"in",
"the",
"spec",
".",
"This",
"function",
"replaces",
"them",
"in",
"a",
"spec",
"conforming",
"manner",
"."
] | 235ded3d09e1b0a05957d3ba8a42424916d34f38 | https://github.com/react-native-community/react-native-svg/blob/235ded3d09e1b0a05957d3ba8a42424916d34f38/index.web.js#L13-L77 |
6,136 | garris/BackstopJS | core/util/runPuppet.js | translateUrl | function translateUrl (url) {
const RE = new RegExp('^[./]');
if (RE.test(url)) {
const fileUrl = 'file://' + path.join(process.cwd(), url);
console.log('Relative filename detected -- translating to ' + fileUrl);
return fileUrl;
} else {
return url;
}
} | javascript | function translateUrl (url) {
const RE = new RegExp('^[./]');
if (RE.test(url)) {
const fileUrl = 'file://' + path.join(process.cwd(), url);
console.log('Relative filename detected -- translating to ' + fileUrl);
return fileUrl;
} else {
return url;
}
} | [
"function",
"translateUrl",
"(",
"url",
")",
"{",
"const",
"RE",
"=",
"new",
"RegExp",
"(",
"'^[./]'",
")",
";",
"if",
"(",
"RE",
".",
"test",
"(",
"url",
")",
")",
"{",
"const",
"fileUrl",
"=",
"'file://'",
"+",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"url",
")",
";",
"console",
".",
"log",
"(",
"'Relative filename detected -- translating to '",
"+",
"fileUrl",
")",
";",
"return",
"fileUrl",
";",
"}",
"else",
"{",
"return",
"url",
";",
"}",
"}"
] | handle relative file name | [
"handle",
"relative",
"file",
"name"
] | d0a5ade11c1d8732158e6218a6f8a288f0bfc4db | https://github.com/garris/BackstopJS/blob/d0a5ade11c1d8732158e6218a6f8a288f0bfc4db/core/util/runPuppet.js#L397-L406 |
6,137 | prebid/Prebid.js | modules/consentManagement.js | processCmpData | function processCmpData(consentObject, hookConfig) {
let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies;
if (
(typeof gdprApplies !== 'boolean') ||
(gdprApplies === true &&
!(utils.isStr(consentObject.getConsentData.consentData) &&
utils.isPlainObject(consentObject.getVendorConsents) &&
Object.keys(consentObject.getVendorConsents).length > 1
)
)
) {
cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject);
} else {
clearTimeout(hookConfig.timer);
storeConsentData(consentObject);
exitModule(null, hookConfig);
}
} | javascript | function processCmpData(consentObject, hookConfig) {
let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies;
if (
(typeof gdprApplies !== 'boolean') ||
(gdprApplies === true &&
!(utils.isStr(consentObject.getConsentData.consentData) &&
utils.isPlainObject(consentObject.getVendorConsents) &&
Object.keys(consentObject.getVendorConsents).length > 1
)
)
) {
cmpFailed(`CMP returned unexpected value during lookup process.`, hookConfig, consentObject);
} else {
clearTimeout(hookConfig.timer);
storeConsentData(consentObject);
exitModule(null, hookConfig);
}
} | [
"function",
"processCmpData",
"(",
"consentObject",
",",
"hookConfig",
")",
"{",
"let",
"gdprApplies",
"=",
"consentObject",
"&&",
"consentObject",
".",
"getConsentData",
"&&",
"consentObject",
".",
"getConsentData",
".",
"gdprApplies",
";",
"if",
"(",
"(",
"typeof",
"gdprApplies",
"!==",
"'boolean'",
")",
"||",
"(",
"gdprApplies",
"===",
"true",
"&&",
"!",
"(",
"utils",
".",
"isStr",
"(",
"consentObject",
".",
"getConsentData",
".",
"consentData",
")",
"&&",
"utils",
".",
"isPlainObject",
"(",
"consentObject",
".",
"getVendorConsents",
")",
"&&",
"Object",
".",
"keys",
"(",
"consentObject",
".",
"getVendorConsents",
")",
".",
"length",
">",
"1",
")",
")",
")",
"{",
"cmpFailed",
"(",
"`",
"`",
",",
"hookConfig",
",",
"consentObject",
")",
";",
"}",
"else",
"{",
"clearTimeout",
"(",
"hookConfig",
".",
"timer",
")",
";",
"storeConsentData",
"(",
"consentObject",
")",
";",
"exitModule",
"(",
"null",
",",
"hookConfig",
")",
";",
"}",
"}"
] | This function checks the consent data provided by CMP to ensure it's in an expected state.
If it's bad, we exit the module depending on config settings.
If it's good, then we store the value and exits the module.
@param {object} consentObject required; object returned by CMP that contains user's consent choices
@param {object} hookConfig contains module related variables (see comment in requestBidsHook function) | [
"This",
"function",
"checks",
"the",
"consent",
"data",
"provided",
"by",
"CMP",
"to",
"ensure",
"it",
"s",
"in",
"an",
"expected",
"state",
".",
"If",
"it",
"s",
"bad",
"we",
"exit",
"the",
"module",
"depending",
"on",
"config",
"settings",
".",
"If",
"it",
"s",
"good",
"then",
"we",
"store",
"the",
"value",
"and",
"exits",
"the",
"module",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/consentManagement.js#L234-L252 |
6,138 | prebid/Prebid.js | modules/consentManagement.js | cmpFailed | function cmpFailed(errMsg, hookConfig, extraArgs) {
clearTimeout(hookConfig.timer);
// still set the consentData to undefined when there is a problem as per config options
if (allowAuction) {
storeConsentData(undefined);
}
exitModule(errMsg, hookConfig, extraArgs);
} | javascript | function cmpFailed(errMsg, hookConfig, extraArgs) {
clearTimeout(hookConfig.timer);
// still set the consentData to undefined when there is a problem as per config options
if (allowAuction) {
storeConsentData(undefined);
}
exitModule(errMsg, hookConfig, extraArgs);
} | [
"function",
"cmpFailed",
"(",
"errMsg",
",",
"hookConfig",
",",
"extraArgs",
")",
"{",
"clearTimeout",
"(",
"hookConfig",
".",
"timer",
")",
";",
"// still set the consentData to undefined when there is a problem as per config options",
"if",
"(",
"allowAuction",
")",
"{",
"storeConsentData",
"(",
"undefined",
")",
";",
"}",
"exitModule",
"(",
"errMsg",
",",
"hookConfig",
",",
"extraArgs",
")",
";",
"}"
] | This function contains the controlled steps to perform when there's a problem with CMP.
@param {string} errMsg required; should be a short descriptive message for why the failure/issue happened.
@param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
@param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging | [
"This",
"function",
"contains",
"the",
"controlled",
"steps",
"to",
"perform",
"when",
"there",
"s",
"a",
"problem",
"with",
"CMP",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/consentManagement.js#L267-L275 |
6,139 | prebid/Prebid.js | modules/consentManagement.js | exitModule | function exitModule(errMsg, hookConfig, extraArgs) {
if (hookConfig.haveExited === false) {
hookConfig.haveExited = true;
let context = hookConfig.context;
let args = hookConfig.args;
let nextFn = hookConfig.nextFn;
if (errMsg) {
if (allowAuction) {
utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
nextFn.apply(context, args);
} else {
utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
if (typeof hookConfig.bidsBackHandler === 'function') {
hookConfig.bidsBackHandler();
} else {
utils.logError('Error executing bidsBackHandler');
}
}
} else {
nextFn.apply(context, args);
}
}
} | javascript | function exitModule(errMsg, hookConfig, extraArgs) {
if (hookConfig.haveExited === false) {
hookConfig.haveExited = true;
let context = hookConfig.context;
let args = hookConfig.args;
let nextFn = hookConfig.nextFn;
if (errMsg) {
if (allowAuction) {
utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
nextFn.apply(context, args);
} else {
utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
if (typeof hookConfig.bidsBackHandler === 'function') {
hookConfig.bidsBackHandler();
} else {
utils.logError('Error executing bidsBackHandler');
}
}
} else {
nextFn.apply(context, args);
}
}
} | [
"function",
"exitModule",
"(",
"errMsg",
",",
"hookConfig",
",",
"extraArgs",
")",
"{",
"if",
"(",
"hookConfig",
".",
"haveExited",
"===",
"false",
")",
"{",
"hookConfig",
".",
"haveExited",
"=",
"true",
";",
"let",
"context",
"=",
"hookConfig",
".",
"context",
";",
"let",
"args",
"=",
"hookConfig",
".",
"args",
";",
"let",
"nextFn",
"=",
"hookConfig",
".",
"nextFn",
";",
"if",
"(",
"errMsg",
")",
"{",
"if",
"(",
"allowAuction",
")",
"{",
"utils",
".",
"logWarn",
"(",
"errMsg",
"+",
"' Resuming auction without consent data as per consentManagement config.'",
",",
"extraArgs",
")",
";",
"nextFn",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
"else",
"{",
"utils",
".",
"logError",
"(",
"errMsg",
"+",
"' Canceling auction as per consentManagement config.'",
",",
"extraArgs",
")",
";",
"if",
"(",
"typeof",
"hookConfig",
".",
"bidsBackHandler",
"===",
"'function'",
")",
"{",
"hookConfig",
".",
"bidsBackHandler",
"(",
")",
";",
"}",
"else",
"{",
"utils",
".",
"logError",
"(",
"'Error executing bidsBackHandler'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"nextFn",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
"}",
"}"
] | This function handles the exit logic for the module.
There are several paths in the module's logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others.
We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios.
One scenario could be auction was canceled due to timeout with CMP being reached.
While the timeout is the accepted exit and runs first, the CMP's callback still tries to process the user's data (which normally leads to a good exit).
In this case, the good exit will be suppressed since we already decided to cancel the auction.
Three exit paths are:
1. good exit where auction runs (CMP data is processed normally).
2. bad exit but auction still continues (warning message is logged, CMP data is undefined and still passed along).
3. bad exit with auction canceled (error message is logged).
@param {string} errMsg optional; only to be used when there was a 'bad' exit. String is a descriptive message for the failure/issue encountered.
@param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
@param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging | [
"This",
"function",
"handles",
"the",
"exit",
"logic",
"for",
"the",
"module",
".",
"There",
"are",
"several",
"paths",
"in",
"the",
"module",
"s",
"logic",
"to",
"call",
"this",
"function",
"and",
"we",
"only",
"allow",
"1",
"of",
"the",
"3",
"potential",
"exits",
"to",
"happen",
"before",
"suppressing",
"others",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/consentManagement.js#L307-L331 |
6,140 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | function (bidRequests, bidderRequest) {
return {
data: bidToTag(bidRequests, bidderRequest),
bidderRequest,
method: 'GET',
url: URL
};
} | javascript | function (bidRequests, bidderRequest) {
return {
data: bidToTag(bidRequests, bidderRequest),
bidderRequest,
method: 'GET',
url: URL
};
} | [
"function",
"(",
"bidRequests",
",",
"bidderRequest",
")",
"{",
"return",
"{",
"data",
":",
"bidToTag",
"(",
"bidRequests",
",",
"bidderRequest",
")",
",",
"bidderRequest",
",",
"method",
":",
"'GET'",
",",
"url",
":",
"URL",
"}",
";",
"}"
] | Make a server request from the list of BidRequests
@param bidRequests
@param bidderRequest | [
"Make",
"a",
"server",
"request",
"from",
"the",
"list",
"of",
"BidRequests"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L64-L71 |
|
6,141 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | function (serverResponse, {bidderRequest}) {
serverResponse = serverResponse.body;
let bids = [];
if (!utils.isArray(serverResponse)) {
return parseRTBResponse(serverResponse, bidderRequest);
}
serverResponse.forEach(serverBidResponse => {
bids = utils.flatten(bids, parseRTBResponse(serverBidResponse, bidderRequest));
});
return bids;
} | javascript | function (serverResponse, {bidderRequest}) {
serverResponse = serverResponse.body;
let bids = [];
if (!utils.isArray(serverResponse)) {
return parseRTBResponse(serverResponse, bidderRequest);
}
serverResponse.forEach(serverBidResponse => {
bids = utils.flatten(bids, parseRTBResponse(serverBidResponse, bidderRequest));
});
return bids;
} | [
"function",
"(",
"serverResponse",
",",
"{",
"bidderRequest",
"}",
")",
"{",
"serverResponse",
"=",
"serverResponse",
".",
"body",
";",
"let",
"bids",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"utils",
".",
"isArray",
"(",
"serverResponse",
")",
")",
"{",
"return",
"parseRTBResponse",
"(",
"serverResponse",
",",
"bidderRequest",
")",
";",
"}",
"serverResponse",
".",
"forEach",
"(",
"serverBidResponse",
"=>",
"{",
"bids",
"=",
"utils",
".",
"flatten",
"(",
"bids",
",",
"parseRTBResponse",
"(",
"serverBidResponse",
",",
"bidderRequest",
")",
")",
";",
"}",
")",
";",
"return",
"bids",
";",
"}"
] | Unpack the response from the server into a list of bids
@param serverResponse
@param bidderRequest
@return {Bid[]} An array of bids which were nested inside the server | [
"Unpack",
"the",
"response",
"from",
"the",
"server",
"into",
"a",
"list",
"of",
"bids"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L79-L92 |
|
6,142 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | getMediaType | function getMediaType(bidderRequest) {
const videoMediaType = utils.deepAccess(bidderRequest, 'mediaTypes.video');
const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context');
return !videoMediaType ? DISPLAY : context === OUTSTREAM ? OUTSTREAM : VIDEO;
} | javascript | function getMediaType(bidderRequest) {
const videoMediaType = utils.deepAccess(bidderRequest, 'mediaTypes.video');
const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context');
return !videoMediaType ? DISPLAY : context === OUTSTREAM ? OUTSTREAM : VIDEO;
} | [
"function",
"getMediaType",
"(",
"bidderRequest",
")",
"{",
"const",
"videoMediaType",
"=",
"utils",
".",
"deepAccess",
"(",
"bidderRequest",
",",
"'mediaTypes.video'",
")",
";",
"const",
"context",
"=",
"utils",
".",
"deepAccess",
"(",
"bidderRequest",
",",
"'mediaTypes.video.context'",
")",
";",
"return",
"!",
"videoMediaType",
"?",
"DISPLAY",
":",
"context",
"===",
"OUTSTREAM",
"?",
"OUTSTREAM",
":",
"VIDEO",
";",
"}"
] | Prepare all parameters for request
@param bidderRequest {object}
@returns {object} | [
"Prepare",
"all",
"parameters",
"for",
"request"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L164-L169 |
6,143 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | createBid | function createBid(bidResponse, mediaType) {
let bid = {
requestId: bidResponse.requestId,
creativeId: bidResponse.cmpId,
height: bidResponse.height,
currency: bidResponse.cur,
width: bidResponse.width,
cpm: bidResponse.cpm,
netRevenue: true,
mediaType,
ttl: 3600
};
if (mediaType === DISPLAY) {
return Object.assign(bid, {
ad: bidResponse.ad
});
}
Object.assign(bid, {
vastUrl: bidResponse.vastUrl
});
if (mediaType === OUTSTREAM) {
Object.assign(bid, {
mediaType: 'video',
adResponse: bidResponse,
renderer: newRenderer(bidResponse.requestId)
});
}
return bid;
} | javascript | function createBid(bidResponse, mediaType) {
let bid = {
requestId: bidResponse.requestId,
creativeId: bidResponse.cmpId,
height: bidResponse.height,
currency: bidResponse.cur,
width: bidResponse.width,
cpm: bidResponse.cpm,
netRevenue: true,
mediaType,
ttl: 3600
};
if (mediaType === DISPLAY) {
return Object.assign(bid, {
ad: bidResponse.ad
});
}
Object.assign(bid, {
vastUrl: bidResponse.vastUrl
});
if (mediaType === OUTSTREAM) {
Object.assign(bid, {
mediaType: 'video',
adResponse: bidResponse,
renderer: newRenderer(bidResponse.requestId)
});
}
return bid;
} | [
"function",
"createBid",
"(",
"bidResponse",
",",
"mediaType",
")",
"{",
"let",
"bid",
"=",
"{",
"requestId",
":",
"bidResponse",
".",
"requestId",
",",
"creativeId",
":",
"bidResponse",
".",
"cmpId",
",",
"height",
":",
"bidResponse",
".",
"height",
",",
"currency",
":",
"bidResponse",
".",
"cur",
",",
"width",
":",
"bidResponse",
".",
"width",
",",
"cpm",
":",
"bidResponse",
".",
"cpm",
",",
"netRevenue",
":",
"true",
",",
"mediaType",
",",
"ttl",
":",
"3600",
"}",
";",
"if",
"(",
"mediaType",
"===",
"DISPLAY",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"bid",
",",
"{",
"ad",
":",
"bidResponse",
".",
"ad",
"}",
")",
";",
"}",
"Object",
".",
"assign",
"(",
"bid",
",",
"{",
"vastUrl",
":",
"bidResponse",
".",
"vastUrl",
"}",
")",
";",
"if",
"(",
"mediaType",
"===",
"OUTSTREAM",
")",
"{",
"Object",
".",
"assign",
"(",
"bid",
",",
"{",
"mediaType",
":",
"'video'",
",",
"adResponse",
":",
"bidResponse",
",",
"renderer",
":",
"newRenderer",
"(",
"bidResponse",
".",
"requestId",
")",
"}",
")",
";",
"}",
"return",
"bid",
";",
"}"
] | Configure new bid by response
@param bidResponse {object}
@param mediaType {Object}
@returns {object} | [
"Configure",
"new",
"bid",
"by",
"response"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L177-L209 |
6,144 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | newRenderer | function newRenderer(requestId) {
const renderer = Renderer.install({
id: requestId,
url: OUTSTREAM_SRC,
loaded: false
});
renderer.setRender(outstreamRender);
return renderer;
} | javascript | function newRenderer(requestId) {
const renderer = Renderer.install({
id: requestId,
url: OUTSTREAM_SRC,
loaded: false
});
renderer.setRender(outstreamRender);
return renderer;
} | [
"function",
"newRenderer",
"(",
"requestId",
")",
"{",
"const",
"renderer",
"=",
"Renderer",
".",
"install",
"(",
"{",
"id",
":",
"requestId",
",",
"url",
":",
"OUTSTREAM_SRC",
",",
"loaded",
":",
"false",
"}",
")",
";",
"renderer",
".",
"setRender",
"(",
"outstreamRender",
")",
";",
"return",
"renderer",
";",
"}"
] | Create Adtelligent renderer
@param requestId
@returns {*} | [
"Create",
"Adtelligent",
"renderer"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L216-L226 |
6,145 | prebid/Prebid.js | modules/adtelligentBidAdapter.js | outstreamRender | function outstreamRender(bid) {
bid.renderer.push(() => {
window.VOutstreamAPI.initOutstreams([{
width: bid.width,
height: bid.height,
vastUrl: bid.vastUrl,
elId: bid.adUnitCode
}]);
});
} | javascript | function outstreamRender(bid) {
bid.renderer.push(() => {
window.VOutstreamAPI.initOutstreams([{
width: bid.width,
height: bid.height,
vastUrl: bid.vastUrl,
elId: bid.adUnitCode
}]);
});
} | [
"function",
"outstreamRender",
"(",
"bid",
")",
"{",
"bid",
".",
"renderer",
".",
"push",
"(",
"(",
")",
"=>",
"{",
"window",
".",
"VOutstreamAPI",
".",
"initOutstreams",
"(",
"[",
"{",
"width",
":",
"bid",
".",
"width",
",",
"height",
":",
"bid",
".",
"height",
",",
"vastUrl",
":",
"bid",
".",
"vastUrl",
",",
"elId",
":",
"bid",
".",
"adUnitCode",
"}",
"]",
")",
";",
"}",
")",
";",
"}"
] | Initialise Adtelligent outstream
@param bid | [
"Initialise",
"Adtelligent",
"outstream"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adtelligentBidAdapter.js#L232-L241 |
6,146 | prebid/Prebid.js | modules/lifestreetBidAdapter.js | formatBidRequest | function formatBidRequest(bid, bidderRequest) {
let url = urlTemplate({
adapter: 'prebid',
slot: bid.params.slot,
adkey: bid.params.adkey,
ad_size: bid.params.ad_size,
location: encodeURIComponent(utils.getTopWindowLocation()),
referrer: encodeURIComponent(utils.getTopWindowReferrer()),
wn: boolToString(/fb_http/i.test(window.name)),
sf: boolToString(window['sfAPI'] || window['$sf']),
fif: boolToString(window['inDapIF'] === true),
if: boolToString(window !== window.top),
stamp: new Date().getTime(),
hbver: ADAPTER_VERSION
});
if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies !== undefined) {
const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0');
url += gdpr;
}
if (bidderRequest.gdprConsent.consentString !== undefined) {
url += '&__consent=' + bidderRequest.gdprConsent.consentString;
}
}
return {
method: 'GET',
url: url,
bidId: bid.bidId
};
} | javascript | function formatBidRequest(bid, bidderRequest) {
let url = urlTemplate({
adapter: 'prebid',
slot: bid.params.slot,
adkey: bid.params.adkey,
ad_size: bid.params.ad_size,
location: encodeURIComponent(utils.getTopWindowLocation()),
referrer: encodeURIComponent(utils.getTopWindowReferrer()),
wn: boolToString(/fb_http/i.test(window.name)),
sf: boolToString(window['sfAPI'] || window['$sf']),
fif: boolToString(window['inDapIF'] === true),
if: boolToString(window !== window.top),
stamp: new Date().getTime(),
hbver: ADAPTER_VERSION
});
if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.gdprApplies !== undefined) {
const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0');
url += gdpr;
}
if (bidderRequest.gdprConsent.consentString !== undefined) {
url += '&__consent=' + bidderRequest.gdprConsent.consentString;
}
}
return {
method: 'GET',
url: url,
bidId: bid.bidId
};
} | [
"function",
"formatBidRequest",
"(",
"bid",
",",
"bidderRequest",
")",
"{",
"let",
"url",
"=",
"urlTemplate",
"(",
"{",
"adapter",
":",
"'prebid'",
",",
"slot",
":",
"bid",
".",
"params",
".",
"slot",
",",
"adkey",
":",
"bid",
".",
"params",
".",
"adkey",
",",
"ad_size",
":",
"bid",
".",
"params",
".",
"ad_size",
",",
"location",
":",
"encodeURIComponent",
"(",
"utils",
".",
"getTopWindowLocation",
"(",
")",
")",
",",
"referrer",
":",
"encodeURIComponent",
"(",
"utils",
".",
"getTopWindowReferrer",
"(",
")",
")",
",",
"wn",
":",
"boolToString",
"(",
"/",
"fb_http",
"/",
"i",
".",
"test",
"(",
"window",
".",
"name",
")",
")",
",",
"sf",
":",
"boolToString",
"(",
"window",
"[",
"'sfAPI'",
"]",
"||",
"window",
"[",
"'$sf'",
"]",
")",
",",
"fif",
":",
"boolToString",
"(",
"window",
"[",
"'inDapIF'",
"]",
"===",
"true",
")",
",",
"if",
":",
"boolToString",
"(",
"window",
"!==",
"window",
".",
"top",
")",
",",
"stamp",
":",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
",",
"hbver",
":",
"ADAPTER_VERSION",
"}",
")",
";",
"if",
"(",
"bidderRequest",
"&&",
"bidderRequest",
".",
"gdprConsent",
")",
"{",
"if",
"(",
"bidderRequest",
".",
"gdprConsent",
".",
"gdprApplies",
"!==",
"undefined",
")",
"{",
"const",
"gdpr",
"=",
"'&__gdpr='",
"+",
"(",
"bidderRequest",
".",
"gdprConsent",
".",
"gdprApplies",
"?",
"'1'",
":",
"'0'",
")",
";",
"url",
"+=",
"gdpr",
";",
"}",
"if",
"(",
"bidderRequest",
".",
"gdprConsent",
".",
"consentString",
"!==",
"undefined",
")",
"{",
"url",
"+=",
"'&__consent='",
"+",
"bidderRequest",
".",
"gdprConsent",
".",
"consentString",
";",
"}",
"}",
"return",
"{",
"method",
":",
"'GET'",
",",
"url",
":",
"url",
",",
"bidId",
":",
"bid",
".",
"bidId",
"}",
";",
"}"
] | Creates a bid requests for a given bid.
@param {BidRequest} bid The bid params to use for formatting a request | [
"Creates",
"a",
"bid",
"requests",
"for",
"a",
"given",
"bid",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/lifestreetBidAdapter.js#L15-L46 |
6,147 | prebid/Prebid.js | modules/lifestreetBidAdapter.js | template | function template(strings, ...keys) {
return function(...values) {
let dict = values[values.length - 1] || {};
let result = [strings[0]];
keys.forEach(function(key, i) {
let value = isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
return result.join('');
};
} | javascript | function template(strings, ...keys) {
return function(...values) {
let dict = values[values.length - 1] || {};
let result = [strings[0]];
keys.forEach(function(key, i) {
let value = isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
return result.join('');
};
} | [
"function",
"template",
"(",
"strings",
",",
"...",
"keys",
")",
"{",
"return",
"function",
"(",
"...",
"values",
")",
"{",
"let",
"dict",
"=",
"values",
"[",
"values",
".",
"length",
"-",
"1",
"]",
"||",
"{",
"}",
";",
"let",
"result",
"=",
"[",
"strings",
"[",
"0",
"]",
"]",
";",
"keys",
".",
"forEach",
"(",
"function",
"(",
"key",
",",
"i",
")",
"{",
"let",
"value",
"=",
"isInteger",
"(",
"key",
")",
"?",
"values",
"[",
"key",
"]",
":",
"dict",
"[",
"key",
"]",
";",
"result",
".",
"push",
"(",
"value",
",",
"strings",
"[",
"i",
"+",
"1",
"]",
")",
";",
"}",
")",
";",
"return",
"result",
".",
"join",
"(",
"''",
")",
";",
"}",
";",
"}"
] | A helper function to form URL from the template | [
"A",
"helper",
"function",
"to",
"form",
"URL",
"from",
"the",
"template"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/lifestreetBidAdapter.js#L51-L61 |
6,148 | prebid/Prebid.js | modules/lifestreetBidAdapter.js | isResponseValid | function isResponseValid(response) {
return !/^\s*\{\s*"advertisementAvailable"\s*:\s*false/i.test(response.content) &&
response.content.indexOf('<VAST version="2.0"></VAST>') === -1 && (typeof response.cpm !== 'undefined') &&
response.status === 1;
} | javascript | function isResponseValid(response) {
return !/^\s*\{\s*"advertisementAvailable"\s*:\s*false/i.test(response.content) &&
response.content.indexOf('<VAST version="2.0"></VAST>') === -1 && (typeof response.cpm !== 'undefined') &&
response.status === 1;
} | [
"function",
"isResponseValid",
"(",
"response",
")",
"{",
"return",
"!",
"/",
"^\\s*\\{\\s*\"advertisementAvailable\"\\s*:\\s*false",
"/",
"i",
".",
"test",
"(",
"response",
".",
"content",
")",
"&&",
"response",
".",
"content",
".",
"indexOf",
"(",
"'<VAST version=\"2.0\"></VAST>'",
")",
"===",
"-",
"1",
"&&",
"(",
"typeof",
"response",
".",
"cpm",
"!==",
"'undefined'",
")",
"&&",
"response",
".",
"status",
"===",
"1",
";",
"}"
] | Validates response from Lifestreet AD server | [
"Validates",
"response",
"from",
"Lifestreet",
"AD",
"server"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/lifestreetBidAdapter.js#L81-L85 |
6,149 | prebid/Prebid.js | modules/lifestreetBidAdapter.js | function(bid) {
return !!(bid.params.slot && bid.params.adkey && bid.params.ad_size);
} | javascript | function(bid) {
return !!(bid.params.slot && bid.params.adkey && bid.params.ad_size);
} | [
"function",
"(",
"bid",
")",
"{",
"return",
"!",
"!",
"(",
"bid",
".",
"params",
".",
"slot",
"&&",
"bid",
".",
"params",
".",
"adkey",
"&&",
"bid",
".",
"params",
".",
"ad_size",
")",
";",
"}"
] | Lifestreet supports banner and video media types
Determines whether or not the given bid request is valid.
@param {BidRequest} bid The bid params to validate.
@return boolean True if this is a valid bid, and false otherwise. | [
"Lifestreet",
"supports",
"banner",
"and",
"video",
"media",
"types",
"Determines",
"whether",
"or",
"not",
"the",
"given",
"bid",
"request",
"is",
"valid",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/lifestreetBidAdapter.js#L98-L100 |
|
6,150 | prebid/Prebid.js | modules/telariaBidAdapter.js | function (bid) {
return !!(bid && bid.params && bid.params.adCode && bid.params.supplyCode);
} | javascript | function (bid) {
return !!(bid && bid.params && bid.params.adCode && bid.params.supplyCode);
} | [
"function",
"(",
"bid",
")",
"{",
"return",
"!",
"!",
"(",
"bid",
"&&",
"bid",
".",
"params",
"&&",
"bid",
".",
"params",
".",
"adCode",
"&&",
"bid",
".",
"params",
".",
"supplyCode",
")",
";",
"}"
] | Determines if the request is valid
@param bid
@returns {*|string} | [
"Determines",
"if",
"the",
"request",
"is",
"valid"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/telariaBidAdapter.js#L19-L21 |
|
6,151 | prebid/Prebid.js | modules/telariaBidAdapter.js | function (syncOptions, serverResponses) {
const syncs = [];
if (syncOptions.pixelEnabled && serverResponses.length) {
try {
serverResponses[0].body.ext.telaria.userSync.forEach(url => syncs.push({type: 'image', url: url}));
} catch (e) {}
}
return syncs;
} | javascript | function (syncOptions, serverResponses) {
const syncs = [];
if (syncOptions.pixelEnabled && serverResponses.length) {
try {
serverResponses[0].body.ext.telaria.userSync.forEach(url => syncs.push({type: 'image', url: url}));
} catch (e) {}
}
return syncs;
} | [
"function",
"(",
"syncOptions",
",",
"serverResponses",
")",
"{",
"const",
"syncs",
"=",
"[",
"]",
";",
"if",
"(",
"syncOptions",
".",
"pixelEnabled",
"&&",
"serverResponses",
".",
"length",
")",
"{",
"try",
"{",
"serverResponses",
"[",
"0",
"]",
".",
"body",
".",
"ext",
".",
"telaria",
".",
"userSync",
".",
"forEach",
"(",
"url",
"=>",
"syncs",
".",
"push",
"(",
"{",
"type",
":",
"'image'",
",",
"url",
":",
"url",
"}",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"}",
"return",
"syncs",
";",
"}"
] | We support pixel syncing only at the moment. Telaria ad server returns 'ext'
as an optional parameter if the tag has 'incIdSync' parameter set to true
@param syncOptions
@param serverResponses
@returns {Array} | [
"We",
"support",
"pixel",
"syncing",
"only",
"at",
"the",
"moment",
".",
"Telaria",
"ad",
"server",
"returns",
"ext",
"as",
"an",
"optional",
"parameter",
"if",
"the",
"tag",
"has",
"incIdSync",
"parameter",
"set",
"to",
"true"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/telariaBidAdapter.js#L100-L108 |
|
6,152 | prebid/Prebid.js | modules/telariaBidAdapter.js | createBid | function createBid(status, reqBid, response, width, height, bidderCode) {
let bid = createBidFactory(status, reqBid);
// TTL 5 mins by default, future support for extended imp wait time
if (response) {
Object.assign(bid, {
requestId: reqBid.bidId,
cpm: response.price,
creativeId: response.crid || '-1',
vastXml: response.adm,
vastUrl: reqBid.vastUrl,
mediaType: 'video',
width: width,
height: height,
bidderCode: bidderCode,
adId: response.id,
currency: 'USD',
netRevenue: true,
ttl: 300,
ad: response.adm
});
}
return bid;
} | javascript | function createBid(status, reqBid, response, width, height, bidderCode) {
let bid = createBidFactory(status, reqBid);
// TTL 5 mins by default, future support for extended imp wait time
if (response) {
Object.assign(bid, {
requestId: reqBid.bidId,
cpm: response.price,
creativeId: response.crid || '-1',
vastXml: response.adm,
vastUrl: reqBid.vastUrl,
mediaType: 'video',
width: width,
height: height,
bidderCode: bidderCode,
adId: response.id,
currency: 'USD',
netRevenue: true,
ttl: 300,
ad: response.adm
});
}
return bid;
} | [
"function",
"createBid",
"(",
"status",
",",
"reqBid",
",",
"response",
",",
"width",
",",
"height",
",",
"bidderCode",
")",
"{",
"let",
"bid",
"=",
"createBidFactory",
"(",
"status",
",",
"reqBid",
")",
";",
"// TTL 5 mins by default, future support for extended imp wait time",
"if",
"(",
"response",
")",
"{",
"Object",
".",
"assign",
"(",
"bid",
",",
"{",
"requestId",
":",
"reqBid",
".",
"bidId",
",",
"cpm",
":",
"response",
".",
"price",
",",
"creativeId",
":",
"response",
".",
"crid",
"||",
"'-1'",
",",
"vastXml",
":",
"response",
".",
"adm",
",",
"vastUrl",
":",
"reqBid",
".",
"vastUrl",
",",
"mediaType",
":",
"'video'",
",",
"width",
":",
"width",
",",
"height",
":",
"height",
",",
"bidderCode",
":",
"bidderCode",
",",
"adId",
":",
"response",
".",
"id",
",",
"currency",
":",
"'USD'",
",",
"netRevenue",
":",
"true",
",",
"ttl",
":",
"300",
",",
"ad",
":",
"response",
".",
"adm",
"}",
")",
";",
"}",
"return",
"bid",
";",
"}"
] | Create and return a bid object based on status and tag
@param status
@param reqBid
@param response
@param width
@param height
@param bidderCode | [
"Create",
"and",
"return",
"a",
"bid",
"object",
"based",
"on",
"status",
"and",
"tag"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/telariaBidAdapter.js#L186-L210 |
6,153 | prebid/Prebid.js | modules/iasBidAdapter.js | stringifySlotSizes | function stringifySlotSizes(sizes) {
let result = '';
if (utils.isArray(sizes)) {
result = sizes.reduce((acc, size) => {
acc.push(size.join('.'));
return acc;
}, []);
result = '[' + result.join(',') + ']';
}
return result;
} | javascript | function stringifySlotSizes(sizes) {
let result = '';
if (utils.isArray(sizes)) {
result = sizes.reduce((acc, size) => {
acc.push(size.join('.'));
return acc;
}, []);
result = '[' + result.join(',') + ']';
}
return result;
} | [
"function",
"stringifySlotSizes",
"(",
"sizes",
")",
"{",
"let",
"result",
"=",
"''",
";",
"if",
"(",
"utils",
".",
"isArray",
"(",
"sizes",
")",
")",
"{",
"result",
"=",
"sizes",
".",
"reduce",
"(",
"(",
"acc",
",",
"size",
")",
"=>",
"{",
"acc",
".",
"push",
"(",
"size",
".",
"join",
"(",
"'.'",
")",
")",
";",
"return",
"acc",
";",
"}",
",",
"[",
"]",
")",
";",
"result",
"=",
"'['",
"+",
"result",
".",
"join",
"(",
"','",
")",
"+",
"']'",
";",
"}",
"return",
"result",
";",
"}"
] | Converts GPT-style size array into a string
@param {Array} sizes: list of GPT-style sizes, e.g. [[300, 250], [300, 300]]
@return {String} a string containing sizes, e.g. '[300.250,300.300]' | [
"Converts",
"GPT",
"-",
"style",
"size",
"array",
"into",
"a",
"string"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/iasBidAdapter.js#L18-L28 |
6,154 | prebid/Prebid.js | modules/adpod.js | attachPriceIndustryDurationKeyToBid | function attachPriceIndustryDurationKeyToBid(bid, brandCategoryExclusion) {
let initialCacheKey = bidCacheRegistry.getInitialCacheKey(bid);
let duration = utils.deepAccess(bid, 'video.durationBucket');
let cpmFixed = bid.cpm.toFixed(2);
let pcd;
if (brandCategoryExclusion) {
let category = utils.deepAccess(bid, 'meta.adServerCatId');
pcd = `${cpmFixed}_${category}_${duration}s`;
} else {
pcd = `${cpmFixed}_${duration}s`;
}
if (!bid.adserverTargeting) {
bid.adserverTargeting = {};
}
bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] = pcd;
bid.adserverTargeting[TARGETING_KEY_CACHE_ID] = initialCacheKey;
bid.videoCacheKey = initialCacheKey;
bid.customCacheKey = `${pcd}_${initialCacheKey}`;
} | javascript | function attachPriceIndustryDurationKeyToBid(bid, brandCategoryExclusion) {
let initialCacheKey = bidCacheRegistry.getInitialCacheKey(bid);
let duration = utils.deepAccess(bid, 'video.durationBucket');
let cpmFixed = bid.cpm.toFixed(2);
let pcd;
if (brandCategoryExclusion) {
let category = utils.deepAccess(bid, 'meta.adServerCatId');
pcd = `${cpmFixed}_${category}_${duration}s`;
} else {
pcd = `${cpmFixed}_${duration}s`;
}
if (!bid.adserverTargeting) {
bid.adserverTargeting = {};
}
bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] = pcd;
bid.adserverTargeting[TARGETING_KEY_CACHE_ID] = initialCacheKey;
bid.videoCacheKey = initialCacheKey;
bid.customCacheKey = `${pcd}_${initialCacheKey}`;
} | [
"function",
"attachPriceIndustryDurationKeyToBid",
"(",
"bid",
",",
"brandCategoryExclusion",
")",
"{",
"let",
"initialCacheKey",
"=",
"bidCacheRegistry",
".",
"getInitialCacheKey",
"(",
"bid",
")",
";",
"let",
"duration",
"=",
"utils",
".",
"deepAccess",
"(",
"bid",
",",
"'video.durationBucket'",
")",
";",
"let",
"cpmFixed",
"=",
"bid",
".",
"cpm",
".",
"toFixed",
"(",
"2",
")",
";",
"let",
"pcd",
";",
"if",
"(",
"brandCategoryExclusion",
")",
"{",
"let",
"category",
"=",
"utils",
".",
"deepAccess",
"(",
"bid",
",",
"'meta.adServerCatId'",
")",
";",
"pcd",
"=",
"`",
"${",
"cpmFixed",
"}",
"${",
"category",
"}",
"${",
"duration",
"}",
"`",
";",
"}",
"else",
"{",
"pcd",
"=",
"`",
"${",
"cpmFixed",
"}",
"${",
"duration",
"}",
"`",
";",
"}",
"if",
"(",
"!",
"bid",
".",
"adserverTargeting",
")",
"{",
"bid",
".",
"adserverTargeting",
"=",
"{",
"}",
";",
"}",
"bid",
".",
"adserverTargeting",
"[",
"TARGETING_KEY_PB_CAT_DUR",
"]",
"=",
"pcd",
";",
"bid",
".",
"adserverTargeting",
"[",
"TARGETING_KEY_CACHE_ID",
"]",
"=",
"initialCacheKey",
";",
"bid",
".",
"videoCacheKey",
"=",
"initialCacheKey",
";",
"bid",
".",
"customCacheKey",
"=",
"`",
"${",
"pcd",
"}",
"${",
"initialCacheKey",
"}",
"`",
";",
"}"
] | This function reads certain fields from the bid to generate a specific key used for caching the bid in Prebid Cache
@param {Object} bid bid object to update
@param {Boolean} brandCategoryExclusion value read from setConfig; influences whether category is required or not | [
"This",
"function",
"reads",
"certain",
"fields",
"from",
"the",
"bid",
"to",
"generate",
"a",
"specific",
"key",
"used",
"for",
"caching",
"the",
"bid",
"in",
"Prebid",
"Cache"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adpod.js#L117-L137 |
6,155 | prebid/Prebid.js | modules/adpod.js | updateBidQueue | function updateBidQueue(auctionInstance, bidResponse, afterBidAdded) {
let bidListIter = bidCacheRegistry.getBids(bidResponse);
if (bidListIter) {
let bidListArr = from(bidListIter);
let callDispatcher = bidCacheRegistry.getQueueDispatcher(bidResponse);
let killQueue = !!(auctionInstance.getAuctionStatus() !== AUCTION_IN_PROGRESS);
callDispatcher(auctionInstance, bidListArr, afterBidAdded, killQueue);
} else {
utils.logWarn('Attempted to cache a bid from an unknown auction. Bid:', bidResponse);
}
} | javascript | function updateBidQueue(auctionInstance, bidResponse, afterBidAdded) {
let bidListIter = bidCacheRegistry.getBids(bidResponse);
if (bidListIter) {
let bidListArr = from(bidListIter);
let callDispatcher = bidCacheRegistry.getQueueDispatcher(bidResponse);
let killQueue = !!(auctionInstance.getAuctionStatus() !== AUCTION_IN_PROGRESS);
callDispatcher(auctionInstance, bidListArr, afterBidAdded, killQueue);
} else {
utils.logWarn('Attempted to cache a bid from an unknown auction. Bid:', bidResponse);
}
} | [
"function",
"updateBidQueue",
"(",
"auctionInstance",
",",
"bidResponse",
",",
"afterBidAdded",
")",
"{",
"let",
"bidListIter",
"=",
"bidCacheRegistry",
".",
"getBids",
"(",
"bidResponse",
")",
";",
"if",
"(",
"bidListIter",
")",
"{",
"let",
"bidListArr",
"=",
"from",
"(",
"bidListIter",
")",
";",
"let",
"callDispatcher",
"=",
"bidCacheRegistry",
".",
"getQueueDispatcher",
"(",
"bidResponse",
")",
";",
"let",
"killQueue",
"=",
"!",
"!",
"(",
"auctionInstance",
".",
"getAuctionStatus",
"(",
")",
"!==",
"AUCTION_IN_PROGRESS",
")",
";",
"callDispatcher",
"(",
"auctionInstance",
",",
"bidListArr",
",",
"afterBidAdded",
",",
"killQueue",
")",
";",
"}",
"else",
"{",
"utils",
".",
"logWarn",
"(",
"'Attempted to cache a bid from an unknown auction. Bid:'",
",",
"bidResponse",
")",
";",
"}",
"}"
] | Updates the running queue for the associated auction.
Does a check to ensure the auction is still running; if it's not - the previously running queue is killed.
@param {*} auctionInstance running context of the auction
@param {Object} bidResponse bid object being added to queue
@param {Function} afterBidAdded callback function used when Prebid Cache responds | [
"Updates",
"the",
"running",
"queue",
"for",
"the",
"associated",
"auction",
".",
"Does",
"a",
"check",
"to",
"ensure",
"the",
"auction",
"is",
"still",
"running",
";",
"if",
"it",
"s",
"not",
"-",
"the",
"previously",
"running",
"queue",
"is",
"killed",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adpod.js#L146-L157 |
6,156 | prebid/Prebid.js | modules/adpod.js | firePrebidCacheCall | function firePrebidCacheCall(auctionInstance, bidList, afterBidAdded) {
// remove entries now so other incoming bids won't accidentally have a stale version of the list while PBC is processing the current submitted list
removeBidsFromStorage(bidList);
store(bidList, function (error, cacheIds) {
if (error) {
utils.logWarn(`Failed to save to the video cache: ${error}. Video bid(s) must be discarded.`);
for (let i = 0; i < bidList.length; i++) {
doCallbacksIfTimedout(auctionInstance, bidList[i]);
}
} else {
for (let i = 0; i < cacheIds.length; i++) {
// when uuid in response is empty string then the key already existed, so this bid wasn't cached
if (cacheIds[i].uuid !== '') {
addBidToAuction(auctionInstance, bidList[i]);
} else {
utils.logInfo(`Detected a bid was not cached because the custom key was already registered. Attempted to use key: ${bidList[i].customCacheKey}. Bid was: `, bidList[i]);
}
afterBidAdded();
}
}
});
} | javascript | function firePrebidCacheCall(auctionInstance, bidList, afterBidAdded) {
// remove entries now so other incoming bids won't accidentally have a stale version of the list while PBC is processing the current submitted list
removeBidsFromStorage(bidList);
store(bidList, function (error, cacheIds) {
if (error) {
utils.logWarn(`Failed to save to the video cache: ${error}. Video bid(s) must be discarded.`);
for (let i = 0; i < bidList.length; i++) {
doCallbacksIfTimedout(auctionInstance, bidList[i]);
}
} else {
for (let i = 0; i < cacheIds.length; i++) {
// when uuid in response is empty string then the key already existed, so this bid wasn't cached
if (cacheIds[i].uuid !== '') {
addBidToAuction(auctionInstance, bidList[i]);
} else {
utils.logInfo(`Detected a bid was not cached because the custom key was already registered. Attempted to use key: ${bidList[i].customCacheKey}. Bid was: `, bidList[i]);
}
afterBidAdded();
}
}
});
} | [
"function",
"firePrebidCacheCall",
"(",
"auctionInstance",
",",
"bidList",
",",
"afterBidAdded",
")",
"{",
"// remove entries now so other incoming bids won't accidentally have a stale version of the list while PBC is processing the current submitted list",
"removeBidsFromStorage",
"(",
"bidList",
")",
";",
"store",
"(",
"bidList",
",",
"function",
"(",
"error",
",",
"cacheIds",
")",
"{",
"if",
"(",
"error",
")",
"{",
"utils",
".",
"logWarn",
"(",
"`",
"${",
"error",
"}",
"`",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"bidList",
".",
"length",
";",
"i",
"++",
")",
"{",
"doCallbacksIfTimedout",
"(",
"auctionInstance",
",",
"bidList",
"[",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"cacheIds",
".",
"length",
";",
"i",
"++",
")",
"{",
"// when uuid in response is empty string then the key already existed, so this bid wasn't cached",
"if",
"(",
"cacheIds",
"[",
"i",
"]",
".",
"uuid",
"!==",
"''",
")",
"{",
"addBidToAuction",
"(",
"auctionInstance",
",",
"bidList",
"[",
"i",
"]",
")",
";",
"}",
"else",
"{",
"utils",
".",
"logInfo",
"(",
"`",
"${",
"bidList",
"[",
"i",
"]",
".",
"customCacheKey",
"}",
"`",
",",
"bidList",
"[",
"i",
"]",
")",
";",
"}",
"afterBidAdded",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | This function will send a list of bids to Prebid Cache. It also removes the same bids from the internal bidCacheRegistry
to maintain which bids are in queue.
If the bids are successfully cached, they will be added to the respective auction.
@param {*} auctionInstance running context of the auction
@param {Array[Object]} bidList list of bid objects that need to be sent to Prebid Cache
@param {Function} afterBidAdded callback function used when Prebid Cache responds | [
"This",
"function",
"will",
"send",
"a",
"list",
"of",
"bids",
"to",
"Prebid",
"Cache",
".",
"It",
"also",
"removes",
"the",
"same",
"bids",
"from",
"the",
"internal",
"bidCacheRegistry",
"to",
"maintain",
"which",
"bids",
"are",
"in",
"queue",
".",
"If",
"the",
"bids",
"are",
"successfully",
"cached",
"they",
"will",
"be",
"added",
"to",
"the",
"respective",
"auction",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adpod.js#L177-L199 |
6,157 | prebid/Prebid.js | modules/getintentBidAdapter.js | function(serverResponse) {
let responseBody = serverResponse.body;
const bids = [];
if (responseBody && responseBody.no_bid !== 1) {
let size = parseSize(responseBody.size);
let bid = {
requestId: responseBody.bid_id,
ttl: BID_RESPONSE_TTL_SEC,
netRevenue: IS_NET_REVENUE,
currency: responseBody.currency,
creativeId: responseBody.creative_id,
cpm: responseBody.cpm,
width: size[0],
height: size[1]
};
if (responseBody.vast_url) {
bid.mediaType = 'video';
bid.vastUrl = responseBody.vast_url;
} else {
bid.mediaType = 'banner';
bid.ad = responseBody.ad;
}
bids.push(bid);
}
return bids;
} | javascript | function(serverResponse) {
let responseBody = serverResponse.body;
const bids = [];
if (responseBody && responseBody.no_bid !== 1) {
let size = parseSize(responseBody.size);
let bid = {
requestId: responseBody.bid_id,
ttl: BID_RESPONSE_TTL_SEC,
netRevenue: IS_NET_REVENUE,
currency: responseBody.currency,
creativeId: responseBody.creative_id,
cpm: responseBody.cpm,
width: size[0],
height: size[1]
};
if (responseBody.vast_url) {
bid.mediaType = 'video';
bid.vastUrl = responseBody.vast_url;
} else {
bid.mediaType = 'banner';
bid.ad = responseBody.ad;
}
bids.push(bid);
}
return bids;
} | [
"function",
"(",
"serverResponse",
")",
"{",
"let",
"responseBody",
"=",
"serverResponse",
".",
"body",
";",
"const",
"bids",
"=",
"[",
"]",
";",
"if",
"(",
"responseBody",
"&&",
"responseBody",
".",
"no_bid",
"!==",
"1",
")",
"{",
"let",
"size",
"=",
"parseSize",
"(",
"responseBody",
".",
"size",
")",
";",
"let",
"bid",
"=",
"{",
"requestId",
":",
"responseBody",
".",
"bid_id",
",",
"ttl",
":",
"BID_RESPONSE_TTL_SEC",
",",
"netRevenue",
":",
"IS_NET_REVENUE",
",",
"currency",
":",
"responseBody",
".",
"currency",
",",
"creativeId",
":",
"responseBody",
".",
"creative_id",
",",
"cpm",
":",
"responseBody",
".",
"cpm",
",",
"width",
":",
"size",
"[",
"0",
"]",
",",
"height",
":",
"size",
"[",
"1",
"]",
"}",
";",
"if",
"(",
"responseBody",
".",
"vast_url",
")",
"{",
"bid",
".",
"mediaType",
"=",
"'video'",
";",
"bid",
".",
"vastUrl",
"=",
"responseBody",
".",
"vast_url",
";",
"}",
"else",
"{",
"bid",
".",
"mediaType",
"=",
"'banner'",
";",
"bid",
".",
"ad",
"=",
"responseBody",
".",
"ad",
";",
"}",
"bids",
".",
"push",
"(",
"bid",
")",
";",
"}",
"return",
"bids",
";",
"}"
] | Callback for bids, after the call to DSP completes.
Parse the response from the server into a list of bids.
@param {object} serverResponse A response from the GetIntent's server.
@return {Bid[]} An array of bids which were nested inside the server. | [
"Callback",
"for",
"bids",
"after",
"the",
"call",
"to",
"DSP",
"completes",
".",
"Parse",
"the",
"response",
"from",
"the",
"server",
"into",
"a",
"list",
"of",
"bids",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/getintentBidAdapter.js#L56-L81 |
|
6,158 | prebid/Prebid.js | modules/getintentBidAdapter.js | buildGiBidRequest | function buildGiBidRequest(bidRequest) {
let giBidRequest = {
bid_id: bidRequest.bidId,
pid: bidRequest.params.pid, // required
tid: bidRequest.params.tid, // required
known: bidRequest.params.known || 1,
is_video: bidRequest.mediaType === 'video',
resp_type: 'JSON',
provider: 'direct.prebidjs'
};
if (bidRequest.sizes) {
giBidRequest.size = produceSize(bidRequest.sizes);
}
addVideo(bidRequest.params.video, giBidRequest);
addOptional(bidRequest.params, giBidRequest, OPTIONAL_PROPERTIES);
return giBidRequest;
} | javascript | function buildGiBidRequest(bidRequest) {
let giBidRequest = {
bid_id: bidRequest.bidId,
pid: bidRequest.params.pid, // required
tid: bidRequest.params.tid, // required
known: bidRequest.params.known || 1,
is_video: bidRequest.mediaType === 'video',
resp_type: 'JSON',
provider: 'direct.prebidjs'
};
if (bidRequest.sizes) {
giBidRequest.size = produceSize(bidRequest.sizes);
}
addVideo(bidRequest.params.video, giBidRequest);
addOptional(bidRequest.params, giBidRequest, OPTIONAL_PROPERTIES);
return giBidRequest;
} | [
"function",
"buildGiBidRequest",
"(",
"bidRequest",
")",
"{",
"let",
"giBidRequest",
"=",
"{",
"bid_id",
":",
"bidRequest",
".",
"bidId",
",",
"pid",
":",
"bidRequest",
".",
"params",
".",
"pid",
",",
"// required",
"tid",
":",
"bidRequest",
".",
"params",
".",
"tid",
",",
"// required",
"known",
":",
"bidRequest",
".",
"params",
".",
"known",
"||",
"1",
",",
"is_video",
":",
"bidRequest",
".",
"mediaType",
"===",
"'video'",
",",
"resp_type",
":",
"'JSON'",
",",
"provider",
":",
"'direct.prebidjs'",
"}",
";",
"if",
"(",
"bidRequest",
".",
"sizes",
")",
"{",
"giBidRequest",
".",
"size",
"=",
"produceSize",
"(",
"bidRequest",
".",
"sizes",
")",
";",
"}",
"addVideo",
"(",
"bidRequest",
".",
"params",
".",
"video",
",",
"giBidRequest",
")",
";",
"addOptional",
"(",
"bidRequest",
".",
"params",
",",
"giBidRequest",
",",
"OPTIONAL_PROPERTIES",
")",
";",
"return",
"giBidRequest",
";",
"}"
] | Builds GI bid request from BidRequest.
@param {BidRequest} bidRequest.
@return {object} GI bid request. | [
"Builds",
"GI",
"bid",
"request",
"from",
"BidRequest",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/getintentBidAdapter.js#L95-L111 |
6,159 | prebid/Prebid.js | modules/c1xBidAdapter.js | function(bid) {
const siteId = bid.params.siteId || '';
if (!siteId) {
utils.logError(LOG_MSG.noSite);
}
return !!(bid.adUnitCode && siteId);
} | javascript | function(bid) {
const siteId = bid.params.siteId || '';
if (!siteId) {
utils.logError(LOG_MSG.noSite);
}
return !!(bid.adUnitCode && siteId);
} | [
"function",
"(",
"bid",
")",
"{",
"const",
"siteId",
"=",
"bid",
".",
"params",
".",
"siteId",
"||",
"''",
";",
"if",
"(",
"!",
"siteId",
")",
"{",
"utils",
".",
"logError",
"(",
"LOG_MSG",
".",
"noSite",
")",
";",
"}",
"return",
"!",
"!",
"(",
"bid",
".",
"adUnitCode",
"&&",
"siteId",
")",
";",
"}"
] | check the bids sent to c1x bidder | [
"check",
"the",
"bids",
"sent",
"to",
"c1x",
"bidder"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/c1xBidAdapter.js#L24-L30 |
|
6,160 | prebid/Prebid.js | modules/express.js | defaultSlots | function defaultSlots(slots) {
return Array.isArray(slots)
? slots.slice()
: googletag.pubads().getSlots().slice();
} | javascript | function defaultSlots(slots) {
return Array.isArray(slots)
? slots.slice()
: googletag.pubads().getSlots().slice();
} | [
"function",
"defaultSlots",
"(",
"slots",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"slots",
")",
"?",
"slots",
".",
"slice",
"(",
")",
":",
"googletag",
".",
"pubads",
"(",
")",
".",
"getSlots",
"(",
")",
".",
"slice",
"(",
")",
";",
"}"
] | a helper function to verify slots or get slots if not present | [
"a",
"helper",
"function",
"to",
"verify",
"slots",
"or",
"get",
"slots",
"if",
"not",
"present"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/express.js#L61-L65 |
6,161 | prebid/Prebid.js | modules/express.js | pickAdUnits | function pickAdUnits(gptSlots) {
var adUnits = [];
// traverse backwards (since gptSlots is mutated) to find adUnits in cache and remove non-mapped slots
for (var i = gptSlots.length - 1; i > -1; i--) {
const gptSlot = gptSlots[i];
const elemId = gptSlot.getSlotElementId();
const adUnit = adUnitsCache[elemId];
if (adUnit) {
gptSlotCache[elemId] = gptSlot; // store by elementId
adUnit.sizes = adUnit.sizes || mapGptSlotSizes(gptSlot.getSizes());
adUnits.push(adUnit);
gptSlots.splice(i, 1);
}
}
return adUnits;
} | javascript | function pickAdUnits(gptSlots) {
var adUnits = [];
// traverse backwards (since gptSlots is mutated) to find adUnits in cache and remove non-mapped slots
for (var i = gptSlots.length - 1; i > -1; i--) {
const gptSlot = gptSlots[i];
const elemId = gptSlot.getSlotElementId();
const adUnit = adUnitsCache[elemId];
if (adUnit) {
gptSlotCache[elemId] = gptSlot; // store by elementId
adUnit.sizes = adUnit.sizes || mapGptSlotSizes(gptSlot.getSizes());
adUnits.push(adUnit);
gptSlots.splice(i, 1);
}
}
return adUnits;
} | [
"function",
"pickAdUnits",
"(",
"gptSlots",
")",
"{",
"var",
"adUnits",
"=",
"[",
"]",
";",
"// traverse backwards (since gptSlots is mutated) to find adUnits in cache and remove non-mapped slots",
"for",
"(",
"var",
"i",
"=",
"gptSlots",
".",
"length",
"-",
"1",
";",
"i",
">",
"-",
"1",
";",
"i",
"--",
")",
"{",
"const",
"gptSlot",
"=",
"gptSlots",
"[",
"i",
"]",
";",
"const",
"elemId",
"=",
"gptSlot",
".",
"getSlotElementId",
"(",
")",
";",
"const",
"adUnit",
"=",
"adUnitsCache",
"[",
"elemId",
"]",
";",
"if",
"(",
"adUnit",
")",
"{",
"gptSlotCache",
"[",
"elemId",
"]",
"=",
"gptSlot",
";",
"// store by elementId",
"adUnit",
".",
"sizes",
"=",
"adUnit",
".",
"sizes",
"||",
"mapGptSlotSizes",
"(",
"gptSlot",
".",
"getSizes",
"(",
")",
")",
";",
"adUnits",
".",
"push",
"(",
"adUnit",
")",
";",
"gptSlots",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"}",
"}",
"return",
"adUnits",
";",
"}"
] | maps gpt slots to adUnits, matches are copied to new array and removed from passed array. | [
"maps",
"gpt",
"slots",
"to",
"adUnits",
"matches",
"are",
"copied",
"to",
"new",
"array",
"and",
"removed",
"from",
"passed",
"array",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/express.js#L68-L85 |
6,162 | prebid/Prebid.js | src/utils.js | tryConvertType | function tryConvertType(typeToConvert, value) {
if (typeToConvert === 'string') {
return value && value.toString();
} else if (typeToConvert === 'number') {
return Number(value);
} else {
return value;
}
} | javascript | function tryConvertType(typeToConvert, value) {
if (typeToConvert === 'string') {
return value && value.toString();
} else if (typeToConvert === 'number') {
return Number(value);
} else {
return value;
}
} | [
"function",
"tryConvertType",
"(",
"typeToConvert",
",",
"value",
")",
"{",
"if",
"(",
"typeToConvert",
"===",
"'string'",
")",
"{",
"return",
"value",
"&&",
"value",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"typeToConvert",
"===",
"'number'",
")",
"{",
"return",
"Number",
"(",
"value",
")",
";",
"}",
"else",
"{",
"return",
"value",
";",
"}",
"}"
] | Try to convert a value to a type.
If it can't be done, the value will be returned.
@param {string} typeToConvert The target type. e.g. "string", "number", etc.
@param {*} value The value to be converted into typeToConvert. | [
"Try",
"to",
"convert",
"a",
"value",
"to",
"a",
"type",
".",
"If",
"it",
"can",
"t",
"be",
"done",
"the",
"value",
"will",
"be",
"returned",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/utils.js#L1193-L1201 |
6,163 | prebid/Prebid.js | modules/freeWheelAdserverVideo.js | getAdPodAdUnits | function getAdPodAdUnits(codes) {
return auctionManager.getAdUnits()
.filter((adUnit) => deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD)
.filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true);
} | javascript | function getAdPodAdUnits(codes) {
return auctionManager.getAdUnits()
.filter((adUnit) => deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD)
.filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true);
} | [
"function",
"getAdPodAdUnits",
"(",
"codes",
")",
"{",
"return",
"auctionManager",
".",
"getAdUnits",
"(",
")",
".",
"filter",
"(",
"(",
"adUnit",
")",
"=>",
"deepAccess",
"(",
"adUnit",
",",
"'mediaTypes.video.context'",
")",
"===",
"ADPOD",
")",
".",
"filter",
"(",
"(",
"adUnit",
")",
"=>",
"(",
"codes",
".",
"length",
">",
"0",
")",
"?",
"codes",
".",
"indexOf",
"(",
"adUnit",
".",
"code",
")",
"!=",
"-",
"1",
":",
"true",
")",
";",
"}"
] | This function returns the adunit of mediaType adpod
@param {Array} codes adUnitCodes
@returns {Array[Object]} adunits of mediaType adpod | [
"This",
"function",
"returns",
"the",
"adunit",
"of",
"mediaType",
"adpod"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/freeWheelAdserverVideo.js#L116-L120 |
6,164 | prebid/Prebid.js | modules/freeWheelAdserverVideo.js | getExclusiveBids | function getExclusiveBids(bidsReceived) {
let bids = bidsReceived
.map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]}));
bids = groupBy(bids, TARGETING_KEY_PB_CAT_DUR);
let filteredBids = [];
Object.keys(bids).forEach((targetingKey) => {
bids[targetingKey].sort(compareOn('responseTimestamp'));
filteredBids.push(bids[targetingKey][0]);
});
return filteredBids;
} | javascript | function getExclusiveBids(bidsReceived) {
let bids = bidsReceived
.map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]}));
bids = groupBy(bids, TARGETING_KEY_PB_CAT_DUR);
let filteredBids = [];
Object.keys(bids).forEach((targetingKey) => {
bids[targetingKey].sort(compareOn('responseTimestamp'));
filteredBids.push(bids[targetingKey][0]);
});
return filteredBids;
} | [
"function",
"getExclusiveBids",
"(",
"bidsReceived",
")",
"{",
"let",
"bids",
"=",
"bidsReceived",
".",
"map",
"(",
"(",
"bid",
")",
"=>",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"bid",
",",
"{",
"[",
"TARGETING_KEY_PB_CAT_DUR",
"]",
":",
"bid",
".",
"adserverTargeting",
"[",
"TARGETING_KEY_PB_CAT_DUR",
"]",
"}",
")",
")",
";",
"bids",
"=",
"groupBy",
"(",
"bids",
",",
"TARGETING_KEY_PB_CAT_DUR",
")",
";",
"let",
"filteredBids",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"bids",
")",
".",
"forEach",
"(",
"(",
"targetingKey",
")",
"=>",
"{",
"bids",
"[",
"targetingKey",
"]",
".",
"sort",
"(",
"compareOn",
"(",
"'responseTimestamp'",
")",
")",
";",
"filteredBids",
".",
"push",
"(",
"bids",
"[",
"targetingKey",
"]",
"[",
"0",
"]",
")",
";",
"}",
")",
";",
"return",
"filteredBids",
";",
"}"
] | This function removes bids of same freewheel category. It will be used when competitive exclusion is enabled.
@param {Array[Object]} bidsReceived
@returns {Array[Object]} unique freewheel category bids | [
"This",
"function",
"removes",
"bids",
"of",
"same",
"freewheel",
"category",
".",
"It",
"will",
"be",
"used",
"when",
"competitive",
"exclusion",
"is",
"enabled",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/freeWheelAdserverVideo.js#L127-L137 |
6,165 | prebid/Prebid.js | modules/freeWheelAdserverVideo.js | getBidsForAdpod | function getBidsForAdpod(bidsReceived, adPodAdUnits) {
let adUnitCodes = adPodAdUnits.map((adUnit) => adUnit.code);
return bidsReceived
.filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD))
} | javascript | function getBidsForAdpod(bidsReceived, adPodAdUnits) {
let adUnitCodes = adPodAdUnits.map((adUnit) => adUnit.code);
return bidsReceived
.filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD))
} | [
"function",
"getBidsForAdpod",
"(",
"bidsReceived",
",",
"adPodAdUnits",
")",
"{",
"let",
"adUnitCodes",
"=",
"adPodAdUnits",
".",
"map",
"(",
"(",
"adUnit",
")",
"=>",
"adUnit",
".",
"code",
")",
";",
"return",
"bidsReceived",
".",
"filter",
"(",
"(",
"bid",
")",
"=>",
"adUnitCodes",
".",
"indexOf",
"(",
"bid",
".",
"adUnitCode",
")",
"!=",
"-",
"1",
"&&",
"(",
"bid",
".",
"video",
"&&",
"bid",
".",
"video",
".",
"context",
"===",
"ADPOD",
")",
")",
"}"
] | This function returns bids for adpod adunits
@param {Array[Object]} bidsReceived
@param {Array[Object]} adPodAdUnits
@returns {Array[Object]} bids of mediaType adpod | [
"This",
"function",
"returns",
"bids",
"for",
"adpod",
"adunits"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/freeWheelAdserverVideo.js#L145-L149 |
6,166 | prebid/Prebid.js | src/bidfactory.js | Bid | function Bid(statusCode, bidRequest) {
var _bidSrc = (bidRequest && bidRequest.src) || 'client';
var _statusCode = statusCode || 0;
this.bidderCode = (bidRequest && bidRequest.bidder) || '';
this.width = 0;
this.height = 0;
this.statusMessage = _getStatus();
this.adId = utils.getUniqueIdentifierStr();
this.requestId = bidRequest && bidRequest.bidId;
this.mediaType = 'banner';
this.source = _bidSrc;
function _getStatus() {
switch (_statusCode) {
case 0:
return 'Pending';
case 1:
return 'Bid available';
case 2:
return 'Bid returned empty or error response';
case 3:
return 'Bid timed out';
}
}
this.getStatusCode = function () {
return _statusCode;
};
// returns the size of the bid creative. Concatenation of width and height by ‘x’.
this.getSize = function () {
return this.width + 'x' + this.height;
};
} | javascript | function Bid(statusCode, bidRequest) {
var _bidSrc = (bidRequest && bidRequest.src) || 'client';
var _statusCode = statusCode || 0;
this.bidderCode = (bidRequest && bidRequest.bidder) || '';
this.width = 0;
this.height = 0;
this.statusMessage = _getStatus();
this.adId = utils.getUniqueIdentifierStr();
this.requestId = bidRequest && bidRequest.bidId;
this.mediaType = 'banner';
this.source = _bidSrc;
function _getStatus() {
switch (_statusCode) {
case 0:
return 'Pending';
case 1:
return 'Bid available';
case 2:
return 'Bid returned empty or error response';
case 3:
return 'Bid timed out';
}
}
this.getStatusCode = function () {
return _statusCode;
};
// returns the size of the bid creative. Concatenation of width and height by ‘x’.
this.getSize = function () {
return this.width + 'x' + this.height;
};
} | [
"function",
"Bid",
"(",
"statusCode",
",",
"bidRequest",
")",
"{",
"var",
"_bidSrc",
"=",
"(",
"bidRequest",
"&&",
"bidRequest",
".",
"src",
")",
"||",
"'client'",
";",
"var",
"_statusCode",
"=",
"statusCode",
"||",
"0",
";",
"this",
".",
"bidderCode",
"=",
"(",
"bidRequest",
"&&",
"bidRequest",
".",
"bidder",
")",
"||",
"''",
";",
"this",
".",
"width",
"=",
"0",
";",
"this",
".",
"height",
"=",
"0",
";",
"this",
".",
"statusMessage",
"=",
"_getStatus",
"(",
")",
";",
"this",
".",
"adId",
"=",
"utils",
".",
"getUniqueIdentifierStr",
"(",
")",
";",
"this",
".",
"requestId",
"=",
"bidRequest",
"&&",
"bidRequest",
".",
"bidId",
";",
"this",
".",
"mediaType",
"=",
"'banner'",
";",
"this",
".",
"source",
"=",
"_bidSrc",
";",
"function",
"_getStatus",
"(",
")",
"{",
"switch",
"(",
"_statusCode",
")",
"{",
"case",
"0",
":",
"return",
"'Pending'",
";",
"case",
"1",
":",
"return",
"'Bid available'",
";",
"case",
"2",
":",
"return",
"'Bid returned empty or error response'",
";",
"case",
"3",
":",
"return",
"'Bid timed out'",
";",
"}",
"}",
"this",
".",
"getStatusCode",
"=",
"function",
"(",
")",
"{",
"return",
"_statusCode",
";",
"}",
";",
"// returns the size of the bid creative. Concatenation of width and height by ‘x’.",
"this",
".",
"getSize",
"=",
"function",
"(",
")",
"{",
"return",
"this",
".",
"width",
"+",
"'x'",
"+",
"this",
".",
"height",
";",
"}",
";",
"}"
] | Required paramaters
bidderCode,
height,
width,
statusCode
Optional paramaters
adId,
cpm,
ad,
adUrl,
dealId,
priceKeyString; | [
"Required",
"paramaters",
"bidderCode",
"height",
"width",
"statusCode",
"Optional",
"paramaters",
"adId",
"cpm",
"ad",
"adUrl",
"dealId",
"priceKeyString",
";"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/bidfactory.js#L17-L51 |
6,167 | prebid/Prebid.js | modules/adkernelBidAdapter.js | dispatchImps | function dispatchImps(bidRequests, refererInfo) {
let secure = (refererInfo && refererInfo.referer.indexOf('https:') === 0);
return bidRequests.map(bidRequest => buildImp(bidRequest, secure))
.reduce((acc, curr, index) => {
let bidRequest = bidRequests[index];
let zoneId = bidRequest.params.zoneId;
let host = bidRequest.params.host;
acc[host] = acc[host] || {};
acc[host][zoneId] = acc[host][zoneId] || [];
acc[host][zoneId].push(curr);
return acc;
}, {});
} | javascript | function dispatchImps(bidRequests, refererInfo) {
let secure = (refererInfo && refererInfo.referer.indexOf('https:') === 0);
return bidRequests.map(bidRequest => buildImp(bidRequest, secure))
.reduce((acc, curr, index) => {
let bidRequest = bidRequests[index];
let zoneId = bidRequest.params.zoneId;
let host = bidRequest.params.host;
acc[host] = acc[host] || {};
acc[host][zoneId] = acc[host][zoneId] || [];
acc[host][zoneId].push(curr);
return acc;
}, {});
} | [
"function",
"dispatchImps",
"(",
"bidRequests",
",",
"refererInfo",
")",
"{",
"let",
"secure",
"=",
"(",
"refererInfo",
"&&",
"refererInfo",
".",
"referer",
".",
"indexOf",
"(",
"'https:'",
")",
"===",
"0",
")",
";",
"return",
"bidRequests",
".",
"map",
"(",
"bidRequest",
"=>",
"buildImp",
"(",
"bidRequest",
",",
"secure",
")",
")",
".",
"reduce",
"(",
"(",
"acc",
",",
"curr",
",",
"index",
")",
"=>",
"{",
"let",
"bidRequest",
"=",
"bidRequests",
"[",
"index",
"]",
";",
"let",
"zoneId",
"=",
"bidRequest",
".",
"params",
".",
"zoneId",
";",
"let",
"host",
"=",
"bidRequest",
".",
"params",
".",
"host",
";",
"acc",
"[",
"host",
"]",
"=",
"acc",
"[",
"host",
"]",
"||",
"{",
"}",
";",
"acc",
"[",
"host",
"]",
"[",
"zoneId",
"]",
"=",
"acc",
"[",
"host",
"]",
"[",
"zoneId",
"]",
"||",
"[",
"]",
";",
"acc",
"[",
"host",
"]",
"[",
"zoneId",
"]",
".",
"push",
"(",
"curr",
")",
";",
"return",
"acc",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Dispatch impressions by ad network host and zone | [
"Dispatch",
"impressions",
"by",
"ad",
"network",
"host",
"and",
"zone"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adkernelBidAdapter.js#L96-L108 |
6,168 | prebid/Prebid.js | modules/adkernelBidAdapter.js | createSite | function createSite(refInfo) {
let url = parseUrl(refInfo.referer);
let result = {
'domain': url.hostname,
'page': url.protocol + '://' + url.hostname + url.pathname
};
if (self === top && document.referrer) {
result.ref = document.referrer;
}
let keywords = document.getElementsByTagName('meta')['keywords'];
if (keywords && keywords.content) {
result.keywords = keywords.content;
}
return result;
} | javascript | function createSite(refInfo) {
let url = parseUrl(refInfo.referer);
let result = {
'domain': url.hostname,
'page': url.protocol + '://' + url.hostname + url.pathname
};
if (self === top && document.referrer) {
result.ref = document.referrer;
}
let keywords = document.getElementsByTagName('meta')['keywords'];
if (keywords && keywords.content) {
result.keywords = keywords.content;
}
return result;
} | [
"function",
"createSite",
"(",
"refInfo",
")",
"{",
"let",
"url",
"=",
"parseUrl",
"(",
"refInfo",
".",
"referer",
")",
";",
"let",
"result",
"=",
"{",
"'domain'",
":",
"url",
".",
"hostname",
",",
"'page'",
":",
"url",
".",
"protocol",
"+",
"'://'",
"+",
"url",
".",
"hostname",
"+",
"url",
".",
"pathname",
"}",
";",
"if",
"(",
"self",
"===",
"top",
"&&",
"document",
".",
"referrer",
")",
"{",
"result",
".",
"ref",
"=",
"document",
".",
"referrer",
";",
"}",
"let",
"keywords",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'meta'",
")",
"[",
"'keywords'",
"]",
";",
"if",
"(",
"keywords",
"&&",
"keywords",
".",
"content",
")",
"{",
"result",
".",
"keywords",
"=",
"keywords",
".",
"content",
";",
"}",
"return",
"result",
";",
"}"
] | Creates site description object | [
"Creates",
"site",
"description",
"object"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adkernelBidAdapter.js#L199-L213 |
6,169 | prebid/Prebid.js | modules/adkernelBidAdapter.js | formatAdMarkup | function formatAdMarkup(bid) {
let adm = bid.adm;
if ('nurl' in bid) {
adm += utils.createTrackPixelHtml(`${bid.nurl}&px=1`);
}
return adm;
} | javascript | function formatAdMarkup(bid) {
let adm = bid.adm;
if ('nurl' in bid) {
adm += utils.createTrackPixelHtml(`${bid.nurl}&px=1`);
}
return adm;
} | [
"function",
"formatAdMarkup",
"(",
"bid",
")",
"{",
"let",
"adm",
"=",
"bid",
".",
"adm",
";",
"if",
"(",
"'nurl'",
"in",
"bid",
")",
"{",
"adm",
"+=",
"utils",
".",
"createTrackPixelHtml",
"(",
"`",
"${",
"bid",
".",
"nurl",
"}",
"`",
")",
";",
"}",
"return",
"adm",
";",
"}"
] | Format creative with optional nurl call
@param bid rtb Bid object | [
"Format",
"creative",
"with",
"optional",
"nurl",
"call"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/adkernelBidAdapter.js#L219-L225 |
6,170 | prebid/Prebid.js | modules/gjirafaBidAdapter.js | generateSizeParam | function generateSizeParam(sizes) {
return sizes.map(size => size.join(DIMENSION_SEPARATOR)).join(SIZE_SEPARATOR);
} | javascript | function generateSizeParam(sizes) {
return sizes.map(size => size.join(DIMENSION_SEPARATOR)).join(SIZE_SEPARATOR);
} | [
"function",
"generateSizeParam",
"(",
"sizes",
")",
"{",
"return",
"sizes",
".",
"map",
"(",
"size",
"=>",
"size",
".",
"join",
"(",
"DIMENSION_SEPARATOR",
")",
")",
".",
"join",
"(",
"SIZE_SEPARATOR",
")",
";",
"}"
] | Generate size param for bid request using sizes array
@param {Array} sizes Possible sizes for the ad unit.
@return {string} Processed sizes param to be used for the bid request. | [
"Generate",
"size",
"param",
"for",
"bid",
"request",
"using",
"sizes",
"array"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/gjirafaBidAdapter.js#L91-L93 |
6,171 | prebid/Prebid.js | modules/liveyieldAnalyticsAdapter.js | function(slot) {
const hbAdIdTargeting = slot.getTargeting('hb_adid');
if (hbAdIdTargeting.length > 0) {
const hbAdId = hbAdIdTargeting[0];
return typeof this.prebidWinnersCache[hbAdId] !== 'undefined';
}
return false;
} | javascript | function(slot) {
const hbAdIdTargeting = slot.getTargeting('hb_adid');
if (hbAdIdTargeting.length > 0) {
const hbAdId = hbAdIdTargeting[0];
return typeof this.prebidWinnersCache[hbAdId] !== 'undefined';
}
return false;
} | [
"function",
"(",
"slot",
")",
"{",
"const",
"hbAdIdTargeting",
"=",
"slot",
".",
"getTargeting",
"(",
"'hb_adid'",
")",
";",
"if",
"(",
"hbAdIdTargeting",
".",
"length",
">",
"0",
")",
"{",
"const",
"hbAdId",
"=",
"hbAdIdTargeting",
"[",
"0",
"]",
";",
"return",
"typeof",
"this",
".",
"prebidWinnersCache",
"[",
"hbAdId",
"]",
"!==",
"'undefined'",
";",
"}",
"return",
"false",
";",
"}"
] | Decides if the GPT slot contains prebid ad impression or not.
When BID_WON event is emitted adid is added to prebidWinnersCache,
then we check if prebidWinnersCache contains slot.hb_adid.
This function is optional and used only when googlePublisherTag is provided.
Default implementation uses slot's `hb_adid` targeting parameter.
@param slot the gpt slot | [
"Decides",
"if",
"the",
"GPT",
"slot",
"contains",
"prebid",
"ad",
"impression",
"or",
"not",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/liveyieldAnalyticsAdapter.js#L76-L83 |
|
6,172 | prebid/Prebid.js | modules/liveyieldAnalyticsAdapter.js | function(instanceConfig, slot, version) {
const bid = getHighestPrebidBidResponseBySlotTargeting(
instanceConfig,
slot,
version
);
// this is bid response event has `bidder` while bid won has bidderCode property
return bid ? bid.bidderCode || bid.bidder : null;
} | javascript | function(instanceConfig, slot, version) {
const bid = getHighestPrebidBidResponseBySlotTargeting(
instanceConfig,
slot,
version
);
// this is bid response event has `bidder` while bid won has bidderCode property
return bid ? bid.bidderCode || bid.bidder : null;
} | [
"function",
"(",
"instanceConfig",
",",
"slot",
",",
"version",
")",
"{",
"const",
"bid",
"=",
"getHighestPrebidBidResponseBySlotTargeting",
"(",
"instanceConfig",
",",
"slot",
",",
"version",
")",
";",
"// this is bid response event has `bidder` while bid won has bidderCode property",
"return",
"bid",
"?",
"bid",
".",
"bidderCode",
"||",
"bid",
".",
"bidder",
":",
"null",
";",
"}"
] | If isPrebidAdImpression decides that slot contain prebid ad impression,
this function should return prebids highest ad impression partner for that
slot.
Default implementation uses slot's `hb_adid` targeting value to find
highest bid response and when present then returns `bidder`.
@param instanceConfig merged analytics adapter instance configuration
@param slot the gpt slot for which the name of the highest bidder shall be
returned
@param version the version of the prebid.js library | [
"If",
"isPrebidAdImpression",
"decides",
"that",
"slot",
"contain",
"prebid",
"ad",
"impression",
"this",
"function",
"should",
"return",
"prebids",
"highest",
"ad",
"impression",
"partner",
"for",
"that",
"slot",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/liveyieldAnalyticsAdapter.js#L98-L107 |
|
6,173 | prebid/Prebid.js | modules/liveyieldAnalyticsAdapter.js | function(instanceConfig, slot, version) {
const bid = getHighestPrebidBidResponseBySlotTargeting(
instanceConfig,
slot,
version
);
return bid ? bid.cpm : null;
} | javascript | function(instanceConfig, slot, version) {
const bid = getHighestPrebidBidResponseBySlotTargeting(
instanceConfig,
slot,
version
);
return bid ? bid.cpm : null;
} | [
"function",
"(",
"instanceConfig",
",",
"slot",
",",
"version",
")",
"{",
"const",
"bid",
"=",
"getHighestPrebidBidResponseBySlotTargeting",
"(",
"instanceConfig",
",",
"slot",
",",
"version",
")",
";",
"return",
"bid",
"?",
"bid",
".",
"cpm",
":",
"null",
";",
"}"
] | If isPrebidAdImpression decides that slot contain prebid ad impression,
this function should return prebids highest ad impression value for that
slot.
Default implementation uses slot's `hb_adid` targeting value to find
highest bid response and when present then returns `cpm`.
@param instanceConfig merged analytics adapter instance configuration
@param slot the gpt slot for which the highest ad impression value shall be
returned
@param version the version of the prebid.js library | [
"If",
"isPrebidAdImpression",
"decides",
"that",
"slot",
"contain",
"prebid",
"ad",
"impression",
"this",
"function",
"should",
"return",
"prebids",
"highest",
"ad",
"impression",
"value",
"for",
"that",
"slot",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/liveyieldAnalyticsAdapter.js#L122-L130 |
|
6,174 | prebid/Prebid.js | modules/yieldmoBidAdapter.js | function(serverResponse) {
let bids = [];
let data = serverResponse.body;
if (data.length > 0) {
data.forEach((response) => {
if (response.cpm && response.cpm > 0) {
bids.push(createNewBid(response));
}
});
}
return bids;
} | javascript | function(serverResponse) {
let bids = [];
let data = serverResponse.body;
if (data.length > 0) {
data.forEach((response) => {
if (response.cpm && response.cpm > 0) {
bids.push(createNewBid(response));
}
});
}
return bids;
} | [
"function",
"(",
"serverResponse",
")",
"{",
"let",
"bids",
"=",
"[",
"]",
";",
"let",
"data",
"=",
"serverResponse",
".",
"body",
";",
"if",
"(",
"data",
".",
"length",
">",
"0",
")",
"{",
"data",
".",
"forEach",
"(",
"(",
"response",
")",
"=>",
"{",
"if",
"(",
"response",
".",
"cpm",
"&&",
"response",
".",
"cpm",
">",
"0",
")",
"{",
"bids",
".",
"push",
"(",
"createNewBid",
"(",
"response",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"bids",
";",
"}"
] | Makes Yieldmo Ad Server response compatible to Prebid specs
@param serverResponse successful response from Ad Server
@param bidderRequest original bidRequest
@return {Bid[]} an array of bids | [
"Makes",
"Yieldmo",
"Ad",
"Server",
"response",
"compatible",
"to",
"Prebid",
"specs"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/yieldmoBidAdapter.js#L67-L78 |
|
6,175 | prebid/Prebid.js | modules/yieldmoBidAdapter.js | createNewBid | function createNewBid(response) {
return {
requestId: response['callback_id'],
cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.creative_id,
currency: CURRENCY,
netRevenue: NET_REVENUE,
ttl: TIME_TO_LIVE,
ad: response.ad
};
} | javascript | function createNewBid(response) {
return {
requestId: response['callback_id'],
cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.creative_id,
currency: CURRENCY,
netRevenue: NET_REVENUE,
ttl: TIME_TO_LIVE,
ad: response.ad
};
} | [
"function",
"createNewBid",
"(",
"response",
")",
"{",
"return",
"{",
"requestId",
":",
"response",
"[",
"'callback_id'",
"]",
",",
"cpm",
":",
"response",
".",
"cpm",
",",
"width",
":",
"response",
".",
"width",
",",
"height",
":",
"response",
".",
"height",
",",
"creativeId",
":",
"response",
".",
"creative_id",
",",
"currency",
":",
"CURRENCY",
",",
"netRevenue",
":",
"NET_REVENUE",
",",
"ttl",
":",
"TIME_TO_LIVE",
",",
"ad",
":",
"response",
".",
"ad",
"}",
";",
"}"
] | creates a new bid with response information
@param response server response | [
"creates",
"a",
"new",
"bid",
"with",
"response",
"information"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/yieldmoBidAdapter.js#L116-L128 |
6,176 | prebid/Prebid.js | gulpfile.js | viewCoverage | function viewCoverage(done) {
var coveragePort = 1999;
var mylocalhost = (argv.host) ? argv.host : 'localhost';
connect.server({
port: coveragePort,
root: 'build/coverage/karma_html',
livereload: false
});
opens('http://' + mylocalhost + ':' + coveragePort);
done();
} | javascript | function viewCoverage(done) {
var coveragePort = 1999;
var mylocalhost = (argv.host) ? argv.host : 'localhost';
connect.server({
port: coveragePort,
root: 'build/coverage/karma_html',
livereload: false
});
opens('http://' + mylocalhost + ':' + coveragePort);
done();
} | [
"function",
"viewCoverage",
"(",
"done",
")",
"{",
"var",
"coveragePort",
"=",
"1999",
";",
"var",
"mylocalhost",
"=",
"(",
"argv",
".",
"host",
")",
"?",
"argv",
".",
"host",
":",
"'localhost'",
";",
"connect",
".",
"server",
"(",
"{",
"port",
":",
"coveragePort",
",",
"root",
":",
"'build/coverage/karma_html'",
",",
"livereload",
":",
"false",
"}",
")",
";",
"opens",
"(",
"'http://'",
"+",
"mylocalhost",
"+",
"':'",
"+",
"coveragePort",
")",
";",
"done",
"(",
")",
";",
"}"
] | View the code coverage report in the browser. | [
"View",
"the",
"code",
"coverage",
"report",
"in",
"the",
"browser",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/gulpfile.js#L78-L89 |
6,177 | prebid/Prebid.js | gulpfile.js | watch | function watch(done) {
var mainWatcher = gulp.watch([
'src/**/*.js',
'modules/**/*.js',
'test/spec/**/*.js',
'!test/spec/loaders/**/*.js'
]);
var loaderWatcher = gulp.watch([
'loaders/**/*.js',
'test/spec/loaders/**/*.js'
]);
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
});
mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
loaderWatcher.on('all', gulp.series(lint));
done();
} | javascript | function watch(done) {
var mainWatcher = gulp.watch([
'src/**/*.js',
'modules/**/*.js',
'test/spec/**/*.js',
'!test/spec/loaders/**/*.js'
]);
var loaderWatcher = gulp.watch([
'loaders/**/*.js',
'test/spec/loaders/**/*.js'
]);
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
});
mainWatcher.on('all', gulp.series(clean, gulp.parallel(lint, 'build-bundle-dev', test)));
loaderWatcher.on('all', gulp.series(lint));
done();
} | [
"function",
"watch",
"(",
"done",
")",
"{",
"var",
"mainWatcher",
"=",
"gulp",
".",
"watch",
"(",
"[",
"'src/**/*.js'",
",",
"'modules/**/*.js'",
",",
"'test/spec/**/*.js'",
",",
"'!test/spec/loaders/**/*.js'",
"]",
")",
";",
"var",
"loaderWatcher",
"=",
"gulp",
".",
"watch",
"(",
"[",
"'loaders/**/*.js'",
",",
"'test/spec/loaders/**/*.js'",
"]",
")",
";",
"connect",
".",
"server",
"(",
"{",
"https",
":",
"argv",
".",
"https",
",",
"port",
":",
"port",
",",
"root",
":",
"'./'",
",",
"livereload",
":",
"true",
"}",
")",
";",
"mainWatcher",
".",
"on",
"(",
"'all'",
",",
"gulp",
".",
"series",
"(",
"clean",
",",
"gulp",
".",
"parallel",
"(",
"lint",
",",
"'build-bundle-dev'",
",",
"test",
")",
")",
")",
";",
"loaderWatcher",
".",
"on",
"(",
"'all'",
",",
"gulp",
".",
"series",
"(",
"lint",
")",
")",
";",
"done",
"(",
")",
";",
"}"
] | Watch Task with Live Reload | [
"Watch",
"Task",
"with",
"Live",
"Reload"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/gulpfile.js#L94-L116 |
6,178 | prebid/Prebid.js | src/adUnits.js | incrementCounter | function incrementCounter(adunit) {
adUnits[adunit] = adUnits[adunit] || {};
adUnits[adunit].counter = (deepAccess(adUnits, `${adunit}.counter`) + 1) || 1;
return adUnits[adunit].counter;
} | javascript | function incrementCounter(adunit) {
adUnits[adunit] = adUnits[adunit] || {};
adUnits[adunit].counter = (deepAccess(adUnits, `${adunit}.counter`) + 1) || 1;
return adUnits[adunit].counter;
} | [
"function",
"incrementCounter",
"(",
"adunit",
")",
"{",
"adUnits",
"[",
"adunit",
"]",
"=",
"adUnits",
"[",
"adunit",
"]",
"||",
"{",
"}",
";",
"adUnits",
"[",
"adunit",
"]",
".",
"counter",
"=",
"(",
"deepAccess",
"(",
"adUnits",
",",
"`",
"${",
"adunit",
"}",
"`",
")",
"+",
"1",
")",
"||",
"1",
";",
"return",
"adUnits",
"[",
"adunit",
"]",
".",
"counter",
";",
"}"
] | Increments and returns current Adunit counter
@param {string} adunit id
@returns {number} current adunit count | [
"Increments",
"and",
"returns",
"current",
"Adunit",
"counter"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/adUnits.js#L10-L14 |
6,179 | prebid/Prebid.js | modules/brainyBidAdapter.js | _getFlash | function _getFlash() {
try {
var _mac = (navigator.userAgent.indexOf('Mac') != -1);
if (document.all) {
if (_mac) {
if (window['sample']) {
return ((window['sample'].FlashVersion() & 0xffff0000) >> 16);
}
} else {
var _axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
return Math.floor(_axo.FlashVersion() / 0x10000);
}
} else {
if (navigator.plugins && navigator.plugins['Shockwave Flash']) {
var info = navigator.plugins['Shockwave Flash'].description.split(' ');
var _v = parseInt(info[2]);
if (!isNaN(_v)) {
return _v;
}
}
}
} catch (e) {}
return 0;
} | javascript | function _getFlash() {
try {
var _mac = (navigator.userAgent.indexOf('Mac') != -1);
if (document.all) {
if (_mac) {
if (window['sample']) {
return ((window['sample'].FlashVersion() & 0xffff0000) >> 16);
}
} else {
var _axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
return Math.floor(_axo.FlashVersion() / 0x10000);
}
} else {
if (navigator.plugins && navigator.plugins['Shockwave Flash']) {
var info = navigator.plugins['Shockwave Flash'].description.split(' ');
var _v = parseInt(info[2]);
if (!isNaN(_v)) {
return _v;
}
}
}
} catch (e) {}
return 0;
} | [
"function",
"_getFlash",
"(",
")",
"{",
"try",
"{",
"var",
"_mac",
"=",
"(",
"navigator",
".",
"userAgent",
".",
"indexOf",
"(",
"'Mac'",
")",
"!=",
"-",
"1",
")",
";",
"if",
"(",
"document",
".",
"all",
")",
"{",
"if",
"(",
"_mac",
")",
"{",
"if",
"(",
"window",
"[",
"'sample'",
"]",
")",
"{",
"return",
"(",
"(",
"window",
"[",
"'sample'",
"]",
".",
"FlashVersion",
"(",
")",
"&",
"0xffff0000",
")",
">>",
"16",
")",
";",
"}",
"}",
"else",
"{",
"var",
"_axo",
"=",
"new",
"ActiveXObject",
"(",
"'ShockwaveFlash.ShockwaveFlash'",
")",
";",
"return",
"Math",
".",
"floor",
"(",
"_axo",
".",
"FlashVersion",
"(",
")",
"/",
"0x10000",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"navigator",
".",
"plugins",
"&&",
"navigator",
".",
"plugins",
"[",
"'Shockwave Flash'",
"]",
")",
"{",
"var",
"info",
"=",
"navigator",
".",
"plugins",
"[",
"'Shockwave Flash'",
"]",
".",
"description",
".",
"split",
"(",
"' '",
")",
";",
"var",
"_v",
"=",
"parseInt",
"(",
"info",
"[",
"2",
"]",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"_v",
")",
")",
"{",
"return",
"_v",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"return",
"0",
";",
"}"
] | Check if the browser supports flash
0 is return if it dosen't support flash
@return {int} Flash version
接続元のブラウザがフラッシュに対応しているか判定
対応していなければ0を返す
@return {int} フラッシュのバージョン | [
"Check",
"if",
"the",
"browser",
"supports",
"flash",
"0",
"is",
"return",
"if",
"it",
"dosen",
"t",
"support",
"flash"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/brainyBidAdapter.js#L18-L41 |
6,180 | prebid/Prebid.js | modules/brainyBidAdapter.js | function(bid) {
return !!(bid && bid.params && bid.params.accountID && bid.params.slotID);
} | javascript | function(bid) {
return !!(bid && bid.params && bid.params.accountID && bid.params.slotID);
} | [
"function",
"(",
"bid",
")",
"{",
"return",
"!",
"!",
"(",
"bid",
"&&",
"bid",
".",
"params",
"&&",
"bid",
".",
"params",
".",
"accountID",
"&&",
"bid",
".",
"params",
".",
"slotID",
")",
";",
"}"
] | Check if the bid account ID and slotID is valid
@param {object} bid the brainy bid to validate
@return {boolean}
adUnits.bidに値が入っているかを判断する
@param {object} bid 検証する入札リクエスト
@return {boolean} | [
"Check",
"if",
"the",
"bid",
"account",
"ID",
"and",
"slotID",
"is",
"valid"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/brainyBidAdapter.js#L57-L59 |
|
6,181 | prebid/Prebid.js | modules/brainyBidAdapter.js | function(validBidRequests) {
var bidRequests = [];
for (var i = 0, len = validBidRequests.length; i < len; i++) {
var bid = validBidRequests[i];
var accountID = utils.getBidIdParameter('accountID', bid.params);
var slotID = utils.getBidIdParameter('slotID', bid.params);
var url = utils.getTopWindowUrl();
var flash = _getFlash();
var nocache = new Date().getTime() + Math.floor(Math.random() * 100000000);
var requestURL;
requestURL = '_aid=' + accountID + '&';
requestURL += '_slot=' + slotID + '&';
requestURL += '_url=' + url + '&';
requestURL += '_flash=' + flash + '&';
requestURL += '_nocache=' + nocache;
bidRequests.push({
method: 'GET',
url: BASE_URL,
data: requestURL,
bidRequest: bid
})
}
return bidRequests;
} | javascript | function(validBidRequests) {
var bidRequests = [];
for (var i = 0, len = validBidRequests.length; i < len; i++) {
var bid = validBidRequests[i];
var accountID = utils.getBidIdParameter('accountID', bid.params);
var slotID = utils.getBidIdParameter('slotID', bid.params);
var url = utils.getTopWindowUrl();
var flash = _getFlash();
var nocache = new Date().getTime() + Math.floor(Math.random() * 100000000);
var requestURL;
requestURL = '_aid=' + accountID + '&';
requestURL += '_slot=' + slotID + '&';
requestURL += '_url=' + url + '&';
requestURL += '_flash=' + flash + '&';
requestURL += '_nocache=' + nocache;
bidRequests.push({
method: 'GET',
url: BASE_URL,
data: requestURL,
bidRequest: bid
})
}
return bidRequests;
} | [
"function",
"(",
"validBidRequests",
")",
"{",
"var",
"bidRequests",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"validBidRequests",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"bid",
"=",
"validBidRequests",
"[",
"i",
"]",
";",
"var",
"accountID",
"=",
"utils",
".",
"getBidIdParameter",
"(",
"'accountID'",
",",
"bid",
".",
"params",
")",
";",
"var",
"slotID",
"=",
"utils",
".",
"getBidIdParameter",
"(",
"'slotID'",
",",
"bid",
".",
"params",
")",
";",
"var",
"url",
"=",
"utils",
".",
"getTopWindowUrl",
"(",
")",
";",
"var",
"flash",
"=",
"_getFlash",
"(",
")",
";",
"var",
"nocache",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"+",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"100000000",
")",
";",
"var",
"requestURL",
";",
"requestURL",
"=",
"'_aid='",
"+",
"accountID",
"+",
"'&'",
";",
"requestURL",
"+=",
"'_slot='",
"+",
"slotID",
"+",
"'&'",
";",
"requestURL",
"+=",
"'_url='",
"+",
"url",
"+",
"'&'",
";",
"requestURL",
"+=",
"'_flash='",
"+",
"flash",
"+",
"'&'",
";",
"requestURL",
"+=",
"'_nocache='",
"+",
"nocache",
";",
"bidRequests",
".",
"push",
"(",
"{",
"method",
":",
"'GET'",
",",
"url",
":",
"BASE_URL",
",",
"data",
":",
"requestURL",
",",
"bidRequest",
":",
"bid",
"}",
")",
"}",
"return",
"bidRequests",
";",
"}"
] | Format the bid request object for our endpoint
@param {BidRequest[]} bidRequests Array of brainy bidders
@return object of parameters for Prebid AJAX request
入札リクエストをbrainyに対応するように整形する
@param {BidRequest[]} bidRequests 入札のための配列
@return Prebid AJAX用に整形したオブジェクト | [
"Format",
"the",
"bid",
"request",
"object",
"for",
"our",
"endpoint"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/brainyBidAdapter.js#L71-L96 |
|
6,182 | prebid/Prebid.js | modules/brainyBidAdapter.js | function (brainyResponseObj, request) {
var bidResponses = [];
var bidRequest = request.bidRequest;
var responseBody = brainyResponseObj ? brainyResponseObj.body : {};
bidResponses.push({
requestId: bidRequest.bidId,
cpm: responseBody.cpm || 0,
width: responseBody.width,
height: responseBody.height,
creativeId: responseBody.adID,
currency: 'USD',
netRevenue: true,
ttl: 1000,
mediaType: BANNER,
ad: responseBody.src
});
return bidResponses;
} | javascript | function (brainyResponseObj, request) {
var bidResponses = [];
var bidRequest = request.bidRequest;
var responseBody = brainyResponseObj ? brainyResponseObj.body : {};
bidResponses.push({
requestId: bidRequest.bidId,
cpm: responseBody.cpm || 0,
width: responseBody.width,
height: responseBody.height,
creativeId: responseBody.adID,
currency: 'USD',
netRevenue: true,
ttl: 1000,
mediaType: BANNER,
ad: responseBody.src
});
return bidResponses;
} | [
"function",
"(",
"brainyResponseObj",
",",
"request",
")",
"{",
"var",
"bidResponses",
"=",
"[",
"]",
";",
"var",
"bidRequest",
"=",
"request",
".",
"bidRequest",
";",
"var",
"responseBody",
"=",
"brainyResponseObj",
"?",
"brainyResponseObj",
".",
"body",
":",
"{",
"}",
";",
"bidResponses",
".",
"push",
"(",
"{",
"requestId",
":",
"bidRequest",
".",
"bidId",
",",
"cpm",
":",
"responseBody",
".",
"cpm",
"||",
"0",
",",
"width",
":",
"responseBody",
".",
"width",
",",
"height",
":",
"responseBody",
".",
"height",
",",
"creativeId",
":",
"responseBody",
".",
"adID",
",",
"currency",
":",
"'USD'",
",",
"netRevenue",
":",
"true",
",",
"ttl",
":",
"1000",
",",
"mediaType",
":",
"BANNER",
",",
"ad",
":",
"responseBody",
".",
"src",
"}",
")",
";",
"return",
"bidResponses",
";",
"}"
] | Format brainy responses as Prebid bid responses
@param {String} brainyResponseObj A successful response from brainy.
@param {object} request Object received from web page
@return {object} An array of formatted bids.
brainySSPからのレスポンスを解釈するメソッド
@param {String} brainyResponseObj SSPから受け取った文字列
@param {object} request メディアから受け取ったオブジェクト
@return {object} 分解、再格納したbidResponses | [
"Format",
"brainy",
"responses",
"as",
"Prebid",
"bid",
"responses"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/brainyBidAdapter.js#L110-L129 |
|
6,183 | prebid/Prebid.js | modules/onetagBidAdapter.js | getPageInfo | function getPageInfo() {
var w, d, l, r, m, p, e, t, s;
for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, e = encodeURIComponent, t = new Date(), s = screen; w !== w.parent;) {
try {
p = w.parent; l = p.location.href; r = p.document.referrer; w = p;
} catch (e) {
m = top !== w.parent ? 2 : 1;
break
}
}
const params = {
location: e(l),
referrer: e(r) || '0',
masked: m,
wWidth: w.innerWidth,
wHeight: w.innerHeight,
sWidth: s.width,
sHeight: s.height,
date: t.toUTCString(),
timeOffset: t.getTimezoneOffset()
};
return params;
} | javascript | function getPageInfo() {
var w, d, l, r, m, p, e, t, s;
for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, e = encodeURIComponent, t = new Date(), s = screen; w !== w.parent;) {
try {
p = w.parent; l = p.location.href; r = p.document.referrer; w = p;
} catch (e) {
m = top !== w.parent ? 2 : 1;
break
}
}
const params = {
location: e(l),
referrer: e(r) || '0',
masked: m,
wWidth: w.innerWidth,
wHeight: w.innerHeight,
sWidth: s.width,
sHeight: s.height,
date: t.toUTCString(),
timeOffset: t.getTimezoneOffset()
};
return params;
} | [
"function",
"getPageInfo",
"(",
")",
"{",
"var",
"w",
",",
"d",
",",
"l",
",",
"r",
",",
"m",
",",
"p",
",",
"e",
",",
"t",
",",
"s",
";",
"for",
"(",
"w",
"=",
"window",
",",
"d",
"=",
"w",
".",
"document",
",",
"l",
"=",
"d",
".",
"location",
".",
"href",
",",
"r",
"=",
"d",
".",
"referrer",
",",
"m",
"=",
"0",
",",
"e",
"=",
"encodeURIComponent",
",",
"t",
"=",
"new",
"Date",
"(",
")",
",",
"s",
"=",
"screen",
";",
"w",
"!==",
"w",
".",
"parent",
";",
")",
"{",
"try",
"{",
"p",
"=",
"w",
".",
"parent",
";",
"l",
"=",
"p",
".",
"location",
".",
"href",
";",
"r",
"=",
"p",
".",
"document",
".",
"referrer",
";",
"w",
"=",
"p",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"m",
"=",
"top",
"!==",
"w",
".",
"parent",
"?",
"2",
":",
"1",
";",
"break",
"}",
"}",
"const",
"params",
"=",
"{",
"location",
":",
"e",
"(",
"l",
")",
",",
"referrer",
":",
"e",
"(",
"r",
")",
"||",
"'0'",
",",
"masked",
":",
"m",
",",
"wWidth",
":",
"w",
".",
"innerWidth",
",",
"wHeight",
":",
"w",
".",
"innerHeight",
",",
"sWidth",
":",
"s",
".",
"width",
",",
"sHeight",
":",
"s",
".",
"height",
",",
"date",
":",
"t",
".",
"toUTCString",
"(",
")",
",",
"timeOffset",
":",
"t",
".",
"getTimezoneOffset",
"(",
")",
"}",
";",
"return",
"params",
";",
"}"
] | Returns information about the page needed by the server in an object to be converted in JSON
@returns {{location: *, referrer: (*|string), masked: *, wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} | [
"Returns",
"information",
"about",
"the",
"page",
"needed",
"by",
"the",
"server",
"in",
"an",
"object",
"to",
"be",
"converted",
"in",
"JSON"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/onetagBidAdapter.js#L105-L130 |
6,184 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | bidResponseAvailable | function bidResponseAvailable(bidRequest, bidResponse) {
const idToImpMap = {};
const idToBidMap = {};
bidResponse = bidResponse.body
// extract the request bids and the response bids, keyed by impr-id
const ortbRequest = parse(bidRequest.data);
ortbRequest.imp.forEach(imp => {
idToImpMap[imp.id] = imp;
});
if (bidResponse) {
bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => {
idToBidMap[bid.impid] = bid;
}));
}
const bids = [];
Object.keys(idToImpMap).forEach(id => {
if (idToBidMap[id]) {
const bid = {
requestId: id,
cpm: idToBidMap[id].price,
creative_id: idToBidMap[id].crid,
creativeId: idToBidMap[id].crid,
adId: id,
ttl: DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
bid.mediaType = 'native';
} else {
bid.ad = idToBidMap[id].adm;
bid.width = idToImpMap[id].banner.w;
bid.height = idToImpMap[id].banner.h;
}
applyExt(bid, idToBidMap[id])
bids.push(bid);
}
});
return bids;
} | javascript | function bidResponseAvailable(bidRequest, bidResponse) {
const idToImpMap = {};
const idToBidMap = {};
bidResponse = bidResponse.body
// extract the request bids and the response bids, keyed by impr-id
const ortbRequest = parse(bidRequest.data);
ortbRequest.imp.forEach(imp => {
idToImpMap[imp.id] = imp;
});
if (bidResponse) {
bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => {
idToBidMap[bid.impid] = bid;
}));
}
const bids = [];
Object.keys(idToImpMap).forEach(id => {
if (idToBidMap[id]) {
const bid = {
requestId: id,
cpm: idToBidMap[id].price,
creative_id: idToBidMap[id].crid,
creativeId: idToBidMap[id].crid,
adId: id,
ttl: DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
bid.mediaType = 'native';
} else {
bid.ad = idToBidMap[id].adm;
bid.width = idToImpMap[id].banner.w;
bid.height = idToImpMap[id].banner.h;
}
applyExt(bid, idToBidMap[id])
bids.push(bid);
}
});
return bids;
} | [
"function",
"bidResponseAvailable",
"(",
"bidRequest",
",",
"bidResponse",
")",
"{",
"const",
"idToImpMap",
"=",
"{",
"}",
";",
"const",
"idToBidMap",
"=",
"{",
"}",
";",
"bidResponse",
"=",
"bidResponse",
".",
"body",
"// extract the request bids and the response bids, keyed by impr-id",
"const",
"ortbRequest",
"=",
"parse",
"(",
"bidRequest",
".",
"data",
")",
";",
"ortbRequest",
".",
"imp",
".",
"forEach",
"(",
"imp",
"=>",
"{",
"idToImpMap",
"[",
"imp",
".",
"id",
"]",
"=",
"imp",
";",
"}",
")",
";",
"if",
"(",
"bidResponse",
")",
"{",
"bidResponse",
".",
"seatbid",
".",
"forEach",
"(",
"seatBid",
"=>",
"seatBid",
".",
"bid",
".",
"forEach",
"(",
"bid",
"=>",
"{",
"idToBidMap",
"[",
"bid",
".",
"impid",
"]",
"=",
"bid",
";",
"}",
")",
")",
";",
"}",
"const",
"bids",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"idToImpMap",
")",
".",
"forEach",
"(",
"id",
"=>",
"{",
"if",
"(",
"idToBidMap",
"[",
"id",
"]",
")",
"{",
"const",
"bid",
"=",
"{",
"requestId",
":",
"id",
",",
"cpm",
":",
"idToBidMap",
"[",
"id",
"]",
".",
"price",
",",
"creative_id",
":",
"idToBidMap",
"[",
"id",
"]",
".",
"crid",
",",
"creativeId",
":",
"idToBidMap",
"[",
"id",
"]",
".",
"crid",
",",
"adId",
":",
"id",
",",
"ttl",
":",
"DEFAULT_BID_TTL",
",",
"netRevenue",
":",
"DEFAULT_NET_REVENUE",
",",
"currency",
":",
"DEFAULT_CURRENCY",
"}",
";",
"if",
"(",
"idToImpMap",
"[",
"id",
"]",
"[",
"'native'",
"]",
")",
"{",
"bid",
"[",
"'native'",
"]",
"=",
"nativeResponse",
"(",
"idToImpMap",
"[",
"id",
"]",
",",
"idToBidMap",
"[",
"id",
"]",
")",
";",
"bid",
".",
"mediaType",
"=",
"'native'",
";",
"}",
"else",
"{",
"bid",
".",
"ad",
"=",
"idToBidMap",
"[",
"id",
"]",
".",
"adm",
";",
"bid",
".",
"width",
"=",
"idToImpMap",
"[",
"id",
"]",
".",
"banner",
".",
"w",
";",
"bid",
".",
"height",
"=",
"idToImpMap",
"[",
"id",
"]",
".",
"banner",
".",
"h",
";",
"}",
"applyExt",
"(",
"bid",
",",
"idToBidMap",
"[",
"id",
"]",
")",
"bids",
".",
"push",
"(",
"bid",
")",
";",
"}",
"}",
")",
";",
"return",
"bids",
";",
"}"
] | Callback for bids, after the call to PulsePoint completes. | [
"Callback",
"for",
"bids",
"after",
"the",
"call",
"to",
"PulsePoint",
"completes",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L82-L122 |
6,185 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | impression | function impression(slot) {
return {
id: slot.bidId,
banner: banner(slot),
'native': nativeImpression(slot),
tagid: slot.params.ct.toString(),
};
} | javascript | function impression(slot) {
return {
id: slot.bidId,
banner: banner(slot),
'native': nativeImpression(slot),
tagid: slot.params.ct.toString(),
};
} | [
"function",
"impression",
"(",
"slot",
")",
"{",
"return",
"{",
"id",
":",
"slot",
".",
"bidId",
",",
"banner",
":",
"banner",
"(",
"slot",
")",
",",
"'native'",
":",
"nativeImpression",
"(",
"slot",
")",
",",
"tagid",
":",
"slot",
".",
"params",
".",
"ct",
".",
"toString",
"(",
")",
",",
"}",
";",
"}"
] | Produces an OpenRTBImpression from a slot config. | [
"Produces",
"an",
"OpenRTBImpression",
"from",
"a",
"slot",
"config",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L135-L142 |
6,186 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | banner | function banner(slot) {
const size = adSize(slot);
return slot.nativeParams ? null : {
w: size[0],
h: size[1],
};
} | javascript | function banner(slot) {
const size = adSize(slot);
return slot.nativeParams ? null : {
w: size[0],
h: size[1],
};
} | [
"function",
"banner",
"(",
"slot",
")",
"{",
"const",
"size",
"=",
"adSize",
"(",
"slot",
")",
";",
"return",
"slot",
".",
"nativeParams",
"?",
"null",
":",
"{",
"w",
":",
"size",
"[",
"0",
"]",
",",
"h",
":",
"size",
"[",
"1",
"]",
",",
"}",
";",
"}"
] | Produces an OpenRTB Banner object for the slot given. | [
"Produces",
"an",
"OpenRTB",
"Banner",
"object",
"for",
"the",
"slot",
"given",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L147-L153 |
6,187 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | site | function site(bidderRequest) {
const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0';
const appParams = bidderRequest[0].params.app;
if (!appParams) {
return {
publisher: {
id: pubId.toString(),
},
ref: referrer(),
page: utils.getTopWindowLocation().href,
}
}
return null;
} | javascript | function site(bidderRequest) {
const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0';
const appParams = bidderRequest[0].params.app;
if (!appParams) {
return {
publisher: {
id: pubId.toString(),
},
ref: referrer(),
page: utils.getTopWindowLocation().href,
}
}
return null;
} | [
"function",
"site",
"(",
"bidderRequest",
")",
"{",
"const",
"pubId",
"=",
"bidderRequest",
"&&",
"bidderRequest",
".",
"length",
">",
"0",
"?",
"bidderRequest",
"[",
"0",
"]",
".",
"params",
".",
"cp",
":",
"'0'",
";",
"const",
"appParams",
"=",
"bidderRequest",
"[",
"0",
"]",
".",
"params",
".",
"app",
";",
"if",
"(",
"!",
"appParams",
")",
"{",
"return",
"{",
"publisher",
":",
"{",
"id",
":",
"pubId",
".",
"toString",
"(",
")",
",",
"}",
",",
"ref",
":",
"referrer",
"(",
")",
",",
"page",
":",
"utils",
".",
"getTopWindowLocation",
"(",
")",
".",
"href",
",",
"}",
"}",
"return",
"null",
";",
"}"
] | Produces an OpenRTB site object. | [
"Produces",
"an",
"OpenRTB",
"site",
"object",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L231-L244 |
6,188 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | app | function app(bidderRequest) {
const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0';
const appParams = bidderRequest[0].params.app;
if (appParams) {
return {
publisher: {
id: pubId.toString(),
},
bundle: appParams.bundle,
storeurl: appParams.storeUrl,
domain: appParams.domain,
}
}
return null;
} | javascript | function app(bidderRequest) {
const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0';
const appParams = bidderRequest[0].params.app;
if (appParams) {
return {
publisher: {
id: pubId.toString(),
},
bundle: appParams.bundle,
storeurl: appParams.storeUrl,
domain: appParams.domain,
}
}
return null;
} | [
"function",
"app",
"(",
"bidderRequest",
")",
"{",
"const",
"pubId",
"=",
"bidderRequest",
"&&",
"bidderRequest",
".",
"length",
">",
"0",
"?",
"bidderRequest",
"[",
"0",
"]",
".",
"params",
".",
"cp",
":",
"'0'",
";",
"const",
"appParams",
"=",
"bidderRequest",
"[",
"0",
"]",
".",
"params",
".",
"app",
";",
"if",
"(",
"appParams",
")",
"{",
"return",
"{",
"publisher",
":",
"{",
"id",
":",
"pubId",
".",
"toString",
"(",
")",
",",
"}",
",",
"bundle",
":",
"appParams",
".",
"bundle",
",",
"storeurl",
":",
"appParams",
".",
"storeUrl",
",",
"domain",
":",
"appParams",
".",
"domain",
",",
"}",
"}",
"return",
"null",
";",
"}"
] | Produces an OpenRTB App object. | [
"Produces",
"an",
"OpenRTB",
"App",
"object",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L249-L263 |
6,189 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | device | function device() {
return {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
} | javascript | function device() {
return {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
} | [
"function",
"device",
"(",
")",
"{",
"return",
"{",
"ua",
":",
"navigator",
".",
"userAgent",
",",
"language",
":",
"(",
"navigator",
".",
"language",
"||",
"navigator",
".",
"browserLanguage",
"||",
"navigator",
".",
"userLanguage",
"||",
"navigator",
".",
"systemLanguage",
")",
",",
"}",
";",
"}"
] | Produces an OpenRTB Device object. | [
"Produces",
"an",
"OpenRTB",
"Device",
"object",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L279-L284 |
6,190 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | parse | function parse(rawResponse) {
try {
if (rawResponse) {
return JSON.parse(rawResponse);
}
} catch (ex) {
utils.logError('pulsepointLite.safeParse', 'ERROR', ex);
}
return null;
} | javascript | function parse(rawResponse) {
try {
if (rawResponse) {
return JSON.parse(rawResponse);
}
} catch (ex) {
utils.logError('pulsepointLite.safeParse', 'ERROR', ex);
}
return null;
} | [
"function",
"parse",
"(",
"rawResponse",
")",
"{",
"try",
"{",
"if",
"(",
"rawResponse",
")",
"{",
"return",
"JSON",
".",
"parse",
"(",
"rawResponse",
")",
";",
"}",
"}",
"catch",
"(",
"ex",
")",
"{",
"utils",
".",
"logError",
"(",
"'pulsepointLite.safeParse'",
",",
"'ERROR'",
",",
"ex",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Safely parses the input given. Returns null on
parsing failure. | [
"Safely",
"parses",
"the",
"input",
"given",
".",
"Returns",
"null",
"on",
"parsing",
"failure",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L290-L299 |
6,191 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | adSize | function adSize(slot) {
if (slot.params.cf) {
const size = slot.params.cf.toUpperCase().split('X');
const width = parseInt(slot.params.cw || size[0], 10);
const height = parseInt(slot.params.ch || size[1], 10);
return [width, height];
}
return [1, 1];
} | javascript | function adSize(slot) {
if (slot.params.cf) {
const size = slot.params.cf.toUpperCase().split('X');
const width = parseInt(slot.params.cw || size[0], 10);
const height = parseInt(slot.params.ch || size[1], 10);
return [width, height];
}
return [1, 1];
} | [
"function",
"adSize",
"(",
"slot",
")",
"{",
"if",
"(",
"slot",
".",
"params",
".",
"cf",
")",
"{",
"const",
"size",
"=",
"slot",
".",
"params",
".",
"cf",
".",
"toUpperCase",
"(",
")",
".",
"split",
"(",
"'X'",
")",
";",
"const",
"width",
"=",
"parseInt",
"(",
"slot",
".",
"params",
".",
"cw",
"||",
"size",
"[",
"0",
"]",
",",
"10",
")",
";",
"const",
"height",
"=",
"parseInt",
"(",
"slot",
".",
"params",
".",
"ch",
"||",
"size",
"[",
"1",
"]",
",",
"10",
")",
";",
"return",
"[",
"width",
",",
"height",
"]",
";",
"}",
"return",
"[",
"1",
",",
"1",
"]",
";",
"}"
] | Determines the AdSize for the slot. | [
"Determines",
"the",
"AdSize",
"for",
"the",
"slot",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L304-L312 |
6,192 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | applyGdpr | function applyGdpr(bidderRequest, ortbRequest) {
if (bidderRequest && bidderRequest.gdprConsent) {
ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } };
ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } };
}
} | javascript | function applyGdpr(bidderRequest, ortbRequest) {
if (bidderRequest && bidderRequest.gdprConsent) {
ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } };
ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } };
}
} | [
"function",
"applyGdpr",
"(",
"bidderRequest",
",",
"ortbRequest",
")",
"{",
"if",
"(",
"bidderRequest",
"&&",
"bidderRequest",
".",
"gdprConsent",
")",
"{",
"ortbRequest",
".",
"regs",
"=",
"{",
"ext",
":",
"{",
"gdpr",
":",
"bidderRequest",
".",
"gdprConsent",
".",
"gdprApplies",
"?",
"1",
":",
"0",
"}",
"}",
";",
"ortbRequest",
".",
"user",
"=",
"{",
"ext",
":",
"{",
"consent",
":",
"bidderRequest",
".",
"gdprConsent",
".",
"consentString",
"}",
"}",
";",
"}",
"}"
] | Applies GDPR parameters to request. | [
"Applies",
"GDPR",
"parameters",
"to",
"request",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L317-L322 |
6,193 | prebid/Prebid.js | modules/pulsepointBidAdapter.js | nativeResponse | function nativeResponse(imp, bid) {
if (imp['native']) {
const nativeAd = parse(bid.adm);
const keys = {};
if (nativeAd && nativeAd['native'] && nativeAd['native'].assets) {
nativeAd['native'].assets.forEach(asset => {
keys.title = asset.title ? asset.title.text : keys.title;
keys.body = asset.data && asset.data.type === 2 ? asset.data.value : keys.body;
keys.sponsoredBy = asset.data && asset.data.type === 1 ? asset.data.value : keys.sponsoredBy;
keys.image = asset.img && asset.img.type === 3 ? asset.img.url : keys.image;
keys.icon = asset.img && asset.img.type === 1 ? asset.img.url : keys.icon;
});
if (nativeAd['native'].link) {
keys.clickUrl = encodeURIComponent(nativeAd['native'].link.url);
}
keys.impressionTrackers = nativeAd['native'].imptrackers;
return keys;
}
}
return null;
} | javascript | function nativeResponse(imp, bid) {
if (imp['native']) {
const nativeAd = parse(bid.adm);
const keys = {};
if (nativeAd && nativeAd['native'] && nativeAd['native'].assets) {
nativeAd['native'].assets.forEach(asset => {
keys.title = asset.title ? asset.title.text : keys.title;
keys.body = asset.data && asset.data.type === 2 ? asset.data.value : keys.body;
keys.sponsoredBy = asset.data && asset.data.type === 1 ? asset.data.value : keys.sponsoredBy;
keys.image = asset.img && asset.img.type === 3 ? asset.img.url : keys.image;
keys.icon = asset.img && asset.img.type === 1 ? asset.img.url : keys.icon;
});
if (nativeAd['native'].link) {
keys.clickUrl = encodeURIComponent(nativeAd['native'].link.url);
}
keys.impressionTrackers = nativeAd['native'].imptrackers;
return keys;
}
}
return null;
} | [
"function",
"nativeResponse",
"(",
"imp",
",",
"bid",
")",
"{",
"if",
"(",
"imp",
"[",
"'native'",
"]",
")",
"{",
"const",
"nativeAd",
"=",
"parse",
"(",
"bid",
".",
"adm",
")",
";",
"const",
"keys",
"=",
"{",
"}",
";",
"if",
"(",
"nativeAd",
"&&",
"nativeAd",
"[",
"'native'",
"]",
"&&",
"nativeAd",
"[",
"'native'",
"]",
".",
"assets",
")",
"{",
"nativeAd",
"[",
"'native'",
"]",
".",
"assets",
".",
"forEach",
"(",
"asset",
"=>",
"{",
"keys",
".",
"title",
"=",
"asset",
".",
"title",
"?",
"asset",
".",
"title",
".",
"text",
":",
"keys",
".",
"title",
";",
"keys",
".",
"body",
"=",
"asset",
".",
"data",
"&&",
"asset",
".",
"data",
".",
"type",
"===",
"2",
"?",
"asset",
".",
"data",
".",
"value",
":",
"keys",
".",
"body",
";",
"keys",
".",
"sponsoredBy",
"=",
"asset",
".",
"data",
"&&",
"asset",
".",
"data",
".",
"type",
"===",
"1",
"?",
"asset",
".",
"data",
".",
"value",
":",
"keys",
".",
"sponsoredBy",
";",
"keys",
".",
"image",
"=",
"asset",
".",
"img",
"&&",
"asset",
".",
"img",
".",
"type",
"===",
"3",
"?",
"asset",
".",
"img",
".",
"url",
":",
"keys",
".",
"image",
";",
"keys",
".",
"icon",
"=",
"asset",
".",
"img",
"&&",
"asset",
".",
"img",
".",
"type",
"===",
"1",
"?",
"asset",
".",
"img",
".",
"url",
":",
"keys",
".",
"icon",
";",
"}",
")",
";",
"if",
"(",
"nativeAd",
"[",
"'native'",
"]",
".",
"link",
")",
"{",
"keys",
".",
"clickUrl",
"=",
"encodeURIComponent",
"(",
"nativeAd",
"[",
"'native'",
"]",
".",
"link",
".",
"url",
")",
";",
"}",
"keys",
".",
"impressionTrackers",
"=",
"nativeAd",
"[",
"'native'",
"]",
".",
"imptrackers",
";",
"return",
"keys",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Parses the native response from the Bid given. | [
"Parses",
"the",
"native",
"response",
"from",
"the",
"Bid",
"given",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/pulsepointBidAdapter.js#L327-L347 |
6,194 | prebid/Prebid.js | modules/33acrossBidAdapter.js | _createBidResponse | function _createBidResponse(response) {
return {
requestId: response.id,
bidderCode: BIDDER_CODE,
cpm: response.seatbid[0].bid[0].price,
width: response.seatbid[0].bid[0].w,
height: response.seatbid[0].bid[0].h,
ad: response.seatbid[0].bid[0].adm,
ttl: response.seatbid[0].bid[0].ttl || 60,
creativeId: response.seatbid[0].bid[0].crid,
currency: response.cur,
netRevenue: true
}
} | javascript | function _createBidResponse(response) {
return {
requestId: response.id,
bidderCode: BIDDER_CODE,
cpm: response.seatbid[0].bid[0].price,
width: response.seatbid[0].bid[0].w,
height: response.seatbid[0].bid[0].h,
ad: response.seatbid[0].bid[0].adm,
ttl: response.seatbid[0].bid[0].ttl || 60,
creativeId: response.seatbid[0].bid[0].crid,
currency: response.cur,
netRevenue: true
}
} | [
"function",
"_createBidResponse",
"(",
"response",
")",
"{",
"return",
"{",
"requestId",
":",
"response",
".",
"id",
",",
"bidderCode",
":",
"BIDDER_CODE",
",",
"cpm",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"price",
",",
"width",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"w",
",",
"height",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"h",
",",
"ad",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"adm",
",",
"ttl",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"ttl",
"||",
"60",
",",
"creativeId",
":",
"response",
".",
"seatbid",
"[",
"0",
"]",
".",
"bid",
"[",
"0",
"]",
".",
"crid",
",",
"currency",
":",
"response",
".",
"cur",
",",
"netRevenue",
":",
"true",
"}",
"}"
] | All this assumes that only one bid is ever returned by ttx | [
"All",
"this",
"assumes",
"that",
"only",
"one",
"bid",
"is",
"ever",
"returned",
"by",
"ttx"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/33acrossBidAdapter.js#L15-L28 |
6,195 | prebid/Prebid.js | modules/33acrossBidAdapter.js | _createSync | function _createSync(siteId) {
const ttxSettings = config.getConfig('ttxSettings');
const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT;
return {
type: 'iframe',
url: `${syncUrl}&id=${siteId}`
}
} | javascript | function _createSync(siteId) {
const ttxSettings = config.getConfig('ttxSettings');
const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT;
return {
type: 'iframe',
url: `${syncUrl}&id=${siteId}`
}
} | [
"function",
"_createSync",
"(",
"siteId",
")",
"{",
"const",
"ttxSettings",
"=",
"config",
".",
"getConfig",
"(",
"'ttxSettings'",
")",
";",
"const",
"syncUrl",
"=",
"(",
"ttxSettings",
"&&",
"ttxSettings",
".",
"syncUrl",
")",
"||",
"SYNC_ENDPOINT",
";",
"return",
"{",
"type",
":",
"'iframe'",
",",
"url",
":",
"`",
"${",
"syncUrl",
"}",
"${",
"siteId",
"}",
"`",
"}",
"}"
] | Sync object will always be of type iframe for TTX | [
"Sync",
"object",
"will",
"always",
"be",
"of",
"type",
"iframe",
"for",
"TTX"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/33acrossBidAdapter.js#L125-L133 |
6,196 | prebid/Prebid.js | modules/33acrossBidAdapter.js | ViewabilityContributor | function ViewabilityContributor(viewabilityAmount) {
function contributeViewability(ttxRequest) {
const req = Object.assign({}, ttxRequest);
const imp = req.imp = req.imp.map(impItem => Object.assign({}, impItem));
const banner = imp[0].banner = Object.assign({}, imp[0].banner);
const ext = banner.ext = Object.assign({}, banner.ext);
const ttx = ext.ttx = Object.assign({}, ext.ttx);
ttx.viewability = { amount: isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount) };
return req;
}
return contributeViewability;
} | javascript | function ViewabilityContributor(viewabilityAmount) {
function contributeViewability(ttxRequest) {
const req = Object.assign({}, ttxRequest);
const imp = req.imp = req.imp.map(impItem => Object.assign({}, impItem));
const banner = imp[0].banner = Object.assign({}, imp[0].banner);
const ext = banner.ext = Object.assign({}, banner.ext);
const ttx = ext.ttx = Object.assign({}, ext.ttx);
ttx.viewability = { amount: isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount) };
return req;
}
return contributeViewability;
} | [
"function",
"ViewabilityContributor",
"(",
"viewabilityAmount",
")",
"{",
"function",
"contributeViewability",
"(",
"ttxRequest",
")",
"{",
"const",
"req",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"ttxRequest",
")",
";",
"const",
"imp",
"=",
"req",
".",
"imp",
"=",
"req",
".",
"imp",
".",
"map",
"(",
"impItem",
"=>",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"impItem",
")",
")",
";",
"const",
"banner",
"=",
"imp",
"[",
"0",
"]",
".",
"banner",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"imp",
"[",
"0",
"]",
".",
"banner",
")",
";",
"const",
"ext",
"=",
"banner",
".",
"ext",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"banner",
".",
"ext",
")",
";",
"const",
"ttx",
"=",
"ext",
".",
"ttx",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"ext",
".",
"ttx",
")",
";",
"ttx",
".",
"viewability",
"=",
"{",
"amount",
":",
"isNaN",
"(",
"viewabilityAmount",
")",
"?",
"viewabilityAmount",
":",
"Math",
".",
"round",
"(",
"viewabilityAmount",
")",
"}",
";",
"return",
"req",
";",
"}",
"return",
"contributeViewability",
";",
"}"
] | Viewability contribution to request.. | [
"Viewability",
"contribution",
"to",
"request",
".."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/modules/33acrossBidAdapter.js#L226-L240 |
6,197 | prebid/Prebid.js | src/auction.js | tryAddVideoBid | function tryAddVideoBid(auctionInstance, bidResponse, bidRequests, afterBidAdded) {
let addBid = true;
const bidderRequest = getBidRequest(bidResponse.requestId, [bidRequests]);
const videoMediaType =
bidderRequest && deepAccess(bidderRequest, 'mediaTypes.video');
const context = videoMediaType && deepAccess(videoMediaType, 'context');
if (config.getConfig('cache.url') && context !== OUTSTREAM) {
if (!bidResponse.videoCacheKey) {
addBid = false;
callPrebidCache(auctionInstance, bidResponse, afterBidAdded, bidderRequest);
} else if (!bidResponse.vastUrl) {
utils.logError('videoCacheKey specified but not required vastUrl for video bid');
addBid = false;
}
}
if (addBid) {
addBidToAuction(auctionInstance, bidResponse);
afterBidAdded();
}
} | javascript | function tryAddVideoBid(auctionInstance, bidResponse, bidRequests, afterBidAdded) {
let addBid = true;
const bidderRequest = getBidRequest(bidResponse.requestId, [bidRequests]);
const videoMediaType =
bidderRequest && deepAccess(bidderRequest, 'mediaTypes.video');
const context = videoMediaType && deepAccess(videoMediaType, 'context');
if (config.getConfig('cache.url') && context !== OUTSTREAM) {
if (!bidResponse.videoCacheKey) {
addBid = false;
callPrebidCache(auctionInstance, bidResponse, afterBidAdded, bidderRequest);
} else if (!bidResponse.vastUrl) {
utils.logError('videoCacheKey specified but not required vastUrl for video bid');
addBid = false;
}
}
if (addBid) {
addBidToAuction(auctionInstance, bidResponse);
afterBidAdded();
}
} | [
"function",
"tryAddVideoBid",
"(",
"auctionInstance",
",",
"bidResponse",
",",
"bidRequests",
",",
"afterBidAdded",
")",
"{",
"let",
"addBid",
"=",
"true",
";",
"const",
"bidderRequest",
"=",
"getBidRequest",
"(",
"bidResponse",
".",
"requestId",
",",
"[",
"bidRequests",
"]",
")",
";",
"const",
"videoMediaType",
"=",
"bidderRequest",
"&&",
"deepAccess",
"(",
"bidderRequest",
",",
"'mediaTypes.video'",
")",
";",
"const",
"context",
"=",
"videoMediaType",
"&&",
"deepAccess",
"(",
"videoMediaType",
",",
"'context'",
")",
";",
"if",
"(",
"config",
".",
"getConfig",
"(",
"'cache.url'",
")",
"&&",
"context",
"!==",
"OUTSTREAM",
")",
"{",
"if",
"(",
"!",
"bidResponse",
".",
"videoCacheKey",
")",
"{",
"addBid",
"=",
"false",
";",
"callPrebidCache",
"(",
"auctionInstance",
",",
"bidResponse",
",",
"afterBidAdded",
",",
"bidderRequest",
")",
";",
"}",
"else",
"if",
"(",
"!",
"bidResponse",
".",
"vastUrl",
")",
"{",
"utils",
".",
"logError",
"(",
"'videoCacheKey specified but not required vastUrl for video bid'",
")",
";",
"addBid",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"addBid",
")",
"{",
"addBidToAuction",
"(",
"auctionInstance",
",",
"bidResponse",
")",
";",
"afterBidAdded",
"(",
")",
";",
"}",
"}"
] | Video bids may fail if the cache is down, or there's trouble on the network. | [
"Video",
"bids",
"may",
"fail",
"if",
"the",
"cache",
"is",
"down",
"or",
"there",
"s",
"trouble",
"on",
"the",
"network",
"."
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/auction.js#L405-L426 |
6,198 | prebid/Prebid.js | src/auction.js | createKeyVal | function createKeyVal(key, value) {
return {
key,
val: (typeof value === 'function')
? function (bidResponse) {
return value(bidResponse);
}
: function (bidResponse) {
return getValue(bidResponse, value);
}
};
} | javascript | function createKeyVal(key, value) {
return {
key,
val: (typeof value === 'function')
? function (bidResponse) {
return value(bidResponse);
}
: function (bidResponse) {
return getValue(bidResponse, value);
}
};
} | [
"function",
"createKeyVal",
"(",
"key",
",",
"value",
")",
"{",
"return",
"{",
"key",
",",
"val",
":",
"(",
"typeof",
"value",
"===",
"'function'",
")",
"?",
"function",
"(",
"bidResponse",
")",
"{",
"return",
"value",
"(",
"bidResponse",
")",
";",
"}",
":",
"function",
"(",
"bidResponse",
")",
"{",
"return",
"getValue",
"(",
"bidResponse",
",",
"value",
")",
";",
"}",
"}",
";",
"}"
] | factory for key value objs | [
"factory",
"for",
"key",
"value",
"objs"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/auction.js#L519-L530 |
6,199 | prebid/Prebid.js | src/auction.js | groupByPlacement | function groupByPlacement(bidsByPlacement, bid) {
if (!bidsByPlacement[bid.adUnitCode]) { bidsByPlacement[bid.adUnitCode] = { bids: [] }; }
bidsByPlacement[bid.adUnitCode].bids.push(bid);
return bidsByPlacement;
} | javascript | function groupByPlacement(bidsByPlacement, bid) {
if (!bidsByPlacement[bid.adUnitCode]) { bidsByPlacement[bid.adUnitCode] = { bids: [] }; }
bidsByPlacement[bid.adUnitCode].bids.push(bid);
return bidsByPlacement;
} | [
"function",
"groupByPlacement",
"(",
"bidsByPlacement",
",",
"bid",
")",
"{",
"if",
"(",
"!",
"bidsByPlacement",
"[",
"bid",
".",
"adUnitCode",
"]",
")",
"{",
"bidsByPlacement",
"[",
"bid",
".",
"adUnitCode",
"]",
"=",
"{",
"bids",
":",
"[",
"]",
"}",
";",
"}",
"bidsByPlacement",
"[",
"bid",
".",
"adUnitCode",
"]",
".",
"bids",
".",
"push",
"(",
"bid",
")",
";",
"return",
"bidsByPlacement",
";",
"}"
] | groupByPlacement is a reduce function that converts an array of Bid objects
to an object with placement codes as keys, with each key representing an object
with an array of `Bid` objects for that placement
@returns {*} as { [adUnitCode]: { bids: [Bid, Bid, Bid] } } | [
"groupByPlacement",
"is",
"a",
"reduce",
"function",
"that",
"converts",
"an",
"array",
"of",
"Bid",
"objects",
"to",
"an",
"object",
"with",
"placement",
"codes",
"as",
"keys",
"with",
"each",
"key",
"representing",
"an",
"object",
"with",
"an",
"array",
"of",
"Bid",
"objects",
"for",
"that",
"placement"
] | bd1636ada243f30c309bd8212e4446d39d86659b | https://github.com/prebid/Prebid.js/blob/bd1636ada243f30c309bd8212e4446d39d86659b/src/auction.js#L688-L692 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.