leyserplus-moji
Version:
半角全角変換・特定文字抽出など日本語を便利に扱うJavaScriptライブラリ。
1,425 lines (1,218 loc) • 77.3 kB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 13);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
// original notice:
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
function compare(a, b) {
if (a === b) {
return 0;
}
var x = a.length;
var y = b.length;
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y) {
return -1;
}
if (y < x) {
return 1;
}
return 0;
}
function isBuffer(b) {
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
return global.Buffer.isBuffer(b);
}
return !!(b != null && b._isBuffer);
}
// based on node assert, original notice:
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
var util = __webpack_require__(11);
var hasOwn = Object.prototype.hasOwnProperty;
var pSlice = Array.prototype.slice;
var functionsHaveNames = (function () {
return function foo() {}.name === 'foo';
}());
function pToString (obj) {
return Object.prototype.toString.call(obj);
}
function isView(arrbuf) {
if (isBuffer(arrbuf)) {
return false;
}
if (typeof global.ArrayBuffer !== 'function') {
return false;
}
if (typeof ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(arrbuf);
}
if (!arrbuf) {
return false;
}
if (arrbuf instanceof DataView) {
return true;
}
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
return true;
}
return false;
}
// 1. The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
var assert = module.exports = ok;
// 2. The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
// actual: actual,
// expected: expected })
var regex = /\s*function\s+([^\(\s]*)\s*/;
// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
function getName(func) {
if (!util.isFunction(func)) {
return;
}
if (functionsHaveNames) {
return func.name;
}
var str = func.toString();
var match = str.match(regex);
return match && match[1];
}
assert.AssertionError = function AssertionError(options) {
this.name = 'AssertionError';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
if (options.message) {
this.message = options.message;
this.generatedMessage = false;
} else {
this.message = getMessage(this);
this.generatedMessage = true;
}
var stackStartFunction = options.stackStartFunction || fail;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
} else {
// non v8 browsers so we can have a stacktrace
var err = new Error();
if (err.stack) {
var out = err.stack;
// try to strip useless frames
var fn_name = getName(stackStartFunction);
var idx = out.indexOf('\n' + fn_name);
if (idx >= 0) {
// once we have located the function frame
// we need to strip out everything before it (and its line)
var next_line = out.indexOf('\n', idx + 1);
out = out.substring(next_line + 1);
}
this.stack = out;
}
}
};
// assert.AssertionError instanceof Error
util.inherits(assert.AssertionError, Error);
function truncate(s, n) {
if (typeof s === 'string') {
return s.length < n ? s : s.slice(0, n);
} else {
return s;
}
}
function inspect(something) {
if (functionsHaveNames || !util.isFunction(something)) {
return util.inspect(something);
}
var rawname = getName(something);
var name = rawname ? ': ' + rawname : '';
return '[Function' + name + ']';
}
function getMessage(self) {
return truncate(inspect(self.actual), 128) + ' ' +
self.operator + ' ' +
truncate(inspect(self.expected), 128);
}
// At present only the three keys mentioned above are used and
// understood by the spec. Implementations or sub modules can pass
// other keys to the AssertionError's constructor - they will be
// ignored.
// 3. All of the following functions must throw an AssertionError
// when a corresponding condition is not met, with a message that
// may be undefined if not provided. All assertion methods provide
// both the actual and expected values to the assertion error for
// display purposes.
function fail(actual, expected, message, operator, stackStartFunction) {
throw new assert.AssertionError({
message: message,
actual: actual,
expected: expected,
operator: operator,
stackStartFunction: stackStartFunction
});
}
// EXTENSION! allows for well behaved errors defined elsewhere.
assert.fail = fail;
// 4. Pure assertion tests whether a value is truthy, as determined
// by !!guard.
// assert.ok(guard, message_opt);
// This statement is equivalent to assert.equal(true, !!guard,
// message_opt);. To test strictly for the value true, use
// assert.strictEqual(true, guard, message_opt);.
function ok(value, message) {
if (!value) fail(value, true, message, '==', assert.ok);
}
assert.ok = ok;
// 5. The equality assertion tests shallow, coercive equality with
// ==.
// assert.equal(actual, expected, message_opt);
assert.equal = function equal(actual, expected, message) {
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};
// 6. The non-equality assertion tests for whether two objects are not equal
// with != assert.notEqual(actual, expected, message_opt);
assert.notEqual = function notEqual(actual, expected, message) {
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
};
// 7. The equivalence assertion tests a deep equality relation.
// assert.deepEqual(actual, expected, message_opt);
assert.deepEqual = function deepEqual(actual, expected, message) {
if (!_deepEqual(actual, expected, false)) {
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
}
};
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
if (!_deepEqual(actual, expected, true)) {
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
}
};
function _deepEqual(actual, expected, strict, memos) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (isBuffer(actual) && isBuffer(expected)) {
return compare(actual, expected) === 0;
// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (util.isDate(actual) && util.isDate(expected)) {
return actual.getTime() === expected.getTime();
// 7.3 If the expected value is a RegExp object, the actual value is
// equivalent if it is also a RegExp object with the same source and
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
return actual.source === expected.source &&
actual.global === expected.global &&
actual.multiline === expected.multiline &&
actual.lastIndex === expected.lastIndex &&
actual.ignoreCase === expected.ignoreCase;
// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if ((actual === null || typeof actual !== 'object') &&
(expected === null || typeof expected !== 'object')) {
return strict ? actual === expected : actual == expected;
// If both values are instances of typed arrays, wrap their underlying
// ArrayBuffers in a Buffer each to increase performance
// This optimization requires the arrays to have the same type as checked by
// Object.prototype.toString (aka pToString). Never perform binary
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
// bit patterns are not identical.
} else if (isView(actual) && isView(expected) &&
pToString(actual) === pToString(expected) &&
!(actual instanceof Float32Array ||
actual instanceof Float64Array)) {
return compare(new Uint8Array(actual.buffer),
new Uint8Array(expected.buffer)) === 0;
// 7.5 For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else if (isBuffer(actual) !== isBuffer(expected)) {
return false;
} else {
memos = memos || {actual: [], expected: []};
var actualIndex = memos.actual.indexOf(actual);
if (actualIndex !== -1) {
if (actualIndex === memos.expected.indexOf(expected)) {
return true;
}
}
memos.actual.push(actual);
memos.expected.push(expected);
return objEquiv(actual, expected, strict, memos);
}
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b, strict, actualVisitedObjects) {
if (a === null || a === undefined || b === null || b === undefined)
return false;
// if one is a primitive, the other must be same
if (util.isPrimitive(a) || util.isPrimitive(b))
return a === b;
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
return false;
var aIsArgs = isArguments(a);
var bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b, strict);
}
var ka = objectKeys(a);
var kb = objectKeys(b);
var key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length !== kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] !== kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
return false;
}
return true;
}
// 8. The non-equivalence assertion tests for any deep inequality.
// assert.notDeepEqual(actual, expected, message_opt);
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
if (_deepEqual(actual, expected, false)) {
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
}
};
assert.notDeepStrictEqual = notDeepStrictEqual;
function notDeepStrictEqual(actual, expected, message) {
if (_deepEqual(actual, expected, true)) {
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
}
}
// 9. The strict equality assertion tests strict equality, as determined by ===.
// assert.strictEqual(actual, expected, message_opt);
assert.strictEqual = function strictEqual(actual, expected, message) {
if (actual !== expected) {
fail(actual, expected, message, '===', assert.strictEqual);
}
};
// 10. The strict non-equality assertion tests for strict inequality, as
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (actual === expected) {
fail(actual, expected, message, '!==', assert.notStrictEqual);
}
};
function expectedException(actual, expected) {
if (!actual || !expected) {
return false;
}
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
return expected.test(actual);
}
try {
if (actual instanceof expected) {
return true;
}
} catch (e) {
// Ignore. The instanceof check doesn't work for arrow functions.
}
if (Error.isPrototypeOf(expected)) {
return false;
}
return expected.call({}, actual) === true;
}
function _tryBlock(block) {
var error;
try {
block();
} catch (e) {
error = e;
}
return error;
}
function _throws(shouldThrow, block, expected, message) {
var actual;
if (typeof block !== 'function') {
throw new TypeError('"block" argument must be a function');
}
if (typeof expected === 'string') {
message = expected;
expected = null;
}
actual = _tryBlock(block);
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
fail(actual, expected, 'Missing expected exception' + message);
}
var userProvidedMessage = typeof message === 'string';
var isUnwantedException = !shouldThrow && util.isError(actual);
var isUnexpectedException = !shouldThrow && actual && !expected;
if ((isUnwantedException &&
userProvidedMessage &&
expectedException(actual, expected)) ||
isUnexpectedException) {
fail(actual, expected, 'Got unwanted exception' + message);
}
if ((shouldThrow && actual && expected &&
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
throw actual;
}
}
// 11. Expected to throw an error:
// assert.throws(block, Error_opt, message_opt);
assert.throws = function(block, /*optional*/error, /*optional*/message) {
_throws(true, block, error, message);
};
// EXTENSION! This is annoying to write outside this module.
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
_throws(false, block, error, message);
};
assert.ifError = function(err) { if (err) throw err; };
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
if (hasOwn.call(obj, key)) keys.push(key);
}
return keys;
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
(function webpackUniversalModuleDefinition(root, factory) {
if (( false ? 'undefined' : _typeof(exports)) === 'object' && ( false ? 'undefined' : _typeof(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') exports["moji"] = factory();else root["moji"] = factory();
})(undefined, function () {
return (/******/function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/var installedModules = {};
/******/
/******/ // The require function
/******/function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/if (installedModules[moduleId]) {
/******/return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/var module = installedModules[moduleId] = {
/******/i: moduleId,
/******/l: false,
/******/exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/module.l = true;
/******/
/******/ // Return the exports of the module
/******/return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/__webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/__webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/__webpack_require__.i = function (value) {
return value;
};
/******/
/******/ // define getter function for harmony exports
/******/__webpack_require__.d = function (exports, name, getter) {
/******/if (!__webpack_require__.o(exports, name)) {
/******/Object.defineProperty(exports, name, {
/******/configurable: false,
/******/enumerable: true,
/******/get: getter
/******/ });
/******/
}
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/__webpack_require__.n = function (module) {
/******/var getter = module && module.__esModule ?
/******/function getDefault() {
return module['default'];
} :
/******/function getModuleExports() {
return module;
};
/******/__webpack_require__.d(getter, 'a', getter);
/******/return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/__webpack_require__.o = function (object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
};
/******/
/******/ // __webpack_public_path__
/******/__webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/return __webpack_require__(__webpack_require__.s = 8);
/******/
}(
/************************************************************************/
/******/[
/* 0 */
/***/function (module, exports, __webpack_require__) {
"use strict";
module.exports = {
/**
* @param {string} str
* @param {number} startCode
* @param {number} endCode
* @param {Function} cb
* @return {Array}
* @private
*/
rangeMap: function rangeMap(str, startCode, endCode, cb) {
return str.split("").map(function (s) {
var c = s.charCodeAt(0);
return cb(c > startCode && c < endCode, s, c);
});
},
/**
* @param {string} str
* @param {Regexp} regexp
* @param {Function} cb
* @return {String}
* @private
*/
regexpMap: function regexpMap(str, regexp, cb) {
return str.replace(regexp, function (s) {
return cb(s);
});
}
};
/***/
},
/* 1 */
/***/function (module, exports, __webpack_require__) {
"use strict";
module.exports = {
'ZE': { start: 0xff01, end: 0xff5e }, // 全角英数
'HE': { start: 0x0021, end: 0x007e }, // 半角英数
'HG': { start: 0x3041, end: 0x3096 }, // ひらがな
'KK': { start: 0x30a1, end: 0x30f6 }, // カタカナ
'HS': { patterns: [[/(\s|\u00A0)/g, { "ZS": " " }]] }, // 半角スペース
'ZS': { patterns: [[/(\u3000)/g, { "HS": " " }]] }, //全角スペース
'HK': { regexp: /([\uff66-\uff9c]\uff9e)|([\uff8a-\uff8e]\uff9f)|([\uff61-\uff9f])/g, // 半角カナ
list: ['。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚', 'ヺ', 'ヴ', 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', 'ゾ', 'ダ', 'ヂ', 'ヅ', 'デ', 'ド', 'バ', 'パ', 'ビ', 'ピ', 'ブ', 'プ', 'ベ', 'ペ', 'ボ', 'ポ', 'ヷ'] },
'ZK': { regexp: /([\u30a1-\u30f6])/g, //全角カナ (半角カナ変換用)
list: ['。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゛', '゜', 'ヺ', 'ヴ', 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', 'ゾ', 'ダ', 'ヂ', 'ヅ', 'デ', 'ド', 'バ', 'パ', 'ビ', 'ピ', 'ブ', 'プ', 'ベ', 'ペ', 'ボ', 'ポ', 'ヷ'] }
};
/***/
},
/* 2 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}return target;
};
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
}
}return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
};
}();
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var core = __webpack_require__(6);
/**
* @type {Moji}
*/
module.exports = function () {
/**
* @param {String} str
* @param {Object} mojisyu
*/
function Moji(str, mojisyu) {
_classCallCheck(this, Moji);
this._str = str;
this._mojisyu = _extends({}, mojisyu);
}
/**
* 変換
* @param {String} fromName 変換前の文字種名
* @param {String} toName 変換後の文字種名
* @return {Moji}
*/
_createClass(Moji, [{
key: "convert",
value: function convert(fromName, toName) {
if (!toName) {
var m = fromName.split("to");
return this.convert(m[0], m[1]);
}
var from = this._mojisyu[fromName];
var to = this._mojisyu[toName];
this._str = core.convert(this._str, from, to);
return this;
}
/**
* @param {string} filterMojisyuName フィルタする文字種名
* @return {Moji}
*/
}, {
key: "filter",
value: function filter(filterMojisyuName) {
this._str = core.filter(this._str, this._mojisyu[filterMojisyuName]);
return this;
}
/**
* @param {string} rejectMojisyuName
* @return {Moji}
*/
}, {
key: "reject",
value: function reject(rejectMojisyuName) {
this._str = core.reject(this._str, this._mojisyu[rejectMojisyuName]);
return this;
}
/**
* @return {string}
*/
}, {
key: "toString",
value: function toString() {
return this._str;
}
/**
* @param {string} separateString
* @return {string}
*/
}, {
key: "toCharCode",
value: function toCharCode(separateString) {
var ss = separateString || "|";
return this._str.split("").map(function (s) {
return s.charCodeAt(0);
}).join(ss);
}
/**
* 渡されたmethodをそのままString渡す
* @param {string} method
* @param {args} args
* @return {Moji}
*/
}, {
key: "string",
value: function string(method) {
var _String$prototype$met;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
this._str = (_String$prototype$met = String.prototype[method]).call.apply(_String$prototype$met, [this._str].concat(args));
return this;
}
}]);
return Moji;
}();
/***/
},
/* 3 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}return target;
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
/**
* @param {Object} mObj
* @return {Object}
*/
function types(mObj) {
var o = {};
o.range = mObj.start && mObj.end ? true : false;
o.regexpList = mObj.regexp && mObj.list ? true : false;
o.patterns = mObj.patterns ? true : false;
return o;
}
/**
* @type {Mojisyu}
*/
module.exports =
/**
* @param {String} name
* @param {Object} mObj
*/
function Mojisyu(name, mObj) {
_classCallCheck(this, Mojisyu);
this.name = name;
this.types = types(mObj);
this.props = {};
_extends(this.props, mObj);
};
/***/
},
/* 4 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var map = __webpack_require__(0);
module.exports = function convert(str, fromMojisyu, toMojisyu) {
if (fromMojisyu.types.range && toMojisyu.types.range) {
str = rangeConvert(str, fromMojisyu, toMojisyu);
}
if (fromMojisyu.types.regexpList && toMojisyu.types.regexpList) {
str = regexpListConvert(str, fromMojisyu, toMojisyu);
}
if (fromMojisyu.types.patterns) {
str = patternConvert(str, fromMojisyu, toMojisyu);
}
return str;
};
/**
* @param {string} str
* @param {Mojisyu} from
* @param {Mojisyu} to
* @return {string}
* @private
*/
function rangeConvert(str, from, to) {
var d = to.props.start - from.props.start;
return map.rangeMap(str, from.props.start, from.props.end, function (match, s, c) {
if (!match) {
return s;
}
return String.fromCharCode(c + d);
}).join("");
}
/**
* @param {string} str
* @param {Mojisyu} from
* @param {Mojisyu} to
* @return {string}
* @private
*/
function regexpListConvert(str, from, to) {
return map.regexpMap(str, from.props.regexp, function (s) {
var i = from.props.list.indexOf(s);
if (i === -1) return s;
return to.props.list[i];
});
}
/**
* @param {string} str
* @param {Mojisyu} from
* @param {Mojisyu} to
* @return {string}
* @private
*/
function patternConvert(str, from, to) {
return from.props.patterns.map(function (pattern) {
return map.regexpMap(str, pattern[0], function (s) {
return pattern[1][to.name];
});
}).join("");
}
/***/
},
/* 5 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var map = __webpack_require__(0);
/**
* @param {string} str
* @param {Mojisyu} filterMojisyu フィルタする文字種名
* @return {Moji}
*/
module.exports = function filter(str, filterMojisyu) {
if (filterMojisyu.types.range) {
str = rangeFilter(str, filterMojisyu);
}
if (filterMojisyu.types.regexpList) {
str = regexpListFilter(str, filterMojisyu);
}
if (filterMojisyu.types.patterns) {
str = patternFilter(str, filterMojisyu);
}
return str;
};
/**
* @param {string} str
* @param {Mojisyu} filterMojisyu
* @return {string}
* @private
*/
function rangeFilter(str, filterMojisyu) {
return map.rangeMap(str, filterMojisyu.props.start, filterMojisyu.props.end, function (match, str, code) {
if (!match) {
return "";
}
return str;
}).join("");
}
/**
* @param {string} str
* @param {Mojisyu} filterMojisyu
* @return {string}
* @private
*/
function regexpListFilter(str, filterMojisyu) {
var r = [];
map.regexpMap(str, filterMojisyu.props.regexp, function (s) {
var i = filterMojisyu.props.list.indexOf(s);
if (i !== -1) {
r.push(s);
}
});
return r.join("");
}
/**
* @param {string} str
* @param {Mojisyu} filterMojisyu
* @return {string}
* @private
*/
function patternFilter(str, filterMojisyu) {
var r = [];
filterMojisyu.props.patterns.forEach(function (pattern) {
map.regexpMap(str, pattern[0], function (s) {
r.push(s);
});
});
return r.join("");
}
/***/
},
/* 6 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var convert = __webpack_require__(4);
var filter = __webpack_require__(5);
var reject = __webpack_require__(7);
module.exports = {
convert: convert,
filter: filter,
reject: reject
};
/***/
},
/* 7 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var map = __webpack_require__(0);
/**
* @param {string} str
* @param {Mojisyu} rejectMojisyu
* @return {string}
*/
module.exports = function reject(str, rejectMojisyu) {
if (rejectMojisyu.types.range) {
str = rangeReject(str, rejectMojisyu);
}
if (rejectMojisyu.types.regexpList) {
str = regexpListReject(str, rejectMojisyu);
}
if (rejectMojisyu.types.patterns) {
str = patternReject(str, rejectMojisyu);
}
return str;
};
/**
* @param {string} str
* @param {Mojisyu} rejectMojisyu
* @return {string}
* @private
*/
function rangeReject(str, rejectMojisyu) {
return map.rangeMap(str, rejectMojisyu.props.start, rejectMojisyu.props.end, function (match, str, code) {
if (!match) {
return str;
}
return "";
}).join("");
}
/**
* @param {string} str
* @param {Mojisyu} rejectMojisyu
* @return {string}
* @private
*/
function regexpListReject(str, rejectMojisyu) {
map.regexpMap(str, rejectMojisyu.props.regexp, function (s) {
var i = rejectMojisyu.props.list.indexOf(s);
if (i !== -1) {
str = str.replace(s, "");
}
});
return str;
}
/**
* @param {string} str
* @param {Mojisyu} rejectMojisyu
* @return {string}
* @private
*/
function patternReject(str, rejectMojisyu) {
rejectMojisyu.props.patterns.forEach(function (pattern) {
map.regexpMap(str, pattern[0], function (s) {
str = str.replace(s, "");
});
});
return str;
}
/***/
},
/* 8 */
/***/function (module, exports, __webpack_require__) {
"use strict";
var Moji = __webpack_require__(2);
var defaultMojisyu = __webpack_require__(1);
var Mojisyu = __webpack_require__(3);
var mojisyu = {};
/**
* @param {string} str
* @return {Moji}
*/
function moji(str) {
return new Moji(str, mojisyu);
}
moji.addMojisyu = function (obj) {
Object.keys(obj).forEach(function (m) {
mojisyu[m] = new Mojisyu(m, obj[m]);
});
};
moji.addMojisyu(defaultMojisyu);
/**
* @param {String} str
* @return {Moji}
*/
module.exports = moji;
/***/
}])
);
});
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(12)(module)))
/***/ }),
/* 2 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var assert = __webpack_require__(0);
var moji = __webpack_require__(1);
if (typeof window !== "undefined") {
moji = window.moji;
}
describe("moji.cores", function () {
it("toCharCode", function () {
assert.strictEqual(moji("ABC").toCharCode(), "65|66|67");
});
it("全角英数から半角英数 arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZE", "HE").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("全角英数から半角英数 arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZEtoHE").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("全角スペースを半角スペースに arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZS", "HS").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("全角スペースを半角スペースに arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZStoHS").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角スペースを全角スペースに arm2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HS", "ZS").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角スペースを全角スペースに arm1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HStoZS").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角英数から全角英数 arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HE", "ZE").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角英数から全角英数 arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HEtoZE").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("ひらがなからカタカナ arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HG", "KK").toString(), "ABCD 01234アイウアイウABCD 01234アイウ");
});
it("ひらがなからカタカナ arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HGtoKK").toString(), "ABCD 01234アイウアイウABCD 01234アイウ");
});
it("カタカナからひらがな arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("KK", "HG").toString(), "ABCD 01234あいうあいうABCD 01234アイウ");
});
it("カタカナからひらがな arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("KKtoHG").toString(), "ABCD 01234あいうあいうABCD 01234アイウ");
});
it("全角カナから半角カナ arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZK", "HK").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("全角カナから半角カナ arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("ZKtoHK").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角カナから全角カナ arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HK", "ZK").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("半角カナから全角カナ arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HKtoZK").toString(), "ABCD 01234あいうアイウABCD 01234アイウ");
});
it("複数の文字種を置換 arg2", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HK", "ZK").convert("KK", "HG").toString(), "ABCD 01234あいうあいうABCD 01234あいう");
});
it("複数の文字種を置換 arg1", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").convert("HKtoZK").convert("KKtoHG").toString(), "ABCD 01234あいうあいうABCD 01234あいう");
});
it("filter range", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").filter("HG").toString(), "あいう");
});
it("filter regexp", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").filter("ZK").toString(), "アイウ");
});
it("filter pattern", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").filter("ZS").toString(), " ");
});
it("reject range", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").reject('HG').toString(), "ABCD 01234アイウABCD 01234アイウ");
});
it("reject regexp", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").reject("ZK").toString(), "ABCD 01234あいうABCD 01234アイウ");
});
it("filter pattern", function () {
assert.strictEqual(moji("ABCD 01234あいうアイウABCD 01234アイウ").reject("ZS").toString(), "ABCD01234あいうアイウABCD 01234アイウ");
});
it("addMojisyu", function () {
var o = {
"ADD": { start: 0xff01, end: 0xff5e }
};
moji.addMojisyu(o);
assert.deepEqual(moji()._mojisyu.ADD.name, "ADD");
});
});
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var assert = __webpack_require__(0);
var moji = __webpack_require__(1);
if (typeof window !== "undefined") {
moji = window.moji;
}
describe("moji.str", function () {
it("trim", function () {
assert.strictEqual(moji(" あ あ あ ").string("trim").convert("HG", "KK").toString(), "ア ア ア");
});
it("replace", function () {
assert.strictEqual(moji("あああ").string("replace", "あああ", "いいい").convert("HG", "KK").toString(), "イイイ");
});
it("substr", function () {
assert.strictEqual(moji("abcdefghij").string("substr", 1, 2).toString(), "bc");
});
});
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* globals describe, it */
var assert = __webpack_require__(0);
var Mojisyu = __webpack_require__(7);
var defaultMojisyu = __webpack_require__(6);
describe("Mojisyu", function () {
var mZE = new Mojisyu("ZE", defaultMojisyu.ZE);
var mHS = new Mojisyu("HS", defaultMojisyu.HS);
it("range type", function () {
assert.ok(mZE.types.range, "range");
assert.ok(!mZE.types.regexp, "regexp");
});
it("range property", function () {
assert.ok(mZE.props.start);
assert.ok(mZE.props.end);
assert.ok(!mZE.props.regexp);
});
it("regexp type", function () {
assert.ok(!mHS.types.range, "range");
assert.ok(mHS.types.patterns, "patterns");
});
});
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = {
'ZE': { start: 0xff01, end: 0xff5e }, // 全角英数
'HE': { start: 0x0021, end: 0x007e }, // 半角英数
'HG': { start: 0x3041, end: 0x3096 }, // ひらがな
'KK': { start: 0x30a1, end: 0x30f6 }, // カタカナ
'HS': { patterns: [[/(\s|\u00A0)/g, { "ZS": " " }]] }, // 半角スペース
'ZS': { patterns: [[/(\u3000)/g, { "HS": " " }]] }, //全角スペース
'HK': { regexp: /([\uff66-\uff9c]\uff9e)|([\uff8a-\uff8e]\uff9f)|([\uff61-\uff9f])/g, // 半角カナ
list: ['。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゙', '゚', 'ヺ', 'ヴ', 'ガ', 'ギ', 'グ', 'ゲ', 'ゴ', 'ザ', 'ジ', 'ズ', 'ゼ', 'ゾ', 'ダ', 'ヂ', 'ヅ', 'デ', 'ド', 'バ', 'パ', 'ビ', 'ピ', 'ブ', 'プ', 'ベ', 'ペ', 'ボ', 'ポ', 'ヷ'] },
'ZK': { regexp: /([\u30a1-\u30f6])/g, //全角カナ (半角カナ変換用)
list: ['。', '「', '」', '、', '・', 'ヲ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ャ', 'ュ', 'ョ', 'ッ', 'ー', 'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ', 'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ', 'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ', 'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ン', '゛', '゜', 'ヺ', 'ヴ', 'ガ', 'ギ', '