Skip to content

Commit

Permalink
config/ pre-commit-config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolnetto committed Jan 24, 2022
1 parent f71673f commit 5670613
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 41 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
18 changes: 0 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,8 @@ repos:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v8.7.0' # Use the sha / tag you want to point at
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
additional_dependencies:
- eslint@4.15.0
- eslint-config-google@0.7.1
- eslint-loader@1.6.1
- eslint-plugin-react@6.10.3
- babel-eslint@6.1.2
- repo: https://github.com/pre-commit/mirrors-fixmyjs
rev: 'v2.0.0' # Use the sha / tag you want to point at
hooks:
- id: fixmyjs
args: ['-l', '-c', '.jshintrc']
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.10
hooks:
Expand Down
12 changes: 12 additions & 0 deletions data-structures/graph/VisitMetadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Helper class for visited vertex metadata.
*/
export default class VisitMetadata {
constructor({ discoveryTime, lowDiscoveryTime }) {
this.discoveryTime = discoveryTime;
this.lowDiscoveryTime = lowDiscoveryTime;
// We need this in order to check graph root node, whether it has two
// disconnected children or not.
this.independentChildrenCount = 0;
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"scripts": {
"start": "nodemon ./server.js",
"test": "jest",
"lint": "eslint .",
"lint": "./node_modules/.bin/eslint ."
"update": "npm i -g npm-check-updates && ncu -u && npm update",
"coverage": "npm run test -- --coverage"
},
"devDependencies": {
"@types/jest": "27.4.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"canvas": "2.9.0",
"eslint-plugin-import": "2.25.4",
"eslint": "^8.7.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.0.0",
"jest": "^27.4.7"
},
Expand Down
103 changes: 82 additions & 21 deletions utils/arrays/arrays.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,103 @@
import _ from 'lodash';
import Iter from 'es-iter';

export const getAllIndexes = (arr, val) => {
var indexes = [], i;

for(i = 0; i < arr.length; i++)
if (arr[i] === val)
const indexes = [];
let i;

for (i = 0; i < arr.length; i++) {
if (arr[i] === val) {
indexes.push(i);

}
}

return indexes;
}
};

export const cyclicSort = (array, index) => {
if(array.length < index){
console.error('Error: Provided index '+index+' greater than array length '+array.length);
if (array.length < index) {
const category = 'Error';
const subject = 'Provided index '+index;
const condition = 'greater than array length '+array.length;

console.error(category+' : '+subject+' '+condition);
}
let head = array.slice(index);
let tail = array.slice(0, index);

const head = array.slice(index);
const tail = array.slice(0, index);

return head.concat(tail);
}
};

export const isCyclicEqual = (control_, treatment_) => {
let control_len = control_.length;
let treatment_len = treatment_.length;

if(control_len != treatment_len){
if (control_.length != treatment_.length) {
return false;
}

for(let i=0; i<treatment_len; i++){
if(cyclicSort(treatment_, i) == control_){
return true
for (let i=0; i<treatment_.length; i++) {
if (cyclicSort(treatment_, i) == control_) {
return true;
}
}

return false;
}
};

export const getUniques = (vec) => {
return Array.from(new Set(vec));
}
};

export const extendedVenn = (sets) => {
const keys = Object.keys(sets);
const extended_venn = {};
let comb_sets_inter = {};
let comb_sets_union = {};
let comb_sets_excl = {};

for (const i of _.rangeRight(1, keys.length+1)) {
for (const comb_keys of new Iter(keys).combinations(i)) {
const comb_sets = comb_keys.map((key) => sets[key]);

// Intersection of elements
comb_sets_inter = Object
.values(comb_sets)
.reduce((acc, arr) => arr.filter(Set.prototype.has,
new Set(acc)));

// No intersection means no exclusive value
if (comb_sets_inter.length==0) {
break;
}

const ev_keys_i_to_n = [];
Object
.keys(extended_venn)
.forEach(
(key) => {
if (key.split(',').length >= i) {
ev_keys_i_to_n.push(key);
};
},
);

// Intersection of elements
comb_sets_union = ev_keys_i_to_n.length==0 ? [] :
ev_keys_i_to_n.reduce(
(acc, key) => [
...new Set(
[
...acc,
...extended_venn[key],
])], []);

// Exclusive combination set elements
comb_sets_excl = _.difference(comb_sets_inter, comb_sets_union);

if (comb_sets_inter.length!=0) {
extended_venn[comb_keys.toString()] = comb_sets_excl;
}
}
}

return extended_venn;
};

0 comments on commit 5670613

Please sign in to comment.