| Index: src/js/string.js
|
| diff --git a/src/js/string.js b/src/js/string.js
|
| index e0ee7adef769f28a9499a44642510fa4df84dda3..28e74a50cb1fb28af37f9ec63aef39d031fcd423 100644
|
| --- a/src/js/string.js
|
| +++ b/src/js/string.js
|
| @@ -433,6 +433,34 @@
|
| %FunctionSetLength(StringEndsWith, 1);
|
|
|
|
|
| +// ES6 draft 04-05-14, section 21.1.3.6
|
| +function StringIncludes(searchString, position) { // length == 1
|
| + CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
|
| +
|
| + var string = TO_STRING(this);
|
| +
|
| + if (IsRegExp(searchString)) {
|
| + throw %make_type_error(kFirstArgumentNotRegExp, "String.prototype.includes");
|
| + }
|
| +
|
| + searchString = TO_STRING(searchString);
|
| + var pos = TO_INTEGER(position);
|
| +
|
| + var stringLength = string.length;
|
| + if (pos < 0) pos = 0;
|
| + if (pos > stringLength) pos = stringLength;
|
| + var searchStringLength = searchString.length;
|
| +
|
| + if (searchStringLength + pos > stringLength) {
|
| + return false;
|
| + }
|
| +
|
| + return %StringIndexOf(string, searchString, pos) !== -1;
|
| +}
|
| +
|
| +%FunctionSetLength(StringIncludes, 1);
|
| +
|
| +
|
| // ES6 Draft 05-22-2014, section 21.1.3.3
|
| function StringCodePointAt(pos) {
|
| CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt");
|
| @@ -491,6 +519,7 @@
|
| "codePointAt", StringCodePointAt,
|
| "concat", StringConcat,
|
| "endsWith", StringEndsWith,
|
| + "includes", StringIncludes,
|
| "match", StringMatchJS,
|
| "repeat", StringRepeat,
|
| "replace", StringReplace,
|
|
|