The Punycode.js library can be used to count code points.
var puny = require('punycode');
count = puny.ucs2.decode(str).length;
The core language does not provide a way to count grapheme clusters. If you know of a library with this functionality, please contribute it here.