[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#68941] [PATCH v2 02/44] guix: build-system: node: Add node-is-type-
From: |
Nicolas Graves |
Subject: |
[bug#68941] [PATCH v2 02/44] guix: build-system: node: Add node-is-type-object helper. |
Date: |
Thu, 8 Feb 2024 01:24:25 +0100 |
* guix/build-system/node.scm (node-is-type-object): Add function.
Change-Id: I7027aff3b314cd999798afd8c11dc90ef7c6e43c
---
guix/build-system/node.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index a16627e68c..3f68cd3f21 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -35,8 +35,22 @@ (define-module (guix build-system node)
node-build
node-build-system
+ node-is-type-object
trivial-node-package))
+(define* (node-is-type-object type #:optional (type-exists? #t))
+ "Helper for node packages replacement. This is actual code factorized from
+the packages it replaces, use with caution. It doesn't apply to all
+javascript types."
+ (string-append
+ "function(value) {"
+ (if type-exists?
+ (string-append
+ "if (typeof value === '" (string-downcase type) "') {return true;} ")
+ "")
+ "if (value === null || typeof value !== 'object') {return false;}
+ return Object.prototype.toString.call(value) === '[object " type "]';}"))
+
(define* (trivial-node-package node-name version replacement description
#:key (propagated-inputs '())
(mozilla-doclink #f) ;maybe-string
--
2.41.0
- [bug#68941] [PATCH 37/44] gnu: Add node-which-boxed-primitive., (continued)
- [bug#68941] [PATCH 37/44] gnu: Add node-which-boxed-primitive., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 38/44] gnu: Add node-which-collection., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 40/44] gnu: Add node-is-date-object., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 42/44] gnu: Add node-object-keys., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 43/44] gnu: Add node-regexp-prototype-flags., Nicolas Graves, 2024/02/05
- [bug#68941] [PATCH 01/44] guix: build-system: node: Add node-trivial-package helper., Liliana Marie Prikler, 2024/02/06
[bug#68941] [PATCH v2 01/44] guix: build-system: node: Add trivial-node-package helper., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 03/44] gnu: Add node-function-bind., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 02/44] guix: build-system: node: Add node-is-type-object helper.,
Nicolas Graves <=
- [bug#68941] [PATCH v2 04/44] gnu: Add node-has-proto., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 05/44] gnu: Add node-has., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 06/44] gnu: Add node-has-symbols., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 07/44] gnu: Add node-has-tostringtag., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 08/44] gnu: Add node-is-callable., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 09/44] gnu: Add node-get-intrinsic., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 19/44] gnu: Add node-is-weakmap., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 10/44] gnu: Add node-is-symbol., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 16/44] gnu: Add node-is-regex., Nicolas Graves, 2024/02/07
- [bug#68941] [PATCH v2 14/44] gnu: Add node-call-bind., Nicolas Graves, 2024/02/07