Skip to content
This repository has been archived by the owner on Nov 28, 2017. It is now read-only.

Commit

Permalink
More strict checking (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Jul 16, 2013
1 parent c20db3c commit 8f508d2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions youtube-feeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ app.feeds = {

app.video = function( videoid, cb ) {

if( typeof cb == 'function' ) {
if( typeof cb === 'function' ) {
app.talk( 'feeds/api/videos/'+ videoid, cb )
}

Expand Down Expand Up @@ -124,7 +124,7 @@ app.video = function( videoid, cb ) {
// User
app.user = function( userid, cb ) {

if( cb && typeof cb == 'function' ) {
if( cb && typeof cb === 'function' ) {
app.user( userid ).profile( cb )
}

Expand Down Expand Up @@ -164,13 +164,13 @@ app.talk = function( path, fields, cb, oldJsonKey ) {
var complete = false

// fix callback
if( !cb && typeof fields == 'function' ) {
if( !cb && typeof fields === 'function' ) {
var cb = fields
var fields = {}
}

// fix fields
if( !fields || typeof fields != 'object' ) {
if( !fields || typeof fields !== 'object' ) {
var fields = {}
}

Expand Down Expand Up @@ -297,12 +297,12 @@ app.talk = function( path, fields, cb, oldJsonKey ) {
}

// parse error
if( error && error.origin == 'api' && error.message == 'error' ) {
if( error && error.origin === 'api' && error.message === 'error' ) {
var errorDetails = error.details
if(
error.details[0] !== undefined
&& error.details[0].code !== undefined
&& error.details[0].code == 'ResourceNotFoundException'
&& error.details[0].code === 'ResourceNotFoundException'
) {
complete = true
error = new Error('not found')
Expand All @@ -313,12 +313,12 @@ app.talk = function( path, fields, cb, oldJsonKey ) {
error = new Error('not allowed')
error.origin = 'method'
error.details = errorDetails
} else if( error.details.message == 'Invalid id' ) {
} else if( error.details.message === 'Invalid id' ) {
complete = true
error = new Error('invalid id')
error.origin = 'method'
error.details = errorDetails
} else if( error.details[0] && error.details[0].internalReason == 'Developer key required for this operation' ) {
} else if( error.details[0] && error.details[0].internalReason === 'Developer key required for this operation' ) {
complete = true
error = new Error('developer key missing')
error.origin = 'api'
Expand Down

0 comments on commit 8f508d2

Please sign in to comment.