Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101517851
processor.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 11, 05:27
Size
1 KB
Mime Type
text/x-c++
Expires
Thu, Feb 13, 05:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24168407
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
processor.js
View Options
'use strict'
let NoWorkResult = require('./no-work-result')
let LazyResult = require('./lazy-result')
let Document = require('./document')
let Root = require('./root')
class Processor {
constructor(plugins = []) {
this.version = '8.4.21'
this.plugins = this.normalize(plugins)
}
use(plugin) {
this.plugins = this.plugins.concat(this.normalize([plugin]))
return this
}
process(css, opts = {}) {
if (
this.plugins.length === 0 &&
typeof opts.parser === 'undefined' &&
typeof opts.stringifier === 'undefined' &&
typeof opts.syntax === 'undefined'
) {
return new NoWorkResult(this, css, opts)
} else {
return new LazyResult(this, css, opts)
}
}
normalize(plugins) {
let normalized = []
for (let i of plugins) {
if (i.postcss === true) {
i = i()
} else if (i.postcss) {
i = i.postcss
}
if (typeof i === 'object' && Array.isArray(i.plugins)) {
normalized = normalized.concat(i.plugins)
} else if (typeof i === 'object' && i.postcssPlugin) {
normalized.push(i)
} else if (typeof i === 'function') {
normalized.push(i)
} else if (typeof i === 'object' && (i.parse || i.stringify)) {
if (process.env.NODE_ENV !== 'production') {
throw new Error(
'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
'one of the syntax/parser/stringifier options as outlined ' +
'in your PostCSS runner documentation.'
)
}
} else {
throw new Error(i + ' is not a PostCSS plugin')
}
}
return normalized
}
}
module.exports = Processor
Processor.default = Processor
Root.registerProcessor(Processor)
Document.registerProcessor(Processor)
Event Timeline
Log In to Comment