29 var path = require(
'path');
30 var binding = require(
'../build/Release/binding');
32 var assetsPath = path.resolve(__dirname,
'../build/Release');
33 var getConfigPath =
function (config) {
34 var configPath = config;
35 if (config[0] !==
'/' && config[1] !==
':') {
37 configPath = path.join(assetsPath, config);
49 var
OpenCC = module.exports =
function (config) {
51 config =
'zhs2zht.ini';
53 config = getConfigPath(config);
54 this.handler =
new binding.Opencc(config);
63 OpenCC.CONVERSION_FAST = 0;
70 OpenCC.CONVERSION_SEGMENT_ONLY = 1;
77 OpenCC.CONVERSION_LIST_CANDIDATES = 2;
88 OpenCC.prototype.convert =
function (input, callback) {
89 return this.handler.convert(input.toString(), callback);
101 OpenCC.prototype.convertSync =
function (input) {
102 return this.handler.convertSync(input.toString());
113 OpenCC.prototype.setConversionMode =
function (conversionMode) {
114 return this.handler.setConversionMode(conversionMode);