diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 05ae876..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -patreon: erynlynn diff --git a/.gitignore b/.gitignore index 82afbfe..edbcfff 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules/ .vscode build -roblox.toml \ No newline at end of file +roblox.toml +sourcemap.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b112a89..c5657e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## FORKED VERSION [4.0.0] +- Added `any` type annotations to many variables in the internal implementation in order to prevent crashes while using this library +- Added `--!nonstrict` compiler directive at the top of the script to expose types +- Added library-user-facing typings for `Promise`, `Error`, `Status` and the library itself. This fork uses the `(object :: any) :: PublicType` idiom to simplify the types to the library, allowing for better autocompletion and type annotations in a strict-mode Luau codebase + +No other changes have been made to the library's runtime behavior. + +Please notify me through the issues section if any issues are encountered related to type safety or crashes. Otherwise, please send any issues related to runtime behavior to the [original repository](https://github.com/evaera/roblox-lua-promise). + ## [4.0.0] ### Changed - `Promise:finally` no longer observes a rejection from a Promise. Calling `Promise:finally` is mostly transparent now. diff --git a/LICENSE b/LICENSE index acf72c8..e73391f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2022 Amber Grace Copyright (c) 2019 Eryn L. K. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 48233f8..70877c6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@
An implementation of Promise
similar to Promise/A+.
]=] -function Promise.fromEvent(event, predicate) +function Promise.fromEvent(event: any, predicate: any) predicate = predicate or function() return true end - return Promise._new(debug.traceback(nil, 2), function(resolve, _, onCancel) + return Promise._new(debug.traceback(nil, 2), function(resolve: any, _: any, onCancel: any) local connection local shouldDisconnect = false @@ -2019,8 +2153,8 @@ function Promise.fromEvent(event, predicate) -- Connect returns, connection will still be nil. This happens with events that queue up -- events when there's nothing connected, such as RemoteEvents - connection = event:Connect(function(...) - local callbackValue = predicate(...) + connection = event:Connect(function(...: any) + local callbackValue = (predicate :: any)(...) if callbackValue == true then resolve(...) @@ -2040,6 +2174,7 @@ function Promise.fromEvent(event, predicate) end onCancel(disconnect) + return end) end @@ -2053,7 +2188,7 @@ end @param callback (promise: Promise, ...: any) -- A callback that runs when an unhandled rejection happens. @return () -> () -- Function that unregisters the `callback` when called ]=] -function Promise.onUnhandledRejection(callback) +function Promise.onUnhandledRejection(callback: any) table.insert(Promise._unhandledRejectionCallbacks, callback) return function() @@ -2065,4 +2200,4 @@ function Promise.onUnhandledRejection(callback) end end -return Promise +return (Promise :: any) :: PromiseLib diff --git a/lib/init.spec.lua b/lib/init.spec.luau similarity index 100% rename from lib/init.spec.lua rename to lib/init.spec.luau diff --git a/rotriever.toml b/rotriever.toml deleted file mode 100644 index b105f14..0000000 --- a/rotriever.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "evaera/roblox-lua-promise" -version = "4.0.0" -author = "evaera" -content_root = "lib" -license = "MIT" - -[dependencies] diff --git a/selene.toml b/selene.toml deleted file mode 100644 index c1911be..0000000 --- a/selene.toml +++ /dev/null @@ -1 +0,0 @@ -std = "roblox+testez" \ No newline at end of file diff --git a/wally.toml b/wally.toml index 4d85244..49607de 100644 --- a/wally.toml +++ b/wally.toml @@ -1,6 +1,6 @@ [package] -name = "evaera/promise" -description = "Promise implementation for Roblox" +name = "ambers-careware/promise" +description = "Promise implementation for Roblox Luau" version = "4.0.0" license = "MIT" registry = "https://github.com/UpliftGames/wally-index"