From 19c5909587b77ab43a1d280eb364c3d04e48a21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Tue, 12 Nov 2024 12:09:50 +0100 Subject: [PATCH] Code optimization --- src/blog.coffee | 2 +- src/comment.coffee | 2 +- test/client_test.coffee | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blog.coffee b/src/blog.coffee index 19af54e..1dbf496 100644 --- a/src/blog.coffee +++ b/src/blog.coffee @@ -21,7 +21,7 @@ export class Blog # Returns a JSON representation of this object. toJSON: -> - map = blog: @url?.href ? "" + map = blog: if @url? then @url.href else "" map.blog_charset = @charset if @charset map.blog_lang = Array.from(@languages).join "," if @languages.size map diff --git a/src/comment.coffee b/src/comment.coffee index 91ae3fd..a4e2d9a 100644 --- a/src/comment.coffee +++ b/src/comment.coffee @@ -49,7 +49,7 @@ export class Comment # Returns a JSON representation of this object. toJSON: -> - map = @author?.toJSON() ? {} + map = @author?.toJSON() or {} map.comment_content = @content if @content map.comment_context = @context if @context.length map.comment_date_gmt = @date.toJSON() if @date diff --git a/test/client_test.coffee b/test/client_test.coffee index d30547d..3ce7a3d 100644 --- a/test/client_test.coffee +++ b/test/client_test.coffee @@ -6,7 +6,7 @@ import {describe, it} from "node:test" # Tests the features of the `Client` class. describe "Client", -> # The client used to query the remote API. - client = new Client env.AKISMET_API_KEY ? "", new Blog(url: "https://github.com/cedx/akismet.js"), isTest: yes + client = new Client env.AKISMET_API_KEY or "", new Blog(url: "https://github.com/cedx/akismet.js"), isTest: yes # A comment with content marked as ham. ham = new Comment