From a4e76c785372fe91fd71f5ac721190cecf432942 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 23 Dec 2015 10:59:49 -0800 Subject: [PATCH] Provide toCYON for more built-in JavaScript types. --- libcycript.cy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libcycript.cy b/libcycript.cy index 79a1735..dd7e2ac 100644 --- a/libcycript.cy +++ b/libcycript.cy @@ -35,6 +35,12 @@ let $cy_set = function(object, properties) { }); }; +$cy_set(Boolean.prototype, { + toCYON: function() { + return `new Boolean(${this.toString()})`; + }, +}); + $cy_set(Date.prototype, { toCYON: function() { return `new ${this.constructor.name}(${this.toUTCString().toCYON()})`; @@ -52,6 +58,18 @@ $cy_set(Error.prototype, { }, }); +$cy_set(Number.prototype, { + toCYON: function() { + return `new Number(${this.toString()})`; + }, +}); + +$cy_set(RegExp.prototype, { + toCYON: function() { + return this.toString(); + }, +}); + let IsFile = function(path) { // XXX: this doesn't work on symlinks, but I don't want to fix stat :/ return access(path, F_OK) == 0 && access(path + '/', F_OK) == -1; -- 2.49.0