Spaces:
Sleeping
Sleeping
Download frontend/node_modules/@emotion/babel-plugin/src/utils/strings.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40emotion/babel-plugin/src/utils/strings.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/@emotion/babel-plugin/src/utils/strings.js
-
curl -L -o strings.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40emotion/babel-plugin/src/utils/strings.js
1.95 kB
| import { | |
| getTypeScriptMakeTemplateObjectPath, | |
| isTaggedTemplateTranspiledByBabel | |
| } from './transpiled-output-utils' | |
| export const appendStringReturningExpressionToArguments = ( | |
| t, | |
| path, | |
| expression | |
| ) => { | |
| let lastIndex = path.node.arguments.length - 1 | |
| let last = path.node.arguments[lastIndex] | |
| if (t.isStringLiteral(last)) { | |
| if (typeof expression === 'string') { | |
| path.node.arguments[lastIndex].value += expression | |
| } else { | |
| path.node.arguments[lastIndex] = t.binaryExpression('+', last, expression) | |
| } | |
| } else { | |
| const makeTemplateObjectCallPath = getTypeScriptMakeTemplateObjectPath(path) | |
| if (makeTemplateObjectCallPath) { | |
| makeTemplateObjectCallPath.get('arguments').forEach(argPath => { | |
| const elements = argPath.get('elements') | |
| const lastElement = elements[elements.length - 1] | |
| if (typeof expression === 'string') { | |
| lastElement.replaceWith( | |
| t.stringLiteral(lastElement.node.value + expression) | |
| ) | |
| } else { | |
| lastElement.replaceWith( | |
| t.binaryExpression('+', lastElement.node, t.cloneNode(expression)) | |
| ) | |
| } | |
| }) | |
| } else if (!isTaggedTemplateTranspiledByBabel(path)) { | |
| if (typeof expression === 'string') { | |
| path.node.arguments.push(t.stringLiteral(expression)) | |
| } else { | |
| path.node.arguments.push(expression) | |
| } | |
| } | |
| } | |
| } | |
| export const joinStringLiterals = (expressions /*: Array<*> */, t) => { | |
| return expressions.reduce((finalExpressions, currentExpression, i) => { | |
| if (!t.isStringLiteral(currentExpression)) { | |
| finalExpressions.push(currentExpression) | |
| } else if ( | |
| t.isStringLiteral(finalExpressions[finalExpressions.length - 1]) | |
| ) { | |
| finalExpressions[finalExpressions.length - 1].value += | |
| currentExpression.value | |
| } else { | |
| finalExpressions.push(currentExpression) | |
| } | |
| return finalExpressions | |
| }, []) | |
| } | |