diff --git a/CHANGELOG.md b/CHANGELOG.md index f37882558..71207fa20 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## 1.0.0-beta.19 +### Breaking +* `get-environment-variables` and `get-environment-variable` returns nil and undefined in the browser ### Features * add `vector-for-each` and `vector-copy!` function from R7RS * add `string-for-each`, `string-downcase`, and `string-upcase` from R7RS diff --git a/README.md b/README.md index bce366f98..45c8d05fe 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/lips_lang)](https://twitter.com/lips_lang) -[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) +[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18.1-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) ![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete) [![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7951433cc9ff158c3701ffea07e0f004)](https://coveralls.io/github/jcubic/lips?branch=devel) diff --git a/dist/std.min.scm b/dist/std.min.scm index 4996fb2eb..f6caf52d6 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -382,8 +382,8 @@ (define (error-object? obj) "(error-object? obj)\u000A\u000AChecks if object is of Error object thrown by error function." (instanceof lips.Error obj)) (define (error-object-message obj) "(error-object-message error-object)\u000A\u000AReturns the message encapsulated by error-object." (if (error-object? obj) obj.message)) (define (error-object-irritants obj) "(error-object-irritants error-object)\u000A\u000AReturns a list of the irritants encapsulated by error-object." (if (error-object? obj) obj.args)) -(define (get-environment-variables) "(get-environment-variables)\u000A\u000AReturns all process environment variables as an alist. This function throws exception\u000Awhen called in browser." (if (eq? self window) (throw "get-environment-variables: Node.js only function") (object->alist process.env))) -(define (get-environment-variable name) "(get-environment-variable name)\u000A\u000AReturns given environment variable. This function throws exception\u000Awhen called in browser." (. process.env name)) +(define (get-environment-variables) "(get-environment-variables)\u000A\u000AReturns all process environment variables as an alist. This function returns\u000Aan empty list when called in the browser." (if (eq? self window) () (object->alist process.env))) +(define (get-environment-variable name) "(get-environment-variable name)\u000A\u000AReturns given environment variable. This function returns undefined\u000Awhen called in the browser." (if (not (eq? self window)) (. process.env name))) (define (current-second) "(current-second)\u000A\u000AFunctionn return exact integer of the seconds since January 1, 1970" (inexact->exact (truncate (/ (+ %%start-jiffy (current-jiffy)) (jiffies-per-second))))) (define %%start-jiffy (truncate (* 1000 (if (eq? self window) performance.timing.navigationStart performance.timeOrigin))) "Constant value that indicates start jiffy of the scheme process.") (define (current-jiffy) "(current-jiffy)\u000A\u000AReturn current jiffy. In LIPS is jiffy since start of the process.\u000AYou can divide this value by (jiffies-per-second) to get seconds since\u000Astart of the process. And you can add %%start-jiffy to get jiffy since\u000AJanuary 1, 1970." (inexact->exact (truncate (* (performance.now) 1000)))) diff --git a/dist/std.scm b/dist/std.scm index b2fcae247..f1a658a94 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -5058,19 +5058,20 @@ (define (get-environment-variables) "(get-environment-variables) - Returns all process environment variables as an alist. This function throws exception - when called in browser." + Returns all process environment variables as an alist. This function returns + an empty list when called in the browser." (if (eq? self window) - (throw "get-environment-variables: Node.js only function") + nil (object->alist process.env))) ;; ----------------------------------------------------------------------------- (define (get-environment-variable name) "(get-environment-variable name) - Returns given environment variable. This function throws exception - when called in browser." - (. process.env name)) + Returns given environment variable. This function returns undefined + when called in the browser." + (if (not (eq? self window)) + (. process.env name))) ;; ----------------------------------------------------------------------------- (define (current-second) diff --git a/dist/std.xcb b/dist/std.xcb index 8fe57c82c..09a59264d 100644 Binary files a/dist/std.xcb and b/dist/std.xcb differ diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 42d438d8b..6e194e309 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -1790,19 +1790,20 @@ (define (get-environment-variables) "(get-environment-variables) - Returns all process environment variables as an alist. This function throws exception - when called in browser." + Returns all process environment variables as an alist. This function returns + an empty list when called in the browser." (if (eq? self window) - (throw "get-environment-variables: Node.js only function") + nil (object->alist process.env))) ;; ----------------------------------------------------------------------------- (define (get-environment-variable name) "(get-environment-variable name) - Returns given environment variable. This function throws exception - when called in browser." - (. process.env name)) + Returns given environment variable. This function returns undefined + when called in the browser." + (if (not (eq? self window)) + (. process.env name))) ;; ----------------------------------------------------------------------------- (define (current-second)