From 050c3e6243d5c669eba5da5b8379c36f88b47f2a Mon Sep 17 00:00:00 2001 From: Michael Hohn Date: Wed, 6 Dec 2023 16:59:09 -0800 Subject: [PATCH] wip: illustrate puzzling FP --- source/sample-utility-0.js | 2 +- source/sample-utility-1.js | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/sample-utility-0.js b/source/sample-utility-0.js index 166e2d4..f2d9dd2 100644 --- a/source/sample-utility-0.js +++ b/source/sample-utility-0.js @@ -32,7 +32,7 @@ SampleUtility.prototype = Object.extendsObject(Processor, { } } - if (ua == magicval) { + if (ua === magicval) { 1 } else { if (ua.safeToWrite()) { diff --git a/source/sample-utility-1.js b/source/sample-utility-1.js index 01b3632..31d3657 100644 --- a/source/sample-utility-1.js +++ b/source/sample-utility-1.js @@ -1,8 +1,18 @@ -var SampleUtility = function () { +function sus() { var value = this.getParameter('value'); - var ua = new GR('users'); - ua.query(); + var ua = new GR('ust'); + + if (funnyvar) { + nothing() + } + else { + nothing() + if (ua.safeToWrite()) { + ua.setValue('status', value); + ua.update(); + } + } if (!ua.hasNext()) { ua.initialize(); @@ -11,7 +21,11 @@ var SampleUtility = function () { } else { ua.next(); - ua.setValue('status', value); - ua.update(); + ua.setValue('status', value); + ua.update(); // unsafe + if (ua.safeToWrite()) { + ua.setValue('status', value); // safe + ua.update(); + } } }