Comparing version 0.2.3 to 0.2.4
@@ -22,2 +22,4 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _functions = require('./functions'); | ||
@@ -33,19 +35,12 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
exports.parse = _parser2.default; | ||
/* | ||
Converts camelCase to camel-case | ||
Parses @var with {var: 'value'} | ||
*/ | ||
function camelCaseToDash(key) { | ||
return key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | ||
} | ||
/* | ||
Parses @var with {var: 'value'} | ||
*/ | ||
function parseVars(str) { | ||
@@ -61,3 +56,3 @@ var vars = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var _key = key[0] === '@' ? key : '@' + key; | ||
var dashKey = camelCaseToDash(_key); | ||
var dashKey = (0, _utils.camelCaseToDash)(_key); | ||
if (dashKey !== _key) { | ||
@@ -71,2 +66,10 @@ pointer = pointer.replace(dashKey, replacement); | ||
function containsCall(str) { | ||
return str.trim().search(/\)$/) > -1; | ||
} | ||
function isDimension(str) { | ||
return typeof str === "number" || containsOp(str) || !containsCall(str) && containsUnit(str); | ||
} | ||
/* | ||
@@ -79,4 +82,16 @@ Parses less entity string | ||
var finalstr = parseVars(str, vars); | ||
if (isPlainObj(str)) { | ||
return Object.keys(str).reduce(function (pointer, key) { | ||
var subVal = str[key]; | ||
return _extends({}, pointer, _defineProperty({}, key, lessly(subVal, vars))); | ||
}, {}); | ||
} | ||
if (isDimension(parseVars(str, vars))) { | ||
return dimension(parseVars(str, vars)); | ||
} | ||
return (0, _parser2.default)(finalstr).toCSS(); | ||
}; | ||
} | ||
@@ -185,2 +200,13 @@ exports.default = lessly; | ||
function containsUnit(val) { | ||
var units = Object.keys(dimensions); | ||
for (var i = 0; i < units.length; i++) { | ||
var reg = new RegExp(units[i] + '/b'); | ||
if (val.search && val.trim().search(reg) > -1) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function toOps() { | ||
@@ -282,2 +308,2 @@ for (var _len3 = arguments.length, args = Array(_len3), _key4 = 0; _key4 < _len3; _key4++) { | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9sZXNzbHkuanMiXSwibmFtZXMiOlsidGhlbWUiLCJkaW1lbnNpb24iLCJ2YWx1ZSIsInBhcnNlIiwiY2FtZWxDYXNlVG9EYXNoIiwia2V5IiwicmVwbGFjZSIsInRvTG93ZXJDYXNlIiwicGFyc2VWYXJzIiwic3RyIiwidmFycyIsImtleXMiLCJPYmplY3QiLCJzb3J0IiwiYSIsImIiLCJsZW5ndGgiLCJyZWR1Y2UiLCJwb2ludGVyIiwicmVwbGFjZW1lbnQiLCJfa2V5IiwiZGFzaEtleSIsImxlc3NseSIsImZpbmFsc3RyIiwidG9DU1MiLCJiaW5kUGFyc2UiLCJmdW5jIiwiY29udmVydCIsImFyZ3MiLCJmaW5hbEFyZ3MiLCJtYXAiLCJTdHJpbmciLCJhcmciLCJyZXN1bHQiLCJpc05hTiIsIk51bWJlciIsImNhbGxhYmxlIiwiZGVmYXVsRnVuY3Rpb24iLCJzdWJWYXJzIiwiZGltZW5zaW9ucyIsImNvbG9yRnVuY3Rpb25zIiwibW9kdWxlIiwiZXhwb3J0cyIsImlzUGxhaW5PYmoiLCJvIiwiY29uc3RydWN0b3IiLCJ2YWwiLCJ1bml0Iiwic3ViVmFsIiwidW5kZWZpbmVkIiwib3AiLCJ0b09wcyIsImNvbnRhaW5zT3AiLC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PT4gZGltZW5zaW9uKHZhbCwgJ3JhZCcpO1xuZXhwb3J0IGNvbnN0IHB0ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdwdCcpO1xuZXhwb3J0IGNvbnN0IHZoID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICd2aCcpO1xuZXhwb3J0IGNvbnN0IHZ3ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICd2dycpO1xuZXhwb3J0IGNvbnN0IGluY2ggPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJ2luJyk7XG5leHBvcnQgY29uc3QgbW0gPSB2YWwgPT4gZGltZW5zaW9uKHZhbCwgJ21tJyk7XG5leHBvcnQgY29uc3Qgdm1pbiA9IHZhbCA9PiBkaW1lbnNpb24odmFsLCAndm1pbicpO1xuZXhwb3J0IGNvbnN0IGNtID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdjbScpO1xuZXhwb3J0IGNvbnN0IHBjID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdwYycpO1xuZXhwb3J0IGNvbnN0IGV4ID0gdmFsID0+IGRpbWVuc2lvbih2YWwsICdleCcpO1xuXG5leHBvcnQgY29uc3QgZGltZW5zaW9ucyA9IHtcbiAgcHgsIHBlcmNlbnQsIGluY2gsIG1tLCB2aCwgdncsIHJhZCwgcHQsIGNtLCB2bWluLCBwYywgZXgsIGRpbWVuc2lvbiwgZGltXG59O1xuIl19 |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -14,4 +14,7 @@ /* jshint proto: true */ | ||
return copy; | ||
}, | ||
camelCaseToDash: function camelCaseToDash(key) { | ||
return key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | ||
} | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwiY29weUFycmF5IiwiYXJy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YXNlKCk7XG4gICAgfVxufTtcbiJdfQ== |
{ | ||
"name": "lessly", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Less functions without less", | ||
@@ -5,0 +5,0 @@ "main": "lib/lessly.js", |
@@ -41,2 +41,11 @@ # [Less][] Standalone Functions [![Build Status](https://travis-ci.org/gtg092x/lessly.svg?branch=master)](https://travis-ci.org/gtg092x/lessly) | ||
Lessly will also crawl objects and parse each value | ||
```js | ||
lessly({ | ||
myRule: 'fade(red, 90%)' | ||
}); | ||
// outputs {myRule: 'rgba(255, 0, 0, 0.9)'} | ||
``` | ||
## Variables | ||
@@ -107,2 +116,9 @@ | ||
Lessly will also parse what looks like dimensions | ||
```js | ||
lessly('10px + 10'); | ||
// outputs 20px | ||
``` | ||
We'll also recurse any object and apply operations to child values | ||
@@ -109,0 +125,0 @@ |
import parse from './parser/parser' | ||
import { camelCaseToDash } from './utils'; | ||
export {parse}; | ||
/* | ||
Converts camelCase to camel-case | ||
*/ | ||
function camelCaseToDash(key) { | ||
return key.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase(); | ||
} | ||
/* | ||
Parses @var with {var: 'value'} | ||
@@ -31,2 +25,10 @@ */ | ||
function containsCall(str) { | ||
return str.trim().search(/\)$/) > -1; | ||
} | ||
function isDimension(str) { | ||
return typeof str === "number" || containsOp(str) || (!containsCall(str) && containsUnit(str)); | ||
} | ||
/* | ||
@@ -37,4 +39,19 @@ Parses less entity string | ||
const finalstr = parseVars(str, vars); | ||
if (isPlainObj(str)) { | ||
return Object.keys(str).reduce(function(pointer, key){ | ||
const subVal = str[key]; | ||
return { | ||
...pointer, | ||
[key]: lessly(subVal, vars) | ||
}; | ||
}, {}); | ||
} | ||
if (isDimension(parseVars(str, vars))) { | ||
return dimension(parseVars(str, vars)); | ||
} | ||
return parse(finalstr).toCSS(); | ||
}; | ||
} | ||
@@ -133,2 +150,13 @@ export default lessly; | ||
function containsUnit(val) { | ||
const units = Object.keys(dimensions); | ||
for(let i = 0; i < units.length; i++) { | ||
const reg = new RegExp(units[i] + '/b'); | ||
if(val.search && val.trim().search(reg) > -1) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function toOps(...args) { | ||
@@ -135,0 +163,0 @@ return args.map(arg => arg.trim ? arg.trim() : arg).join(' '); |
@@ -11,3 +11,6 @@ /* jshint proto: true */ | ||
return copy; | ||
}, | ||
camelCaseToDash(key) { | ||
return key.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase(); | ||
} | ||
}; |
@@ -21,2 +21,5 @@ import chai from 'chai'; | ||
assert.equal(color, 'rgba(0, 0, 0, 0.9)'); | ||
assert.deepEqual(lessly({ | ||
myColor: 'fade(rgb(0, 0, 0), 90%)' | ||
}), {myColor: 'rgba(0, 0, 0, 0.9)'}); | ||
@@ -75,3 +78,3 @@ color = lessly('fade(black, 90%)'); | ||
assert.strictEqual(dimension('10px'), '10'); | ||
assert.strictEqual(dimension('10% + 10%'), '20%'); | ||
assert.strictEqual(lessly('10% + 10%'), '20%'); | ||
assert.strictEqual(dimension('10% + 10'), '20%'); | ||
@@ -78,0 +81,0 @@ assert.strictEqual(dimension('10% +', 10), '20%'); |
Sorry, the diff of this file is not supported yet
351484
3868
184