Skip to content

Commit

Permalink
optional env for ref and unref + noasync
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcotten committed Dec 1, 2022
1 parent 2dab32f commit e7c2679
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/Napoli/ObjectReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ open class Reference: ValueConvertible {
return result
}

@available(*, noasync)
@discardableResult
public func unref(_ env: Environment) throws -> UInt32 {
public func unref(_ env: Environment? = nil) throws -> UInt32 {
let env = env ?? storedEnvironment
var result: UInt32 = 0
try napi_reference_unref(env.env, internalRef, &result).throwIfError()
return result
}

@available(*, noasync)
@discardableResult
func ref(_ env: Environment) throws -> UInt32 {
func ref(_ env: Environment? = nil) throws -> UInt32 {
let env = env ?? storedEnvironment
var result: UInt32 = 0
try napi_reference_ref(env.env, internalRef, &result).throwIfError()
return result
Expand Down

0 comments on commit e7c2679

Please sign in to comment.