Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Improve exports: now nice for CommonJS, Babel 5 & 6
Browse files Browse the repository at this point in the history
  • Loading branch information
René Kooi committed Feb 24, 2016
1 parent b62cc47 commit e5806e5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,24 @@ function user(email, password, opts, cb = null) {
})
}

login.getAuthToken = getAuthToken
login.guest = guest
login.user = user

export default function login(email, password, opts, cb = null) {
function login(email, password, opts, cb = null) {
if (typeof email === 'string') {
return user(email, password, opts, cb)
} else {
[ opts, cb ] = [ email, password ]
return guest(opts, cb)
}
}

// Attempting to offer good support for both `require('plug-login')` and
// `import { … } from 'plug-login'`:

// for `import { login } from 'plug-login'`
login.login = login
// `import { getAuthToken, guest, user }` from 'plug-login'
login.getAuthToken = getAuthToken
login.guest = guest
login.user = user

// `import login from 'plug-login'`
module.exports = login

0 comments on commit e5806e5

Please sign in to comment.