forked from sjbarag/brs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(interp): Preventing multiple calls for dot-chained methods (#22)
* Preventing multiple calls for dot-chained methods * Fixed `prettier` issue
- Loading branch information
Showing
6 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ lib/ | |
types/ | ||
node_modules/ | ||
.vscode/ | ||
coverage/ | ||
coverage/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
sub main() | ||
a = [" 1 ", " 2 ", " 3 "] | ||
b = a.pop().trim().toInt() | ||
print "removed number '" + b.toStr() + "' from array, remaining " + a.count().toStr() | ||
m.__result = "bad" | ||
immediatePromise("foo").then(sub(result) | ||
print "promise-like resolved to '" + result + "'" | ||
end sub) | ||
print "optional chaining " + testOptionalChaining() | ||
end sub | ||
|
||
' A simple promise-like function that immediately resolves to the provided value. | ||
' You probably don't want to use it in production. | ||
' @param {*} val the value this promise-like should immediately resolve to | ||
' @returns {AssociativeArray} an associative array contianing a `then` property, used to chain | ||
' promise-like constructs. | ||
function immediatePromise(val as dynamic) as object | ||
return { | ||
__result: val | ||
then: sub(resolved as function) | ||
resolved(m.__result) | ||
end sub | ||
} | ||
end function | ||
|
||
function testOptionalChaining() | ||
responseData = { | ||
data:{ | ||
metricsData:{ | ||
addOnsStepStart : "works" | ||
} | ||
} | ||
} | ||
result = responseData?.data.metricsData?.addOnsStepStart | ||
return result | ||
end function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters