Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
presets: ['@babel/preset-env'],
};
17 changes: 0 additions & 17 deletions index.html

This file was deleted.

14,016 changes: 14,016 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --config ./webpack/webpack.dev.js --open HOST=0.0.0.0",
"scripts": {
"test": "jest",
"lint": "eslint ./src",
"lint:watch": "esw --watch",
"stylelint": "stylelint './src/**/*.css'",
"precommit": "npm run lint && npm run stylelint",
"prepush": "npm run test"
"stylelint": "stylelint './src/**/*.css'"
},
"repository": {
"type": "git",
Expand All @@ -30,6 +27,10 @@
"html-webpack-plugin": "^3.2.0",
"husky": "^1.1.2",
"jest": "^23.6.0",
"@babel/core": "*",
"@babel/preset-env": "*",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "*",
"node-sass": "^4.9.4",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
Expand Down
21 changes: 19 additions & 2 deletions src/dragon-curve/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
export const dragonCurve = n => {
// logic...
};

const reverseString = string => {
return string.split('')
.map(el => {
return el === '1' ? '0' : '1';
})
.reverse()
.join('');
};

let dragonRow = '1';

n -= 1;
while (n > 0){
dragonRow += '1' + reverseString(dragonRow);
n -= 1;
}
return dragonRow;
};
20 changes: 17 additions & 3 deletions src/dragon-curve/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import {dragonCurve} from './index'
import {dragonCurve} from './index';

describe('dragonCurve::', () => {
// need to implement
});
it('Function returns dragon row with curves', () => {
expect(dragonCurve(1)).toEqual('1');
});

it('Function returns dragon row with curves', () => {
expect(dragonCurve(2)).toEqual('110');
});

it('Function returns dragon row with curves', () => {
expect(dragonCurve(3)).toEqual('1101100');
});

it('Function returns dragon row with curves', () => {
expect(dragonCurve(4)).toEqual('110110011100100');
});
});
1 change: 0 additions & 1 deletion src/main.js

This file was deleted.

14 changes: 12 additions & 2 deletions src/rotate-matrix/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
export const rotateMatrix = arr => {
// logic...
};
const resultArray = [];
const len = arr.length;
let rowArray = [];

for (let col = 0; col < len; col++){
for (let row = 0; row < len; row++){
rowArray.push(arr[row][col]);
}
resultArray.push(rowArray);
rowArray = [];
}
return resultArray;
};
58 changes: 57 additions & 1 deletion src/rotate-matrix/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
import {rotateMatrix} from './index'

expect.extend({
compareTwoArrays (received, array) {
let pass = true;
const len = array.length;
for(let row = 0; row < len; row++){
for(let col = 0; col < len; col++){
if (received[row][col] !== array[row][col]){
pass = false;
}
}
}
if (pass) {
return {
message: () =>
'Test OK',
pass: true,
};
} else {
return {
message: () =>
'Test Fail',
pass: false,
};
}
},
});

const arr1 = [
[1, 2],
[3, 4]
];

const arr2 = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
];

const res1 = [
[1, 3],
[2, 4]
];

const res2 = [
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
];

describe('rotateMatrix::', () => {
// need to implement

it('That function returns rotated array', () => {
expect(rotateMatrix(arr1)).compareTwoArrays(res1);
});

it('That function returns rotated array', () => {
expect(rotateMatrix(arr2)).compareTwoArrays(res2);
});
});
9 changes: 0 additions & 9 deletions src/styles/main.scss

This file was deleted.

55 changes: 0 additions & 55 deletions webpack/webpack.dev.js

This file was deleted.