JSFiddle - React, Tailwind, and code Playground

by Chase Wilson

JavaScript

less.tree.functions.shard = function( path, base, shards){
    
    var sum = 0,
        i=0,
        len = path.value.length, 
        newPath = [], 
        shards = shards || 1,
        shard;

    for(;i<len;i++){
        sum += path.toString().charCodeAt(i);
    }

    shard = 1 + sum % shards;
    
    newPath.push(base.value.replace(/{#}/, shard ));
    newPath.push(path.value);
    console.log(path.value);
    newPath = newPath.join('/');
    
    return new(less.tree.Quoted)('"'+ newPath +'"',newPath);
};