Skip to content

khell/less-variables-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A simple library function to transform a string of LESS variables into a JSON key-value pair mapping.

Install

npm install less-variables-to-json

Usage

Returns a Promise.

const lessVariablesToJson = require('less-variables-to-json');

let json;

// Standard usage
lessVariablesToJson("@primary-color: red;").then((result) => {
    json = result;  // json = { "@primary-color": "red" }
});

// With a projection function to change the name
let nameProjectionFunc = (name) => name.substr(1);
lessVariablesToJson("@primary-color: red;", { nameProjectionFunc }).then((result) => {
    json = result;  // json = { "primary-color": "red" }
};

License

MIT