src/atomic/string.js
function charCodesToString(charCodes) {
  // Use these methods to be able to convert large strings
  if (hasProperty('Buffer')) {
    return Buffer.from(charCodes).toString(STR_ENCODING)
  } else if (hasProperty('TextDecoder')) {
    return new TextDecoder(STR_ENCODING) // eslint-disable-line no-undef
      .decode(new Int8Array(charCodes))
  }

  // Fallback method
  let str = ''

  for (let i = 0; i < charCodes.length; i += STR_SLICE_SIZE) {
    str += String.fromCharCode.apply(
      null,
      charCodes.slice(i, i + STR_SLICE_SIZE)
    )
  }

  return str
}
function charCodesToString(charCodes) {
  // Use these methods to be able to convert large strings
  if (hasProperty('Buffer')) {
    return Buffer.from(charCodes).toString(STR_ENCODING)
  } else if (hasProperty('TextDecoder')) {
    return new TextDecoder(STR_ENCODING) // eslint-disable-line no-undef
      .decode(new Int8Array(charCodes))
  }

  // Fallback method
  let str = ''

  for (let i = 0; i < charCodes.length; i += STR_SLICE_SIZE) {
    str += String.fromCharCode.apply(
      null,
      charCodes.slice(i, i + STR_SLICE_SIZE)
    )
  }

  return str
}
function charCodesToString ( charCodes ) { // Use these methods to be able to convert large strings if ( hasProperty ( 'Buffer' ) ) { return Buffer . from ( charCodes ) . toString ( STR_ENCODING ) } else if ( hasProperty ( 'TextDecoder' ) ) { return new TextDecoder ( STR_ENCODING ) // eslint-disable-line no-undef . decode ( new Int8Array ( charCodes ) ) } // Fallback method let str = '' for ( let i = 0 ; i < charCodes . length ; i += STR_SLICE_SIZE ) { str += String . fromCharCode . apply ( null , charCodes . slice ( i , i + STR_SLICE_SIZE ) ) } return str }
Helper method to decode a string using different methods depending on environment
@param {array} charCodes Array of char codes
@return {string} Decoded string
Helper method to decode a string using different methods depending on environment