Comparing version 1.0.63 to 1.0.64
@@ -48,2 +48,7 @@ // Generated by dts-bundle v0.7.3 | ||
export const REGEXP_TEST: RegExp; | ||
export const SAFE_MODE_CHAR: string[]; | ||
export function getOptionsSkip(options: IOptions, skip?: string[]): IOptions; | ||
export function getOptions(options?: IOptions, defaultOpts?: Readonly<{ | ||
safe: boolean; | ||
}>, skip?: string[]): IOptions; | ||
export function _call(fn: any, text: string, options?: IOptions, ...argv: any[]): any; | ||
@@ -50,0 +55,0 @@ export interface ITable { |
@@ -23,2 +23,7 @@ /** | ||
export declare const REGEXP_TEST: RegExp; | ||
export declare const SAFE_MODE_CHAR: string[]; | ||
export declare function getOptionsSkip(options: IOptions, skip?: string[]): IOptions; | ||
export declare function getOptions(options?: IOptions, defaultOpts?: Readonly<{ | ||
safe: boolean; | ||
}>, skip?: string[]): IOptions; | ||
export declare function _call(fn: any, text: string, options?: IOptions, ...argv: any[]): any; | ||
@@ -25,0 +30,0 @@ export interface ITable { |
@@ -117,26 +117,36 @@ "use strict"; | ||
exports.REGEXP_TEST = /[\u4E00-\u9FFF]/g; | ||
const SAFE_MODE_CHAR = [ | ||
exports.SAFE_MODE_CHAR = [ | ||
'后', | ||
'里', | ||
]; | ||
function _call(fn, text, options = {}, ...argv) { | ||
options = Object.assign({}, exports.defaultOptions, options); | ||
function getOptionsSkip(options, skip = exports.SAFE_MODE_CHAR) { | ||
if (!options.skip) { | ||
options.skip = skip.slice(); | ||
} | ||
else if (typeof options.skip == 'string') { | ||
options.skip += skip.join(''); | ||
} | ||
else if (Array.isArray(options.skip)) { | ||
options.skip = options.skip.slice().concat(skip); | ||
} | ||
else { | ||
options.table = skip.reduce(function (a, b) { | ||
a[b] = b; | ||
return a; | ||
}, Object.assign({}, options.table || {})); | ||
} | ||
return options; | ||
} | ||
exports.getOptionsSkip = getOptionsSkip; | ||
function getOptions(options = {}, defaultOpts = exports.defaultOptions, skip = exports.SAFE_MODE_CHAR) { | ||
options = Object.assign({}, defaultOpts, options); | ||
if (options.safe) { | ||
if (!options.skip) { | ||
options.skip = SAFE_MODE_CHAR.slice(); | ||
} | ||
else if (typeof options.skip == 'string') { | ||
options.skip += '后'; | ||
} | ||
else if (Array.isArray(options.skip)) { | ||
options.skip = options.skip.concat(SAFE_MODE_CHAR); | ||
} | ||
else { | ||
options.table = SAFE_MODE_CHAR.reduce(function (a, b) { | ||
a[b] = b; | ||
return a; | ||
}, options.table || {}); | ||
} | ||
options = getOptionsSkip(options, skip); | ||
//console.log(options); | ||
} | ||
return options; | ||
} | ||
exports.getOptions = getOptions; | ||
function _call(fn, text, options = {}, ...argv) { | ||
options = getOptions(options); | ||
if (options.skip || options.table || options.tableOnly) { | ||
@@ -143,0 +153,0 @@ let { skip, table, tableOnly } = options; |
@@ -163,3 +163,3 @@ /** | ||
const SAFE_MODE_CHAR = [ | ||
export const SAFE_MODE_CHAR = [ | ||
'后', | ||
@@ -169,33 +169,47 @@ '里', | ||
export function _call(fn, text: string, options: IOptions = {}, ...argv) | ||
export function getOptionsSkip(options: IOptions, skip = SAFE_MODE_CHAR) | ||
{ | ||
options = Object.assign({}, defaultOptions, options); | ||
if (!options.skip) | ||
{ | ||
options.skip = skip.slice(); | ||
} | ||
else if (typeof options.skip == 'string') | ||
{ | ||
options.skip += skip.join(''); | ||
} | ||
else if (Array.isArray(options.skip)) | ||
{ | ||
options.skip = options.skip.slice().concat(skip); | ||
} | ||
else | ||
{ | ||
options.table = skip.reduce(function (a, b) | ||
{ | ||
a[b] = b; | ||
return a; | ||
}, Object.assign({}, options.table || {})); | ||
} | ||
return options; | ||
} | ||
export function getOptions(options: IOptions = {}, defaultOpts = defaultOptions, skip = SAFE_MODE_CHAR) | ||
{ | ||
options = Object.assign({}, defaultOpts, options); | ||
if (options.safe) | ||
{ | ||
if (!options.skip) | ||
{ | ||
options.skip = SAFE_MODE_CHAR.slice(); | ||
} | ||
else if (typeof options.skip == 'string') | ||
{ | ||
options.skip += '后'; | ||
} | ||
else if (Array.isArray(options.skip)) | ||
{ | ||
options.skip = options.skip.concat(SAFE_MODE_CHAR); | ||
} | ||
else | ||
{ | ||
options.table = SAFE_MODE_CHAR.reduce(function (a, b) | ||
{ | ||
a[b] = b; | ||
options = getOptionsSkip(options, skip); | ||
return a; | ||
}, options.table || {}); | ||
} | ||
//console.log(options); | ||
} | ||
return options; | ||
} | ||
export function _call(fn, text: string, options: IOptions = {}, ...argv) | ||
{ | ||
options = getOptions(options); | ||
if (options.skip || options.table || options.tableOnly) | ||
@@ -202,0 +216,0 @@ { |
@@ -8,2 +8,3 @@ /** | ||
export { tableTw2CnDebug, tableCn2TwDebug }; | ||
export declare const SAFE_MODE_CHAR: string[]; | ||
/** | ||
@@ -10,0 +11,0 @@ * 以不造成歧異的字典表來取代 |
@@ -11,2 +11,7 @@ "use strict"; | ||
const index_1 = require("./index"); | ||
exports.SAFE_MODE_CHAR = index_1.SAFE_MODE_CHAR | ||
.slice() | ||
.concat([ | ||
'忧', | ||
]); | ||
/** | ||
@@ -32,2 +37,3 @@ * 以不造成歧異的字典表來取代 | ||
options.tableOnly = options.tableOnly !== false; | ||
options = index_1.getOptions(options, index_1.defaultOptions, exports.SAFE_MODE_CHAR); | ||
return options; | ||
@@ -37,3 +43,3 @@ } | ||
/* | ||
let msg = `并且之后在深海変異成亚种的半人鱼。顺便说一句,当时人鱼国的守护神《海之神》特里斯坦,发现在神代时代时被自己封印的宿敌复活了。`; | ||
let msg = `并且之后在深海変異成亚种的半人鱼。顺便说一句,当时人鱼国的守护神《海之神》特里斯坦,发现在神代时代时被自己封印的宿敌复活了忧。`; | ||
@@ -45,3 +51,3 @@ console.log(1, cn2tw(msg, { | ||
console.log(2, cn2tw_min(msg, { | ||
safe: false, | ||
//safe: false, | ||
})); | ||
@@ -48,0 +54,0 @@ */ |
@@ -7,6 +7,13 @@ /** | ||
import * as tableCn2TwDebug from '../../../build/zh/convert/table_cn2tw.debug.json'; | ||
import { tw2cn, cn2tw, IOptions, defaultOptions, ITable } from './index'; | ||
import { tw2cn, cn2tw, IOptions, defaultOptions, ITable, getOptions, getOptionsSkip, SAFE_MODE_CHAR as _SAFE_MODE_CHAR } from './index'; | ||
export { tableTw2CnDebug, tableCn2TwDebug } | ||
export const SAFE_MODE_CHAR = _SAFE_MODE_CHAR | ||
.slice() | ||
.concat([ | ||
'忧', | ||
]) | ||
; | ||
/** | ||
@@ -38,2 +45,4 @@ * 以不造成歧異的字典表來取代 | ||
options = getOptions(options, defaultOptions, SAFE_MODE_CHAR); | ||
return options; | ||
@@ -43,3 +52,3 @@ } | ||
/* | ||
let msg = `并且之后在深海変異成亚种的半人鱼。顺便说一句,当时人鱼国的守护神《海之神》特里斯坦,发现在神代时代时被自己封印的宿敌复活了。`; | ||
let msg = `并且之后在深海変異成亚种的半人鱼。顺便说一句,当时人鱼国的守护神《海之神》特里斯坦,发现在神代时代时被自己封印的宿敌复活了忧。`; | ||
@@ -51,3 +60,3 @@ console.log(1, cn2tw(msg, { | ||
console.log(2, cn2tw_min(msg, { | ||
safe: false, | ||
//safe: false, | ||
})); | ||
@@ -54,0 +63,0 @@ */ |
{ | ||
"name": "cjk-conv", | ||
"version": "1.0.63", | ||
"version": "1.0.64", | ||
"description": "convert chinese, japanese 簡繁日漢字轉換 ( merge/split submodule from node-novel, regexp-cjk, str-util )", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
695934
51355