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

Fixed spelling #1073

Merged
merged 4 commits into from
Jan 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions boa/examples/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use boa::{
// We derive `Debug`, `Trace` and `Finalize`, It automatically implements `NativeObject`
// so we can pass it an object in JavaScript.
//
// The fields of the sturct are not accesable by JavaScript unless accessors are created for them.
// The fields of the sturct are not accessible by JavaScript unless accessors are created for them.
vishalsodani marked this conversation as resolved.
Show resolved Hide resolved
/// This Represents a Person.
#[derive(Debug, Trace, Finalize)]
struct Person {
Expand Down Expand Up @@ -58,20 +58,20 @@ impl Class for Person {

// This is what is called when we do `new Person()`
fn constructor(_this: &Value, args: &[Value], context: &mut Context) -> Result<Self> {
// we get the first arguemnt of undefined if the first one is unavalable and call `to_string`.
// we get the first argument of undefined if the first one is unavailable and call `to_string`.
vishalsodani marked this conversation as resolved.
Show resolved Hide resolved
//
// This is equivalent to `String(arg)`.
let name = args
.get(0)
.cloned()
.unwrap_or_default()
.to_string(context)?;
// we get the second arguemnt of undefined if the first one is unavalable and call `to_u32`.
// we get the second argument of undefined if the first one is unavailable and call `to_u32`.
RageKnify marked this conversation as resolved.
Show resolved Hide resolved
//
// This is equivalent to `arg | 0`.
let age = args.get(1).cloned().unwrap_or_default().to_u32(context)?;

// we construct the the native struct `Person`
// we construct the native struct `Person`
let person = Person {
name: name.to_string(),
age,
Expand All @@ -86,7 +86,7 @@ impl Class for Person {
//
// This function is added to `Person.prototype.sayHello()`
class.method("sayHello", 0, Self::say_hello);
// we add a static mathod `is`, and here we use a closure, but it must be converible
// we add a static mathod `is`, and here we use a closure, but it must be convertible
// to a NativeFunction. it must not contain state, if it does it will give a compilation error.
//
// This function is added to `Person.is()`
Expand All @@ -102,11 +102,11 @@ impl Class for Person {
Ok(false.into()) // otherwise `false`.
});

// Add a inherited property with the value `10`, with deafault attribute.
// Add a inherited property with the value `10`, with default attribute.
// (`READONLY, NON_ENUMERABLE, PERMANENT).
class.property("inheritedProperty", 10, Attribute::default());

// Add a static property with the value `"Im a static property"`, with deafault attribute.
// Add a static property with the value `"Im a static property"`, with default attribute.
// (`WRITABLE, ENUMERABLE, PERMANENT`).
class.static_property(
"staticProperty",
Expand Down