File tree Expand file tree Collapse file tree 5 files changed +43
-24
lines changed
lib/data-structures/chapter-1 Expand file tree Collapse file tree 5 files changed +43
-24
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+
3+ # Logs
4+ logs
5+ * .log
6+
7+ # Mac specific
8+ DS_Store
Original file line number Diff line number Diff line change 1- ####Run the code and test
2- This project uses Mocha and Chai for testing:
1+ # Cracking the Coding Interview 6th Edition - JavaScript
32
43<br >
5- #####Install dependencies:
4+
5+ ## Install dependencies:
66``` bash
77npm install
8- npm install -g mocha
9- npm install -g chai
108```
119
1210<br >
13- #####Run tests:
11+
12+ ## Test
13+
1414``` bash
15- mocha --recursive
15+ npm test
1616```
1717
18- <br >
19- #####Add new npm modules:
18+ If you just want to lint
2019``` bash
21- npm install --save < package name >
20+ npm run lint
2221```
22+
23+ <br >
Original file line number Diff line number Diff line change 11module . exports = Strings_1_8 = ( function ( ) {
2- var _isSubstring = function ( str1 , str2 ) {
3- return str1 . indexOf ( str2 ) != - 1
4- }
5- var _sameLengthAndNotBlank = function ( str1 , str2 ) {
2+ var isSubstring = function ( str1 , str2 ) {
3+ return str1 . indexOf ( str2 ) != - 1 ;
4+ } ;
5+
6+ var sameLengthAndNotBlank = function ( str1 , str2 ) {
67 var len = str1 . length ;
7- return len === str2 . length && len > 0
8- }
8+ return len === str2 . length && len > 0 ;
9+ } ;
10+
911 return {
1012 isRotation : function ( str1 , str2 ) {
11- if ( ! _sameLengthAndNotBlank ( str1 , str2 ) ) return false ;
12- if ( _isSubstring ( str1 + str1 , str2 ) ) return true ;
13+ if ( ! sameLengthAndNotBlank ( str1 , str2 ) ) {
14+ return false ;
15+ }
16+ if ( isSubstring ( str1 + str1 , str2 ) ) {
17+ return true ;
18+ }
1319 }
14- }
20+ } ;
1521} ( ) ) ;
Original file line number Diff line number Diff line change 22 "name" : " CrackingJS" ,
33 "version" : " 0.0.1" ,
44 "description" : " Data Structures and Algorithms in Javascript" ,
5+ "scripts" : {
6+ "lint" : " eslint lib/**/*.js test/**/*.js" ,
7+ "test" : " npm run lint && mocha --recursive"
8+ },
59 "dependencies" : {
6- "mocha" : " *" ,
710 "chai" : " *" ,
11+ "eslint" : " ^2.2.0" ,
12+ "mocha" : " *" ,
813 "require-directory" : " *" ,
914 "sinon" : " *"
1015 },
11- "devDependencies" : {
12- }
16+ "devDependencies" : {}
1317}
Original file line number Diff line number Diff line change 11require ( '../lib' ) ;
2- module . exports = sinon = require ( " sinon" ) ;
3- module . exports = expect = require ( " chai" ) . expect
2+ module . exports = sinon = require ( ' sinon' ) ;
3+ module . exports = expect = require ( ' chai' ) . expect ;
You can’t perform that action at this time.
0 commit comments