made with esnextbin
Last active
April 6, 2017 10:25
-
-
Save TylorS/9d7272c53b1eb92b59c60b10a431bae6 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"@typed/hashmap": "0.1.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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