diff options
Diffstat (limited to 'node_modules/stylus/lib/functions/unit.js')
| -rw-r--r-- | node_modules/stylus/lib/functions/unit.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/stylus/lib/functions/unit.js b/node_modules/stylus/lib/functions/unit.js new file mode 100644 index 00000000..bd904a55 --- /dev/null +++ b/node_modules/stylus/lib/functions/unit.js @@ -0,0 +1,23 @@ +var utils = require('../utils') + , nodes = require('../nodes'); + +/** + * Assign `type` to the given `unit` or return `unit`'s type. + * + * @param {Unit} unit + * @param {String|Ident} type + * @return {Unit} + * @api public + */ + +module.exports = function unit(unit, type){ + utils.assertType(unit, 'unit', 'unit'); + + // Assign + if (type) { + utils.assertString(type, 'type'); + return new nodes.Unit(unit.val, type.string); + } else { + return unit.type || ''; + } +}; |
