code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
formatMilliseconds (millisec) {
const seconds = (millisec / 1000).toFixed(1)
const minutes = (millisec / (1000 * 60)).toFixed(1)
const hours = (millisec / (1000 * 60 * 60)).toFixed(1)
const days = (millisec / (1000 * 60 * 60 * 24)).toFixed(1)
if (seconds < 60) {
return seconds + ' seconds'
... | inspired from https://stackoverflow.com/questions/19700283/how-to-convert-time-milliseconds-to-hours-min-sec-format-in-javascript
@param millisec
@returns {string} | formatMilliseconds | javascript | evansiroky/timezone-boundary-builder | util/progressStats.js | https://github.com/evansiroky/timezone-boundary-builder/blob/master/util/progressStats.js | MIT |
ObjectProperty(path) {
if (
DATA_FETCH_FNS.includes(path.node.value.name) &&
path.findParent(
(path) =>
path.isVariableDeclarator() &&
path.node.id.name === 'layoutProps',
)
) {
path.remove()
}
} | Currently it's not possible to export data fetching functions from MDX pages
because MDX includes them in `layoutProps`, and Next.js removes them at some
point, causing a `ReferenceError`.
https://github.com/mdx-js/mdx/issues/742#issuecomment-612652071
This plugin can be removed once MDX removes `layoutProps`, at lea... | ObjectProperty | javascript | jaredpalmer/tsdx | website/.nextra/babel-plugin-nextjs-mdx-patch.js | https://github.com/jaredpalmer/tsdx/blob/master/website/.nextra/babel-plugin-nextjs-mdx-patch.js | MIT |
function _createCanvas(){
var canvasses = document.getElementById("canvasses");
var canvas = document.createElement("canvas");
// Dimensions
var _onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px"... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createCanvas | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
_onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px";
canvas.height = height*2; // retina
canvas.style.height = height+"px";
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onResize | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _createLabel(message){
var label = document.createElement("div");
label.innerHTML = message;
label.setAttribute("class","component_label");
return label;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createLabel | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _createButton(label, onclick){
var button = document.createElement("div");
button.innerHTML = label;
button.onclick = onclick;
button.setAttribute("class","component_button");
return button;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createButton | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _createInput(className, textarea){
var input = textarea ? document.createElement("textarea") : document.createElement("input");
input.setAttribute("class",className);
input.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true);
},false); /... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createInput | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _createNumberInput(onUpdate){
var self = {};
// dom!
self.dom = document.createElement("input");
self.dom.style.border = "none";
self.dom.style.width = "40px";
self.dom.style.padding = "5px";
self.dom.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (eve... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createNumberInput | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _blank(){
// just a blank function to toss in.
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blank | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _getTotalOffset(target){
var bounds = target.getBoundingClientRect();
return {
left: bounds.left,
top: bounds.top
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getTotalOffset | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _addMouseEvents(target, onmousedown, onmousemove, onmouseup){
// WRAP THEM CALLBACKS
var _onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
};
var _onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
//... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _addMouseEvents | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
_onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousedown | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
_onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
// Touch
var offset = _getTotalOffset(target);
_fakeEvent.x = event.changedTouches[0].clientX - offset.left;
_fakeEvent.y = event.changedTouches[0].clientY - offset.top;
event.preventDefault();
}el... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousemove | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
_onmouseup = function(event){
var _fakeEvent = {};
onmouseup(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmouseup | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _getBounds(points){
// Bounds
var left=Infinity, top=Infinity, right=-Infinity, bottom=-Infinity;
for(var i=0;i<points.length;i++){
var point = points[i];
if(point[0]<left) left=point[0];
if(right<point[0]) right=point[0];
if(point[1]<top) top=point[1];
if(bottom<point[1]) bottom=point[1];
}
/... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getBounds | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _translatePoints(points, dx, dy){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
p[0] += dx;
p[1] += dy;
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _translatePoints | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _rotatePoints(points, angle){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
var x = p[0];
var y = p[1];
p[0] = x*Math.cos(angle) - y*Math.sin(angle);
p[1] = y*Math.cos(angle) + x*Math.sin(angle);
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _rotatePoints | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _configureProperties(self, config, properties){
for(var propName in properties){
// Default values!
if(config[propName]===undefined){
var value = properties[propName];
if(typeof value=="function") value=value();
config[propName] = value;
}
// Transfer to "self".
self[propName] = config[p... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _configureProperties | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _isPointInCircle(x, y, cx, cy, radius){
// Point distance
var dx = cx-x;
var dy = cy-y;
var dist2 = dx*dx + dy*dy;
// My radius
var r2 = radius*radius;
// Inside?
return dist2<=r2;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInCircle | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _isPointInBox(x, y, box){
if(x<box.x) return false;
if(x>box.x+box.width) return false;
if(y<box.y) return false;
if(y>box.y+box.height) return false;
return true;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInBox | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _makeErrorFunc(msg){
return function(){
throw Error(msg);
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _makeErrorFunc | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _getParameterByName(name){
var url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getParameterByName | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _blendColors(hex1, hex2, blend){
var color = "#";
for(var i=0; i<3; i++) {
// Into numbers...
var sub1 = hex1.substring(1+2*i, 3+2*i);
var sub2 = hex2.substring(1+2*i, 3+2*i);
var num1 = parseInt(sub1, 16);
var num2 = parseInt(sub2, 16);
// Blended number & sub
var num = Math.floor( num1*... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blendColors | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function _shiftArray(array, shiftIndex){
var moveThisAround = array.splice(-shiftIndex);
var shifted = moveThisAround.concat(array);
return shifted;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _shiftArray | javascript | ncase/loopy | splash/js/helpers.js | https://github.com/ncase/loopy/blob/master/splash/js/helpers.js | CC0-1.0 |
function Ink(loopy){
var self = this;
self.loopy = loopy;
// Create canvas & context
var canvas = _createCanvas();
var ctx = canvas.getContext("2d");
self.canvas = canvas;
self.context = ctx;
// Stroke data!
self.strokeData = [];
// Drawing!
self.drawInk = function(){
if(!Mouse.pressed) return;
// ... | *******************************
LOOPY!
- with edit & play mode
TODO: smoother bezier curve?
TODO: when switch away tool, clear the Ink canvas
******************************** | Ink | javascript | ncase/loopy | splash/js/Ink.js | https://github.com/ncase/loopy/blob/master/splash/js/Ink.js | CC0-1.0 |
_onUpdate = function(){
var embedCode = '<iframe width="'+width.getValue()+'" height="'+height.getValue()+'" frameborder="0" src="'+iframeSRC+'"></iframe>';
output.output(embedCode);
} | ********************
Use the same PAGE UI thing
********************** | _onUpdate | javascript | ncase/loopy | splash/js/Modal.js | https://github.com/ncase/loopy/blob/master/splash/js/Modal.js | CC0-1.0 |
function ModalIframe(config){
var self = this;
// IFRAME
var iframe = document.createElement("iframe");
self.dom = iframe;
iframe.width = config.width;
iframe.height = config.height;
// Show & Hide
if(!config.manual){
config.page.onshow = function(){
iframe.src = config.src;
};
config.page.onhide = ... | ********************
Use the same PAGE UI thing
********************** | ModalIframe | javascript | ncase/loopy | splash/js/Modal.js | https://github.com/ncase/loopy/blob/master/splash/js/Modal.js | CC0-1.0 |
function PageUI(dom){
var self = this;
self.dom = dom;
self.pages = [];
self.addPage = function(id, page){
page.id = id;
self.dom.appendChild(page.dom);
self.pages.push(page);
};
self.currentPage = null;
self.showPage = function(id){
var shownPage = null;
for(var i=0; i<self.pages.length; i++){
va... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | PageUI | javascript | ncase/loopy | splash/js/PageUI.js | https://github.com/ncase/loopy/blob/master/splash/js/PageUI.js | CC0-1.0 |
function Page(){
var self = this;
// DOM
self.dom = document.createElement("div");
self.show = function(){ self.dom.style.display="block"; };
self.hide = function(){ self.dom.style.display="none"; };
// Add Component
self.addComponent = function(component){
self.dom.appendChild(component.dom); // add to DOM... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | Page | javascript | ncase/loopy | splash/js/PageUI.js | https://github.com/ncase/loopy/blob/master/splash/js/PageUI.js | CC0-1.0 |
function PlayButton(config){
var self = this;
var label = "<div class='play_button_icon' icon='"+config.icon+"'></div> "
+ "<div class='play_button_label'>"+config.label+"</div>";
self.dom = _createButton(label, function(){
config.onclick();
});
// Tooltip!
if(config.tooltip){
self.dom.setAttribute("d... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlayButton | javascript | ncase/loopy | splash/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/splash/js/PlayControls.js | CC0-1.0 |
function PlaySlider(config){
var self = this;
self.dom = document.createElement("div");
self.dom.style.bottom = "0px";
self.dom.style.position = "absolute";
self.dom.style.width = "100%";
self.dom.style.height = "20px";
// Input
var input = document.createElement("input");
input.setAttribute("class"... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlaySlider | javascript | ncase/loopy | splash/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/splash/js/PlayControls.js | CC0-1.0 |
function _createCanvas(){
var canvasses = document.getElementById("canvasses");
var canvas = document.createElement("canvas");
// Dimensions
var _onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px"... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createCanvas | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
_onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px";
canvas.height = height*2; // retina
canvas.style.height = height+"px";
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onResize | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _createLabel(message){
var label = document.createElement("div");
label.innerHTML = message;
label.setAttribute("class","component_label");
return label;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createLabel | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _createButton(label, onclick){
var button = document.createElement("div");
button.innerHTML = label;
button.onclick = onclick;
button.setAttribute("class","component_button");
return button;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createButton | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _createInput(className, textarea){
var input = textarea ? document.createElement("textarea") : document.createElement("input");
input.setAttribute("class",className);
input.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true);
},false); /... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createInput | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _createNumberInput(onUpdate){
var self = {};
// dom!
self.dom = document.createElement("input");
self.dom.style.border = "none";
self.dom.style.width = "40px";
self.dom.style.padding = "5px";
self.dom.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (eve... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createNumberInput | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _blank(){
// just a blank function to toss in.
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blank | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _getTotalOffset(target){
var bounds = target.getBoundingClientRect();
return {
left: bounds.left,
top: bounds.top
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getTotalOffset | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _addMouseEvents(target, onmousedown, onmousemove, onmouseup){
// WRAP THEM CALLBACKS
var _onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
};
var _onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
//... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _addMouseEvents | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
_onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousedown | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
_onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
// Touch
var offset = _getTotalOffset(target);
_fakeEvent.x = event.changedTouches[0].clientX - offset.left;
_fakeEvent.y = event.changedTouches[0].clientY - offset.top;
event.preventDefault();
}el... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousemove | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
_onmouseup = function(event){
var _fakeEvent = {};
onmouseup(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmouseup | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _getBounds(points){
// Bounds
var left=Infinity, top=Infinity, right=-Infinity, bottom=-Infinity;
for(var i=0;i<points.length;i++){
var point = points[i];
if(point[0]<left) left=point[0];
if(right<point[0]) right=point[0];
if(point[1]<top) top=point[1];
if(bottom<point[1]) bottom=point[1];
}
/... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getBounds | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _translatePoints(points, dx, dy){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
p[0] += dx;
p[1] += dy;
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _translatePoints | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _rotatePoints(points, angle){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
var x = p[0];
var y = p[1];
p[0] = x*Math.cos(angle) - y*Math.sin(angle);
p[1] = y*Math.cos(angle) + x*Math.sin(angle);
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _rotatePoints | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _configureProperties(self, config, properties){
for(var propName in properties){
// Default values!
if(config[propName]===undefined){
var value = properties[propName];
if(typeof value=="function") value=value();
config[propName] = value;
}
// Transfer to "self".
self[propName] = config[p... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _configureProperties | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _isPointInCircle(x, y, cx, cy, radius){
// Point distance
var dx = cx-x;
var dy = cy-y;
var dist2 = dx*dx + dy*dy;
// My radius
var r2 = radius*radius;
// Inside?
return dist2<=r2;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInCircle | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _isPointInBox(x, y, box){
if(x<box.x) return false;
if(x>box.x+box.width) return false;
if(y<box.y) return false;
if(y>box.y+box.height) return false;
return true;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInBox | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _makeErrorFunc(msg){
return function(){
throw Error(msg);
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _makeErrorFunc | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _getParameterByName(name){
var url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getParameterByName | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _blendColors(hex1, hex2, blend){
var color = "#";
for(var i=0; i<3; i++) {
// Into numbers...
var sub1 = hex1.substring(1+2*i, 3+2*i);
var sub2 = hex2.substring(1+2*i, 3+2*i);
var num1 = parseInt(sub1, 16);
var num2 = parseInt(sub2, 16);
// Blended number & sub
var num = Math.floor( num1*... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blendColors | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function _shiftArray(array, shiftIndex){
var moveThisAround = array.splice(-shiftIndex);
var shifted = moveThisAround.concat(array);
return shifted;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _shiftArray | javascript | ncase/loopy | v1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1/js/helpers.js | CC0-1.0 |
function Ink(loopy){
var self = this;
self.loopy = loopy;
// Create canvas & context
var canvas = _createCanvas();
var ctx = canvas.getContext("2d");
self.canvas = canvas;
self.context = ctx;
// Stroke data!
self.strokeData = [];
// Drawing!
self.drawInk = function(){
if(!Mouse.pressed) return;
// ... | *******************************
LOOPY!
- with edit & play mode
TODO: smoother bezier curve?
TODO: when switch away tool, clear the Ink canvas
******************************** | Ink | javascript | ncase/loopy | v1/js/Ink.js | https://github.com/ncase/loopy/blob/master/v1/js/Ink.js | CC0-1.0 |
_onUpdate = function(){
var embedCode = '<iframe width="'+width.getValue()+'" height="'+height.getValue()+'" frameborder="0" src="'+iframeSRC+'"></iframe>';
output.output(embedCode);
} | ********************
Use the same PAGE UI thing
********************** | _onUpdate | javascript | ncase/loopy | v1/js/Modal.js | https://github.com/ncase/loopy/blob/master/v1/js/Modal.js | CC0-1.0 |
function ModalIframe(config){
var self = this;
// IFRAME
var iframe = document.createElement("iframe");
self.dom = iframe;
iframe.width = config.width;
iframe.height = config.height;
// Show & Hide
if(!config.manual){
config.page.onshow = function(){
iframe.src = config.src;
};
config.page.onhide = ... | ********************
Use the same PAGE UI thing
********************** | ModalIframe | javascript | ncase/loopy | v1/js/Modal.js | https://github.com/ncase/loopy/blob/master/v1/js/Modal.js | CC0-1.0 |
function PageUI(dom){
var self = this;
self.dom = dom;
self.pages = [];
self.addPage = function(id, page){
page.id = id;
self.dom.appendChild(page.dom);
self.pages.push(page);
};
self.currentPage = null;
self.showPage = function(id){
var shownPage = null;
for(var i=0; i<self.pages.length; i++){
va... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | PageUI | javascript | ncase/loopy | v1/js/PageUI.js | https://github.com/ncase/loopy/blob/master/v1/js/PageUI.js | CC0-1.0 |
function Page(){
var self = this;
// DOM
self.dom = document.createElement("div");
self.show = function(){ self.dom.style.display="block"; };
self.hide = function(){ self.dom.style.display="none"; };
// Add Component
self.addComponent = function(component){
self.dom.appendChild(component.dom); // add to DOM... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | Page | javascript | ncase/loopy | v1/js/PageUI.js | https://github.com/ncase/loopy/blob/master/v1/js/PageUI.js | CC0-1.0 |
function PlayButton(config){
var self = this;
var label = "<div class='play_button_icon' icon='"+config.icon+"'></div> "
+ "<div class='play_button_label'>"+config.label+"</div>";
self.dom = _createButton(label, function(){
config.onclick();
});
// Tooltip!
if(config.tooltip){
self.dom.setAttribute("d... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlayButton | javascript | ncase/loopy | v1/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/v1/js/PlayControls.js | CC0-1.0 |
function PlaySlider(config){
var self = this;
self.dom = document.createElement("div");
self.dom.style.bottom = "0px";
self.dom.style.position = "absolute";
self.dom.style.width = "100%";
self.dom.style.height = "20px";
// Input
var input = document.createElement("input");
input.setAttribute("class"... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlaySlider | javascript | ncase/loopy | v1/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/v1/js/PlayControls.js | CC0-1.0 |
function _createCanvas(){
var canvasses = document.getElementById("canvasses");
var canvas = document.createElement("canvas");
// Dimensions
var _onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px"... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createCanvas | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
_onResize = function(){
var width = canvasses.clientWidth;
var height = canvasses.clientHeight;
canvas.width = width*2; // retina
canvas.style.width = width+"px";
canvas.height = height*2; // retina
canvas.style.height = height+"px";
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onResize | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _createLabel(message){
var label = document.createElement("div");
label.innerHTML = message;
label.setAttribute("class","component_label");
return label;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createLabel | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _createButton(label, onclick){
var button = document.createElement("div");
button.innerHTML = label;
button.onclick = onclick;
button.setAttribute("class","component_button");
return button;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createButton | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _createInput(className, textarea){
var input = textarea ? document.createElement("textarea") : document.createElement("input");
input.setAttribute("class",className);
input.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (event.cancelBubble=true);
},false); /... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createInput | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _createNumberInput(onUpdate){
var self = {};
// dom!
self.dom = document.createElement("input");
self.dom.style.border = "none";
self.dom.style.width = "40px";
self.dom.style.padding = "5px";
self.dom.addEventListener("keydown",function(event){
event.stopPropagation ? event.stopPropagation() : (eve... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _createNumberInput | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _blank(){
// just a blank function to toss in.
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blank | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _getTotalOffset(target){
var bounds = target.getBoundingClientRect();
return {
left: bounds.left,
top: bounds.top
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getTotalOffset | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _addMouseEvents(target, onmousedown, onmousemove, onmouseup){
// WRAP THEM CALLBACKS
var _onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
};
var _onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
//... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _addMouseEvents | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
_onmousedown = function(event){
var _fakeEvent = _onmousemove(event);
onmousedown(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousedown | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
_onmousemove = function(event){
// Mouse position
var _fakeEvent = {};
if(event.changedTouches){
// Touch
var offset = _getTotalOffset(target);
_fakeEvent.x = event.changedTouches[0].clientX - offset.left;
_fakeEvent.y = event.changedTouches[0].clientY - offset.top;
event.preventDefault();
}el... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmousemove | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
_onmouseup = function(event){
var _fakeEvent = {};
onmouseup(_fakeEvent);
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _onmouseup | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _getBounds(points){
// Bounds
var left=Infinity, top=Infinity, right=-Infinity, bottom=-Infinity;
for(var i=0;i<points.length;i++){
var point = points[i];
if(point[0]<left) left=point[0];
if(right<point[0]) right=point[0];
if(point[1]<top) top=point[1];
if(bottom<point[1]) bottom=point[1];
}
/... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getBounds | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _translatePoints(points, dx, dy){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
p[0] += dx;
p[1] += dy;
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _translatePoints | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _rotatePoints(points, angle){
points = JSON.parse(JSON.stringify(points));
for(var i=0;i<points.length;i++){
var p = points[i];
var x = p[0];
var y = p[1];
p[0] = x*Math.cos(angle) - y*Math.sin(angle);
p[1] = y*Math.cos(angle) + x*Math.sin(angle);
}
return points;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _rotatePoints | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _configureProperties(self, config, properties){
for(var propName in properties){
// Default values!
if(config[propName]===undefined){
var value = properties[propName];
if(typeof value=="function") value=value();
config[propName] = value;
}
// Transfer to "self".
self[propName] = config[p... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _configureProperties | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _isPointInCircle(x, y, cx, cy, radius){
// Point distance
var dx = cx-x;
var dy = cy-y;
var dist2 = dx*dx + dy*dy;
// My radius
var r2 = radius*radius;
// Inside?
return dist2<=r2;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInCircle | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _isPointInBox(x, y, box){
if(x<box.x) return false;
if(x>box.x+box.width) return false;
if(y<box.y) return false;
if(y>box.y+box.height) return false;
return true;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _isPointInBox | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _makeErrorFunc(msg){
return function(){
throw Error(msg);
};
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _makeErrorFunc | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _getParameterByName(name){
var url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _getParameterByName | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _blendColors(hex1, hex2, blend){
var color = "#";
for(var i=0; i<3; i++) {
// Into numbers...
var sub1 = hex1.substring(1+2*i, 3+2*i);
var sub2 = hex2.substring(1+2*i, 3+2*i);
var num1 = parseInt(sub1, 16);
var num2 = parseInt(sub2, 16);
// Blended number & sub
var num = Math.floor( num1*... | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _blendColors | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function _shiftArray(array, shiftIndex){
var moveThisAround = array.splice(-shiftIndex);
var shifted = moveThisAround.concat(array);
return shifted;
} | **************************
A miscellaneous collection of reuseable helper methods
that I couldn't be arsed to put into separate classes
*************************** | _shiftArray | javascript | ncase/loopy | v1.1/js/helpers.js | https://github.com/ncase/loopy/blob/master/v1.1/js/helpers.js | CC0-1.0 |
function Ink(loopy){
var self = this;
self.loopy = loopy;
// Create canvas & context
var canvas = _createCanvas();
var ctx = canvas.getContext("2d");
self.canvas = canvas;
self.context = ctx;
// Stroke data!
self.strokeData = [];
// Drawing!
self.drawInk = function(){
if(!Mouse.pressed) return;
// ... | *******************************
LOOPY!
- with edit & play mode
TODO: smoother bezier curve?
TODO: when switch away tool, clear the Ink canvas
******************************** | Ink | javascript | ncase/loopy | v1.1/js/Ink.js | https://github.com/ncase/loopy/blob/master/v1.1/js/Ink.js | CC0-1.0 |
_onUpdate = function(){
var embedCode = '<iframe width="'+width.getValue()+'" height="'+height.getValue()+'" frameborder="0" src="'+iframeSRC+'"></iframe>';
output.output(embedCode);
} | ********************
Use the same PAGE UI thing
********************** | _onUpdate | javascript | ncase/loopy | v1.1/js/Modal.js | https://github.com/ncase/loopy/blob/master/v1.1/js/Modal.js | CC0-1.0 |
function ModalIframe(config){
var self = this;
// IFRAME
var iframe = document.createElement("iframe");
self.dom = iframe;
iframe.width = config.width;
iframe.height = config.height;
// Show & Hide
if(!config.manual){
config.page.onshow = function(){
iframe.src = config.src;
};
config.page.onhide = ... | ********************
Use the same PAGE UI thing
********************** | ModalIframe | javascript | ncase/loopy | v1.1/js/Modal.js | https://github.com/ncase/loopy/blob/master/v1.1/js/Modal.js | CC0-1.0 |
function PageUI(dom){
var self = this;
self.dom = dom;
self.pages = [];
self.addPage = function(id, page){
page.id = id;
self.dom.appendChild(page.dom);
self.pages.push(page);
};
self.currentPage = null;
self.showPage = function(id){
var shownPage = null;
for(var i=0; i<self.pages.length; i++){
va... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | PageUI | javascript | ncase/loopy | v1.1/js/PageUI.js | https://github.com/ncase/loopy/blob/master/v1.1/js/PageUI.js | CC0-1.0 |
function Page(){
var self = this;
// DOM
self.dom = document.createElement("div");
self.show = function(){ self.dom.style.display="block"; };
self.hide = function(){ self.dom.style.display="none"; };
// Add Component
self.addComponent = function(component){
self.dom.appendChild(component.dom); // add to DOM... | *******************************
PAGE UI: to extend to Sidebar, Play Controls, Modal.
******************************** | Page | javascript | ncase/loopy | v1.1/js/PageUI.js | https://github.com/ncase/loopy/blob/master/v1.1/js/PageUI.js | CC0-1.0 |
function PlayButton(config){
var self = this;
var label = "<div class='play_button_icon' icon='"+config.icon+"'></div> "
+ "<div class='play_button_label'>"+config.label+"</div>";
self.dom = _createButton(label, function(){
config.onclick();
});
// Tooltip!
if(config.tooltip){
self.dom.setAttribute("d... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlayButton | javascript | ncase/loopy | v1.1/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/v1.1/js/PlayControls.js | CC0-1.0 |
function PlaySlider(config){
var self = this;
self.dom = document.createElement("div");
self.dom.style.bottom = "0px";
self.dom.style.position = "absolute";
self.dom.style.width = "100%";
self.dom.style.height = "20px";
// Input
var input = document.createElement("input");
input.setAttribute("class"... | *******************************
PLAY CONTROLS CODE:
- play
- pause/reset/speed
******************************** | PlaySlider | javascript | ncase/loopy | v1.1/js/PlayControls.js | https://github.com/ncase/loopy/blob/master/v1.1/js/PlayControls.js | CC0-1.0 |
constructor (opts = {
apiKey: '',
apiSecret: '',
authToken: '',
company: '',
transform: false,
ws: {},
rest: {}
}) {
if (opts.constructor.name !== 'Object') {
throw new Error([
'constructor takes an object since version 2.0.0, see:',
'https://github.com/bitfinexco... | @param {object} [opts] - options
@param {string} [opts.apiKey] - API key
@param {string} [opts.apiSecret] - API secret
@param {string} [opts.authToken] - optional auth option
@param {string} [opts.company] - optional auth option
@param {boolean} [opts.transform] - if true, packets are converted to models
@param {object... | constructor | javascript | bitfinexcom/bitfinex-api-node | index.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/index.js | MIT |
_getTransportPayload (extraOpts) {
return {
apiKey: this._apiKey,
apiSecret: this._apiSecret,
authToken: this._authToken,
company: this._company,
transform: this._transform,
...extraOpts
}
} | Returns an arguments map ready to pass to a transport constructor
@param {object} extraOpts - options to pass to transport
@returns {object} payload | _getTransportPayload | javascript | bitfinexcom/bitfinex-api-node | index.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/index.js | MIT |
rest (version = 2, extraOpts = {}) {
if (version !== 1 && version !== 2) {
throw new Error(`invalid http API version: ${version}`)
}
const key = `${version}|${JSON.stringify(extraOpts)}`
if (!this._transportCache.rest[key]) {
Object.assign(extraOpts, this._restArgs)
const payload = t... | Returns a new REST API class instance (cached by version)
@param {number} [version] - 1 or 2 (default)
@param {object} [extraOpts] - passed to transport constructor
@returns {RESTv1|RESTv2} transport | rest | javascript | bitfinexcom/bitfinex-api-node | index.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/index.js | MIT |
ws (version = 2, extraOpts = {}) {
if (version !== 1 && version !== 2) {
throw new Error(`invalid websocket API version: ${version}`)
}
const key = `${version}|${JSON.stringify(extraOpts)}`
if (!this._transportCache.ws[key]) {
Object.assign(extraOpts, this._wsArgs)
const payload = th... | Returns a new WebSocket API class instance (cached by version)
@param {number} [version] - 1 or 2 (default)
@param {object} [extraOpts] - passed to transport constructor
@returns {WSv1|WSv2} transport | ws | javascript | bitfinexcom/bitfinex-api-node | index.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/index.js | MIT |
debugTable = ({ rows = [], headers, widths }, extraRows = []) => {
debug('')
debugTableUtil({
rows: [...rows, ...extraRows],
headers,
widths,
debug
})
debug('')
} | Log a table to the console
@param {object} args - arguments
@param {object[]} args.rows - data, can be specified as 2nd param
@param {string[]} args.headers - column labels
@param {number[]} args.widths - column widths
@param {object[]} extraRows - optional row spec as 2nd param | debugTable | javascript | bitfinexcom/bitfinex-api-node | examples/util/setup.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/examples/util/setup.js | MIT |
debugTable = ({ rows = [], headers, widths }, extraRows = []) => {
debug('')
debugTableUtil({
rows: [...rows, ...extraRows],
headers,
widths,
debug
})
debug('')
} | Log a table to the console
@param {object} args - arguments
@param {object[]} args.rows - data, can be specified as 2nd param
@param {string[]} args.headers - column labels
@param {number[]} args.widths - column widths
@param {object[]} extraRows - optional row spec as 2nd param | debugTable | javascript | bitfinexcom/bitfinex-api-node | examples/util/setup.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/examples/util/setup.js | MIT |
get args () {
return argsFromEnv()
} | Log a table to the console
@param {object} args - arguments
@param {object[]} args.rows - data, can be specified as 2nd param
@param {string[]} args.headers - column labels
@param {number[]} args.widths - column widths
@param {object[]} extraRows - optional row spec as 2nd param | args | javascript | bitfinexcom/bitfinex-api-node | examples/util/setup.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/examples/util/setup.js | MIT |
get readline () {
return Readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
})
} | Log a table to the console
@param {object} args - arguments
@param {object[]} args.rows - data, can be specified as 2nd param
@param {string[]} args.headers - column labels
@param {number[]} args.widths - column widths
@param {object[]} extraRows - optional row spec as 2nd param | readline | javascript | bitfinexcom/bitfinex-api-node | examples/util/setup.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/examples/util/setup.js | MIT |
constructor (socketArgs, authArgs = { calc: 0, dms: 0 }) {
super()
this.setMaxListeners(1000)
this._authArgs = authArgs
this._sockets = []
this._socketArgs = {
...(socketArgs || {}),
reconnectThrottler
}
} | @param {object} socketArgs - passed to WSv2 constructors
@param {object} [authArgs] - cached for all internal socket auth() calls
@param {number} [authArgs.calc] - default 0
@param {number} [authArgs.dms] - default 0 | constructor | javascript | bitfinexcom/bitfinex-api-node | lib/ws2_manager.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/ws2_manager.js | MIT |
setAuthArgs (args = {}) {
this._authArgs = {
...this._authArgs,
...args
}
this._sockets.forEach(socket => socket.ws.updateAuthArgs(this._authArgs))
} | Update authentication arguments on all sockets
@param {object} args - arguments
@param {number} [args.calc] - calc value
@param {number} [args.dms] - active 4 | setAuthArgs | javascript | bitfinexcom/bitfinex-api-node | lib/ws2_manager.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/ws2_manager.js | MIT |
getAuthArgs () {
return this._authArgs
} | Retrieve internal authentication arguments
@returns {object} args | getAuthArgs | javascript | bitfinexcom/bitfinex-api-node | lib/ws2_manager.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/ws2_manager.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.