From 1d04203e8961fad185fa5dd05409cbc76f3b21bb Mon Sep 17 00:00:00 2001
From: belfz <marcinbar1@gmail.com>
Date: Sun, 1 Jul 2018 23:50:10 +0200
Subject: [PATCH] implements Object.values() binding

---
 src/js.rs                      |  9 +++++++++
 tests/all/js_globals/Object.rs | 29 +++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/src/js.rs b/src/js.rs
index f6a110d7..f18ab446 100644
--- a/src/js.rs
+++ b/src/js.rs
@@ -832,6 +832,15 @@ extern "C" {
     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf
     #[wasm_bindgen(method, js_name = valueOf)]
     pub fn value_of(this: &Object) -> Object;
+
+    /// The Object.values() method returns an array of a given object's
+    /// own enumerable property values, in the same order as that provided
+    /// by a for...in loop (the difference being that a for-in loop
+    /// enumerates properties in the prototype chain as well).
+    /// 
+    /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
+    #[wasm_bindgen(static_method_of = Object)]
+    pub fn values(object: &Object) -> Array;
 }
 
 // Set
diff --git a/tests/all/js_globals/Object.rs b/tests/all/js_globals/Object.rs
index 8787cf91..b3ceb312 100644
--- a/tests/all/js_globals/Object.rs
+++ b/tests/all/js_globals/Object.rs
@@ -368,3 +368,32 @@ fn value_of() {
         )
         .test()
 }
+
+#[test]
+fn values() {
+    project()
+        .file("src/lib.rs", r#"
+            #![feature(proc_macro, wasm_custom_section)]
+
+            extern crate wasm_bindgen;
+            use wasm_bindgen::prelude::*;
+            use wasm_bindgen::js;
+
+            #[wasm_bindgen]
+            pub fn values(obj: &js::Object) -> js::Array {
+                js::Object::values(&obj)
+            }
+        "#)
+        .file("test.ts", r#"
+            import * as assert from "assert";
+            import * as wasm from "./out";
+
+            export function test() {
+                const object = { foo: 'bar', baz: 'qux' };
+                const values = wasm.values(object);
+                assert.equal(values.length, 2);
+                assert.deepEqual(values.sort(), ['bar', 'qux']);
+            }
+        "#)
+        .test()
+}