<?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: Sam Clark</title>
    <description>The latest articles on DEV Community by Sam Clark (@samrocksc).</description>
    <link>https://dev.to/samrocksc</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%2F99858%2F21ff5718-96c7-4a80-a598-202b14071ff5.jpeg</url>
      <title>DEV Community: Sam Clark</title>
      <link>https://dev.to/samrocksc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samrocksc"/>
    <language>en</language>
    <item>
      <title>Using sed To Find and Replace</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Thu, 23 May 2019 18:55:41 +0000</pubDate>
      <link>https://dev.to/samrocksc/using-sed-to-find-and-replace-2ba2</link>
      <guid>https://dev.to/samrocksc/using-sed-to-find-and-replace-2ba2</guid>
      <description>&lt;h2&gt;
  
  
  Using sed to find and replace
&lt;/h2&gt;

&lt;p&gt;When you need to find and replace a massive amount of modules(think of having to refactor a require to a privately scoped package at your company).&lt;/p&gt;

&lt;p&gt;Luckily we're using a &lt;em&gt;nix&lt;/em&gt; based system(unless it's windows...then whatever, enjoy windows).  We can use &lt;code&gt;sed&lt;/code&gt; which is basically going to run commands against a stream.  &lt;code&gt;find&lt;/code&gt; is basically going to pipe a stream directly into &lt;code&gt;sed&lt;/code&gt;, and sed is going to run a simple find/replace scheme(just like we would if we were using vim).    &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;fix foo and move it to point to a private repo:&lt;/strong&gt;&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;find ./ &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"s/'foo/'@my-org&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="s2"&gt;foo/g"&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>horriblesnippets</category>
      <category>code</category>
      <category>linux</category>
      <category>hotdogs</category>
    </item>
    <item>
      <title>Arity In Functional Javascript</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Thu, 16 May 2019 21:19:16 +0000</pubDate>
      <link>https://dev.to/samrocksc/arity-in-functional-javascript-4ngl</link>
      <guid>https://dev.to/samrocksc/arity-in-functional-javascript-4ngl</guid>
      <description>&lt;p&gt;Good References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339"&gt;Understanding Currying in JavaScript – Bits and Pieces&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I think most of the time it's easier for me atleast to read someone else's code instead of long drawn out blog posts.  Let's take a look at this non-functional JS snippet:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;nfMultiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&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="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;c&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'non-functional'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nfMultiply&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="mi"&gt;2&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Arity in essence is the number of functions you can pass into an object.  It's all rather confusing, but i think of it as the amount of functions you can curry into one function, let's convert the function above into an arity of &lt;em&gt;3&lt;/em&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&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="nx"&gt;b&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;return&lt;/span&gt; &lt;span class="nx"&gt;c&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;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;c&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'arity breakdown'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;multiply&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="mi"&gt;2&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you think about it simply how many times can i fold this function against itself.  This becomes useful when we start creating more complex functional javascript statements(I really enjoy using lodash in my node code, and also because it's included in AWS lambdas by default, thus not really bloating it.):&lt;/p&gt;

&lt;h2&gt;
  
  
  More Advanced
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;has&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'lodash'&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;fakeDataFunc&lt;/span&gt; &lt;span class="o"&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="mi"&gt;3&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;fakeObjFunc&lt;/span&gt; &lt;span class="o"&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="na"&gt;uncool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'blue'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;coolDude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&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="nx"&gt;b&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;return&lt;/span&gt; &lt;span class="nx"&gt;c&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;return&lt;/span&gt; &lt;span class="nx"&gt;d&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;return&lt;/span&gt; &lt;span class="nx"&gt;e&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;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;bTimesC&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;eHas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s1"&gt;'cool'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'sure does'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'nope'&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="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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'testing'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;coolDude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Mutliplied Value times a function is: '&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;fakeDataFunc&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;
    &lt;span class="s1"&gt;'and here we generate a ternary if something is in an object:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;fakeObjFunc&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 can take the above snippets and kind of meld them to your wishes, and play with them to create Higher Order Functions, enjoy!!!&lt;/p&gt;

</description>
      <category>horriblesnippets</category>
      <category>code</category>
      <category>javascript</category>
      <category>functional</category>
    </item>
    <item>
      <title>Horrible Snippets - Check the string</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Thu, 02 May 2019 17:13:20 +0000</pubDate>
      <link>https://dev.to/samrocksc/horrible-snippets-check-the-string-33lp</link>
      <guid>https://dev.to/samrocksc/horrible-snippets-check-the-string-33lp</guid>
      <description>

&lt;p&gt;&lt;strong&gt;Usecase&lt;/strong&gt;&lt;br&gt;
Let's say you're looking to implement a darklaunch feature, you have some options, you can pass a bunch of env vars(RUN_EVENT_1=true, etc.) OR you can just pass a &lt;code&gt;DARK_LAUNCH&lt;/code&gt; flag with some comma separated vars.  &lt;/p&gt;



&lt;div class="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;stringydingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'foo,bar,baz'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;stringydingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'foo'&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;stringydingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'foo'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;runDarkLaunchDotCalm&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;Play with it, try it out in your project!  Give me feedback on how it can be improved!&lt;/p&gt;


</description>
      <category>horriblesnippets</category>
      <category>arrays</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Horrible Snippet - Updating an Nested Array With The Spread Operator</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Sat, 20 Apr 2019 00:46:18 +0000</pubDate>
      <link>https://dev.to/samrocksc/horrible-snippet-updating-an-nested-array-with-the-spread-operator-4918</link>
      <guid>https://dev.to/samrocksc/horrible-snippet-updating-an-nested-array-with-the-spread-operator-4918</guid>
      <description>

&lt;p&gt;Sometimes I like to just sit there and think of weird ways to accomplish things, and sometimes I come up with ideas like this, I think this could be applied to some Functional JS&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// I Really dig this one
const foo = {
  bar: {
    baz: [{ changeMe: 'asdf', notMe: 'asdf' }, { changeMe: 'ffff', notMe: 'asdf' }],
  },
};

const newArr = foo.bar.baz.map(baz =&amp;gt; ({ ...baz, changeMe: 'swee' }));

const newData = {
  ...foo,
  bar: {
    baz: newArr,
  },
};

console.log('newData', newData.bar.baz);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;




</description>
      <category>horriblehowtos</category>
      <category>horriblesnippets</category>
      <category>snippet</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Horrible Howto - Attach A Stack To Debug</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Sat, 20 Apr 2019 00:22:35 +0000</pubDate>
      <link>https://dev.to/samrocksc/horrible-howto-attach-a-stack-to-debug-3ln</link>
      <guid>https://dev.to/samrocksc/horrible-howto-attach-a-stack-to-debug-3ln</guid>
      <description>&lt;p&gt;So, a few years ago in my infancy of learning how to use Javascript, I came upon a situation where I &lt;em&gt;really&lt;/em&gt; wanted to learn how to attach the function name and file name to my functions.  At the time, I do not think I really understood the concept of stack traces, and the value of an error.  &lt;/p&gt;

&lt;h3&gt;
  
  
  The Circumstance
&lt;/h3&gt;

&lt;p&gt;Assume if you will the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You are early in the development cycle of a cloud function(e.g. lambda)&lt;/li&gt;
&lt;li&gt;Deploying your function takes some time, and so every time you do run it, you want as much &lt;em&gt;valid&lt;/em&gt; feedback from it.&lt;/li&gt;
&lt;li&gt;Because you are deploying a cloud function your ability to inspect it via a debugger is severely limited.  You need to be able to show some breakpoints, or at least WHERE your function is breaking.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here it comes......the &lt;a href="https://www.npmjs.com/package/debug" rel="noopener noreferrer"&gt;debug&lt;/a&gt; module....&lt;/p&gt;

&lt;p&gt;The basis of the debug module is that we can turn on debugging with an environment variable, and then turn it off!  That hits all the check boxes.  We don't have to run it in production, and it's somewhat limited.&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting Out
&lt;/h3&gt;

&lt;p&gt;Let's start by declaring a few variables and debugs per the documentation:&lt;/p&gt;

&lt;p&gt;blah.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const v = require('debug')('verbose');

v('test');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if we were to pass the environment variable &lt;code&gt;DEBUG=verbose&lt;/code&gt;, we would end up with something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;verbose test +0ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get a nice timer on the end of it to, with some colors if you're using it locally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building the Stack
&lt;/h3&gt;

&lt;p&gt;Unfortunately Javascript does not actually carry a stack globally(much like glibc I have come to find out).  The cheapest way to get the stack history is to actually drop the function into an error status.  This &lt;em&gt;shouldn't&lt;/em&gt; be a problem with our proposed use cases, because we are using this for debugging purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const buildStack = () =&amp;gt; {
  const depth = 3;
  if (!this.stackIs) {
    Object.defineProperty(this, 'stackIs', {
      get: function() {
        const orig = Error.prepareStackTrace;
        Error.prepareStackTrace = function(_, stack) {
          return stack;
        };
        const err = new Error();
        Error.captureStackTrace(err, arguments.callee);
        const stack = err.stack;
        Error.prepareStackTrace = orig;
        return stack;
      },
    });
  }

  if (!this.lineIs) {
    Object.defineProperty(this, 'lineIs', {
      get: function() {
        return this.stackIs[depth].getLineNumber();
      },
    });
  }

  if (!this.functionIs) {
    Object.defineProperty(this, 'functionIs', {
      get: function() {
        return this.stackIs[depth].getFunctionName();
      },
    });
  }

  return {
    function: this.functionIs,
    line: this.lineIs,
  };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We use the nice revealing pattern to print out an object with where our debug, and voila!  We now have really awesome debugging!&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6gbgqlv61cdmvq3gxjcf.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6gbgqlv61cdmvq3gxjcf.png" title="awesome debugging" alt="of debugging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Total Snippet &lt;a href="https://gist.github.com/samrocksc/2b9639c99538848be7bb80f99ca63f83" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sources: &lt;a href="https://stackoverflow.com/questions/14172455/get-name-and-line-of-calling-function-in-node-js" rel="noopener noreferrer"&gt;stack overflow&lt;/a&gt;&lt;/p&gt;

</description>
      <category>horriblehowto</category>
      <category>snippets</category>
    </item>
    <item>
      <title>Horrible Howto - Get that Middle Initial</title>
      <dc:creator>Sam Clark</dc:creator>
      <pubDate>Sat, 20 Apr 2019 00:08:00 +0000</pubDate>
      <link>https://dev.to/samrocksc/horrible-howto-get-that-middle-initial-5e5j</link>
      <guid>https://dev.to/samrocksc/horrible-howto-get-that-middle-initial-5e5j</guid>
      <description>&lt;p&gt;I really just wanted to post my first post, and I had just made this snippet, so I decided to post it here!  What the hay!&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;const&lt;/span&gt; &lt;span class="nx"&gt;formatMiddleInitial&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;middleName&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;middleName&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;middleName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;charAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toUpperCase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&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;stuff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;formatMiddleInitial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;clark hark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>horriblesnippets</category>
      <category>howto</category>
      <category>snippet</category>
    </item>
  </channel>
</rss>
