3 * Example of Node.js API.
8 * Copyright 2010-2013 BYVoid <byvoid@byvoid.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * @example node/demo.js
25 * This is an example of how to use the Node.js API.
28 // In your project you should replace './opencc' with 'opencc'
29 var OpenCC = require('./opencc');
31 // Load the default Simplified to Traditional config
32 var opencc = new OpenCC('zhs2zht.ini');
34 // Set conversion mode
35 opencc.setConversionMode(OpenCC.CONVERSION_FAST);
38 var converted = opencc.convertSync("汉字");
39 console.log(converted);
42 opencc.convert("汉字", function (err, converted) {
43 console.log(converted);