Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b9fb002
Added strongly typed classes
colemancda Jun 3, 2020
ff13814
Added `JSPromise`
colemancda Jun 3, 2020
94c7dbb
Working on `JSPromise`
colemancda Jun 3, 2020
4714de8
Working on `JSPromise`
colemancda Jun 3, 2020
b5c8fa3
Added `JSError`
colemancda Jun 4, 2020
1a44d94
Updated `JSType`
colemancda Jun 4, 2020
c88b849
Working on `JSBluetooth`
colemancda Jun 4, 2020
128a862
Working on `JSBluetooth`
colemancda Jun 4, 2020
2f0eae8
Updated example
colemancda Jun 4, 2020
b75da55
Updated `JSBluetoothDevice`
colemancda Jun 4, 2020
3f47ae9
Added `JSConsole`
colemancda Jun 4, 2020
cde8d76
Added `JSBluetoothRemoteGATTServer`
colemancda Jun 4, 2020
4fb0f75
Updated `JSPromise`
colemancda Jun 4, 2020
66dd688
Updated logging
colemancda Jun 4, 2020
e14b6ac
Updated `JSPromise`
colemancda Jun 4, 2020
e4f4025
Updated `JSConsole`
colemancda Jun 4, 2020
ea55aa5
Fixed `JSType.toString()`
colemancda Jun 4, 2020
e002eb8
Updated `JSPromise`
colemancda Jun 4, 2020
195b5e2
Updated logging
colemancda Jun 4, 2020
f1be2de
Added `JSBluetooth.isAvailable`
colemancda Jun 4, 2020
7eb4587
Updated `JSPromise`
colemancda Jun 4, 2020
b1a06cb
Added `JSBluetoothRemoteGATTService`
colemancda Jun 4, 2020
235a4fe
Updated `JSPromise`
colemancda Jun 4, 2020
31e87ef
Renamed `JSDecoder`
colemancda Jun 4, 2020
8d5a12b
Fixed `JSConsole.assert()`
colemancda Jun 4, 2020
23d930b
Added `JSBluetooth.devices`
colemancda Jun 5, 2020
4356521
Added `JSEncoder`
colemancda Jun 5, 2020
4ed88b3
Added `JSObject.keys`
colemancda Jun 5, 2020
fdef8c2
Updated dependencies
colemancda Jun 5, 2020
a3093b9
Added `JSDate`
colemancda Jun 5, 2020
cfc85ce
Updated assertions
colemancda Jun 5, 2020
9fbb5e7
Updated `JSDate`
colemancda Jun 5, 2020
8f05e88
Fixed `JSEncoder`
colemancda Jun 5, 2020
c976028
Fixed `CodingKey.sanitizedName`
colemancda Jun 5, 2020
6a1528f
Fixed `JSArray`
colemancda Jun 5, 2020
699a1f0
Fixed `JSEncoder`
colemancda Jun 5, 2020
830a969
Updated dependencies
colemancda Jun 5, 2020
bb9e31c
Updated from `kateinoigakukun/JavaScriptKit`
colemancda Jun 5, 2020
d56d684
Fixed `JSDate`
colemancda Jun 5, 2020
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
Prev Previous commit
Next Next commit
Updated assertions
  • Loading branch information
colemancda committed Jun 5, 2020
commit cfc85cee7987f01b3d0191f52e4fac5ec35e80ef
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Utilities.swift
// Assert.swift
//
//
// Created by Alsey Coleman Miller on 6/4/20.
Expand All @@ -24,3 +24,15 @@ internal func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosu
internal func assert(_ condition: @autoclosure () -> JSBoolean, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) {
assert(condition().rawValue, message(), file: file, line: line)
}

internal extension Optional {

func assert(_ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) -> Wrapped {
switch self {
case .none:
fatalError(message(), file: file, line: line)
case let .some(value):
return value
}
Comment on lines +30 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name is assert but it uses fatalError. Should we use fatalError instead?

}
}
5 changes: 2 additions & 3 deletions Sources/JavaScriptKit/JS Types/JSBoolean.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ extension JSBoolean: RawRepresentable {
}

public var rawValue: Bool {
guard let function = jsObject.valueOf.function
else { fatalError("Invalid function \(#function)") }
return function.apply(this: jsObject).boolean ?? false
let function = jsObject.valueOf.function.assert("Invalid function \(#function)")
return function.apply(this: jsObject).boolean.assert()
}
}

Expand Down