11.2.2 gb18030 encoder 
@constructor
@implements {Encoder}
@param {{fatal: boolean}} options
@param {boolean=} gbk_flag
192628
function GB18030Encoder(options, gbk_flag) {
    var fatal = options.fatal;
    // gb18030's decoder has an associated gbk flag (initially unset).
    /**
     * @param {Stream} stream Input stream.
     * @param {number} code_point Next code point read from the stream.
     * @return {(number|!Array.<number>)} Byte(s) to emit.
     */
    this.handler = function(stream, code_point) {
      // 1. If code point is end-of-stream, return finished.
      if (code_point === end_of_stream)
        return finished;

      // 2. If code point is an ASCII code point, return a byte whose
      // value is code point.
      if (isASCIICodePoint(code_point))
        return code_point;

      // 3. If code point is U+E5E5, return error with code point.
      if (code_point === 0xE5E5)
        return encoderError(code_point);

      // 4. If the gbk flag is set and code point is U+20AC, return
      // byte 0x80.
      if (gbk_flag && code_point === 0x20AC)
        return 0x80;

      // 5. Let pointer be the index pointer for code point in index
      // gb18030.
      var pointer = indexPointerFor(code_point, index('gb18030'));

      // 6. If pointer is not null, run these substeps:
      if (pointer !== null) {

        // 1. Let lead be floor(pointer / 190) + 0x81.
        var lead = floor(pointer / 190) + 0x81;

        // 2. Let trail be pointer % 190.
        var trail = pointer % 190;

        // 3. Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise.
        var offset = trail < 0x3F ? 0x40 : 0x41;

        // 4. Return two bytes whose values are lead and trail + offset.
        return [lead, trail + offset];
      }

      // 7. If gbk flag is set, return error with code point.
      if (gbk_flag)
        return encoderError(code_point);

      // 8. Set pointer to the index gb18030 ranges pointer for code
      // point.
      pointer = indexGB18030RangesPointerFor(code_point);

      // 9. Let byte1 be floor(pointer / 10 / 126 / 10).
      var byte1 = floor(pointer / 10 / 126 / 10);

      // 10. Set pointer to pointer − byte1 × 10 × 126 × 10.
      pointer = pointer - byte1 * 10 * 126 * 10;

      // 11. Let byte2 be floor(pointer / 10 / 126).
      var byte2 = floor(pointer / 10 / 126);

      // 12. Set pointer to pointer − byte2 × 10 × 126.
      pointer = pointer - byte2 * 10 * 126;

      // 13. Let byte3 be floor(pointer / 10).
      var byte3 = floor(pointer / 10);

      // 14. Let byte4 be pointer − byte3 × 10.
      var byte4 = pointer - byte3 * 10;

      // 15. Return four bytes whose values are byte1 + 0x81, byte2 +
      // 0x30, byte3 + 0x81, byte4 + 0x30.
      return [byte1 + 0x81,
              byte2 + 0x30,
              byte3 + 0x81,
              byte4 + 0x30];
    };
  }
1016257
function compile (extension, content, options, fn) {
    // allow optional options argument
    if (_.isFunction(options)) {
      fn = options;
      options = {};
    }

    var config = _.clone(compile.configuration)
      , args = flags.slice(0)
      , buffer = ''
      , errors = ''
      , compressor;

    if (compile.configuration.type) {
      config.type = extension;
    }

    // generate the --key value options, both the key and the value should added
    // seperately to the `args` array or the child_process will chocke.
    Object.keys(config).filter(function filter (option) {
      return config[option];
    }).forEach(function format (option) {
      var bool = _.isBoolean(config[option]);

      if (!bool || config[option]) {
        args.push('--' + option);
        if (!bool) args.push(config[option]);
      }
    });

    // apply the configuration
    _.extend(config, options);

    // spawn the shit and set the correct encoding
    compressor = spawn(type, args);
    compressor.stdout.setEncoding('utf8');
    compressor.stderr.setEncoding('utf8');

    /**
     * Buffer up the results so we can concat them once the compression is
     * finished.
     *
     * @param {Buffer} chunk
     * @api private
     */

    compressor.stdout.on('data', function data (chunk) {
      buffer += chunk;
    });

    compressor.stderr.on('data', function data (err) {
      errors += err;
    });

    /**
     * The compressor has finished can we now process the data and see if it was
     * a success.
     *
     * @param {Number} code
     * @api private
     */

    compressor.on('close', function close (code) {
      // invalid states
      if (errors.length) return fn(new Error(errors));
      if (code !== 0) return fn(new Error('process exited with code ' + code));
      if (!buffer.length) return fn(new Error('no data returned ' + type + args));

      // correctly processed the data
      fn(null, buffer);
    });

    // write out the content that needs to be minified
    compressor.stdin.end(content);
  }
491311
function VK(options, redirectUri, code, token) {
    EventEmitter.call(self);
    self = this;
    if (options === undefined)
        throw 'No options passed to constructor';
    if (options.appID === undefined || options.appSecret === undefined)
        throw 'Wrong options';
    if (options.mode === 'undefined' || !(options.mode === 'oauth' || options.mode === 'sig'))
        options.mode = 'oauth';
    self.options = options;
    self.code = code || '';
    self.token = token || '';
    self.redirectUri = redirectUri || 'http://localhost';
    self.userId = 0;
}
1365407
function Big5Encoder(options) {
    var fatal = options.fatal;
    /**
     * @param {Stream} stream Input stream.
     * @param {number} code_point Next code point read from the stream.
     * @return {(number|!Array.<number>)} Byte(s) to emit.
     */
    this.handler = function(stream, code_point) {
      // 1. If code point is end-of-stream, return finished.
      if (code_point === end_of_stream)
        return finished;

      // 2. If code point is an ASCII code point, return a byte whose
      // value is code point.
      if (isASCIICodePoint(code_point))
        return code_point;

      // 3. Let pointer be the index big5 pointer for code point.
      var pointer = indexBig5PointerFor(code_point);

      // 4. If pointer is null, return error with code point.
      if (pointer === null)
        return encoderError(code_point);

      // 5. Let lead be floor(pointer / 157) + 0x81.
      var lead = floor(pointer / 157) + 0x81;

      // 6. If lead is less than 0xA1, return error with code point.
      if (lead < 0xA1)
        return encoderError(code_point);

      // 7. Let trail be pointer % 157.
      var trail = pointer % 157;

      // 8. Let offset be 0x40 if trail is less than 0x3F and 0x62
      // otherwise.
      var offset = trail < 0x3F ? 0x40 : 0x62;

      // Return two bytes whose values are lead and trail + offset.
      return [lead, trail + offset];
    };
  }
332297
function init(options) {
  var debug = require('../debug').spawn('init');

  function sourceMapInit(file, encoding, callback) {
    // pass through if file is null or already has a source map
    if (file.isNull() || file.sourceMap) {
      this.push(file);
      return callback();
    }

    if (file.isStream()) {
      return callback(new Error(utils.PLUGIN_NAME + '-init: Streaming not supported'));
    }

    if (options === undefined) {
      options = {};
    }
    debug(function() {
      return options;
    });

    var fileContent = file.contents.toString();
    var sourceMap, preExistingComment;
    var internals = initInternals(options, file, fileContent);

    if (options.loadMaps) {
      var result = internals.loadMaps();
      sourceMap = result.map;
      fileContent = result.content;
      preExistingComment = result.preExistingComment;
    }

    if (!sourceMap && options.identityMap) {
      debug(function() { return '**identityMap option is deprecated, update to use sourcemap.identityMap stream**'; });
      debug(function() {
        return 'identityMap';
      });
      var fileType = path.extname(file.path);
      var source = unixStylePath(file.relative);
      var generator = new SourceMapGenerator({ file: source });

      if (fileType === '.js') {
        var tokenizer = acorn.tokenizer(fileContent, { locations: true });
        while (true) {
          var token = tokenizer.getToken();
          if (token.type.label === 'eof') {
            break;
          }
          var mapping = {
            original: token.loc.start,
            generated: token.loc.start,
            source: source,
          };
          if (token.type.label === 'name') {
            mapping.name = token.value;
          }
          generator.addMapping(mapping);
        }
        generator.setSourceContent(source, fileContent);
        sourceMap = generator.toJSON();
      } else if (fileType === '.css') {
        debug('css');
        var ast = css.parse(fileContent, { silent: true });
        debug(function() {
          return ast;
        });
        var registerTokens = function(ast) {
          if (ast.position) {
            generator.addMapping({ original: ast.position.start, generated: ast.position.start, source: source });
          }

          function logAst(key, ast) {
            debug(function() {
              return 'key: ' + key;
            });
            debug(function() {
              return ast[key];
            });
          }

          for (var key in ast) {
            logAst(key, ast);
            if (key !== 'position') {
              if (Object.prototype.toString.call(ast[key]) === '[object Object]') {
                registerTokens(ast[key]);
              } else if (Array.isArray(ast[key])) {
                debug(function() {
                  return '@@@@ ast[key] isArray @@@@';
                });
                for (var i = 0; i < ast[key].length; i++) {
                  registerTokens(ast[key][i]);
                }
              }
            }
          }
        };
        registerTokens(ast);
        generator.setSourceContent(source, fileContent);
        sourceMap = generator.toJSON();
      }
    }

    if (!sourceMap) {
      // Make an empty source map
      sourceMap = {
        version: 3,
        names: [],
        mappings: '',
        sources: [unixStylePath(file.relative)],
        sourcesContent: [fileContent],
      };
    } else if (preExistingComment !== null && typeof preExistingComment !== 'undefined') {
      sourceMap.preExistingComment = preExistingComment;
    }

    sourceMap.file = unixStylePath(file.relative);
    file.sourceMap = sourceMap;

    this.push(file);
    callback();
  }

  return through.obj(sourceMapInit);
}
339011
function BaseN(options) {

    var self = this;
    var opt = options || {};

    // assert
    if (opt.max && opt.length) {
        throw new Error('cannot specify both max and length');
    }

    // merge in default options
    for (var key in DEFAULT_OPTIONS) {
        if (!opt.hasOwnProperty(key)) {
            opt[key] = DEFAULT_OPTIONS[key];
        }
    }

    /**
     * a string of all allowed characters used for encoding/decoding.
     * @type {String}
     */
    self.characters = opt.characters;

    /**
     * number of unique characters used to encode ids.
     * @type {Number}
     */
    self.base = opt.base || opt.characters.length;

    /**
     * max length of id string.
     * @type {Number}
     */
    self.length = opt.length || self._findLength(opt.max);
}
1106634
function validateEncoding(encoding) {
		if (encoding === null || encoding === 'buffer' || Buffer.isEncoding(encoding)) {
			return true;
		}
		throw new TypeError('Unknown encoding: ' + encoding);
	}
966628
function generateKey(options) {
  // Options
  options = _.extend({
    length: 32,
    name: '',
    symbols: false,
    google: false,
    qrCode: false,
    type: 'base32'
  }, options || {});

  // Generate the random string
  var key = randomString(options);

  if (options.type === 'ascii') {
    return key;
  } else if (options.type === 'base32') {
    // Encode the ascii string into base32 and remove any `=` signs which google
    // doesn't like
    key = base32.encode(key).toString().replace(/=/g, '');

    return key;
  } else {
    throw new Error('InvalidKeyType');
  }
}
1127344
function Atok (options) {
  if (!(this instanceof Atok))
    return new Atok(options)

  // Possible events are defined at instanciation for better performance
  EV.call(this, Atok.events)
  this.writable = true
  this.readable = true

  // Options
  options = options || {}
  this._encoding = null
  if (options.encoding) this.setEncoding( options.encoding )

  // Initializations
  // Debug flag
  this.debugMode = false

  // Status flags
  this.ended = false        // Flag indicating stream has ended
  this.ending = false       // Set when end() invokes write()
  this.paused = false       // Flag indicating stream is paused
  this.needDrain = false    // Flag indicating stream needs drain

//var keepRules = false
//include("Atok_properties.js")

//include("Atok_rule_properties.js")


  this._defaultProps = Object.keys(this)
    .filter(function (prop) {
      return /^_p_/.test(prop) && !/(continueOnFail|nextIndex)$/.test(prop)
    })
    .map(function (prop) {
      return prop.substr(3)
    })
}
411946
function EUCKRDecoder(options) {
    var fatal = options.fatal;

    // euc-kr's decoder has an associated euc-kr lead (initially 0x00).
    var /** @type {number} */ euckr_lead = 0x00;
    /**
     * @param {Stream} stream The stream of bytes being decoded.
     * @param {number} bite The next byte read from the stream.
     * @return {?(number|!Array.<number>)} The next code point(s)
     *     decoded, or null if not enough data exists in the input
     *     stream to decode a complete code point.
     */
    this.handler = function(stream, bite) {
      // 1. If byte is end-of-stream and euc-kr lead is not 0x00, set
      // euc-kr lead to 0x00 and return error.
      if (bite === end_of_stream && euckr_lead !== 0) {
        euckr_lead = 0x00;
        return decoderError(fatal);
      }

      // 2. If byte is end-of-stream and euc-kr lead is 0x00, return
      // finished.
      if (bite === end_of_stream && euckr_lead === 0)
        return finished;

      // 3. If euc-kr lead is not 0x00, let lead be euc-kr lead, let
      // pointer be null, set euc-kr lead to 0x00, and then run these
      // substeps:
      if (euckr_lead !== 0x00) {
        var lead = euckr_lead;
        var pointer = null;
        euckr_lead = 0x00;

        // 1. If byte is in the range 0x41 to 0xFE, set pointer to
        // (lead − 0x81) × 190 + (byte − 0x41).
        if (inRange(bite, 0x41, 0xFE))
          pointer = (lead - 0x81) * 190 + (bite - 0x41);

        // 2. Let code point be null, if pointer is null, and the
        // index code point for pointer in index euc-kr otherwise.
        var code_point = (pointer === null)
              ? null : indexCodePointFor(pointer, index('euc-kr'));

        // 3. If code point is null and byte is an ASCII byte, prepend
        // byte to stream.
        if (pointer === null && isASCIIByte(bite))
          stream.prepend(bite);

        // 4. If code point is null, return error.
        if (code_point === null)
          return decoderError(fatal);

        // 5. Return a code point whose value is code point.
        return code_point;
      }

      // 4. If byte is an ASCII byte, return a code point whose value
      // is byte.
      if (isASCIIByte(bite))
        return bite;

      // 5. If byte is in the range 0x81 to 0xFE, set euc-kr lead to
      // byte and return continue.
      if (inRange(bite, 0x81, 0xFE)) {
        euckr_lead = bite;
        return null;
      }

      // 6. Return error.
      return decoderError(fatal);
    };
  }
158997
function Utf16Encoder(options, codec) {
    options = options || {};
    if (options.addBOM === undefined)
        options.addBOM = true;
    this.encoder = codec.iconv.getEncoder('utf-16le', options);
}
1011838
function HZGB2312Decoder(options) {
  var fatal = options.fatal;
  var /** @type {boolean} */ hzgb2312 = false,
      /** @type {number} */ hzgb2312_lead = 0x00;
  /**
   * @param {ByteInputStream} byte_pointer The byte stream to decode.
   * @return {?number} The next code point decoded, or null if not enough
   *     data exists in the input stream to decode a complete code point.
   */
  this.decode = function(byte_pointer) {
    var bite = byte_pointer.get();
    if (bite === EOF_byte && hzgb2312_lead === 0x00) {
      return EOF_code_point;
    }
    if (bite === EOF_byte && hzgb2312_lead !== 0x00) {
      hzgb2312_lead = 0x00;
      return decoderError(fatal);
    }
    byte_pointer.offset(1);
    if (hzgb2312_lead === 0x7E) {
      hzgb2312_lead = 0x00;
      if (bite === 0x7B) {
        hzgb2312 = true;
        return null;
      }
      if (bite === 0x7D) {
        hzgb2312 = false;
        return null;
      }
      if (bite === 0x7E) {
        return 0x007E;
      }
      if (bite === 0x0A) {
        return null;
      }
      byte_pointer.offset(-1);
      return decoderError(fatal);
    }
    if (hzgb2312_lead !== 0x00) {
      var lead = hzgb2312_lead;
      hzgb2312_lead = 0x00;
      var code_point = null;
      if (inRange(bite, 0x21, 0x7E)) {
        code_point = indexCodePointFor((lead - 1) * 190 +
                                       (bite + 0x3F), indexes['gbk']);
      }
      if (bite === 0x0A) {
        hzgb2312 = false;
      }
      if (code_point === null) {
        return decoderError(fatal);
      }
      return code_point;
    }
    if (bite === 0x7E) {
      hzgb2312_lead = 0x7E;
      return null;
    }
    if (hzgb2312) {
      if (inRange(bite, 0x20, 0x7F)) {
        hzgb2312_lead = bite;
        return null;
      }
      if (bite === 0x0A) {
        hzgb2312 = false;
      }
      return decoderError(fatal);
    }
    if (inRange(bite, 0x00, 0x7F)) {
      return bite;
    }
    return decoderError(fatal);
  };
}
959363
function MemoryStore (options) {
  options = options || {};

  options.max = Number(options.max);
  if (isNaN(options.max)) options.max = DEFAULT_MAX;
  this._max = options.max;

  options.gcProbability = Number(options.gcProbability);
  if (isNaN(options.gcProbability)) options.gcProbability = DEFAULT_PROBABILITY;
  this._gcProbability = options.gcProbability;

  debug('init: max=%s, gcProbability=%s', this._max, this._gcProbability);

  this._keys = {};
  this._keyTotal = 0;

  return this;
}
659111
function UTF16Decoder(utf16_be, options) {
  var fatal = options.fatal;
  var /** @type {?number} */ utf16_lead_byte = null,
      /** @type {?number} */ utf16_lead_surrogate = null;
  /**
   * @param {ByteInputStream} byte_pointer The byte stream to decode.
   * @return {?number} The next code point decoded, or null if not enough
   *     data exists in the input stream to decode a complete code point.
   */
  this.decode = function(byte_pointer) {
    var bite = byte_pointer.get();
    if (bite === EOF_byte && utf16_lead_byte === null &&
        utf16_lead_surrogate === null) {
      return EOF_code_point;
    }
    if (bite === EOF_byte && (utf16_lead_byte !== null ||
                              utf16_lead_surrogate !== null)) {
      return decoderError(fatal);
    }
    byte_pointer.offset(1);
    if (utf16_lead_byte === null) {
      utf16_lead_byte = bite;
      return null;
    }
    var code_point;
    if (utf16_be) {
      code_point = (utf16_lead_byte << 8) + bite;
    } else {
      code_point = (bite << 8) + utf16_lead_byte;
    }
    utf16_lead_byte = null;
    if (utf16_lead_surrogate !== null) {
      var lead_surrogate = utf16_lead_surrogate;
      utf16_lead_surrogate = null;
      if (inRange(code_point, 0xDC00, 0xDFFF)) {
        return 0x10000 + (lead_surrogate - 0xD800) * 0x400 +
            (code_point - 0xDC00);
      }
      byte_pointer.offset(-2);
      return decoderError(fatal);
    }
    if (inRange(code_point, 0xD800, 0xDBFF)) {
      utf16_lead_surrogate = code_point;
      return null;
    }
    if (inRange(code_point, 0xDC00, 0xDFFF)) {
      return decoderError(fatal);
    }
    return code_point;
  };
}
787556
function DBCSEncoder(options, codec) {
    // Encoder state
    this.leadSurrogate = -1;
    this.seqObj = undefined;
    
    // Static data
    this.encodeTable = codec.encodeTable;
    this.encodeTableSeq = codec.encodeTableSeq;
    this.defaultCharSingleByte = codec.defCharSB;
    this.gb18030 = codec.gb18030;
}
1137167
function EUCKRDecoder(options) {
  var fatal = options.fatal;
  var /** @type {number} */ euckr_lead = 0x00;
  /**
   * @param {ByteInputStream} byte_pointer The byte stream to decode.
   * @return {?number} The next code point decoded, or null if not enough
   *     data exists in the input stream to decode a complete code point.
   */
  this.decode = function(byte_pointer) {
    var bite = byte_pointer.get();
    if (bite === EOF_byte && euckr_lead === 0) {
      return EOF_code_point;
    }
    if (bite === EOF_byte && euckr_lead !== 0) {
      euckr_lead = 0x00;
      return decoderError(fatal);
    }
    byte_pointer.offset(1);
    if (euckr_lead !== 0x00) {
      var lead = euckr_lead;
      var pointer = null;
      euckr_lead = 0x00;

      if (inRange(lead, 0x81, 0xC6)) {
        var temp = (26 + 26 + 126) * (lead - 0x81);
        if (inRange(bite, 0x41, 0x5A)) {
          pointer = temp + bite - 0x41;
        } else if (inRange(bite, 0x61, 0x7A)) {
          pointer = temp + 26 + bite - 0x61;
        } else if (inRange(bite, 0x81, 0xFE)) {
          pointer = temp + 26 + 26 + bite - 0x81;
        }
      }

      if (inRange(lead, 0xC7, 0xFD) && inRange(bite, 0xA1, 0xFE)) {
        pointer = (26 + 26 + 126) * (0xC7 - 0x81) + (lead - 0xC7) * 94 +
            (bite - 0xA1);
      }

      var code_point = (pointer === null) ? null :
          indexCodePointFor(pointer, indexes['euc-kr']);
      if (pointer === null) {
        byte_pointer.offset(-1);
      }
      if (code_point === null) {
        return decoderError(fatal);
      }
      return code_point;
    }

    if (inRange(bite, 0x00, 0x7F)) {
      return bite;
    }

    if (inRange(bite, 0x81, 0xFD)) {
      euckr_lead = bite;
      return null;
    }

    return decoderError(fatal);
  };
}
928667
function Board(options) {
    EventEmitter.call(this);

    this._options = options;
    this._buf = [];
    this._digitalPort = [];
    this._numPorts = 0;
    this._analogPinMapping = [];
    this._digitalPinMapping = [];
    this._i2cPins = [];
    this._ioPins = [];
    this._totalPins = 0;
    this._totalAnalogPins = 0;
    this._samplingInterval = 19;
    this._isReady = false;
    this._firmwareName = '';
    this._firmwareVersion = 0;
    this._capabilityQueryResponseReceived = false;
    this._numPinStateRequests = 0;
    this._numDigitalPortReportRequests = 0;
    this._transport = null;
    this._pinStateEventCenter = new EventEmitter();
    this._logger = new Logger('Board');

    this._initialVersionResultHandler = onInitialVersionResult.bind(this);
    this._openHandler = onOpen.bind(this);
    this._reOpenHandler = onReOpen.bind(this);
    this._messageHandler = onMessage.bind(this);
    this._errorHandler = onError.bind(this);
    this._closeHandler = onClose.bind(this);
    this._cleanupHandler = cleanup.bind(this);

    attachCleanup(this);
    this._setTransport(this._options.transport);
  }