Guest User

Untitled

a guest
Oct 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const {
  4. TextEncoder,
  5. TextDecoder
  6. } = require('util');
  7.  
  8. let original = 'this is some data';
  9. const encoder = new TextEncoder();
  10. const uint8array = encoder.encode(original);
  11. console.log('uint8array', uint8array);
  12.  
  13. const decoder = new TextDecoder('utf-8');
  14. let string = '';
  15. string += decoder.decode(uint8array, {stream: true});
  16. string += decoder.decode();
  17. console.log('string', string);
Add Comment
Please, Sign In to add comment