diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-05-19 23:11:17 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-05-19 23:11:17 +0200 |
commit | a5b308da13855cc4476f561e828bb9d90ee72167 (patch) | |
tree | 5f289528d555a2b7f2906c72591773814d6e0ea4 /js/src/jsarray.cpp | |
parent | 9ca07f93b5f7832f4e10c114d25a6d005559d3f7 (diff) | |
download | uxp-a5b308da13855cc4476f561e828bb9d90ee72167.tar.gz |
Implement array.flat and array.flatMap
Self-hosted implementation that adds both functions and adds them to
@@unscopables as specced in ES2019.
Resolves #1095
Diffstat (limited to 'js/src/jsarray.cpp')
-rw-r--r-- | js/src/jsarray.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 7a67c00954..3b4c957dc8 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -3169,6 +3169,11 @@ static const JSFunctionSpec array_methods[] = { /* ES7 additions */ JS_SELF_HOSTED_FN("includes", "ArrayIncludes", 2,0), + + /* ES2019 additions */ + JS_SELF_HOSTED_FN("flat", "ArrayFlat", 0,0), + JS_SELF_HOSTED_FN("flatMap", "ArrayFlatMap", 1,0), + JS_FS_END }; @@ -3333,6 +3338,8 @@ array_proto_finish(JSContext* cx, JS::HandleObject ctor, JS::HandleObject proto) !DefineProperty(cx, unscopables, cx->names().fill, value) || !DefineProperty(cx, unscopables, cx->names().find, value) || !DefineProperty(cx, unscopables, cx->names().findIndex, value) || + !DefineProperty(cx, unscopables, cx->names().flat, value) || + !DefineProperty(cx, unscopables, cx->names().flatMap, value) || !DefineProperty(cx, unscopables, cx->names().includes, value) || !DefineProperty(cx, unscopables, cx->names().keys, value) || !DefineProperty(cx, unscopables, cx->names().values, value)) |