@nxtedition/lib 23.15.3 → 23.15.4

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": "23.15.3",
3
+ "version": "23.15.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -22,3 +22,15 @@ test('nexpression', async () => {
22
22
 
23
23
  assert.strictEqual(await compiler.resolveTemplate('{{ foo }}', { foo: 'bar' }), 'bar')
24
24
  })
25
+
26
+ test('pipe short-circuit', async () => {
27
+ const compiler = makeTemplateCompiler({
28
+ ds: {},
29
+ logger: console,
30
+ })
31
+
32
+ assert.strictEqual(
33
+ await compiler.resolveTemplate('{{#js _($.id, x => x + "ASD") }}', { foo: 'bar' }),
34
+ undefined,
35
+ )
36
+ })
@@ -244,6 +244,15 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
244
244
  this._wrap = null
245
245
  this._suspended = false
246
246
  this._errored = false
247
+ this._globalThis = {
248
+ fp: null,
249
+ moment: null,
250
+ Timecode: null,
251
+ datefns: null,
252
+ JSON5: null,
253
+ $: null,
254
+ nxt: null,
255
+ }
247
256
 
248
257
  if (rxjs.isObservable(args)) {
249
258
  this._subscription = args.subscribe({
@@ -361,15 +370,13 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
361
370
  throw new Error('expression is already suspended')
362
371
  }
363
372
 
364
- const savedThis = {
365
- fp: globalThis.fp,
366
- moment: globalThis.moment,
367
- Timecode: globalThis.Timecode,
368
- datefns: globalThis.datefns,
369
- JSON5: globalThis.JSON5,
370
- $: globalThis.$,
371
- nxt: globalThis.nxt,
372
- }
373
+ this._globalThis.fp = globalThis.fp
374
+ this._globalThis.moment = globalThis.moment
375
+ this._globalThis.Timecode = globalThis.Timecode
376
+ this._globalThis.datefns = globalThis.datefns
377
+ this._globalThis.JSON5 = globalThis.JSON5
378
+ this._globalThis.$ = globalThis.$
379
+ this._globalThis.nxt = globalThis.nxt
373
380
 
374
381
  let value
375
382
  try {
@@ -387,14 +394,13 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
387
394
  // - Use https://github.com/tc39/proposal-shadowrealm?
388
395
  value = this._script()
389
396
  } finally {
390
- globalThis.fp = savedThis.fp
391
- globalThis._ = savedThis._
392
- globalThis.moment = savedThis.moment
393
- globalThis.Timecode = savedThis.Timecode
394
- globalThis.datefns = savedThis.datefns
395
- globalThis.JSON5 = savedThis.JSON5
396
- globalThis.$ = savedThis.$
397
- globalThis.nxt = savedThis.nxt
397
+ globalThis.fp = this._globalThis.fp
398
+ globalThis.moment = this._globalThis.moment
399
+ globalThis.Timecode = this._globalThis.Timecode
400
+ globalThis.datefns = this._globalThis.datefns
401
+ globalThis.JSON5 = this._globalThis.JSON5
402
+ globalThis.$ = this._globalThis.$
403
+ globalThis.nxt = this._globalThis.nxt
398
404
  }
399
405
 
400
406
  this._errored = false
@@ -624,10 +630,12 @@ export default function ({ ds, proxify, compiler, logger, platform }) {
624
630
  script = new Function(
625
631
  transform(`
626
632
  const _ = (value, ...fns) => {
627
- for (const fn of fns) {
628
- value = fn(value)
629
- if (value == null) {
630
- return value
633
+ if (value != null) {
634
+ for (const fn of fns) {
635
+ value = fn(value)
636
+ if (value == null) {
637
+ return value
638
+ }
631
639
  }
632
640
  }
633
641
  return value