From e4dcb8f85e226161f466c50b003c875dee5263ca Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 8 Jun 2018 14:22:18 -0700 Subject: [PATCH] Add associated constants for common JS values --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 055e7e3b..5905adc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,18 @@ const JSIDX_FALSE: u32 = 6; const JSIDX_RESERVED: u32 = 8; impl JsValue { + /// The `null` JS value constant. + pub const NULL: JsValue = JsValue { idx: JSIDX_NULL }; + + /// The `undefined` JS value constant. + pub const UNDEFINED: JsValue = JsValue { idx: JSIDX_UNDEFINED }; + + /// The `true` JS value constant. + pub const TRUE: JsValue = JsValue { idx: JSIDX_TRUE }; + + /// The `false` JS value constant. + pub const FALSE: JsValue = JsValue { idx: JSIDX_FALSE }; + /// Creates a new JS value which is a string. /// /// The utf-8 string provided is copied to the JS heap and the string will