Skip to content

Commit

Permalink
docs: updates on workflows
Browse files Browse the repository at this point in the history
Added information on documentation
  • Loading branch information
ADMSK\AVROGAL1 committed Mar 9, 2021
1 parent 911a64f commit b79842b
Show file tree
Hide file tree
Showing 23 changed files with 491 additions and 189 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"axios": "^0.21.1",
"crypto": "^1.0.1",
"dateformat": "^4.5.1",
"dayjs": "^1.10.4",
"dayjs-precise-range": "^1.0.1",
Expand Down
18 changes: 18 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ErrorData, ErrorType } from '../typings/domain-types'

import { Logging } from './logging'
import { Utils } from './utils'
import { Checkers } from './checkers'
Expand Down Expand Up @@ -145,6 +146,23 @@ export namespace Errors {
}
}

/**
* QueryParseError
* @desc Class representing query parse error
*/
export class QueryParseError extends GeneralError {
/**
* Unsupported language error constructor by input parameters
* @param message initial input {@link string} message
* @param start initial input {@link number} start position
* @param end initial input {@link number} end position
* @param args initial input {@link Array} of arguments
*/
constructor(readonly message: string, readonly start: string, readonly end: string, ...args: any[]) {
super(ErrorType.parser_error, message, args)
}
}

export const newError = (type: ErrorType, message: string): ErrorData => {
return { type, message }
}
Expand Down
14 changes: 14 additions & 0 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import {
rmdirSync,
statSync,
unlinkSync,
writeFileSync,
} from 'fs'
import path, { join } from 'path'
import { randomBytes } from 'crypto'
import { execSync } from 'child_process'
import { Strings } from './strings'

export namespace Files {
import uniqueId = Strings.uniqueId

export const createFilePath = (locations: { path; name; extension }): string => {
const date = new Date()
const timestamp = `${date.getFullYear()}_${
Expand All @@ -37,6 +42,15 @@ export namespace Files {
}
}

export const createRandomDataFile = (numBytes: number): string => {
const path = join(process.cwd(), uniqueId())
const buffer = randomBytes(numBytes)

writeFileSync(path, buffer)

return path
}

export const checkFilesExist = async (fileList: string[]): Promise<boolean> => {
return fileList.every(async (file: string) => {
return await checkFileExist(file)
Expand Down
11 changes: 11 additions & 0 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ export namespace Functions {
subType.prototype = subProto
}

export const makeBackgroundable = <T extends (...args: any[]) => any>(
pool: any,
func: T,
): ((...funcArgs: Parameters<T>) => Promise<ReturnType<T>>) => {
const funcName = func.name

return (...args: Parameters<T>): ReturnType<T> => {
return pool.exec(funcName, args)
}
}

export const composeAsync = async (...funcArgs) => async value =>
// eslint-disable-next-line github/no-then
await funcArgs.reduce((acc, val) => acc.then(val), Promise.resolve(value))
Expand Down
6 changes: 6 additions & 0 deletions src/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export namespace Strings {
}
})()

export const uniqueId = (): string => {
return Math.random()
.toString(36)
.substring(Number(2 + new Date().getTime().toString(36)))
}

export const combinations = (value: string): string[] => {
let str = ''
const res: string[] = []
Expand Down
10 changes: 10 additions & 0 deletions tests/arrays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export namespace Arrays_Test {
import findArray = Arrays.findArray;
import insert = Arrays.insert;

beforeAll(() => {
console.log("Arrays test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Arrays test suite finished")
console.timeEnd("Execution time took")
})

describe('Check iteration on array of elements', () => {
it('it should perform valid array iteration', () => {
let array: any[] = []
Expand Down
10 changes: 10 additions & 0 deletions tests/browsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export namespace Browsers_Test {
import windowWidth = Browsers.windowWidth;
import windowHeight = Browsers.windowHeight;

beforeAll(() => {
console.log("Browsers test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Browsers test suite finished")
console.timeEnd("Execution time took")
})

describe('Check DOM element matches', () => {
it('it should return true when DOM elements matches', () => {
const div = document.createElement('div')
Expand Down
14 changes: 12 additions & 2 deletions tests/checkers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export namespace Checkers_Test {
import isSafeInt = Checkers.isSafeInt;
import getClass = Checkers.getClass;

beforeAll(() => {
console.log("Checkers test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Checkers test suite finished")
console.timeEnd("Execution time took")
})

describe('Check value is in range', () => {
it('it should return true when value is in range without bounds', () => {
expect(isInRange(1, 0, 6)).toBeTruthy()
Expand Down Expand Up @@ -148,8 +158,8 @@ export namespace Checkers_Test {
expect(isSafeInt(1)).toBeTruthy()
expect(isSafeInt(Number.MAX_SAFE_INTEGER)).toBeTruthy()
expect(isSafeInt(Number.MIN_SAFE_INTEGER)).toBeTruthy()
expect(isSafeInt(Number.MAX_VALUE)).toBeTruthy()
expect(isSafeInt(Number.MIN_VALUE)).toBeTruthy()
expect(isSafeInt(Number.MAX_VALUE)).toBeFalsy()
expect(isSafeInt(Number.MIN_VALUE)).toBeFalsy()

expect(isSafeInt(1.1)).toBeFalsy()
expect(isSafeInt('1')).toBeFalsy()
Expand Down
10 changes: 10 additions & 0 deletions tests/commons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export namespace Commons_Test {
import toPrimitive = Commons.toPrimitive;
import hasProperty = Checkers.hasProperty;

beforeAll(() => {
console.log("Commons test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Commons test suite finished")
console.timeEnd("Execution time took")
})

describe('Check isEmpty by input object', () => {
it('it should return true when value is null', () => {
expect(isEmpty(null)).toEqual(true)
Expand Down
10 changes: 10 additions & 0 deletions tests/datetimes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import { DataTimes } from '../src'
export namespace DateTimes_Test {
import diffDatesAsString = DataTimes.diffDatesAsString;

beforeAll(() => {
console.log("DateTimes test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("DateTimes test suite finished")
console.timeEnd("Execution time took")
})

describe('Check diff dates as string', () => {
it('it should return valid dates differences', () => {
expect(diffDatesAsString(new Date('2020-03-02T15:56:00')).join('-')).toEqual("1 year-2 days")
Expand Down
18 changes: 9 additions & 9 deletions tests/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export namespace Errors_Test {
class SubTestError extends TestError {
}

describe('Test extendable error type', () => {
beforeAll(() => {
console.log("Test suite started")
console.time("Execution time took")
});
beforeAll(() => {
console.log("Errors test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Test suite finished")
console.timeEnd("Execution time took")
});
afterAll(() => {
console.log("Errors test suite finished")
console.timeEnd("Execution time took")
})

describe('Test extendable error type', () => {
it('it should be a valid error instance of', () => {
const err = new ExtendableError(ErrorType.value_error, 'Value error')
expect(err).toBeInstanceOf(Error)
Expand Down
10 changes: 10 additions & 0 deletions tests/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ export namespace Commons_Test {
import autoCurry = Functions.autoCurry;
import getFunctionArgs = Functions.getFunctionArgs;

beforeAll(() => {
console.log("Functions test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Functions test suite finished")
console.timeEnd("Execution time took")
})

const sequence = (start: number, end: number): number[] => {
const result: number[] = []

Expand Down
60 changes: 60 additions & 0 deletions tests/maths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ export namespace Maths_Test {
export namespace Geometry_Test {
import Calculations = Maths.Calculations;

beforeAll(() => {
console.log("Geometry test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Geometry test suite finished")
console.timeEnd("Execution time took")
})

describe('Check rectangular area calculation', () => {
const rect = [{ 'x1': 0, 'x2': 2, 'y1': 14, 'y2': 15 }, {
'x1': 1,
Expand Down Expand Up @@ -59,6 +69,16 @@ export namespace Maths_Test {
export namespace Algebra_Test {
import Calculations = Maths.Calculations;

beforeAll(() => {
console.log("Algebra test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Algebra test suite finished")
console.timeEnd("Execution time took")
})

describe('Check greatest common divisor calculation', () => {
it('it should return valid GCD', () => {
expect(Calculations.Algebra.gcd(7, 10)).toEqual(1)
Expand Down Expand Up @@ -91,6 +111,16 @@ export namespace Maths_Test {
export namespace Trigonometry_Test {
import Calculations = Maths.Calculations;

beforeAll(() => {
console.log("Trigonometry test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Trigonometry test suite finished")
console.timeEnd("Execution time took")
})

describe('Check triangle square calculation', () => {
it('it should return valid triangle square', () => {
expect(Calculations.Trigonometry.log10(100)).toEqual(2)
Expand All @@ -102,6 +132,16 @@ export namespace Maths_Test {
export namespace Areas_Test {
import Calculations = Maths.Calculations;

beforeAll(() => {
console.log("Areas test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Areas test suite finished")
console.timeEnd("Execution time took")
})

describe('Check triangle square calculation', () => {
it('it should return valid triangle square', () => {
expect(Calculations.Areas.triangleSquare([[3, 7], [5, 9], [8, 6]])).toEqual(6)
Expand All @@ -113,6 +153,16 @@ export namespace Maths_Test {
export namespace Helpers_Test {
import sum = Maths.Helpers.sum;

beforeAll(() => {
console.log("Helpers test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Helpers test suite finished")
console.timeEnd("Execution time took")
})

describe('Check sum calculation by input values', () => {
it('it should calculate valid sum', () => {
expect(sum(3, 7)).toEqual(10)
Expand All @@ -125,6 +175,16 @@ export namespace Maths_Test {
export namespace Numerals_Test {
import Numerals = Maths.Numerals;

beforeAll(() => {
console.log("Numerals test suite started")
console.time("Execution time took")
})

afterAll(() => {
console.log("Numerals test suite finished")
console.timeEnd("Execution time took")
})

describe('Check fibonacci calculation', () => {
it('it should return a valid fibonacci number', () => {
expect(Numerals.fibonacci2(3)).toEqual(2)
Expand Down
Loading

0 comments on commit b79842b

Please sign in to comment.