处理其中一个wiz本地文件，并从中获得 markdown 文件和 图片
@param  {function} callback 回调方法，见https://github.com/caolan/async模块说明
493824
function dealOne(callback) {
  myLog('\n=======================================');

  var index = queue[0].index;

  var allWizArr = queue[0].allWizArr;

  var total = allWizArr.length;

  // 当前的为知笔记相对于queue[0].wizBasePath的相对路径
  var wizRelativePath = allWizArr[index];

  myLog('Begin deal .ziw of %s (%s/%s)', wizRelativePath, index + 1, total);

  // 当前wiz文件原始的文件名，比如test.md.wiz，则其原始文件名为test.md
  var curWizName = path.basename(wizRelativePath, '.ziw');

  // 当前wiz文件的完整路径
  var curWizPath = path.join(queue[0].wizBasePath, wizRelativePath);

  // 当前wiz文件相对于wizBasePath的子目录，解析之后的md文件也要按该目录结构存放
  var curWizSubDir = path.dirname(wizRelativePath);

  // 解析之后的 markdown 文件保存的文件夹目录
  var mdSaveDir = path.join(queue[0].mdBasePath, curWizSubDir);

  // 解析之后的 image 文件相对于解析之后的markdown保存的文件夹目录，用于替换在md文件中的引用
  var imgSaveDirInMdFiles = path.join('images', path.basename(curWizName, '.md'));

  // 解析之后的 image 文件保存的文件夹目录
  var imgSaveDir = path.join(mdSaveDir, imgSaveDirInMdFiles);

  // 开始解压并处理，压缩文件中每一个文件都会触发一次 entry 事件。
  fs.createReadStream(curWizPath)
    .pipe(unzip.Parse())
    .on('entry', function (entry) {
      // 解压之后的其中一个文件名
      var fileName = entry.path;

      myLog('[on entry] deal %s in %s', fileName, curWizPath);

      if (fileName === 'index.html') {
        //entry.pipe(fs.createWriteStream(path.join(unzipPath, wizRelativePath) + '.html')).on('finish',function(tee){
        //  myLog('[on entry][createWriteStream]',wizRelativePath,tee);
        //  var content = fs.readFileSync(path.join(unzipPath, wizRelativePath) + '.html');
        //  content = iconv.decode(content, 'utf16');
        //  myLog(content);
        //});
        entry.pipe(iconv.decodeStream('utf16')).collect(function (errCollect, decodedBody) {

          if (errCollect) {
            console.error('[on entry][collect] ', curWizPath, fileName, errCollect);
            return;
          }

          // 默认的获得的 markdown 内容
          var content = getNewContent(decodedBody, imgSaveDirInMdFiles);

          // 自定义修改content
          if (typeof queue[0].options.contentFn === 'function') {
            var newContent = queue[0].options.contentFn(content);
            if (newContent) {
              myLog('[on entry] contentFn run and return a new content!');
              content = newContent;
            }
          }

          // 创建要保存的文件目录：如果之前不存在，则创建之，且返回已创建的路径；如果已存在则不处理，返回 null。
          var mkdirpMdSaveDir = mkdirp.sync(mdSaveDir);
          if (mkdirpMdSaveDir) {
            myLog('[on entry] mkdirp %s', mkdirpMdSaveDir);
          }

          // md 文件保存的本地路径
          var mdSavePath = path.join(mdSaveDir, curWizName);
          fs.writeFileSync(mdSavePath, content);

          myLog('[on entry] %s saved!', mdSavePath);

        });

      } else if (['.jpg', '.png', '.gif'].indexOf(path.extname(fileName).toLowerCase()) > -1) {
        // xx/testimg.md.ziw/index_files/a.jpg 修改为 xx/images/testimg/a.jpg

        // 创建要保存的文件目录：如果之前不存在，则创建之，且返回已创建的路径；如果已存在则不处理，返回 null。
        var mkdirpImgSaveDir = mkdirp.sync(imgSaveDir);
        if (mkdirpImgSaveDir) {
          myLog('[on entry] mkdirp %s', mkdirpImgSaveDir);
        }

        // img 文件保存的本地路径
        var imgSavePath = path.join(imgSaveDir, path.basename(fileName));

        entry.pipe(fs.createWriteStream(imgSavePath)).on('finish', function () {
          myLog('[on entry] %s saved!', imgSavePath);
        });

      } else {
        myLog('[on entry] Ignore %s, because we do not care it', fileName);

        entry.autodrain();

      }

    })
    .on('close', function () {
      // see https://nodejs.org/api/stream.html#stream_event_close
      myLog('End deal .ziw of %s (%s/%s)', wizRelativePath, index + 1, total);
      myLog('=======================================');

      queue[0].index++;
      callback();
    });
}
958732
function(path, callback, opts) {

		if (!callback) callback = function() { };

		var fallbacks = [];
		if (path.each) {
			if (path.length==0) return;
			fallbacks = path;
			path      = fallbacks.shift()+"";
		}

		//Stuff that will make us not want to load files.
		if (this.failedFiles.contains(path)) return;

		opts = opts || {};
		var file = this.worldPath+path+'.js';
		if (opts.rootPath) file = path+'.js';

		var my = this;
		var err;
		var handleData = function(e,raw) {
			data = false;
			if (!raw) {
				err = e;
				my.failedFiles.push(path);
				/* Continue down our list of fallbacks. */
				if (fallbacks.length>0) {
					my.loadFile(fallbacks, callback, opts);
				} else {
					log_error("File not found: "+file);
				}
			} else {
				try { eval('data='+raw); }
				catch (e) { log_error(e); }
			} callback(err, data);
			return data;
		};

		if (opts.sync) {
			try {
				var data = fs.readFileSync(file);
			} catch (e) {
				this.failedFiles.push(path);
				/* Continue down our list of fallbacks. */
				if (fallbacks.length>0) {
					return this.loadFile(fallbacks, callback, opts);
				} else return e;
			} return handleData(false,data);
		} else {
			fs.readFile(file, handleData);
		}
	}
330330
public void asyncPut(final byte[] data, final String key, final String token, StringMap params,
                         String mime, boolean checkCrc, UpCompletionHandler handler) throws IOException {
        checkArgs(key, data, null, token);
        if (mime == null) {
            mime = Client.DefaultMime;
        }
        params = filterParam(params);
        new FormUploader(client, token, key, data, params, mime, checkCrc, configuration).asyncUpload(handler);
    }
668005
function _readFile(fileName, callback) {
    fs.readFile(fileName, "utf8", function (err, data) {
        var content = "";
        if (!err) {
            content = data;
        }
        callback.apply(null, [fileName, content]);
    });
}
624509
function(file, callback) {
		var that = this;
		
		this.png_encode.encode(this, function (data) {
			var fd = that.fs.openSync(file, 'w');
			for(var i = 0; i < data.length; i++) {
				that.fs.writeSync(fd, data[i], 0, data[i].length);
			}
			that.fs.closeSync(fd);
			
			if(callback) {
				callback.call(that);
			}
		});
	}
979896
function(callback) {
    //process first all directories and then all files.
    async.mapSeries(['getDirectories', 'getFiles'], (nodeSource, cbMap) => {
      syncDb[nodeSource]((err, nodes) => {
        async.eachSeries(nodes, (node, cb) => {

          // If a node has to be redownloaded do not delete it remotely
          // See: https://github.com/gyselroth/balloon-node-sync/issues/17
          if(node.downloadOriginal) return cb();

          var nodePath = utility.joinPath(node.parent, node.name);

          process.nextTick(() => {
            var nodePath = utility.joinPath(node.parent, node.name);

            if(fsWrap.existsSync(nodePath) === false) {
              //Node doesn't exist localy -> delete it remotely
              deleteNode(node, false, cb);
            } else {
              try {
                var stat = fsWrap.lstatSync(nodePath);
              } catch(e) {
                logger.warning('findDeletedNodes got lstat error on node', {category: 'sync-local-delta', nodePath, code: e.code});
                throw new BlnDeltaError(e.message);
              }

              if(stat.ino === node.ino) {
                //node still exists at given path
                return cb();
              } else {
                deleteNode(node, true, cb);
              }
            }
          });
        }, cbMap);
      });
    }, callback);
  }
968508
function asyncLoadJs(src) {
  if (!isBrowser()) {
    _logger2.default.error({
      description: 'Document does not exsist to load assets into.',
      func: 'asyncLoadJs', obj: 'dom'
    });
    throw new Error('Document object is required to load assets.');
  }
  var js = window.document.createElement('script');
  js.src = src;
  js.type = 'text/javascript';
  window.document.getElementsByTagName('head')[0].appendChild(js);
  _logger2.default.log({
    description: 'JS was loaded into document.', element: js,
    func: 'asyncLoadJs', obj: 'dom'
  });
  return new Promise(function (resolve) {
    window.setTimeout(resolve, 200);
  });
}
721970
function (callback) {
    return function (err, stdout, stderr) {
        if (err) {
            throw err;
        } else if (stderr) {
            log('sync error', 'failed with the following output:');
            console.log('\n', stderr, '\n');
        } else {
            log('sync', 'completed successfully');
            log();
            if (callback) callback();
        }
    };
}
1327769
function (callback) {
					if (!handlebarsMatcher.test(file)) {
						return callback();
					}

					render(file, metadata, function (err, res) {
						if (err) return callback(err);
						// safety check to prevent file deletion in case filename doesn't change
						if (file === res) return callback();
						// safety check to prevent overwriting another file
						if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);

						// add entry for interpolated file name
						files[res] = files[file];
						// delete entry for template file name
						delete files[file];
						callback();
					});
				}
133190
function whenDocumentReady( callback ) {
   return new Promise( ( resolve, reject ) => {
      function ready() {
         try {
            resolve( callback() );
         }
         catch( err ) {
            reject( err );
         }
      }

      if( document.readyState === 'complete' || document.readyState === 'interactive' ) {
         ready();
      }
      else {
         document.addEventListener( 'DOMContentLoaded', ready );
      }
   } );
}
1258521
function(callback) {
            if(typeof opts !== "object") return callback();

            defOpts = Object.merge(defOpts, opts);
            for(var key in defOpts) {
                if(!defOpts.hasOwnProperty(key)) continue;
                switch(key) {
                case "mkdir": header.mkdir = defOpts.mkdir; break;
                case "md5": {
                    if(!md5) break;
                    if(typeof defOpts.md5 === "string" && 32 === defOpts.md5.length) {
                        header["content-md5"] = defOpts.md5;
                        break;
                    }
                    header["content-md5"] = md5(rawData);
                    break;
                }
                case "secret": header["content-secret"] = defOpts.secret; break;
                case "mime": header["content-type"] = defOpts.mime; break;
                default: break;
                }
            }

            callback();
        }
1204180
function _addReadCallbacks(filename, cache) {
  const callbacks = new Set();
  cache.set(filename, true);
  readFileCallbacks.set(filename, callbacks);
  return callbacks;
}
1140387
function astFromSource(options, source, extension, cb) {
  if (typeof cb === 'undefined') {
    cb = extension;
    extension = null;
  }
  pegParser(options, extension, function (err, parser, key) {
    if (err) {
      return cb(err);
    }
    var ast;
    try {
      ast = parser.parse(source);
      addLineNumbers(ast, source);
      if (ast.type === 'program') {
        ast.type = 'script';
      } else if (ast.type === 'markdown') {
        ast.content = source;
      }
      ast.grammarFile = key;
      // adding in comment nodes, in case they get added to the grammar later
      walk(ast, function (node) {
        if (!node.comments && node.type !== 'undefined') {
          node.comments = [];
        }
      });
      //console.log(JSON.stringify(ast, null, 2));
    } catch (e) {
      return cb(e);
    }
    return cb(null, ast);
  });
}
1149134
function(callback) {
      var asyncFunctions = [];

      for (var i = 0; i < numberOfRows; i++) {
        var rowsImagesPaths = imagesPaths.slice(i * numberOfColumns, i * numberOfColumns + numberOfColumns);
        var lineWidth = width;
        var lineHeight = height;
        var linePath = path.join(temporaryDirectoryPath, 'line-' + i);

        linesPaths.push(linePath);
        asyncFunctions.push(createLine(rowsImagesPaths, linePath, lineWidth, lineHeight, true, 100));
      }

      async.parallel(asyncFunctions, function(error, results) {
        if (error) return callback(error);

        results.forEach(function(line) {
          line.forEach(function(image) {
            if (image.image === path.join(temporaryDirectoryPath, 'transparent.png')) return;

            var spritePathChunks = path.parse(image.sprite).name.match(/-([0-9]+)$/);
            var lineIndex = (spritePathChunks && parseInt(spritePathChunks[1])) || 0;

            image.y = image.y + (lineIndex * height);
            image.sprite = destinationPath;
            images.push(image);
          });
        });

        callback();
      });
    }
661451
function ReadFile(path, callback) {
    if (typeof callback === "function") {
        return Fs.readFile(path, ENCODING, callback);
    }
    return Fs.readFileSync(path, ENCODING);
}
20485
function contentLoaded(callback) {
    var addEventListener = doc['addEventListener'];
    var done = false, top = true,
        add = addEventListener ? 'addEventListener' : 'attachEvent',
        rem = addEventListener ? 'removeEventListener' : 'detachEvent',
        pre = addEventListener ? '' : 'on',

        init = function(e) {
          if (e.type == 'readystatechange' && doc.readyState != 'complete') {
            return;
          }
          (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
          if (!done && (done = true)) { callback.call(win, e.type || e); }
        },

        poll = function() {
          try {
            root.doScroll('left');
          } catch(e) {
            win.setTimeout(poll, 50);
            return;
          }
          init('poll');
        };

    if (doc.readyState == 'complete') {
      callback.call(win, 'lazy');
    } else {
      if (doc.createEventObject && root.doScroll) {
        try { top = !win.frameElement; } catch(e) { }
        if (top) { poll(); }
      }
      doc[add](pre + 'DOMContentLoaded', init, false);
      doc[add](pre + 'readystatechange', init, false);
      win[add](pre + 'load', init, false);
    }
  }
824457
function createDocumentLoader(promise) {
    return function(url, callback) {
      promise(url).then(
        // success
        function(remoteDocument) {
          callback(null, remoteDocument);
        },
        // failure
        callback
      );
    };
  }