Skip to content

Commit

Permalink
Go ahead with release.
Browse files Browse the repository at this point in the history
  • Loading branch information
howmanysmall committed Aug 9, 2023
1 parent c9eff81 commit 4a44d39
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ Janitor.rbxmx
build
Garbage

Packages/
Packages/

*.code-workspace
11 changes: 9 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2023-08-09
## [1.15.6] - 2023-08-09

### Added

- Added a small safeguard in `Janitor:LinkToInstances()` that prevents non-Instances.

### Changed

- The Promise dependency has been bumped to `4.0.0-rc.2`.
- Changed how the formatting of Janitor is (120 character lines).

### Fixed

- Fixed an error that would only happen if you set SuppressInstanceReDestroy (tries to clean it up). Thanks Meta-Maxim!

### Removed

- Removed `LegacyLinkToInstance`. This reduces the overall size of the package.
- "Removed" `LegacyLinkToInstance`. This reduces the overall size of the package. The function itself still technically exists,
just as a pointer to `LinkToInstance`, but it is not exported with the class type.
- Removed the Symbol ModuleScript. We're gonna use a metatable'd table instead from now on. This also reduces the size of the package.

## [1.15.5] - 2023-07-28

Expand Down
2 changes: 1 addition & 1 deletion docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ HttpService.HttpEnabled = HttpEnabled`}

```toml
[dependencies]
Janitor = "howmanysmall/janitor@^2.0.0"
Janitor = "howmanysmall/janitor@^1.15.6"
```

## Next
Expand Down
2 changes: 1 addition & 1 deletion moonwave.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
classOrder = ["Janitor", "RbxScriptConnection"]
classOrder = ["Janitor"]
changelog = true
gitSourceBranch = "main"

Expand Down
2 changes: 1 addition & 1 deletion selene.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
std = "roblox+testez"
std = "roblox+testez"
12 changes: 0 additions & 12 deletions src/Symbol.lua

This file was deleted.

48 changes: 38 additions & 10 deletions src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
-- Cleanup edge cases fixed by codesenseAye.

local Promise = require(script.Parent.Promise)
local Symbol = require(script.Symbol)

local IndicesReference = Symbol("IndicesReference")
local LinkToInstanceIndex = Symbol("LinkToInstanceIndex")
local IndicesReference = setmetatable({}, {
__tostring = function()
return "IndicesReference"
end;
})

local INVALID_METHOD_NAME = "Object is a %* and as such expected `true?` for the method name and instead got %*. Traceback: %*"
local LinkToInstanceIndex = setmetatable({}, {
__tostring = function()
return "LinkToInstanceIndex"
end;
})

local INVALID_METHOD_NAME =
"Object is a %* and as such expected `true?` for the method name and instead got %*. Traceback: %*"
local METHOD_NOT_FOUND_ERROR = "Object %* doesn't have method %*, are you sure you want to add it? Traceback: %*"
local NOT_A_PROMISE = "Invalid argument #1 to 'Janitor:AddPromise' (Promise expected, got %* (%*)) Traceback: %*"

Expand Down Expand Up @@ -41,6 +50,7 @@ Janitor.__index = Janitor
--[=[
@prop SuppressInstanceReDestroy boolean
@within Janitor
@since 1.15.4
Whether or not you want to suppress the re-destroying
of instances. Default is false, which is the original
Expand Down Expand Up @@ -150,7 +160,7 @@ type BooleanOrString = boolean | string
```
@param Object T -- The object you want to clean up.
@param MethodName? string|true -- The name of the method that will be used to clean up. If not passed, it will first check if the object's type exists in TypeDefaults, and if that doesn't exist, it assumes `Destroy`.
@param MethodName? boolean | string -- The name of the method that will be used to clean up. If not passed, it will first check if the object's type exists in TypeDefaults, and if that doesn't exist, it assumes `Destroy`.
@param Index? any -- The index that can be used to clean up the object manually.
@return T -- The object that was passed as the first argument.
]=]
Expand All @@ -172,11 +182,18 @@ function Janitor:Add<T>(Object: T, MethodName: BooleanOrString?, Index: any?): T

if TypeOf == "function" or TypeOf == "thread" then
if NewMethodName ~= true then
warn(string.format(INVALID_METHOD_NAME, TypeOf, tostring(NewMethodName), debug.traceback(nil :: any, 2)))
warn(string.format(INVALID_METHOD_NAME, TypeOf, tostring(NewMethodName), debug.traceback(nil, 2)))
end
else
if not (Object :: any)[NewMethodName] then
warn(string.format(METHOD_NOT_FOUND_ERROR, tostring(Object), tostring(NewMethodName), debug.traceback(nil :: any, 2)))
warn(
string.format(
METHOD_NOT_FOUND_ERROR,
tostring(Object),
tostring(NewMethodName),
debug.traceback(nil, 2)
)
)
end
end

Expand Down Expand Up @@ -212,7 +229,7 @@ end
]=]
function Janitor:AddPromise(PromiseObject)
if not Promise.is(PromiseObject) then
error(string.format(NOT_A_PROMISE, typeof(PromiseObject), tostring(PromiseObject), debug.traceback(nil :: any, 2)))
error(string.format(NOT_A_PROMISE, typeof(PromiseObject), tostring(PromiseObject), debug.traceback(nil, 2)))
end

if PromiseObject:getStatus() == Promise.Status.Started then
Expand Down Expand Up @@ -291,7 +308,11 @@ function Janitor:Remove(Index: any)
else
local ObjectMethod = Object[MethodName]
if ObjectMethod then
if self.SuppressInstanceReDestroy and MethodName == "Destroy" and typeof(Object) == "Instance" then
if
self.SuppressInstanceReDestroy
and MethodName == "Destroy"
and typeof(Object) == "Instance"
then
pcall(ObjectMethod, Object)
else
ObjectMethod(Object)
Expand Down Expand Up @@ -677,6 +698,8 @@ function Janitor:LinkToInstance(Object: Instance, AllowMultiple: boolean?): RBXS
end), "Disconnect", IndexToUse)
end

Janitor.LegacyLinkToInstance = Janitor.LinkToInstance

--[=[
Links several instances to a new Janitor, which is then returned.
Expand All @@ -685,7 +708,12 @@ end
]=]
function Janitor:LinkToInstances(...: Instance)
local ManualCleanup = Janitor.new()
for _, Object in {...} do
for Index = 1, select("#", ...) do
local Object = select(Index, ...)
if typeof(Object) ~= "Instance" then
continue
end

ManualCleanup:Add(self:LinkToInstance(Object, true), "Disconnect")
end

Expand Down
4 changes: 2 additions & 2 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
column_width = 248347834343
quote_style = "ForceDouble"
column_width = 120
quote_style = "ForceDouble"
2 changes: 1 addition & 1 deletion wally.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dependencies = []

[[package]]
name = "howmanysmall/janitor"
version = "1.15.4"
version = "1.15.6"
dependencies = [["Promise", "evaera/[email protected]"]]
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "A garbage collector object implementation for Roblox, featuring s
license = "MIT"
realm = "shared"
registry = "https://github.com/UpliftGames/wally-index"
version = "1.15.5"
version = "1.15.6"
exclude = [
"docs",
".moonwave",
Expand Down

0 comments on commit 4a44d39

Please sign in to comment.