Sha256: 102c13e42c001e1478a3a2e4dfa0b85590e960341d3d36cd2ed979ad7c30ea0d

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

var $util = {};

$util.cleanInfo = function(tree) {
    var r = [];
    tree = tree.slice(1);

    tree.forEach(function(e) {
        r.push(Array.isArray(e) ? $util.cleanInfo(e) : e);
    });

    return r;
};

$util.treeToString = function(tree, level) {
    var spaces = $util.dummySpaces(level),
        level = level ? level : 0,
        s = (level ? '\n' + spaces : '') + '[';

    tree.forEach(function(e) {
        s += (Array.isArray(e) ? $util.treeToString(e, level + 1) : e.f !== undefined ? $util.ircToString(e) : ('\'' + e.toString() + '\'')) + ', ';
    });

    return s.substr(0, s.length - 2) + ']';
};

$util.ircToString = function(o) {
    return '{' + o.f + ',' + o.l + '}';
};

$util.dummySpaces = function(num) {
    return '                                                  '.substr(0, num * 2);
};
$util.printTree = function(tree) {
    require('sys').print($util.treeToString(tree));
};

exports.cleanInfo = $util.cleanInfo;

exports.treeToString = $util.treeToString;

exports.printTree = $util.printTree;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csso-rails-0.0.3 lib/csso/js/util.js
csso-rails-0.0.2 lib/csso/js/util.js
csso-rails-0.0.1 lib/csso/js/util.js