<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dina</title>
    <description>The latest articles on DEV Community by Dina (@dnafication).</description>
    <link>https://dev.to/dnafication</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F104638%2F0f393b52-1e2c-47ba-bea8-1db5f90e2ec2.png</url>
      <title>DEV Community: Dina</title>
      <link>https://dev.to/dnafication</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dnafication"/>
    <language>en</language>
    <item>
      <title>QuizCraft: Test Your Knowledge Right from Your Terminal</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Fri, 31 Oct 2025 10:17:37 +0000</pubDate>
      <link>https://dev.to/dnafication/quizcraft-test-your-knowledge-right-from-your-terminal-1900</link>
      <guid>https://dev.to/dnafication/quizcraft-test-your-knowledge-right-from-your-terminal-1900</guid>
      <description>&lt;p&gt;Ever wanted to test your knowledge without leaving your terminal? Meet &lt;strong&gt;QuizCraft&lt;/strong&gt;, a beautiful Terminal User Interface (TUI) quiz application that brings interactive quizzes right to your command line!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh28u9x71vaw0i0qbux64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh28u9x71vaw0i0qbux64.png" alt="QuizCraft App" width="800" height="975"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why QuizCraft?
&lt;/h2&gt;

&lt;p&gt;As developers, we spend most of our time in the terminal. Whether you're waiting for a build to complete, taking a quick break, or just want to learn something new, QuizCraft lets you challenge yourself without switching contexts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🎨 &lt;strong&gt;Beautiful Interface&lt;/strong&gt;: Colorful and intuitive TUI powered by @clack/prompts&lt;/li&gt;
&lt;li&gt;📚 &lt;strong&gt;Multiple Categories&lt;/strong&gt;: Linux, DevOps, Docker, Kubernetes, Programming, and more&lt;/li&gt;
&lt;li&gt;🎚️ &lt;strong&gt;Difficulty Levels&lt;/strong&gt;: Choose between Easy, Medium, or Hard questions&lt;/li&gt;
&lt;li&gt;💡 &lt;strong&gt;Instant Feedback&lt;/strong&gt;: Get explanations for each answer&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Score Tracking&lt;/strong&gt;: See your performance with detailed results&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Lightning Fast&lt;/strong&gt;: No browser needed, runs entirely in your terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;

&lt;p&gt;Getting started is super simple:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Get Your API Key
&lt;/h3&gt;

&lt;p&gt;First, grab a free API key from &lt;a href="https://quizapi.io/clientarea/settings/token" rel="noopener noreferrer"&gt;quizapi.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And set it as env variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;QUIZ_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your_api_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Install QuizCraft
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; quizcraft
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and start playing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;quizcraft
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or run it without installing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx quizcraft
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! Follow the interactive prompts to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select a category&lt;/li&gt;
&lt;li&gt;Choose difficulty level&lt;/li&gt;
&lt;li&gt;Pick number of questions&lt;/li&gt;
&lt;li&gt;Start answering!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;p&gt;QuizCraft is built with modern Node.js tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/natemoo-re/clack" rel="noopener noreferrer"&gt;@clack/prompts&lt;/a&gt;&lt;/strong&gt;: For beautiful CLI prompts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/chalk/chalk" rel="noopener noreferrer"&gt;chalk&lt;/a&gt;&lt;/strong&gt;: Terminal string styling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://axios-http.com/" rel="noopener noreferrer"&gt;axios&lt;/a&gt;&lt;/strong&gt;: HTTP requests to quizapi.io&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/motdotla/dotenv" rel="noopener noreferrer"&gt;dotenv&lt;/a&gt;&lt;/strong&gt;: Environment configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Contributing
&lt;/h2&gt;

&lt;p&gt;QuizCraft is open source! Check it out on &lt;a href="https://github.com/dnafication/quizcraft" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and feel free to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Report bugs&lt;/li&gt;
&lt;li&gt;Suggest features&lt;/li&gt;
&lt;li&gt;Submit pull requests&lt;/li&gt;
&lt;li&gt;Star the repo ⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;Some ideas for future enhancements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🏆 Local leaderboard&lt;/li&gt;
&lt;li&gt;⏱️ Timed quizzes&lt;/li&gt;
&lt;li&gt;📈 Progress tracking over time&lt;/li&gt;
&lt;li&gt;🎨 Custom themes&lt;/li&gt;
&lt;li&gt;🌐 More quiz sources&lt;/li&gt;
&lt;li&gt;📊 Detailed analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Now!
&lt;/h2&gt;

&lt;p&gt;Don't just read about it, try it yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx quizcraft
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy quizzing! 🎯&lt;/p&gt;

</description>
      <category>cli</category>
      <category>quiz</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Join Hacktoberfest 2024 and Make Your First Open Source Contribution!</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Sat, 05 Oct 2024 01:15:05 +0000</pubDate>
      <link>https://dev.to/dnafication/join-hacktoberfest-2024-and-make-your-first-open-source-contribution-5hmp</link>
      <guid>https://dev.to/dnafication/join-hacktoberfest-2024-and-make-your-first-open-source-contribution-5hmp</guid>
      <description>&lt;p&gt;It's that time of the year again! &lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt; is here, and it's the perfect opportunity for developers, especially beginners, to dive into the world of open source. If you're new to coding or open source, &lt;a href="https://hacktoberfest.com/" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt; is a fantastic way to learn, grow, and give back to the community.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Contribute to Open Source?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Real-World Experience&lt;/strong&gt;: Contributing to open source lets you work on real projects with real-world problems. It’s a great way to build your portfolio.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning Opportunities&lt;/strong&gt;: You'll get to learn from other developers, see how large codebases are structured, and understand how collaborative development works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Networking&lt;/strong&gt;: Open source communities are full of talented people. It's a great way to make connections, ask questions, and get advice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feel Good&lt;/strong&gt;: It’s rewarding to know that your code is helping others!&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  My Project: Talk Timer – Perfect for Beginners
&lt;/h3&gt;

&lt;p&gt;I have a small open-source project that’s &lt;strong&gt;Hacktoberfest eligible&lt;/strong&gt; and beginner-friendly! It’s a &lt;strong&gt;Next.js app&lt;/strong&gt; called &lt;strong&gt;Talk Timer&lt;/strong&gt;. This app is a simple timer for talks, with configurable warning and end times. You can also toggle full screen mode using the F/f key to keep things distraction-free during presentations.&lt;/p&gt;

&lt;p&gt;Demo: &lt;a href="https://talk-timer.vercel.app" rel="noopener noreferrer"&gt;https://talk-timer.vercel.app&lt;/a&gt;&lt;br&gt;
Github repo: &lt;a href="https://github.com/dnafication/talk-timer" rel="noopener noreferrer"&gt;https://github.com/dnafication/talk-timer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're just getting started with open source or want to contribute to something simple, there are &lt;strong&gt;beginner-friendly issues&lt;/strong&gt; up for grabs in this project. Whether you're comfortable with JavaScript or want to dip your toes into the world of React and Next.js, there’s something here for you.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to Get Involved
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fork the Repo&lt;/strong&gt;: Head over to the &lt;a href="https://github.com/dnafication/talk-timer" rel="noopener noreferrer"&gt;Talk Timer repository on GitHub&lt;/a&gt;, fork it, and get started.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the Issues&lt;/strong&gt;: All the issues are currently beginner friendly and hacktoberfest ready. These are small, manageable tasks that you can tackle as your first contribution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make Your Contribution&lt;/strong&gt;: Submit your pull request and you’ll be well on your way to completing Hacktoberfest!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn Along the Way&lt;/strong&gt;: Don’t worry if you get stuck; feel free to ask questions. I am happy to help and the open source communities are welcoming and love helping new contributors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Hacktoberfest&lt;/strong&gt; is a wonderful opportunity to start your open source journey. Take the leap, and let’s make this month one of growth and contribution!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@ykhomi?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Yurii Khomitskyi&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/a-laptop-computer-sitting-on-top-of-a-wooden-desk-Dqx2PyviLUg?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>hacktoberfest</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Motivation to Contribute</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Tue, 31 Oct 2023 22:10:18 +0000</pubDate>
      <link>https://dev.to/dnafication/motivation-to-contribute-1kmi</link>
      <guid>https://dev.to/dnafication/motivation-to-contribute-1kmi</guid>
      <description>&lt;p&gt;Hello I'm Dina 👋, a senior backend developer primarily working with Node.js. Today, I want to share my thoughts on Hacktoberfest and my recent experiences contributing to open source projects.&lt;/p&gt;

&lt;p&gt;In our fast-paced lives, it can be challenging to find the time to give back to the open source community. While it's relatively easy to get started with open source contributions, making a meaningful impact often requires a substantial commitment of time and effort. Understanding the project and effectively communicating with maintainers are important components of successful open source contributions.&lt;/p&gt;

&lt;p&gt;This year, my motivation for Hacktoberfest was to learn and contribute to a simple Swift/SwiftUI related project that I stumbled upon. While I'm excited about this endeavor, I also realize that it will take some time for me to complete my pull request and truly make a difference in the project.&lt;/p&gt;

&lt;p&gt;In addition, I made contributions to two other projects during the time. First, I contributed to &lt;a href="https://www.verto.sh/" rel="noopener noreferrer"&gt;Verto.sh&lt;/a&gt;, which is an excellent resource for finding popular open source projects with beginner-friendly issues. It simplifies the process of discovering new projects and making your first contributions.&lt;/p&gt;

&lt;p&gt;I also made a small contribution to &lt;a href="//www.verdaccio.org/"&gt;Verdaccio&lt;/a&gt;, a lightweight Node.js private proxy registry. While it may not be a massive contribution, it's a part of my journey to give back to the open source community and contribute in ways that align with my skills and interests. &lt;em&gt;It's the hours that dedicate to the tool/project of your choice that matters. It gives me a sense of fulfilment.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hacktoberfest is a fantastic opportunity to engage with open source projects, learn new things, and connect with the global developer community. It's a reminder that every contribution, no matter how big or small, is valuable and appreciated by maintainers and fellow developers. As we wrap up this year's Hacktoberfest, I'm &lt;strong&gt;grateful&lt;/strong&gt; for the chance to give back and look forward to more open source adventures in the future.&lt;/p&gt;

&lt;p&gt;Let's keep the spirit of open source alive, learn, and grow together. Happy hacking! &lt;/p&gt;

</description>
      <category>hack23contributor</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>Building Iterators</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Mon, 04 Apr 2022 01:36:06 +0000</pubDate>
      <link>https://dev.to/dnafication/building-iterators-1ebb</link>
      <guid>https://dev.to/dnafication/building-iterators-1ebb</guid>
      <description>&lt;p&gt;As programmers, one of the very first thing we learn is "&lt;a href="https://en.wikipedia.org/wiki/Control_flow#Loops" rel="noopener noreferrer"&gt;the loop&lt;/a&gt;". There is always an array or list or collection which needs to be looped through, an object or map or dictionary whose keys and values require traversing. Iterations are key programming concept.&lt;/p&gt;

&lt;p&gt;Arrays and Maps are collections of things and it should to be defined explicitly prior to iterating. You can start out with an empty array or a declaration and you can push items to it. Example: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;things&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;headphone&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mouse&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;friends&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;tomo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nuxt expert&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;jt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;writes nasty sqls&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;deco&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;the leader&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;van&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;php guru&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 

&lt;span class="nx"&gt;things&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cables&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// one of the ways of iterating arrays&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;things&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// iterate the key of objects&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; - &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;friends&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There are many ways of iterating over an array or an object. To name a few:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;for(const i = 0; i &amp;lt; arr.length; i+=1)&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;for...of&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;for...in&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;while()&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Array.forEach&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Array.map&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Array.filter&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Array.reduce&lt;/code&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One thing about arrays or objects(Map, Set etc) is that you kind of know what you are getting. You could push things into an array but you know what you pushed. Its not dynamic. If something is in array, its there for good until you remove it. Also, its taking up that space in the memory. &lt;/p&gt;

&lt;h2&gt;
  
  
  Iterator protocol
&lt;/h2&gt;

&lt;p&gt;What if you had a dynamic array that calculated what &lt;code&gt;value&lt;/code&gt; you get in the &lt;code&gt;next&lt;/code&gt; iteration? What if that worked based on a formula that you've built? You need to use iterator pattern. You'll notice that its very simple to implement. Its a protocol that is well known among JS programmers and also followed in other languages too. An iterator is an object that has &lt;code&gt;next()&lt;/code&gt; method. Calling &lt;code&gt;next()&lt;/code&gt; function on the object gives us the iterator result which is an object with two properties - &lt;code&gt;done&lt;/code&gt; which is a boolean to hold the status of the iterator and &lt;code&gt;value&lt;/code&gt; to hold whatever you want to return. Let's build a simple range iterator. This range iterator will allow us to create a range of numbers by providing a start, end and step.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="c1"&gt;// iterator protocol: an agreed interface&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;numberRangeIterator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;step&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;thanks for using me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// value is optional here but you can use it to return meta info&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;
      &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;step&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;iterator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;numberRangeIterator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;iteratorResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;iterator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;iteratorResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;iteratorResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;iteratorResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;iterator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You see? Its very simple and yet powerful. Two things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;next&lt;/code&gt; function should return and object with &lt;code&gt;done: true&lt;/code&gt; to indicate that there are no more elements. But it's not mandatory, you can have an iterator that runs forever!&lt;/li&gt;
&lt;li&gt;you can have &lt;code&gt;done: false&lt;/code&gt; or return just &lt;code&gt;{value}&lt;/code&gt; and above code will just work fine.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;randomNumberIterator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rIterator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;randomNumberIterator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;rIteratorResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rIterator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;rIteratorResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rIteratorResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;rIteratorResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rIterator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;While I cannot think of when you'd use the iterator above, I just wanted to demonstrate an iterator that can generate random numbers infinitely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Iterable protocol
&lt;/h2&gt;

&lt;p&gt;Iterable protocol goes one step further by defining a standard within JS language for any object to return an iterator. An &lt;code&gt;iterable&lt;/code&gt; is an object that implements an iterator method called &lt;code&gt;[Symbol.iterator]&lt;/code&gt;. The best thing about using iterables over the iterator which we talked about above is that it allows us to use JS native apis for looping over the array such as &lt;code&gt;for...of&lt;/code&gt;. Let's build our &lt;code&gt;numberRangeIterator&lt;/code&gt; as an iterable.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NumberRange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;step&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;step&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// for an object/class to classify as iterable&lt;/span&gt;
  &lt;span class="c1"&gt;// it has to implement [Symbol.iterator]&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;iterator&lt;/span&gt;&lt;span class="p"&gt;]()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;
        &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;step&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myRange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NumberRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;myRange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It was almost the same amount of code to define the iterable class and we reused most of our code. However, the beauty is in the way we consume the iterator. Using &lt;code&gt;for...of&lt;/code&gt; makes it look so clean and concise. I prefer this over the &lt;code&gt;while&lt;/code&gt; loop above. But it doesn't stop here. There are other ways you can consume this iterable. You can use it with spread operator.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myRange2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NumberRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;myRange2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// prints 5 9 13 17&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or, destructure and assign it &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myRange2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NumberRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;second&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;third&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myRange2&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;first&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;second&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;third&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// prints 5 9 13&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There are other JS built-in APIs that accept iterables where you can pass your iterables such as &lt;code&gt;Array.from(iterable)&lt;/code&gt;, &lt;code&gt;Set([iterable])&lt;/code&gt;, &lt;code&gt;Promise.all(iterable)&lt;/code&gt; and even &lt;code&gt;stream.Readable.from(iterable)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators" rel="noopener noreferrer"&gt;Read  more about iterators here&lt;/a&gt;. You can pretty much treat it like your regular array but dynamic in nature and it will calculate your values only when it needs to. Things get a bit hairy though, when you start getting into the territory of async iterators but that is for another day.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Learning TypeScript? try Deno</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Thu, 31 Mar 2022 01:47:03 +0000</pubDate>
      <link>https://dev.to/dnafication/learning-typescript-try-deno-4pen</link>
      <guid>https://dev.to/dnafication/learning-typescript-try-deno-4pen</guid>
      <description>&lt;p&gt;&lt;a href="https://deno.land" rel="noopener noreferrer"&gt;Deno&lt;/a&gt; is modern, fast and secure runtime that supports TypeScript and JavaScript natively. It is very simple to setup and use. It is very welcoming to JS developers because its very easy to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;As simple as &lt;code&gt;brew install deno&lt;/code&gt; on a mac and &lt;code&gt;choco install deno&lt;/code&gt; on a windows machine. Detailed instruction on &lt;a href="https://deno.land/#installation" rel="noopener noreferrer"&gt;installation is here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run
&lt;/h2&gt;

&lt;p&gt;Deno can run any JS or TS file hosted on the internet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ deno run https://deno.land/std/examples/welcome.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, let us write any valid TypeScript file locally&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// save this as welcome.ts&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Account&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
  &lt;span class="nx"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Account&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Welcome,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Dina&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file above and run it directly as shown below. Deno takes care of compiling and executing the code. To start out, you don't have to deal will &lt;code&gt;.tsconfig&lt;/code&gt; files or running &lt;code&gt;tsc&lt;/code&gt; etc. psst, if you are in a hurry and want to learn TS and not interested in Deno, you could use TS repl and execution environment called &lt;a href="https://typestrong.org/ts-node/" rel="noopener noreferrer"&gt;ts-node&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ deno run welcome.ts

Check file:///Users/dina/dev/try-deno/welcome.ts
Welcome, Dina
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Developer Experience
&lt;/h2&gt;

&lt;p&gt;Deno offers a great DX by &lt;a href="https://deno.land/#toolchain" rel="noopener noreferrer"&gt;providing tools&lt;/a&gt; like code linters, formatters and test runners all in the deno executable. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lint&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ deno lint

(prefer-const) `order` is never reassigned
let order = new Order()
    ^^^^^
    at /Users/dina/try-deno/design-patterns/state.ts:106:4

    hint: Use `const` instead
    help: for further information visit https://lint.deno.land/#prefer-const

Found 24 problems
Checked 25 files

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Format&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ deno fmt

/Users/dina/try-deno/design-patterns/decorator.ts
/Users/dina/try-deno/design-patterns/state.ts
Checked 30 files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ deno test feature.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  My Two Cents
&lt;/h2&gt;

&lt;p&gt;I don't think Node.js is going away any time soon. Deno is a great alternative but its still under heavy development. Node.js has a huge ecosystem of libraries and utilities which are yet to be converted or made available to Deno. Good thing is introduction of Deno has led to maturing of Node.js since there wasn't many competition to it before. What slice of web is deno going to get? only time will tell. 👋&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>deno</category>
      <category>beginners</category>
      <category>node</category>
    </item>
    <item>
      <title>AWS S3 Iterator in TypeScript</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Thu, 14 Jan 2021 02:32:26 +0000</pubDate>
      <link>https://dev.to/dnafication/aws-s3-iterator-in-typescript-5egf</link>
      <guid>https://dev.to/dnafication/aws-s3-iterator-in-typescript-5egf</guid>
      <description>&lt;p&gt;Amazon Simple Storage Service (Amazon S3) is a very popular object storage service that offers industry-leading scalability, data availability, security, and performance. It allows you to virtually store unlimited number of files (objects). AWS provides &lt;a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html" rel="noopener noreferrer"&gt;JavaScript SDK&lt;/a&gt; to interact with S3 APIs. You can use &lt;code&gt;aws-sdk&lt;/code&gt; to do variety of things like getting the list of objects in an S3 bucket, upload an object, download the object etc.&lt;/p&gt;

&lt;p&gt;While working with it recently, I figured it would be handy to use the Iterator pattern to fetch files from s3 in a loop using &lt;code&gt;for await...of&lt;/code&gt;. So came up with a basic implementation below. Please provide your feedback&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Downside of this pattern or the code above is that only 1 file is processed at a time as we are awaiting the download of the file and processing it before moving to the next iteration. We could use &lt;code&gt;Promise.all&lt;/code&gt; with regular loops. Do you guys think its doable in this pattern?&lt;/p&gt;

&lt;p&gt;One improvement I definitely want to see is to only load next set of keys when we are running out of objects in the &lt;code&gt;keysList&lt;/code&gt; instead of loading all (currently using &lt;code&gt;loadKeys()&lt;/code&gt; function). Can someone fork and build that out? 😉 ciao!!&lt;/p&gt;

</description>
      <category>s3</category>
      <category>aws</category>
      <category>typescript</category>
      <category>iterator</category>
    </item>
    <item>
      <title>Best thing about JMeter is JSR223</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Thu, 13 Aug 2020 07:24:32 +0000</pubDate>
      <link>https://dev.to/dnafication/best-thing-about-jmeter-is-jsr223-3ihm</link>
      <guid>https://dev.to/dnafication/best-thing-about-jmeter-is-jsr223-3ihm</guid>
      <description>&lt;p&gt;My favorite part of &lt;a href="https://jmeter.apache.org/" rel="noopener noreferrer"&gt;JMeter&lt;/a&gt; is anything starting with JSR223. &lt;em&gt;Why?&lt;/em&gt; Because it allows me to do anything literally! You have the raw power of a programming language such as Groovy, JavaScript, Java etc. &lt;a href="https://jcp.org/en/jsr/detail?id=223" rel="noopener noreferrer"&gt;JSR223&lt;/a&gt; kind of opens the window of JVM (Java Virtual Machine) for you to access and fiddle with through use of other scripting languages. You are not writing a full fledged Java plugin which is what you would do if you are doing something for JMeter. JSR223 scripting languages allow you to quickly hack up a process, control flow or other things you would want to do as part of your scripting process.&lt;/p&gt;

&lt;p&gt;JMeter exposes control flow into your script through Controllers and actual task is carried out by Samplers. Listeners do the job of recording the results and processing them. Its better to stick to as much of the JMeter tree for your general JMeter scripting. But lets say you want more which is why you are snooping around JMeter APIs to figure out how you can jump into its invocation lifecycle and do something in between. JSR223 [pre|post] processor allows you to do that. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do you want custom code in samplers?&lt;/em&gt; JSR223 sampler or pre or post processor. &lt;em&gt;Any customization in assertions?&lt;/em&gt; there is JSR223 assertions. &lt;em&gt;What about results? and timers?&lt;/em&gt; you got it, there are equivalent JSR223 capabilities.&lt;/p&gt;

&lt;p&gt;This will be a series of posts on tips and tricks in Apache JMeter scripting. Lets start by talking about &lt;a href="https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html" rel="noopener noreferrer"&gt;SampleResult&lt;/a&gt; today. API documentation has one line to say about SampleResult which is to the point!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a nice packaging for the various information returned from taking a sample of an entry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can access &lt;code&gt;SampleResult&lt;/code&gt; in PostProcessor, Assertion and Listener. You access it as &lt;code&gt;prev&lt;/code&gt; variable which is injected by JMeter when the script is executed. It is a java object which contains all the information related to the Sampler that it is attached to. Add it as shown in the figure below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8okk2bua8s983vq24tuj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8okk2bua8s983vq24tuj.png" alt="How to add JSR223 PostProcessor" width="800" height="613"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paste in following code and then run the script. You will see the output based on if your sampler was successful or not.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isSuccessful&lt;/span&gt;&lt;span class="o"&gt;()){&lt;/span&gt;
  &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sampler passed"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;// do something here&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"sampler failed"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;// do something else&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let's go through some of the common useful functions which allow access to different attributes of the Result object.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;prev.getResponseDataAsString()&lt;/code&gt; Gets the responseData of the SampleResult object as a String. This is the actual response body for HTTP sampler. Example: if your sampler is sending request to &lt;code&gt;https://jsonplaceholder.typicode.com/users/1&lt;/code&gt;, this function will return the response body which looks like &lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Leanne Graham"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Bret"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sincere@april.biz"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"street"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Kulas Light"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"suite"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Apt. 556"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Gwenborough"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"zipcode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"92998-3874"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"geo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"lat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"-37.3159"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"lng"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"81.1496"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"phone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1-770-736-8031 x56442"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"website"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hildegard.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"company"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Romaguera-Crona"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"catchPhrase"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Multi-layered client-server neural-net"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"harness real-time e-markets"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;prev.getResponseHeaders()&lt;/code&gt; Returns the response headers as string. Example:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Content-Type: application/json; charset=utf-8
Content-Length: 509
Connection: keep-alive
Set-Cookie: __cfduid=444; expires=Sat, 12-Sep-20 06:14:43 GMT; path=/; domain=.typicode.com; HttpOnly; SameSite=Lax
X-Powered-By: Express
X-Ratelimit-Limit: 1000
X-Ratelimit-Remaining: 999
X-Ratelimit-Reset: 1597292781
Vary: Origin, Accept-Encoding


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;prev.getResponseMessage()&lt;/code&gt; Example: &lt;code&gt;OK&lt;/code&gt;, &lt;code&gt;Created&lt;/code&gt;, &lt;code&gt;Not Found&lt;/code&gt; etc.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.getResponseCode()&lt;/code&gt; returns &lt;code&gt;200&lt;/code&gt;, &lt;code&gt;400&lt;/code&gt; or other HTTP codes. &lt;a href="https://httpstatuses.com/" rel="noopener noreferrer"&gt;List of HTTP codes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.getResponseData()&lt;/code&gt; Same as &lt;code&gt;getResponseDataAsString()&lt;/code&gt; but returns byte[].&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.setSuccessful(true or false)&lt;/code&gt; to mark the sampler pass or fail.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.isSuccessful()&lt;/code&gt; returns true/false based on result status. This is to check the status.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.getUrlAsString()&lt;/code&gt; return the URL for HTTP Request samplers.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.isResponseCodeOK()&lt;/code&gt; Another method to check the response code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prev.setIgnore()&lt;/code&gt; to ignore the result and don't show it in results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You get the idea. What this script box allows you to do is anything. You can check the results and inverse the result (if you want to), do additional task based on the result of the Sampler, transform the results and do some calculations based on the response etc. The result is endless. Hope you find this useful. I will see you next week with other tips in JMeter World.&lt;/p&gt;

</description>
      <category>jmeter</category>
      <category>tips</category>
      <category>jsr223</category>
      <category>groovy</category>
    </item>
    <item>
      <title>Reuse Serverless Deployment S3 buckets</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Mon, 27 Jul 2020 06:50:58 +0000</pubDate>
      <link>https://dev.to/dnafication/reuse-serverless-deployment-s3-buckets-3m3j</link>
      <guid>https://dev.to/dnafication/reuse-serverless-deployment-s3-buckets-3m3j</guid>
      <description>&lt;p&gt;&lt;a href="https://www.serverless.com/" rel="noopener noreferrer"&gt;Serverless framework&lt;/a&gt; does a lot of magic (not in a bad way) to make your life easy while deploying serverless projects. Serverless or &lt;code&gt;sls&lt;/code&gt; in short, packages your application and uses s3 bucket to deploy your application. It doesn't ask you what the name should be, but infers it based on your service name and some random strings to come up with the S3 bucket name. Just give name which exists in your s3.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;

&lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cool-service&lt;/span&gt;

&lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
  &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nodejs12.x&lt;/span&gt;
  &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ap-southeast-2&lt;/span&gt;
&lt;span class="nn"&gt;...&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If your &lt;code&gt;serverless.yml&lt;/code&gt; looks like above, you might get a bucket name like &lt;code&gt;cool-service-prod-serverlessdeploymentbucket-&amp;lt;random string&amp;gt;&lt;/code&gt;. No problem with that. All good! If you have 1000 serverless projects in one account, you will need 1000 s3 buckets for sls deployment and you cannot have more than 1000 s3 buckets in an AWS account. That's when you would think of reusing the s3 buckets. And here is how to do it by using a key in the &lt;code&gt;serverless.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;

&lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cool-service&lt;/span&gt;

&lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
  &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nodejs12.x&lt;/span&gt;

  &lt;span class="na"&gt;deploymentBucket&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;all-service-deployments&lt;/span&gt; &lt;span class="c1"&gt;# Deployment bucket name. Default is generated by the framework&lt;/span&gt;
    &lt;span class="na"&gt;maxPreviousDeploymentArtifacts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt; &lt;span class="c1"&gt;# On every deployment the framework prunes the bucket to remove artifacts older than this limit. The default is 5&lt;/span&gt;
    &lt;span class="na"&gt;blockPublicAccess&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# Prevents public access via ACLs or bucket policies. Default is false&lt;/span&gt;
    &lt;span class="na"&gt;serverSideEncryption&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AES256&lt;/span&gt; &lt;span class="c1"&gt;# server-side encryption method&lt;/span&gt;
    &lt;span class="na"&gt;sseKMSKeyId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa&lt;/span&gt; &lt;span class="c1"&gt;# when using server-side encryption&lt;/span&gt;
    &lt;span class="na"&gt;sseCustomerAlgorithim&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AES256&lt;/span&gt; &lt;span class="c1"&gt;# when using server-side encryption and custom keys&lt;/span&gt;
    &lt;span class="na"&gt;sseCustomerKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;string&lt;/span&gt; &lt;span class="c1"&gt;# when using server-side encryption and custom keys&lt;/span&gt;
    &lt;span class="na"&gt;sseCustomerKeyMD5&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;md5sum&lt;/span&gt; &lt;span class="c1"&gt;# when using server-side encryption and custom keys&lt;/span&gt;
    &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# Tags that will be added to each of the deployment resources&lt;/span&gt;
      &lt;span class="na"&gt;key1&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;value1&lt;/span&gt;
      &lt;span class="na"&gt;key2&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;value2&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It will store all your deployment packages in subfolders in the s3 bucket.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>aws</category>
      <category>s3</category>
    </item>
    <item>
      <title>Ensure npm package is updated</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Sun, 26 Jul 2020 03:12:14 +0000</pubDate>
      <link>https://dev.to/dnafication/ensure-npm-package-is-updated-3ma0</link>
      <guid>https://dev.to/dnafication/ensure-npm-package-is-updated-3ma0</guid>
      <description>&lt;h3&gt;
  
  
  Do you install your private node modules as below?
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private-module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"git+ssh://git@github.com:private-module.git#v5.5.5"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;



&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If yes, chances are when you upgrade the package version to &lt;code&gt;#v5.5.6&lt;/code&gt;, and do &lt;code&gt;npm install&lt;/code&gt;, your &lt;code&gt;package-lock.json&lt;/code&gt; wont be updated and neither the actual files inside &lt;code&gt;node_modules&lt;/code&gt;. To ensure the update, I am having to manually update the &lt;code&gt;package-lock&lt;/code&gt; file. Has anyone faced this? &lt;/p&gt;

</description>
      <category>node</category>
      <category>npm</category>
    </item>
    <item>
      <title>Running WASM on node.js</title>
      <dc:creator>Dina</dc:creator>
      <pubDate>Mon, 20 Jul 2020 09:48:48 +0000</pubDate>
      <link>https://dev.to/dnafication/running-wasm-on-node-js-3pfn</link>
      <guid>https://dev.to/dnafication/running-wasm-on-node-js-3pfn</guid>
      <description>&lt;p&gt;Getting started with Web Assembly is super easy with &lt;a href="https://www.secondstate.io/ssvm/" rel="noopener noreferrer"&gt;SSVM&lt;/a&gt;. It allows you compile high performance Rust functions into WebAssembly (wasm file), and call them from Node.js/deno applications. So, you get best of both worlds.&lt;/p&gt;

&lt;p&gt;While manual installation has its perks and also headaches, I prefer docker image for quick tests and ssvm is easy to setup in Docker. Ensure you have docker installed to go through following steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo: &lt;a href="https://github.com/second-state/rust-wasm-ai-demo" rel="noopener noreferrer"&gt;https://github.com/second-state/rust-wasm-ai-demo&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/second-state/rust-wasm-ai-demo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Go into the cloned directory &lt;code&gt;rust-wasm-ai-demo&lt;/code&gt; and do the following.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# create the Dockerfile&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; Dockerfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOL&lt;/span&gt;&lt;span class="sh"&gt;
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ENV RUSTUP_HOME=/usr/local/rustup &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    CARGO_HOME=/usr/local/cargo &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    PATH=/usr/local/cargo/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="sh"&gt;
RUN apt-get update &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; apt-get install -y tzdata &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; apt-get -y upgrade &amp;amp;&amp;amp; apt-get install -y build-essential curl wget git vim libboost-all-dev
RUN curl -sL https://deb.nodesource.com/setup_14.x |  bash &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; apt-get install -y nodejs &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; npm install -y -g ssvmup --unsafe-perm &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; npm install -y ssvm &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="sh"&gt;
    &amp;amp;&amp;amp; npm install express express-fileupload
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
&lt;/span&gt;&lt;span class="no"&gt;EOL

&lt;/span&gt;&lt;span class="c"&gt;# build the image&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; ssvm-nodejs:v1 &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# run the docker container exposing port 8080 which is &lt;/span&gt;
&lt;span class="c"&gt;# where express server is listening. &lt;/span&gt;
&lt;span class="c"&gt;# also mounting the current directory to `/app`&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/app ssvm-nodejs:v1

&lt;span class="c"&gt;## ---------------------------------------- ##&lt;/span&gt;

&lt;span class="c"&gt;# when you run above command, &lt;/span&gt;
&lt;span class="c"&gt;# you will be in the container's shell:&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /app

&lt;span class="c"&gt;# build the WASM bytecode &lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;ssvmup build

&lt;span class="c"&gt;# install node dependencies&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /app/node
&lt;span class="nv"&gt;$ &lt;/span&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express express-fileupload

&lt;span class="c"&gt;# run the webserver&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;npm start

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If all went correctly, you should have a running web server with Image Recognition capability. Point your browser to &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt; and enjoy. 😊 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference Repos:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/second-state/rust-wasm-ai-demo" rel="noopener noreferrer"&gt;rust-wasm-ai-demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.secondstate.io/articles/artificial-intelligence/" rel="noopener noreferrer"&gt;image recognition in nodejs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.secondstate.io/articles/raspberry-pi-for-free-20200709" rel="noopener noreferrer"&gt;get a raspberry pi for free&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ssvm</category>
      <category>webassembly</category>
      <category>node</category>
    </item>
  </channel>
</rss>
