Skip to content

Commit a340b03

Browse files
committed
merge gitignore
* fix eslint tests * simplify instructions on readme
1 parent 7071af1 commit a340b03

File tree

5 files changed

+43
-25
lines changed

5 files changed

+43
-25
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
/node_modules
1+
node_modules
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Mac specific
8+
DS_Store

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
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
77
npm 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>
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
module.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
}());

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
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
}

test/test_helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
require('../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;

0 commit comments

Comments
 (0)