00001 var asciiWords = require('./_asciiWords'), 00002 hasUnicodeWord = require('./_hasUnicodeWord'), 00003 toString = require('./toString'), 00004 unicodeWords = require('./_unicodeWords'); 00005 00025 function words(string, pattern, guard) { 00026 string = toString(string); 00027 pattern = guard ? undefined : pattern; 00028 00029 if (pattern === undefined) { 00030 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 00031 } 00032 return string.match(pattern) || []; 00033 } 00034 00035 module.exports = words;