This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Asyncronously iterate over an array | |
* @example | |
* var array = [1,2,3]; | |
* console.log(`This is just the beginning!`); | |
* await asyncForEach(array, function (element) { | |
* console.log(`Iterating ${element}`); | |
* }); | |
* console.log(`Done!`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class XmlTools { | |
private readonly closingPattern: RegExp; | |
private readonly namePattern: RegExp; | |
private readonly nestPattern: RegExp; | |
private preparedStatement: object = {}; | |
private rawStatement: string; | |
constructor() { | |
this.closingPattern = /<\/([\w]+)[^>]*\>/g; | |
this.namePattern = /(?![</])([^ >][A-Za-z0-9]{1,}){1}/g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Asynchronously calculate a percentage to a given precision. | |
* @example | |
* const denominator: number = 435; | |
* const numberator: number = 37; | |
* const precision: number = 2; | |
* const percentage: number = await calculatePercentage(denominator, numerator, precision); | |
* console.log(`${numerator} is ${percentage} percent of ${denominator} to a precision of ${precision}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateArray = (start: number, length: number, skipValues: number[] = []): number[] => { | |
const outputArray: number[] = []; | |
// Length of array should be length + skipValues length since we will be skipping that many iterations of i | |
length = length + skipValues.length; | |
// Loop until proper array length is reached | |
for (let i=start;i<length-1;i++) { | |
// If the value of i isn't contained in skipValues, we push it to outputArray; |