Use Snippets tab of Chrome browser inspector to run your code instead of console

While developing projects, we may need to take help from other projects hosted on github.com. General procedure involves cloning the repository, because it is not easy to navigate through the files on github.com.

https://github.com/conwnet/github1s solves this simple issue of easing navigation through files in browser itself

Checkout below repo link

https://github1s.com/conwnet/github1s

Instead of github.com it is github1s.com

You can easily navigate through any github public repository, by adding 1s after Github in the repo link

I am writing this code snippet that should be helpful to you as a utility function.
It will throw an exact error for you when you want to assert, that something should not be null or undefined

export const shouldNotBeNull = (container: any) => {const entries = Object.entries(container);let error = '';const getErrorMessage = (variable: string, token: string) =>`${variable} should not be ${token}`;const addError = (errorString: string) => (error += errorString);for (let i = 0; i < entries.length; i++) {let [key, value] = entries[i];if (value === null) {addError(getErrorMessage(key, 'null'));}if (value === undefined) {addError(getErrorMessage(key, 'undefined'));}}if (error.length > 0) {throw new Error(error);}};

link to gist
Thank you!

Suppose we have an API /getTransaction with following response

{
transactionId: “TCC1232434”,
bankName: “ABC”,
accountNumber: 12131314,
transactionComments: "comments"
}

We might have another API to create the transaction and generally, transactionComments is an optional field

So while creating a transaction if someone does not enter transaction comments, nothing is stored…

Akshay Jain

I love learning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store