stackoverflow-careers
Advanced tools
Comparing version 1.1.2 to 1.1.3
const xml2js = require('xml2js').parseString, | ||
Utils = require('./Utils.js').Utils, | ||
https = require('https'); | ||
Utils = require('./Utils.js').Utils, | ||
https = require('https'); | ||
/** | ||
* Makes a HTTP GET request to the specified URL. | ||
* @param {String} url - URL to make a GET request to | ||
* @param {Function} callback - Callback function containing the returned XML String. | ||
*/ | ||
* Makes a HTTP GET request to the specified URL. | ||
* @param {String} url - URL to make a GET request to | ||
* @param {Function} callback - Callback function containing the returned XML String. | ||
*/ | ||
function GetRequest(url, callback) { | ||
@@ -16,2 +14,3 @@ let xml = ''; | ||
https.get(url, (result) => { | ||
result.on('data', (data) => { | ||
@@ -28,5 +27,5 @@ xml += data; | ||
/** | ||
* Splits an array into a properly formatted string for URL | ||
* @param {Array} arr - The array to split and restructure | ||
*/ | ||
* Splits an array into a properly formatted string for URL | ||
* @param {Array} arr - The array to split and restructure | ||
*/ | ||
function ArrToUrl(arr) { | ||
@@ -37,5 +36,5 @@ return arr.length === 1 ? arr[0] : arr.join('+'); | ||
/** | ||
* Builds the URL to make a GET request to. | ||
* @param {Object} props - Passed to getCareers as an object with search parameters. | ||
*/ | ||
* Builds the URL to make a GET request to. | ||
* @param {Object} props - Passed to getCareers as an object with search parameters. | ||
*/ | ||
function UrlBuilder(props) { | ||
@@ -73,14 +72,14 @@ | ||
/** | ||
* @property {Object} props - Properties for your search | ||
* @property {String} query - Additional information for the search (eg. "Junior" or "remote full time" etc). | ||
* @property {String} location - Location for the job search. Make this as specific as possible. | ||
* @property {String[]} techLiked - An array of technologies prefered. (eg. ["javascript", "c", "Java", "wordpress"]) | ||
* @property {String[]} techDisliked - An array of technologies to filter out. (eg. ["fortran", "c++", "AWS"]) | ||
* @property {String} Unit - Unit of measurement for distance. Typically this should be miles. | ||
* @param {Function} cb - Callback for the array of objects returned. | ||
*/ | ||
* @param {Object} props - Properties for your search | ||
* @param {String} props.query - Additional information for the search (eg. "Junior" or "remote full time" etc). | ||
* @param {String} props.location - Location for the job search. Make this as specific as possible. | ||
* @param {String[]} props.techLiked - An array of technologies prefered. (eg. ["javascript", "c", "Java", "wordpress"]) | ||
* @param {String[]} props.techDisliked - An array of technologies to filter out. (eg. ["fortran", "c++", "AWS"]) | ||
* @param {String} props.unit - Unit of measurement for distance. Typically this should be miles. | ||
* @param {Function} cb - Callback for the array of objects returned. | ||
*/ | ||
function getCareers(props, cb) { | ||
let url = UrlBuilder(props); | ||
const url = UrlBuilder(props); | ||
var data = GetRequest(url, (data) => { | ||
GetRequest(url, (data) => { | ||
xml2js(data, (err, jobs) => { | ||
@@ -87,0 +86,0 @@ cb(jobs.rss.channel[0].item) |
@@ -17,2 +17,3 @@ const EncodedCharacters = { | ||
'/': '%2F', | ||
' ': '%20', | ||
}; | ||
@@ -28,15 +29,15 @@ | ||
IsValidObject(obj) { | ||
return Object.keys(obj).length | ||
}, | ||
/** | ||
* Converts protected HTML characters and converts them to their encoded version. Eg: # -> %23 | ||
* @param {String} param - A string with (potentially) encoded characters | ||
*/ | ||
EncodeProtectedCharacters(param) { | ||
const paramSplit = param.split(''); | ||
let encodedCharacterString = ''; | ||
let convertedCharacters = ''; | ||
paramSplit.forEach(char => { | ||
(EncodedCharacters.hasOwnProperty(char)) ? encodedCharacterString += EncodedCharacters[char] : encodedCharacterString += char; | ||
(Object.prototype.hasOwnProperty.call(EncodedCharacters, char)) ? convertedCharacters += EncodedCharacters[char] : convertedCharacters += char; | ||
}); | ||
return encodedCharacterString; | ||
return convertedCharacters; | ||
} | ||
@@ -43,0 +44,0 @@ } |
{ | ||
"name": "stackoverflow-careers", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A wrapper for the StackOverflow careers feed.", | ||
@@ -9,5 +9,2 @@ "main": "index.js", | ||
}, | ||
"devDependencies": { | ||
"xml2js": "^0.4.17" | ||
}, | ||
"scripts": { | ||
@@ -14,0 +11,0 @@ "test": "echo \"Error: no test specified\" && exit 1" |
@@ -35,8 +35,4 @@ # StackOverflow Careers API for Javascript applications. | ||
# Contributing | ||
**v1.2** Fixed some silly errors that I released to everyone following a deprecation. Sorry! Please `npm outdated && npm update` to make sure you have the latest version. | ||
- I've used the Airbnb ESLint configuration for this project and any pull requests that don't lint correctly under it will be rejected. If you're unsure how to install this specific config, [I've written a guide here](http://fullstackhumanoid.com/quick-eslint-set-up-with-google-airbnb-or-standard-rulesets/) | ||
- All exposed API endpoints must be fully JSDoc'd. [An example can be seen here](https://github.com/james-gould/stackoverflow-careers/blob/master/lib/SO.js#L59-L67). In my experience this prevents a lot of issues being raised because people know what to expect :smile: | ||
# Outstanding issues | ||
@@ -43,0 +39,0 @@ |
11241
0
9
110
41