Merge pull request #10 from sharpshark28/CodeClimate
Code climate fixes, travis config, badge
This commit is contained in:
		
						commit
						6c24592e43
					
				
					 5 changed files with 26 additions and 9 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +1,2 @@ | |||
| node_modules | ||||
| coverage | ||||
|  |  | |||
							
								
								
									
										16
									
								
								.travis.yml
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								.travis.yml
									
										
									
									
									
								
							|  | @ -1,3 +1,19 @@ | |||
| env: | ||||
|   global: | ||||
|     - CC_TEST_REPORTER_ID=e1449b0f2e8eba8f08c56a292243145925aeb4f521e5682667ac6d704829ba4c | ||||
|     - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi) | ||||
| language: node_js | ||||
| node_js: | ||||
|   - "7" | ||||
| before_script: | ||||
|   - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||||
|   - chmod +x ./cc-test-reporter | ||||
| script: | ||||
|   - npm run test | ||||
|   # Preferably you will run test-reporter on branch update events. But  | ||||
|   # if you setup travis to build PR updates only, you don't need to run  | ||||
|   # the line below | ||||
|   - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi | ||||
|   # In the case where travis is setup to build PR updates only,  | ||||
|   # uncomment the line below | ||||
|   # - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| # json-query-chain | ||||
| 
 | ||||
| [](https://travis-ci.org/sharpshark28/json-query-chain) [](https://badge.fury.io/js/json-query-chain) | ||||
| [](https://travis-ci.org/sharpshark28/json-query-chain) [](https://badge.fury.io/js/json-query-chain) [](https://codeclimate.com/github/sharpshark28/json-query-chain) | ||||
| 
 | ||||
| Chain queries onto POJOs to return precise results. | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										14
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								index.js
									
										
									
									
									
								
							|  | @ -4,21 +4,21 @@ module.exports = class Query { | |||
|       item.sortScore = 0; | ||||
|       return item; | ||||
|     }); | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   get results () { | ||||
|     return this.data; | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   filter (func) { | ||||
|     this.data = this.data.filter(func); | ||||
|     return this; | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   filterBy (key, func) { | ||||
|     this.data = this.data.filter(item => func(item[key])); | ||||
|     return this; | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   search (key, term, score = 0) { | ||||
|     switch (typeof term) { | ||||
|  | @ -35,7 +35,7 @@ module.exports = class Query { | |||
|         break; | ||||
|     } | ||||
|     return this; | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   sort (key = 'sortScore') { | ||||
|     this.data = this.data.sort((a, b) => { | ||||
|  | @ -44,12 +44,12 @@ module.exports = class Query { | |||
|       return 0; | ||||
|     }); | ||||
|     return this; | ||||
|   }; | ||||
|   } | ||||
| 
 | ||||
|   paginate (page = 1, perPage = 10) { | ||||
|     let min = page * perPage - perPage; | ||||
|     let max = min + perPage; | ||||
|     this.data = this.data.slice(min, max); | ||||
|     return this; | ||||
|   }; | ||||
|   } | ||||
| }; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
|   "description": "Chain queries onto POJOs to return precise results.", | ||||
|   "main": "index.js", | ||||
|   "scripts": { | ||||
|     "test": "jest" | ||||
|     "test": "jest --coverage" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue