cjk-count
Version:
cjk word count
17 lines (12 loc) • 391 B
JavaScript
var cjk = require('unicode-6.3.0/blocks/CJK Unified Ideographs/regex');
var re_char = new RegExp(cjk.source, 'g');
var re_word = new RegExp(cjk.source + '+', 'g');
function count (str, word) {
word = word || false;
if (typeof str === 'string') {
return str.match(word ? re_word : re_char);
} else{
throw new Error('arguments str is not a string');
};
};
module.exports = count;