Socket
Socket
Sign inDemoInstall

searchitunes

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.2 to 2.4.0

51

CHANGELOG.md

@@ -0,1 +1,52 @@

### 2.4.0 (2018-03-16)
##### Chores
* **package:**
* Update minimum node to v6 ([1a87868a](https://github.com/fvdm/nodejs-searchitunes/commit/1a87868ace4117fb01449f0ff64b994ffb95761b))
* Update httpreq dep ([757621be](https://github.com/fvdm/nodejs-searchitunes/commit/757621befaa47e6e2a929c8d21efda84dd2dccb2))
* Update dotest dev dep ([cbbb9df3](https://github.com/fvdm/nodejs-searchitunes/commit/cbbb9df3ae9dea1a36a2bfdfedf327bf18025e82))
* Update dev deps ([53ad56b9](https://github.com/fvdm/nodejs-searchitunes/commit/53ad56b9f6595244a2370419435de4ee54f486a8))
* **develop:** Clean up gitignore ([e5e07cac](https://github.com/fvdm/nodejs-searchitunes/commit/e5e07cac5062fde9b1268923c3331f539fe41459))
* **example:**
* Fix and shorten callback ([c34d8aa7](https://github.com/fvdm/nodejs-searchitunes/commit/c34d8aa75d31a2375c99fb89daefeeabf422a141))
* Rewrite to promises ([9d8bd694](https://github.com/fvdm/nodejs-searchitunes/commit/9d8bd6940d50b2e1a2fbec04f43effc1a34e0ac1))
##### Documentation Changes
* **readme:**
* Clean up ([96ec3423](https://github.com/fvdm/nodejs-searchitunes/commit/96ec342315eee76759128ac58e53052379fd19a1))
* Add coffee link to Author ([b188f5ea](https://github.com/fvdm/nodejs-searchitunes/commit/b188f5ea4133721c9d4f73d1f573470f087c22c0))
* **badges:** Moved GreenKeeper ([cef2a96c](https://github.com/fvdm/nodejs-searchitunes/commit/cef2a96cee87bda2b1ff6f54198ba8663b01fbfc))
##### New Features
* **interface:** Return promises ([b4637e63](https://github.com/fvdm/nodejs-searchitunes/commit/b4637e635377dd4b8c323f1823dd412e3329ea8a))
##### Bug Fixes
* **request:** Parse timeout to int ([17ceab20](https://github.com/fvdm/nodejs-searchitunes/commit/17ceab20721bb5d2fcb0a546c42f6e4f2454e8e9))
##### Refactors
* **package:** Add es6-promisify to deps ([b711a72d](https://github.com/fvdm/nodejs-searchitunes/commit/b711a72d99e5efcb7b54211a73e3a88915a1b341))
##### Code Style Changes
* **test:** Convert to const, let, arrows ([d6cd8eec](https://github.com/fvdm/nodejs-searchitunes/commit/d6cd8eec71a40a1d629e80448d2a7ce5f73e559e))
* **syntax:** Convert to const, let & arrows ([ad847cf3](https://github.com/fvdm/nodejs-searchitunes/commit/ad847cf3ef7aa266da39a633d7589a45ad4ac98e))
* **main:** Cleaner comments ([db75a86e](https://github.com/fvdm/nodejs-searchitunes/commit/db75a86ec3195adfb175cfe64a6f6ba3d47e53e0))
* **comments:** Clean up JSDoc comments ([e02e72f0](https://github.com/fvdm/nodejs-searchitunes/commit/e02e72f0be596713c37deb3145280bc2ef93a697))
##### Tests
* **main:**
* Fix broken script after failed promise ([859eae62](https://github.com/fvdm/nodejs-searchitunes/commit/859eae62c989541d0b99fcf2ff953e537e4ed64c))
* Just pass the timeout ([add96439](https://github.com/fvdm/nodejs-searchitunes/commit/add964391a033ac9ebab712393aa2b6633431534))
* Added tests for promises ([27bc99fb](https://github.com/fvdm/nodejs-searchitunes/commit/27bc99fb9880608445e9058c92cf6ddbfda13eb7))
* **package:** Change dev deps to dotest ([359a8ff4](https://github.com/fvdm/nodejs-searchitunes/commit/359a8ff4d3427a89ad8c177afb9ff021bf66d702))
* **config:**
* Update Travis CI node versions ([543d70c5](https://github.com/fvdm/nodejs-searchitunes/commit/543d70c56f6d54866d9b4430806c8a23a0905175))
* Travis CI update node versions ([18b433f7](https://github.com/fvdm/nodejs-searchitunes/commit/18b433f714ccba8e256f070a358338f754c7c7e6))
#### 2.3.2 (2016-10-26)

@@ -2,0 +53,0 @@

17

example.js
// Load module
var itunes = require ('searchitunes');
const itunes = require ('searchitunes');
// Search parameters
var params = {
const params = {
entity: 'software',

@@ -13,11 +13,8 @@ country: 'NL',

// Fancy console.log
function output (err, data) {
console.dir (err || data, {
// Do the search
itunes (params)
.then (data => console.dir (data, {
depth: null,
colors: true
});
}
// Do the search
itunes (params, output);
}))
.catch (console.error);

@@ -9,3 +9,3 @@ {

"description": "Search the Apple iTunes Store and App Store with this lightweight module",
"version": "2.3.2",
"version": "2.4.0",
"repository": {

@@ -20,9 +20,10 @@ "type": "git",

"dependencies": {
"httpreq": "^0.4.22"
"es6-promisify": "^6.0.0",
"httpreq": "^0.4.24"
},
"devDependencies": {
"dotest": "^1.13.6"
"dotest": "^2.3.0"
},
"engines": {
"node": ">=4.0.0"
"node": ">=6.0.0"
},

@@ -29,0 +30,0 @@ "keywords": [

@@ -1,5 +0,4 @@

searchitunes
============
# searchitunes
Light node.js module to quickly search the Apple iTunes Store and App Store for music, apps, etc.
Lightweight Node.js package to quickly search the Apple iTunes Store and App Store for music, movies, apps, etc.

@@ -11,33 +10,54 @@ [![npm](https://img.shields.io/npm/v/searchitunes.svg?maxAge=3600)](https://github.com/fvdm/nodejs-searchitunes/blob/master/CHANGELOG.md)

[![bitHound Code](https://www.bithound.io/github/fvdm/nodejs-searchitunes/badges/code.svg)](https://www.bithound.io/github/fvdm/nodejs-searchitunes)
[![Greenkeeper badge](https://badges.greenkeeper.io/fvdm/nodejs-searchitunes.svg)](https://greenkeeper.io/)
Installation
------------
## Example
`npm install searchitunes`
```js
const searchitunes = require ('searchitunes');
const params = {
entity: 'software',
country: 'NL',
term: 'github',
limit: 1,
price: 0
};
// Find free Github app for iPhone in Dutch App Store
searchitunes (params).then (console.log);
Usage
-----
// Get one specific item by ID
searchitunes ({ id: 512939461 }).then (console.log);
```
### ( params, [timeout], callback )
## Installation
`npm i searchitunes`
## Usage
**( params, [timeout], [callback] )**
The module returns promises but also supports the callback argument.
It's up to you which you prefer.
argument | type | required | default | description
:---------|:---------|:---------|:--------|:------------------------------
params | object | yes | | Search parameters
timeout | number | no | 5000 | Wait time out in ms
callback | function | yes | | [Callback](#callback) function to process results
timeout | int | no | 5000 | Wait time out in ms
callback | function | no | | `(err, data)` or use promises
* [Search API documentation](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#overview)
* [Live demo](https://tonicdev.com/npm/searchitunes)
* [Search-API docs](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#overview)
* [Live demo](https://npm.runkit.com/searchitunes)
#### Lookup by ID
### Lookup by ID
When you wish to retrieve one specific item by its ID,
include one of the following params to use the Lookup API.
The result `data` will be only the _object_ with the item's details.
The result data will be only the _object_ with the item's details.
* [Lookup API documentation](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#lookup)
* [Lookup-API docs](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#lookup)

@@ -56,125 +76,10 @@

```js
searchitunes ({ id: 123456 }, callback);
searchitunes ({ id: 123456 })
.then (console.log)
.catch (console.error);
```
#### Callback
### Errors
The `callback` function receives two parameters: `err` and `data`.
On success `err` is _null_ and `data` is the result object.
On error `err` is an instance of _Error_ and `data` is not set, see [Errors](#errors) below.
#### Example
```js
const searchitunes = require ('searchitunes');
const searchParams = {
entity: 'software',
country: 'NL',
term: 'github',
limit: 1,
price: 0
};
// Find free Github app for iPhone in Dutch App Store
searchitunes (searchParams, (err, data) => {
if (err) {
console.log (err);
return;
}
// All good
console.log (data);
});
// Get one specific item by ID
searchitunes ({ id: 512939461 }, console.log);
```
#### Output
When you lookup an item by its ID you only get the singular result _object_.
```js
{ resultCount: 1,
results:
[ { screenshotUrls:
[ 'http://a4.mzstatic.com/eu/r30/Purple69/v4/8e/b6/b1/8eb6b18c-1703-3fe9-1311-9a891a851f2b/screen1136x1136.jpeg',
'http://a5.mzstatic.com/eu/r30/Purple69/v4/8c/9c/df/8c9cdf9a-36ec-9b81-63af-68be202691d3/screen1136x1136.jpeg',
'http://a3.mzstatic.com/eu/r30/Purple69/v4/9b/f7/6f/9bf76f76-05d8-80b0-4b9f-6dbb365a782a/screen1136x1136.jpeg',
'http://a1.mzstatic.com/eu/r30/Purple69/v4/3d/81/77/3d8177a8-2653-7cbb-e04c-d45942ca980e/screen1136x1136.jpeg',
'http://a4.mzstatic.com/eu/r30/Purple49/v4/b8/4d/24/b84d24c8-3647-9df3-2244-ea0ddea32bc6/screen1136x1136.jpeg' ],
ipadScreenshotUrls:
[ 'http://a1.mzstatic.com/eu/r30/Purple69/v4/f6/44/ee/f644ee69-53ed-65dd-85f0-24cf31f7daa1/screen480x480.jpeg',
'http://a5.mzstatic.com/eu/r30/Purple69/v4/56/94/d3/5694d376-cea1-ab3f-51b4-f771c73c9bce/screen480x480.jpeg',
'http://a3.mzstatic.com/eu/r30/Purple69/v4/2e/19/1d/2e191d6d-c571-360a-5d7c-a5a3e636af39/screen480x480.jpeg',
'http://a4.mzstatic.com/eu/r30/Purple69/v4/aa/ec/91/aaec918e-4e32-f90e-dc18-9d183a636925/screen480x480.jpeg',
'http://a4.mzstatic.com/eu/r30/Purple69/v4/6e/0d/30/6e0d30fc-aaa8-f3f4-0fd7-42f92b876e96/screen480x480.jpeg' ],
appletvScreenshotUrls: [],
artworkUrl60: 'http://is2.mzstatic.com/image/thumb/Purple30/v4/19/f4/66/19f46673-c118-c52d-ca78-a1f3439a020e/source/60x60bb.jpg',
artworkUrl512: 'http://is2.mzstatic.com/image/thumb/Purple30/v4/19/f4/66/19f46673-c118-c52d-ca78-a1f3439a020e/source/512x512bb.jpg',
artworkUrl100: 'http://is2.mzstatic.com/image/thumb/Purple30/v4/19/f4/66/19f46673-c118-c52d-ca78-a1f3439a020e/source/100x100bb.jpg',
artistViewUrl: 'https://itunes.apple.com/nl/developer/dillon-buchanan/id551531425?uo=4',
kind: 'software',
features: [ 'iosUniversal' ],
supportedDevices:
[ 'iPad2Wifi',
'iPad23G',
'iPhone4S',
'iPadThirdGen',
'iPadThirdGen4G',
'iPhone5',
'iPodTouchFifthGen',
'iPadFourthGen',
'iPadFourthGen4G',
'iPadMini',
'iPadMini4G',
'iPhone5c',
'iPhone5s',
'iPhone6',
'iPhone6Plus',
'iPodTouchSixthGen' ],
advisories: [],
isGameCenterEnabled: false,
trackCensoredName: 'CodeHub - A Client for GitHub',
languageCodesISO2A: [ 'EN' ],
fileSizeBytes: '42310545',
sellerUrl: 'http://codehub-app.com',
contentAdvisoryRating: '4+',
trackViewUrl: 'https://itunes.apple.com/nl/app/codehub-a-client-for-github/id707173885?mt=8&uo=4',
trackContentRating: '4+',
genreIds: [ '6007', '6005' ],
currency: 'EUR',
wrapperType: 'software',
version: '2.9.3',
description: 'CodeHub is the best way to browse and maintain your GitHub repositories on any iPhone, iPod Touch, and iPad device! Keep an eye on your projects with the ability to view everything from pull requests to commenting on individual file diffs in the latest changeset. CodeHub brings GitHub to your finger tips in a sleek and efficient design. \n\nFeatures include: \n\n- GitHub.com and GitHub Enterprise support\n- Multiple GitHub profiles for easy switching \n- View repository events, issues, and change sets, pull requests, etc..\n- Browse source directories & files with beautiful syntax highlighting\n- Edit files and commit them!\n- View file diffs from checkins and pull requests\n- Update, comment and manage repository issues\n- Upload images directly from your devices to comments/issues.\n- Explore other GitHub open source repositories \n- Inline commit commenting\n- Access your public, private, and starred gists\n- Slide out menu for quick and efficient navigation\n- Much much more! \n\nFollow the project on twitter: @CodeHubApp\n\nPlease note: CodeHub is not affiliated with GitHub in any way. CodeHub is a third-party GitHub client.',
artistId: 551531425,
artistName: 'Dillon Buchanan',
genres: [ 'Productiviteit', 'Sociaal netwerken' ],
price: 0,
trackName: 'CodeHub - A Client for GitHub',
trackId: 707173885,
bundleId: 'com.dillonbuchanan.codehub',
releaseDate: '2013-10-01T01:00:56Z',
primaryGenreName: 'Productivity',
isVppDeviceBasedLicensingEnabled: false,
primaryGenreId: 6007,
formattedPrice: 'Gratis',
releaseNotes: '- Bug fixes',
currentVersionReleaseDate: '2016-05-04T16:04:45Z',
sellerName: 'Dillon Buchanan',
minimumOsVersion: '9.0',
averageUserRating: 4.5,
userRatingCount: 19 } ] }
```
Errors
------
message | description

@@ -188,4 +93,3 @@ :----------------|:--------------------------------------------

Unlicense
---------
## Unlicense

@@ -218,5 +122,8 @@ This is free and unencumbered software released into the public domain.

Author
------
## Author
[Franklin van de Meent](https://frankl.in)
Is this project useful to you?
[Buy me a coffee](https://ko-fi.com/franklin)
to help me stay awake while debugging.

@@ -7,10 +7,11 @@ /*

Feedback: https://github.com/fvdm/nodejs-searchitunes/issues
API docs: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
License: Unlicense / Public Domain, see UNLICENSE file
API docs: https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/
License: Unlicense (Public Domain, see UNLICENSE file)
(https://github.com/fvdm/nodejs-searchitunes/raw/master/UNLICENSE)
*/
var httpreq = require ('httpreq');
const { doRequest } = require ('httpreq');
const { promisify } = require ('es6-promisify');
var config = {
let config = {
timeout: 5000,

@@ -31,9 +32,10 @@ idKeys: [

*
* @param keys {array} - Property names to check
* @param obj {object} - Object to process
* @returns {boolean} - `true` = yes
* @return {boolean} `true` = yes
*
* @param {array} keys Property names to check
* @param {object} obj Object to process
*/
function keysInObject (keys, obj) {
var i = 0;
let i = 0;

@@ -51,13 +53,14 @@ for (i; i < keys.length; i++) {

/**
* Call back a request error
* Callback a request error
*
* @callback callback
* @param err {Error} - The error to include in `.error`
* @param res {object} - Response details from httpreq
* @param message {string} - Error message to report
* @returns {Error} error
* @callback callback
* @return {Error} error
*
* @param {error} err The error to include in `.error`
* @param {object} res Response details from httpreq
* @param {string} message Error message to report
*/
function httpError (err, res, message) {
var error = new Error (message);
let error = new Error (message);

@@ -75,13 +78,14 @@ error.code = res && res.statusCode;

*
* @callback callback
* @param err {Error, null} - Client error
* @param [res] {object} - Response details
* @param [callback] {function} - `function (err, data) {}`
* @param [firstResult = false] {boolean} - Call back only first result
* @returns {void}
* @callback callback
* @return {void}
*
* @param {Error|null} err Client error
* @param {object} [res] Response details
* @param {function} [callback] `(err, data)`
* @param {bool} [firstResult=false] Call back only first result
*/
function httpResponse (err, res, callback, firstResult) {
var data = res && res.body || '';
var error = null;
let data = res && res.body || '';
let error = null;

@@ -115,18 +119,19 @@ try {

*
* @callback callback
* @param props {object} - Request details
* @param props.url {string} - URL to fetch
* @param props.params {object} - Parameters to send along
* @param [props.timeout = 5000] {number} - Wait time out in ms
* @param callback {function} - `function (err, data) {}`
* @returns {void}
* @callback callback
* @return {void}
*
* @param {object} props Request details
* @param {string} props.url URL to fetch
* @param {object} props.params Parameters to send along
* @param {int} [props.timeout=5000] Wait time out in ms
* @param {function} callback `(err, data)`
*/
function httpRequest (props, callback) {
var firstResult = false;
var options = {
let firstResult = false;
let options = {
url: 'https://itunes.apple.com/search',
method: 'GET',
parameters: props.params || {},
timeout: props.timeout || config.timeout,
timeout: parseInt (props.timeout || config.timeout, 10),
headers: {

@@ -143,3 +148,3 @@ 'Accept': 'application/json',

httpreq.doRequest (options, function (err, res) {
doRequest (options, (err, res) => {
httpResponse (err, res, callback, firstResult);

@@ -153,11 +158,12 @@ });

*
* @callback callback
* @param params {object} - Parameters to send to API
* @param [timeout = 5000] {number} - Wait time out in ms
* @param callback {function} - `function (err, data) {}`
* @returns {void}
* @callback callback
* @return {object} Promises then & catch
*
* @param {object} params Parameters to send to API
* @param {int} [timeout=5000] Wait time out in ms
* @param {function} callback `(err, data)`
*/
module.exports = function (params, timeout, callback) {
var options = {
module.exports = promisify ((params, timeout, callback) => {
let options = {
params: params || {}

@@ -179,2 +185,2 @@ };

httpRequest (options, callback);
};
});

@@ -9,11 +9,27 @@ /*

var dotest = require ('dotest');
var app = require ('./');
const dotest = require ('dotest');
const app = require ('./');
// Setup
var timeout = process.env.testTimeout || null;
const timeout = String (process.env.testTimeout);
const goodParams = {
entity: 'software',
country: 'NL',
term: 'github',
limit: 1,
price: 0
};
const badParams = {
entity: 'software',
country: 'NL',
term: null,
limit: 1,
price: 0
};
// Tests
dotest.add ('Module', function (test) {
dotest.add ('Interface', test => {
test ()

@@ -25,4 +41,24 @@ .isFunction ('fail', 'exports', app)

dotest.add ('Error: invalid params', function (test) {
app (null, function (err) {
dotest.add ('Promise - good', test => {
app ({ id: 512939461 })
.then (data => test()
.isObject ('fail', 'data', data)
.isNotEmpty ('fail', 'data', data)
)
.then (() => test().done());
});
dotest.add ('Promise - Error', test => {
app (null)
.catch (err => test()
.isError ('fail', 'err', err)
.isExactly ('fail', 'err.message', err && err.message, 'invalid params')
)
.then(() => test().done());
});
dotest.add ('Error: invalid params', test => {
app (null, err => {
test ()

@@ -36,12 +72,4 @@ .isError ('fail', 'err', err)

dotest.add ('Error: no results', function (test) {
var params = {
entity: 'software',
country: 'NL',
term: null,
limit: 1,
price: 0
};
app (params, timeout, function (err) {
dotest.add ('Error: no results', test => {
app (badParams, timeout, err => {
test ()

@@ -55,4 +83,4 @@ .isError ('fail', 'err', err)

dotest.add ('Error: http error', function (test) {
app ({}, 1, function (err, data) {
dotest.add ('Error: http error', test => {
app ({}, 1, (err, data) => {
test (null)

@@ -68,11 +96,7 @@ .isError ('fail', 'err', err)

dotest.add ('Search by ID', function (test) {
var params = {
id: 512939461
};
app (params, timeout, function (err, data) {
dotest.add ('Lookup by ID', test => {
app ({ id: 512939461 }, timeout, (err, data) => {
test (err)
.isObject ('fail', 'data', data)
.isExactly ('fail', 'data.trackId', data && data.trackId, params.id)
.isExactly ('fail', 'data.trackId', data && data.trackId, 512939461)
.done ();

@@ -83,14 +107,6 @@ });

dotest.add ('Search by term', function (test) {
var params = {
entity: 'software',
country: 'NL',
term: 'github',
limit: 1,
price: 0
};
dotest.add ('Search by term', test => {
app (goodParams, timeout, (err, data) => {
const item = data && data.results && data.results [0];
app (params, timeout, function (err, data) {
var item = data && data.results && data.results [0];
test (err)

@@ -97,0 +113,0 @@ .isObject ('fail', 'data', data)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc