Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Update aftman tools #25

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .stylua.toml

This file was deleted.

6 changes: 3 additions & 3 deletions aftman.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tools]
rojo = "rojo-rbx/rojo@7.3.0"
rojo = "rojo-rbx/rojo@7.4.1"
run-in-roblox = "rojo-rbx/[email protected]"
wally = "upliftgames/[email protected]"
stylua = "johnnymorganz/stylua@0.18.1"
selene = "kampfkarren/selene@0.25.0"
selene = "Kampfkarren/selene@0.27.1"
stylua = "JohnnyMorganz/stylua@0.20.0"
14 changes: 7 additions & 7 deletions src/Array/difference.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--!strict
local T = require(script.Parent.Parent.Types)

local toSet = require(script.Parent.toSet)
local toArray = require(script.Parent.Parent.Set.toArray)
local setDifference = require(script.Parent.Parent.Set.difference)
local SetDifference = require(script.Parent.Parent.Set.difference)
local ToArray = require(script.Parent.Parent.Set.toArray)
local ToSet = require(script.Parent.toSet)

--[=[
@function difference
Expand All @@ -23,20 +23,20 @@ local setDifference = require(script.Parent.Parent.Set.difference)
```
]=]
local function difference<V>(array: T.Array<V>, ...: T.Array<V>): T.Array<V>
local arraySet = toSet(array)
local arraySet = ToSet(array)
local otherSets = {}

for _, nextArray in { ... } do
if typeof(nextArray) ~= "table" then
continue
end

table.insert(otherSets, toSet(nextArray))
table.insert(otherSets, ToSet(nextArray))
end

local differenceSet = setDifference(arraySet, unpack(otherSets))
local differenceSet = SetDifference(arraySet, unpack(otherSets))

return toArray(differenceSet)
return ToArray(differenceSet)
end

return difference
8 changes: 4 additions & 4 deletions src/Array/difference.spec.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
return function()
local difference = require(script.Parent.difference)
local Difference = require(script.Parent.difference)

it("should return the difference between two arrays", function()
local array = { "hello", "world" }
local otherArray = { "cat", "dog", "hello" }

local newArray = difference(array, otherArray)
local newArray = Difference(array, otherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(1)
Expand All @@ -17,7 +17,7 @@ return function()
local array = { "hello", "world" }
local otherArray = { "cat", "dog", "hello" }

local newArray = difference(array, nil, otherArray)
local newArray = Difference(array, nil, otherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(1)
Expand All @@ -30,7 +30,7 @@ return function()
local otherArray = { "cat", "dog", "hello" }
local anotherArray = { "hello", "panda" }

local newArray = difference(array, otherArray, anotherArray)
local newArray = Difference(array, otherArray, anotherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(1)
Expand Down
14 changes: 7 additions & 7 deletions src/Array/differenceSymmetric.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--!strict
local T = require(script.Parent.Parent.Types)

local toSet = require(script.Parent.toSet)
local toArray = require(script.Parent.Parent.Set.toArray)
local setDifferenceSymmetric = require(script.Parent.Parent.Set.differenceSymmetric)
local SetDifferenceSymmetric = require(script.Parent.Parent.Set.differenceSymmetric)
local ToArray = require(script.Parent.Parent.Set.toArray)
local ToSet = require(script.Parent.toSet)

--[=[
@function differenceSymmetric
Expand All @@ -23,20 +23,20 @@ local setDifferenceSymmetric = require(script.Parent.Parent.Set.differenceSymmet
```
]=]
local function differenceSymmetric<V>(array: T.Array<V>, ...: T.Array<V>): T.Array<V>
local arraySet = toSet(array)
local arraySet = ToSet(array)
local otherSets = {}

for _, nextArray in { ... } do
if typeof(nextArray) ~= "table" then
continue
end

table.insert(otherSets, toSet(nextArray))
table.insert(otherSets, ToSet(nextArray))
end

local differenceSet = setDifferenceSymmetric(arraySet, unpack(otherSets))
local differenceSet = SetDifferenceSymmetric(arraySet, unpack(otherSets))

return toArray(differenceSet)
return ToArray(differenceSet)
end

return differenceSymmetric
8 changes: 4 additions & 4 deletions src/Array/differenceSymmetric.spec.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
return function()
local differenceSymmetric = require(script.Parent.differenceSymmetric)
local DifferenceSymmetric = require(script.Parent.differenceSymmetric)

it("should return the symmetric difference between two arrays", function()
local array = { "hello", "world" }
local otherArray = { "cat", "dog", "hello" }

local newArray = differenceSymmetric(array, otherArray)
local newArray = DifferenceSymmetric(array, otherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(3)
Expand All @@ -19,7 +19,7 @@ return function()
local array = { "hello", "world" }
local otherArray = { "cat", "dog", "hello" }

local newArray = differenceSymmetric(array, nil, otherArray)
local newArray = DifferenceSymmetric(array, nil, otherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(3)
Expand All @@ -34,7 +34,7 @@ return function()
local otherArray = { "cat", "dog", "hello" }
local anotherArray = { "hello", "panda" }

local newArray = differenceSymmetric(array, otherArray, anotherArray)
local newArray = DifferenceSymmetric(array, otherArray, anotherArray)

expect(newArray).to.be.a("table")
expect(#newArray).to.equal(4)
Expand Down
1 change: 1 addition & 0 deletions src/Array/is.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ return function()
expect(isArray({})).to.equal(false)
expect(isArray({ 1, 2, 3 })).to.equal(true)
expect(isArray({ hello = "world" })).to.equal(false)
--selene: allow(mixed_table)
expect(isArray({ 1, 2, hello = "world" })).to.equal(false)
expect(isArray({ 1, 2, 3, nil, 5 })).to.equal(true)
end)
Expand Down
1 change: 1 addition & 0 deletions src/Array/toSet.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--!strict
local Sift = script.Parent.Parent

local _T = require(Sift.Types)

--[=[
Expand Down
2 changes: 1 addition & 1 deletion src/Array/update.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--!strict
local Sift = script.Parent.Parent

local Util = require(Sift.Util)
local Copy = require(script.Parent.copy)
local Util = require(Sift.Util)

type Callback<T> = (index: number) -> T
type Updater<T> = (currentValue: T, index: number) -> T
Expand Down
2 changes: 1 addition & 1 deletion src/Array/zipAll.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--!strict
local Sift = script.Parent.Parent

local Reduce = require(script.Parent.reduce)
local None = require(Sift.None)
local Reduce = require(script.Parent.reduce)

--[=[
@function zipAll
Expand Down
2 changes: 1 addition & 1 deletion src/Dictionary/freeze.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--!strict
local _T = require(script.Parent.Parent.Types)
local Copy = require(script.Parent.copy)
local _T = require(script.Parent.Parent.Types)

--[=[
@function freeze
Expand Down
4 changes: 2 additions & 2 deletions src/Dictionary/mergeDeep.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--!strict
local Sift = script.Parent.Parent

local CopyDeep = require(script.Parent.copyDeep)
local None = require(Sift.None)
local copyDeep = require(script.Parent.copyDeep)

--[=[
@function mergeDeep
Expand Down Expand Up @@ -40,7 +40,7 @@ local function mergeDeep<T>(...: any): T
result[key] = nil
elseif type(value) == "table" then
if result[key] == nil or type(result[key]) ~= "table" then
result[key] = copyDeep(value)
result[key] = CopyDeep(value)
else
result[key] = mergeDeep(result[key], value)
end
Expand Down
4 changes: 2 additions & 2 deletions src/Dictionary/removeKey.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--!strict
local copy = require(script.Parent.copy)
local Copy = require(script.Parent.copy)

--[=[
@function removeKey
Expand All @@ -19,7 +19,7 @@ local copy = require(script.Parent.copy)
```
]=]
local function removeKey<K, V>(dictionary: { [K]: V }, key: K): { [K]: V }
local result = copy(dictionary)
local result = Copy(dictionary)

result[key] = nil

Expand Down
4 changes: 2 additions & 2 deletions src/Dictionary/removeKeys.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--!strict
local copy = require(script.Parent.copy)
local Copy = require(script.Parent.copy)

--[=[
@function removeKeys
Expand All @@ -18,7 +18,7 @@ local copy = require(script.Parent.copy)
```
]=]
local function removeKeys<K, V>(dictionary: { [K]: V }, ...: K): { [K]: V }
local result = copy(dictionary)
local result = Copy(dictionary)

for _, key in ipairs({ ... }) do
result[key] = nil
Expand Down
4 changes: 2 additions & 2 deletions src/Dictionary/set.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--!strict
local copy = require(script.Parent.copy)
local Copy = require(script.Parent.copy)

--[=[
@function set
Expand All @@ -19,7 +19,7 @@ local copy = require(script.Parent.copy)
```
]=]
local function set<K, V>(dictionary: { [K]: V }, key: K, value: V): { [K]: V }
local result = copy(dictionary)
local result = Copy(dictionary)

result[key] = value

Expand Down
4 changes: 2 additions & 2 deletions src/Dictionary/update.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--!strict
local copy = require(script.Parent.copy)
local Copy = require(script.Parent.copy)

--[=[
@function update
Expand Down Expand Up @@ -33,7 +33,7 @@ local function update<K, V, U, C>(
updater: ((value: V, key: K) -> U)?,
callback: ((key: K) -> C)?
): { [K]: V | U | C }
local result: { [K]: any } = copy(dictionary)
local result: { [K]: any } = Copy(dictionary)

if result[key] then
if updater then
Expand Down
6 changes: 3 additions & 3 deletions src/Set/add.spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
return function()
local add = require(script.Parent.add)
local Add = require(script.Parent.add)

it("should add values to a set", function()
local set = { hello = true }

local newSet = add(set, "world")
local newSet = Add(set, "world")

expect(newSet).to.be.a("table")

Expand All @@ -15,7 +15,7 @@ return function()
it("should not modify the original set", function()
local set = { hello = true }

add(set, "world")
Add(set, "world")

expect(set).to.be.a("table")

Expand Down
4 changes: 2 additions & 2 deletions src/Set/copy.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--!strict
local Sift = script.Parent.Parent

local copy = require(Sift.Dictionary.copy)
local Copy = require(Sift.Dictionary.copy)

--[=[
@function copy
Expand All @@ -18,4 +18,4 @@ local copy = require(Sift.Dictionary.copy)
local newSet = Copy(set) -- { hello = true }
```
]=]
return copy
return Copy
4 changes: 2 additions & 2 deletions src/Set/copy.spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
return function()
local copy = require(script.Parent.copy)
local Copy = require(script.Parent.copy)

it("should copy a set", function()
local set = { hello = true }

local newSet = copy(set)
local newSet = Copy(set)

expect(newSet).to.be.a("table")
expect(newSet).never.to.equal(set)
Expand Down
6 changes: 3 additions & 3 deletions src/Set/count.spec.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
return function()
local count = require(script.Parent.count)
local Count = require(script.Parent.count)

it("should count the number of values in a set", function()
local set = { hello = true, world = true }

expect(count(set)).to.equal(2)
expect(Count(set)).to.equal(2)
end)

it("should count the number of values in a set matching the predicate", function()
local set = { hello = true, world = true }

expect(count(set, function(value)
expect(Count(set, function(value)
return value == "hello"
end)).to.equal(1)
end)
Expand Down
6 changes: 3 additions & 3 deletions src/Set/delete.spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
return function()
local delete = require(script.Parent.delete)
local Delete = require(script.Parent.delete)

it("should delete a value from a set", function()
local set = { hello = true }

local newSet = delete(set, "hello")
local newSet = Delete(set, "hello")

expect(newSet).to.be.a("table")
expect(newSet).never.to.equal(set)
Expand All @@ -15,7 +15,7 @@ return function()
it("should not modify the original set", function()
local set = { hello = true }

delete(set, "hello")
Delete(set, "hello")

expect(set).to.be.a("table")
expect(set.hello).to.equal(true)
Expand Down
Loading
Loading