Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
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
16 changes: 13 additions & 3 deletions 16 Sources/JavaScriptKit/JSValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,28 @@ public extension JSValue {
}
#endif

/// An unsafe convenience method of `JSObject.subscript(_ index: Int) -> JSValue`
/// An unsafe convenience method of `JSObject.subscript(_ index: String) -> JSValue`
/// - Precondition: `self` must be a JavaScript Object.
subscript(dynamicMember name: String) -> JSValue {
get { self.object![name] }
set { self.object![name] = newValue }
nonmutating set { self.object![name] = newValue }
}

#if !hasFeature(Embedded)
/// An unsafe convenience method of `JSObject.subscript(_ index: String) -> JSValue`
/// - Precondition: `self` must be a JavaScript Object.
@_disfavoredOverload
subscript(dynamicMember name: String) -> ConvertibleToJSValue {
get { self.object![name] }
nonmutating set { self.object![name] = newValue.jsValue }
}
#endif

/// An unsafe convenience method of `JSObject.subscript(_ index: Int) -> JSValue`
/// - Precondition: `self` must be a JavaScript Object.
subscript(_ index: Int) -> JSValue {
get { object![index] }
set { object![index] = newValue }
nonmutating set { object![index] = newValue }
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.