lodash from pairs method and vanilla javaScript options

In lodash there is the _.fromPairs array method that can create a new object where each key is the value of the first element of a nested array in an array of arrays, and the value is the second element in that nested array. It is the inversion of the lodash to pairs method that does the opposite of this. Although that might sound like a mouthful if you take a moment to look at some quick code examples you will find that this is not something that is all that hard. In addition this is one of many lodash method where doing the same with plain old vanilla javaScript is pretty quick and easy. So lets look at some code examples for the lodash from pairs method as well as some plain old vanilla javaScript code examples that do the same thing.

Read More

Basic idle game canvas example

There is a lot that I like about idle games, so I thought I would make another canvas example post that is a basic idle game. This canvas example makes use of a custom trailered utility library that has a method that creates a button layout, which is one way that I go about making menus in a canvas project. I wrote a post in which I get into this button layout method in detail, but will be covering it here also. The game module has an upgrade system that I worked out that is worth writing a thing or two about So I will be getting into that a little here also. In any case this post should server as a good starting point for making a basic idea game with canvas elements and javaScript.

Read More

Node path parse method and the compoents of a path

In the node path core build in module of node js there is the path parse method. This is a method that can be used to parse a path string into an object with properties for each of the parts of a typical file system path. Properties of a path like the dir to a file as well as the filename and file extension.

There is also a user space npm package called path-parse that aims to be a so called ponyfill of this native nodejs path module method. However I do not see much of a need for such a package as this is something that was introduced a long time ago and seems to work just fine.

Read More

Getting the number of days between two javaScript dates.

This will be a quick post on getting the number of days between two javaScript dates. Like most things like this it is important to look at more than one solution, so I will be taking a look at two to say then least. In addition I will break off into some additional examples and related topics that have to do with working with dates in javaScript so things post is not to thin.

Read More

Pointer manager mouse and touch canvas example

This is a canvas example that makes use of what I am calling a pointer manager. Maybe there are other names for such a thing but until I am aware of a better name that is what I am going to call it. Anyway say you want to make a canvas project that will work well with both mouse and touch events. So in other words you do not want to do anything with muti touch on touch devices, and you want all events for both mouse and touch events to be mapped to certain events that are the same. However in order to do so a bit of parsing, adjusting values, and other things need to be preformed before calling some uniform handers that are to be called for both mouse and touch events.
So thins will be a quick post on such a project that does what I just described so lets take a look.

Read More