UNPKG

1.27 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4 * Returns the value with '' around it. Any 's will be escaped \' in the output
5 */
6function calc(exp) {
7 return "calc(" + exp + ")";
8}
9exports.calc = calc;
10/**
11 * Returns the value with '' around it. Any 's will be escaped \' in the output
12 */
13function quote(val) {
14 var val2 = (val || val === 0 ? val.toString() : '').replace(/\'/g, "\\'");
15 return "'" + val2 + "'";
16}
17exports.quote = quote;
18/**
19 * Returns the value with !important on the end. If the value provided is a CSSHelper, it will
20 * be converted to a string by necessity, but will look like it is the original type to TypeScript.
21 */
22function important(val) {
23 if (!val && val !== 0) {
24 return '';
25 }
26 return val.toString() + " !important";
27}
28exports.important = important;
29/**
30 * Returns the string in a url()
31 * @see https://developer.mozilla.org/en-US/docs/Web/CSS/url
32 */
33function url(val) {
34 return "url(" + (val || '') + ")";
35}
36exports.url = url;
37/**
38 * Returns the value as a string or an empty string if null or undefined.
39 * @param value
40 * @param fallbackValue
41 */
42function coalesce(value) {
43 return !value && value !== 0 ? '' : value.toString();
44}
45exports.coalesce = coalesce;