/ test_cluster.html
test_cluster.html
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 6 7 <title>Cluster — Space.js</title> 8 9 <link rel="preconnect" href="https://fonts.gstatic.com"> 10 <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto+Mono"> 11 <link rel="stylesheet" href="assets/css/style.css"> 12 13 <script type="importmap"> 14 { 15 "imports": { 16 "@alienkitty/space.js": "../src/index.js" 17 } 18 } 19 </script> 20 21 <script type="module"> 22 import { Cluster } from '@alienkitty/space.js'; 23 24 // 25 26 const cluster = new Cluster(); 27 28 for (let i = 0; i < 4; i++) { 29 cluster.push(i); 30 } 31 32 console.log(cluster.length); // 4 33 34 let object = cluster.get(); 35 console.log(object, cluster.length); // 0 4 36 37 object = cluster.get(); 38 console.log(object, cluster.length); // 1 4 39 40 object = cluster.get(); 41 console.log(object, cluster.length); // 2 4 42 43 object = cluster.get(); 44 console.log(object, cluster.length); // 3 4 45 46 object = cluster.get(); 47 console.log(object, cluster.length); // 0 4 48 49 // 50 51 const cluster2 = new Cluster(); 52 cluster2.push(0, 1, 2, 3); 53 console.log(cluster2.length); // 4 54 55 const object2 = cluster2.get(); 56 console.log(object2, cluster2.length); // 0 4 57 </script> 58 </head> 59 <body> 60 </body> 61 </html>