<?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: yatharth1706</title>
    <description>The latest articles on DEV Community by yatharth1706 (@yatharth1706).</description>
    <link>https://dev.to/yatharth1706</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%2F325795%2F6702a5e7-e387-431f-9d57-79f8bbd15dde.jpeg</url>
      <title>DEV Community: yatharth1706</title>
      <link>https://dev.to/yatharth1706</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yatharth1706"/>
    <language>en</language>
    <item>
      <title>Portfolio using Jekyll</title>
      <dc:creator>yatharth1706</dc:creator>
      <pubDate>Fri, 12 Jun 2020 13:27:57 +0000</pubDate>
      <link>https://dev.to/yatharth1706/portfolio-30jf</link>
      <guid>https://dev.to/yatharth1706/portfolio-30jf</guid>
      <description>&lt;p&gt;Hello dev.to community!. I wanted to learn something new, so I started learning Jekyll which is a static site generator. I also thought to make some side projects using this. So I built my portfolio using Jekyll.&lt;/p&gt;

&lt;p&gt;This is the link of my portfolio: &lt;a href="https://yatharth1706.github.io/"&gt;https://yatharth1706.github.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once take a look at this portfolio, and let me know what more things i can add or improve in my Portfolio. It would mean a lot to me!!&lt;/p&gt;

&lt;p&gt;Thank you!!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>emojigit npm package</title>
      <dc:creator>yatharth1706</dc:creator>
      <pubDate>Fri, 12 Jun 2020 06:16:40 +0000</pubDate>
      <link>https://dev.to/yatharth1706/emojigit-npm-package-ddh</link>
      <guid>https://dev.to/yatharth1706/emojigit-npm-package-ddh</guid>
      <description>&lt;h3&gt;
  
  
  emojigit
&lt;/h3&gt;

&lt;p&gt;Built my first ever npm package 'emojigit'. It is a CLI tool which is used for adding emojis to commit messages. This cli tool will show users list of emojis that can be used on commit messages and then will ask some questions like branch name and git remote repo name and then code is pushed automatically to user's github repository after commit. It is built using nodejs and some libraries like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inquirer: For displaying prompt for asking questions to user&lt;/li&gt;
&lt;li&gt;meow: Its a CLI app helper&lt;/li&gt;
&lt;li&gt;node-fetch: For making network requests&lt;/li&gt;
&lt;li&gt;ora: For terminal spinner&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Github Link: &lt;a href="https://github.com/yatharth1706/emojigit"&gt;https://github.com/yatharth1706/emojigit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;npm package link: &lt;a href="https://www.npmjs.com/package/emojigit"&gt;https://www.npmjs.com/package/emojigit&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Within 2 days this package has been downloaded by users 205 times.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I request all of you to once use this package for adding emojis to commit messages for github repository. And also let me know what improvements I can do in this project.&lt;/p&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Promises</title>
      <dc:creator>yatharth1706</dc:creator>
      <pubDate>Tue, 14 Apr 2020 16:26:13 +0000</pubDate>
      <link>https://dev.to/yatharth1706/promises-4a0</link>
      <guid>https://dev.to/yatharth1706/promises-4a0</guid>
      <description>&lt;h3&gt;
  
  
  What are promises?
&lt;/h3&gt;

&lt;p&gt;Its a special JavaScript object to handle asynchronous operations in an easy way.&lt;/p&gt;

&lt;p&gt;The constructor syntax for a promise object is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform some asynchronous task here&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The function passed to new Promise is called the executor. When new Promise is created, the executor runs automatically.&lt;/p&gt;

&lt;h4&gt;
  
  
  Arguments of Executor:
&lt;/h4&gt;

&lt;p&gt;It contains two callbacks&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;resolve&lt;/li&gt;
&lt;li&gt;reject&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;resolve(value)&lt;/strong&gt; — if the job finished successfully, with result value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;reject(error)&lt;/strong&gt; — if an error occurred, error is the error object.&lt;/p&gt;

&lt;p&gt;The promise object returned by the new Promise constructor has these internal properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;state&lt;/strong&gt; — initially "pending", then changes to either "fulfilled" when resolve is called or "rejected" when reject is         called.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;result&lt;/strong&gt; — initially undefined, then changes to value when resolve(value) called or error when reject(error) is called.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3hgU-W7t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://yatharth1706.github.io/assets/promise1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3hgU-W7t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://yatharth1706.github.io/assets/promise1.PNG" alt="Promise States"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Methods on Promise
&lt;/h3&gt;

&lt;p&gt;1.&lt;strong&gt;then&lt;/strong&gt;: for fetching results and errors from promises&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;      &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* handle a successful result */&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* handle an error */&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;Some Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;done!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;

      &lt;span class="c1"&gt;// resolve runs the first function in .then&lt;/span&gt;
      &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// shows "done!" after 1 second&lt;/span&gt;
        &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// doesn't run&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;catch&lt;/strong&gt;: for fetching errors from promise&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Whoops!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;

      &lt;span class="c1"&gt;// .catch(f) is the same as promise.then(null, f)&lt;/span&gt;
      &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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



&lt;p&gt;3.&lt;strong&gt;finally&lt;/strong&gt;: for performing cleanup operations. It will always execute no matter your callback is returning resolve callback or reject callback.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;result&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2000&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="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Promise ready&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

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



&lt;p&gt;&lt;strong&gt;Link for tutorial video&lt;/strong&gt; &lt;a href="https://youtu.be/_J3QK56lU7A"&gt;Click here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
