MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / compile

Function compile

code/styling/public/app.js:22248–22962  ·  view source on GitHub ↗

* Compile * * @param {Array } parent * @param {Array } current * @param {string} body * @param {number} id * @param {number} depth * @return {string}

(parent, current, body, id, depth)

Source from the content-addressed store, hash-verified

22246 * @return {string}
22247 */
22248 function compile (parent, current, body, id, depth) {
22249 var bracket = 0 /* brackets [] */
22250 var comment = 0 /* comments /* // or /* */
22251 var parentheses = 0 /* functions () */
22252 var quote = 0 /* quotes '', "" */
22253
22254 var first = 0 /* first character code */
22255 var second = 0 /* second character code */
22256 var code = 0 /* current character code */
22257 var tail = 0 /* previous character code */
22258 var trail = 0 /* character before previous code */
22259 var peak = 0 /* previous non-whitespace code */
22260
22261 var counter = 0 /* count sequence termination */
22262 var context = 0 /* track current context */
22263 var atrule = 0 /* track @at-rule context */
22264 var pseudo = 0 /* track pseudo token index */
22265 var caret = 0 /* current character index */
22266 var format = 0 /* control character formating context */
22267 var insert = 0 /* auto semicolon insertion */
22268 var invert = 0 /* inverted selector pattern */
22269 var length = 0 /* generic length address */
22270 var eof = body.length /* end of file(length) */
22271 var eol = eof - 1 /* end of file(characters) */
22272
22273 var char = '' /* current character */
22274 var chars = '' /* current buffer of characters */
22275 var child = '' /* next buffer of characters */
22276 var out = '' /* compiled body */
22277 var children = '' /* compiled children */
22278 var flat = '' /* compiled leafs */
22279 var selector /* generic selector address */
22280 var result /* generic address */
22281
22282 // ...build body
22283 while (caret < eof) {
22284 code = body.charCodeAt(caret)
22285
22286 // eof varient
22287 if (caret === eol) {
22288 // last character + noop context, add synthetic padding for noop context to terminate
22289 if (comment + quote + parentheses + bracket !== 0) {
22290 if (comment !== 0) {
22291 code = comment === FOWARDSLASH ? NEWLINE : FOWARDSLASH
22292 }
22293
22294 quote = parentheses = bracket = 0
22295 eof++
22296 eol++
22297 }
22298 }
22299
22300 if (comment + quote + parentheses + bracket === 0) {
22301 // eof varient
22302 if (caret === eol) {
22303 if (format > 0) {
22304 chars = chars.replace(formatptn, '')
22305 }

Callers 1

stylisFunction · 0.85

Calls 5

selectFunction · 0.85
vendorFunction · 0.85
propertyFunction · 0.85
isolateFunction · 0.85
proxyFunction · 0.70

Tested by

no test coverage detected