diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala index 7b5b2df74..4ec63bee4 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/Assert.scala @@ -31,11 +31,18 @@ trait Assert extends js.Object { def deepStrictEqual(actual: js.Any, expected: js.Any, message: String): Unit = js.native def deepStrictEqual(actual: js.Any, expected: js.Any): Unit = js.native - def doesNotReject(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function, message: String): Unit = - js.native - def doesNotReject(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function): Unit = js.native - def doesNotReject(asyncFn: js.Function | js.Promise[_], message: String): Unit = js.native - def doesNotReject(asyncFn: js.Function | js.Promise[_]): Unit = js.native + def doesNotReject(asyncFn: js.Function, error: js.RegExp, message: String): Unit = js.native + def doesNotReject(asyncFn: js.Function, error: js.RegExp): Unit = js.native + def doesNotReject(asyncFn: js.Function, error: js.Function, message: String): Unit = js.native + def doesNotReject(asyncFn: js.Function, error: js.Function): Unit = js.native + def doesNotReject(asyncFn: js.Function, message: String): Unit = js.native + def doesNotReject(asyncFn: js.Function): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_], error: js.RegExp, message: String): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_], error: js.RegExp): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_], error: js.Function, message: String): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_], error: js.Function): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_], message: String): Unit = js.native + def doesNotReject(asyncFn: js.Promise[_]): Unit = js.native /** * Asserts that the function block does not throw an error. See assert.throws() for more details. @@ -44,10 +51,12 @@ trait Assert extends js.Object { * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller. * @example assert.doesNotThrow(block[, error][, message]) */ - def doesNotThrow(block: js.Function, error: js.RegExp | js.Function, message: String): Unit = js.native - def doesNotThrow(block: js.Function, error: js.RegExp | js.Function): Unit = js.native - def doesNotThrow(block: js.Function, message: String): Unit = js.native - def doesNotThrow(block: js.Function): Unit = js.native + def doesNotThrow(block: js.Function, error: js.RegExp, message: String): Unit = js.native + def doesNotThrow(block: js.Function, error: js.RegExp): Unit = js.native + def doesNotThrow(block: js.Function, error: js.Function, message: String): Unit = js.native + def doesNotThrow(block: js.Function, error: js.Function): Unit = js.native + def doesNotThrow(block: js.Function, message: String): Unit = js.native + def doesNotThrow(block: js.Function): Unit = js.native /** * @see https://nodejs.org/api/assert.html#assert_assert_fail_message @@ -102,17 +111,17 @@ trait Assert extends js.Object { * of the message parameter. If the message parameter is undefined, a default error message is assigned. * @example assert.throws(block[, error][, message]) */ - def throws(block: js.Function, error: js.RegExp | js.Function | js.Object | Error, message: String): Unit = js.native - def throws(block: js.Function, error: js.RegExp | js.Function | js.Object | Error): Unit = js.native - - def rejects(asyncFn: js.Function | js.Promise[_], - error: js.RegExp | js.Function | js.Object | Error, - message: String - ): Unit = js.native - def rejects(asyncFn: js.Function | js.Promise[_], error: js.RegExp | js.Function | js.Object | Error): Unit = - js.native - def rejects(asyncFn: js.Function | js.Promise[_], message: String): Unit = js.native - def rejects(asyncFn: js.Function | js.Promise[_]): Unit = js.native + def throws(block: js.Function, error: js.Object, message: String): Unit = js.native + def throws(block: js.Function, error: js.Object): Unit = js.native + + def rejects(asyncFn: js.Function, error: js.Object, message: String): Unit = js.native + def rejects(asyncFn: js.Function, error: js.Object): Unit = js.native + def rejects(asyncFn: js.Function, message: String): Unit = js.native + def rejects(asyncFn: js.Function): Unit = js.native + def rejects(asyncFn: js.Promise[_], error: js.Object, message: String): Unit = js.native + def rejects(asyncFn: js.Promise[_], error: js.Object): Unit = js.native + def rejects(asyncFn: js.Promise[_], message: String): Unit = js.native + def rejects(asyncFn: js.Promise[_]): Unit = js.native } /** diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/StringDecoder.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/StringDecoder.scala index 2597b0aa1..b78c311df 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/StringDecoder.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/StringDecoder.scala @@ -20,12 +20,14 @@ class StringDecoder(encoding: String) extends IEventEmitter { * Returns any trailing bytes that were left in the buffer. * @example decoder.end() */ - def end(buffer: TypedArray[_, _] | DataView): String = js.native - def end(): String = js.native + def end(buffer: TypedArray[_, _]): String = js.native + def end(buffer: DataView): String = js.native + def end(): String = js.native /** * Returns a decoded string. * @example decoder.write(buffer) */ - def write(buffer: TypedArray[_, _] | DataView): String = js.native + def write(buffer: TypedArray[_, _]): String = js.native + def write(buffer: DataView): String = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala index 123474086..9bb674d90 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/Buffer.scala @@ -97,49 +97,36 @@ class Buffer private[this] () extends Uint8Array( /* dummy to trick constructor */ def equals(otherBuffer: Uint8Array): Boolean = js.native - /** - * Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled. - * This is meant to be a small simplification to allow the creation and filling of a Buffer to be done on a single line. - * - * @param value The value to fill buf with - * @param offset Where to start filling buf. Default: 0 - * @param end Where to stop filling buf (not inclusive). Default: buf.length - * @param encoding If value is a string, this is its encoding. Default: 'utf8' - * @return A reference to buf - * @see https://nodejs.org/api/buffer.html#buffer_buf_fill_value_offset_end_encoding - */ - def fill(value: Uint8Array | Int | String, offset: Int, end: Int, encoding: String): this.type = js.native - def fill(value: Uint8Array | Int | String, offset: Int, end: Int): this.type = js.native - def fill(value: Uint8Array | Int | String, offset: Int, encoding: String): this.type = js.native - def fill(value: Uint8Array | Int | String, offset: Int): this.type = js.native - def fill(value: Uint8Array | Int | String, encoding: String): this.type = js.native - def fill(value: Uint8Array | Int | String): this.type = js.native - - /** - * Returns the index of the first occurrence of value in buf or -1 if buf does not contain value - * @param value What to search for - * @param byteOffset Where to begin searching in buf. Default: 0 - * @param encoding If value is a string, this is its encoding. Default: 'utf8' - * @return The index of the first occurrence of value in buf or -1 if buf does not contain value - * @example {{{ buf.indexOf(value[, byteOffset][, encoding]) }}} - */ - def indexOf(value: Buffer | Int | String, byteOffset: Int, encoding: String): Int = js.native - def indexOf(value: Buffer | Int | String, byteOffset: Int): Int = js.native - def indexOf(value: Buffer | Int | String, encoding: String): Int = js.native - def indexOf(value: Buffer | Int | String): Int = js.native - - /** - * Equivalent to buf.indexOf() !== -1. - * @param value What to search for - * @param byteOffset Where to begin searching in buf. Default: 0 - * @param encoding If value is a string, this is its encoding. Default: 'utf8' - * @return true if value was found in buf, false otherwise - * @example {{{ buf.includes(value[, byteOffset][, encoding]) }}} - */ - def includes(value: Buffer | Int | String, byteOffset: Int, encoding: String): Boolean = js.native - def includes(value: Buffer | Int | String, byteOffset: Int): Boolean = js.native - def includes(value: Buffer | Int | String, encoding: String): Boolean = js.native - def includes(value: Buffer | Int | String): Boolean = js.native + def fill(value: Uint8Array, offset: Int, end: Int): this.type = js.native + def fill(value: Uint8Array, offset: Int): this.type = js.native + def fill(value: Uint8Array): this.type = js.native + def fill(value: Int, offset: Int, end: Int): this.type = js.native + def fill(value: Int, offset: Int): this.type = js.native + def fill(value: Int): this.type = js.native + def fill(value: String, offset: Int, end: Int, encoding: String): this.type = js.native + def fill(value: String, offset: Int, end: Int): this.type = js.native + def fill(value: String, offset: Int, encoding: String): this.type = js.native + def fill(value: String, offset: Int): this.type = js.native + def fill(value: String, encoding: String): this.type = js.native + def fill(value: String): this.type = js.native + + def indexOf(value: Buffer, byteOffset: Int): Int = js.native + def indexOf(value: Buffer): Int = js.native + def indexOf(value: Int, byteOffset: Int): Int = js.native + def indexOf(value: Int): Int = js.native + def indexOf(value: String, byteOffset: Int, encoding: String): Int = js.native + def indexOf(value: String, byteOffset: Int): Int = js.native + def indexOf(value: String, encoding: String): Int = js.native + def indexOf(value: String): Int = js.native + + def includes(value: Buffer, byteOffset: Int): Boolean = js.native + def includes(value: Buffer): Boolean = js.native + def includes(value: Int, byteOffset: Int): Boolean = js.native + def includes(value: Int): Boolean = js.native + def includes(value: String, byteOffset: Int, encoding: String): Boolean = js.native + def includes(value: String, byteOffset: Int): Boolean = js.native + def includes(value: String, encoding: String): Boolean = js.native + def includes(value: String): Boolean = js.native /** * Creates and returns an iterator of buf keys (indices). @@ -148,18 +135,14 @@ class Buffer private[this] () extends Uint8Array( /* dummy to trick constructor */ def keys(): js.Iterator[Int] = js.native - /** - * Identical to buf.indexOf(), except buf is searched from back to front instead of front to back. - * @param value What to search for - * @param byteOffset Where to begin searching in buf. Default: 0 - * @param encoding If value is a string, this is its encoding. Default: 'utf8' - * @return The index of the last occurrence of value in buf or -1 if buf does not contain value - * @example {{{ buf.lastIndexOf(value[, byteOffset][, encoding]) }}} - */ - def lastIndexOf(value: Buffer | Int | String, byteOffset: Int, encoding: String): Int = js.native - def lastIndexOf(value: Buffer | Int | String, byteOffset: Int): Int = js.native - def lastIndexOf(value: Buffer | Int | String, encoding: String): Int = js.native - def lastIndexOf(value: Buffer | Int | String): Int = js.native + def lastIndexOf(value: Buffer, byteOffset: Int): Int = js.native + def lastIndexOf(value: Buffer): Int = js.native + def lastIndexOf(value: Int, byteOffset: Int): Int = js.native + def lastIndexOf(value: Int): Int = js.native + def lastIndexOf(value: String, byteOffset: Int, encoding: String): Int = js.native + def lastIndexOf(value: String, byteOffset: Int): Int = js.native + def lastIndexOf(value: String, encoding: String): Int = js.native + def lastIndexOf(value: String): Int = js.native /** * Returns the amount of memory allocated for buf in bytes. @@ -925,8 +908,11 @@ object Buffer extends js.Object { * * @see [[https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding]] */ - def byteLength(string: String | TypedArray[_, _] | DataView | ArrayBuffer, encoding: String = "utf8"): Int = - js.native + def byteLength(string: String, encoding: String): Int = js.native + def byteLength(string: String): Int = js.native + def byteLength(string: TypedArray[_, _]): Int = js.native + def byteLength(string: DataView): Int = js.native + def byteLength(string: ArrayBuffer): Int = js.native /** * Compares `buf1` to `buf2` typically for the purpose of sorting arrays of `Buffer` instances. @@ -945,8 +931,8 @@ object Buffer extends js.Object { * @see [[https://nodejs.org/api/buffer.html#buffer_class_method_buffer_concat_list_totallength]] * */ - def concat(list: js.Array[Buffer] | js.Array[Uint8Array], totalLength: Int): Buffer = js.native - def concat(list: js.Array[Buffer] | js.Array[Uint8Array]): Buffer = js.native + def concat[B <: Uint8Array](list: js.Array[B], totalLength: Int): Buffer = js.native + def concat[B <: Uint8Array](list: js.Array[B]): Buffer = js.native /** * When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/package.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/package.scala index 8081f0ce4..3c31e7dfd 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/package.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/buffer/package.scala @@ -29,11 +29,9 @@ package object buffer { /** * Returns the actual byte length of a string. This is not the same as String.prototype.length since that returns * the number of characters in a string. - * - * @param encoding the optional encoding (default "utf8") */ @inline - def byteLength(encoding: String = "utf8"): Int = Buffer.byteLength(buffer, encoding) + def byteLength(encoding: String): Int = Buffer.byteLength(buffer) /** * Returns the hex-formatted string diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala index 4393eaacb..0124a7007 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Certificate.scala @@ -9,10 +9,12 @@ import scala.scalajs.js.| @js.native @JSImport("crypto", "Certificate") object Certificate extends js.Object { - def exportChallenge(spkac: String | BufferLike): Buffer = js.native + def exportChallenge(spkac: String): Buffer = js.native + def exportChallenge(spkac: BufferLike): Buffer = js.native - def exportPublicKey(spkac: String | BufferLike, encoding: String): Buffer = js.native - def exportPublicKey(spkac: String | BufferLike): Buffer = js.native + def exportPublicKey(spkac: String, encoding: String): Buffer = js.native + def exportPublicKey(spkac: String): Buffer = js.native + def exportPublicKey(spkac: BufferLike): Buffer = js.native def verifySpkac(spkac: BufferLike): Boolean = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala index 2c3465af5..a3704a58c 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Crypto.scala @@ -49,20 +49,25 @@ trait Crypto extends js.Object { * either a 'binary' encoded string or a Buffer. * @example crypto.createCipher(algorithm, password) */ - @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") - def createCipher(algorithm: String, password: Buffer | String): Cipher = js.native - - def createCipheriv(algorithm: String, - key: String | BufferLike, - iv: String | BufferLike, - options: TransformOptions - ): Cipher = js.native - def createCipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike): Cipher = js.native + @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") def createCipher(algorithm: String, + password: Buffer + ): Cipher = js.native + @deprecated("Use crypto.createCipheriv() instead.", "Node.js v10.0") def createCipher(algorithm: String, + password: String + ): Cipher = js.native + + def createCipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Cipher = js.native + def createCipheriv(algorithm: String, key: String, iv: BufferLike): Cipher = js.native + def createCipheriv(algorithm: String, key: BufferLike, iv: String, options: TransformOptions): Cipher = js.native + def createCipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Cipher = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createCipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike, options: TransformOptions): Cipher = - js.native + def createCipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Cipher = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike, options: TransformOptions): Cipher = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createCipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike): Cipher = js.native + def createCipheriv(algorithm: String, key: KeyObject, iv: String): Cipher = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Cipher = js.native /** * Creates and returns a Decipher object that uses the given algorithm and password (key). @@ -75,31 +80,34 @@ trait Crypto extends js.Object { * derive a key and IV on their own using crypto.pbkdf2() and to use crypto.createDecipheriv() to create the Decipher object. * @example crypto.createDecipher(algorithm, password) */ - @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") - def createDecipher(algorithm: String, password: Buffer | String): Decipher = js.native - - def createDecipheriv(algorithm: String, - key: String | BufferLike, - iv: String | BufferLike, - options: TransformOptions - ): Decipher = js.native - def createDecipheriv(algorithm: String, key: String | BufferLike, iv: String | BufferLike): Decipher = js.native - def createDecipheriv(algorithm: String, - key: KeyObject, - iv: String | BufferLike, - options: TransformOptions - ): Decipher = js.native - def createDecipheriv(algorithm: String, key: KeyObject, iv: String | BufferLike): Decipher = js.native - - def createDiffieHellman(prime: String, primeEncoding: String, generator: Int | BufferLike): DiffieHellman = js.native + @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") def createDecipher(algorithm: String, + password: Buffer + ): Decipher = js.native + @deprecated("Use crypto.createDecipheriv() instead.", "Node.js v10.0") def createDecipher(algorithm: String, + password: String + ): Decipher = js.native + + def createDecipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Decipher = js.native + def createDecipheriv(algorithm: String, key: String, iv: BufferLike, options: TransformOptions): Decipher = js.native + def createDecipheriv(algorithm: String, key: BufferLike, iv: String): Decipher = js.native + def createDecipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Decipher = js.native + def createDecipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Decipher = js.native + def createDecipheriv(algorithm: String, key: KeyObject, iv: BufferLike, options: TransformOptions): Decipher = + js.native + def createDecipheriv(algorithm: String, key: KeyObject, iv: String): Decipher = js.native + def createDecipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Decipher = js.native + + def createDiffieHellman(prime: String, primeEncoding: String, generator: Int): DiffieHellman = js.native + def createDiffieHellman(prime: String, primeEncoding: String, generator: BufferLike): DiffieHellman = js.native def createDiffieHellman(prime: String, primeEncoding: String, generator: String, generatorEncoding: String ): DiffieHellman = js.native def createDiffieHellman(prime: BufferLike, generator: String, generatorEncoding: String): DiffieHellman = js.native - def createDiffieHellman(prime: BufferLike, generator: Int | BufferLike): DiffieHellman = js.native - def createDiffieHellman(primeLength: Int, generator: Int | String | BufferLike): DiffieHellman = js.native + def createDiffieHellman(prime: BufferLike, generator: Int): DiffieHellman = js.native + def createDiffieHellman(prime: BufferLike, generator: BufferLike): DiffieHellman = js.native + def createDiffieHellman(primeLength: Int, generator: Int): DiffieHellman = js.native def createDiffieHellmanGroup(name: String): DiffieHellman = js.native @@ -127,18 +135,32 @@ trait Crypto extends js.Object { * @param algorithm the given algorithm (e.g. 'sha256', 'sha512') * @param key The key is the HMAC key used to generate the cryptographic HMAC hash. */ - def createHmac(algorithm: String, key: String | BufferLike, options: TransformOptions): Hmac = js.native - def createHmac(algorithm: String, key: String | BufferLike): Hmac = js.native + def createHmac(algorithm: String, key: String, options: TransformOptions): Hmac = js.native + def createHmac(algorithm: String, key: BufferLike, options: TransformOptions): Hmac = js.native + def createHmac(algorithm: String, key: String): Hmac = js.native + def createHmac(algorithm: String, key: BufferLike): Hmac = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createHmac(algorithm: String, key: KeyObject, options: TransformOptions): Hmac = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createHmac(algorithm: String, key: KeyObject): Hmac = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createPrivateKey(key: String | Buffer | CreatePrivateKeyOptions): KeyObject = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey(key: String): KeyObject = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey(key: Buffer): KeyObject = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPrivateKey( + key: CreatePrivateKeyOptions + ): KeyObject = js.native - @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def createPublicKey(key: String | Buffer | KeyObject | CreatePublicKeyOptions): KeyObject = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: String): KeyObject = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: Buffer): KeyObject = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey(key: KeyObject): KeyObject = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createPublicKey( + key: CreatePublicKeyOptions + ): KeyObject = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def createSecretKey(key: Buffer): KeyObject = js.native @@ -184,8 +206,29 @@ trait Crypto extends js.Object { def getHashes(): js.Array[String] = js.native - def pbkdf2(password: String | BufferLike, - salt: String | BufferLike, + def pbkdf2(password: String, + salt: String, + iterations: Int, + keylen: Int, + digest: String, + callback: Callback1[Buffer] + ): Buffer = js.native + def pbkdf2(password: String, + salt: BufferLike, + iterations: Int, + keylen: Int, + digest: String, + callback: Callback1[Buffer] + ): Buffer = js.native + def pbkdf2(password: BufferLike, + salt: String, + iterations: Int, + keylen: Int, + digest: String, + callback: Callback1[Buffer] + ): Buffer = js.native + def pbkdf2(password: BufferLike, + salt: BufferLike, iterations: Int, keylen: Int, digest: String, @@ -207,26 +250,29 @@ trait Crypto extends js.Object { * * (Doc source: https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest) */ - def pbkdf2Sync(password: String | BufferLike, - salt: String | BufferLike, - iterations: Int, - keylen: Int, - digest: String - ): Buffer = js.native + def pbkdf2Sync(password: String, salt: String, iterations: Int, keylen: Int, digest: String): Buffer = js.native + def pbkdf2Sync(password: String, salt: BufferLike, iterations: Int, keylen: Int, digest: String): Buffer = js.native + def pbkdf2Sync(password: BufferLike, salt: String, iterations: Int, keylen: Int, digest: String): Buffer = js.native + def pbkdf2Sync(password: BufferLike, salt: BufferLike, iterations: Int, keylen: Int, digest: String): Buffer = + js.native - def privateDecrypt(privateKey: String | Buffer, buffer: BufferLike): Buffer = js.native + def privateDecrypt(privateKey: String, buffer: BufferLike): Buffer = js.native + def privateDecrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def privateDecrypt(privateKey: PrivateDecryptKeyObject, buffer: BufferLike): Buffer = js.native - def privateEncrypt(privateKey: String | Buffer, buffer: BufferLike): Buffer = js.native + def privateEncrypt(privateKey: String, buffer: BufferLike): Buffer = js.native + def privateEncrypt(privateKey: Buffer, buffer: BufferLike): Buffer = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def privateEncrypt(privateKey: PrivateEncryptKeyObject, buffer: BufferLike): Buffer = js.native - def publicDecrypt(key: String | Buffer, buffer: BufferLike): Buffer = js.native + def publicDecrypt(key: String, buffer: BufferLike): Buffer = js.native + def publicDecrypt(key: Buffer, buffer: BufferLike): Buffer = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def publicDecrypt(key: PublicDecryptKeyObject, buffer: BufferLike): Buffer = js.native - def publicEncrypt(key: String | Buffer, buffer: BufferLike): Buffer = js.native + def publicEncrypt(key: String, buffer: BufferLike): Buffer = js.native + def publicEncrypt(key: Buffer, buffer: BufferLike): Buffer = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def publicEncrypt(key: PublicEncryptKeyObject, buffer: BufferLike): Buffer = js.native @@ -277,21 +323,39 @@ trait Crypto extends js.Object { js.native def randomFill[T <: scala.scalajs.js.typedarray.TypedArray[_, T]](buffer: T, callback: Callback1[T]): T = js.native - def scrypt(password: String | BufferLike, - salt: String | BufferLike, + def scrypt(password: String, salt: String, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer]): Unit = + js.native + def scrypt(password: String, + salt: BufferLike, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer] ): Unit = js.native - def scrypt(password: String | BufferLike, salt: String | BufferLike, keylen: Int, callback: Callback1[Buffer]): Unit = - js.native - - def scryptSync(password: String | BufferLike, - salt: String | BufferLike, - keylen: Int, - options: ScryptOptions - ): Buffer = js.native - def scryptSync(password: String | BufferLike, salt: String | BufferLike, keylen: Int): Buffer = js.native + def scrypt(password: BufferLike, + salt: String, + keylen: Int, + options: ScryptOptions, + callback: Callback1[Buffer] + ): Unit = js.native + def scrypt(password: BufferLike, + salt: BufferLike, + keylen: Int, + options: ScryptOptions, + callback: Callback1[Buffer] + ): Unit = js.native + def scrypt(password: String, salt: String, keylen: Int, callback: Callback1[Buffer]): Unit = js.native + def scrypt(password: String, salt: BufferLike, keylen: Int, callback: Callback1[Buffer]): Unit = js.native + def scrypt(password: BufferLike, salt: String, keylen: Int, callback: Callback1[Buffer]): Unit = js.native + def scrypt(password: BufferLike, salt: BufferLike, keylen: Int, callback: Callback1[Buffer]): Unit = js.native + + def scryptSync(password: String, salt: String, keylen: Int, options: ScryptOptions): Buffer = js.native + def scryptSync(password: String, salt: BufferLike, keylen: Int, options: ScryptOptions): Buffer = js.native + def scryptSync(password: BufferLike, salt: String, keylen: Int, options: ScryptOptions): Buffer = js.native + def scryptSync(password: BufferLike, salt: BufferLike, keylen: Int, options: ScryptOptions): Buffer = js.native + def scryptSync(password: String, salt: String, keylen: Int): Buffer = js.native + def scryptSync(password: String, salt: BufferLike, keylen: Int): Buffer = js.native + def scryptSync(password: BufferLike, salt: String, keylen: Int): Buffer = js.native + def scryptSync(password: BufferLike, salt: BufferLike, keylen: Int): Buffer = js.native def setEngine(engine: String, fips: Int): Unit = js.native def setEngine(engine: String): Unit = js.native @@ -300,20 +364,46 @@ trait Crypto extends js.Object { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, data: BufferLike, - key: String | Buffer | KeyObject + key: String + ): Buffer = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, + data: BufferLike, + key: Buffer + ): Buffer = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(algorithm: String, + data: BufferLike, + key: KeyObject ): Buffer = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, key: String): Buffer = + js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, key: Buffer): Buffer = + js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(data: BufferLike, - key: String | Buffer | KeyObject + key: KeyObject ): Buffer = js.native def timingSafeEqual(a: BufferLike, b: BufferLike): Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, data: BufferLike, - key: String | Buffer | KeyObject + key: String + ): Boolean = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, + data: BufferLike, + key: Buffer + ): Boolean = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(algorithm: String, + data: BufferLike, + key: KeyObject + ): Boolean = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, + key: String + ): Boolean = js.native + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, + key: Buffer ): Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(data: BufferLike, - key: String | Buffer | KeyObject + key: KeyObject ): Boolean = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala index 7312fc2b7..944d9d7f3 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Sign.scala @@ -19,8 +19,10 @@ import scala.scalajs.js.| */ @js.native sealed trait Sign extends Writable { - def sign(privateKey: String | Buffer): Buffer = js.native - def sign(privateKey: String | Buffer, outputEncoding: String): String = js.native + def sign(privateKey: String): Buffer = js.native + def sign(privateKey: Buffer): Buffer = js.native + def sign(privateKey: String, outputEncoding: String): String = js.native + def sign(privateKey: Buffer, outputEncoding: String): String = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def sign(privateKey: KeyObject): Buffer = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala index 66c3fbb8f..741581290 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/crypto/Verify.scala @@ -44,8 +44,10 @@ trait Verify extends Writable { * signature is expected to be a Buffer. * @return true or false depending on the validity of the signature for the data and public key. */ - def verify(obj: String | Buffer, signature: String, signatureEncoding: String): Boolean = js.native - def verify(obj: String | Buffer, signature: BufferLike): Boolean = js.native + def verify(obj: String, signature: String, signatureEncoding: String): Boolean = js.native + def verify(obj: Buffer, signature: String, signatureEncoding: String): Boolean = js.native + def verify(obj: String, signature: BufferLike): Boolean = js.native + def verify(obj: Buffer, signature: BufferLike): Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def verify(obj: KeyObject, signature: String, signatureEncoding: String): Boolean = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/DNS.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/DNS.scala index 9a4a98cdd..ae2f35307 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/DNS.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/DNS.scala @@ -35,7 +35,9 @@ trait DNS extends IResolver { * All properties are optional. * @example dns.lookup(hostname[, options], callback) */ - def lookup(hostname: String, options: DnsOptions | Int, callback: DnsCallback2[String, Int]): Unit = js.native + def lookup(hostname: String, options: DnsOptions, callback: DnsCallback2[String, Int]): Unit = js.native + def lookup(hostname: String, options: Int, callback: DnsCallback2[String, Int]): Unit = js.native + def lookup(hostname: String, callback: DnsCallback2[String, Int]): Unit = js.native /** * Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. options can be an diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/package.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/package.scala index 3de8ff27f..79b920d73 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/package.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/dns/package.scala @@ -70,9 +70,17 @@ package object dns { * integer, then it must be 4 or 6. */ @inline - def lookupFuture(hostname: String, options: DnsOptions | Int = null): Future[(String, Int)] = { + def lookupFuture(hostname: String, family: Int): Future[(String, Int)] = { + promiseWithError2[DnsError, String, Int](dns.lookup(hostname, family, _)) + } + @inline + def lookupFuture(hostname: String, options: DnsOptions): Future[(String, Int)] = { promiseWithError2[DnsError, String, Int](dns.lookup(hostname, options, _)) } + @inline + def lookupFuture(hostname: String): Future[(String, Int)] = { + promiseWithError2[DnsError, String, Int](dns.lookup(hostname, _)) + } /** * Resolves the given address and port into a hostname and service using the operating system's underlying diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala index d931fc983..248ca9dbb 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/Fs.scala @@ -87,11 +87,12 @@ trait Fs extends js.Object with FSConstants { * @param callback the callback function * @example fs.appendFile(file, data[, options], callback) */ - def appendFile(file: Path | FileDescriptor, - data: Buffer | String, - options: FileAppendOptions, - callback: FsCallback0 - ): Unit = js.native + def appendFile(file: Path, data: Buffer, options: FileAppendOptions, callback: FsCallback0): Unit = js.native + def appendFile(file: Path, data: String, options: FileAppendOptions, callback: FsCallback0): Unit = js.native + def appendFile(file: FileDescriptor, data: Buffer, options: FileAppendOptions, callback: FsCallback0): Unit = + js.native + def appendFile(file: FileDescriptor, data: String, options: FileAppendOptions, callback: FsCallback0): Unit = + js.native /** * Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer. @@ -100,7 +101,10 @@ trait Fs extends js.Object with FSConstants { * @param callback the callback function * @example fs.appendFile(file, data[, options], callback) */ - def appendFile(path: Path | FileDescriptor, data: Buffer | String, callback: FsCallback0): Unit = js.native + def appendFile(path: Path, data: Buffer, callback: FsCallback0): Unit = js.native + def appendFile(path: Path, data: String, callback: FsCallback0): Unit = js.native + def appendFile(path: FileDescriptor, data: Buffer, callback: FsCallback0): Unit = js.native + def appendFile(path: FileDescriptor, data: String, callback: FsCallback0): Unit = js.native /** * The synchronous version of fs.appendFile(). @@ -109,8 +113,14 @@ trait Fs extends js.Object with FSConstants { * @param options the [[FileAppendOptions optional append settings]] * @return undefined. */ - def appendFileSync(path: Path | FileDescriptor, data: Buffer | String, options: FileAppendOptions): Unit = js.native - def appendFileSync(path: Path | FileDescriptor, data: Buffer | String): Unit = js.native + def appendFileSync(path: Path, data: Buffer, options: FileAppendOptions): Unit = js.native + def appendFileSync(path: Path, data: String, options: FileAppendOptions): Unit = js.native + def appendFileSync(path: Path, data: Buffer): Unit = js.native + def appendFileSync(path: Path, data: String): Unit = js.native + def appendFileSync(path: FileDescriptor, data: Buffer, options: FileAppendOptions): Unit = js.native + def appendFileSync(path: FileDescriptor, data: String, options: FileAppendOptions): Unit = js.native + def appendFileSync(path: FileDescriptor, data: Buffer): Unit = js.native + def appendFileSync(path: FileDescriptor, data: String): Unit = js.native /** * Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback. @@ -435,7 +445,8 @@ trait Fs extends js.Object with FSConstants { * After v13.11.0, in recursive mode, the `callback`` now receives the first created path as an 2nd argument. * @example fs.mkdir(path[, mode], callback) */ - def mkdir(path: Path, mode: MkdirOptions, callback: FsCallback0 | FsRecursiveCallback0): Unit = js.native + def mkdir(path: Path, mode: MkdirOptions, callback: FsCallback0): Unit = js.native + def mkdir(path: Path, mode: MkdirOptions, callback: FsRecursiveCallback0): Unit = js.native /** * Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. @@ -468,8 +479,8 @@ trait Fs extends js.Object with FSConstants { * @param callback the callback * @example fs.mkdtemp(prefix[, options], callback) */ - def mkdtemp(prefix: String, options: String | FileEncodingOptions, callback: FsCallback1[String]): Unit = - js.native + def mkdtemp(prefix: String, options: String, callback: FsCallback1[String]): Unit = js.native + def mkdtemp(prefix: String, options: FileEncodingOptions, callback: FsCallback1[String]): Unit = js.native /** * Creates a unique temporary directory. @@ -490,8 +501,9 @@ trait Fs extends js.Object with FSConstants { * @param prefix the prefix * @param options the optional encoding setting */ - def mkdtempSync(prefix: String, options: String | FileEncodingOptions): String = js.native - def mkdtempSync(prefix: String): String = js.native + def mkdtempSync(prefix: String, options: String): String = js.native + def mkdtempSync(prefix: String, options: FileEncodingOptions): String = js.native + def mkdtempSync(prefix: String): String = js.native /** * Asynchronous file open. See open(2). @@ -645,8 +657,9 @@ trait Fs extends js.Object with FSConstants { * of the names of the files in the directory excluding '.' and '..'. * @example fs.readdir(path[, options], callback) */ - def readdir(path: Path, options: String | FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit = js.native - def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native + def readdir(path: Path, options: String, callback: FsCallback1[ReaddirArrays]): Unit = js.native + def readdir(path: Path, options: FileEncodingOptions, callback: FsCallback1[ReaddirArrays]): Unit = js.native + def readdir(path: Path, options: ReaddirOptions, callback: FsCallback1[ReaddirArrays2]): Unit = js.native /** * Asynchronous readdir(3). Reads the contents of a directory. @@ -678,7 +691,8 @@ trait Fs extends js.Object with FSConstants { * If no encoding is specified, then the raw buffer is returned. * @example fs.readFile(file[, options], callback) */ - def readFile(file: Path | FileDescriptor, options: ReadFileOptions, callback: FsCallback1[Output]): Unit = js.native + def readFile(file: Path, options: ReadFileOptions, callback: FsCallback1[Output]): Unit = js.native + def readFile(file: FileDescriptor, options: ReadFileOptions, callback: FsCallback1[Output]): Unit = js.native /** * Asynchronously reads the entire contents of a file. @@ -688,8 +702,8 @@ trait Fs extends js.Object with FSConstants { * If no encoding is specified, then the raw buffer is returned. * @example fs.readFile(file[, options], callback) */ - def readFile(file: Path | FileDescriptor, encoding: String, callback: FsCallback1[String]): Unit = - js.native + def readFile(file: Path, encoding: String, callback: FsCallback1[String]): Unit = js.native + def readFile(file: FileDescriptor, encoding: String, callback: FsCallback1[String]): Unit = js.native /** * Asynchronously reads the entire contents of a file. @@ -698,7 +712,8 @@ trait Fs extends js.Object with FSConstants { * If no encoding is specified, then the raw buffer is returned. * @example fs.readFile(file[, options], callback) */ - def readFile(file: Path | FileDescriptor, callback: FsCallback1[Buffer]): Unit = js.native + def readFile(file: Path, callback: FsCallback1[Buffer]): Unit = js.native + def readFile(file: FileDescriptor, callback: FsCallback1[Buffer]): Unit = js.native /** * Synchronous version of fs.readFile. Returns the contents of the file. @@ -708,7 +723,8 @@ trait Fs extends js.Object with FSConstants { * Otherwise it returns a buffer. * @example fs.readFileSync(file[, options]) */ - def readFileSync(file: Path | FileDescriptor, encoding: String): String = js.native + def readFileSync(file: Path, encoding: String): String = js.native + def readFileSync(file: FileDescriptor, encoding: String): String = js.native /** * Synchronous version of fs.readFile. Returns the contents of the file. @@ -718,7 +734,8 @@ trait Fs extends js.Object with FSConstants { * Otherwise it returns a buffer. * @example fs.readFileSync(file[, options]) */ - def readFileSync(file: Path | FileDescriptor, options: ReadFileOptions): Output = js.native + def readFileSync(file: Path, options: ReadFileOptions): Output = js.native + def readFileSync(file: FileDescriptor, options: ReadFileOptions): Output = js.native /** * Synchronous version of fs.readFile. @@ -727,7 +744,8 @@ trait Fs extends js.Object with FSConstants { * Otherwise it returns a buffer. * @example fs.readFileSync(file[, options]) */ - def readFileSync(file: Path | FileDescriptor): Buffer = js.native + def readFileSync(file: Path): Buffer = js.native + def readFileSync(file: FileDescriptor): Buffer = js.native /** * Asynchronous readlink(2). @@ -739,9 +757,9 @@ trait Fs extends js.Object with FSConstants { * @param callback the callback gets two arguments (err, linkString). * @example fs.readlink(path[, options], callback) */ - def readlink(path: Path, options: String | FileEncodingOptions, callback: FsCallback1[Output]): Unit = - js.native - def readlink(path: Path, callback: FsCallback1[String]): Unit = js.native + def readlink(path: Path, options: String, callback: FsCallback1[Output]): Unit = js.native + def readlink(path: Path, options: FileEncodingOptions, callback: FsCallback1[Output]): Unit = js.native + def readlink(path: Path, callback: FsCallback1[String]): Unit = js.native /** * Synchronous readlink(2). @@ -752,8 +770,9 @@ trait Fs extends js.Object with FSConstants { * to 'buffer', the link path returned will be passed as a Buffer object. * @return the symbolic link's string value. */ - def readlinkSync(path: Path, options: String | FileEncodingOptions): Output = js.native - def readlinkSync(path: Path): String = js.native + def readlinkSync(path: Path, options: String): Output = js.native + def readlinkSync(path: Path, options: FileEncodingOptions): Output = js.native + def readlinkSync(path: Path): String = js.native /** * Asynchronous realpath(2). @@ -766,8 +785,8 @@ trait Fs extends js.Object with FSConstants { * the path returned will be passed as a Buffer object. * @example fs.realpath(path[, options], callback) */ - def realpath(path: Path, options: String | FileEncodingOptions, callback: FsCallback1[Output]): Unit = - js.native + def realpath(path: Path, options: String, callback: FsCallback1[Output]): Unit = js.native + def realpath(path: Path, options: FileEncodingOptions, callback: FsCallback1[Output]): Unit = js.native /** * Asynchronous realpath(2). The callback gets two arguments (err, resolvedPath). @@ -1099,13 +1118,18 @@ trait Fs extends js.Object with FSConstants { * @return undefined. * @example fs.writeFileSync(file, data[, options]) */ - def writeFileSync(file: Path | FileDescriptor, data: js.typedarray.Uint8Array, options: FileWriteOptions): Unit = - js.native - def writeFileSync(file: Path | FileDescriptor, data: js.typedarray.Uint8Array): Unit = js.native - def writeFileSync(file: Path | FileDescriptor, data: String, options: FileWriteOptions): Unit = js.native - def writeFileSync(file: Path | FileDescriptor, data: String): Unit = js.native - def writeFileSync(file: Path | FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit = js.native - def writeFileSync(file: Path | FileDescriptor, data: BufferLike): Unit = js.native + def writeFileSync(file: Path, data: js.typedarray.Uint8Array, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: Path, data: js.typedarray.Uint8Array): Unit = js.native + def writeFileSync(file: Path, data: String, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: Path, data: String): Unit = js.native + def writeFileSync(file: Path, data: BufferLike, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: Path, data: BufferLike): Unit = js.native + def writeFileSync(file: FileDescriptor, data: js.typedarray.Uint8Array, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: FileDescriptor, data: js.typedarray.Uint8Array): Unit = js.native + def writeFileSync(file: FileDescriptor, data: String, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: FileDescriptor, data: String): Unit = js.native + def writeFileSync(file: FileDescriptor, data: BufferLike, options: FileWriteOptions): Unit = js.native + def writeFileSync(file: FileDescriptor, data: BufferLike): Unit = js.native /** * Write buffer to the file specified by fd. @@ -1162,10 +1186,14 @@ object Fs extends Fs { trait FsPromises extends js.Object { def access(path: Path, mode: FileMode): js.Promise[Unit] = js.native - def appendFile(file: Path | FileDescriptor, data: String | Buffer, options: FileAppendOptions): js.Promise[Unit] = - js.native - def appendFile(file: Path | FileDescriptor, data: String | Buffer, encoding: String): js.Promise[Unit] = js.native - def appendFile(file: Path | FileDescriptor, data: String | Buffer): js.Promise[Unit] = js.native + def appendFile(file: Path, data: String, options: FileAppendOptions): js.Promise[Unit] = js.native + def appendFile(file: FileDescriptor, data: Buffer, options: FileAppendOptions): js.Promise[Unit] = js.native + def appendFile(file: Path, data: String, encoding: String): js.Promise[Unit] = js.native + def appendFile(file: FileDescriptor, data: Buffer, encoding: String): js.Promise[Unit] = js.native + def appendFile(file: Path, data: String): js.Promise[Unit] = js.native + def appendFile(file: Path, data: Buffer): js.Promise[Unit] = js.native + def appendFile(file: FileDescriptor, data: String): js.Promise[Unit] = js.native + def appendFile(file: FileDescriptor, data: Buffer): js.Promise[Unit] = js.native def chmod(path: Path, mode: FileMode): js.Promise[Unit] = js.native def chown(path: Path, uid: UID, gid: GID): js.Promise[Unit] = js.native @@ -1194,33 +1222,40 @@ object Fs extends Fs { def readdir(path: Path, options: FileEncodingOptions): js.Promise[js.Array[String]] = js.native def readdir(path: Path): js.Promise[js.Array[String]] = js.native def readlink(path: Path): js.Promise[String] = js.native - def readlink(path: Path, options: String | FileEncodingOptions): js.Promise[Output] = js.native + def readlink(path: Path, options: String): js.Promise[Output] = js.native + def readlink(path: Path, options: FileEncodingOptions): js.Promise[Output] = js.native def rename(oldPath: Path, newPath: Path): js.Promise[Unit] = js.native def rmdir(path: Path): js.Promise[Unit] = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def rmdir(path: Path, options: RmdirOptions): js.Promise[Unit] = js.native - def stat(path: Path, options: StatOptions): js.Promise[StatsVariant] = js.native - def stat(path: Path): js.Promise[StatsVariant] = js.native - def symlink(target: Path, path: Path, `type`: String): js.Promise[Unit] = js.native - def symlink(target: Path, path: Path): js.Promise[Unit] = js.native - def truncate(path: Path, length: Int): js.Promise[Unit] = js.native - def truncate(path: Path): js.Promise[Unit] = js.native - def unlink(path: Path): js.Promise[Unit] = js.native - def utimes(path: Path, atime: Time, mtime: Time): js.Promise[Unit] = js.native - def writeFile(file: Path | FileHandle, data: String | BufferLike, options: FileWriteOptions): js.Promise[Unit] = - js.native + def rmdir(path: Path, options: RmdirOptions): js.Promise[Unit] = js.native + def stat(path: Path, options: StatOptions): js.Promise[StatsVariant] = js.native + def stat(path: Path): js.Promise[StatsVariant] = js.native + def symlink(target: Path, path: Path, `type`: String): js.Promise[Unit] = js.native + def symlink(target: Path, path: Path): js.Promise[Unit] = js.native + def truncate(path: Path, length: Int): js.Promise[Unit] = js.native + def truncate(path: Path): js.Promise[Unit] = js.native + def unlink(path: Path): js.Promise[Unit] = js.native + def utimes(path: Path, atime: Time, mtime: Time): js.Promise[Unit] = js.native + def writeFile(file: Path, data: String, options: FileWriteOptions): js.Promise[Unit] = js.native + def writeFile(file: Path, data: BufferLike, options: FileWriteOptions): js.Promise[Unit] = js.native + def writeFile(file: FileHandle, data: String, options: FileWriteOptions): js.Promise[Unit] = js.native + def writeFile(file: FileHandle, data: BufferLike, options: FileWriteOptions): js.Promise[Unit] = js.native } @js.native trait FileHandle extends js.Object { val fd: FileDescriptor = js.native - def appendFile(data: String | Buffer, options: FileAppendOptions): js.Promise[Unit] = js.native - def appendFile(data: String | Buffer): js.Promise[Unit] = js.native - def chmod(mode: FileMode): js.Promise[Unit] = js.native - def chown(uid: UID, gid: GID): js.Promise[Unit] = js.native - def close(): js.Promise[Unit] = js.native - def datasync(): js.Promise[Unit] = js.native + def appendFile(data: String, options: FileAppendOptions): js.Promise[Unit] = js.native + def appendFile(data: String): js.Promise[Unit] = js.native + def appendFile(data: Buffer, options: FileAppendOptions): js.Promise[Unit] = js.native + def appendFile(data: Buffer): js.Promise[Unit] = js.native + + def chmod(mode: FileMode): js.Promise[Unit] = js.native + def chown(uid: UID, gid: GID): js.Promise[Unit] = js.native + def close(): js.Promise[Unit] = js.native + def datasync(): js.Promise[Unit] = js.native + def read[T <: js.typedarray.TypedArray[_, _]](buffer: T, offset: Int | Null, length: Int | Null, @@ -1238,6 +1273,7 @@ object Fs extends Fs { def truncate(): js.Promise[Unit] = js.native def truncate(length: Int): js.Promise[Unit] = js.native def utimes(atime: Time, mtime: Time): js.Promise[Unit] = js.native + def write[T <: js.typedarray.TypedArray[_, _]](buffer: T, offset: Int | Null, length: Int | Null, @@ -1249,10 +1285,16 @@ object Fs extends Fs { position: Int | Null ): js.Promise[BufferIOResult[js.typedarray.DataView]] = js.native def write(string: String, position: Int | Null, encoding: String): js.Promise[BufferIOResult[String]] = js.native - def writeFile(data: String | BufferLike, options: FileWriteOptions): js.Promise[Unit] = js.native - def writeFile(data: String | BufferLike): js.Promise[Unit] = js.native + + def writeFile(data: String, options: FileWriteOptions): js.Promise[Unit] = js.native + def writeFile(data: String): js.Promise[Unit] = js.native + def writeFile(data: BufferLike, options: FileWriteOptions): js.Promise[Unit] = js.native + def writeFile(data: BufferLike): js.Promise[Unit] = js.native + + @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) + def writev(buffers: js.Array[js.typedarray.ArrayBufferView], position: Int): js.Promise[Unit] = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) - def writev(buffers: js.Array[js.typedarray.ArrayBufferView], position: Int | Null): js.Promise[Unit] = js.native + def writev(buffers: js.Array[js.typedarray.ArrayBufferView]): js.Promise[Unit] = js.native } val promises: FsPromises = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala index 94712ef99..cad8c40f2 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/fs/package.scala @@ -37,25 +37,50 @@ package object fs { */ implicit final class FsExtensions(private val instance: Fs) extends AnyVal { @inline - def accessFuture(path: Buffer | String): Future[Unit] = { + def accessFuture(path: Path): Future[Unit] = { promiseWithError0[FileIOError](instance.access(path, _)) } @inline - def accessFuture(path: Buffer | String, mode: FileMode): Future[Unit] = { + def accessFuture(path: Path, mode: FileMode): Future[Unit] = { promiseWithError0[FileIOError](instance.access(path, mode, _)) } @inline - def appendFileFuture(file: Buffer | FileDescriptor | String, - data: Buffer | String, - options: FileAppendOptions = null - ): Future[Unit] = { + def appendFileFuture(file: Path, data: Buffer, options: FileAppendOptions): Future[Unit] = { promiseWithError0[FileIOError](instance.appendFile(file, data, options, _)) } + @inline + def appendFileFuture(file: Path, data: String, options: FileAppendOptions): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, options, _)) + } + @inline + def appendFileFuture(file: FileDescriptor, data: Buffer, options: FileAppendOptions): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, options, _)) + } + @inline + def appendFileFuture(file: FileDescriptor, data: String, options: FileAppendOptions): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, options, _)) + } + @inline + def appendFileFuture(file: Path, data: Buffer): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, _)) + } + @inline + def appendFileFuture(file: Path, data: String): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, _)) + } + @inline + def appendFileFuture(file: FileDescriptor, data: Buffer): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, _)) + } + @inline + def appendFileFuture(file: FileDescriptor, data: String): Future[Unit] = { + promiseWithError0[FileIOError](instance.appendFile(file, data, _)) + } @inline - def chmodFuture(path: Buffer | String, mode: FileMode): Future[Unit] = { + def chmodFuture(path: Path, mode: FileMode): Future[Unit] = { promiseWithError0[FileIOError](instance.chmod(path, mode, _)) } @@ -247,7 +272,18 @@ package object fs { } @inline - def readdirDirentFuture(path: Buffer | String): Future[js.Array[Dirent]] = { + def readdirDirentFuture(path: Buffer): Future[js.Array[Dirent]] = { + val callback: FsCallback1[js.Array[Dirent]] => Unit = { callback => + instance.readdir( + path, + ReaddirOptions(withFileTypes = true), + callback.asInstanceOf[FsCallback1[ReaddirArrays2]] + ) + } + promiseWithError1[FileIOError, js.Array[Dirent]](callback) + } + @inline + def readdirDirentFuture(path: String): Future[js.Array[Dirent]] = { val callback: FsCallback1[js.Array[Dirent]] => Unit = { callback => instance.readdir( path, @@ -259,22 +295,38 @@ package object fs { } @inline - def readFileFuture(file: Path | FileDescriptor, options: ReadFileOptions): Future[Output] = { + def readFileFuture(file: Path, options: ReadFileOptions): Future[Output] = { + promiseWithError1[FileIOError, Output](instance.readFile(file, options, _)) + } + @inline + def readFileFuture(file: FileDescriptor, options: ReadFileOptions): Future[Output] = { promiseWithError1[FileIOError, Output](instance.readFile(file, options, _)) } @inline - def readFileFuture(file: Path | FileDescriptor, encoding: String): Future[String] = { + def readFileFuture(file: Path, encoding: String): Future[String] = { + promiseWithError1[FileIOError, String](instance.readFile(file, encoding, _)) + } + @inline + def readFileFuture(file: FileDescriptor, encoding: String): Future[String] = { promiseWithError1[FileIOError, String](instance.readFile(file, encoding, _)) } @inline - def readFileFuture(file: Path | FileDescriptor): Future[Buffer] = { + def readFileFuture(file: Path): Future[Buffer] = { + promiseWithError1[FileIOError, Buffer](instance.readFile(file, _)) + } + @inline + def readFileFuture(file: FileDescriptor): Future[Buffer] = { promiseWithError1[FileIOError, Buffer](instance.readFile(file, _)) } @inline - def readlinkFuture(file: Path, options: String | FileEncodingOptions): Future[Output] = { + def readlinkFuture(file: Path, options: String): Future[Output] = { + promiseWithError1[FileIOError, Output](instance.readlink(file, options, _)) + } + @inline + def readlinkFuture(file: Path, options: FileEncodingOptions): Future[Output] = { promiseWithError1[FileIOError, Output](instance.readlink(file, options, _)) } @@ -289,7 +341,11 @@ package object fs { } @inline - def realpathFuture(file: Path, options: String | FileEncodingOptions): Future[Output] = { + def realpathFuture(file: Path, options: String): Future[Output] = { + promiseWithError1[FileIOError, Output](instance.realpath(file, options, _)) + } + @inline + def realpathFuture(file: Path, options: FileEncodingOptions): Future[Output] = { promiseWithError1[FileIOError, Output](instance.realpath(file, options, _)) } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/Http.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/Http.scala index 67d6cdc2e..dc334e1f2 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/Http.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/Http.scala @@ -47,23 +47,30 @@ trait Http extends js.Object { def createServer(requestListener: js.Function2[ClientRequest, ServerResponse, Any]): Server = js.native def createServer(): Server = js.native - def get(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = - js.native - def get(url: String | URL, options: RequestOptions): ClientRequest = js.native - def get(url: String | URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native - def get(url: String | URL): ClientRequest = js.native - def get(options: RequestOptions): ClientRequest = js.native - def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native + def get(url: String, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: String, options: RequestOptions): ClientRequest = js.native + def get(url: String, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: String): ClientRequest = js.native + def get(url: URL, options: RequestOptions): ClientRequest = js.native + def get(url: URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: URL): ClientRequest = js.native + def get(options: RequestOptions): ClientRequest = js.native + def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def maxHeaderSize: Int = js.native - def request(url: String | URL, options: RequestOptions): Unit = js.native - def request(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native - def request(url: String | URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native - def request(url: String | URL): Unit = js.native - def request(options: RequestOptions): Unit = js.native - def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: String, options: RequestOptions): Unit = js.native + def request(url: String, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: String, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: String): Unit = js.native + def request(url: URL, options: RequestOptions): Unit = js.native + def request(url: URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: URL): Unit = js.native + def request(options: RequestOptions): Unit = js.native + def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs14) def validateHeaderName(name: String): Unit = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala index e44758dcd..53a6af264 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http/ServerResponse.scala @@ -127,10 +127,12 @@ trait ServerResponse extends stream.Writable { def writeContinue(): Unit = js.native // Todo: Return this.type when Node.js v10 dropped - def writeHead(statusCode: Int, statusMessage: String, headers: js.Object | js.Dictionary[_]): Unit = js.native - def writeHead(statusCode: Int, statusMessage: String): Unit = js.native - def writeHead(statusCode: Int, headers: js.Object | js.Dictionary[_]): Unit = js.native - def writeHead(statusCode: Int): Unit = js.native + def writeHead(statusCode: Int, statusMessage: String, headers: js.Object): Unit = js.native + def writeHead(statusCode: Int, statusMessage: String, headers: js.Dictionary[_]): Unit = js.native + def writeHead(statusCode: Int, statusMessage: String): Unit = js.native + def writeHead(statusCode: Int, headers: js.Object): Unit = js.native + def writeHead(statusCode: Int, headers: js.Dictionary[_]): Unit = js.native + def writeHead(statusCode: Int): Unit = js.native def writeProcessing(): Unit = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2.scala index 98e778f8b..bb9306a00 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2.scala @@ -17,8 +17,8 @@ trait Http2 extends js.Object { js.native def createSecureServer(options: Http2SecureServerOptions): Http2SecureServer = js.native - def connect(authority: String | URL, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session = - js.native + def connect(authority: String, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session = js.native + def connect(authority: URL, options: Http2ConnectOptions, listener: js.Function): ClientHttp2Session = js.native def constants: Http2Constants = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Headers.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Headers.scala index a320eda4b..43bac459c 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Headers.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Headers.scala @@ -52,7 +52,9 @@ trait Http2Headers extends js.Object { def apply(key: String): js.UndefOr[String | js.Array[String]] = js.native @JSBracketAccess - def update(key: String, value: String | js.Array[String]): Unit = js.native + def update(key: String, value: String): Unit = js.native + @JSBracketAccess + def update(key: String, value: js.Array[String]): Unit = js.native } object Http2Headers { diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2ServerResponse.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2ServerResponse.scala index a41eaf81f..9da8726f2 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2ServerResponse.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2ServerResponse.scala @@ -28,12 +28,13 @@ class Http2ServerResponse extends stream.Writable with Http2TimeoutOps { callback: js.Function2[io.scalajs.nodejs.Error, ServerHttp2Stream, Any] ): Unit = js.native - def getHeader(name: String): String = js.native - def getHeaderNames(name: String): js.Array[String] = js.native - def getHeaders(): Http2Headers = js.native - def hasHeader(name: String): Boolean = js.native - def removeHeader(name: String): Unit = js.native - def setHeader(name: String, value: String | js.Array[String]): Unit = js.native + def getHeader(name: String): String = js.native + def getHeaderNames(name: String): js.Array[String] = js.native + def getHeaders(): Http2Headers = js.native + def hasHeader(name: String): Boolean = js.native + def removeHeader(name: String): Unit = js.native + def setHeader(name: String, value: String): Unit = js.native + def setHeader(name: String, value: js.Array[String]): Unit = js.native @deprecated("Use writableEnd", "Node.js v13.4.0, v12.16.0") def finished: Boolean = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala index 7c31466dd..9fdc2500f 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/Http2Session.scala @@ -27,13 +27,11 @@ trait Http2Session extends IEventEmitter { def encrypted: Boolean = js.native - def goaway(code: Int, lastStreamID: Int, opaqueData: TypedArray[_, _] | DataView): Unit = js.native - - def goaway(code: Int, lastStreamID: Int): Unit = js.native - - def goaway(code: Int): Unit = js.native - - def goaway(): Unit = js.native + def goaway(code: Int, lastStreamID: Int, opaqueData: TypedArray[_, _]): Unit = js.native + def goaway(code: Int, lastStreamID: Int, opaqueData: DataView): Unit = js.native + def goaway(code: Int, lastStreamID: Int): Unit = js.native + def goaway(code: Int): Unit = js.native + def goaway(): Unit = js.native def localSettings: Http2Settings = js.native def remoteSettings: Http2Settings = js.native @@ -42,9 +40,9 @@ trait Http2Session extends IEventEmitter { def pendingSettingsAck: Boolean = js.native - def ping(payload: TypedArray[_, _] | DataView, callback: js.Function): Boolean = js.native - - def ping(callback: js.Function): Boolean = js.native + def ping(payload: TypedArray[_, _], callback: js.Function): Boolean = js.native + def ping(payload: DataView, callback: js.Function): Boolean = js.native + def ping(callback: js.Function): Boolean = js.native def ref(): Unit = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala index 95bc2cca2..a162e42e5 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/http2/ServerHttp2Session.scala @@ -4,7 +4,8 @@ import scala.scalajs.js @js.native trait ServerHttp2Session extends Http2Session { - def altsvc(alt: String, originOrStream: js.|[Int, Origin]): Unit = js.native + def altsvc(alt: String, stream: Int): Unit = js.native + def altsvc(alt: String, origin: Origin): Unit = js.native def origin(origins: Origin*): Unit = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/Https.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/Https.scala index a7aca3bd6..ede525845 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/Https.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/Https.scala @@ -36,17 +36,22 @@ trait Https extends js.Object { def createServer(options: ServerOptions): Server = js.native def createServer(): Server = js.native - def get(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = - js.native - def get(url: String | URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native - def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native - - def request(url: String | URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native - def request(url: String | URL, options: RequestOptions): Unit = js.native - def request(url: String | URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native - def request(url: String | URL): Unit = js.native - def request(options: RequestOptions): Unit = js.native - def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def get(url: String, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: String, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(url: URL, callback: js.Function1[ServerResponse, Any]): ClientRequest = js.native + def get(options: RequestOptions, callback: js.Function): ClientRequest = js.native + + def request(url: String, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: String, options: RequestOptions): Unit = js.native + def request(url: String, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: String): Unit = js.native + def request(url: URL, options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: URL, options: RequestOptions): Unit = js.native + def request(url: URL, callback: js.Function1[ServerResponse, Any]): Unit = js.native + def request(url: URL): Unit = js.native + def request(options: RequestOptions): Unit = js.native + def request(options: RequestOptions, callback: js.Function1[ServerResponse, Any]): Unit = js.native } /** diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/package.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/package.scala index 408825fa0..6ba894e23 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/package.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/https/package.scala @@ -43,16 +43,20 @@ package object https { promiseCallback1[ServerResponse](https.request(options, _)) } - /** - * Makes a request to a secure web server. - */ @inline - def requestFuture(url: String | URL): Future[ServerResponse] = { + def requestFuture(url: String): Future[ServerResponse] = { promiseCallback1[ServerResponse](https.request(url, _)) } - @inline - def requestFuture(url: String | URL, options: RequestOptions): Future[ServerResponse] = { + def requestFuture(url: URL): Future[ServerResponse] = { + promiseCallback1[ServerResponse](https.request(url, _)) + } + @inline + def requestFuture(url: String, options: RequestOptions): Future[ServerResponse] = { + promiseCallback1[ServerResponse](https.request(url, options, _)) + } + @inline + def requestFuture(url: URL, options: RequestOptions): Future[ServerResponse] = { promiseCallback1[ServerResponse](https.request(url, options, _)) } } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/process/Process.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/process/Process.scala index dd2646011..0d37ec550 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/process/Process.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/process/Process.scala @@ -275,7 +275,10 @@ trait Process extends IEventEmitter { * This is a privileged operation, meaning you need to be root or have the CAP_SETGID capability. * @example process.initgroups(user, extra_group) */ - def initgroups(user: String | Int, extra_group: String | Int): js.Array[Int] = js.native + def initgroups(user: String, extra_group: String): js.Array[Int] = js.native + def initgroups(user: String, extra_group: Int): js.Array[Int] = js.native + def initgroups(user: Int, extra_group: String): js.Array[Int] = js.native + def initgroups(user: Int, extra_group: Int): js.Array[Int] = js.native def hasUncaughtExceptionCaptureCallback(): Boolean = js.native @@ -291,8 +294,9 @@ trait Process extends IEventEmitter { * like the kill system call. The signal sent may do something other than kill the target process. * @example process.kill(pid[, signal]) */ - def kill(pid: Int, signal: String | Int): Unit = js.native - def kill(pid: Int): Unit = js.native + def kill(pid: Int, signal: String): Unit = js.native + def kill(pid: Int, signal: Int): Unit = js.native + def kill(pid: Int): Unit = js.native /** * Returns an object describing the memory usage of the Node.js process measured in bytes. @@ -335,35 +339,39 @@ trait Process extends IEventEmitter { * @example process.setegid(id) * @since 2.0.0 */ - def setegid(id: String | Int): Unit = js.native + def setegid(id: String): Unit = js.native + def setegid(id: Int): Unit = js.native /** * Sets the effective user identity of the process. This accepts either a numerical ID or a username string. * If a username is specified, this method blocks while resolving it to a numerical ID. * @example process.seteuid(id) */ - def seteuid(id: String | Int): Unit = js.native + def seteuid(id: String): Unit = js.native + def seteuid(id: Int): Unit = js.native /** * Sets the group identity of the process. This accepts either a numerical ID or a groupname string. * If a groupname is specified, this method blocks while resolving it to a numerical ID. * @example process.setgid(id) */ - def setgid(id: String | Int): Unit = js.native + def setgid(id: String): Unit = js.native + def setgid(id: Int): Unit = js.native /** * Sets the supplementary group IDs. This is a privileged operation, meaning you need to be root or have the * CAP_SETGID capability. The list can contain group IDs, group names or both. * @example process.setgroups(groups) */ - def setgroups(groups: js.Array[Int] | js.Array[String] | js.Array[String | Int]): Unit = js.native + def setgroups(groups: js.Array[Int]): Unit = js.native /** * Sets the user identity of the process. This accepts either a numerical ID or a username string. * If a username is specified, this method blocks while resolving it to a numerical ID. * @example process.setuid(id) */ - def setuid(id: String | Int): Unit = js.native + def setuid(id: String): Unit = js.native + def setuid(id: Int): Unit = js.native def setUncaughtExceptionCaptureCallback(callback: js.Function): Unit = js.native def setUncaughtExceptionCaptureCallback(): Unit = js.native diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala index a2ab51cc0..0b9095d64 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/repl/REPLServer.scala @@ -32,7 +32,8 @@ trait REPLServer extends IEventEmitter with Interface { * @param keyword The command keyword (without a leading . character). * @param cmd The function to invoke when the command is processed. */ - def defineCommand(keyword: String, cmd: DefinedCommand | js.Function1[String, Any]): Unit = js.native + def defineCommand(keyword: String, cmd: DefinedCommand): Unit = js.native + def defineCommand(keyword: String, cmd: js.Function1[String, Any]): Unit = js.native /** * The replServer.displayPrompt() method readies the REPL instance for input from the user, printing the diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/stream/Stream.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/stream/Stream.scala index f3208c409..671eb1782 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/stream/Stream.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/stream/Stream.scala @@ -223,7 +223,8 @@ sealed trait IReadable extends LegacyStream { * a Transform stream instead. * @example readable.unshift(chunk) */ - def unshift(chunk: String | Uint8Array): Unit = js.native + def unshift(chunk: String): Unit = js.native + def unshift(chunk: Uint8Array): Unit = js.native /** * Versions of Node.js prior to v0.10 had streams that did not implement the entire Streams API as it is today. @@ -287,9 +288,10 @@ sealed trait IWritable extends LegacyStream { def destroyed: Boolean = js.native - def end(chunk: String | Uint8Array, callback: js.Function1[Error, Any]): this.type = js.native - def end(chunk: String | Uint8Array): this.type = js.native - + def end(chunk: String, callback: js.Function1[Error, Any]): this.type = js.native + def end(chunk: Uint8Array, callback: js.Function1[Error, Any]): this.type = js.native + def end(chunk: String): this.type = js.native + def end(chunk: Uint8Array): this.type = js.native def end(chunk: String, encoding: String, callback: js.Function1[Error, Any]): this.type = js.native def end(chunk: String, encoding: String): this.type = js.native def end(callback: js.Function1[Error, Any]): this.type = js.native @@ -323,8 +325,10 @@ sealed trait IWritable extends LegacyStream { @enableIf(io.scalajs.nodejs.internal.CompilerSwitches.gteNodeJs12) def writableObjectMode: Boolean = js.native - def write(chunk: Uint8Array | String, callback: js.Function1[Error, Any]): Boolean = js.native - def write(chunk: Uint8Array | String): Boolean = js.native + def write(chunk: Uint8Array, callback: js.Function1[Error, Any]): Boolean = js.native + def write(chunk: Uint8Array): Boolean = js.native + def write(chunk: String, callback: js.Function1[Error, Any]): Boolean = js.native + def write(chunk: String): Boolean = js.native def write(chunk: String, encoding: String): Boolean = js.native def write(chunk: String, encoding: String, callback: js.Function1[Error, Any]): Boolean = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala index c2eee36ca..d5436b456 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/url/URL.scala @@ -13,8 +13,9 @@ import scala.scalajs.js.| */ @js.native @JSImport("url", "URL") -class URL(input: String, base: String | URL) extends js.Object { - def this(input: String) = this(input, ???) +class URL(input: String, base: String) extends js.Object { + def this(input: String, base: URL) = this(input, "") + def this(input: String) = this(input, "") /** * The auth property is the username and password portion of the URL, also referred to as "userinfo". @@ -169,7 +170,8 @@ object URL extends js.Object { */ def domainToUnicode(domain: String): String = js.native - def fileURLToPath(url: URL | String): String = js.native + def fileURLToPath(url: URL): String = js.native + def fileURLToPath(url: String): String = js.native def pathToFileURL(url: String): URL = js.native } diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/util/TextDecoder.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/util/TextDecoder.scala index b617ff2cc..db7923e8c 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/util/TextDecoder.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/util/TextDecoder.scala @@ -15,8 +15,10 @@ class TextDecoder() extends js.Object { val fatal: Boolean = js.native val ignoreBOM: Boolean = js.native - def decode(buffer: ArrayBuffer | ArrayBufferView, options: TextDecodeOptions): String = js.native - def decode(buffer: ArrayBuffer | ArrayBufferView): String = js.native + def decode(buffer: ArrayBuffer, options: TextDecodeOptions): String = js.native + def decode(buffer: ArrayBufferView, options: TextDecodeOptions): String = js.native + def decode(buffer: ArrayBuffer): String = js.native + def decode(buffer: ArrayBufferView): String = js.native } @Factory diff --git a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala index 7f6446c74..eae850446 100644 --- a/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala +++ b/app/nodejs-v14/src/main/scala/io/scalajs/nodejs/worker_threads/Worker.scala @@ -1,6 +1,7 @@ package io.scalajs.nodejs.worker_threads import scala.scalajs.js +import scala.scalajs.js.| import scala.scalajs.js.annotation.JSImport @js.native @@ -16,7 +17,7 @@ class Worker(filename: String, workerOptions: WorkerOptions) extends js.Object w def threadId: Int = js.native - def stderr: io.scalajs.nodejs.stream.Readable = js.native - def stdout: io.scalajs.nodejs.stream.Readable = js.native - def stdin: js.|[io.scalajs.nodejs.stream.Writable, Null] = js.native + def stderr: io.scalajs.nodejs.stream.Readable = js.native + def stdout: io.scalajs.nodejs.stream.Readable = js.native + def stdin: io.scalajs.nodejs.stream.Writable | Null = js.native }