diff --git a/.gitignore b/.gitignore index 26e4078..e53a910 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ Packages/_Workspace/* # Local IDE settings .vscode .idea/ +sourcemap.json # Code coverage data files **/luacov.* diff --git a/CHANGELOG.md b/CHANGELOG.md index d769c08..787cd04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Refactor structure to a rotriever workspace + ## 1.0.0 * add `indexOf` method to `String` type diff --git a/bin/ci.sh b/bin/ci.sh index 25aced8..88cac88 100755 --- a/bin/ci.sh +++ b/bin/ci.sh @@ -9,9 +9,9 @@ find Packages/Dev -name "*.robloxrc" | xargs rm -f find Packages/_Index -name "*.robloxrc" | xargs rm -f echo "Run static analysis" roblox-cli analyze test-model.project.json -selene src -stylua -c src +selene modules +stylua -c modules echo "Run tests in DEV" roblox-cli run --load.model test-model.project.json --run bin/spec.lua --lua.globals=__DEV__=true echo "Run tests in release" -roblox-cli run --load.model model.rbxmx --run bin/spec.lua +roblox-cli run --load.model model.rbxmx --run bin/spec.lua diff --git a/bin/spec.lua b/bin/spec.lua index b84cfd8..517a4db 100644 --- a/bin/spec.lua +++ b/bin/spec.lua @@ -17,13 +17,10 @@ local Root = script.Parent.LuauPolyfillTestModel local Packages = Root.Packages -- Load JestRoblox source into Packages folder so it's next to Roact as expected -local TestEZ= require(Root.Packages.Dev.TestEZ) +local TestEZ = require(Packages._Workspace:FindFirstChild("TestEZ", true)) -- Run all tests, collect results, and report to stdout. -local result = TestEZ.TestBootstrap:run( - { Packages.LuauPolyfill }, - TestEZ.Reporters.TextReporterQuiet -) +local result = TestEZ.TestBootstrap:run({ Packages._Workspace }, TestEZ.Reporters.TextReporterQuiet) if result.failureCount == 0 and #result.errors == 0 then ProcessService:ExitAsync(0) diff --git a/default.project.json b/default.project.json index 75c80ab..5d56e80 100644 --- a/default.project.json +++ b/default.project.json @@ -1,6 +1,6 @@ { "name": "RobloxLuauPolyfill", "tree": { - "$path": "src" + "$path": "modules" } } \ No newline at end of file diff --git a/modules/boolean/default.project.json b/modules/boolean/default.project.json new file mode 100644 index 0000000..6ab39e8 --- /dev/null +++ b/modules/boolean/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Boolean", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/boolean/rotriever.toml b/modules/boolean/rotriever.toml new file mode 100644 index 0000000..7a7816f --- /dev/null +++ b/modules/boolean/rotriever.toml @@ -0,0 +1,12 @@ +[package] +name = "Boolean" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +Number = { path = "../number" } + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/Array/.robloxrc b/modules/boolean/src/.robloxrc similarity index 100% rename from src/Array/.robloxrc rename to modules/boolean/src/.robloxrc diff --git a/src/Boolean/__tests__/toJSBoolean.spec.lua b/modules/boolean/src/__tests__/toJSBoolean.spec.lua similarity index 94% rename from src/Boolean/__tests__/toJSBoolean.spec.lua rename to modules/boolean/src/__tests__/toJSBoolean.spec.lua index a8d0d02..c12aed6 100644 --- a/src/Boolean/__tests__/toJSBoolean.spec.lua +++ b/modules/boolean/src/__tests__/toJSBoolean.spec.lua @@ -2,8 +2,7 @@ return function() local Boolean = script.Parent.Parent local toJSBoolean = require(Boolean.toJSBoolean) - local LuauPolyfill = Boolean.Parent - local Packages = LuauPolyfill.Parent + local Packages = Boolean.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Boolean/init.lua b/modules/boolean/src/init.lua similarity index 100% rename from src/Boolean/init.lua rename to modules/boolean/src/init.lua diff --git a/src/Boolean/toJSBoolean.lua b/modules/boolean/src/toJSBoolean.lua similarity index 91% rename from src/Boolean/toJSBoolean.lua rename to modules/boolean/src/toJSBoolean.lua index 4eeeda4..6ce55fb 100644 --- a/src/Boolean/toJSBoolean.lua +++ b/modules/boolean/src/toJSBoolean.lua @@ -13,8 +13,8 @@ * limitations under the License. ]] --!strict -local Polyfills = script.Parent.Parent -local Number = require(Polyfills.Number) +local Packages = script.Parent.Parent +local Number = require(Packages.Number) -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean return function(val: any): boolean diff --git a/modules/collections/rotriever.toml b/modules/collections/rotriever.toml new file mode 100644 index 0000000..75636b9 --- /dev/null +++ b/modules/collections/rotriever.toml @@ -0,0 +1,15 @@ +[package] +name = "Collections" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +InstanceOf = { path = "../instance-of" } +ES7Types = { path = "../es7-types" } + +[dev_dependencies] +Number = { path = "../number" } +JestGlobals = { workspace = true } +Promise = { workspace = true } diff --git a/src/Boolean/.robloxrc b/modules/collections/src/.robloxrc similarity index 100% rename from src/Boolean/.robloxrc rename to modules/collections/src/.robloxrc diff --git a/src/Array/__tests__/concat.spec.lua b/modules/collections/src/Array/__tests__/concat.spec.lua similarity index 96% rename from src/Array/__tests__/concat.spec.lua rename to modules/collections/src/Array/__tests__/concat.spec.lua index 5e6268a..9a85159 100644 --- a/src/Array/__tests__/concat.spec.lua +++ b/modules/collections/src/Array/__tests__/concat.spec.lua @@ -16,15 +16,15 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local concat = require(Array.concat) - local types = require(LuauPolyfill.types) - type Array = types.Array + local Packages = Array.Parent.Parent - local Packages = LuauPolyfill.Parent + local concat = require(Array.concat) + local types = require(Packages.ES7Types) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect + type Array = types.Array + it("concatenate arrays with single values", function() jestExpect(concat({ 1 })).toEqual({ 1 }) jestExpect(concat({ 1 }, { 2 })).toEqual({ 1, 2 }) diff --git a/src/Array/__tests__/every.spec.lua b/modules/collections/src/Array/__tests__/every.spec.lua similarity index 96% rename from src/Array/__tests__/every.spec.lua rename to modules/collections/src/Array/__tests__/every.spec.lua index 6464009..3672853 100644 --- a/src/Array/__tests__/every.spec.lua +++ b/modules/collections/src/Array/__tests__/every.spec.lua @@ -17,10 +17,9 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local every = require(Array.every) + local Packages = Array.Parent.Parent - local Packages = LuauPolyfill.Parent + local every = require(Array.every) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/filter.spec.lua b/modules/collections/src/Array/__tests__/filter.spec.lua similarity index 96% rename from src/Array/__tests__/filter.spec.lua rename to modules/collections/src/Array/__tests__/filter.spec.lua index f889dab..f568e23 100644 --- a/src/Array/__tests__/filter.spec.lua +++ b/modules/collections/src/Array/__tests__/filter.spec.lua @@ -17,16 +17,16 @@ return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) - type Array = types.Array - local filter = require(Array.filter) - local isFinite = require(LuauPolyfill.Number.isFinite) + local Packages = Array.Parent.Parent - local Packages = LuauPolyfill.Parent + local types = require(Packages.ES7Types) + local filter = require(Array.filter) + local isFinite = require(Packages.Dev.Number).isFinite local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect + type Array = types.Array + it("Filtering out all small values", function() local isBigEnough = function(value) return value >= 10 diff --git a/src/Array/__tests__/find.spec.lua b/modules/collections/src/Array/__tests__/find.spec.lua similarity index 93% rename from src/Array/__tests__/find.spec.lua rename to modules/collections/src/Array/__tests__/find.spec.lua index 9b766d6..277d443 100644 --- a/src/Array/__tests__/find.spec.lua +++ b/modules/collections/src/Array/__tests__/find.spec.lua @@ -14,15 +14,15 @@ ]] return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) - type Array = types.Array - local find = require(Array.find) + local Packages = Array.Parent.Parent - local Packages = LuauPolyfill.Parent + local find = require(Array.find) + local types = require(Packages.ES7Types) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect + type Array = types.Array + local function returnTrue() return true end diff --git a/src/Array/__tests__/findIndex.spec.lua b/modules/collections/src/Array/__tests__/findIndex.spec.lua similarity index 95% rename from src/Array/__tests__/findIndex.spec.lua rename to modules/collections/src/Array/__tests__/findIndex.spec.lua index f54f8da..40b895b 100644 --- a/src/Array/__tests__/findIndex.spec.lua +++ b/modules/collections/src/Array/__tests__/findIndex.spec.lua @@ -14,15 +14,15 @@ ]] return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) - type Array = types.Array - local findIndex = require(Array.findIndex) + local Packages = Array.Parent.Parent - local Packages = LuauPolyfill.Parent + local findIndex = require(Array.findIndex) + local types = require(Packages.ES7Types) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect + type Array = types.Array + local function returnTrue() return true end diff --git a/src/Array/__tests__/forEach.spec.lua b/modules/collections/src/Array/__tests__/forEach.spec.lua similarity index 94% rename from src/Array/__tests__/forEach.spec.lua rename to modules/collections/src/Array/__tests__/forEach.spec.lua index 1a8b526..95c088a 100644 --- a/src/Array/__tests__/forEach.spec.lua +++ b/modules/collections/src/Array/__tests__/forEach.spec.lua @@ -16,15 +16,16 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach return function() local Array = script.Parent.Parent - type Array = { [number]: T } - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local forEach = require(Array.forEach) local isArray = require(Array.isArray) + local types = require(Packages.ES7Types) + local JestGlobals = require(Packages.Dev.JestGlobals) + local jestExpect = JestGlobals.expect + local jest = JestGlobals.jest - local Packages = LuauPolyfill.Parent - local JestModule = require(Packages.Dev.JestGlobals) - local jestExpect = JestModule.expect - local jest = JestModule.jest + type Array = types.Array it("Invalid argument", function() -- roblox-cli analyze fails because forEach is called with an diff --git a/src/Array/__tests__/from.spec.lua b/modules/collections/src/Array/__tests__/from.spec.lua similarity index 95% rename from src/Array/__tests__/from.spec.lua rename to modules/collections/src/Array/__tests__/from.spec.lua index 38c7433..240d574 100644 --- a/src/Array/__tests__/from.spec.lua +++ b/modules/collections/src/Array/__tests__/from.spec.lua @@ -16,17 +16,18 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) - type Array = types.Array - local from = require(Array.from) - local Set = require(LuauPolyfill).Set - local Map = require(LuauPolyfill).Map + local Collections = Array.Parent + local Packages = Collections.Parent - local Packages = LuauPolyfill.Parent + local types = require(Packages.ES7Types) + local from = require(Array.from) + local Set = require(Collections.Set) + local Map = require(Collections.Map.Map) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect + type Array = types.Array + it("creates a array of characters given a string", function() jestExpect(from("bar")).toEqual({ "b", "a", "r" }) end) diff --git a/src/Array/__tests__/includes.spec.lua b/modules/collections/src/Array/__tests__/includes.spec.lua similarity index 96% rename from src/Array/__tests__/includes.spec.lua rename to modules/collections/src/Array/__tests__/includes.spec.lua index 5534c24..34a144b 100644 --- a/src/Array/__tests__/includes.spec.lua +++ b/modules/collections/src/Array/__tests__/includes.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local includes = require(Array.includes) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/indexOf.spec.lua b/modules/collections/src/Array/__tests__/indexOf.spec.lua similarity index 96% rename from src/Array/__tests__/indexOf.spec.lua rename to modules/collections/src/Array/__tests__/indexOf.spec.lua index 926ce64..eb11c26 100644 --- a/src/Array/__tests__/indexOf.spec.lua +++ b/modules/collections/src/Array/__tests__/indexOf.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local indexOf = require(Array.indexOf) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/isArray.spec.lua b/modules/collections/src/Array/__tests__/isArray.spec.lua similarity index 95% rename from src/Array/__tests__/isArray.spec.lua rename to modules/collections/src/Array/__tests__/isArray.spec.lua index 73911f7..c175e1c 100644 --- a/src/Array/__tests__/isArray.spec.lua +++ b/modules/collections/src/Array/__tests__/isArray.spec.lua @@ -16,12 +16,12 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) + local Packages = Array.Parent.Parent + + local types = require(Packages.ES7Types) type Array = types.Array local isArray = require(Array.isArray) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/join.spec.lua b/modules/collections/src/Array/__tests__/join.spec.lua similarity index 94% rename from src/Array/__tests__/join.spec.lua rename to modules/collections/src/Array/__tests__/join.spec.lua index 45aae32..7844e77 100644 --- a/src/Array/__tests__/join.spec.lua +++ b/modules/collections/src/Array/__tests__/join.spec.lua @@ -14,11 +14,12 @@ ]] return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Collections = Array.Parent + local Packages = Collections.Parent + local join = require(Array.join) - local Set = require(LuauPolyfill.Set) + local Set = require(Collections.Set) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/map.spec.lua b/modules/collections/src/Array/__tests__/map.spec.lua similarity index 97% rename from src/Array/__tests__/map.spec.lua rename to modules/collections/src/Array/__tests__/map.spec.lua index dd22150..549e59f 100644 --- a/src/Array/__tests__/map.spec.lua +++ b/modules/collections/src/Array/__tests__/map.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local map = require(Array.map) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/reduce.spec.lua b/modules/collections/src/Array/__tests__/reduce.spec.lua similarity index 96% rename from src/Array/__tests__/reduce.spec.lua rename to modules/collections/src/Array/__tests__/reduce.spec.lua index c6b5d2a..2b6fe1e 100644 --- a/src/Array/__tests__/reduce.spec.lua +++ b/modules/collections/src/Array/__tests__/reduce.spec.lua @@ -16,12 +16,12 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) + local Packages = Array.Parent.Parent + + local types = require(Packages.ES7Types) type Array = types.Array local reduce = require(Array.reduce) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/reverse.spec.lua b/modules/collections/src/Array/__tests__/reverse.spec.lua similarity index 93% rename from src/Array/__tests__/reverse.spec.lua rename to modules/collections/src/Array/__tests__/reverse.spec.lua index bcdd9a9..f070b5d 100644 --- a/src/Array/__tests__/reverse.spec.lua +++ b/modules/collections/src/Array/__tests__/reverse.spec.lua @@ -14,10 +14,10 @@ ]] return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local reverse = require(Array.reverse) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/shift.spec.lua b/modules/collections/src/Array/__tests__/shift.spec.lua similarity index 96% rename from src/Array/__tests__/shift.spec.lua rename to modules/collections/src/Array/__tests__/shift.spec.lua index 8164c60..3f9d65a 100644 --- a/src/Array/__tests__/shift.spec.lua +++ b/modules/collections/src/Array/__tests__/shift.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local shift = require(Array.shift) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/slice.spec.lua b/modules/collections/src/Array/__tests__/slice.spec.lua similarity index 96% rename from src/Array/__tests__/slice.spec.lua rename to modules/collections/src/Array/__tests__/slice.spec.lua index 36e9495..7e0b125 100644 --- a/src/Array/__tests__/slice.spec.lua +++ b/modules/collections/src/Array/__tests__/slice.spec.lua @@ -16,12 +16,12 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent - local types = require(LuauPolyfill.types) + local Packages = Array.Parent.Parent + + local types = require(Packages.ES7Types) type Array = types.Array local slice = require(Array.slice) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/some.spec.lua b/modules/collections/src/Array/__tests__/some.spec.lua similarity index 96% rename from src/Array/__tests__/some.spec.lua rename to modules/collections/src/Array/__tests__/some.spec.lua index 752cb45..9a7acb1 100644 --- a/src/Array/__tests__/some.spec.lua +++ b/modules/collections/src/Array/__tests__/some.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local some = require(Array.some) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/sort.spec.lua b/modules/collections/src/Array/__tests__/sort.spec.lua similarity index 96% rename from src/Array/__tests__/sort.spec.lua rename to modules/collections/src/Array/__tests__/sort.spec.lua index ecb9d4c..436a7f3 100644 --- a/src/Array/__tests__/sort.spec.lua +++ b/modules/collections/src/Array/__tests__/sort.spec.lua @@ -17,11 +17,12 @@ return function() local Array = script.Parent.Parent + local Collections = Array.Parent + local Packages = Collections.Parent + local sort = require(Array.sort) - local LuauPolyfill = Array.Parent - local Object = require(LuauPolyfill.Object) - local Packages = LuauPolyfill.Parent + local None = require(Collections.Object.None) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect @@ -33,7 +34,7 @@ return function() it("sorts string when compare function is Lua equivalent of 'undefined'", function() local months = { "March", "Jan", "Feb", "Dec" } - sort(months, Object.None) + sort(months, None) jestExpect(months).toEqual({ "Dec", "Feb", "Jan", "March" }) end) diff --git a/src/Array/__tests__/splice.spec.lua b/modules/collections/src/Array/__tests__/splice.spec.lua similarity index 97% rename from src/Array/__tests__/splice.spec.lua rename to modules/collections/src/Array/__tests__/splice.spec.lua index 050b63a..7954076 100644 --- a/src/Array/__tests__/splice.spec.lua +++ b/modules/collections/src/Array/__tests__/splice.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent + local Packages = Array.Parent.Parent + local splice = require(Array.splice) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/__tests__/unshift.spec.lua b/modules/collections/src/Array/__tests__/unshift.spec.lua similarity index 96% rename from src/Array/__tests__/unshift.spec.lua rename to modules/collections/src/Array/__tests__/unshift.spec.lua index df0d7f9..b6c7fab 100644 --- a/src/Array/__tests__/unshift.spec.lua +++ b/modules/collections/src/Array/__tests__/unshift.spec.lua @@ -16,10 +16,9 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ununshift return function() local Array = script.Parent.Parent - local LuauPolyfill = Array.Parent local unshift = require(Array.unshift) - local Packages = LuauPolyfill.Parent + local Packages = Array.Parent.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Array/concat.lua b/modules/collections/src/Array/concat.lua similarity index 96% rename from src/Array/concat.lua rename to modules/collections/src/Array/concat.lua index 8d821b8..a5d7436 100644 --- a/src/Array/concat.lua +++ b/modules/collections/src/Array/concat.lua @@ -14,9 +14,9 @@ ]] --!strict local Array = script.Parent +local Packages = Array.Parent.Parent local isArray = require(Array.isArray) -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local types = require(Packages.ES7Types) type Array = types.Array local RECEIVED_OBJECT_ERROR = "Array.concat(...) only works with array-like tables but " diff --git a/src/Array/every.lua b/modules/collections/src/Array/every.lua similarity index 94% rename from src/Array/every.lua rename to modules/collections/src/Array/every.lua index b9c0ca3..d82d0c8 100644 --- a/src/Array/every.lua +++ b/modules/collections/src/Array/every.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object type callbackFn = (element: T, index: number, array: Array) -> boolean diff --git a/src/Array/filter.lua b/modules/collections/src/Array/filter.lua similarity index 94% rename from src/Array/filter.lua rename to modules/collections/src/Array/filter.lua index 7d20eb5..81ce1e0 100644 --- a/src/Array/filter.lua +++ b/modules/collections/src/Array/filter.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object type callbackFn = (element: T, index: number, array: Array) -> boolean diff --git a/src/Array/find.lua b/modules/collections/src/Array/find.lua similarity index 89% rename from src/Array/find.lua rename to modules/collections/src/Array/find.lua index b5e8668..1f3dc32 100644 --- a/src/Array/find.lua +++ b/modules/collections/src/Array/find.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type PredicateFunction = (value: T, index: number, array: Array) -> boolean diff --git a/src/Array/findIndex.lua b/modules/collections/src/Array/findIndex.lua similarity index 89% rename from src/Array/findIndex.lua rename to modules/collections/src/Array/findIndex.lua index ecf2ea2..76e6616 100644 --- a/src/Array/findIndex.lua +++ b/modules/collections/src/Array/findIndex.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type PredicateFunction = (T, number, Array) -> boolean diff --git a/src/Array/forEach.lua b/modules/collections/src/Array/forEach.lua similarity index 94% rename from src/Array/forEach.lua rename to modules/collections/src/Array/forEach.lua index 4b36698..370b4e9 100644 --- a/src/Array/forEach.lua +++ b/modules/collections/src/Array/forEach.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object type callbackFn = (element: T, index: number, array: Array) -> () diff --git a/src/Array/from/fromArray.lua b/modules/collections/src/Array/from/fromArray.lua similarity index 95% rename from src/Array/from/fromArray.lua rename to modules/collections/src/Array/from/fromArray.lua index 91da629..df9155b 100644 --- a/src/Array/from/fromArray.lua +++ b/modules/collections/src/Array/from/fromArray.lua @@ -14,8 +14,8 @@ ]] --!strict local Array = script.Parent.Parent -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Object = types.Object type Array = types.Array diff --git a/src/Array/from/fromMap.lua b/modules/collections/src/Array/from/fromMap.lua similarity index 95% rename from src/Array/from/fromMap.lua rename to modules/collections/src/Array/from/fromMap.lua index 9e0c2e4..58c6f83 100644 --- a/src/Array/from/fromMap.lua +++ b/modules/collections/src/Array/from/fromMap.lua @@ -14,8 +14,8 @@ ]] --!strict local Array = script.Parent.Parent -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Object = types.Object type Array = types.Array type Map = types.Map diff --git a/src/Array/from/fromSet.lua b/modules/collections/src/Array/from/fromSet.lua similarity index 94% rename from src/Array/from/fromSet.lua rename to modules/collections/src/Array/from/fromSet.lua index 729c1ac..9d91d63 100644 --- a/src/Array/from/fromSet.lua +++ b/modules/collections/src/Array/from/fromSet.lua @@ -14,8 +14,8 @@ ]] --!strict local Array = script.Parent.Parent -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Object = types.Object type Array = types.Array type Set = types.Set diff --git a/src/Array/from/fromString.lua b/modules/collections/src/Array/from/fromString.lua similarity index 95% rename from src/Array/from/fromString.lua rename to modules/collections/src/Array/from/fromString.lua index ccf69ae..605608a 100644 --- a/src/Array/from/fromString.lua +++ b/modules/collections/src/Array/from/fromString.lua @@ -14,8 +14,8 @@ ]] --!strict local Array = script.Parent.Parent -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Object = types.Object type Array = types.Array diff --git a/src/Array/from/init.lua b/modules/collections/src/Array/from/init.lua similarity index 89% rename from src/Array/from/init.lua rename to modules/collections/src/Array/from/init.lua index 8571d05..95be1cd 100644 --- a/src/Array/from/init.lua +++ b/modules/collections/src/Array/from/init.lua @@ -14,19 +14,19 @@ ]] --!strict local Array = script.Parent -local LuauPolyfill = Array.Parent +local Collections = Array.Parent +local Packages = Collections.Parent +local Set = require(Collections.Set) +local Map = require(Collections.Map.Map) local isArray = require(Array.isArray) -local instanceof = require(LuauPolyfill.instanceof) -local Set = require(LuauPolyfill.Set) -local Map = require(LuauPolyfill.Map) +local instanceof = require(Packages.InstanceOf) +local types = require(Packages.ES7Types) local fromString = require(script.fromString) local fromSet = require(script.fromSet) local fromMap = require(script.fromMap) local fromArray = require(script.fromArray) -local types = require(LuauPolyfill.types) - type Array = types.Array type Object = types.Object type Set = types.Set diff --git a/src/Array/includes.lua b/modules/collections/src/Array/includes.lua similarity index 88% rename from src/Array/includes.lua rename to modules/collections/src/Array/includes.lua index 37ef4fb..85dc1cf 100644 --- a/src/Array/includes.lua +++ b/modules/collections/src/Array/includes.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array local indexOf = require(script.Parent.indexOf) diff --git a/src/Array/indexOf.lua b/modules/collections/src/Array/indexOf.lua similarity index 93% rename from src/Array/indexOf.lua rename to modules/collections/src/Array/indexOf.lua index 1219e94..5f1147c 100644 --- a/src/Array/indexOf.lua +++ b/modules/collections/src/Array/indexOf.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array -- Implements equivalent functionality to JavaScript's `array.indexOf`, diff --git a/src/Array/init.lua b/modules/collections/src/Array/init.lua similarity index 91% rename from src/Array/init.lua rename to modules/collections/src/Array/init.lua index ec4ff08..21356f8 100644 --- a/src/Array/init.lua +++ b/modules/collections/src/Array/init.lua @@ -13,6 +13,11 @@ * limitations under the License. ]] --!strict +local Packages = script.Parent.Parent +local ES7Types = require(Packages.ES7Types) + +export type Array = ES7Types.Array + return { concat = require(script.concat), every = require(script.every), diff --git a/src/Array/isArray.lua b/modules/collections/src/Array/isArray.lua similarity index 100% rename from src/Array/isArray.lua rename to modules/collections/src/Array/isArray.lua diff --git a/src/Array/join.lua b/modules/collections/src/Array/join.lua similarity index 87% rename from src/Array/join.lua rename to modules/collections/src/Array/join.lua index 0ca2374..611c077 100644 --- a/src/Array/join.lua +++ b/modules/collections/src/Array/join.lua @@ -13,10 +13,11 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array -local map = require(script.Parent.map) +local map = require(Array.map) return function(arr: Array, separator: string?): string if #arr == 0 then diff --git a/src/Array/map.lua b/modules/collections/src/Array/map.lua similarity index 94% rename from src/Array/map.lua rename to modules/collections/src/Array/map.lua index 75c3cf7..01b1443 100644 --- a/src/Array/map.lua +++ b/modules/collections/src/Array/map.lua @@ -14,8 +14,9 @@ ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object type callbackFn = (element: T, index: number, array: Array) -> U diff --git a/src/Array/reduce.lua b/modules/collections/src/Array/reduce.lua similarity index 94% rename from src/Array/reduce.lua rename to modules/collections/src/Array/reduce.lua index d36257f..a360587 100644 --- a/src/Array/reduce.lua +++ b/modules/collections/src/Array/reduce.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type reduceFn = (previousValue: U, currentValue: T, currentIndex: number, array: Array) -> U diff --git a/src/Array/reverse.lua b/modules/collections/src/Array/reverse.lua similarity index 89% rename from src/Array/reverse.lua rename to modules/collections/src/Array/reverse.lua index d734d97..92a5d5d 100644 --- a/src/Array/reverse.lua +++ b/modules/collections/src/Array/reverse.lua @@ -14,8 +14,9 @@ ]] --!strict -- https://programming-idioms.org/idiom/19/reverse-a-list/1314/lua -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array return function(t: Array): Array diff --git a/src/Array/shift.lua b/modules/collections/src/Array/shift.lua similarity index 92% rename from src/Array/shift.lua rename to modules/collections/src/Array/shift.lua index b464be3..0d0b99c 100644 --- a/src/Array/shift.lua +++ b/modules/collections/src/Array/shift.lua @@ -14,9 +14,9 @@ ]] --!strict local Array = script.Parent +local Packages = Array.Parent.Parent local isArray = require(Array.isArray) -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local types = require(Packages.ES7Types) type Array = types.Array return function(value: Array): T? diff --git a/src/Array/slice.lua b/modules/collections/src/Array/slice.lua similarity index 93% rename from src/Array/slice.lua rename to modules/collections/src/Array/slice.lua index 9c2fb79..e309702 100644 --- a/src/Array/slice.lua +++ b/modules/collections/src/Array/slice.lua @@ -13,9 +13,9 @@ * limitations under the License. ]] --!strict - -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array -- Implements Javascript's `Array.prototype.slice` as defined below, but with 1-indexing diff --git a/src/Array/some.lua b/modules/collections/src/Array/some.lua similarity index 94% rename from src/Array/some.lua rename to modules/collections/src/Array/some.lua index 4381a10..7469ce0 100644 --- a/src/Array/some.lua +++ b/modules/collections/src/Array/some.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object diff --git a/src/Array/sort.lua b/modules/collections/src/Array/sort.lua similarity index 89% rename from src/Array/sort.lua rename to modules/collections/src/Array/sort.lua index d77be06..a852065 100644 --- a/src/Array/sort.lua +++ b/modules/collections/src/Array/sort.lua @@ -13,9 +13,11 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local None = require(LuauPolyfill.Object.None) -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Collections = Array.Parent +local Packages = Collections.Parent +local None = require(Collections.Object.None) +local types = require(Packages.ES7Types) type Array = types.Array type Comparable = (any, any) -> number local defaultSort = function(a: T, b: T): boolean diff --git a/src/Array/splice.lua b/modules/collections/src/Array/splice.lua similarity index 95% rename from src/Array/splice.lua rename to modules/collections/src/Array/splice.lua index adbbf2a..0eeff32 100644 --- a/src/Array/splice.lua +++ b/modules/collections/src/Array/splice.lua @@ -13,8 +13,9 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Array = script.Parent +local Packages = Array.Parent.Parent +local types = require(Packages.ES7Types) type Array = types.Array -- Implements equivalent functionality to JavaScript's `array.splice`, including diff --git a/src/Array/unshift.lua b/modules/collections/src/Array/unshift.lua similarity index 93% rename from src/Array/unshift.lua rename to modules/collections/src/Array/unshift.lua index f63240b..915b0b0 100644 --- a/src/Array/unshift.lua +++ b/modules/collections/src/Array/unshift.lua @@ -14,9 +14,9 @@ ]] --!strict local Array = script.Parent +local Packages = Array.Parent.Parent local isArray = require(Array.isArray) -local LuauPolyfill = Array.Parent -local types = require(LuauPolyfill.types) +local types = require(Packages.ES7Types) type Array = types.Array return function(array: Array, ...: T): number diff --git a/src/Map/init.lua b/modules/collections/src/Map/Map.lua similarity index 95% rename from src/Map/init.lua rename to modules/collections/src/Map/Map.lua index efe5b0d..d97e1f9 100644 --- a/src/Map/init.lua +++ b/modules/collections/src/Map/Map.lua @@ -13,10 +13,12 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent -local arrayForEach = require(LuauPolyfill.Array.forEach) -local arrayMap = require(LuauPolyfill.Array.map) -local types = require(LuauPolyfill.types) +local Collections = script.Parent.Parent +local Packages = Collections.Parent + +local arrayForEach = require(Collections.Array.forEach) +local arrayMap = require(Collections.Array.map) +local types = require(Packages.ES7Types) type Object = types.Object type Array = types.Array type Table = types.Table diff --git a/src/__tests__/Map.spec.lua b/modules/collections/src/Map/__tests__/Map.spec.lua similarity index 97% rename from src/__tests__/Map.spec.lua rename to modules/collections/src/Map/__tests__/Map.spec.lua index e65cbec..86e8415 100644 --- a/src/__tests__/Map.spec.lua +++ b/modules/collections/src/Map/__tests__/Map.spec.lua @@ -14,23 +14,25 @@ ]] --!strict return function() - local LuauPolyfill = script.Parent.Parent + local MapModule = script.Parent.Parent + local Collections = MapModule.Parent + local Packages = Collections.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect local jest = JestGlobals.jest - local Array = require(LuauPolyfill.Array) - local types = require(LuauPolyfill.types) - type Function = types.Function - type Object = types.Object + local Array = require(Collections.Array) + local types = require(Packages.ES7Types) + local instanceOf = require(Packages.InstanceOf) + + local Map = require(MapModule.Map) + local coerceToMap = require(MapModule.coerceToMap) + local coerceToTable = require(MapModule.coerceToTable) - local Map = require(LuauPolyfill.Map) + type Function = types.Function type Map = types.Map - local coerceToMap = require(LuauPolyfill.Map.coerceToMap) - local coerceToTable = require(LuauPolyfill.Map.coerceToTable) - local instanceOf = require(LuauPolyfill.instanceof) + type Object = types.Object local AN_ITEM = "bar" local ANOTHER_ITEM = "baz" diff --git a/src/Map/coerceToMap.lua b/modules/collections/src/Map/coerceToMap.lua similarity index 77% rename from src/Map/coerceToMap.lua rename to modules/collections/src/Map/coerceToMap.lua index 9554fe8..0853aa6 100644 --- a/src/Map/coerceToMap.lua +++ b/modules/collections/src/Map/coerceToMap.lua @@ -12,11 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. ]] -local LuauPolyfill = script.Parent.Parent -local Map = require(script.Parent) -local Object = require(LuauPolyfill.Object) -local instanceOf = require(LuauPolyfill.instanceof) -local types = require(LuauPolyfill.types) +local MapModule = script.Parent +local Collections = MapModule.Parent +local Packages = Collections.Parent + +local Map = require(MapModule.Map) +local Object = require(Collections.Object) +local instanceOf = require(Packages.InstanceOf) +local types = require(Packages.ES7Types) + type Map = types.Map type Table = types.Table diff --git a/src/Map/coerceToTable.lua b/modules/collections/src/Map/coerceToTable.lua similarity index 77% rename from src/Map/coerceToTable.lua rename to modules/collections/src/Map/coerceToTable.lua index bf624b2..2ae52ba 100644 --- a/src/Map/coerceToTable.lua +++ b/modules/collections/src/Map/coerceToTable.lua @@ -12,11 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. ]] -local LuauPolyfill = script.Parent.Parent -local Map = require(script.Parent) -local instanceOf = require(LuauPolyfill.instanceof) -local arrayReduce = require(LuauPolyfill.Array.reduce) -local types = require(LuauPolyfill.types) +local MapModule = script.Parent +local Collections = MapModule.Parent +local Packages = Collections.Parent + +local Map = require(MapModule.Map) +local instanceOf = require(Packages.InstanceOf) +local arrayReduce = require(Collections.Array.reduce) +local types = require(Packages.ES7Types) + type Map = types.Map type Table = types.Table diff --git a/modules/collections/src/Map/init.lua b/modules/collections/src/Map/init.lua new file mode 100644 index 0000000..6035b56 --- /dev/null +++ b/modules/collections/src/Map/init.lua @@ -0,0 +1,15 @@ +local Packages = script.Parent.Parent + +local ES7Types = require(Packages.ES7Types) + +local Map = require(script.Map) +local coerceToMap = require(script.coerceToMap) +local coerceToTable = require(script.coerceToTable) + +export type Map = ES7Types.Map + +return { + Map = Map, + coerceToMap = coerceToMap, + coerceToTable = coerceToTable, +} diff --git a/src/Object/None.lua b/modules/collections/src/Object/None.lua similarity index 100% rename from src/Object/None.lua rename to modules/collections/src/Object/None.lua diff --git a/src/Object/__tests__/assign.spec.lua b/modules/collections/src/Object/__tests__/assign.spec.lua similarity index 97% rename from src/Object/__tests__/assign.spec.lua rename to modules/collections/src/Object/__tests__/assign.spec.lua index 9776a54..b54081b 100644 --- a/src/Object/__tests__/assign.spec.lua +++ b/modules/collections/src/Object/__tests__/assign.spec.lua @@ -15,12 +15,11 @@ --!strict return function() local Object = script.Parent.Parent - local None = require(Object.None) + local Packages = Object.Parent.Parent local assign = require(Object.assign) + local None = require(Object.None) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/entries.spec.lua b/modules/collections/src/Object/__tests__/entries.spec.lua similarity index 95% rename from src/Object/__tests__/entries.spec.lua rename to modules/collections/src/Object/__tests__/entries.spec.lua index 8883cb8..85955ab 100644 --- a/src/Object/__tests__/entries.spec.lua +++ b/modules/collections/src/Object/__tests__/entries.spec.lua @@ -17,13 +17,13 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries return function() local Object = script.Parent.Parent + local Packages = Object.Parent.Parent + local entries = require(Object.entries) - local LuauPolyfill = Object.Parent - local types = require(LuauPolyfill.types) + local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/freeze.spec.lua b/modules/collections/src/Object/__tests__/freeze.spec.lua similarity index 97% rename from src/Object/__tests__/freeze.spec.lua rename to modules/collections/src/Object/__tests__/freeze.spec.lua index 45d6a3d..04dd523 100644 --- a/src/Object/__tests__/freeze.spec.lua +++ b/modules/collections/src/Object/__tests__/freeze.spec.lua @@ -15,11 +15,11 @@ --!strict return function() local Object = script.Parent.Parent + local Packages = Object.Parent.Parent + local freeze = require(Object.freeze) local isFrozen = require(Object.isFrozen) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/is.spec.lua b/modules/collections/src/Object/__tests__/is.spec.lua similarity index 96% rename from src/Object/__tests__/is.spec.lua rename to modules/collections/src/Object/__tests__/is.spec.lua index 4c98216..403a5ae 100644 --- a/src/Object/__tests__/is.spec.lua +++ b/modules/collections/src/Object/__tests__/is.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is return function() local Object = script.Parent.Parent + local Packages = Object.Parent.Parent + local is = require(Object.is) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/keys.spec.lua b/modules/collections/src/Object/__tests__/keys.spec.lua similarity index 95% rename from src/Object/__tests__/keys.spec.lua rename to modules/collections/src/Object/__tests__/keys.spec.lua index 1e9c7d2..fed8388 100644 --- a/src/Object/__tests__/keys.spec.lua +++ b/modules/collections/src/Object/__tests__/keys.spec.lua @@ -14,11 +14,11 @@ ]] return function() local Object = script.Parent.Parent + local Collections = Object.Parent + local Packages = Collections.Parent local keys = require(Object.keys) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent - local Set = require(LuauPolyfill.Set) + local Set = require(Collections.Set) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/preventExtensions.spec.lua b/modules/collections/src/Object/__tests__/preventExtensions.spec.lua similarity index 96% rename from src/Object/__tests__/preventExtensions.spec.lua rename to modules/collections/src/Object/__tests__/preventExtensions.spec.lua index 754264e..6452192 100644 --- a/src/Object/__tests__/preventExtensions.spec.lua +++ b/modules/collections/src/Object/__tests__/preventExtensions.spec.lua @@ -14,10 +14,10 @@ ]] return function() local Object = script.Parent.Parent + local Packages = Object.Parent.Parent + local preventExtensions = require(Object.preventExtensions) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/__tests__/values.spec.lua b/modules/collections/src/Object/__tests__/values.spec.lua similarity index 95% rename from src/Object/__tests__/values.spec.lua rename to modules/collections/src/Object/__tests__/values.spec.lua index 327df9a..cb0198c 100644 --- a/src/Object/__tests__/values.spec.lua +++ b/modules/collections/src/Object/__tests__/values.spec.lua @@ -14,10 +14,10 @@ ]] return function() local Object = script.Parent.Parent + local Packages = Object.Parent.Parent + local values = require(Object.values) - local LuauPolyfill = Object.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Object/assign.lua b/modules/collections/src/Object/assign.lua similarity index 93% rename from src/Object/assign.lua rename to modules/collections/src/Object/assign.lua index d75d870..8abb4ce 100644 --- a/src/Object/assign.lua +++ b/modules/collections/src/Object/assign.lua @@ -13,9 +13,11 @@ * limitations under the License. ]] --!strict -local None = require(script.Parent.None) -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local None = require(Object.None) +local types = require(Packages.ES7Types) type Object = types.Object --[[ diff --git a/src/Object/entries.lua b/modules/collections/src/Object/entries.lua similarity index 93% rename from src/Object/entries.lua rename to modules/collections/src/Object/entries.lua index b486778..d84b083 100644 --- a/src/Object/entries.lua +++ b/modules/collections/src/Object/entries.lua @@ -13,7 +13,10 @@ * limitations under the License. ]] --!strict -local types = require(script.Parent.Parent.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array type Map = types.Map type Tuple = types.Tuple diff --git a/src/Object/freeze.lua b/modules/collections/src/Object/freeze.lua similarity index 88% rename from src/Object/freeze.lua rename to modules/collections/src/Object/freeze.lua index 6a998de..f1fe93e 100644 --- a/src/Object/freeze.lua +++ b/modules/collections/src/Object/freeze.lua @@ -13,8 +13,10 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object diff --git a/src/Object/init.lua b/modules/collections/src/Object/init.lua similarity index 99% rename from src/Object/init.lua rename to modules/collections/src/Object/init.lua index 0f9dff8..07c9742 100644 --- a/src/Object/init.lua +++ b/modules/collections/src/Object/init.lua @@ -13,6 +13,7 @@ * limitations under the License. ]] --!strict + return { assign = require(script.assign), entries = require(script.entries), diff --git a/src/Object/is.lua b/modules/collections/src/Object/is.lua similarity index 100% rename from src/Object/is.lua rename to modules/collections/src/Object/is.lua diff --git a/src/Object/isFrozen.lua b/modules/collections/src/Object/isFrozen.lua similarity index 88% rename from src/Object/isFrozen.lua rename to modules/collections/src/Object/isFrozen.lua index df407dd..0868911 100644 --- a/src/Object/isFrozen.lua +++ b/modules/collections/src/Object/isFrozen.lua @@ -13,8 +13,10 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object diff --git a/src/Object/keys.lua b/modules/collections/src/Object/keys.lua similarity index 84% rename from src/Object/keys.lua rename to modules/collections/src/Object/keys.lua index d54f84d..23685e8 100644 --- a/src/Object/keys.lua +++ b/modules/collections/src/Object/keys.lua @@ -12,10 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. ]] -local LuauPolyfill = script.Parent.Parent -local Set = require(LuauPolyfill.Set) -local instanceOf = require(LuauPolyfill.instanceof) -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Collections = Object.Parent +local Packages = Object.Parent.Parent + +local Set = require(Collections.Set) +local types = require(Packages.ES7Types) +local instanceOf = require(Packages.InstanceOf) type Array = types.Array type Set = types.Set type Table = { [any]: any } diff --git a/src/Object/preventExtensions.lua b/modules/collections/src/Object/preventExtensions.lua similarity index 91% rename from src/Object/preventExtensions.lua rename to modules/collections/src/Object/preventExtensions.lua index 7416851..a094a10 100644 --- a/src/Object/preventExtensions.lua +++ b/modules/collections/src/Object/preventExtensions.lua @@ -13,8 +13,10 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object diff --git a/src/Object/seal.lua b/modules/collections/src/Object/seal.lua similarity index 88% rename from src/Object/seal.lua rename to modules/collections/src/Object/seal.lua index 6a998de..f1fe93e 100644 --- a/src/Object/seal.lua +++ b/modules/collections/src/Object/seal.lua @@ -13,8 +13,10 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array type Object = types.Object diff --git a/src/Object/values.lua b/modules/collections/src/Object/values.lua similarity index 92% rename from src/Object/values.lua rename to modules/collections/src/Object/values.lua index 5262c02..cc73a0b 100644 --- a/src/Object/values.lua +++ b/modules/collections/src/Object/values.lua @@ -13,8 +13,10 @@ * limitations under the License. ]] --!strict -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Object = script.Parent +local Packages = Object.Parent.Parent + +local types = require(Packages.ES7Types) type Array = types.Array -- TODO Luau: needs overloads to model this more correctly diff --git a/src/__tests__/Set.spec.lua b/modules/collections/src/Set/__tests__/Set.spec.lua similarity index 98% rename from src/__tests__/Set.spec.lua rename to modules/collections/src/Set/__tests__/Set.spec.lua index 15f5f25..92feba9 100644 --- a/src/__tests__/Set.spec.lua +++ b/modules/collections/src/Set/__tests__/Set.spec.lua @@ -14,13 +14,14 @@ ]] --!strict return function() - local LuauPolyfill = script.Parent.Parent - local types = require(LuauPolyfill.types) + local SetModule = script.Parent.Parent + local Packages = SetModule.Parent.Parent + + local types = require(Packages.ES7Types) type Object = types.Object type Set = types.Set - local Set = require(LuauPolyfill.Set) + local Set = require(SetModule) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect local jest = JestGlobals.jest diff --git a/src/Set.lua b/modules/collections/src/Set/init.lua similarity index 91% rename from src/Set.lua rename to modules/collections/src/Set/init.lua index 48a6daa..06d2038 100644 --- a/src/Set.lua +++ b/modules/collections/src/Set/init.lua @@ -13,19 +13,21 @@ * limitations under the License. ]] --!nonstrict -local LuauPolyfill = script.Parent ---local Array = require(LuauPolyfill.Array) -local isArray = require(LuauPolyfill.Array.isArray) -local arrayFromString = require(LuauPolyfill.Array.from.fromString) -local arrayForEach = require(LuauPolyfill.Array.forEach) -local types = require(LuauPolyfill.types) +local Collections = script.Parent +local Packages = Collections.Parent + +local inspect = require(Collections.inspect) +local isArray = require(Collections.Array.isArray) +local arrayForEach = require(Collections.Array.forEach) +local arrayFromString = require(Collections.Array.from.fromString) + +local types = require(Packages.ES7Types) + type Array = types.Array type Object = types.Object type setCallbackFn = types.setCallbackFn type setCallbackFnWithThisArg = types.setCallbackFnWithThisArg -type Set = types.Set - -local inspect = require(LuauPolyfill.util.inspect) +export type Set = types.Set type Set_Statics = { new: (iterable: Array | Set | string | nil) -> Set, diff --git a/src/WeakMap.lua b/modules/collections/src/WeakMap.lua similarity index 100% rename from src/WeakMap.lua rename to modules/collections/src/WeakMap.lua diff --git a/src/__tests__/WeakMap.spec.lua b/modules/collections/src/__tests__/WeakMap.spec.lua similarity index 94% rename from src/__tests__/WeakMap.spec.lua rename to modules/collections/src/__tests__/WeakMap.spec.lua index d426886..a7c89e5 100644 --- a/src/__tests__/WeakMap.spec.lua +++ b/modules/collections/src/__tests__/WeakMap.spec.lua @@ -13,13 +13,13 @@ * limitations under the License. ]] return function() - local LuauPolyfill = script.Parent.Parent + local root = script.Parent.Parent + local Packages = root.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect - local WeakMap = require(LuauPolyfill.WeakMap) + local WeakMap = require(root.WeakMap) describe("WeakMap", function() it("should be imported", function() diff --git a/src/util/__tests__/inspect.spec.lua b/modules/collections/src/__tests__/inspect.spec.lua similarity index 92% rename from src/util/__tests__/inspect.spec.lua rename to modules/collections/src/__tests__/inspect.spec.lua index a4b06d6..8e1e896 100644 --- a/src/util/__tests__/inspect.spec.lua +++ b/modules/collections/src/__tests__/inspect.spec.lua @@ -16,14 +16,17 @@ -- https://github.com/graphql/graphql-js/blob/1951bce42092123e844763b6a8e985a8a3327511/src/jsutils/__tests__/inspect-test.js -- https://github.com/edam/inspect.lua/blob/master/spec/inspect_spec.lua return function() - local LuauPolyfill = script.Parent.Parent.Parent - local Packages = LuauPolyfill.Parent + local root = script.Parent.Parent + local Packages = root.Parent + + local inspect = require(root.inspect) + local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect local Promise = require(Packages.Dev.Promise) - local inspect = require(LuauPolyfill).util.inspect - local Set = require(LuauPolyfill).Set - local types = require(LuauPolyfill.types) + local Set = require(root.Set) + local types = require(Packages.ES7Types) + type Array = types.Array type Object = types.Object @@ -80,7 +83,7 @@ return function() -- deviation: Lua does not handle nil elements jestExpect(inspect({ true })).toBe("[true]") jestExpect(inspect({ 1, 0 / 0 })).toBe("[1, NaN]") - jestExpect(inspect({ { "a", "b" }, "c" } :: Array)).toBe('[["a", "b"], "c"]') + jestExpect(inspect({ { "a", "b" } :: Array | string, "c" })).toBe('[["a", "b"], "c"]') jestExpect(inspect({ { {} } })).toBe("[[[]]]") jestExpect(inspect({ { { "a" } } })).toBe("[[[Array]]]") @@ -100,7 +103,7 @@ return function() -- jestExpect(inspect({})).toBe("{}") jestExpect(inspect({ a = 1 })).toBe("{ a: 1 }") jestExpect(inspect({ a = 1, b = 2 })).toBe("{ a: 1, b: 2 }") - jestExpect(inspect({ array = { false, 0 } :: Array })).toBe("{ array: [false, 0] }") + jestExpect(inspect({ array = { false :: boolean | number, 0 } })).toBe("{ array: [false, 0] }") jestExpect(inspect({ a = { b = {} } })).toBe("{ a: { b: [] } }") jestExpect(inspect({ a = { b = { c = 1 } } })).toBe("{ a: { b: [Object] } }") @@ -116,8 +119,8 @@ return function() end) it("Set", function() - jestExpect(inspect(Set.new({ 31337, "foo" } :: Array))).toBe('Set (2) [31337, "foo"]') - jestExpect(inspect(Set.new({ Set.new({ 90210, "baz" } :: Array) }))).toBe( + jestExpect(inspect(Set.new({ 31337 :: number | string, "foo" }))).toBe('Set (2) [31337, "foo"]') + jestExpect(inspect(Set.new({ Set.new({ 90210 :: number | string, "baz" } :: Array) }))).toBe( 'Set (1) [Set (2) [90210, "baz"]]' ) jestExpect(inspect(Set.new({}))).toBe("Set []") diff --git a/modules/collections/src/init.lua b/modules/collections/src/init.lua new file mode 100644 index 0000000..31b7684 --- /dev/null +++ b/modules/collections/src/init.lua @@ -0,0 +1,28 @@ +--!strict +local Packages = script.Parent + +local Array = require(script.Array) +local Map = require(script.Map) +local Object = require(script.Object) +local Set = require(script.Set) +local WeakMap = require(script.WeakMap) +local inspect = require(script.inspect) + +local types = require(Packages.ES7Types) + +export type Array = types.Array +export type Map = types.Map +export type Object = types.Object +export type Set = types.Set +export type WeakMap = WeakMap.WeakMap + +return { + Array = Array, + Object = Object, + Map = Map.Map, + coerceToMap = Map.coerceToMap, + coerceToTable = Map.coerceToTable, + Set = Set, + WeakMap = WeakMap, + inspect = inspect, +} diff --git a/src/util/inspect.lua b/modules/collections/src/inspect.lua similarity index 96% rename from src/util/inspect.lua rename to modules/collections/src/inspect.lua index cb07d44..0702ff9 100644 --- a/src/util/inspect.lua +++ b/modules/collections/src/inspect.lua @@ -14,13 +14,15 @@ ]] -- derived from these upstream sources: -- https://github.com/graphql/graphql-js/blob/1951bce42092123e844763b6a8e985a8a3327511/src/jsutils/inspect.js - -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) -type Array = types.Array local HttpService = game:GetService("HttpService") -local isArray = require(LuauPolyfill.Array.isArray) +local Collections = script.Parent +local Packages = Collections.Parent + +local isArray = require(Collections.Array.isArray) +local ES7Types = require(Packages.ES7Types) + +type Array = ES7Types.Array -- local NULL = require(srcWorkspace.luaUtils.null) -- Support for options partial implementation diff --git a/modules/console/default.project.json b/modules/console/default.project.json new file mode 100644 index 0000000..9eae661 --- /dev/null +++ b/modules/console/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Console", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/console/rotriever.toml b/modules/console/rotriever.toml new file mode 100644 index 0000000..5163c04 --- /dev/null +++ b/modules/console/rotriever.toml @@ -0,0 +1,12 @@ +[package] +name = "Console" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +Collections = { path = "../collections" } + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/Error/.robloxrc b/modules/console/src/.robloxrc similarity index 100% rename from src/Error/.robloxrc rename to modules/console/src/.robloxrc diff --git a/src/console/__tests__/console.spec.lua b/modules/console/src/__tests__/console.spec.lua similarity index 98% rename from src/console/__tests__/console.spec.lua rename to modules/console/src/__tests__/console.spec.lua index a63f915..0b4eedb 100644 --- a/src/console/__tests__/console.spec.lua +++ b/modules/console/src/__tests__/console.spec.lua @@ -15,10 +15,10 @@ return function() type Function = (...any) -> ...any local consoleModule = script.Parent.Parent + local Packages = consoleModule.Parent + local makeConsoleImpl = require(consoleModule.makeConsoleImpl) - local LuauPolyfill = consoleModule.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/console/init.lua b/modules/console/src/init.lua similarity index 100% rename from src/console/init.lua rename to modules/console/src/init.lua diff --git a/src/console/makeConsoleImpl.lua b/modules/console/src/makeConsoleImpl.lua similarity index 95% rename from src/console/makeConsoleImpl.lua rename to modules/console/src/makeConsoleImpl.lua index 91f4a3c..a2be5dc 100644 --- a/src/console/makeConsoleImpl.lua +++ b/modules/console/src/makeConsoleImpl.lua @@ -13,8 +13,11 @@ * limitations under the License. ]] --!strict +local root = script.Parent +local Packages = root.Parent +local inspect = require(Packages.Collections).inspect + local INDENT = " " -local inspect = require(script.Parent.Parent.util).inspect return function() local console = {} diff --git a/modules/es7-types/default.project.json b/modules/es7-types/default.project.json new file mode 100644 index 0000000..22e8f07 --- /dev/null +++ b/modules/es7-types/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "ES7Types", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/es7-types/rotriever.toml b/modules/es7-types/rotriever.toml new file mode 100644 index 0000000..68045f0 --- /dev/null +++ b/modules/es7-types/rotriever.toml @@ -0,0 +1,6 @@ +[package] +name = "ES7Types" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] diff --git a/src/types.lua b/modules/es7-types/src/init.lua similarity index 100% rename from src/types.lua rename to modules/es7-types/src/init.lua diff --git a/modules/instance-of/default.project.json b/modules/instance-of/default.project.json new file mode 100644 index 0000000..29553eb --- /dev/null +++ b/modules/instance-of/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "InstanceOf", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/instance-of/rotriever.toml b/modules/instance-of/rotriever.toml new file mode 100644 index 0000000..ae77274 --- /dev/null +++ b/modules/instance-of/rotriever.toml @@ -0,0 +1,12 @@ +[package] +name = "InstanceOf" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] + +[dev_dependencies] +Collections = { path = "../collections" } +JestGlobals = { workspace = true } diff --git a/src/Math/.robloxrc b/modules/instance-of/src/.robloxrc similarity index 100% rename from src/Math/.robloxrc rename to modules/instance-of/src/.robloxrc diff --git a/src/__tests__/instanceof.spec.lua b/modules/instance-of/src/__tests__/instanceof.spec.lua similarity index 91% rename from src/__tests__/instanceof.spec.lua rename to modules/instance-of/src/__tests__/instanceof.spec.lua index 9d7afdf..13953e3 100644 --- a/src/__tests__/instanceof.spec.lua +++ b/modules/instance-of/src/__tests__/instanceof.spec.lua @@ -1,3 +1,4 @@ +--!strict --[[ * Copyright (c) Roblox Corporation. All rights reserved. * Licensed under the MIT License (the "License"); @@ -12,20 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. ]] ---!nocheck return function() - local LuauPolyfillModule = script.Parent.Parent - local LuauPolyfill = require(LuauPolyfillModule) + local root = script.Parent.Parent - local instanceof = LuauPolyfill.instanceof + local instanceof = require(root.instanceof) - local Packages = LuauPolyfillModule.Parent + local Packages = root.Parent + local Collections = require(Packages.Dev.Collections) + local Set = Collections.Set + local Map = Collections.Map local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect - local Set = LuauPolyfill.Set - local Map = LuauPolyfill.Map - -- https://roblox.github.io/lua-style-guide/#prototype-based-classes it("tests the example from the Lua style guide", function() local MyClass = {} @@ -65,7 +64,7 @@ return function() setmetatable(Foo2, Foo) function Foo2.new() local self = Foo.new() - setmetatable(self, Foo2) + setmetatable(self :: any, Foo2) return self end @@ -108,14 +107,16 @@ return function() end setmetatable(SubClass, { - __call = SubClass.new, + __call = function(_self) + return SubClass.new() + end, __index = Class, }) local subClassObj = SubClass() -- expect call as a sanity check that we actually inherit classField - jestExpect(subClassObj.classField).toEqual(10) + jestExpect((subClassObj :: any).classField).toEqual(10) jestExpect(instanceof(subClassObj, SubClass)).toEqual(true) jestExpect(instanceof(subClassObj, Class)).toEqual(true) diff --git a/modules/instance-of/src/init.lua b/modules/instance-of/src/init.lua new file mode 100644 index 0000000..8ef0115 --- /dev/null +++ b/modules/instance-of/src/init.lua @@ -0,0 +1,3 @@ +local instanceof = require(script.instanceof) + +return instanceof diff --git a/src/instanceof.lua b/modules/instance-of/src/instanceof.lua similarity index 95% rename from src/instanceof.lua rename to modules/instance-of/src/instanceof.lua index e991b9a..a20454a 100644 --- a/src/instanceof.lua +++ b/modules/instance-of/src/instanceof.lua @@ -16,7 +16,7 @@ -- polyfill for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof -- FIXME Luau: typing class as Object gives: Type '{ @metatable {| __call: (a, ...any) -> Error, __tostring: ({+ message: b, name: c +}) -> string |}, Error }' could not be converted into 'table' -return function(tbl: any, class: any): boolean +local function instanceof(tbl: any, class: any): boolean if _G.__DEV__ then assert(typeof(class) == "table", "Received a non-table as the second argument for instanceof") end @@ -55,3 +55,5 @@ return function(tbl: any, class: any): boolean return false end + +return instanceof diff --git a/modules/luau-polyfill/default.project.json b/modules/luau-polyfill/default.project.json new file mode 100644 index 0000000..2871d0b --- /dev/null +++ b/modules/luau-polyfill/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "LuauPolyfill", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/luau-polyfill/rotriever.toml b/modules/luau-polyfill/rotriever.toml new file mode 100644 index 0000000..fe8edbd --- /dev/null +++ b/modules/luau-polyfill/rotriever.toml @@ -0,0 +1,24 @@ +[package] +name = "LuauPolyfill" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +Boolean = { path = "../boolean" } +Collections = { path = "../collections" } +Console = { path = "../console" } +InstanceOf = { path = "../instance-of" } +Math = { path = "../math" } +Number = { path = "../number" } +ES7Types = { path = "../es7-types" } +String = { path = "../string" } +Symbol = { path = "../symbol" } +Timers = { path = "../timers" } + +[dev_dependencies] +JestGlobals = { workspace = true } +TestEZ = { workspace = true } +RegExp = { workspace = true } +Promise = { workspace = true } diff --git a/src/.robloxrc b/modules/luau-polyfill/src/.robloxrc similarity index 100% rename from src/.robloxrc rename to modules/luau-polyfill/src/.robloxrc diff --git a/src/AssertionError/AssertionError.lua b/modules/luau-polyfill/src/AssertionError/AssertionError.lua similarity index 97% rename from src/AssertionError/AssertionError.lua rename to modules/luau-polyfill/src/AssertionError/AssertionError.lua index 537af8e..7cacfaf 100644 --- a/src/AssertionError/AssertionError.lua +++ b/modules/luau-polyfill/src/AssertionError/AssertionError.lua @@ -22,15 +22,19 @@ IN THE SOFTWARE. ]] -local SrcWorkspace = script.Parent.Parent -local Array = require(SrcWorkspace.Array) -local Boolean = require(SrcWorkspace.Boolean) -local Object = require(SrcWorkspace.Object) -local String = require(SrcWorkspace.String) -local Error = require(SrcWorkspace.Error) -local instanceof = require(SrcWorkspace.instanceof) -local inspect = require(SrcWorkspace.util.inspect) -local types = require(SrcWorkspace.types) +local LuauPolyfill = script.Parent.Parent +local Packages = LuauPolyfill.Parent + +local Collections = require(Packages.Collections) +local Array = Collections.Array +local Object = Collections.Object +local Boolean = require(Packages.Boolean) +local String = require(Packages.String) +local types = require(Packages.ES7Types) +local inspect = Collections.inspect + +local Error = require(LuauPolyfill.Error) +local instanceof = require(Packages.InstanceOf) type Error = Error.Error type Array = types.Array diff --git a/src/AssertionError/__tests__/AssertionError.spec.lua b/modules/luau-polyfill/src/AssertionError/__tests__/AssertionError.spec.lua similarity index 100% rename from src/AssertionError/__tests__/AssertionError.spec.lua rename to modules/luau-polyfill/src/AssertionError/__tests__/AssertionError.spec.lua diff --git a/src/AssertionError/init.lua b/modules/luau-polyfill/src/AssertionError/init.lua similarity index 100% rename from src/AssertionError/init.lua rename to modules/luau-polyfill/src/AssertionError/init.lua diff --git a/src/Number/.robloxrc b/modules/luau-polyfill/src/Error/.robloxrc similarity index 100% rename from src/Number/.robloxrc rename to modules/luau-polyfill/src/Error/.robloxrc diff --git a/src/Error/__tests__/Error.spec.lua b/modules/luau-polyfill/src/Error/__tests__/Error.spec.lua similarity index 100% rename from src/Error/__tests__/Error.spec.lua rename to modules/luau-polyfill/src/Error/__tests__/Error.spec.lua diff --git a/src/Error/init.lua b/modules/luau-polyfill/src/Error/init.lua similarity index 100% rename from src/Error/init.lua rename to modules/luau-polyfill/src/Error/init.lua diff --git a/src/Promise.lua b/modules/luau-polyfill/src/Promise.lua similarity index 100% rename from src/Promise.lua rename to modules/luau-polyfill/src/Promise.lua diff --git a/src/__tests__/encodeURIComponent.spec.lua b/modules/luau-polyfill/src/__tests__/encodeURIComponent.spec.lua similarity index 96% rename from src/__tests__/encodeURIComponent.spec.lua rename to modules/luau-polyfill/src/__tests__/encodeURIComponent.spec.lua index 669e2f7..fcbc6b2 100644 --- a/src/__tests__/encodeURIComponent.spec.lua +++ b/modules/luau-polyfill/src/__tests__/encodeURIComponent.spec.lua @@ -18,7 +18,7 @@ return function() local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect - local encodeURIComponent = require(script.Parent.Parent.encodeURIComponent) + local encodeURIComponent = require(LuauPolyfillModule.encodeURIComponent) describe("encodeURIComponent", function() it("encodes characters like MDN example #1", function() diff --git a/src/__tests__/extends.spec.lua b/modules/luau-polyfill/src/__tests__/extends.spec.lua similarity index 100% rename from src/__tests__/extends.spec.lua rename to modules/luau-polyfill/src/__tests__/extends.spec.lua diff --git a/src/encodeURIComponent.lua b/modules/luau-polyfill/src/encodeURIComponent.lua similarity index 92% rename from src/encodeURIComponent.lua rename to modules/luau-polyfill/src/encodeURIComponent.lua index 867d2fb..235a5b1 100644 --- a/src/encodeURIComponent.lua +++ b/modules/luau-polyfill/src/encodeURIComponent.lua @@ -13,10 +13,15 @@ * limitations under the License. ]] -- reference documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent -local charCodeAt = require(script.Parent.String.charCodeAt) -local Error = require(script.Parent.Error) local HttpService = game:GetService("HttpService") +local root = script.Parent +local Packages = root.Parent + +local String = require(Packages.String) +local charCodeAt = String.charCodeAt +local Error = require(script.Parent.Error) + local function encodeURIComponent(value: string): string local valueLength = utf8.len(value) if valueLength == 0 or valueLength == nil then diff --git a/src/extends.lua b/modules/luau-polyfill/src/extends.lua similarity index 100% rename from src/extends.lua rename to modules/luau-polyfill/src/extends.lua diff --git a/src/init.lua b/modules/luau-polyfill/src/init.lua similarity index 60% rename from src/init.lua rename to modules/luau-polyfill/src/init.lua index 5721274..7cf7663 100644 --- a/src/init.lua +++ b/modules/luau-polyfill/src/init.lua @@ -1,3 +1,4 @@ +--!strict --[[ * Copyright (c) Roblox Corporation. All rights reserved. * Licensed under the MIT License (the "License"); @@ -12,20 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. ]] ---!strict -local Array = require(script.Array) +local Packages = script.Parent + +local Boolean = require(Packages.Boolean) +local Collections = require(Packages.Collections) +local Console = require(Packages.Console) +local Math = require(Packages.Math) +local Number = require(Packages.Number) +local String = require(Packages.String) +local Symbol = require(Packages.Symbol) +local Timers = require(Packages.Timers) +local types = require(Packages.ES7Types) + local AssertionError = require(script.AssertionError) local Error = require(script.Error) -local Object = require(script.Object) local PromiseModule = require(script.Promise) -local Set = require(script.Set) -local Symbol = require(script.Symbol) -local Timers = require(script.Timers) -local WeakMap = require(script.WeakMap) -local Map = require(script.Map) -local coerceToMap = require(script.Map.coerceToMap) -local coerceToTable = require(script.Map.coerceToTable) -local types = require(script.types) +local extends = require(script.extends) +local instanceof = require(Packages.InstanceOf) export type Array = types.Array export type AssertionError = AssertionError.AssertionError @@ -40,29 +44,31 @@ export type Set = types.Set export type Symbol = Symbol.Symbol export type Timeout = Timers.Timeout export type Interval = Timers.Interval -export type WeakMap = WeakMap.WeakMap +export type WeakMap = Collections.WeakMap return { - Array = Array, + Array = Collections.Array, AssertionError = AssertionError, - Boolean = require(script.Boolean), - console = require(script.console), + Boolean = Boolean, + console = Console, Error = Error, - extends = require(script.extends), - instanceof = require(script.instanceof), - Math = require(script.Math), - Number = require(script.Number), - Object = Object, - Map = Map, - coerceToMap = coerceToMap, - coerceToTable = coerceToTable, - Set = Set, - WeakMap = WeakMap, - String = require(script.String), + extends = extends, + instanceof = instanceof, + Math = Math, + Number = Number, + Object = Collections.Object, + Map = Collections.Map, + coerceToMap = Collections.coerceToMap, + coerceToTable = Collections.coerceToTable, + Set = Collections.Set, + WeakMap = Collections.WeakMap, + String = String, Symbol = Symbol, setTimeout = Timers.setTimeout, clearTimeout = Timers.clearTimeout, setInterval = Timers.setInterval, clearInterval = Timers.clearInterval, - util = require(script.util), + util = { + inspect = Collections.inspect, + }, } diff --git a/modules/math/default.project.json b/modules/math/default.project.json new file mode 100644 index 0000000..c39612b --- /dev/null +++ b/modules/math/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Math", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/math/rotriever.toml b/modules/math/rotriever.toml new file mode 100644 index 0000000..f1ca2b3 --- /dev/null +++ b/modules/math/rotriever.toml @@ -0,0 +1,11 @@ +[package] +name = "Math" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/String/.robloxrc b/modules/math/src/.robloxrc similarity index 100% rename from src/String/.robloxrc rename to modules/math/src/.robloxrc diff --git a/src/Math/__tests__/clz32.spec.lua b/modules/math/src/__tests__/clz32.spec.lua similarity index 94% rename from src/Math/__tests__/clz32.spec.lua rename to modules/math/src/__tests__/clz32.spec.lua index 3b98923..fc64346 100644 --- a/src/Math/__tests__/clz32.spec.lua +++ b/modules/math/src/__tests__/clz32.spec.lua @@ -16,8 +16,7 @@ return function() local Math = script.Parent.Parent local clz32 = require(Math.clz32) - local LuauPolyfill = Math.Parent - local Packages = LuauPolyfill.Parent + local Packages = Math.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Math/clz32.lua b/modules/math/src/clz32.lua similarity index 100% rename from src/Math/clz32.lua rename to modules/math/src/clz32.lua diff --git a/src/Math/init.lua b/modules/math/src/init.lua similarity index 100% rename from src/Math/init.lua rename to modules/math/src/init.lua diff --git a/modules/number/default.project.json b/modules/number/default.project.json new file mode 100644 index 0000000..d275418 --- /dev/null +++ b/modules/number/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Number", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/number/rotriever.toml b/modules/number/rotriever.toml new file mode 100644 index 0000000..424983a --- /dev/null +++ b/modules/number/rotriever.toml @@ -0,0 +1,11 @@ +[package] +name = "Number" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/Symbol/.robloxrc b/modules/number/src/.robloxrc similarity index 100% rename from src/Symbol/.robloxrc rename to modules/number/src/.robloxrc diff --git a/src/Number/MAX_SAFE_INTEGER.lua b/modules/number/src/MAX_SAFE_INTEGER.lua similarity index 100% rename from src/Number/MAX_SAFE_INTEGER.lua rename to modules/number/src/MAX_SAFE_INTEGER.lua diff --git a/src/Number/MIN_SAFE_INTEGER.lua b/modules/number/src/MIN_SAFE_INTEGER.lua similarity index 100% rename from src/Number/MIN_SAFE_INTEGER.lua rename to modules/number/src/MIN_SAFE_INTEGER.lua diff --git a/src/Number/__tests__/MAX_SAFE_INTEGER.spec.lua b/modules/number/src/__tests__/MAX_SAFE_INTEGER.spec.lua similarity index 93% rename from src/Number/__tests__/MAX_SAFE_INTEGER.spec.lua rename to modules/number/src/__tests__/MAX_SAFE_INTEGER.spec.lua index 9252175..74d6518 100644 --- a/src/Number/__tests__/MAX_SAFE_INTEGER.spec.lua +++ b/modules/number/src/__tests__/MAX_SAFE_INTEGER.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local MAX_SAFE_INTEGER = require(Number.MAX_SAFE_INTEGER) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/MIN_SAFE_INTEGER.spec.lua b/modules/number/src/__tests__/MIN_SAFE_INTEGER.spec.lua similarity index 93% rename from src/Number/__tests__/MIN_SAFE_INTEGER.spec.lua rename to modules/number/src/__tests__/MIN_SAFE_INTEGER.spec.lua index b4594f2..627fdb0 100644 --- a/src/Number/__tests__/MIN_SAFE_INTEGER.spec.lua +++ b/modules/number/src/__tests__/MIN_SAFE_INTEGER.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local MIN_SAFE_INTEGER = require(Number.MIN_SAFE_INTEGER) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/init.spec.lua b/modules/number/src/__tests__/init.spec.lua similarity index 92% rename from src/Number/__tests__/init.spec.lua rename to modules/number/src/__tests__/init.spec.lua index dfbcacd..704e26a 100644 --- a/src/Number/__tests__/init.spec.lua +++ b/modules/number/src/__tests__/init.spec.lua @@ -16,8 +16,7 @@ return function() local NumberModule = script.Parent.Parent local Number = require(NumberModule) - local LuauPolyfill = NumberModule.Parent - local Packages = LuauPolyfill.Parent + local Packages = NumberModule.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/isFinite.spec.lua b/modules/number/src/__tests__/isFinite.spec.lua similarity index 95% rename from src/Number/__tests__/isFinite.spec.lua rename to modules/number/src/__tests__/isFinite.spec.lua index ddc88c6..cfbc497 100644 --- a/src/Number/__tests__/isFinite.spec.lua +++ b/modules/number/src/__tests__/isFinite.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local isFinite = require(Number.isFinite) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/isInteger.spec.lua b/modules/number/src/__tests__/isInteger.spec.lua similarity index 96% rename from src/Number/__tests__/isInteger.spec.lua rename to modules/number/src/__tests__/isInteger.spec.lua index 9161493..5d4c45d 100644 --- a/src/Number/__tests__/isInteger.spec.lua +++ b/modules/number/src/__tests__/isInteger.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local isInteger = require(Number.isInteger) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/isNaN.spec.lua b/modules/number/src/__tests__/isNaN.spec.lua similarity index 95% rename from src/Number/__tests__/isNaN.spec.lua rename to modules/number/src/__tests__/isNaN.spec.lua index 307f508..2733b4d 100644 --- a/src/Number/__tests__/isNaN.spec.lua +++ b/modules/number/src/__tests__/isNaN.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local isNaN = require(Number.isNaN) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/isSafeInteger.spec.lua b/modules/number/src/__tests__/isSafeInteger.spec.lua similarity index 95% rename from src/Number/__tests__/isSafeInteger.spec.lua rename to modules/number/src/__tests__/isSafeInteger.spec.lua index 53b9da7..c71963d 100644 --- a/src/Number/__tests__/isSafeInteger.spec.lua +++ b/modules/number/src/__tests__/isSafeInteger.spec.lua @@ -16,8 +16,7 @@ return function() local Number = script.Parent.Parent local isSafeInteger = require(Number.isSafeInteger) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/__tests__/toExponential.spec.lua b/modules/number/src/__tests__/toExponential.spec.lua similarity index 93% rename from src/Number/__tests__/toExponential.spec.lua rename to modules/number/src/__tests__/toExponential.spec.lua index 3c9c980..23dcfed 100644 --- a/src/Number/__tests__/toExponential.spec.lua +++ b/modules/number/src/__tests__/toExponential.spec.lua @@ -14,10 +14,9 @@ ]] return function() local Number = script.Parent.Parent - local toExponential = require(script.Parent.Parent.toExponential) + local toExponential = require(Number.toExponential) - local LuauPolyfill = Number.Parent - local Packages = LuauPolyfill.Parent + local Packages = Number.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Number/init.lua b/modules/number/src/init.lua similarity index 100% rename from src/Number/init.lua rename to modules/number/src/init.lua diff --git a/src/Number/isFinite.lua b/modules/number/src/isFinite.lua similarity index 100% rename from src/Number/isFinite.lua rename to modules/number/src/isFinite.lua diff --git a/src/Number/isInteger.lua b/modules/number/src/isInteger.lua similarity index 100% rename from src/Number/isInteger.lua rename to modules/number/src/isInteger.lua diff --git a/src/Number/isNaN.lua b/modules/number/src/isNaN.lua similarity index 100% rename from src/Number/isNaN.lua rename to modules/number/src/isNaN.lua diff --git a/src/Number/isSafeInteger.lua b/modules/number/src/isSafeInteger.lua similarity index 100% rename from src/Number/isSafeInteger.lua rename to modules/number/src/isSafeInteger.lua diff --git a/src/Number/toExponential.lua b/modules/number/src/toExponential.lua similarity index 100% rename from src/Number/toExponential.lua rename to modules/number/src/toExponential.lua diff --git a/modules/string/default.project.json b/modules/string/default.project.json new file mode 100644 index 0000000..c65e666 --- /dev/null +++ b/modules/string/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "String", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/string/rotriever.toml b/modules/string/rotriever.toml new file mode 100644 index 0000000..8d32dda --- /dev/null +++ b/modules/string/rotriever.toml @@ -0,0 +1,13 @@ +[package] +name = "String" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +Number = { path = "../number" } +ES7Types = { path = "../es7-types" } + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/Timers/.robloxrc b/modules/string/src/.robloxrc similarity index 100% rename from src/Timers/.robloxrc rename to modules/string/src/.robloxrc diff --git a/src/String/__tests__/charCodeAt.spec.lua b/modules/string/src/__tests__/charCodeAt.spec.lua similarity index 95% rename from src/String/__tests__/charCodeAt.spec.lua rename to modules/string/src/__tests__/charCodeAt.spec.lua index a8a0215..8c21589 100644 --- a/src/String/__tests__/charCodeAt.spec.lua +++ b/modules/string/src/__tests__/charCodeAt.spec.lua @@ -14,11 +14,11 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local charCodeAt = require(String.charCodeAt) - local LuauPolyfill = String.Parent - local Number = require(LuauPolyfill.Number) - local Packages = LuauPolyfill.Parent + local Number = require(Packages.Number) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/endsWith.spec.lua b/modules/string/src/__tests__/endsWith.spec.lua similarity index 96% rename from src/String/__tests__/endsWith.spec.lua rename to modules/string/src/__tests__/endsWith.spec.lua index 4d084e7..b63041b 100644 --- a/src/String/__tests__/endsWith.spec.lua +++ b/modules/string/src/__tests__/endsWith.spec.lua @@ -14,10 +14,10 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local endsWith = require(String.endsWith) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/findOr.spec.lua b/modules/string/src/__tests__/findOr.spec.lua similarity index 98% rename from src/String/__tests__/findOr.spec.lua rename to modules/string/src/__tests__/findOr.spec.lua index a0dc392..99c9c34 100644 --- a/src/String/__tests__/findOr.spec.lua +++ b/modules/string/src/__tests__/findOr.spec.lua @@ -14,7 +14,8 @@ ]] return function() local String = script.Parent.Parent - local Packages = String.Parent.Parent + local Packages = String.Parent + local findOr = require(String.findOr) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/includes.spec.lua b/modules/string/src/__tests__/includes.spec.lua similarity index 97% rename from src/String/__tests__/includes.spec.lua rename to modules/string/src/__tests__/includes.spec.lua index 33c1ad5..83cb2a3 100644 --- a/src/String/__tests__/includes.spec.lua +++ b/modules/string/src/__tests__/includes.spec.lua @@ -15,10 +15,10 @@ -- tests inspired by MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes return function() local String = script.Parent.Parent + local Packages = String.Parent + local includes = require(String.includes) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/indexOf.spec.lua b/modules/string/src/__tests__/indexOf.spec.lua similarity index 96% rename from src/String/__tests__/indexOf.spec.lua rename to modules/string/src/__tests__/indexOf.spec.lua index 18e9e01..4a40f59 100644 --- a/src/String/__tests__/indexOf.spec.lua +++ b/modules/string/src/__tests__/indexOf.spec.lua @@ -16,10 +16,10 @@ -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf return function() local String = script.Parent.Parent - local LuauPolyfill = String.Parent + local Packages = String.Parent + local indexOf = require(String.indexOf) - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/lastIndexOf.spec.lua b/modules/string/src/__tests__/lastIndexOf.spec.lua similarity index 96% rename from src/String/__tests__/lastIndexOf.spec.lua rename to modules/string/src/__tests__/lastIndexOf.spec.lua index 4db78c9..e113137 100644 --- a/src/String/__tests__/lastIndexOf.spec.lua +++ b/modules/string/src/__tests__/lastIndexOf.spec.lua @@ -15,10 +15,10 @@ -- unit tests based on MDN examples: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf return function() local String = script.Parent.Parent + local Packages = String.Parent + local lastIndexOf = require(String.lastIndexOf) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/slice.spec.lua b/modules/string/src/__tests__/slice.spec.lua similarity index 98% rename from src/String/__tests__/slice.spec.lua rename to modules/string/src/__tests__/slice.spec.lua index 16b94f5..1cad7de 100644 --- a/src/String/__tests__/slice.spec.lua +++ b/modules/string/src/__tests__/slice.spec.lua @@ -14,7 +14,8 @@ ]] return function() local String = script.Parent.Parent - local Packages = String.Parent.Parent + local Packages = String.Parent + local slice = require(String.slice) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/split.spec.lua b/modules/string/src/__tests__/split.spec.lua similarity index 98% rename from src/String/__tests__/split.spec.lua rename to modules/string/src/__tests__/split.spec.lua index 12aa898..2766061 100644 --- a/src/String/__tests__/split.spec.lua +++ b/modules/string/src/__tests__/split.spec.lua @@ -14,7 +14,8 @@ ]] return function() local String = script.Parent.Parent - local Packages = String.Parent.Parent + local Packages = String.Parent + local split = require(String.split) local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/startsWith.spec.lua b/modules/string/src/__tests__/startsWith.spec.lua similarity index 96% rename from src/String/__tests__/startsWith.spec.lua rename to modules/string/src/__tests__/startsWith.spec.lua index 5ff298c..7972d28 100644 --- a/src/String/__tests__/startsWith.spec.lua +++ b/modules/string/src/__tests__/startsWith.spec.lua @@ -14,10 +14,10 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local startsWith = require(String.startsWith) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/substr.spec.lua b/modules/string/src/__tests__/substr.spec.lua similarity index 95% rename from src/String/__tests__/substr.spec.lua rename to modules/string/src/__tests__/substr.spec.lua index b1b9039..2c46c38 100644 --- a/src/String/__tests__/substr.spec.lua +++ b/modules/string/src/__tests__/substr.spec.lua @@ -15,10 +15,10 @@ -- tests inspired by MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr return function() local String = script.Parent.Parent + local Packages = String.Parent + local substr = require(String.substr) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/trim.spec.lua b/modules/string/src/__tests__/trim.spec.lua similarity index 94% rename from src/String/__tests__/trim.spec.lua rename to modules/string/src/__tests__/trim.spec.lua index d494e76..7da32bd 100644 --- a/src/String/__tests__/trim.spec.lua +++ b/modules/string/src/__tests__/trim.spec.lua @@ -14,10 +14,10 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local trim = require(String.trim) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/trimEnd.spec.lua b/modules/string/src/__tests__/trimEnd.spec.lua similarity index 95% rename from src/String/__tests__/trimEnd.spec.lua rename to modules/string/src/__tests__/trimEnd.spec.lua index 904cba1..2ff523a 100644 --- a/src/String/__tests__/trimEnd.spec.lua +++ b/modules/string/src/__tests__/trimEnd.spec.lua @@ -14,10 +14,10 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local trimEnd = require(String.trimEnd) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/__tests__/trimStart.spec.lua b/modules/string/src/__tests__/trimStart.spec.lua similarity index 95% rename from src/String/__tests__/trimStart.spec.lua rename to modules/string/src/__tests__/trimStart.spec.lua index 720fa27..253807d 100644 --- a/src/String/__tests__/trimStart.spec.lua +++ b/modules/string/src/__tests__/trimStart.spec.lua @@ -14,10 +14,10 @@ ]] return function() local String = script.Parent.Parent + local Packages = String.Parent + local trimStart = require(String.trimStart) - local LuauPolyfill = String.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/String/charCodeAt.lua b/modules/string/src/charCodeAt.lua similarity index 94% rename from src/String/charCodeAt.lua rename to modules/string/src/charCodeAt.lua index 2679c57..a4dc2ed 100644 --- a/src/String/charCodeAt.lua +++ b/modules/string/src/charCodeAt.lua @@ -14,8 +14,8 @@ ]] --!strict local String = script.Parent -local LuauPolyfill = String.Parent -local Number = require(LuauPolyfill.Number) +local Packages = String.Parent +local Number = require(Packages.Number) local NaN = Number.NaN diff --git a/src/String/endsWith.lua b/modules/string/src/endsWith.lua similarity index 100% rename from src/String/endsWith.lua rename to modules/string/src/endsWith.lua diff --git a/src/String/findOr.lua b/modules/string/src/findOr.lua similarity index 100% rename from src/String/findOr.lua rename to modules/string/src/findOr.lua diff --git a/src/String/includes.lua b/modules/string/src/includes.lua similarity index 100% rename from src/String/includes.lua rename to modules/string/src/includes.lua diff --git a/src/String/indexOf.lua b/modules/string/src/indexOf.lua similarity index 100% rename from src/String/indexOf.lua rename to modules/string/src/indexOf.lua diff --git a/src/String/init.lua b/modules/string/src/init.lua similarity index 100% rename from src/String/init.lua rename to modules/string/src/init.lua diff --git a/src/String/lastIndexOf.lua b/modules/string/src/lastIndexOf.lua similarity index 100% rename from src/String/lastIndexOf.lua rename to modules/string/src/lastIndexOf.lua diff --git a/src/String/slice.lua b/modules/string/src/slice.lua similarity index 100% rename from src/String/slice.lua rename to modules/string/src/slice.lua diff --git a/src/String/split.lua b/modules/string/src/split.lua similarity index 90% rename from src/String/split.lua rename to modules/string/src/split.lua index c029269..6542b2d 100644 --- a/src/String/split.lua +++ b/modules/string/src/split.lua @@ -13,13 +13,14 @@ * limitations under the License. ]] --!strict -local findOr = require(script.Parent.findOr) -local slice = require(script.Parent.slice) +local String = script.Parent +local findOr = require(String.findOr) +local slice = require(String.slice) -local LuauPolyfill = script.Parent.Parent -local types = require(LuauPolyfill.types) +local Packages = String.Parent +local types = require(Packages.ES7Types) type Array = types.Array -local MAX_SAFE_INTEGER = require(LuauPolyfill.Number).MAX_SAFE_INTEGER +local MAX_SAFE_INTEGER = require(Packages.Number).MAX_SAFE_INTEGER type Pattern = string | Array diff --git a/src/String/startsWith.lua b/modules/string/src/startsWith.lua similarity index 100% rename from src/String/startsWith.lua rename to modules/string/src/startsWith.lua diff --git a/src/String/substr.lua b/modules/string/src/substr.lua similarity index 100% rename from src/String/substr.lua rename to modules/string/src/substr.lua diff --git a/src/String/trim.lua b/modules/string/src/trim.lua similarity index 100% rename from src/String/trim.lua rename to modules/string/src/trim.lua diff --git a/src/String/trimEnd.lua b/modules/string/src/trimEnd.lua similarity index 100% rename from src/String/trimEnd.lua rename to modules/string/src/trimEnd.lua diff --git a/src/String/trimStart.lua b/modules/string/src/trimStart.lua similarity index 100% rename from src/String/trimStart.lua rename to modules/string/src/trimStart.lua diff --git a/modules/symbol/default.project.json b/modules/symbol/default.project.json new file mode 100644 index 0000000..18a5e96 --- /dev/null +++ b/modules/symbol/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Symbol", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/symbol/rotriever.toml b/modules/symbol/rotriever.toml new file mode 100644 index 0000000..18929c1 --- /dev/null +++ b/modules/symbol/rotriever.toml @@ -0,0 +1,11 @@ +[package] +name = "Symbol" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] + +[dev_dependencies] +JestGlobals = { workspace = true } diff --git a/src/console/.robloxrc b/modules/symbol/src/.robloxrc similarity index 100% rename from src/console/.robloxrc rename to modules/symbol/src/.robloxrc diff --git a/src/Symbol/GlobalRegistry.lua b/modules/symbol/src/GlobalRegistry.lua similarity index 100% rename from src/Symbol/GlobalRegistry.lua rename to modules/symbol/src/GlobalRegistry.lua diff --git a/src/Symbol/Symbol.lua b/modules/symbol/src/Symbol.lua similarity index 100% rename from src/Symbol/Symbol.lua rename to modules/symbol/src/Symbol.lua diff --git a/src/Symbol/__tests__/Symbol.spec.lua b/modules/symbol/src/__tests__/Symbol.spec.lua similarity index 96% rename from src/Symbol/__tests__/Symbol.spec.lua rename to modules/symbol/src/__tests__/Symbol.spec.lua index ca600b2..4a0e9f7 100644 --- a/src/Symbol/__tests__/Symbol.spec.lua +++ b/modules/symbol/src/__tests__/Symbol.spec.lua @@ -24,8 +24,7 @@ return function() local Symbol = require(SymbolModule) local GlobalRegistry = require(SymbolModule.GlobalRegistry) - local LuauPolyfill = SymbolModule.Parent - local Packages = LuauPolyfill.Parent + local Packages = SymbolModule.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect diff --git a/src/Symbol/init.lua b/modules/symbol/src/init.lua similarity index 100% rename from src/Symbol/init.lua rename to modules/symbol/src/init.lua diff --git a/modules/timers/default.project.json b/modules/timers/default.project.json new file mode 100644 index 0000000..05b1b82 --- /dev/null +++ b/modules/timers/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "Timers", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/modules/timers/rotriever.toml b/modules/timers/rotriever.toml new file mode 100644 index 0000000..2e69671 --- /dev/null +++ b/modules/timers/rotriever.toml @@ -0,0 +1,13 @@ +[package] +name = "Timers" +version = { workspace = true } +authors = { workspace = true } +content_root = "src" +files = ["*", "!**/__tests__/**"] + +[dependencies] +Collections = { path = "../collections" } + +[dev_dependencies] +JestGlobals = { workspace = true } +Promise = { workspace = true } diff --git a/src/util/.robloxrc b/modules/timers/src/.robloxrc similarity index 100% rename from src/util/.robloxrc rename to modules/timers/src/.robloxrc diff --git a/src/Timers/__tests__/Timers.spec.lua b/modules/timers/src/__tests__/Timers.spec.lua similarity index 99% rename from src/Timers/__tests__/Timers.spec.lua rename to modules/timers/src/__tests__/Timers.spec.lua index 455da41..7b72095 100644 --- a/src/Timers/__tests__/Timers.spec.lua +++ b/modules/timers/src/__tests__/Timers.spec.lua @@ -14,11 +14,11 @@ ]] return function() local Timers = script.Parent.Parent + local Packages = Timers.Parent + local makeTimerImpl = require(Timers.makeTimerImpl) local makeIntervalImpl = require(Timers.makeIntervalImpl) - local LuauPolyfill = Timers.Parent - local Packages = LuauPolyfill.Parent local JestGlobals = require(Packages.Dev.JestGlobals) local jestExpect = JestGlobals.expect local jest = JestGlobals.jest diff --git a/src/Timers/init.lua b/modules/timers/src/init.lua similarity index 82% rename from src/Timers/init.lua rename to modules/timers/src/init.lua index b4fe749..71c3269 100644 --- a/src/Timers/init.lua +++ b/modules/timers/src/init.lua @@ -13,11 +13,14 @@ * limitations under the License. ]] --!strict +local Packages = script.Parent + +local Object = require(Packages.Collections).Object + local makeTimerImpl = require(script.makeTimerImpl) local makeIntervalImpl = require(script.makeIntervalImpl) -local assign = require(script.Parent.Object.assign) export type Timeout = makeTimerImpl.Timeout export type Interval = makeIntervalImpl.Interval -return assign({}, makeTimerImpl(task.delay), makeIntervalImpl(task.delay)) +return Object.assign({}, makeTimerImpl(task.delay), makeIntervalImpl(task.delay)) diff --git a/src/Timers/makeIntervalImpl.lua b/modules/timers/src/makeIntervalImpl.lua similarity index 100% rename from src/Timers/makeIntervalImpl.lua rename to modules/timers/src/makeIntervalImpl.lua diff --git a/src/Timers/makeTimerImpl.lua b/modules/timers/src/makeTimerImpl.lua similarity index 100% rename from src/Timers/makeTimerImpl.lua rename to modules/timers/src/makeTimerImpl.lua diff --git a/rotriever.toml b/rotriever.toml index 47dabcf..d74d40f 100644 --- a/rotriever.toml +++ b/rotriever.toml @@ -1,6 +1,6 @@ -[package] -name = "LuauPolyfill" +[workspace] version = "1.0.0" +members = ["modules/*"] authors = [ "Chris TrzeĊ›niewski ", "Kyle Mitofsky ", @@ -10,10 +10,8 @@ authors = [ "Raymond Ng ", "Zack Ovits ", ] -content_root = "src" -files = ["*", "!**/__tests__/**"] -[dev_dependencies] +[workspace.dependencies] JestGlobals = "github.com/roblox/jest-roblox@2.4.1" TestEZ = "github.com/roblox/jest-roblox@2.4.1" RegExp = "github.com/roblox/luau-regexp@0.1.3" diff --git a/src/util/init.lua b/src/util/init.lua deleted file mode 100644 index fae15b5..0000000 --- a/src/util/init.lua +++ /dev/null @@ -1,17 +0,0 @@ ---[[ - * Copyright (c) Roblox Corporation. All rights reserved. - * Licensed under the MIT License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/MIT - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -]] -return { - inspect = require(script.inspect), -} diff --git a/test-model.project.json b/test-model.project.json index 5f8dbea..7041a1e 100644 --- a/test-model.project.json +++ b/test-model.project.json @@ -3,10 +3,7 @@ "tree": { "$className": "Folder", "Packages": { - "$path": "Packages", - "LuauPolyfill": { - "$path": "src" - } + "$path": "Packages" } } } \ No newline at end of file