File tree Expand file tree Collapse file tree 4 files changed +139
-1
lines changed Expand file tree Collapse file tree 4 files changed +139
-1
lines changed Original file line number Diff line number Diff line change 1+ language : node_js
2+ node_js :
3+ - 12
4+ - 10
5+ - 8
Original file line number Diff line number Diff line change 33 "version" : " 0.0.1" ,
44 "description" : " This method is used to transpose 2D array." ,
55 "main" : " dist/index.js" ,
6+ "types" : " types/index.d.ts" ,
67 "scripts" : {
78 "dev" : " nodemon src/index.ts" ,
89 "prepare" : " npm run build" ,
910 "build" : " tsc" ,
10- "test" : " echo \" Error: no test specified\" && exit 1"
11+ "test" : " jest"
12+ },
13+ "bugs" : {
14+ "url" : " https://github.com/grafikri/transpose-2D-array/issues"
15+ },
16+ "repository" : {
17+ "type" : " git" ,
18+ "url" : " git+https://github.com/grafikri/transpose-2D-array.git"
1119 },
1220 "keywords" : [
1321 " tranpose" ,
1624 " javascript" ,
1725 " typescript"
1826 ],
27+ "files" : [
28+ " dist" ,
29+ " types"
30+ ],
1931 "author" : " Serhan Coşkun" ,
2032 "license" : " ISC" ,
2133 "devDependencies" : {
2234 "@types/node" : " ^13.7.0" ,
35+ "jest" : " ^25.1.0" ,
2336 "nodemon" : " ^2.0.2" ,
37+ "np" : " ^6.0.0" ,
2438 "typescript" : " ^3.7.5"
2539 }
2640}
Original file line number Diff line number Diff line change 1+ const transpose2D = require ( "../dist" )
2+
3+ describe ( "Transpose" , ( ) => {
4+ it ( "Basic transpose" , ( ) => {
5+ const given = [ [ [ 1 ] ] , [ [ 2 ] ] ]
6+
7+ const expected = [ [ [ 1 ] , [ 2 ] ] ]
8+
9+ expect ( transpose2D ( given ) ) . toStrictEqual ( expected )
10+ } )
11+
12+ it ( "Vertical transpose" , ( ) => {
13+ const given = [
14+ [ [ 1 ] , [ 1 ] , [ 1 ] , [ 1 ] ] ,
15+ [ [ 2 ] , [ 2 ] , [ 2 ] , [ 2 ] ]
16+ ]
17+
18+ const expected = [
19+ [ [ 1 ] , [ 2 ] ] ,
20+ [ [ 1 ] , [ 2 ] ] ,
21+ [ [ 1 ] , [ 2 ] ] ,
22+ [ [ 1 ] , [ 2 ] ]
23+ ]
24+
25+ expect ( transpose2D ( given ) ) . toStrictEqual ( expected )
26+ } )
27+
28+ it ( "Horizontal transpose" , ( ) => {
29+ const given = [
30+ [ [ 1 ] , [ 2 ] ] ,
31+ [ [ 1 ] , [ 2 ] ] ,
32+ [ [ 1 ] , [ 2 ] ] ,
33+ [ [ 1 ] , [ 2 ] ]
34+ ]
35+
36+ const expected = [
37+ [ [ 1 ] , [ 1 ] , [ 1 ] , [ 1 ] ] ,
38+ [ [ 2 ] , [ 2 ] , [ 2 ] , [ 2 ] ]
39+ ]
40+
41+ expect ( transpose2D ( given ) ) . toStrictEqual ( expected )
42+ } )
43+
44+ it ( "Square transpose" , ( ) => {
45+ const given = [
46+ [ [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] ] ,
47+ [ [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] ] ,
48+ [ [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] ] ,
49+ [ [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] ]
50+ ]
51+
52+ const expected = [
53+ [ [ 1 ] , [ 1 ] , [ 1 ] , [ 1 ] ] ,
54+ [ [ 2 ] , [ 2 ] , [ 2 ] , [ 2 ] ] ,
55+ [ [ 3 ] , [ 3 ] , [ 3 ] , [ 3 ] ] ,
56+ [ [ 4 ] , [ 4 ] , [ 4 ] , [ 4 ] ]
57+ ]
58+
59+ expect ( transpose2D ( given ) ) . toStrictEqual ( expected )
60+ } )
61+
62+ it ( "Complex transpose" , ( ) => {
63+ const given = [
64+ [
65+ [ 1 , 1 ] ,
66+ [ 2 , 2 ] ,
67+ [ 3 , 3 ] ,
68+ [ 4 , 4 ]
69+ ] ,
70+ [
71+ [ 1 , 1 ] ,
72+ [ 2 , 2 ] ,
73+ [ 3 , 3 ] ,
74+ [ 4 , 4 ]
75+ ] ,
76+ [
77+ [ 1 , 1 ] ,
78+ [ 2 , 2 ] ,
79+ [ 3 , 3 ] ,
80+ [ 4 , 4 ]
81+ ] ,
82+ [
83+ [ 1 , 1 ] ,
84+ [ 2 , 2 ] ,
85+ [ 3 , 3 ] ,
86+ [ 4 , 4 ]
87+ ]
88+ ]
89+
90+ const expected = [
91+ [
92+ [ 1 , 1 ] ,
93+ [ 1 , 1 ] ,
94+ [ 1 , 1 ] ,
95+ [ 1 , 1 ]
96+ ] ,
97+ [
98+ [ 2 , 2 ] ,
99+ [ 2 , 2 ] ,
100+ [ 2 , 2 ] ,
101+ [ 2 , 2 ]
102+ ] ,
103+ [
104+ [ 3 , 3 ] ,
105+ [ 3 , 3 ] ,
106+ [ 3 , 3 ] ,
107+ [ 3 , 3 ]
108+ ] ,
109+ [
110+ [ 4 , 4 ] ,
111+ [ 4 , 4 ] ,
112+ [ 4 , 4 ] ,
113+ [ 4 , 4 ]
114+ ]
115+ ]
116+
117+ expect ( transpose2D ( given ) ) . toStrictEqual ( expected )
118+ } )
119+ } )
You can’t perform that action at this time.
0 commit comments