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

Function flatten

code/styling/public/app.js:19853–19880  ·  view source on GitHub ↗
(chunks, executionContext)

Source from the content-addressed store, hash-verified

19851};
19852
19853var flatten = function flatten(chunks, executionContext) {
19854 return chunks.reduce(function (ruleSet, chunk) {
19855 /* Remove falsey values */
19856 if (chunk === undefined || chunk === null || chunk === false || chunk === '') {
19857 return ruleSet;
19858 }
19859 /* Flatten ruleSet */
19860 if (Array.isArray(chunk)) {
19861 return [].concat(ruleSet, flatten(chunk, executionContext));
19862 }
19863
19864 /* Handle other components */
19865 if (chunk.hasOwnProperty('styledComponentId')) {
19866 // $FlowFixMe not sure how to make this pass
19867 return [].concat(ruleSet, ['.' + chunk.styledComponentId]);
19868 }
19869
19870 /* Either execute or defer the function */
19871 if (typeof chunk === 'function') {
19872 return executionContext ? ruleSet.concat.apply(ruleSet, flatten([chunk(executionContext)], executionContext)) : ruleSet.concat(chunk);
19873 }
19874
19875 /* Handle objects */
19876 return ruleSet.concat(
19877 // $FlowFixMe have to add %checks somehow to isPlainObject
19878 isPlainObject(chunk) ? objToCss(chunk) : chunk.toString());
19879 }, []);
19880};
19881
19882//
19883// NOTE: This stylis instance is only used to split rules from SSR'd style tags

Callers 1

app.jsFile · 0.85

Calls 2

isPlainObjectFunction · 0.85
objToCssFunction · 0.85

Tested by

no test coverage detected