| let { list } = require('postcss') |
|
|
| |
| |
| |
| |
| module.exports.error = function (text) { |
| let err = new Error(text) |
| err.autoprefixer = true |
| throw err |
| } |
|
|
| |
| |
| |
| module.exports.uniq = function (array) { |
| return [...new Set(array)] |
| } |
|
|
| |
| |
| |
| module.exports.removeNote = function (string) { |
| if (!string.includes(' ')) { |
| return string |
| } |
|
|
| return string.split(' ')[0] |
| } |
|
|
| |
| |
| |
| module.exports.escapeRegexp = function (string) { |
| return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&') |
| } |
|
|
| |
| |
| |
| module.exports.regexp = function (word, escape = true) { |
| if (escape) { |
| word = this.escapeRegexp(word) |
| } |
| return new RegExp(`(^|[\\s,(])(${word}($|[\\s(,]))`, 'gi') |
| } |
|
|
| |
| |
| |
| module.exports.editList = function (value, callback) { |
| let origin = list.comma(value) |
| let changed = callback(origin, []) |
|
|
| if (origin === changed) { |
| return value |
| } |
|
|
| let join = value.match(/,\s*/) |
| join = join ? join[0] : ', ' |
| return changed.join(join) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| module.exports.splitSelector = function (selector) { |
| return list.comma(selector).map(i => { |
| return list.space(i).map(k => { |
| return k.split(/(?=\.|#)/g) |
| }) |
| }) |
| } |
|
|
| |
| |
| |
| |
| |
| module.exports.isPureNumber = function (value) { |
| if (typeof value === 'number') { |
| return true |
| } |
| if (typeof value === 'string') { |
| return /^[0-9]+$/.test(value) |
| } |
| return false |
| } |
|
|