-
Notifications
You must be signed in to change notification settings - Fork 59
Developers Code Style
Heimdall development follows the Vue.js style guide provided by Vue.js Style Guide
Heimdall development follows the TypeScript style guide provided by TS Style Guide
Use this space to add common code style practices used for developing Heimdall
Recommend using async/await
when possible, and minimize promise chaining. Async/await makes JavaScript code more accessible to developers that aren't as familiar with JavaScript, and much easier to read.
The difference is that in an async function, JavaScript will pause the function execution until the promise settles. With .then()
, the rest of the function will continue to execute but JavaScript won't execute the .then()
callback until the promise settles.
If using promise chaining with .then()
, we need to put any logic we want to execute after the request in the promise chain. Any code placed after fetch() will execute immediately, before the fetch() is done.
From a performance point of view, await is just an internal version of .then()
(doing basically the same thing). The reason to choose one over the other doesn't really have to do with performance, but has to do with desired coding style or coding convenience.
An array is a homogenous collection of values. To simplify, an array is a collection of values of the same data type. It is a user defined type.
Best usages for Filter
vs Map
vs Reduce
vs Foreach
Foreach takes a callback function and run that callback function on each element of array one by one. The 'forEach()' method calls a function for each element in the array.
Basically forEach()
works as a traditional for loop looping over the array and providing you array elements to do operations on them.
Filter provides a callback for every element and returns a filtered array. The filter()
method creates a new array with all elements that pass the test implemented by the provided function.
The main difference between forEach()
and filter()
is that forEach just loop over the array and executes the callback but filter executes the callback and check its return value.
Map provides a callback that modifies (by means of operations) the array elements and save them into the new array, that is returned once the entire mapped array is finished. The map()
method creates a new array with the results of calling a provided function on every element in this array.
Basically map()
creates a new array from calling a function for every array element, it does not execute the function for empty elements, and does not change the original array.
Reduce provides a callback that modifies (by means of removing) array elements into one single value and returns it upon completion.
Basically reduce()
applies a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
Note
The filter()
and map()
methods do not update the existing array, they create and return a new array every time
Helping the overall cybersecurity strength of organizations.
- Home
- How to create a release
- Environment Variables Configuration
- Heimdall Authentication Methods
- Heimdall API Documentation
- Group and User Management
- Heimdall Interface Connections
- Heimdall Architecture Information
- Heimdall Class Diagrams
- Heimdall Development Tips & Tricks
- Heimdall Frontend Components
- Heimdall Processes Documentation
- Heimdall Heroku Documentation
- Developers Code Style
- Troubleshooting
- HDF Converter Mappings
- HDF Converters How Tos
- Manual Attestations
- Control Correlation Identifier (CCI) Converter