joycss/lib/csslib/cssReader.js
function read(data){

    var dismember = this.get('DISMEMBER');
    var i = 0, j = 0;
    var comment = false;
    var len = data.length;
    var code = data[0];
    var line = 1;
    var val;
    var slice = data.asciiSlice ? 'asciiSlice' : 'slice';
    //console.log("one\n");

    while(code){

      if (typeof code == 'string') code = code.charCodeAt();
      if (code === 10 || code === 13){
        var isoneLine = code === 10 && data[i - 1] === 13;
        //isoneLine = isoneLine || (code === 10 && data[i - 1] === 13);
        if (!isoneLine) line = line + 1;
      } else if (code === 42 && (data[i + 1] === 47 || data[i + 1] == '/')){
        //comment end 
        comment = false;
        i++;
        j = i + 1;
      } else if (code === 47 && (data[i + 1] === 42 || data[i + 1] == '*')){
        //comment start
        comment = true;
        i++;
      } else if (!comment && code in dismember){

        var status = this.get('status');
        //filter the condiction of semicolon(,) in css rule such as
        //_filter: xxx(src=url, sizingMethod='crop')
        var isFalseSelecterBreak = code === 44 && 
                                            status == 'valueStart';
        //filter the condiction of pseudo selector(:)
        var isPseudo = code == 58 && status != 'ruleStart' &&
                                               status != 'valueEnd';

        //
        var isInExpression = (code === 123 || code === 125)
          && status === 'valueStart' && data[slice](j, i).indexOf('expression') > -1;

        if (isPseudo || isFalseSelecterBreak || isInExpression){
          code = data[++i];
          continue;
        }

        val = data[slice](j, i).replace(this.get('TRIM_REG'), '');
        this._addEvent(dismember[code], val, line);
        j = i + 1;
      }

      code = data[++i];
    }

  }
function read(data){

    var dismember = this.get('DISMEMBER');
    var i = 0, j = 0;
    var comment = false;
    var len = data.length;
    var code = data[0];
    var line = 1;
    var val;
    var slice = data.asciiSlice ? 'asciiSlice' : 'slice';
    //console.log("one\n");

    while(code){

      if (typeof code == 'string') code = code.charCodeAt();
      if (code === 10 || code === 13){
        var isoneLine = code === 10 && data[i - 1] === 13;
        //isoneLine = isoneLine || (code === 10 && data[i - 1] === 13);
        if (!isoneLine) line = line + 1;
      } else if (code === 42 && (data[i + 1] === 47 || data[i + 1] == '/')){
        //comment end 
        comment = false;
        i++;
        j = i + 1;
      } else if (code === 47 && (data[i + 1] === 42 || data[i + 1] == '*')){
        //comment start
        comment = true;
        i++;
      } else if (!comment && code in dismember){

        var status = this.get('status');
        //filter the condiction of semicolon(,) in css rule such as
        //_filter: xxx(src=url, sizingMethod='crop')
        var isFalseSelecterBreak = code === 44 && 
                                            status == 'valueStart';
        //filter the condiction of pseudo selector(:)
        var isPseudo = code == 58 && status != 'ruleStart' &&
                                               status != 'valueEnd';

        //
        var isInExpression = (code === 123 || code === 125)
          && status === 'valueStart' && data[slice](j, i).indexOf('expression') > -1;

        if (isPseudo || isFalseSelecterBreak || isInExpression){
          code = data[++i];
          continue;
        }

        val = data[slice](j, i).replace(this.get('TRIM_REG'), '');
        this._addEvent(dismember[code], val, line);
        j = i + 1;
      }

      code = data[++i];
    }

  }
function read ( data ) { var dismember = this . get ( 'DISMEMBER' ) ; var i = 0 , j = 0 ; var comment = false ; var len = data . length ; var code = data [ 0 ] ; var line = 1 ; var val ; var slice = data . asciiSlice ? 'asciiSlice' : 'slice' ; //console.log("one\n"); while ( code ) { if ( typeof code == 'string' ) code = code . charCodeAt ( ) ; if ( code === 10 || code === 13 ) { var isoneLine = code === 10 && data [ i - 1 ] === 13 ; //isoneLine = isoneLine || (code === 10 && data[i - 1] === 13); if ( ! isoneLine ) line = line + 1 ; } else if ( code === 42 && ( data [ i + 1 ] === 47 || data [ i + 1 ] == '/' ) ) { //comment end  comment = false ; i ++ ; j = i + 1 ; } else if ( code === 47 && ( data [ i + 1 ] === 42 || data [ i + 1 ] == '*' ) ) { //comment start comment = true ; i ++ ; } else if ( ! comment && code in dismember ) { var status = this . get ( 'status' ) ; //filter the condiction of semicolon(,) in css rule such as //_filter: xxx(src=url, sizingMethod='crop') var isFalseSelecterBreak = code === 44 && status == 'valueStart' ; //filter the condiction of pseudo selector(:) var isPseudo = code == 58 && status != 'ruleStart' && status != 'valueEnd' ; // var isInExpression = ( code === 123 || code === 125 ) && status === 'valueStart' && data [ slice ] ( j , i ) . indexOf ( 'expression' ) > - 1 ; if ( isPseudo || isFalseSelecterBreak || isInExpression ) { code = data [ ++ i ] ; continue ; } val = data [ slice ] ( j , i ) . replace ( this . get ( 'TRIM_REG' ) , '' ) ; this . _addEvent ( dismember [ code ] , val , line ) ; j = i + 1 ; } code = data [ ++ i ] ; } }
read data steam, loop exam the assic code one by one. filter the comment
and when meet with code in dismember, fire some event, then change the
property of status, push event into the array of history, and deliver a
string of selector or property or value.
read data steam loop exam the assic code one by one . filter the comment and when meet with code in dismember fire some event then change the property of status push event into the array of history and deliver a string of selector or property or value .