Skip to content

Instantly share code, notes, and snippets.

@TylorS
Last active April 6, 2017 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylorS/9d7272c53b1eb92b59c60b10a431bae6 to your computer and use it in GitHub Desktop.
Save TylorS/9d7272c53b1eb92b59c60b10a431bae6 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
const NUMBER_OF_HANDS_RENDERED = 5
function zoomIn(start, allHands) {
const length = allHands.length
const numberOfHandsToRender = Math.min(length, NUMBER_OF_HANDS_RENDERED)
let end = start + numberOfHandsToRender
if (end >= length) {
end = length
start = end - numberOfHandsToRender
}
if (start < 0)
start = 0
console.log(allHands.slice(start, end))
}
const a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
const b = [ 1, 2, 3, 4, 5 ]
zoomIn(0, a)
zoomIn(10, a)
zoomIn(19, a)
zoomIn(0, b)
zoomIn(3, b)
zoomIn(10, b)
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"@typed/hashmap": "0.1.1"
}
}
"use strict";
var NUMBER_OF_HANDS_RENDERED = 5;
function zoomIn(start, allHands) {
var length = allHands.length;
var numberOfHandsToRender = Math.min(length, NUMBER_OF_HANDS_RENDERED);
var end = start + numberOfHandsToRender;
if (end >= length) {
end = length;
start = end - numberOfHandsToRender;
}
if (start < 0) start = 0;
console.log(allHands.slice(start, end));
}
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
var b = [1, 2, 3, 4, 5];
zoomIn(0, a);
zoomIn(10, a);
zoomIn(19, a);
zoomIn(0, b);
zoomIn(3, b);
zoomIn(10, b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment