index.js
function encode(str) {
    var i;
    var vacs = findSingleVacancies(str, singleLen + complexLen);
    var singleReplacements = vacs.slice(0, singleLen);
    var complexReplacements = vacs.slice(singleLen);
    var dest = str;
    // first replace complex delimiters
    for (i = COMPLEX_DELIMITERS.length - 1; i >= 0; i--) {
        if (i < complexReplacements.length) {
            dest = dest.split(COMPLEX_DELIMITERS[i]).join(complexReplacements[i]);
        }
    }
    // then replace single delimiters
    for (i = 0; i < singleReplacements.length; i++) {
        dest = dest.split(SINGLE_DELIMITERS[i]).join(singleReplacements[i]);
    }
    // concatenate with replacement map
    dest = singleReplacements.join('') + SECTION_DELIMITER + complexReplacements.join('') + SECTION_DELIMITER + dest;
    return dest;
}
function encode(str) {
    var i;
    var vacs = findSingleVacancies(str, singleLen + complexLen);
    var singleReplacements = vacs.slice(0, singleLen);
    var complexReplacements = vacs.slice(singleLen);
    var dest = str;
    // first replace complex delimiters
    for (i = COMPLEX_DELIMITERS.length - 1; i >= 0; i--) {
        if (i < complexReplacements.length) {
            dest = dest.split(COMPLEX_DELIMITERS[i]).join(complexReplacements[i]);
        }
    }
    // then replace single delimiters
    for (i = 0; i < singleReplacements.length; i++) {
        dest = dest.split(SINGLE_DELIMITERS[i]).join(singleReplacements[i]);
    }
    // concatenate with replacement map
    dest = singleReplacements.join('') + SECTION_DELIMITER + complexReplacements.join('') + SECTION_DELIMITER + dest;
    return dest;
}
function encode ( str ) { var i ; var vacs = findSingleVacancies ( str , singleLen + complexLen ) ; var singleReplacements = vacs . slice ( 0 , singleLen ) ; var complexReplacements = vacs . slice ( singleLen ) ; var dest = str ; // first replace complex delimiters for ( i = COMPLEX_DELIMITERS . length - 1 ; i >= 0 ; i -- ) { if ( i < complexReplacements . length ) { dest = dest . split ( COMPLEX_DELIMITERS [ i ] ) . join ( complexReplacements [ i ] ) ; } } // then replace single delimiters for ( i = 0 ; i < singleReplacements . length ; i ++ ) { dest = dest . split ( SINGLE_DELIMITERS [ i ] ) . join ( singleReplacements [ i ] ) ; } // concatenate with replacement map dest = singleReplacements . join ( '' ) + SECTION_DELIMITER + complexReplacements . join ( '' ) + SECTION_DELIMITER + dest ; return dest ; }
Encode JSON string
@param {string} str
@returns {string}
Encode JSON string