index.js
function encode(source, label) {
  if (!Buffer.isBuffer(source)) {
    throw new TypeError('Argument `source` should be a Buffer.')
  }

  if (typeof label !== 'string') {
    throw new TypeError('Argument `label` should be a string in upper case.')
  }

  const prefix = before + ' ' + label + endline
  const suffix = after + ' ' + label + endline

  const body = source.toString('base64').replace(/(.{64})/g, '$1\r\n')

  return [prefix, body, suffix].join('\r\n')
}
function encode(source, label) {
  if (!Buffer.isBuffer(source)) {
    throw new TypeError('Argument `source` should be a Buffer.')
  }

  if (typeof label !== 'string') {
    throw new TypeError('Argument `label` should be a string in upper case.')
  }

  const prefix = before + ' ' + label + endline
  const suffix = after + ' ' + label + endline

  const body = source.toString('base64').replace(/(.{64})/g, '$1\r\n')

  return [prefix, body, suffix].join('\r\n')
}
function encode ( source , label ) { if ( ! Buffer . isBuffer ( source ) ) { throw new TypeError ( 'Argument `source` should be a Buffer.' ) } if ( typeof label !== 'string' ) { throw new TypeError ( 'Argument `label` should be a string in upper case.' ) } const prefix = before + ' ' + label + endline const suffix = after + ' ' + label + endline const body = source . toString ( 'base64' ) . replace ( / (.{64}) / g , '$1\r\n' ) return [ prefix , body , suffix ] . join ( '\r\n' ) }
Convert data to PEM format.
@param {Buffer} source
@param {string} label
@returns {String}
Convert data to PEM format .