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 18, 2021
1 parent 1782957 commit b6317d8
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: codespell
uses: codespell-project/actions-codespell@master
with:
skip: .git,*.png,*.jpg,*.svg,*.sum,*.json,*.lock
skip: .git,*.png,*.jpg,*.svg,*.sum,*.json,*.lock,*.js.map,*.html
ignore_words_list: aks,keyserver,atleast,dne,ser,ist,files,ba,dum,iam,te,parm,bumb,nd,sie,GIR,afterAll
check_filenames: true
check_hidden: true
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@types/prettier": "^2.1.5",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"semantic-release": ">=17.2.3",
"axios": "^0.21.1",
"crypto": "^1.0.1",
"dateformat": "^4.5.1",
Expand All @@ -68,45 +67,46 @@
"del-cli": "^3.0.1",
"eslint": "^7.18.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-github": "^4.1.1",
"eslint-plugin-github": "^4.1.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-spellcheck": "0.0.8",
"folio": "^0.3.18",
"yaml": "^1.10.0",
"import-fresh": "^3.2.1",
"parse-json": "^5.0.0",
"path-type": "^4.0.0",
"gradient-string": "^1.2.0",
"license-badger": "^0.18.0",
"remark-cli": "^9.0.0",
"remark-validate-links": "^10.0.2",
"remark-lint-code-block-style": "^2.0.1",
"remark-lint-ordered-list-marker-value": "^2.0.1",
"remark-preset-davidtheclark": "^0.12.0",
"typedoc": "^0.20.28",
"import-fresh": "^3.2.1",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jsdom": "16.4.0",
"jsdom-global": "3.0.2",
"license-badger": "^0.18.0",
"markdown-link-check": "^3.8.6",
"object-hash": "^2.1.1",
"parse-json": "^5.0.0",
"path-type": "^4.0.0",
"prettier": "^2.1.2",
"pretty-quick": "^3.1.0",
"randomcolor": "^0.5.4",
"remark-cli": "^9.0.0",
"remark-lint-code-block-style": "^2.0.1",
"remark-lint-ordered-list-marker-value": "^2.0.1",
"remark-preset-davidtheclark": "^0.12.0",
"remark-validate-links": "^10.0.2",
"rimraf": "^3.0.2",
"semantic-release": ">=17.2.3",
"slugify": "^1.4.6",
"ts-jest": "^26.4.4",
"ts-node": ">=9.0.0",
"tsdx": "^0.14.1",
"typed-rest-client": "^1.8.1",
"typedoc": "^0.20.28",
"typescript": "^4.1.3",
"typescript-object-utils": "^0.4.1",
"utility-types": "^3.10.0",
"vague-time": "^2.4.2",
"ws": "^7.4.3",
"yaml": "^1.10.0",
"yaspeller": "^7.0.0"
},
"repository": {
Expand Down
17 changes: 17 additions & 0 deletions src/checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export namespace Checkers {
import valueError = Errors.valueError
import validationError = Errors.validationError

const { hasOwnProperty: hasOwnProp } = Object.prototype

export const getClass = (obj: any): string | null => {
const str = Object.prototype.toString.call(obj)
const value = /^\[object (.*)]$/.exec(str)
Expand Down Expand Up @@ -365,6 +367,21 @@ export namespace Checkers {

return isFunction(obj.hasOwnProperty) ? obj.hasOwnProperty(prop) : prop in obj
}

/**
* @private
* @module comparators
* @param obj initial input object to verify
* @param prop initial input {@link PropertyKey} to validate by
* @return {@link boolean} true - if property exists, false - otherwise
*/
export const hasProperty2 = (obj: any, prop: PropertyKey): boolean => {
const proto = obj.__proto__ || obj.constructor.prototype

//return (prop in obj) && (!(prop in proto) || proto[prop] !== obj[prop]);
return hasOwnProp.call(obj, prop) || hasOwnProp.call(proto, prop) || proto[prop] === obj[prop]
}

/**
* Checks for an object to be of the specified type; if not throws an Error.
*/
Expand Down
16 changes: 2 additions & 14 deletions src/comparators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Errors } from './errors'

export namespace Comparators {
import valueError = Errors.valueError
import hasProperty = Checkers.hasProperty

/**
* Comparator types
Expand All @@ -16,20 +17,6 @@ export namespace Comparators {
*/
export type ComparatorMode = 'asc' | 'desc'

/**
* @private
* @module comparators
* @param obj initial input object to verify
* @param prop initial input {@link PropertyKey} to validate by
* @return {@link boolean} true - if property exists, false - otherwise
*/
const hasProperty = (obj: any, prop: PropertyKey): boolean => {
const proto = obj.__proto__ || obj.constructor.prototype

//return (prop in obj) && (!(prop in proto) || proto[prop] !== obj[prop]);
return prop in obj || prop in proto || proto[prop] === obj[prop]
}

/**
* @public
* @module comparators
Expand All @@ -44,6 +31,7 @@ export namespace Comparators {

if (typeof a === typeof b) {
if (hasProperty(a, 'compareTo')) {
console.log(a.compareTo)
return a.compareTo(b)
}

Expand Down
16 changes: 16 additions & 0 deletions src/maths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Checkers } from './checkers'
import { Errors } from './errors'
import { Processor } from '../typings/function-types'
import { Sorting } from './sorting'
import { Utils } from './utils'

export namespace Maths {
import isIntNumber = Checkers.isIntNumber
Expand All @@ -14,6 +15,7 @@ export namespace Maths {
import isRealNumber = Checkers.isRealNumber
import typeError = Errors.typeError
import isObject = Checkers.isObject
import Commons = Utils.Commons

export const sqrt = Math.sqrt
export const atan2 = Math.atan2
Expand All @@ -24,6 +26,20 @@ export namespace Maths {
export const PiBy2 = Math.PI / 2
export const invLog2 = 1 / Math.log(2)

export const init = (() => {
if (!isFunction(Math['sign'])) {
Commons.defineStaticProperty(Math, 'sign', {
value(value: number): number {
value = +value // преобразуем в число
if (value === 0 || isNaN(value)) {
return value
}
return value > 0 ? 1 : -1
},
})
}
})()

export namespace Helpers {
import shellSort = Sorting.shellSort
export const memoizer = (
Expand Down
16 changes: 8 additions & 8 deletions tests/checkers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ export namespace Checkers_Test {

describe('Check object class', () => {
it('it should return valid object class', () => {
expect(getClass(1)).toEqual('number')
expect(getClass(1.1)).toEqual('number')
expect(getClass('1')).toEqual('string')
expect(getClass('test')).toEqual('string')
expect(getClass([])).toEqual('array')
expect(getClass(true)).toEqual('boolean')
expect(getClass(null)).toEqual('null')
expect(getClass(undefined)).toEqual('undefined')
expect(getClass(1)).toEqual('Number')
expect(getClass(1.1)).toEqual('Number')
expect(getClass('1')).toEqual('String')
expect(getClass('test')).toEqual('String')
expect(getClass([])).toEqual('Array')
expect(getClass(true)).toEqual('Boolean')
expect(getClass(null)).toEqual('Null')
expect(getClass(undefined)).toEqual('Undefined')
})
})

Expand Down
48 changes: 48 additions & 0 deletions tests/comparators.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Comparators } from '../src'

export namespace Comparators_Test {

import compareByOrder = Comparators.compareByOrder;
import compare = Comparators.compare;
beforeAll(() => {
console.log("Comparators test suite started")
console.time("Execution time took")
})

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

describe('Check compare by order result', () => {
it('it should return valid result by compare order', () => {
expect(compareByOrder(1, 1)).toEqual(0)
expect(compareByOrder(1, 2)).toEqual(-1)
expect(compareByOrder(2, 1)).toEqual(1)

expect(compareByOrder('test', 'test')).toEqual(0)
expect(compareByOrder('test', 'retest')).toEqual(1)
expect(compareByOrder('retest', 'test')).toEqual(-1)

expect(compareByOrder(true, true)).toEqual(0)
expect(compareByOrder(true, false)).toEqual(1)
expect(compareByOrder(false, true)).toEqual(-1)
})
})

describe('Check compare result', () => {
it('it should return valid result by compare', () => {
expect(compare(1, 1)).toEqual(-0)
expect(compare(1, 2)).toEqual(-1)
expect(compare(2, 1)).toEqual(1)

expect(compare('test', 'test')).toEqual(-0)
expect(compare('test', 'retest')).toEqual(1)
expect(compare('retest', 'test')).toEqual(-1)

expect(compare(true, true)).toEqual(-0)
expect(compare(true, false)).toEqual(1)
expect(compare(false, true)).toEqual(-1)
})
})
}

0 comments on commit b6317d8

Please sign in to comment.