diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/clean-css/lib/options | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/clean-css/lib/options')
| -rw-r--r-- | node_modules/clean-css/lib/options/compatibility.js | 181 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/fetch.js | 7 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/format.js | 241 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/inline-request.js | 22 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/inline-timeout.js | 7 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/inline.js | 15 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/optimization-level.js | 218 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/plugins.js | 25 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/rebase-to.js | 7 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/rebase.js | 10 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/options/rounding-precision.js | 88 |
11 files changed, 0 insertions, 821 deletions
diff --git a/node_modules/clean-css/lib/options/compatibility.js b/node_modules/clean-css/lib/options/compatibility.js deleted file mode 100644 index a55fc11c..00000000 --- a/node_modules/clean-css/lib/options/compatibility.js +++ /dev/null @@ -1,181 +0,0 @@ -var DEFAULTS = { - '*': { - colors: { - hexAlpha: false, // 4- and 8-character hex notation - opacity: true // rgba / hsla - }, - customUnits: { rpx: false }, - properties: { - backgroundClipMerging: true, // background-clip to shorthand - backgroundOriginMerging: true, // background-origin to shorthand - backgroundSizeMerging: true, // background-size to shorthand - colors: true, // any kind of color transformations, like `#ff00ff` to `#f0f` or `#fff` into `red` - ieBangHack: false, // !ie suffix hacks on IE<8 - ieFilters: false, // whether to preserve `filter` and `-ms-filter` properties - iePrefixHack: false, // underscore / asterisk prefix hacks on IE - ieSuffixHack: false, // \9 suffix hacks on IE6-9, \0 suffix hack on IE6-11 - merging: true, // merging properties into one - shorterLengthUnits: false, // optimize pixel units into `pt`, `pc` or `in` units - spaceAfterClosingBrace: true, // 'url() no-repeat' to 'url()no-repeat' - urlQuotes: true, // whether to wrap content of `url()` into quotes or not - zeroUnits: true // 0[unit] -> 0 - }, - selectors: { - adjacentSpace: false, // div+ nav Android stock browser hack - ie7Hack: false, // *+html hack - mergeablePseudoClasses: [ - ':active', - ':after', - ':before', - ':empty', - ':checked', - ':disabled', - ':empty', - ':enabled', - ':first-child', - ':first-letter', - ':first-line', - ':first-of-type', - ':focus', - ':hover', - ':lang', - ':last-child', - ':last-of-type', - ':link', - ':not', - ':nth-child', - ':nth-last-child', - ':nth-last-of-type', - ':nth-of-type', - ':only-child', - ':only-of-type', - ':root', - ':target', - ':visited' - ], // selectors with these pseudo-classes can be merged as these are universally supported - mergeablePseudoElements: [ - '::after', - '::before', - '::first-letter', - '::first-line' - ], // selectors with these pseudo-elements can be merged as these are universally supported - mergeLimit: 8191, // number of rules that can be safely merged together - multiplePseudoMerging: true - }, - units: { - ch: true, - in: true, - pc: true, - pt: true, - rem: true, - vh: true, - vm: true, // vm is vmin on IE9+ see https://developer.mozilla.org/en-US/docs/Web/CSS/length - vmax: true, - vmin: true, - vw: true - } - } -}; - -DEFAULTS.ie11 = merge(DEFAULTS['*'], { properties: { ieSuffixHack: true } }); - -DEFAULTS.ie10 = merge(DEFAULTS['*'], { properties: { ieSuffixHack: true } }); - -DEFAULTS.ie9 = merge(DEFAULTS['*'], { - properties: { - ieFilters: true, - ieSuffixHack: true - } -}); - -DEFAULTS.ie8 = merge(DEFAULTS.ie9, { - colors: { opacity: false }, - properties: { - backgroundClipMerging: false, - backgroundOriginMerging: false, - backgroundSizeMerging: false, - iePrefixHack: true, - merging: false - }, - selectors: { - mergeablePseudoClasses: [ - ':after', - ':before', - ':first-child', - ':first-letter', - ':focus', - ':hover', - ':visited' - ], - mergeablePseudoElements: [] - }, - units: { - ch: false, - rem: false, - vh: false, - vm: false, - vmax: false, - vmin: false, - vw: false - } -}); - -DEFAULTS.ie7 = merge(DEFAULTS.ie8, { - properties: { ieBangHack: true }, - selectors: { - ie7Hack: true, - mergeablePseudoClasses: [ - ':first-child', - ':first-letter', - ':hover', - ':visited' - ] - } -}); - -function compatibilityFrom(source) { - return merge(DEFAULTS['*'], calculateSource(source)); -} - -function merge(source, target) { - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - var value = source[key]; - - if (Object.prototype.hasOwnProperty.call(target, key) && typeof value === 'object' && !Array.isArray(value)) { - target[key] = merge(value, target[key] || {}); - } else { - target[key] = key in target ? target[key] : value; - } - } - } - - return target; -} - -function calculateSource(source) { - if (typeof source == 'object') { return source; } - - if (!/[,+-]/.test(source)) { return DEFAULTS[source] || DEFAULTS['*']; } - - var parts = source.split(','); - var template = parts[0] in DEFAULTS - ? DEFAULTS[parts.shift()] - : DEFAULTS['*']; - - source = {}; - - parts.forEach(function(part) { - var isAdd = part[0] == '+'; - var key = part.substring(1).split('.'); - var group = key[0]; - var option = key[1]; - - source[group] = source[group] || {}; - source[group][option] = isAdd; - }); - - return merge(template, source); -} - -module.exports = compatibilityFrom; diff --git a/node_modules/clean-css/lib/options/fetch.js b/node_modules/clean-css/lib/options/fetch.js deleted file mode 100644 index 0aaad786..00000000 --- a/node_modules/clean-css/lib/options/fetch.js +++ /dev/null @@ -1,7 +0,0 @@ -var loadRemoteResource = require('../reader/load-remote-resource'); - -function fetchFrom(callback) { - return callback || loadRemoteResource; -} - -module.exports = fetchFrom; diff --git a/node_modules/clean-css/lib/options/format.js b/node_modules/clean-css/lib/options/format.js deleted file mode 100644 index 8c56c372..00000000 --- a/node_modules/clean-css/lib/options/format.js +++ /dev/null @@ -1,241 +0,0 @@ -var override = require('../utils/override'); - -function getSystemLineBreak() { - var systemLineBreak = '\n'; - try { - var os = require('os'); - systemLineBreak = os.EOL; - } catch (_) { - // no op - } - return systemLineBreak; -} - -var Breaks = { - AfterAtRule: 'afterAtRule', - AfterBlockBegins: 'afterBlockBegins', - AfterBlockEnds: 'afterBlockEnds', - AfterComment: 'afterComment', - AfterProperty: 'afterProperty', - AfterRuleBegins: 'afterRuleBegins', - AfterRuleEnds: 'afterRuleEnds', - BeforeBlockEnds: 'beforeBlockEnds', - BetweenSelectors: 'betweenSelectors' -}; - -var BreakWith = { - CarriageReturnLineFeed: '\r\n', - LineFeed: '\n', - System: getSystemLineBreak() -}; - -var IndentWith = { - Space: ' ', - Tab: '\t' -}; - -var Spaces = { - AroundSelectorRelation: 'aroundSelectorRelation', - BeforeBlockBegins: 'beforeBlockBegins', - BeforeValue: 'beforeValue' -}; - -var DEFAULTS = { - breaks: breaks(false), - breakWith: BreakWith.System, - indentBy: 0, - indentWith: IndentWith.Space, - spaces: spaces(false), - wrapAt: false, - semicolonAfterLastProperty: false -}; - -var BEAUTIFY_ALIAS = 'beautify'; -var KEEP_BREAKS_ALIAS = 'keep-breaks'; - -var OPTION_SEPARATOR = ';'; -var OPTION_NAME_VALUE_SEPARATOR = ':'; -var HASH_VALUES_OPTION_SEPARATOR = ','; -var HASH_VALUES_NAME_VALUE_SEPARATOR = '='; - -var FALSE_KEYWORD_1 = 'false'; -var FALSE_KEYWORD_2 = 'off'; -var TRUE_KEYWORD_1 = 'true'; -var TRUE_KEYWORD_2 = 'on'; - -function breaks(value) { - var breakOptions = {}; - - breakOptions[Breaks.AfterAtRule] = value; - breakOptions[Breaks.AfterBlockBegins] = value; - breakOptions[Breaks.AfterBlockEnds] = value; - breakOptions[Breaks.AfterComment] = value; - breakOptions[Breaks.AfterProperty] = value; - breakOptions[Breaks.AfterRuleBegins] = value; - breakOptions[Breaks.AfterRuleEnds] = value; - breakOptions[Breaks.BeforeBlockEnds] = value; - breakOptions[Breaks.BetweenSelectors] = value; - - return breakOptions; -} - -function spaces(value) { - var spaceOptions = {}; - - spaceOptions[Spaces.AroundSelectorRelation] = value; - spaceOptions[Spaces.BeforeBlockBegins] = value; - spaceOptions[Spaces.BeforeValue] = value; - - return spaceOptions; -} - -function formatFrom(source) { - if (source === undefined || source === false) { - return false; - } - - if (typeof source == 'object' && 'breakWith' in source) { - source = override(source, { breakWith: mapBreakWith(source.breakWith) }); - } - - if (typeof source == 'object' && 'indentBy' in source) { - source = override(source, { indentBy: parseInt(source.indentBy) }); - } - - if (typeof source == 'object' && 'indentWith' in source) { - source = override(source, { indentWith: mapIndentWith(source.indentWith) }); - } - - if (typeof source == 'object') { - return remapBreaks(override(DEFAULTS, source)); - } - - if (typeof source == 'string' && source == BEAUTIFY_ALIAS) { - return remapBreaks( - override(DEFAULTS, { - breaks: breaks(true), - indentBy: 2, - spaces: spaces(true) - }) - ); - } - - if (typeof source == 'string' && source == KEEP_BREAKS_ALIAS) { - return remapBreaks( - override(DEFAULTS, { - breaks: { - afterAtRule: true, - afterBlockBegins: true, - afterBlockEnds: true, - afterComment: true, - afterRuleEnds: true, - beforeBlockEnds: true - } - }) - ); - } - - if (typeof source == 'string') { - return remapBreaks(override(DEFAULTS, toHash(source))); - } - - return DEFAULTS; -} - -function toHash(string) { - return string - .split(OPTION_SEPARATOR) - .reduce(function(accumulator, directive) { - var parts = directive.split(OPTION_NAME_VALUE_SEPARATOR); - var name = parts[0]; - var value = parts[1]; - - if (name == 'breaks' || name == 'spaces') { - accumulator[name] = hashValuesToHash(value); - } else if (name == 'indentBy' || name == 'wrapAt') { - accumulator[name] = parseInt(value); - } else if (name == 'indentWith') { - accumulator[name] = mapIndentWith(value); - } else if (name == 'breakWith') { - accumulator[name] = mapBreakWith(value); - } - - return accumulator; - }, {}); -} - -function hashValuesToHash(string) { - return string - .split(HASH_VALUES_OPTION_SEPARATOR) - .reduce(function(accumulator, directive) { - var parts = directive.split(HASH_VALUES_NAME_VALUE_SEPARATOR); - var name = parts[0]; - var value = parts[1]; - - accumulator[name] = normalizeValue(value); - - return accumulator; - }, {}); -} - -function normalizeValue(value) { - switch (value) { - case FALSE_KEYWORD_1: - case FALSE_KEYWORD_2: - return false; - case TRUE_KEYWORD_1: - case TRUE_KEYWORD_2: - return true; - default: - return value; - } -} - -function mapBreakWith(value) { - switch (value) { - case 'windows': - case 'crlf': - case BreakWith.CarriageReturnLineFeed: - return BreakWith.CarriageReturnLineFeed; - case 'unix': - case 'lf': - case BreakWith.LineFeed: - return BreakWith.LineFeed; - default: - return BreakWith.System; - } -} - -function mapIndentWith(value) { - switch (value) { - case 'space': - return IndentWith.Space; - case 'tab': - return IndentWith.Tab; - default: - return value; - } -} - -function remapBreaks(source) { - for (var key in Breaks) { - var breakName = Breaks[key]; - var breakValue = source.breaks[breakName]; - - if (breakValue === true) { - source.breaks[breakName] = source.breakWith; - } else if (breakValue === false) { - source.breaks[breakName] = ''; - } else { - source.breaks[breakName] = source.breakWith.repeat(parseInt(breakValue)); - } - } - - return source; -} - -module.exports = { - Breaks: Breaks, - Spaces: Spaces, - formatFrom: formatFrom -}; diff --git a/node_modules/clean-css/lib/options/inline-request.js b/node_modules/clean-css/lib/options/inline-request.js deleted file mode 100644 index e611dc29..00000000 --- a/node_modules/clean-css/lib/options/inline-request.js +++ /dev/null @@ -1,22 +0,0 @@ -var url = require('url'); - -var override = require('../utils/override'); - -function inlineRequestFrom(option) { - return override( - /* jshint camelcase: false */ - proxyOptionsFrom(process.env.HTTP_PROXY || process.env.http_proxy), - option || {} - ); -} - -function proxyOptionsFrom(httpProxy) { - return httpProxy - ? { - hostname: url.parse(httpProxy).hostname, - port: parseInt(url.parse(httpProxy).port) - } - : {}; -} - -module.exports = inlineRequestFrom; diff --git a/node_modules/clean-css/lib/options/inline-timeout.js b/node_modules/clean-css/lib/options/inline-timeout.js deleted file mode 100644 index c7fb454d..00000000 --- a/node_modules/clean-css/lib/options/inline-timeout.js +++ /dev/null @@ -1,7 +0,0 @@ -var DEFAULT_TIMEOUT = 5000; - -function inlineTimeoutFrom(option) { - return option || DEFAULT_TIMEOUT; -} - -module.exports = inlineTimeoutFrom; diff --git a/node_modules/clean-css/lib/options/inline.js b/node_modules/clean-css/lib/options/inline.js deleted file mode 100644 index 6b18f2db..00000000 --- a/node_modules/clean-css/lib/options/inline.js +++ /dev/null @@ -1,15 +0,0 @@ -function inlineOptionsFrom(rules) { - if (Array.isArray(rules)) { - return rules; - } - - if (rules === false) { - return ['none']; - } - - return undefined === rules - ? ['local'] - : rules.split(','); -} - -module.exports = inlineOptionsFrom; diff --git a/node_modules/clean-css/lib/options/optimization-level.js b/node_modules/clean-css/lib/options/optimization-level.js deleted file mode 100644 index 0b6f0fa1..00000000 --- a/node_modules/clean-css/lib/options/optimization-level.js +++ /dev/null @@ -1,218 +0,0 @@ -var roundingPrecisionFrom = require('./rounding-precision').roundingPrecisionFrom; - -var override = require('../utils/override'); - -var OptimizationLevel = { - Zero: '0', - One: '1', - Two: '2' -}; - -var DEFAULTS = {}; - -DEFAULTS[OptimizationLevel.Zero] = {}; -DEFAULTS[OptimizationLevel.One] = { - cleanupCharsets: true, - normalizeUrls: true, - optimizeBackground: true, - optimizeBorderRadius: true, - optimizeFilter: true, - optimizeFontWeight: true, - optimizeOutline: true, - removeEmpty: true, - removeNegativePaddings: true, - removeQuotes: true, - removeWhitespace: true, - replaceMultipleZeros: true, - replaceTimeUnits: true, - replaceZeroUnits: true, - roundingPrecision: roundingPrecisionFrom(undefined), - selectorsSortingMethod: 'standard', - specialComments: 'all', - tidyAtRules: true, - tidyBlockScopes: true, - tidySelectors: true, - variableValueOptimizers: [] -}; -DEFAULTS[OptimizationLevel.Two] = { - mergeAdjacentRules: true, - mergeIntoShorthands: true, - mergeMedia: true, - mergeNonAdjacentRules: true, - mergeSemantically: false, - overrideProperties: true, - removeEmpty: true, - reduceNonAdjacentRules: true, - removeDuplicateFontRules: true, - removeDuplicateMediaBlocks: true, - removeDuplicateRules: true, - removeUnusedAtRules: false, - restructureRules: false, - skipProperties: [] -}; - -var ALL_KEYWORD_1 = '*'; -var ALL_KEYWORD_2 = 'all'; -var FALSE_KEYWORD_1 = 'false'; -var FALSE_KEYWORD_2 = 'off'; -var TRUE_KEYWORD_1 = 'true'; -var TRUE_KEYWORD_2 = 'on'; - -var LIST_VALUE_SEPARATOR = ','; -var OPTION_SEPARATOR = ';'; -var OPTION_VALUE_SEPARATOR = ':'; - -function optimizationLevelFrom(source) { - var level = override(DEFAULTS, {}); - var Zero = OptimizationLevel.Zero; - var One = OptimizationLevel.One; - var Two = OptimizationLevel.Two; - - if (undefined === source) { - delete level[Two]; - return level; - } - - if (typeof source == 'string') { - source = parseInt(source); - } - - if (typeof source == 'number' && source === parseInt(Two)) { - return level; - } - - if (typeof source == 'number' && source === parseInt(One)) { - delete level[Two]; - return level; - } - - if (typeof source == 'number' && source === parseInt(Zero)) { - delete level[Two]; - delete level[One]; - return level; - } - - if (typeof source == 'object') { - source = covertValuesToHashes(source); - } - - if (One in source && 'roundingPrecision' in source[One]) { - source[One].roundingPrecision = roundingPrecisionFrom(source[One].roundingPrecision); - } - - if (Two in source && 'skipProperties' in source[Two] && typeof (source[Two].skipProperties) == 'string') { - source[Two].skipProperties = source[Two].skipProperties.split(LIST_VALUE_SEPARATOR); - } - - if (Zero in source || One in source || Two in source) { - level[Zero] = override(level[Zero], source[Zero]); - } - - if (One in source && ALL_KEYWORD_1 in source[One]) { - level[One] = override(level[One], defaults(One, normalizeValue(source[One][ALL_KEYWORD_1]))); - delete source[One][ALL_KEYWORD_1]; - } - - if (One in source && ALL_KEYWORD_2 in source[One]) { - level[One] = override(level[One], defaults(One, normalizeValue(source[One][ALL_KEYWORD_2]))); - delete source[One][ALL_KEYWORD_2]; - } - - if (One in source || Two in source) { - level[One] = override(level[One], source[One]); - } else { - delete level[One]; - } - - if (Two in source && ALL_KEYWORD_1 in source[Two]) { - level[Two] = override(level[Two], defaults(Two, normalizeValue(source[Two][ALL_KEYWORD_1]))); - delete source[Two][ALL_KEYWORD_1]; - } - - if (Two in source && ALL_KEYWORD_2 in source[Two]) { - level[Two] = override(level[Two], defaults(Two, normalizeValue(source[Two][ALL_KEYWORD_2]))); - delete source[Two][ALL_KEYWORD_2]; - } - - if (Two in source) { - level[Two] = override(level[Two], source[Two]); - } else { - delete level[Two]; - } - - return level; -} - -function defaults(level, value) { - var options = override(DEFAULTS[level], {}); - var key; - - for (key in options) { - if (typeof options[key] == 'boolean') { - options[key] = value; - } - } - - return options; -} - -function normalizeValue(value) { - switch (value) { - case FALSE_KEYWORD_1: - case FALSE_KEYWORD_2: - return false; - case TRUE_KEYWORD_1: - case TRUE_KEYWORD_2: - return true; - default: - return value; - } -} - -function covertValuesToHashes(source) { - var clonedSource = override(source, {}); - var level; - var i; - - for (i = 0; i <= 2; i++) { - level = '' + i; - - if (level in clonedSource && (clonedSource[level] === undefined || clonedSource[level] === false)) { - delete clonedSource[level]; - } - - if (level in clonedSource && clonedSource[level] === true) { - clonedSource[level] = {}; - } - - if (level in clonedSource && typeof clonedSource[level] == 'string') { - clonedSource[level] = covertToHash(clonedSource[level], level); - } - } - - return clonedSource; -} - -function covertToHash(asString, level) { - return asString - .split(OPTION_SEPARATOR) - .reduce(function(accumulator, directive) { - var parts = directive.split(OPTION_VALUE_SEPARATOR); - var name = parts[0]; - var value = parts[1]; - var normalizedValue = normalizeValue(value); - - if (ALL_KEYWORD_1 == name || ALL_KEYWORD_2 == name) { - accumulator = override(accumulator, defaults(level, normalizedValue)); - } else { - accumulator[name] = normalizedValue; - } - - return accumulator; - }, {}); -} - -module.exports = { - OptimizationLevel: OptimizationLevel, - optimizationLevelFrom: optimizationLevelFrom -}; diff --git a/node_modules/clean-css/lib/options/plugins.js b/node_modules/clean-css/lib/options/plugins.js deleted file mode 100644 index ddec9d92..00000000 --- a/node_modules/clean-css/lib/options/plugins.js +++ /dev/null @@ -1,25 +0,0 @@ -function pluginsFrom(plugins) { - var flatPlugins = { - level1Value: [], - level1Property: [], - level2Block: [] - }; - - plugins = plugins || []; - - flatPlugins.level1Value = plugins - .map(function(plugin) { return plugin.level1 && plugin.level1.value; }) - .filter(function(plugin) { return plugin != null; }); - - flatPlugins.level1Property = plugins - .map(function(plugin) { return plugin.level1 && plugin.level1.property; }) - .filter(function(plugin) { return plugin != null; }); - - flatPlugins.level2Block = plugins - .map(function(plugin) { return plugin.level2 && plugin.level2.block; }) - .filter(function(plugin) { return plugin != null; }); - - return flatPlugins; -} - -module.exports = pluginsFrom; diff --git a/node_modules/clean-css/lib/options/rebase-to.js b/node_modules/clean-css/lib/options/rebase-to.js deleted file mode 100644 index 134b4a38..00000000 --- a/node_modules/clean-css/lib/options/rebase-to.js +++ /dev/null @@ -1,7 +0,0 @@ -var path = require('path'); - -function rebaseToFrom(option) { - return option ? path.resolve(option) : process.cwd(); -} - -module.exports = rebaseToFrom; diff --git a/node_modules/clean-css/lib/options/rebase.js b/node_modules/clean-css/lib/options/rebase.js deleted file mode 100644 index a3e60c4e..00000000 --- a/node_modules/clean-css/lib/options/rebase.js +++ /dev/null @@ -1,10 +0,0 @@ -function rebaseFrom(rebaseOption, rebaseToOption) { - if (undefined !== rebaseToOption) { - return true; - } if (undefined === rebaseOption) { - return false; - } - return !!rebaseOption; -} - -module.exports = rebaseFrom; diff --git a/node_modules/clean-css/lib/options/rounding-precision.js b/node_modules/clean-css/lib/options/rounding-precision.js deleted file mode 100644 index 3de62a84..00000000 --- a/node_modules/clean-css/lib/options/rounding-precision.js +++ /dev/null @@ -1,88 +0,0 @@ -var override = require('../utils/override'); - -var INTEGER_PATTERN = /^\d+$/; - -var ALL_UNITS = ['*', 'all']; -var DEFAULT_PRECISION = 'off'; // all precision changes are disabled -var DIRECTIVES_SEPARATOR = ','; // e.g. *=5,px=3 -var DIRECTIVE_VALUE_SEPARATOR = '='; // e.g. *=5 - -function roundingPrecisionFrom(source) { - return override(defaults(DEFAULT_PRECISION), buildPrecisionFrom(source)); -} - -function defaults(value) { - return { - ch: value, - cm: value, - em: value, - ex: value, - in: value, - mm: value, - pc: value, - pt: value, - px: value, - q: value, - rem: value, - vh: value, - vmax: value, - vmin: value, - vw: value, - '%': value - }; -} - -function buildPrecisionFrom(source) { - if (source === null || source === undefined) { - return {}; - } - - if (typeof source == 'boolean') { - return {}; - } - - if (typeof source == 'number' && source == -1) { - return defaults(DEFAULT_PRECISION); - } - - if (typeof source == 'number') { - return defaults(source); - } - - if (typeof source == 'string' && INTEGER_PATTERN.test(source)) { - return defaults(parseInt(source)); - } - - if (typeof source == 'string' && source == DEFAULT_PRECISION) { - return defaults(DEFAULT_PRECISION); - } - - if (typeof source == 'object') { - return source; - } - - return source - .split(DIRECTIVES_SEPARATOR) - .reduce(function(accumulator, directive) { - var directiveParts = directive.split(DIRECTIVE_VALUE_SEPARATOR); - var name = directiveParts[0]; - var value = parseInt(directiveParts[1]); - - if (Number.isNaN(value) || value == -1) { - value = DEFAULT_PRECISION; - } - - if (ALL_UNITS.indexOf(name) > -1) { - accumulator = override(accumulator, defaults(value)); - } else { - accumulator[name] = value; - } - - return accumulator; - }, {}); -} - -module.exports = { - DEFAULT: DEFAULT_PRECISION, - roundingPrecisionFrom: roundingPrecisionFrom -}; |
