lib/tokens.js
function normalizeTokens(relative, tokens) {
    var _index = 0;

    // Force as an array
    if (!_.isArray(tokens)) tokens = [tokens];

    return _.map(tokens, function(subtoken) {
        if (_.isNull(subtoken)) return null;
        if (_.isString(subtoken)) {
            subtoken = {
                value: subtoken,
                index: _index,
                offset: subtoken.length
            };
        }

        if (_.isObject(subtoken)) {
            subtoken.index = subtoken.index || 0;
            _index = _index + subtoken.index + subtoken.offset;

            // Transform as an absolute token
            subtoken.index = relative.index + subtoken.index;
            subtoken.offset = subtoken.offset || subtoken.value.length;
        }

        return subtoken;
    });
}
function normalizeTokens(relative, tokens) {
    var _index = 0;

    // Force as an array
    if (!_.isArray(tokens)) tokens = [tokens];

    return _.map(tokens, function(subtoken) {
        if (_.isNull(subtoken)) return null;
        if (_.isString(subtoken)) {
            subtoken = {
                value: subtoken,
                index: _index,
                offset: subtoken.length
            };
        }

        if (_.isObject(subtoken)) {
            subtoken.index = subtoken.index || 0;
            _index = _index + subtoken.index + subtoken.offset;

            // Transform as an absolute token
            subtoken.index = relative.index + subtoken.index;
            subtoken.offset = subtoken.offset || subtoken.value.length;
        }

        return subtoken;
    });
}
function normalizeTokens ( relative , tokens ) { var _index = 0 ; // Force as an array if ( ! _ . isArray ( tokens ) ) tokens = [ tokens ] ; return _ . map ( tokens , function ( subtoken ) { if ( _ . isNull ( subtoken ) ) return null ; if ( _ . isString ( subtoken ) ) { subtoken = { value : subtoken , index : _index , offset : subtoken . length } ; } if ( _ . isObject ( subtoken ) ) { subtoken . index = subtoken . index || 0 ; _index = _index + subtoken . index + subtoken . offset ; // Transform as an absolute token subtoken . index = relative . index + subtoken . index ; subtoken . offset = subtoken . offset || subtoken . value . length ; } return subtoken ; } ) ; }
Normalize and resolve a list of tokens relative to a token
Normalize and resolve a list of tokens relative to a token