@nxtedition/lib 14.0.0-alpha.1 → 14.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "14.0.0-alpha.1",
3
+ "version": "14.0.0-alpha.2",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "files": [
@@ -125,6 +125,7 @@ module.exports = (options) => {
125
125
  }
126
126
 
127
127
  return {
128
+ input: str,
128
129
  pre: str.slice(0, templateStart),
129
130
  type,
130
131
  body: str.slice(bodyStart, bodyEnd),
@@ -132,39 +133,41 @@ module.exports = (options) => {
132
133
  }
133
134
  }
134
135
 
135
- const compileStringTemplateLazy = weakCache(function compileStringTemplatLazy(str) {
136
- if (!fp.isString(str)) {
137
- throw new Error('invalid argument')
138
- }
139
-
140
- const match = inner(str)
136
+ const _compileStringTemplate = weakCache(
137
+ function _compileStringTemplate(match) {
138
+ const { pre, type, body, post } = match
141
139
 
142
- if (!match) {
143
- return null
144
- }
140
+ const compileExpression = compilers[type]
141
+ if (!compileExpression) {
142
+ throw new Error('unknown expression type')
143
+ }
145
144
 
146
- const { pre, type, body, post } = match
145
+ const expr = compileExpression(body)
147
146
 
148
- const compileExpression = compilers[type]
149
- if (!compileExpression) {
150
- throw new Error('unknown expression type')
151
- }
147
+ if (!pre && !post) {
148
+ return expr
149
+ }
152
150
 
153
- const expr = compileExpression(body)
151
+ return (...args) =>
152
+ expr(...args).pipe(
153
+ rx.switchMap((body) =>
154
+ compileStringTemplate(`${pre}${stringify(body, type !== 'js')}${post}`)(...args)
155
+ )
156
+ )
157
+ },
158
+ (match) => match.input
159
+ )
154
160
 
155
- if (!pre && !post) {
156
- return expr
161
+ function compileStringTemplateLazy(str) {
162
+ if (!fp.isString(str)) {
163
+ throw new Error('invalid argument')
157
164
  }
158
165
 
159
- return (...args) =>
160
- expr(...args).pipe(
161
- rx.switchMap((body) =>
162
- compileStringTemplate(`${pre}${stringify(body, type !== 'js')}${post}`)(...args)
163
- )
164
- )
165
- })
166
+ const match = inner(str)
167
+ return match ? _compileStringTemplate(str, match) : null
168
+ }
166
169
 
167
- const compileStringTemplate = function compileStringTemplate(str) {
170
+ function compileStringTemplate(str) {
168
171
  return compileStringTemplateLazy(str) ?? (() => rxjs.of(str))
169
172
  }
170
173