Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concat(), repeat(), slice() and all "searchString" based String prototype methods (#13) #31

Merged
merged 10 commits into from
Jun 30, 2019

Conversation

calluw
Copy link
Contributor

@calluw calluw commented Jun 24, 2019

PR for implementation of some of the prototype methods on the String object:

The methods which return string return string values not string objects. Currently in Boa these methods are only available on String objects created directly (via new String(...)), not string literals/values.

This will move the concat, repeat, slice, endsWith, includes, indexOf, lastIndexOf and startsWith entries on issue #13 to done.

Example usage:

let a = new String("Hello ");
let b = a.concat("world!");
b;

Gives:

[src/bin/bin.rs:7] exec(buffer) = "Hello world!"

Test JS:

let a  = new String("Hello world!");
console.log(a.indexOf("o"));
console.log(a.indexOf("warld"));
console.log(a.indexOf("ello", 3));
console.log(a.lastIndexOf("o"));
console.log(a.lastIndexOf("hillo"));
console.log(a.endsWith("orld!"));
console.log(a.endsWith("orld", 11)) // Len - 1
console.log(a.startsWith("Hell"));
console.log(a.startsWith("ell", 1));
console.log(a.startsWith("hell"));
console.log(a.includes("o w"));
console.log(a.includes("o w"), 10);
console.log(a.includes("war"));

Expect output:

22:51:18: 4
22:51:18: -1
22:51:18: -1
22:51:18: 7
22:51:18: -1
22:51:18: true
22:51:18: true
22:51:18: true
22:51:18: true
22:51:18: false
22:55:33: true
22:55:33: false
22:55:33: false

@calluw calluw changed the title concat(), repeat() and slice() String prototype methods (#13) concat(), repeat(), slice() and all "serachString" based String prototype methods (#13) Jun 25, 2019
@calluw calluw changed the title concat(), repeat(), slice() and all "serachString" based String prototype methods (#13) concat(), repeat(), slice() and all "searchString" based String prototype methods (#13) Jun 25, 2019
@calluw
Copy link
Contributor Author

calluw commented Jun 25, 2019

Added all "searchString" based string methods to this pull request as all related to same issue (#13).

@jasonwilliams
Copy link
Member

Sorry @CallumQuick there's some conflicts from merging the other PR

@calluw
Copy link
Contributor Author

calluw commented Jun 29, 2019

@jasonwilliams: merge conflicts have been resolved, please would you be able to take a look.

@jasonwilliams jasonwilliams merged commit fda8571 into boa-dev:master Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants