Merge branch 'master' into climateyml

This commit is contained in:
Joe L Wroten 2017-08-20 21:14:08 -05:00 committed by GitHub
commit fd4e034cd9
5 changed files with 26 additions and 9 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules
coverage

View file

@ -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

View file

@ -1,6 +1,6 @@
# json-query-chain
[![Build Status](https://travis-ci.org/sharpshark28/json-query-chain.svg?branch=master)](https://travis-ci.org/sharpshark28/json-query-chain) [![npm version](https://badge.fury.io/js/json-query-chain.svg)](https://badge.fury.io/js/json-query-chain)
[![Build Status](https://travis-ci.org/sharpshark28/json-query-chain.svg?branch=master)](https://travis-ci.org/sharpshark28/json-query-chain) [![npm version](https://badge.fury.io/js/json-query-chain.svg)](https://badge.fury.io/js/json-query-chain) [![Code Climate](https://img.shields.io/codeclimate/github/sharpshark28/json-query-chain.svg)](https://codeclimate.com/github/sharpshark28/json-query-chain)
Chain queries onto POJOs to return precise results.

View file

@ -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;
};
}
};

View file

@ -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",