# Code coverage report for pinyin/web-pinyin.js

## Statements: 93.33% (14 / 15) Branches: 50% (1 / 2) Functions: 100% (1 / 1) Lines: 93.33% (14 / 15) Ignored: none

All files » pinyin/ » web-pinyin.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30

    1
    1
    1

    1
    1542
    1542
    3500
    3500
    3500

    1

    1
    1
    1

    1

    // 解压拼音库。
    // @param {Object} dict_combo, 压缩的拼音库。
    // @param {Object} 解压的拼音库。
    function buildPinyinCache(dict_combo){
      var hans;
      var uncomboed = {};

      for(var py in dict_combo){
        hans = dict_combo[py];
        for(var i = 0, han, l = hans.length; i < l; i++){
          han = hans.charCodeAt(i);
          Eif(!uncomboed.hasOwnProperty(han)){
            uncomboed[han] = py;
          }else{
            uncomboed[han] += "," + py;
          }
        }
      }

      return uncomboed;
    }

    var PINYIN_DICT = buildPinyinCache(require("./data/dict-zi-web"));
    var pinyin = require("./src/pinyin");
    pinyin.setDict(PINYIN_DICT);

    module.exports = pinyin;