Skip to content

Commit

Permalink
apply stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
dig1t committed Apr 12, 2024
1 parent 93bd84a commit c07d251
Show file tree
Hide file tree
Showing 16 changed files with 391 additions and 397 deletions.
10 changes: 3 additions & 7 deletions src/Animation/init.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local Util = require(script.Parent.Util)

Expand Down Expand Up @@ -45,7 +45,7 @@ export type AnimationConfig = {
tweenInfo: TweenInfo?,
frameCallback: () -> (),
stopCallback: () -> (),
async: boolean?
async: boolean?,
}

--[=[
Expand Down Expand Up @@ -109,11 +109,7 @@ function Animation.animate(config: AnimationConfig): ()
end
end

local TweenBuild = TweenService:Create(
config.source,
config.tweenInfo,
config.stop
)
local TweenBuild = TweenService:Create(config.source, config.tweenInfo, config.stop)

TweenBuild:Play()

Expand Down
40 changes: 18 additions & 22 deletions src/Cache/init.luau
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local Util = require(script.Parent.Util)
local Maid = require(script.Parent.Maid)
local Util = require(script.Parent.Util)

type CacheSet = (self: CacheType, key: string, value: any, ttl: number?) -> boolean?

type CacheObject = {
key: string,
value: any,
ttl: number?
ttl: number?,
}

--[=[
Expand All @@ -19,7 +19,7 @@ type CacheObject = {
type CacheOptions = {
defaultTTL: number?,
checkInterval: number?,
maxKeys: number?
maxKeys: number?,
}

type CachedClass = {
Expand All @@ -38,19 +38,16 @@ type CachedClass = {
has: (self: CacheType, key: string) -> boolean,
destroy: (self: CacheType) -> (),

CacheType: CacheType
CacheType: CacheType,
}

type CachedInstance = {
_cache: { [string]: CacheEntry },
options: CacheOptions,
[any]: any
[any]: any,
}

export type CacheType = typeof(setmetatable(
{} :: CachedInstance,
{} :: CachedClass
))
export type CacheType = typeof(setmetatable({} :: CachedInstance, {} :: CachedClass))

--[=[
@within Cache
Expand All @@ -60,9 +57,9 @@ export type CacheType = typeof(setmetatable(
.expires number -- The unix timestamp of when the cache entry expires.
]=]
type CacheEntry = {
key: string;
value: any;
expires: number;
key: string,
value: any,
expires: number,
}

--[=[
Expand All @@ -78,7 +75,7 @@ Cache.__index = Cache
local defaultOptions = {
defaultTTL = 6000,
checkInterval = 600,
maxKeys = 0
maxKeys = 0,
}

--[=[
Expand All @@ -90,7 +87,10 @@ function Cache.new(options: CacheOptions?): CacheType
assert(typeof(options) == "table" or options == nil, "options must be a table or nil")

if options then
assert(typeof(options.defaultTTL) == "number" or options.defaultTTL == nil, "options.defaultTTL must be a number or nil")
assert(
typeof(options.defaultTTL) == "number" or options.defaultTTL == nil,
"options.defaultTTL must be a number or nil"
)
end

local self = setmetatable({}, Cache)
Expand Down Expand Up @@ -142,9 +142,9 @@ function Cache:set(key: string, value: any, ttl: number?): boolean
end

self._cache[key] = {
key = key;
value = value;
expires = ttl or Util.unix() + (self.options.defaultTTL or defaultOptions.defaultTTL)
key = key,
value = value,
expires = ttl or Util.unix() + (self.options.defaultTTL or defaultOptions.defaultTTL),
} :: CacheEntry

return true
Expand All @@ -171,11 +171,7 @@ end
]=]
function Cache:setMultiple(cacheObjects: { CacheObject }): boolean
for _, cacheObject: CacheObject in pairs(cacheObjects) do
local success: boolean? = self:set(
cacheObject.key,
cacheObject.value,
cacheObject.ttl
)
local success: boolean? = self:set(cacheObject.key, cacheObject.value, cacheObject.ttl)

if success ~= true then
return false
Expand Down
20 changes: 9 additions & 11 deletions src/GamePass/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,17 @@ end
function GamePass.watch(): nil
GamePass.unwatch() -- Prevent duplicating watchers

_maid:task(MarketplaceService.PromptGamePassPurchaseFinished:Connect(
function(player, passId, purchased)
if not purchased then
return
end
_maid:task(MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, passId, purchased)
if not purchased then
return
end

cache:set(`${player.UserId}-${passId}`, true)
cache:set(`${player.UserId}-${passId}`, true)

for _, callback in pairs(callbacks) do
callback(player, passId)
end
end)
)
for _, callback in pairs(callbacks) do
callback(player, passId)
end
end))

_maid:task(Players.PlayerRemoving:Connect(function(player: Player)
for key: string, _owned: boolean in pairs(cache:keys()) do
Expand Down
13 changes: 5 additions & 8 deletions src/Maid/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,24 @@ type MaidClass = {
clean: (self: MaidType) -> (),
destroy: (self: MaidType) -> (),

MaidType: MaidType
MaidType: MaidType,
}

type MaidInstance = {
_tasks: { [string]: MaidTask },
[any]: any
[any]: any,
}

export type MaidType = typeof(setmetatable(
{} :: MaidInstance,
{} :: MaidClass
))
export type MaidType = typeof(setmetatable({} :: MaidInstance, {} :: MaidClass))

type MaidTask = {
Connected: boolean?,
Disconnect: () -> (),
Destroy: (any) -> (),
destroy: (any) -> (),
destructor: (task: any) -> (),
[any]: any
}? | () -> ()? | Instance;
[any]: any,
}? | () -> ()? | Instance

--[=[
Task management class for cleaning up things for garbage collection.
Expand Down
Loading

0 comments on commit c07d251

Please sign in to comment.