summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-auth-token/base64.js
blob: e150099d0458746f04fa2ea56a8e26a406bf774a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function decodeBase64Old(base64) {
  return new Buffer(base64, 'base64').toString('utf8')
}

function decodeBase64New(base64) {
  return Buffer.from(base64, 'base64').toString('utf8')
}

function encodeBase64Old(string) {
  return new Buffer(string, 'utf8').toString('base64')
}

function encodeBase64New(string) {
  return Buffer.from(string, 'utf8').toString('base64')
}

module.exports = {
  decodeBase64: Buffer.prototype.from ? decodeBase64New : decodeBase64Old,
  encodeBase64: Buffer.prototype.from ? encodeBase64New : encodeBase64Old
}