Comparing version 2.2.4 to 2.3.0
@@ -26,2 +26,6 @@ # Change Log | ||
## [2.3.0] - 2017-08-28 | ||
### Changed | ||
- Increase character coverage for isJapanese to include numbers and hankaku katakana | ||
## [2.2.4] - 2017-08-24 | ||
@@ -101,2 +105,3 @@ ### Fixed | ||
[2.3.0]: https://github.com/WaniKani/WanaKana/compare/2.2.4...2.3.0 | ||
[2.2.4]: https://github.com/WaniKani/WanaKana/compare/2.2.3...2.2.4 | ||
@@ -103,0 +108,0 @@ [2.2.3]: https://github.com/WaniKani/WanaKana/compare/2.2.2...2.2.3 |
@@ -36,27 +36,60 @@ 'use strict'; | ||
// CharCode References | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
// http://unicode-table.com | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
var CJK_SYMBOLS_PUNCTUATION = [0x3000, 0x303F]; | ||
var KATAKANA_PUNCTUATION = [0x30FB, 0x30FC]; | ||
var HIRAGANA_CHARS = [0x3040, 0x309F]; | ||
var KATAKANA_CHARS = [0x30A0, 0x30FF]; | ||
var ZENKAKU_NUMBERS = [0xFF10, 0xFF19]; | ||
var ZENKAKU_PUNCTUATION_1 = [0xFF01, 0xFF0F]; | ||
var ZENKAKU_PUNCTUATION_2 = [0xFF1A, 0xFF1F]; | ||
var ZENKAKU_PUNCTUATION_3 = [0xFF3B, 0xFF3F]; | ||
var ZENKAKU_PUNCTUATION_4 = [0xFF5B, 0xFF60]; | ||
var ZENKAKU_SYMBOLS_CURRENCY = [0xFFE0, 0xFFEE]; | ||
var KANA_PUNCTUATION = [0xFF61, 0xFF65]; | ||
var HANKAKU_KATAKANA = [0xFF66, 0xFF9F]; | ||
var COMMON_CJK = [0x4E00, 0x9FFF]; | ||
var RARE_CJK = [0x3400, 0x4DBF]; | ||
var LATIN_NUMBERS = [0x0030, 0x0039]; | ||
var MODERN_ENGLISH = [0x0000, 0x007f]; | ||
var HEPBURN_MACRON_RANGES = [[0x0100, 0x0101], // Ā ā | ||
[0x0112, 0x0113], // Ē ē | ||
[0x012a, 0x012b], // Ī ī | ||
[0x014c, 0x014d], // Ō ō | ||
[0x016a, 0x016b]]; | ||
var SMART_QUOTE_RANGES = [[0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
// const FULL_LATIN_RANGES = [ | ||
// [0x0001-0x007F], | ||
// [0x0080-0x00FF], | ||
// [0x0100-0x017F], | ||
// [0x0180-0x024F], | ||
// ]; | ||
var JA_PUNCTUATION_RANGES = exports.JA_PUNCTUATION_RANGES = [CJK_SYMBOLS_PUNCTUATION, KANA_PUNCTUATION, KATAKANA_PUNCTUATION, ZENKAKU_PUNCTUATION_1, ZENKAKU_PUNCTUATION_2, ZENKAKU_PUNCTUATION_3, ZENKAKU_PUNCTUATION_4, ZENKAKU_SYMBOLS_CURRENCY]; | ||
var KANA_RANGES = [HIRAGANA_CHARS, KATAKANA_CHARS, KANA_PUNCTUATION, HANKAKU_KATAKANA]; | ||
/** | ||
* All Japanese regex, for mixes of kanji and kana like "泣き虫" | ||
* Includes Japanese full-width punctuation ranges | ||
* Doesn't include *half-width katakana / roman letters* since they should be considered typos | ||
* @type {RegExp} | ||
* All Japanese unicode start and end ranges | ||
* Includes full-width punctuation and number ranges. | ||
* Incudes latin numbers since they are used in Japanese text as well. | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var KANJI_KANA_REGEX = exports.KANJI_KANA_REGEX = /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff01-\uff0f\u4e00-\u9faf\u3400-\u4dbf]/; | ||
var JAPANESE_RANGES = exports.JAPANESE_RANGES = [].concat(KANA_RANGES, JA_PUNCTUATION_RANGES, [LATIN_NUMBERS, ZENKAKU_NUMBERS, COMMON_CJK, RARE_CJK]); | ||
/** | ||
* Basic Latin unicode regex, for determining Romaji written as Hepburn romanisation | ||
* Basic Latin unicode regex, for determining Romaji + Hepburn romanisation | ||
* Includes upper/lowercase long vowels like "ā, ī, ū, ē, ō" | ||
* Includes curly quotes ‘’ “” | ||
* @type {RegExp} | ||
* Includes smart quotes ‘’ “” | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var ROMAJI_REGEX = exports.ROMAJI_REGEX = /[\u0000-\u007f\u0100-\u0101\u0112-\u0113\u012a-\u012b\u014c-\u014d\u016a-\u016b\u2018-\u2019\u201C-\u201D]/; | ||
var ROMAJI_RANGES = exports.ROMAJI_RANGES = [MODERN_ENGLISH].concat(HEPBURN_MACRON_RANGES, SMART_QUOTE_RANGES); | ||
// TODO: just use a regex instead? not sure why these are in arrays | ||
var ENGLISH_PUNCTUATION_RANGES = exports.ENGLISH_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E], [0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
var JAPANESE_FULLWIDTH_PUNCTUATION_RANGES = exports.JAPANESE_FULLWIDTH_PUNCTUATION_RANGES = [[0x3001, 0x303E], [0x30FB, 0x30FC], [0xFF01, 0xFF0F], [0xFF1A, 0xFF1F], [0xFF3B, 0xFF3F], [0xFF5B, 0xFF60]]; | ||
var EN_PUNCTUATION_RANGES = exports.EN_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E]].concat(SMART_QUOTE_RANGES); | ||
var LOWERCASE_START = exports.LOWERCASE_START = 0x61; | ||
@@ -66,2 +99,6 @@ var LOWERCASE_END = exports.LOWERCASE_END = 0x7A; | ||
var UPPERCASE_END = exports.UPPERCASE_END = 0x5A; | ||
var LOWERCASE_FULLWIDTH_START = exports.LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = exports.LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = exports.UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = exports.UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var HIRAGANA_START = exports.HIRAGANA_START = 0x3041; | ||
@@ -73,6 +110,2 @@ var HIRAGANA_END = exports.HIRAGANA_END = 0x3096; | ||
var KANJI_END = exports.KANJI_END = 0x9FAF; | ||
var LOWERCASE_FULLWIDTH_START = exports.LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = exports.LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = exports.UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = exports.UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var PROLONGED_SOUND_MARK = exports.PROLONGED_SOUND_MARK = 0x30FC; | ||
@@ -79,0 +112,0 @@ var KANA_SLASH_DOT = exports.KANA_SLASH_DOT = 0x30FB; |
@@ -11,4 +11,6 @@ 'use strict'; | ||
var _constants = require('./constants'); | ||
var _isCharJapanese = require('./utils/isCharJapanese'); | ||
var _isCharJapanese2 = _interopRequireDefault(_isCharJapanese); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -19,6 +21,5 @@ | ||
/** | ||
* Test if `input` is [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) like “「泣き虫」” | ||
* Includes Japanese full-width punctuation ranges | ||
* Test if `input` only includes [Kanji](https://en.wikipedia.org/wiki/Kanji), [Kana](https://en.wikipedia.org/wiki/Kana), zenkaku punctuation, japanese symbols and numbers.” | ||
* @param {String} [input=''] text | ||
* @return {Boolean} true if all [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) | ||
* @return {Boolean} true if passes checks | ||
* @example | ||
@@ -29,7 +30,9 @@ * isJapanese('泣き虫') | ||
* // => true | ||
* isJapanese('泣き虫。!〜') // Full-width punctuation | ||
* isJapanese('2月1日') // Full and half-width numbers allowed | ||
* // => true | ||
* isJapanese('泣き虫.!~') // Half-width / Latin punctuation | ||
* isJapanese('泣き虫。!〜$') | ||
* // => true | ||
* isJapanese('泣き虫.!~$') // Half-width / Latin punctuation fails | ||
* // => false | ||
* isJapanese('泣き虫A') | ||
* isJapanese('A泣き虫') | ||
* // => false | ||
@@ -43,7 +46,5 @@ * isJapanese('A') | ||
if ((0, _isEmpty2.default)(input)) return false; | ||
return [].concat(_toConsumableArray(input)).every(function (char) { | ||
return _constants.KANJI_KANA_REGEX.test(char); | ||
}); | ||
return [].concat(_toConsumableArray(input)).every(_isCharJapanese2.default); | ||
} | ||
exports.default = isJapanese; |
@@ -26,3 +26,3 @@ 'use strict'; | ||
* // => true | ||
* isRomaji('a*b&c-d') | ||
* isRomaji('12a*b&c-d') | ||
* // => true | ||
@@ -40,7 +40,5 @@ * isRomaji('あアA') | ||
if ((0, _isEmpty2.default)(input)) return false; | ||
return [].concat(_toConsumableArray(input)).every(function (char) { | ||
return (0, _isCharRomaji2.default)(char); | ||
}); | ||
return [].concat(_toConsumableArray(input)).every(_isCharRomaji2.default); | ||
} | ||
exports.default = isRomaji; |
@@ -31,27 +31,60 @@ /** | ||
// CharCode References | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
// http://unicode-table.com | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
var CJK_SYMBOLS_PUNCTUATION = [0x3000, 0x303F]; | ||
var KATAKANA_PUNCTUATION = [0x30FB, 0x30FC]; | ||
var HIRAGANA_CHARS = [0x3040, 0x309F]; | ||
var KATAKANA_CHARS = [0x30A0, 0x30FF]; | ||
var ZENKAKU_NUMBERS = [0xFF10, 0xFF19]; | ||
var ZENKAKU_PUNCTUATION_1 = [0xFF01, 0xFF0F]; | ||
var ZENKAKU_PUNCTUATION_2 = [0xFF1A, 0xFF1F]; | ||
var ZENKAKU_PUNCTUATION_3 = [0xFF3B, 0xFF3F]; | ||
var ZENKAKU_PUNCTUATION_4 = [0xFF5B, 0xFF60]; | ||
var ZENKAKU_SYMBOLS_CURRENCY = [0xFFE0, 0xFFEE]; | ||
var KANA_PUNCTUATION = [0xFF61, 0xFF65]; | ||
var HANKAKU_KATAKANA = [0xFF66, 0xFF9F]; | ||
var COMMON_CJK = [0x4E00, 0x9FFF]; | ||
var RARE_CJK = [0x3400, 0x4DBF]; | ||
var LATIN_NUMBERS = [0x0030, 0x0039]; | ||
var MODERN_ENGLISH = [0x0000, 0x007f]; | ||
var HEPBURN_MACRON_RANGES = [[0x0100, 0x0101], // Ā ā | ||
[0x0112, 0x0113], // Ē ē | ||
[0x012a, 0x012b], // Ī ī | ||
[0x014c, 0x014d], // Ō ō | ||
[0x016a, 0x016b]]; | ||
var SMART_QUOTE_RANGES = [[0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
// const FULL_LATIN_RANGES = [ | ||
// [0x0001-0x007F], | ||
// [0x0080-0x00FF], | ||
// [0x0100-0x017F], | ||
// [0x0180-0x024F], | ||
// ]; | ||
var JA_PUNCTUATION_RANGES = [CJK_SYMBOLS_PUNCTUATION, KANA_PUNCTUATION, KATAKANA_PUNCTUATION, ZENKAKU_PUNCTUATION_1, ZENKAKU_PUNCTUATION_2, ZENKAKU_PUNCTUATION_3, ZENKAKU_PUNCTUATION_4, ZENKAKU_SYMBOLS_CURRENCY]; | ||
var KANA_RANGES = [HIRAGANA_CHARS, KATAKANA_CHARS, KANA_PUNCTUATION, HANKAKU_KATAKANA]; | ||
/** | ||
* All Japanese regex, for mixes of kanji and kana like "泣き虫" | ||
* Includes Japanese full-width punctuation ranges | ||
* Doesn't include *half-width katakana / roman letters* since they should be considered typos | ||
* @type {RegExp} | ||
* All Japanese unicode start and end ranges | ||
* Includes full-width punctuation and number ranges. | ||
* Incudes latin numbers since they are used in Japanese text as well. | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var KANJI_KANA_REGEX = /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff01-\uff0f\u4e00-\u9faf\u3400-\u4dbf]/; | ||
var JAPANESE_RANGES = [].concat(KANA_RANGES, JA_PUNCTUATION_RANGES, [LATIN_NUMBERS, ZENKAKU_NUMBERS, COMMON_CJK, RARE_CJK]); | ||
/** | ||
* Basic Latin unicode regex, for determining Romaji written as Hepburn romanisation | ||
* Basic Latin unicode regex, for determining Romaji + Hepburn romanisation | ||
* Includes upper/lowercase long vowels like "ā, ī, ū, ē, ō" | ||
* Includes curly quotes ‘’ “” | ||
* @type {RegExp} | ||
* Includes smart quotes ‘’ “” | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var ROMAJI_REGEX = /[\u0000-\u007f\u0100-\u0101\u0112-\u0113\u012a-\u012b\u014c-\u014d\u016a-\u016b\u2018-\u2019\u201C-\u201D]/; | ||
var ROMAJI_RANGES = [MODERN_ENGLISH].concat(HEPBURN_MACRON_RANGES, SMART_QUOTE_RANGES); | ||
// TODO: just use a regex instead? not sure why these are in arrays | ||
var ENGLISH_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E], [0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
var JAPANESE_FULLWIDTH_PUNCTUATION_RANGES = [[0x3001, 0x303E], [0x30FB, 0x30FC], [0xFF01, 0xFF0F], [0xFF1A, 0xFF1F], [0xFF3B, 0xFF3F], [0xFF5B, 0xFF60]]; | ||
var EN_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E]].concat(SMART_QUOTE_RANGES); | ||
var LOWERCASE_START = 0x61; | ||
@@ -61,2 +94,6 @@ | ||
var UPPERCASE_END = 0x5A; | ||
var LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var HIRAGANA_START = 0x3041; | ||
@@ -68,6 +105,2 @@ var HIRAGANA_END = 0x3096; | ||
var KANJI_END = 0x9FAF; | ||
var LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var PROLONGED_SOUND_MARK = 0x30FC; | ||
@@ -1221,11 +1254,17 @@ var KANA_SLASH_DOT = 0x30FB; | ||
/** | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) (allowing [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization)) | ||
* @param {String} char character string to test | ||
* @return {Boolean} | ||
*/ | ||
function isCharKana$2() { | ||
function isCharRomaji() { | ||
var char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
if (isEmpty(char)) return false; | ||
return ROMAJI_REGEX.test(char); | ||
return ROMAJI_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
start = _ref2[0], | ||
end = _ref2[1]; | ||
return isCharInRange(char, start, end); | ||
}); | ||
} | ||
@@ -1240,3 +1279,3 @@ | ||
* // => true | ||
* isRomaji('a*b&c-d') | ||
* isRomaji('12a*b&c-d') | ||
* // => true | ||
@@ -1254,4 +1293,19 @@ * isRomaji('あアA') | ||
if (isEmpty(input)) return false; | ||
return [].concat(toConsumableArray(input)).every(function (char) { | ||
return isCharKana$2(char); | ||
return [].concat(toConsumableArray(input)).every(isCharRomaji); | ||
} | ||
/** | ||
* Tests a character. Returns true if the character is [Katakana](https://en.wikipedia.org/wiki/Katakana). | ||
* @param {String} char character string to test | ||
* @return {Boolean} | ||
*/ | ||
function isCharJapanese() { | ||
var char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
return JAPANESE_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
start = _ref2[0], | ||
end = _ref2[1]; | ||
return isCharInRange(char, start, end); | ||
}); | ||
@@ -1261,6 +1315,5 @@ } | ||
/** | ||
* Test if `input` is [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) like “「泣き虫」” | ||
* Includes Japanese full-width punctuation ranges | ||
* Test if `input` only includes [Kanji](https://en.wikipedia.org/wiki/Kanji), [Kana](https://en.wikipedia.org/wiki/Kana), zenkaku punctuation, japanese symbols and numbers.” | ||
* @param {String} [input=''] text | ||
* @return {Boolean} true if all [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) | ||
* @return {Boolean} true if passes checks | ||
* @example | ||
@@ -1271,7 +1324,9 @@ * isJapanese('泣き虫') | ||
* // => true | ||
* isJapanese('泣き虫。!〜') // Full-width punctuation | ||
* isJapanese('2月1日') // Full and half-width numbers allowed | ||
* // => true | ||
* isJapanese('泣き虫.!~') // Half-width / Latin punctuation | ||
* isJapanese('泣き虫。!〜$') | ||
* // => true | ||
* isJapanese('泣き虫.!~$') // Half-width / Latin punctuation fails | ||
* // => false | ||
* isJapanese('泣き虫A') | ||
* isJapanese('A泣き虫') | ||
* // => false | ||
@@ -1285,5 +1340,3 @@ * isJapanese('A') | ||
if (isEmpty(input)) return false; | ||
return [].concat(toConsumableArray(input)).every(function (char) { | ||
return KANJI_KANA_REGEX.test(char); | ||
}); | ||
return [].concat(toConsumableArray(input)).every(isCharJapanese); | ||
} | ||
@@ -1593,3 +1646,3 @@ | ||
if (isEmpty(char)) return false; | ||
return ENGLISH_PUNCTUATION_RANGES.some(function (_ref) { | ||
return EN_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
@@ -1604,3 +1657,3 @@ start = _ref2[0], | ||
/** | ||
* Tests a character. Returns true if the character is considered Japanese punctuation. | ||
* Tests a character. Returns true if the character is considered English punctuation. | ||
* @param {String} char character string to test | ||
@@ -1612,3 +1665,4 @@ * @return {Boolean} | ||
return JAPANESE_FULLWIDTH_PUNCTUATION_RANGES.some(function (_ref) { | ||
if (isEmpty(char)) return false; | ||
return JA_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
@@ -1615,0 +1669,0 @@ start = _ref2[0], |
@@ -37,27 +37,60 @@ (function (global, factory) { | ||
// CharCode References | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
// http://unicode-table.com | ||
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml | ||
var CJK_SYMBOLS_PUNCTUATION = [0x3000, 0x303F]; | ||
var KATAKANA_PUNCTUATION = [0x30FB, 0x30FC]; | ||
var HIRAGANA_CHARS = [0x3040, 0x309F]; | ||
var KATAKANA_CHARS = [0x30A0, 0x30FF]; | ||
var ZENKAKU_NUMBERS = [0xFF10, 0xFF19]; | ||
var ZENKAKU_PUNCTUATION_1 = [0xFF01, 0xFF0F]; | ||
var ZENKAKU_PUNCTUATION_2 = [0xFF1A, 0xFF1F]; | ||
var ZENKAKU_PUNCTUATION_3 = [0xFF3B, 0xFF3F]; | ||
var ZENKAKU_PUNCTUATION_4 = [0xFF5B, 0xFF60]; | ||
var ZENKAKU_SYMBOLS_CURRENCY = [0xFFE0, 0xFFEE]; | ||
var KANA_PUNCTUATION = [0xFF61, 0xFF65]; | ||
var HANKAKU_KATAKANA = [0xFF66, 0xFF9F]; | ||
var COMMON_CJK = [0x4E00, 0x9FFF]; | ||
var RARE_CJK = [0x3400, 0x4DBF]; | ||
var LATIN_NUMBERS = [0x0030, 0x0039]; | ||
var MODERN_ENGLISH = [0x0000, 0x007f]; | ||
var HEPBURN_MACRON_RANGES = [[0x0100, 0x0101], // Ā ā | ||
[0x0112, 0x0113], // Ē ē | ||
[0x012a, 0x012b], // Ī ī | ||
[0x014c, 0x014d], // Ō ō | ||
[0x016a, 0x016b]]; | ||
var SMART_QUOTE_RANGES = [[0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
// const FULL_LATIN_RANGES = [ | ||
// [0x0001-0x007F], | ||
// [0x0080-0x00FF], | ||
// [0x0100-0x017F], | ||
// [0x0180-0x024F], | ||
// ]; | ||
var JA_PUNCTUATION_RANGES = [CJK_SYMBOLS_PUNCTUATION, KANA_PUNCTUATION, KATAKANA_PUNCTUATION, ZENKAKU_PUNCTUATION_1, ZENKAKU_PUNCTUATION_2, ZENKAKU_PUNCTUATION_3, ZENKAKU_PUNCTUATION_4, ZENKAKU_SYMBOLS_CURRENCY]; | ||
var KANA_RANGES = [HIRAGANA_CHARS, KATAKANA_CHARS, KANA_PUNCTUATION, HANKAKU_KATAKANA]; | ||
/** | ||
* All Japanese regex, for mixes of kanji and kana like "泣き虫" | ||
* Includes Japanese full-width punctuation ranges | ||
* Doesn't include *half-width katakana / roman letters* since they should be considered typos | ||
* @type {RegExp} | ||
* All Japanese unicode start and end ranges | ||
* Includes full-width punctuation and number ranges. | ||
* Incudes latin numbers since they are used in Japanese text as well. | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var KANJI_KANA_REGEX = /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff01-\uff0f\u4e00-\u9faf\u3400-\u4dbf]/; | ||
var JAPANESE_RANGES = [].concat(KANA_RANGES, JA_PUNCTUATION_RANGES, [LATIN_NUMBERS, ZENKAKU_NUMBERS, COMMON_CJK, RARE_CJK]); | ||
/** | ||
* Basic Latin unicode regex, for determining Romaji written as Hepburn romanisation | ||
* Basic Latin unicode regex, for determining Romaji + Hepburn romanisation | ||
* Includes upper/lowercase long vowels like "ā, ī, ū, ē, ō" | ||
* Includes curly quotes ‘’ “” | ||
* @type {RegExp} | ||
* Includes smart quotes ‘’ “” | ||
* @type {Array} | ||
* @ignore | ||
*/ | ||
var ROMAJI_REGEX = /[\u0000-\u007f\u0100-\u0101\u0112-\u0113\u012a-\u012b\u014c-\u014d\u016a-\u016b\u2018-\u2019\u201C-\u201D]/; | ||
var ROMAJI_RANGES = [MODERN_ENGLISH].concat(HEPBURN_MACRON_RANGES, SMART_QUOTE_RANGES); | ||
// TODO: just use a regex instead? not sure why these are in arrays | ||
var ENGLISH_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E], [0x2018, 0x2019], // ‘ ’ | ||
[0x201C, 0x201D]]; | ||
var JAPANESE_FULLWIDTH_PUNCTUATION_RANGES = [[0x3001, 0x303E], [0x30FB, 0x30FC], [0xFF01, 0xFF0F], [0xFF1A, 0xFF1F], [0xFF3B, 0xFF3F], [0xFF5B, 0xFF60]]; | ||
var EN_PUNCTUATION_RANGES = [[0x21, 0x2F], [0x3A, 0x3F], [0x5B, 0x60], [0x7B, 0x7E]].concat(SMART_QUOTE_RANGES); | ||
var LOWERCASE_START = 0x61; | ||
@@ -67,2 +100,6 @@ | ||
var UPPERCASE_END = 0x5A; | ||
var LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var HIRAGANA_START = 0x3041; | ||
@@ -74,6 +111,2 @@ var HIRAGANA_END = 0x3096; | ||
var KANJI_END = 0x9FAF; | ||
var LOWERCASE_FULLWIDTH_START = 0xFF41; | ||
var LOWERCASE_FULLWIDTH_END = 0xFF5A; | ||
var UPPERCASE_FULLWIDTH_START = 0xFF21; | ||
var UPPERCASE_FULLWIDTH_END = 0xFF3A; | ||
var PROLONGED_SOUND_MARK = 0x30FC; | ||
@@ -1227,11 +1260,17 @@ var KANA_SLASH_DOT = 0x30FB; | ||
/** | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) (allowing [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization)) | ||
* @param {String} char character string to test | ||
* @return {Boolean} | ||
*/ | ||
function isCharKana$2() { | ||
function isCharRomaji() { | ||
var char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
if (isEmpty(char)) return false; | ||
return ROMAJI_REGEX.test(char); | ||
return ROMAJI_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
start = _ref2[0], | ||
end = _ref2[1]; | ||
return isCharInRange(char, start, end); | ||
}); | ||
} | ||
@@ -1246,3 +1285,3 @@ | ||
* // => true | ||
* isRomaji('a*b&c-d') | ||
* isRomaji('12a*b&c-d') | ||
* // => true | ||
@@ -1260,4 +1299,19 @@ * isRomaji('あアA') | ||
if (isEmpty(input)) return false; | ||
return [].concat(toConsumableArray(input)).every(function (char) { | ||
return isCharKana$2(char); | ||
return [].concat(toConsumableArray(input)).every(isCharRomaji); | ||
} | ||
/** | ||
* Tests a character. Returns true if the character is [Katakana](https://en.wikipedia.org/wiki/Katakana). | ||
* @param {String} char character string to test | ||
* @return {Boolean} | ||
*/ | ||
function isCharJapanese() { | ||
var char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
return JAPANESE_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
start = _ref2[0], | ||
end = _ref2[1]; | ||
return isCharInRange(char, start, end); | ||
}); | ||
@@ -1267,6 +1321,5 @@ } | ||
/** | ||
* Test if `input` is [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) like “「泣き虫」” | ||
* Includes Japanese full-width punctuation ranges | ||
* Test if `input` only includes [Kanji](https://en.wikipedia.org/wiki/Kanji), [Kana](https://en.wikipedia.org/wiki/Kana), zenkaku punctuation, japanese symbols and numbers.” | ||
* @param {String} [input=''] text | ||
* @return {Boolean} true if all [Kanji](https://en.wikipedia.org/wiki/Kanji) and/or [Kana](https://en.wikipedia.org/wiki/Kana) | ||
* @return {Boolean} true if passes checks | ||
* @example | ||
@@ -1277,7 +1330,9 @@ * isJapanese('泣き虫') | ||
* // => true | ||
* isJapanese('泣き虫。!〜') // Full-width punctuation | ||
* isJapanese('2月1日') // Full and half-width numbers allowed | ||
* // => true | ||
* isJapanese('泣き虫.!~') // Half-width / Latin punctuation | ||
* isJapanese('泣き虫。!〜$') | ||
* // => true | ||
* isJapanese('泣き虫.!~$') // Half-width / Latin punctuation fails | ||
* // => false | ||
* isJapanese('泣き虫A') | ||
* isJapanese('A泣き虫') | ||
* // => false | ||
@@ -1291,5 +1346,3 @@ * isJapanese('A') | ||
if (isEmpty(input)) return false; | ||
return [].concat(toConsumableArray(input)).every(function (char) { | ||
return KANJI_KANA_REGEX.test(char); | ||
}); | ||
return [].concat(toConsumableArray(input)).every(isCharJapanese); | ||
} | ||
@@ -1599,3 +1652,3 @@ | ||
if (isEmpty(char)) return false; | ||
return ENGLISH_PUNCTUATION_RANGES.some(function (_ref) { | ||
return EN_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
@@ -1610,3 +1663,3 @@ start = _ref2[0], | ||
/** | ||
* Tests a character. Returns true if the character is considered Japanese punctuation. | ||
* Tests a character. Returns true if the character is considered English punctuation. | ||
* @param {String} char character string to test | ||
@@ -1618,3 +1671,4 @@ * @return {Boolean} | ||
return JAPANESE_FULLWIDTH_PUNCTUATION_RANGES.some(function (_ref) { | ||
if (isEmpty(char)) return false; | ||
return JA_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
@@ -1621,0 +1675,0 @@ start = _ref2[0], |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.wanakana=e.wanakana||{})}(this,function(e){"use strict";function n(e){return"string"!=typeof e||!e.length}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1],a=arguments[2];if(n(e))return!1;var r=e.charCodeAt(0);return r>=t&&a>=r}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return[].concat(le(e)).map(function(e,n){var a=e.charCodeAt(0),r=t(e,re,oe),o=t(e,ie,ue);return r?String.fromCharCode(a-re+V):o?String.fromCharCode(a-ie+W):e}).join("")}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[bcdfghjklmnpqrstvwxyz]/:/[bcdfghjklmnpqrstvwxz]/;return-1!==e.toLowerCase().charAt(0).search(a)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&t(e,W,Y)}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Math.min(e,n)}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments[2];return e.slice(n,t)}function y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[aeiouy]/:/[aeiou]/;return-1!==e.toLowerCase().charAt(0).search(a)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===ye}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===ce}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(!!c(e)||t(e,Z,$))}function f(){var e=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("").forEach(function(n){if(c(n)||h(n))e.push(n);else if(s(n)){var t=n.charCodeAt(0)+(ee-Z),a=String.fromCharCode(t);e.push(a)}else e.push(n)}),e.join("")}function d(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",ee,ne)}function v(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(s(e)||d(e))}function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(v)}function g(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=Object.assign({},X,n),h=[],s=0,d=e.length,v=3,g="",w="";d>s;){var p=null;for(v=i(3,d-s);v>0;){if(g=u(e,s,s+v),w=g.toLowerCase(),se.includes(w)&&d-s>=4)w=(g=u(e,s,s+(v+=1))).toLowerCase();else{if("n"===w.charAt(0)){if(2===v){if(!c.IMEMode&&" "===w.charAt(1)){p="ん ";break}if(c.IMEMode&&"n'"===w){p="ん";break}}r(w.charAt(1),!1)&&y(w.charAt(2))&&(w=(g=u(e,s,s+(v=1))).toLowerCase())}"n"!==w.charAt(0)&&r(w.charAt(0))&&g.charAt(0)===g.charAt(1)&&(v=1,t(g.charAt(0),W,Y)?(w="ッ",g="ッ"):(w="っ",g="っ"))}if(null!=(p=fe[w]))break;v-=4===v?2:1}null==p&&(p=g),c.useObsoleteKana&&("wi"===w&&(p="ゐ"),"we"===w&&(p="ゑ")),c.IMEMode&&"n"===w.charAt(0)&&("y"===e.charAt(s+1).toLowerCase()&&!1===y(e.charAt(s+2))||s===d-1||l(e.charAt(s+1)))&&(p=g.charAt(0)),a||o(g.charAt(0))&&(p=f(p)),h.push(p),s+=v||1}return h.join("")}function w(e){var n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});if(e instanceof Element&&ge.includes(e.nodeName)){var t=be();e.setAttribute("data-wanakana-id",t),e.autocapitalize="none",e.addEventListener("compositionupdate",b),e.addEventListener("input",n),we=k(n,t)}else console.warn("Input provided to wanakana.bind was not a valid input field.")}function p(e){var n=j(e);null!=n?(e.removeAttribute("data-wanakana-id"),e.removeEventListener("compositionupdate",b),e.removeEventListener("input",n.handler),we=A(n)):console.warn("Input had no listener registered.")}function m(e){var n=Object.assign({},X,e);return function(e){var t=e.target;if(me)me=!1;else{var r=a(t.value),o=g(x(r,n.IMEMode),Object.assign({},n,{IMEMode:!0}));if(r!==o){if(t.value=o,null!=t.setSelectionRange&&"number"==typeof t.selectionStart)return void t.setSelectionRange(t.value.length,t.value.length);if(null!=t.createTextRange){t.focus();var i=t.createTextRange();i.collapse(!1),i.select()}}}}}function b(e){var n=e.data||e.detail&&e.detail.data,t=n&&n.slice(-2).split("")||[],o="n"===t[0],i=t.every(function(e){return r(a(e))});me=!o&&i}function k(e,n){return we.concat({id:n,handler:e})}function j(e){return e&&we.find(function(n){return n.id===e.getAttribute("data-wanakana-id")})}function A(e){var n=e.id;return we.filter(function(e){return e.id!==n})}function x(e,n){switch(!0){case"toHiragana"===n:return e.toLowerCase();case"toKatakana"===n:return e.toUpperCase();default:return e}}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&F.test(e)}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(function(e){return q(e)})}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(function(e){return B.test(e)})}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(s)}function M(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(d)}function K(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",te,ae)}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(K)}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{passKanji:!0},t=[].concat(le(e)),a=!1;return n.passKanji||(a=t.some(L)),(t.some(E)||t.some(M))&&t.some(C)&&!a}function I(){for(var e=[],n="",t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(""),a=0;t.length>a;a+=1){var r=t[a],o=[h(r),c(r)],i=o[0],u=o[1];if(i||u&&1>a)e.push(r);else if(n&&u&&a>0){var y=de[n].slice(-1);e.push(he[y])}else if(!u&&d(r)){var s=r.charCodeAt(0)+(Z-ee),f=String.fromCharCode(s);e.push(f),n=f}else e.push(r),n=""}return e.join("")}function R(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n),a=e.length,r=[],o=0,y=2,c="",h="",s=void 0;a>o;){y=i(2,a-o);for(var f=!1;y>0;){if(c=u(e,o,o+y),M(c)&&(f=t.upcaseKatakana,c=I(c)),"っ"===c.charAt(0)&&1===y&&a-1>o){s=!0,h="";break}if(null!=(h=de[c])&&s&&(h=h.charAt(0).concat(h),s=!1),null!=h)break;y-=1}null==h&&(h=c),f&&(h=h.toUpperCase()),r.push(h),o+=y||1}return r.join("")}function S(){return g(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},!0)}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n);return t.passRomaji?I(e):C(e)?S(e,t):O(e,{passKanji:!0})?S(I(e),t):I(e)}function H(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n);return f(t.passRomaji?e:C(e)||O(e)?S(e,t):e)}function P(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&G.some(function(n){var a=ve(n,2);return t(e,a[0],a[1])})}function U(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Q.some(function(n){var a=ve(n,2);return t(e,a[0],a[1])})}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(P(e)||U(e))}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{all:!1};if(n(e)||!z(e)||l(e))return e;var a=[].concat(le(e));if(t.all)return a.filter(function(e){return!v(e)}).join("");for(var r=a.reverse(),o=0,i=r.length;i>o;o+=1){var u=r[o];if(!D(u)){if(L(u))break;r[o]=""}}return r.reverse().join("")}function _(e){switch(!0){case U(e):return"japanesePunctuation";case K(e):return"kanji";case s(e):return"hiragana";case d(e):return"katakana";default:return"romaji"}}function J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(n(e))return[""];var t=[].concat(le(e)),a=t.shift(),r=_(a);return t.reduce(function(e,n){var t=_(n)===r;if(r=_(n),t){var a=e.pop();return e.concat(a.concat(n))}return e.concat(n)},[a])}var X={useObsoleteKana:!1,passRomaji:!1,upcaseKatakana:!1,IMEMode:!1},B=/[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff01-\uff0f\u4e00-\u9faf\u3400-\u4dbf]/,F=/[\u0000-\u007f\u0100-\u0101\u0112-\u0113\u012a-\u012b\u014c-\u014d\u016a-\u016b\u2018-\u2019\u201C-\u201D]/,G=[[33,47],[58,63],[91,96],[123,126],[8216,8217],[8220,8221]],Q=[[12289,12350],[12539,12540],[65281,65295],[65306,65311],[65339,65343],[65371,65376]],V=97,W=65,Y=90,Z=12353,$=12438,ee=12449,ne=12540,te=19968,ae=40879,re=65345,oe=65370,ie=65313,ue=65338,ye=12540,ce=12539,he={a:"あ",i:"い",u:"う",e:"え",o:"う"},se=["lts","chy","shy"],fe={".":"。",",":"、",":":":","/":"・","!":"!","?":"?","~":"〜","-":"ー","‘":"「","’":"」","“":"『","”":"』","[":"[","]":"]","(":"(",")":")","{":"{","}":"}",a:"あ",i:"い",u:"う",e:"え",o:"お",yi:"い",wu:"う",whu:"う",xa:"ぁ",xi:"ぃ",xu:"ぅ",xe:"ぇ",xo:"ぉ",xyi:"ぃ",xye:"ぇ",ye:"いぇ",wha:"うぁ",whi:"うぃ",whe:"うぇ",who:"うぉ",wi:"うぃ",we:"うぇ",va:"ゔぁ",vi:"ゔぃ",vu:"ゔ",ve:"ゔぇ",vo:"ゔぉ",vya:"ゔゃ",vyi:"ゔぃ",vyu:"ゔゅ",vye:"ゔぇ",vyo:"ゔょ",ka:"か",ki:"き",ku:"く",ke:"け",ko:"こ",lka:"ヵ",lke:"ヶ",xka:"ヵ",xke:"ヶ",kya:"きゃ",kyi:"きぃ",kyu:"きゅ",kye:"きぇ",kyo:"きょ",ca:"か",ci:"き",cu:"く",ce:"け",co:"こ",lca:"ヵ",lce:"ヶ",xca:"ヵ",xce:"ヶ",qya:"くゃ",qyu:"くゅ",qyo:"くょ",qwa:"くぁ",qwi:"くぃ",qwu:"くぅ",qwe:"くぇ",qwo:"くぉ",qa:"くぁ",qi:"くぃ",qe:"くぇ",qo:"くぉ",kwa:"くぁ",qyi:"くぃ",qye:"くぇ",ga:"が",gi:"ぎ",gu:"ぐ",ge:"げ",go:"ご",gya:"ぎゃ",gyi:"ぎぃ",gyu:"ぎゅ",gye:"ぎぇ",gyo:"ぎょ",gwa:"ぐぁ",gwi:"ぐぃ",gwu:"ぐぅ",gwe:"ぐぇ",gwo:"ぐぉ",sa:"さ",si:"し",shi:"し",su:"す",se:"せ",so:"そ",za:"ざ",zi:"じ",zu:"ず",ze:"ぜ",zo:"ぞ",ji:"じ",sya:"しゃ",syi:"しぃ",syu:"しゅ",sye:"しぇ",syo:"しょ",sha:"しゃ",shu:"しゅ",she:"しぇ",sho:"しょ",shya:"しゃ",shyu:"しゅ",shye:"しぇ",shyo:"しょ",swa:"すぁ",swi:"すぃ",swu:"すぅ",swe:"すぇ",swo:"すぉ",zya:"じゃ",zyi:"じぃ",zyu:"じゅ",zye:"じぇ",zyo:"じょ",ja:"じゃ",ju:"じゅ",je:"じぇ",jo:"じょ",jya:"じゃ",jyi:"じぃ",jyu:"じゅ",jye:"じぇ",jyo:"じょ",ta:"た",ti:"ち",tu:"つ",te:"て",to:"と",chi:"ち",tsu:"つ",ltu:"っ",xtu:"っ",tya:"ちゃ",tyi:"ちぃ",tyu:"ちゅ",tye:"ちぇ",tyo:"ちょ",cha:"ちゃ",chu:"ちゅ",che:"ちぇ",cho:"ちょ",cya:"ちゃ",cyi:"ちぃ",cyu:"ちゅ",cye:"ちぇ",cyo:"ちょ",chya:"ちゃ",chyu:"ちゅ",chye:"ちぇ",chyo:"ちょ",tsa:"つぁ",tsi:"つぃ",tse:"つぇ",tso:"つぉ",tha:"てゃ",thi:"てぃ",thu:"てゅ",the:"てぇ",tho:"てょ",twa:"とぁ",twi:"とぃ",twu:"とぅ",twe:"とぇ",two:"とぉ",da:"だ",di:"ぢ",du:"づ",de:"で",do:"ど",dya:"ぢゃ",dyi:"ぢぃ",dyu:"ぢゅ",dye:"ぢぇ",dyo:"ぢょ",dha:"でゃ",dhi:"でぃ",dhu:"でゅ",dhe:"でぇ",dho:"でょ",dwa:"どぁ",dwi:"どぃ",dwu:"どぅ",dwe:"どぇ",dwo:"どぉ",na:"な",ni:"に",nu:"ぬ",ne:"ね",no:"の",nya:"にゃ",nyi:"にぃ",nyu:"にゅ",nye:"にぇ",nyo:"にょ",ha:"は",hi:"ひ",hu:"ふ",he:"へ",ho:"ほ",fu:"ふ",hya:"ひゃ",hyi:"ひぃ",hyu:"ひゅ",hye:"ひぇ",hyo:"ひょ",fya:"ふゃ",fyu:"ふゅ",fyo:"ふょ",fwa:"ふぁ",fwi:"ふぃ",fwu:"ふぅ",fwe:"ふぇ",fwo:"ふぉ",fa:"ふぁ",fi:"ふぃ",fe:"ふぇ",fo:"ふぉ",fyi:"ふぃ",fye:"ふぇ",ba:"ば",bi:"び",bu:"ぶ",be:"べ",bo:"ぼ",bya:"びゃ",byi:"びぃ",byu:"びゅ",bye:"びぇ",byo:"びょ",pa:"ぱ",pi:"ぴ",pu:"ぷ",pe:"ぺ",po:"ぽ",pya:"ぴゃ",pyi:"ぴぃ",pyu:"ぴゅ",pye:"ぴぇ",pyo:"ぴょ",ma:"ま",mi:"み",mu:"む",me:"め",mo:"も",mya:"みゃ",myi:"みぃ",myu:"みゅ",mye:"みぇ",myo:"みょ",ya:"や",yu:"ゆ",yo:"よ",xya:"ゃ",xyu:"ゅ",xyo:"ょ",ra:"ら",ri:"り",ru:"る",re:"れ",ro:"ろ",rya:"りゃ",ryi:"りぃ",ryu:"りゅ",rye:"りぇ",ryo:"りょ",la:"ら",li:"り",lu:"る",le:"れ",lo:"ろ",lya:"りゃ",lyi:"りぃ",lyu:"りゅ",lye:"りぇ",lyo:"りょ",wa:"わ",wo:"を",lwe:"ゎ",xwa:"ゎ",n:"ん",nn:"ん","n'":"ん","n ":"ん",xn:"ん",ltsu:"っ"},de={" ":" ","!":"!","?":"?","。":".",":":":","・":"/","、":",","〜":"~","ー":"-","「":"‘","」":"’","『":"“","』":"”","[":"[","]":"]","(":"(",")":")","{":"{","}":"}","あ":"a","い":"i","う":"u","え":"e","お":"o","ゔぁ":"va","ゔぃ":"vi","ゔ":"vu","ゔぇ":"ve","ゔぉ":"vo","か":"ka","き":"ki","きゃ":"kya","きぃ":"kyi","きゅ":"kyu","く":"ku","け":"ke","こ":"ko","が":"ga","ぎ":"gi","ぐ":"gu","げ":"ge","ご":"go","ぎゃ":"gya","ぎぃ":"gyi","ぎゅ":"gyu","ぎぇ":"gye","ぎょ":"gyo","さ":"sa","す":"su","せ":"se","そ":"so","ざ":"za","ず":"zu","ぜ":"ze","ぞ":"zo","し":"shi","しゃ":"sha","しゅ":"shu","しょ":"sho","じ":"ji","じゃ":"ja","じゅ":"ju","じょ":"jo","た":"ta","ち":"chi","ちゃ":"cha","ちゅ":"chu","ちょ":"cho","つ":"tsu","て":"te","と":"to","だ":"da","ぢ":"di","づ":"du","で":"de","ど":"do","な":"na","に":"ni","にゃ":"nya","にゅ":"nyu","にょ":"nyo","ぬ":"nu","ね":"ne","の":"no","は":"ha","ひ":"hi","ふ":"fu","へ":"he","ほ":"ho","ひゃ":"hya","ひゅ":"hyu","ひょ":"hyo","ふぁ":"fa","ふぃ":"fi","ふぇ":"fe","ふぉ":"fo","ば":"ba","び":"bi","ぶ":"bu","べ":"be","ぼ":"bo","びゃ":"bya","びゅ":"byu","びょ":"byo","ぱ":"pa","ぴ":"pi","ぷ":"pu","ぺ":"pe","ぽ":"po","ぴゃ":"pya","ぴゅ":"pyu","ぴょ":"pyo","ま":"ma","み":"mi","む":"mu","め":"me","も":"mo","みゃ":"mya","みゅ":"myu","みょ":"myo","や":"ya","ゆ":"yu","よ":"yo","ら":"ra","り":"ri","る":"ru","れ":"re","ろ":"ro","りゃ":"rya","りゅ":"ryu","りょ":"ryo","わ":"wa","を":"wo","ん":"n","ゐ":"wi","ゑ":"we","きぇ":"kye","きょ":"kyo","じぃ":"jyi","じぇ":"jye","ちぃ":"cyi","ちぇ":"che","ひぃ":"hyi","ひぇ":"hye","びぃ":"byi","びぇ":"bye","ぴぃ":"pyi","ぴぇ":"pye","みぇ":"mye","みぃ":"myi","りぃ":"ryi","りぇ":"rye","にぃ":"nyi","にぇ":"nye","しぃ":"syi","しぇ":"she","いぇ":"ye","うぁ":"wha","うぉ":"who","うぃ":"wi","うぇ":"we","ゔゃ":"vya","ゔゅ":"vyu","ゔょ":"vyo","すぁ":"swa","すぃ":"swi","すぅ":"swu","すぇ":"swe","すぉ":"swo","くゃ":"qya","くゅ":"qyu","くょ":"qyo","くぁ":"qwa","くぃ":"qwi","くぅ":"qwu","くぇ":"qwe","くぉ":"qwo","ぐぁ":"gwa","ぐぃ":"gwi","ぐぅ":"gwu","ぐぇ":"gwe","ぐぉ":"gwo","つぁ":"tsa","つぃ":"tsi","つぇ":"tse","つぉ":"tso","てゃ":"tha","てぃ":"thi","てゅ":"thu","てぇ":"the","てょ":"tho","とぁ":"twa","とぃ":"twi","とぅ":"twu","とぇ":"twe","とぉ":"two","ぢゃ":"dya","ぢぃ":"dyi","ぢゅ":"dyu","ぢぇ":"dye","ぢょ":"dyo","でゃ":"dha","でぃ":"dhi","でゅ":"dhu","でぇ":"dhe","でょ":"dho","どぁ":"dwa","どぃ":"dwi","どぅ":"dwu","どぇ":"dwe","どぉ":"dwo","ふぅ":"fwu","ふゃ":"fya","ふゅ":"fyu","ふょ":"fyo","ぁ":"a","ぃ":"i","ぇ":"e","ぅ":"u","ぉ":"o","ゃ":"ya","ゅ":"yu","ょ":"yo","っ":"","ゕ":"ka","ゖ":"ka","ゎ":"wa","んあ":"n'a","んい":"n'i","んう":"n'u","んえ":"n'e","んお":"n'o","んや":"n'ya","んゆ":"n'yu","んよ":"n'yo"},ve=function(){function e(e,n){var t=[],a=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(a=(i=u.next()).done)&&(t.push(i.value),!n||t.length!==n);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&u.return&&u.return()}finally{if(r)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),le=function(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);e.length>n;n++)t[n]=e[n];return t}return Array.from(e)},ge=["TEXTAREA","INPUT"],we=[],pe=0,me=!1,be=function(){return pe+=1,""+Date.now()+pe};e.bind=w,e.unbind=p,e.isRomaji=C,e.isJapanese=z,e.isKana=l,e.isHiragana=E,e.isKatakana=M,e.isMixed=O,e.isKanji=L,e.toRomaji=R,e.toKana=g,e.toHiragana=T,e.toKatakana=H,e.stripOkurigana=N,e.tokenize=J,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.wanakana=e.wanakana||{})}(this,function(e){"use strict";function n(e){return"string"!=typeof e||!e.length}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1],a=arguments[2];if(n(e))return!1;var r=e.charCodeAt(0);return r>=t&&a>=r}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return[].concat(qe(e)).map(function(e,n){var a=e.charCodeAt(0),r=t(e,ye,ce),o=t(e,he,se);return r?String.fromCharCode(a-ye+oe):o?String.fromCharCode(a-he+ie):e}).join("")}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[bcdfghjklmnpqrstvwxyz]/:/[bcdfghjklmnpqrstvwxz]/;return-1!==e.toLowerCase().charAt(0).search(a)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&t(e,ie,ue)}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Math.min(e,n)}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments[2];return e.slice(n,t)}function y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[aeiouy]/:/[aeiou]/;return-1!==e.toLowerCase().charAt(0).search(a)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===pe}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===me}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(!!c(e)||t(e,de,ve))}function d(){var e=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("").forEach(function(n){if(c(n)||h(n))e.push(n);else if(s(n)){var t=n.charCodeAt(0)+(fe-de),a=String.fromCharCode(t);e.push(a)}else e.push(n)}),e.join("")}function v(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",fe,le)}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(s(e)||v(e))}function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(f)}function g(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=Object.assign({},B,n),h=[],s=0,v=e.length,f=3,g="",w="";v>s;){var p=null;for(f=i(3,v-s);f>0;){if(g=u(e,s,s+f),w=g.toLowerCase(),be.includes(w)&&v-s>=4)w=(g=u(e,s,s+(f+=1))).toLowerCase();else{if("n"===w.charAt(0)){if(2===f){if(!c.IMEMode&&" "===w.charAt(1)){p="ん ";break}if(c.IMEMode&&"n'"===w){p="ん";break}}r(w.charAt(1),!1)&&y(w.charAt(2))&&(w=(g=u(e,s,s+(f=1))).toLowerCase())}"n"!==w.charAt(0)&&r(w.charAt(0))&&g.charAt(0)===g.charAt(1)&&(f=1,t(g.charAt(0),ie,ue)?(w="ッ",g="ッ"):(w="っ",g="っ"))}if(null!=(p=je[w]))break;f-=4===f?2:1}null==p&&(p=g),c.useObsoleteKana&&("wi"===w&&(p="ゐ"),"we"===w&&(p="ゑ")),c.IMEMode&&"n"===w.charAt(0)&&("y"===e.charAt(s+1).toLowerCase()&&!1===y(e.charAt(s+2))||s===v-1||l(e.charAt(s+1)))&&(p=g.charAt(0)),a||o(g.charAt(0))&&(p=d(p)),h.push(p),s+=f||1}return h.join("")}function w(e){var n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});if(e instanceof Element&&Ce.includes(e.nodeName)){var t=Ke();e.setAttribute("data-wanakana-id",t),e.autocapitalize="none",e.addEventListener("compositionupdate",k),e.addEventListener("input",n),ze=b(n,t)}else console.warn("Input provided to wanakana.bind was not a valid input field.")}function p(e){var n=j(e);null!=n?(e.removeAttribute("data-wanakana-id"),e.removeEventListener("compositionupdate",k),e.removeEventListener("input",n.handler),ze=A(n)):console.warn("Input had no listener registered.")}function m(e){var n=Object.assign({},B,e);return function(e){var t=e.target;if(Me)Me=!1;else{var r=a(t.value),o=g(x(r,n.IMEMode),Object.assign({},n,{IMEMode:!0}));if(r!==o){if(t.value=o,null!=t.setSelectionRange&&"number"==typeof t.selectionStart)return void t.setSelectionRange(t.value.length,t.value.length);if(null!=t.createTextRange){t.focus();var i=t.createTextRange();i.collapse(!1),i.select()}}}}}function k(e){var n=e.data||e.detail&&e.detail.data,t=n&&n.slice(-2).split("")||[],o="n"===t[0],i=t.every(function(e){return r(a(e))});Me=!o&&i}function b(e,n){return ze.concat({id:n,handler:e})}function j(e){return e&&ze.find(function(n){return n.id===e.getAttribute("data-wanakana-id")})}function A(e){var n=e.id;return ze.filter(function(e){return e.id!==n})}function x(e,n){switch(!0){case"toHiragana"===n:return e.toLowerCase();case"toKatakana"===n:return e.toUpperCase();default:return e}}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&ae.some(function(n){var a=xe(n,2);return t(e,a[0],a[1])})}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(q)}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return te.some(function(n){var a=xe(n,2);return t(e,a[0],a[1])})}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(z)}function M(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(s)}function K(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(v)}function L(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",ge,we)}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(qe(e)).every(L)}function I(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{passKanji:!0},t=[].concat(qe(e)),a=!1;return n.passKanji||(a=t.some(O)),(t.some(M)||t.some(K))&&t.some(C)&&!a}function R(){for(var e=[],n="",t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(""),a=0;t.length>a;a+=1){var r=t[a],o=[h(r),c(r)],i=o[0],u=o[1];if(i||u&&1>a)e.push(r);else if(n&&u&&a>0){var y=Ae[n].slice(-1);e.push(ke[y])}else if(!u&&v(r)){var s=r.charCodeAt(0)+(de-fe),d=String.fromCharCode(s);e.push(d),n=d}else e.push(r),n=""}return e.join("")}function S(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},B,n),a=e.length,r=[],o=0,y=2,c="",h="",s=void 0;a>o;){y=i(2,a-o);for(var d=!1;y>0;){if(c=u(e,o,o+y),K(c)&&(d=t.upcaseKatakana,c=R(c)),"っ"===c.charAt(0)&&1===y&&a-1>o){s=!0,h="";break}if(null!=(h=Ae[c])&&s&&(h=h.charAt(0).concat(h),s=!1),null!=h)break;y-=1}null==h&&(h=c),d&&(h=h.toUpperCase()),r.push(h),o+=y||1}return r.join("")}function T(){return g(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},!0)}function H(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},B,n);return t.passRomaji?R(e):C(e)?T(e,t):I(e,{passKanji:!0})?T(R(e),t):R(e)}function P(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},B,n);return d(t.passRomaji?e:C(e)||I(e)?T(e,t):e)}function U(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&re.some(function(n){var a=xe(n,2);return t(e,a[0],a[1])})}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&ee.some(function(n){var a=xe(n,2);return t(e,a[0],a[1])})}function _(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(U(e)||N(e))}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{all:!1};if(n(e)||!E(e)||l(e))return e;var a=[].concat(qe(e));if(t.all)return a.filter(function(e){return!f(e)}).join("");for(var r=a.reverse(),o=0,i=r.length;i>o;o+=1){var u=r[o];if(!_(u)){if(O(u))break;r[o]=""}}return r.reverse().join("")}function J(e){switch(!0){case N(e):return"japanesePunctuation";case L(e):return"kanji";case s(e):return"hiragana";case v(e):return"katakana";default:return"romaji"}}function X(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(n(e))return[""];var t=[].concat(qe(e)),a=t.shift(),r=J(a);return t.reduce(function(e,n){var t=J(n)===r;if(r=J(n),t){var a=e.pop();return e.concat(a.concat(n))}return e.concat(n)},[a])}var B={useObsoleteKana:!1,passRomaji:!1,upcaseKatakana:!1,IMEMode:!1},F=[65296,65305],G=[65377,65381],Q=[19968,40959],V=[13312,19903],W=[48,57],Y=[0,127],Z=[[256,257],[274,275],[298,299],[332,333],[362,363]],$=[[8216,8217],[8220,8221]],ee=[[12288,12351],G,[12539,12540],[65281,65295],[65306,65311],[65339,65343],[65371,65376],[65504,65518]],ne=[[12352,12447],[12448,12543],G,[65382,65439]],te=[].concat(ne,ee,[W,F,Q,V]),ae=[Y].concat(Z,$),re=[[33,47],[58,63],[91,96],[123,126]].concat($),oe=97,ie=65,ue=90,ye=65345,ce=65370,he=65313,se=65338,de=12353,ve=12438,fe=12449,le=12540,ge=19968,we=40879,pe=12540,me=12539,ke={a:"あ",i:"い",u:"う",e:"え",o:"う"},be=["lts","chy","shy"],je={".":"。",",":"、",":":":","/":"・","!":"!","?":"?","~":"〜","-":"ー","‘":"「","’":"」","“":"『","”":"』","[":"[","]":"]","(":"(",")":")","{":"{","}":"}",a:"あ",i:"い",u:"う",e:"え",o:"お",yi:"い",wu:"う",whu:"う",xa:"ぁ",xi:"ぃ",xu:"ぅ",xe:"ぇ",xo:"ぉ",xyi:"ぃ",xye:"ぇ",ye:"いぇ",wha:"うぁ",whi:"うぃ",whe:"うぇ",who:"うぉ",wi:"うぃ",we:"うぇ",va:"ゔぁ",vi:"ゔぃ",vu:"ゔ",ve:"ゔぇ",vo:"ゔぉ",vya:"ゔゃ",vyi:"ゔぃ",vyu:"ゔゅ",vye:"ゔぇ",vyo:"ゔょ",ka:"か",ki:"き",ku:"く",ke:"け",ko:"こ",lka:"ヵ",lke:"ヶ",xka:"ヵ",xke:"ヶ",kya:"きゃ",kyi:"きぃ",kyu:"きゅ",kye:"きぇ",kyo:"きょ",ca:"か",ci:"き",cu:"く",ce:"け",co:"こ",lca:"ヵ",lce:"ヶ",xca:"ヵ",xce:"ヶ",qya:"くゃ",qyu:"くゅ",qyo:"くょ",qwa:"くぁ",qwi:"くぃ",qwu:"くぅ",qwe:"くぇ",qwo:"くぉ",qa:"くぁ",qi:"くぃ",qe:"くぇ",qo:"くぉ",kwa:"くぁ",qyi:"くぃ",qye:"くぇ",ga:"が",gi:"ぎ",gu:"ぐ",ge:"げ",go:"ご",gya:"ぎゃ",gyi:"ぎぃ",gyu:"ぎゅ",gye:"ぎぇ",gyo:"ぎょ",gwa:"ぐぁ",gwi:"ぐぃ",gwu:"ぐぅ",gwe:"ぐぇ",gwo:"ぐぉ",sa:"さ",si:"し",shi:"し",su:"す",se:"せ",so:"そ",za:"ざ",zi:"じ",zu:"ず",ze:"ぜ",zo:"ぞ",ji:"じ",sya:"しゃ",syi:"しぃ",syu:"しゅ",sye:"しぇ",syo:"しょ",sha:"しゃ",shu:"しゅ",she:"しぇ",sho:"しょ",shya:"しゃ",shyu:"しゅ",shye:"しぇ",shyo:"しょ",swa:"すぁ",swi:"すぃ",swu:"すぅ",swe:"すぇ",swo:"すぉ",zya:"じゃ",zyi:"じぃ",zyu:"じゅ",zye:"じぇ",zyo:"じょ",ja:"じゃ",ju:"じゅ",je:"じぇ",jo:"じょ",jya:"じゃ",jyi:"じぃ",jyu:"じゅ",jye:"じぇ",jyo:"じょ",ta:"た",ti:"ち",tu:"つ",te:"て",to:"と",chi:"ち",tsu:"つ",ltu:"っ",xtu:"っ",tya:"ちゃ",tyi:"ちぃ",tyu:"ちゅ",tye:"ちぇ",tyo:"ちょ",cha:"ちゃ",chu:"ちゅ",che:"ちぇ",cho:"ちょ",cya:"ちゃ",cyi:"ちぃ",cyu:"ちゅ",cye:"ちぇ",cyo:"ちょ",chya:"ちゃ",chyu:"ちゅ",chye:"ちぇ",chyo:"ちょ",tsa:"つぁ",tsi:"つぃ",tse:"つぇ",tso:"つぉ",tha:"てゃ",thi:"てぃ",thu:"てゅ",the:"てぇ",tho:"てょ",twa:"とぁ",twi:"とぃ",twu:"とぅ",twe:"とぇ",two:"とぉ",da:"だ",di:"ぢ",du:"づ",de:"で",do:"ど",dya:"ぢゃ",dyi:"ぢぃ",dyu:"ぢゅ",dye:"ぢぇ",dyo:"ぢょ",dha:"でゃ",dhi:"でぃ",dhu:"でゅ",dhe:"でぇ",dho:"でょ",dwa:"どぁ",dwi:"どぃ",dwu:"どぅ",dwe:"どぇ",dwo:"どぉ",na:"な",ni:"に",nu:"ぬ",ne:"ね",no:"の",nya:"にゃ",nyi:"にぃ",nyu:"にゅ",nye:"にぇ",nyo:"にょ",ha:"は",hi:"ひ",hu:"ふ",he:"へ",ho:"ほ",fu:"ふ",hya:"ひゃ",hyi:"ひぃ",hyu:"ひゅ",hye:"ひぇ",hyo:"ひょ",fya:"ふゃ",fyu:"ふゅ",fyo:"ふょ",fwa:"ふぁ",fwi:"ふぃ",fwu:"ふぅ",fwe:"ふぇ",fwo:"ふぉ",fa:"ふぁ",fi:"ふぃ",fe:"ふぇ",fo:"ふぉ",fyi:"ふぃ",fye:"ふぇ",ba:"ば",bi:"び",bu:"ぶ",be:"べ",bo:"ぼ",bya:"びゃ",byi:"びぃ",byu:"びゅ",bye:"びぇ",byo:"びょ",pa:"ぱ",pi:"ぴ",pu:"ぷ",pe:"ぺ",po:"ぽ",pya:"ぴゃ",pyi:"ぴぃ",pyu:"ぴゅ",pye:"ぴぇ",pyo:"ぴょ",ma:"ま",mi:"み",mu:"む",me:"め",mo:"も",mya:"みゃ",myi:"みぃ",myu:"みゅ",mye:"みぇ",myo:"みょ",ya:"や",yu:"ゆ",yo:"よ",xya:"ゃ",xyu:"ゅ",xyo:"ょ",ra:"ら",ri:"り",ru:"る",re:"れ",ro:"ろ",rya:"りゃ",ryi:"りぃ",ryu:"りゅ",rye:"りぇ",ryo:"りょ",la:"ら",li:"り",lu:"る",le:"れ",lo:"ろ",lya:"りゃ",lyi:"りぃ",lyu:"りゅ",lye:"りぇ",lyo:"りょ",wa:"わ",wo:"を",lwe:"ゎ",xwa:"ゎ",n:"ん",nn:"ん","n'":"ん","n ":"ん",xn:"ん",ltsu:"っ"},Ae={" ":" ","!":"!","?":"?","。":".",":":":","・":"/","、":",","〜":"~","ー":"-","「":"‘","」":"’","『":"“","』":"”","[":"[","]":"]","(":"(",")":")","{":"{","}":"}","あ":"a","い":"i","う":"u","え":"e","お":"o","ゔぁ":"va","ゔぃ":"vi","ゔ":"vu","ゔぇ":"ve","ゔぉ":"vo","か":"ka","き":"ki","きゃ":"kya","きぃ":"kyi","きゅ":"kyu","く":"ku","け":"ke","こ":"ko","が":"ga","ぎ":"gi","ぐ":"gu","げ":"ge","ご":"go","ぎゃ":"gya","ぎぃ":"gyi","ぎゅ":"gyu","ぎぇ":"gye","ぎょ":"gyo","さ":"sa","す":"su","せ":"se","そ":"so","ざ":"za","ず":"zu","ぜ":"ze","ぞ":"zo","し":"shi","しゃ":"sha","しゅ":"shu","しょ":"sho","じ":"ji","じゃ":"ja","じゅ":"ju","じょ":"jo","た":"ta","ち":"chi","ちゃ":"cha","ちゅ":"chu","ちょ":"cho","つ":"tsu","て":"te","と":"to","だ":"da","ぢ":"di","づ":"du","で":"de","ど":"do","な":"na","に":"ni","にゃ":"nya","にゅ":"nyu","にょ":"nyo","ぬ":"nu","ね":"ne","の":"no","は":"ha","ひ":"hi","ふ":"fu","へ":"he","ほ":"ho","ひゃ":"hya","ひゅ":"hyu","ひょ":"hyo","ふぁ":"fa","ふぃ":"fi","ふぇ":"fe","ふぉ":"fo","ば":"ba","び":"bi","ぶ":"bu","べ":"be","ぼ":"bo","びゃ":"bya","びゅ":"byu","びょ":"byo","ぱ":"pa","ぴ":"pi","ぷ":"pu","ぺ":"pe","ぽ":"po","ぴゃ":"pya","ぴゅ":"pyu","ぴょ":"pyo","ま":"ma","み":"mi","む":"mu","め":"me","も":"mo","みゃ":"mya","みゅ":"myu","みょ":"myo","や":"ya","ゆ":"yu","よ":"yo","ら":"ra","り":"ri","る":"ru","れ":"re","ろ":"ro","りゃ":"rya","りゅ":"ryu","りょ":"ryo","わ":"wa","を":"wo","ん":"n","ゐ":"wi","ゑ":"we","きぇ":"kye","きょ":"kyo","じぃ":"jyi","じぇ":"jye","ちぃ":"cyi","ちぇ":"che","ひぃ":"hyi","ひぇ":"hye","びぃ":"byi","びぇ":"bye","ぴぃ":"pyi","ぴぇ":"pye","みぇ":"mye","みぃ":"myi","りぃ":"ryi","りぇ":"rye","にぃ":"nyi","にぇ":"nye","しぃ":"syi","しぇ":"she","いぇ":"ye","うぁ":"wha","うぉ":"who","うぃ":"wi","うぇ":"we","ゔゃ":"vya","ゔゅ":"vyu","ゔょ":"vyo","すぁ":"swa","すぃ":"swi","すぅ":"swu","すぇ":"swe","すぉ":"swo","くゃ":"qya","くゅ":"qyu","くょ":"qyo","くぁ":"qwa","くぃ":"qwi","くぅ":"qwu","くぇ":"qwe","くぉ":"qwo","ぐぁ":"gwa","ぐぃ":"gwi","ぐぅ":"gwu","ぐぇ":"gwe","ぐぉ":"gwo","つぁ":"tsa","つぃ":"tsi","つぇ":"tse","つぉ":"tso","てゃ":"tha","てぃ":"thi","てゅ":"thu","てぇ":"the","てょ":"tho","とぁ":"twa","とぃ":"twi","とぅ":"twu","とぇ":"twe","とぉ":"two","ぢゃ":"dya","ぢぃ":"dyi","ぢゅ":"dyu","ぢぇ":"dye","ぢょ":"dyo","でゃ":"dha","でぃ":"dhi","でゅ":"dhu","でぇ":"dhe","でょ":"dho","どぁ":"dwa","どぃ":"dwi","どぅ":"dwu","どぇ":"dwe","どぉ":"dwo","ふぅ":"fwu","ふゃ":"fya","ふゅ":"fyu","ふょ":"fyo","ぁ":"a","ぃ":"i","ぇ":"e","ぅ":"u","ぉ":"o","ゃ":"ya","ゅ":"yu","ょ":"yo","っ":"","ゕ":"ka","ゖ":"ka","ゎ":"wa","んあ":"n'a","んい":"n'i","んう":"n'u","んえ":"n'e","んお":"n'o","んや":"n'ya","んゆ":"n'yu","んよ":"n'yo"},xe=function(){function e(e,n){var t=[],a=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(a=(i=u.next()).done)&&(t.push(i.value),!n||t.length!==n);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&u.return&&u.return()}finally{if(r)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),qe=function(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);e.length>n;n++)t[n]=e[n];return t}return Array.from(e)},Ce=["TEXTAREA","INPUT"],ze=[],Ee=0,Me=!1,Ke=function(){return Ee+=1,""+Date.now()+Ee};e.bind=w,e.unbind=p,e.isRomaji=C,e.isJapanese=E,e.isKana=l,e.isHiragana=M,e.isKatakana=K,e.isMixed=I,e.isKanji=O,e.toRomaji=S,e.toKana=g,e.toHiragana=H,e.toKatakana=P,e.stripOkurigana=D,e.tokenize=X,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "wanakana", | ||
"version": "2.2.4", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "http://www.wanakana.com", |
@@ -81,3 +81,3 @@ <div align="center"> | ||
/*** TEXT CHECKING UTILITIES ***/ | ||
wanakana.isJapanese('泣き虫。!〜') // Full-width/Zenkaku punctuation allowed | ||
wanakana.isJapanese('泣き虫。!〜2¥') | ||
// => true | ||
@@ -100,3 +100,3 @@ | ||
wanakana.isRomaji('Tōkyō and Ōsaka') // Basic Hepburn romanisation allowed | ||
wanakana.isRomaji('Tōkyō and Ōsaka') | ||
// => true | ||
@@ -109,3 +109,3 @@ | ||
* Non-romaji and _English_ punctuation is passed through: 123 @#$% | ||
* Japanese equivalent punctuation is converted: | ||
* Limited Japanese equivalent punctuation is converted: | ||
* !?.:/,~-‘’“”[](){} | ||
@@ -112,0 +112,0 @@ * !?。:・、〜ー「」『』[](){} |
@@ -30,3 +30,3 @@ 'use strict'; | ||
if ((0, _isEmpty2.default)(char)) return false; | ||
return _constants.ENGLISH_PUNCTUATION_RANGES.some(function (_ref) { | ||
return _constants.EN_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
@@ -33,0 +33,0 @@ start = _ref2[0], |
@@ -9,2 +9,6 @@ 'use strict'; | ||
var _isEmpty = require('./isEmpty'); | ||
var _isEmpty2 = _interopRequireDefault(_isEmpty); | ||
var _constants = require('../constants'); | ||
@@ -19,3 +23,3 @@ | ||
/** | ||
* Tests a character. Returns true if the character is considered Japanese punctuation. | ||
* Tests a character. Returns true if the character is considered English punctuation. | ||
* @param {String} char character string to test | ||
@@ -27,3 +31,4 @@ * @return {Boolean} | ||
return _constants.JAPANESE_FULLWIDTH_PUNCTUATION_RANGES.some(function (_ref) { | ||
if ((0, _isEmpty2.default)(char)) return false; | ||
return _constants.JA_PUNCTUATION_RANGES.some(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
@@ -30,0 +35,0 @@ start = _ref2[0], |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _isEmpty = require('./isEmpty'); | ||
@@ -12,2 +14,6 @@ | ||
var _isCharInRange = require('./isCharInRange'); | ||
var _isCharInRange2 = _interopRequireDefault(_isCharInRange); | ||
var _constants = require('../constants'); | ||
@@ -18,13 +24,19 @@ | ||
/** | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) | ||
* Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) (allowing [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization)) | ||
* @param {String} char character string to test | ||
* @return {Boolean} | ||
*/ | ||
function isCharKana() { | ||
function isCharRomaji() { | ||
var char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
if ((0, _isEmpty2.default)(char)) return false; | ||
return _constants.ROMAJI_REGEX.test(char); | ||
return _constants.ROMAJI_RANGES.some(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
start = _ref2[0], | ||
end = _ref2[1]; | ||
return (0, _isCharInRange2.default)(char, start, end); | ||
}); | ||
} | ||
exports.default = isCharKana; | ||
exports.default = isCharRomaji; |
204182
46
5464