From 2ac5d3eae23aee36676a4a83401fe1a2af768f77 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:00:10 +0000 Subject: [PATCH 01/43] Remove roblox/testez --- .gitmodules | 3 - .husky/pre-commit | 5 - .prettierrc.json | 14 - .vscode/launch.json | 15 - .vscode/scripts/run-tests.ps1 | 8 - .vscode/settings.json | 21 +- LICENSE | 2 +- foreman.toml | 6 - modules/testez | 1 - package-lock.json | 1654 --------------------------------- selene.toml | 2 +- testez.toml | 67 -- 12 files changed, 10 insertions(+), 1788 deletions(-) delete mode 100644 .gitmodules delete mode 100644 .husky/pre-commit delete mode 100644 .prettierrc.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/scripts/run-tests.ps1 delete mode 100644 foreman.toml delete mode 160000 modules/testez delete mode 100644 package-lock.json delete mode 100644 testez.toml diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c8f8c6f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "modules/testez"] - path = modules/testez - url = https://github.com/roblox/testez diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index ece6a97..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -stylua --check src/ -selene src/ diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index db44278..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "arrowParens": "always", - "bracketSameLine": false, - "bracketSpacing": true, - "endOfLine": "auto", - "jsxSingleQuote": false, - "printWidth": 80, - "quoteProps": "consistent", - "semi": false, - "singleQuote": false, - "tabWidth": 2, - "trailingComma": "es5", - "useTabs": false -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index b63a2c7..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "PowerShell: Run Tests", - "type": "PowerShell", - "request": "launch", - "script": "${workspaceFolder}/.vscode/scripts/run-tests.ps1", - "cwd": "${workspaceFolder}" - } - ] -} diff --git a/.vscode/scripts/run-tests.ps1 b/.vscode/scripts/run-tests.ps1 deleted file mode 100644 index 8a3fe5a..0000000 --- a/.vscode/scripts/run-tests.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$FILE_NAME = ".\test-place.rbxl" -$TEST_PROJ = ".\test.project.json" -$TEST_RUNR = ".\TestRunner.server.lua" - -aftman install -rojo build "$TEST_PROJ" -o "$FILE_NAME" -run-in-roblox --place "$FILE_NAME" --script "$TEST_RUNR" -Remove-Item "$FILE_NAME" -Force -ErrorAction SilentlyContinue diff --git a/.vscode/settings.json b/.vscode/settings.json index 52d7ad7..669c6bd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,20 +1,15 @@ { "[lua]": { - "editor.defaultFormatter": "JohnnyMorganz.stylua" + "editor.defaultFormatter": "JohnnyMorganz.stylua", + "editor.formatOnSave": true, + "editor.formatOnPaste": true }, - "[json]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "[luau]": { + "editor.defaultFormatter": "JohnnyMorganz.stylua", + "editor.formatOnSave": true, + "editor.formatOnPaste": true }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.organizeImports": true - }, - "editor.formatOnSave": true, - "editor.formatOnPaste": true, - "editor.formatOnType": true, - "debug.toolBarLocation": "hidden", - "files.eol": "\n" + } } diff --git a/LICENSE b/LICENSE index 73cf3c4..5c4ae0b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 csqrl +Copyright (c) 2024 cxmeel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/foreman.toml b/foreman.toml deleted file mode 100644 index 2c6763b..0000000 --- a/foreman.toml +++ /dev/null @@ -1,6 +0,0 @@ -[tools] -rojo = { source = "rojo-rbx/rojo", version = "=7.1.1" } -run-in-roblox = { source = "rojo-rbx/run-in-roblox", version = "=0.3.0" } -wally = { source = "upliftgames/wally", version = "=0.3.1" } -stylua = { source = "johnnymorganz/stylua", version = "=0.13.1" } -selene = { source = "kampfkarren/selene", version = "=0.17.0" } diff --git a/modules/testez b/modules/testez deleted file mode 160000 index 4bcc719..0000000 --- a/modules/testez +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4bcc719877c9f2074b35877383e1f29dc996bf51 diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 0ef74a7..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1654 +0,0 @@ -{ - "name": "@rbxts/sift", - "version": "0.0.7", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "@rbxts/sift", - "version": "0.0.7", - "license": "MIT", - "devDependencies": { - "@rbxts/compiler-types": "^1.2.3-types.0", - "@rbxts/types": "^1.0.515", - "husky": "^8.0.0", - "rbxts-transform-debug": "^1.0.0-rc.1", - "rbxts-transform-env": "^1.0.0-rc.0", - "roblox-ts": "^1.2.7", - "typescript": "^4.3.5" - } - }, - "node_modules/@rbxts/compiler-types": { - "version": "1.2.3-types.1", - "resolved": "https://registry.npmjs.org/@rbxts/compiler-types/-/compiler-types-1.2.3-types.1.tgz", - "integrity": "sha512-SXXIBazyJ7N6d2xcy471/kqZZpCv7EDOWrRJ45jcv3g00VQaZwYl4Elr10woqRloIblQanwJ7yUqGXAsWv7iuQ==", - "dev": true - }, - "node_modules/@rbxts/types": { - "version": "1.0.591", - "resolved": "https://registry.npmjs.org/@rbxts/types/-/types-1.0.591.tgz", - "integrity": "sha512-72lPUo6ecDxwdL8MhAgyFZiNQ6+/8hSHZDW8IcP6IRdHKn4zq9ABwsQjeIsWuKSI/EgG6k9LrTAdcG9FDaxUYw==", - "dev": true - }, - "node_modules/@roblox-ts/luau-ast": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@roblox-ts/luau-ast/-/luau-ast-1.0.1.tgz", - "integrity": "sha512-FTKP24O0EbGupOmfJ6UHpag0K597bCpN4veDP9N91hSsrhIIHV59xLYw/e97g6hmwqYBfxOCuAvuLvsR4C9aMw==", - "dev": true - }, - "node_modules/@roblox-ts/rojo-resolver": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@roblox-ts/rojo-resolver/-/rojo-resolver-1.0.2.tgz", - "integrity": "sha512-491pyfdxA7cmhDlY23rQi1rEuLCl0mPeAOUQbd6XdiaZ461MMtj38lvn1f8SXd6ZoZ/S4cO0XQUcKEBDGMdM2Q==", - "dev": true, - "dependencies": { - "ajv": "^8.6.3", - "fs-extra": "^10.0.0" - } - }, - "node_modules/ajv": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", - "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true, - "engines": { - "node": ">=0.1.90" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/dotenv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", - "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-core-module": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", - "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", - "dev": true, - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/kleur": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", - "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/lookpath": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/lookpath/-/lookpath-1.2.2.tgz", - "integrity": "sha512-k2Gmn8iV6qdME3ztZC2spubmQISimFOPLuQKiPaLcVdRz0IpdxrNClVepMlyTJlhodm/zG/VfbkWERm3kUIh+Q==", - "dev": true, - "bin": { - "lookpath": "bin/lookpath.js" - }, - "engines": { - "npm": ">=6.13.4" - } - }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true - }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dev": true, - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/prompts/node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/rbxts-transform-debug": { - "version": "1.0.0-ts4.5", - "resolved": "https://registry.npmjs.org/rbxts-transform-debug/-/rbxts-transform-debug-1.0.0-ts4.5.tgz", - "integrity": "sha512-zaHEoEHcq6/uhVaFFfj9WgYWlVqaSpNj0ac9Es0fDQzDBHMt6VGoyZDGw0yWm4MTZoM+K0676ByszZ1RghHlaQ==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "colors": "^1.4.0", - "dotenv": "^8.2.0", - "execa": "^5.1.1", - "typescript": "~4.5.4" - } - }, - "node_modules/rbxts-transform-debug/node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/rbxts-transform-env": { - "version": "1.0.0-ts4.5", - "resolved": "https://registry.npmjs.org/rbxts-transform-env/-/rbxts-transform-env-1.0.0-ts4.5.tgz", - "integrity": "sha512-VokMFb364Kq1DP5x/kXdhpPk1CH3cpCufnmDwp+QR1QjvrAuC+9GVO8CzfRniuxu9JZSWQ6DOYFfatiAJ2l1Vw==", - "dev": true, - "dependencies": { - "chalk": "^4.1.1", - "colors": "^1.4.0", - "dotenv": "^8.2.0", - "typescript": "~4.5.4" - } - }, - "node_modules/rbxts-transform-env/node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, - "dependencies": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/roblox-ts": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/roblox-ts/-/roblox-ts-1.3.3.tgz", - "integrity": "sha512-lInd8WSnTQ2h81maDKG/aH4GVx+iKRWdE/CcfjNZR61ir9r6MdxPlRhoYoh8Blb1ceZMCPLsAMXsK//sQu8C2g==", - "dev": true, - "dependencies": { - "@roblox-ts/luau-ast": "^1.0.1", - "@roblox-ts/rojo-resolver": "^1.0.2", - "ajv": "^8.6.3", - "chokidar": "^3.5.2", - "fs-extra": "^10.0.0", - "kleur": "^4.1.4", - "lookpath": "^1.2.2", - "prompts": "^2.4.1", - "resolve": "^1.20.0", - "typescript": "=4.6.2", - "yargs": "^17.2.0" - }, - "bin": { - "rbxtsc": "out/CLI/cli.js" - } - }, - "node_modules/roblox-ts/node_modules/typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/typescript": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", - "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", - "dev": true, - "engines": { - "node": ">=12" - } - } - }, - "dependencies": { - "@rbxts/compiler-types": { - "version": "1.2.3-types.1", - "resolved": "https://registry.npmjs.org/@rbxts/compiler-types/-/compiler-types-1.2.3-types.1.tgz", - "integrity": "sha512-SXXIBazyJ7N6d2xcy471/kqZZpCv7EDOWrRJ45jcv3g00VQaZwYl4Elr10woqRloIblQanwJ7yUqGXAsWv7iuQ==", - "dev": true - }, - "@rbxts/types": { - "version": "1.0.591", - "resolved": "https://registry.npmjs.org/@rbxts/types/-/types-1.0.591.tgz", - "integrity": "sha512-72lPUo6ecDxwdL8MhAgyFZiNQ6+/8hSHZDW8IcP6IRdHKn4zq9ABwsQjeIsWuKSI/EgG6k9LrTAdcG9FDaxUYw==", - "dev": true - }, - "@roblox-ts/luau-ast": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@roblox-ts/luau-ast/-/luau-ast-1.0.1.tgz", - "integrity": "sha512-FTKP24O0EbGupOmfJ6UHpag0K597bCpN4veDP9N91hSsrhIIHV59xLYw/e97g6hmwqYBfxOCuAvuLvsR4C9aMw==", - "dev": true - }, - "@roblox-ts/rojo-resolver": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@roblox-ts/rojo-resolver/-/rojo-resolver-1.0.2.tgz", - "integrity": "sha512-491pyfdxA7cmhDlY23rQi1rEuLCl0mPeAOUQbd6XdiaZ461MMtj38lvn1f8SXd6ZoZ/S4cO0XQUcKEBDGMdM2Q==", - "dev": true, - "requires": { - "ajv": "^8.6.3", - "fs-extra": "^10.0.0" - } - }, - "ajv": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", - "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "requires": { - "fill-range": "^7.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "dotenv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", - "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "requires": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - } - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true - }, - "husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-core-module": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", - "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "kleur": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.4.tgz", - "integrity": "sha512-8QADVssbrFjivHWQU7KkMgptGTl6WAcSdlbBPY4uNF+mWr6DGcKrvY2w4FQJoXch7+fKMjj0dRrL75vk3k23OA==", - "dev": true - }, - "lookpath": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/lookpath/-/lookpath-1.2.2.tgz", - "integrity": "sha512-k2Gmn8iV6qdME3ztZC2spubmQISimFOPLuQKiPaLcVdRz0IpdxrNClVepMlyTJlhodm/zG/VfbkWERm3kUIh+Q==", - "dev": true - }, - "merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "requires": { - "path-key": "^3.0.0" - } - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dev": true, - "requires": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "dependencies": { - "kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true - } - } - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "rbxts-transform-debug": { - "version": "1.0.0-ts4.5", - "resolved": "https://registry.npmjs.org/rbxts-transform-debug/-/rbxts-transform-debug-1.0.0-ts4.5.tgz", - "integrity": "sha512-zaHEoEHcq6/uhVaFFfj9WgYWlVqaSpNj0ac9Es0fDQzDBHMt6VGoyZDGw0yWm4MTZoM+K0676ByszZ1RghHlaQ==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "colors": "^1.4.0", - "dotenv": "^8.2.0", - "execa": "^5.1.1", - "typescript": "~4.5.4" - }, - "dependencies": { - "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", - "dev": true - } - } - }, - "rbxts-transform-env": { - "version": "1.0.0-ts4.5", - "resolved": "https://registry.npmjs.org/rbxts-transform-env/-/rbxts-transform-env-1.0.0-ts4.5.tgz", - "integrity": "sha512-VokMFb364Kq1DP5x/kXdhpPk1CH3cpCufnmDwp+QR1QjvrAuC+9GVO8CzfRniuxu9JZSWQ6DOYFfatiAJ2l1Vw==", - "dev": true, - "requires": { - "chalk": "^4.1.1", - "colors": "^1.4.0", - "dotenv": "^8.2.0", - "typescript": "~4.5.4" - }, - "dependencies": { - "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", - "dev": true - } - } - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true - }, - "resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, - "requires": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "roblox-ts": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/roblox-ts/-/roblox-ts-1.3.3.tgz", - "integrity": "sha512-lInd8WSnTQ2h81maDKG/aH4GVx+iKRWdE/CcfjNZR61ir9r6MdxPlRhoYoh8Blb1ceZMCPLsAMXsK//sQu8C2g==", - "dev": true, - "requires": { - "@roblox-ts/luau-ast": "^1.0.1", - "@roblox-ts/rojo-resolver": "^1.0.2", - "ajv": "^8.6.3", - "chokidar": "^3.5.2", - "fs-extra": "^10.0.0", - "kleur": "^4.1.4", - "lookpath": "^1.2.2", - "prompts": "^2.4.1", - "resolve": "^1.20.0", - "typescript": "=4.6.2", - "yargs": "^17.2.0" - }, - "dependencies": { - "typescript": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", - "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", - "dev": true - } - } - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, - "sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "typescript": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", - "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==", - "dev": true - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - } - }, - "yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", - "dev": true - } - } -} diff --git a/selene.toml b/selene.toml index 49fb47e..c4ddb46 100644 --- a/selene.toml +++ b/selene.toml @@ -1 +1 @@ -std = "roblox+testez" +std = "roblox" diff --git a/testez.toml b/testez.toml deleted file mode 100644 index adc2434..0000000 --- a/testez.toml +++ /dev/null @@ -1,67 +0,0 @@ -# TestEZ -[[afterAll.args]] -type = "function" - -[[afterEach.args]] -type = "function" - -[[beforeAll.args]] -type = "function" - -[[beforeEach.args]] -type = "function" - -[[describe.args]] -type = "string" - -[[describe.args]] -type = "function" - -[[describeFOCUS.args]] -type = "string" - -[[describeFOCUS.args]] -type = "function" - -[[describeSKIP.args]] -type = "string" - -[[describeSKIP.args]] -type = "function" - -[[expect.args]] -type = "any" - -[[FIXME.args]] -type = "string" -required = false - -[FOCUS] -args = [] - -[[it.args]] -type = "string" - -[[it.args]] -type = "function" - -[[itFIXME.args]] -type = "string" - -[[itFIXME.args]] -type = "function" - -[[itFOCUS.args]] -type = "string" - -[[itFOCUS.args]] -type = "function" - -[[itSKIP.args]] -type = "string" - -[[itSKIP.args]] -type = "function" - -[SKIP] -args = [] From 8fb132354747bf63cae7c30956559ecc5378f3dc Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:09:29 +0000 Subject: [PATCH 02/43] Remove testez tests --- .gitattributes | 3 + .github/FUNDING.yml | 4 +- .github/workflows/publish.yml | 58 ------ .gitignore | 18 +- .luaurc | 8 + .stylua.toml | 7 - CHANGELOG.md | 61 ------- README.md | 33 ++-- aftman.toml | 13 +- default.project.json | 5 +- docs/Installation.md | 10 +- moonwave.toml | 4 +- package.json | 9 +- sourcemap.json | 2 +- src/Array/at.spec.lua | 25 --- src/Array/concat.spec.lua | 53 ------ src/Array/concatDeep.spec.lua | 53 ------ src/Array/copy.spec.lua | 29 --- src/Array/copyDeep.spec.lua | 43 ----- src/Array/count.spec.lua | 29 --- src/Array/create.spec.lua | 14 -- src/Array/difference.spec.lua | 40 ----- src/Array/differenceSymmetric.spec.lua | 47 ----- src/Array/equals.spec.lua | 29 --- src/Array/equalsDeep.spec.lua | 24 --- src/Array/every.spec.lua | 19 -- src/Array/filter.spec.lua | 36 ---- src/Array/find.spec.lua | 33 ---- src/Array/findLast.spec.lua | 33 ---- src/Array/findWhere.spec.lua | 49 ----- src/Array/findWhereLast.spec.lua | 38 ---- src/Array/first.spec.lua | 11 -- src/Array/flatten.spec.lua | 48 ----- src/Array/freeze.spec.lua | 48 ----- src/Array/freezeDeep.spec.lua | 48 ----- src/Array/includes.spec.lua | 11 -- src/Array/insert.spec.lua | 57 ------ src/Array/is.spec.lua | 11 -- src/Array/last.spec.lua | 11 -- src/Array/map.spec.lua | 31 ---- src/Array/pop.spec.lua | 32 ---- src/Array/push.spec.lua | 29 --- src/Array/reduce.spec.lua | 36 ---- src/Array/reduceRight.spec.lua | 39 ---- src/Array/removeIndex.spec.lua | 31 ---- src/Array/removeIndices.spec.lua | 33 ---- src/Array/removeValue.spec.lua | 23 --- src/Array/removeValues.spec.lua | 22 --- src/Array/reverse.spec.lua | 23 --- src/Array/set.spec.lua | 21 --- src/Array/shift.spec.lua | 32 ---- src/Array/shuffle.spec.lua | 13 -- src/Array/slice.spec.lua | 47 ----- src/Array/some.spec.lua | 23 --- src/Array/sort.spec.lua | 44 ----- src/Array/splice.spec.lua | 27 --- src/Array/toSet.spec.lua | 38 ---- src/Array/unshift.spec.lua | 41 ----- src/Array/update.spec.lua | 48 ----- src/Array/zip.spec.lua | 46 ----- src/Array/zipAll.spec.lua | 69 ------- src/Dictionary/copy.spec.lua | 25 --- src/Dictionary/copyDeep.spec.lua | 52 ------ src/Dictionary/count.spec.lua | 29 --- src/Dictionary/entries.spec.lua | 22 --- src/Dictionary/equals.spec.lua | 29 --- src/Dictionary/equalsDeep.spec.lua | 26 --- src/Dictionary/every.spec.lua | 19 -- src/Dictionary/filter.spec.lua | 34 ---- src/Dictionary/flatten.spec.lua | 64 ------- src/Dictionary/flip.spec.lua | 14 -- src/Dictionary/freeze.spec.lua | 42 ----- src/Dictionary/freezeDeep.spec.lua | 43 ----- src/Dictionary/fromArrays.spec.lua | 15 -- src/Dictionary/fromEntries.spec.lua | 14 -- src/Dictionary/has.spec.lua | 19 -- src/Dictionary/includes.spec.lua | 19 -- src/Dictionary/keys.spec.lua | 15 -- src/Dictionary/map.spec.lua | 27 --- src/Dictionary/merge.spec.lua | 61 ------- src/Dictionary/mergeDeep.spec.lua | 61 ------- src/Dictionary/removeKey.spec.lua | 25 --- src/Dictionary/removeKeys.spec.lua | 29 --- src/Dictionary/removeValue.spec.lua | 25 --- src/Dictionary/removeValues.spec.lua | 29 --- src/Dictionary/set.spec.lua | 25 --- src/Dictionary/some.spec.lua | 23 --- src/Dictionary/update.spec.lua | 57 ------ src/Dictionary/values.spec.lua | 15 -- src/Dictionary/withKeys.spec.lua | 29 --- src/Set/add.spec.lua | 25 --- src/Set/copy.spec.lua | 14 -- src/Set/count.spec.lua | 17 -- src/Set/delete.spec.lua | 23 --- src/Set/difference.spec.lua | 43 ----- src/Set/differenceSymmetric.spec.lua | 43 ----- src/Set/filter.spec.lua | 28 --- src/Set/fromArray.spec.lua | 12 -- src/Set/has.spec.lua | 10 -- src/Set/intersection.spec.lua | 16 -- src/Set/isSubset.spec.lua | 11 -- src/Set/isSuperset.spec.lua | 11 -- src/Set/map.spec.lua | 32 ---- src/Set/merge.spec.lua | 33 ---- src/Set/toArray.spec.lua | 25 --- src/init.lua | 2 + stylua.toml | 4 + wally.lock | 237 ++++++++++++++++++++++++- wally.toml | 10 +- 109 files changed, 312 insertions(+), 2993 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .luaurc delete mode 100644 .stylua.toml delete mode 100644 CHANGELOG.md delete mode 100644 src/Array/at.spec.lua delete mode 100644 src/Array/concat.spec.lua delete mode 100644 src/Array/concatDeep.spec.lua delete mode 100644 src/Array/copy.spec.lua delete mode 100644 src/Array/copyDeep.spec.lua delete mode 100644 src/Array/count.spec.lua delete mode 100644 src/Array/create.spec.lua delete mode 100644 src/Array/difference.spec.lua delete mode 100644 src/Array/differenceSymmetric.spec.lua delete mode 100644 src/Array/equals.spec.lua delete mode 100644 src/Array/equalsDeep.spec.lua delete mode 100644 src/Array/every.spec.lua delete mode 100644 src/Array/filter.spec.lua delete mode 100644 src/Array/find.spec.lua delete mode 100644 src/Array/findLast.spec.lua delete mode 100644 src/Array/findWhere.spec.lua delete mode 100644 src/Array/findWhereLast.spec.lua delete mode 100644 src/Array/first.spec.lua delete mode 100644 src/Array/flatten.spec.lua delete mode 100644 src/Array/freeze.spec.lua delete mode 100644 src/Array/freezeDeep.spec.lua delete mode 100644 src/Array/includes.spec.lua delete mode 100644 src/Array/insert.spec.lua delete mode 100644 src/Array/is.spec.lua delete mode 100644 src/Array/last.spec.lua delete mode 100644 src/Array/map.spec.lua delete mode 100644 src/Array/pop.spec.lua delete mode 100644 src/Array/push.spec.lua delete mode 100644 src/Array/reduce.spec.lua delete mode 100644 src/Array/reduceRight.spec.lua delete mode 100644 src/Array/removeIndex.spec.lua delete mode 100644 src/Array/removeIndices.spec.lua delete mode 100644 src/Array/removeValue.spec.lua delete mode 100644 src/Array/removeValues.spec.lua delete mode 100644 src/Array/reverse.spec.lua delete mode 100644 src/Array/set.spec.lua delete mode 100644 src/Array/shift.spec.lua delete mode 100644 src/Array/shuffle.spec.lua delete mode 100644 src/Array/slice.spec.lua delete mode 100644 src/Array/some.spec.lua delete mode 100644 src/Array/sort.spec.lua delete mode 100644 src/Array/splice.spec.lua delete mode 100644 src/Array/toSet.spec.lua delete mode 100644 src/Array/unshift.spec.lua delete mode 100644 src/Array/update.spec.lua delete mode 100644 src/Array/zip.spec.lua delete mode 100644 src/Array/zipAll.spec.lua delete mode 100644 src/Dictionary/copy.spec.lua delete mode 100644 src/Dictionary/copyDeep.spec.lua delete mode 100644 src/Dictionary/count.spec.lua delete mode 100644 src/Dictionary/entries.spec.lua delete mode 100644 src/Dictionary/equals.spec.lua delete mode 100644 src/Dictionary/equalsDeep.spec.lua delete mode 100644 src/Dictionary/every.spec.lua delete mode 100644 src/Dictionary/filter.spec.lua delete mode 100644 src/Dictionary/flatten.spec.lua delete mode 100644 src/Dictionary/flip.spec.lua delete mode 100644 src/Dictionary/freeze.spec.lua delete mode 100644 src/Dictionary/freezeDeep.spec.lua delete mode 100644 src/Dictionary/fromArrays.spec.lua delete mode 100644 src/Dictionary/fromEntries.spec.lua delete mode 100644 src/Dictionary/has.spec.lua delete mode 100644 src/Dictionary/includes.spec.lua delete mode 100644 src/Dictionary/keys.spec.lua delete mode 100644 src/Dictionary/map.spec.lua delete mode 100644 src/Dictionary/merge.spec.lua delete mode 100644 src/Dictionary/mergeDeep.spec.lua delete mode 100644 src/Dictionary/removeKey.spec.lua delete mode 100644 src/Dictionary/removeKeys.spec.lua delete mode 100644 src/Dictionary/removeValue.spec.lua delete mode 100644 src/Dictionary/removeValues.spec.lua delete mode 100644 src/Dictionary/set.spec.lua delete mode 100644 src/Dictionary/some.spec.lua delete mode 100644 src/Dictionary/update.spec.lua delete mode 100644 src/Dictionary/values.spec.lua delete mode 100644 src/Dictionary/withKeys.spec.lua delete mode 100644 src/Set/add.spec.lua delete mode 100644 src/Set/copy.spec.lua delete mode 100644 src/Set/count.spec.lua delete mode 100644 src/Set/delete.spec.lua delete mode 100644 src/Set/difference.spec.lua delete mode 100644 src/Set/differenceSymmetric.spec.lua delete mode 100644 src/Set/filter.spec.lua delete mode 100644 src/Set/fromArray.spec.lua delete mode 100644 src/Set/has.spec.lua delete mode 100644 src/Set/intersection.spec.lua delete mode 100644 src/Set/isSubset.spec.lua delete mode 100644 src/Set/isSuperset.spec.lua delete mode 100644 src/Set/map.spec.lua delete mode 100644 src/Set/merge.spec.lua delete mode 100644 src/Set/toArray.spec.lua create mode 100644 stylua.toml diff --git a/.gitattributes b/.gitattributes index dfe0770..9de76e4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ # Auto detect text files and perform LF normalization * text=auto + +# Highlight Luau as Lua files +*.lua linguist-language=Luau diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 2907ff9..b481a62 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ -github: csqrl +github: cxmeel custom: - - "https://roblox.com/groups/9536808/csqrl#!/store" + - "https://roblox.com/groups/9536808/cxmeel#!/store" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 6b44ec9..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Publish Package - -on: - workflow_dispatch: - release: - types: [published] - -jobs: - publish-package: - if: ${{ github.events.release.prerelease == false }} - runs-on: ubuntu-latest - timeout-minutes: 5 - - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - ref: ${{ github.event.release.tag_name }} - - - name: Setup Aftman - uses: ok-nick/setup-aftman@v0.3.0 - - - name: Setup Node LTS - uses: actions/setup-node@v2 - with: - node-version: lts/* - - - name: Report Tool Versions - run: | - aftman -V - aftman list - node -v - npm -v - - - name: Install Dependencies - run: | - npm install - wally install - - - name: Remove Tests - run: | - find . -name "*.spec.lua" -delete - - # - name: Publish to Roblox - # run: rojo upload default.project.json --asset_id "${{ secrets.ASSET_ID }}" --cookie "${{ secrets.ROBLOSECURITY }}" - - - name: Publish to Wally - env: - WALLY_TOKEN: ${{ secrets.WALLY_TOKEN }} - run: | - mkdir -p ~/.wally - printf "[tokens]\n\"https://api.wally.run/\" = \"%s\"" "$WALLY_TOKEN" >> ~/.wally/auth.toml - wally publish - - - name: Publish to NPM - uses: JS-DevTools/npm-publish@v1 - with: - token: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 55b6621..f0deb4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ -*.rbx* -*.env +/*.rbx* +.env +.env.* *.tsbuildinfo -packages/ -node_modules/ -out/ -include/ -build/ +/Packages +/DevPackages +/ServerPackages +/temp +/node_modules +/out +/include +/build diff --git a/.luaurc b/.luaurc new file mode 100644 index 0000000..cfbdb52 --- /dev/null +++ b/.luaurc @@ -0,0 +1,8 @@ +{ + "languageMode": "strict", + "lint": { "*": false }, + "aliases": { + "Pkg": "Packages", + "DevPkg": "DevPackages" + } +} diff --git a/.stylua.toml b/.stylua.toml deleted file mode 100644 index 3ae7657..0000000 --- a/.stylua.toml +++ /dev/null @@ -1,7 +0,0 @@ -column_width = 100 -line_endings = "Unix" -indent_type = "Tabs" -indent_width = 4 -quote_style = "AutoPreferDouble" -call_parentheses = "Always" -collapse_simple_statement = "Never" diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index fb5a513..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,61 +0,0 @@ -# Changelog - -## [0.0.6] - -### Added - -- `Dictionary.withKeys` by @sasial-dev to restrict what keys can appear in a given dictionary. - -## [0.0.5] - -### Added - -- `Array.difference` and `Array.differenceSymmetric` to find the difference between two or more arrays. -- `Set.difference` and `Set.differenceSymmetric` to find the difference between two or more sets. - -### Fixed - -- Typings for `Array.concat`, which previously returned `T[][]` instead of `T[]`. - -## [0.0.4] - -- Implemented `Array.is: (value: any) -> boolean` to check if a given value is an array. - -## [0.0.3] - -### Changed - -- If `update` is called with a key that doesn't exist in the specified dictionary, the key's value is **set to the key itself**. Fix by [@reselim](https://github.com/Reselim) in [PR #7](https://github.com/csqrl/sift/pull/7). -- Added `aftman.toml` and switched GitHub workflows over to use aftman. - -## [0.0.2] - -### Changed - -- Fixed a bug where `Array.concat(Deep)`, `Dictionary.merge(Deep)` and `Set.merge` would not accept holes (`nil` values) in their arguments. This would cause the function to stop processing further arguments once it found a `nil` value. -- Fixed a bug where `Array.insert` would not insert the element at the correct index. An index of `0` will now insert the element at the end of the array. `length+1` will also insert the element at the end of the array. `length+2` (or greater) will be ignored, and the original array will be returned. -- Bumped tooling versions: - - rojo to v7.1.1 - - stylua to v0.13.1 - - selene to v0.17.0 - -## [0.0.1] - -### Added - -- Basic **TypeScript (roblox-ts) support** (no tsdoc yet)! 🎉 -- Implemented `isEmpty` -- Added typings to `equalObjects` -- Added aliases for `Array.concat`, `Array.concatDeep`, `Array.push`, `Array.unshift`, `Array.find`, `Array.includes`, `Dictionary.join`, `Dictionary.joinDeep`, `Set.fromArray`, `Set.merge`, `Set.delete` -- Added doc pages for installation and usage samples - -### Changed - -- Exposed `isEmpty` and `equalObjects` from the root module -- Improved typings for methods accepting predictes -- Updated documentation for some methods -- Fixed `Dictionary.flatten` being shown in the `Array` docs (wrong `@within` tag) - -## [0.0.0] - -Initial development version. diff --git a/README.md b/README.md index e748a2e..bb2b1a8 100644 --- a/README.md +++ b/README.md @@ -3,30 +3,29 @@ [freddylist/llama]: https://github.com/freddylist/llama [osyrisrblx/t]: https://github.com/osyrisrblx/t [upliftgames/moonwave]: https://github.com/upliftgames/moonwave -[upliftgames/wally]: https://github.com/upliftgames/wally -[sift]: https://github.com/csqrl/sift -[sift/releases]: https://github.com/csqrl/sift/releases -[sift/wally]: https://wally.run/package/csqrl/sift +[sift]: https://github.com/cxmeel/sift +[sift/releases]: https://github.com/cxmeel/sift/releases +[sift/wally]: https://wally.run/package/cxmeel/sift [sift/roblox]: https://www.roblox.com/library/9486684823 -[sift/itch.io]: https://csqrl.itch.io/sift +[sift/itch.io]: https://cxmeel.itch.io/sift [sift/npm]: https://npmjs.com/package/@rbxts/sift -[shields/github-release]: https://img.shields.io/github/v/release/csqrl/sift?label=latest+release&style=flat -[shields/wally]: https://img.shields.io/endpoint?url=https://runkit.io/clockworksquirrel/wally-version-shield/branches/master/csqrl/sift&color=blue&label=wally&style=flat +[shields/github-release]: https://img.shields.io/github/v/release/cxmeel/sift?label=latest+release&style=flat +[shields/wally]: https://img.shields.io/endpoint?url=https://runkit.io/clockworksquirrel/wally-version-shield/branches/master/cxmeel/sift&color=blue&label=wally&style=flat [shields/npm]: https://img.shields.io/npm/v/@rbxts/sift?style=flat -[badges/github]: https://raw.githubusercontent.com/gist/csqrl/56c5f18b229ca1e61feb6eb5fb149f43/raw/githubSource.svg -[badges/itch]: https://raw.githubusercontent.com/gist/csqrl/56c5f18b229ca1e61feb6eb5fb149f43/raw/itch.svg -[badges/npm]: https://raw.githubusercontent.com/gist/csqrl/56c5f18b229ca1e61feb6eb5fb149f43/raw/npm.svg -[badges/roblox]: https://raw.githubusercontent.com/gist/csqrl/56c5f18b229ca1e61feb6eb5fb149f43/raw/roblox.svg -[badges/roblox-small]: https://raw.githubusercontent.com/gist/csqrl/56c5f18b229ca1e61feb6eb5fb149f43/raw/robloxSmall.svg +[badges/github]: https://raw.githubusercontent.com/gist/cxmeel/56c5f18b229ca1e61feb6eb5fb149f43/raw/githubSource.svg +[badges/itch]: https://raw.githubusercontent.com/gist/cxmeel/56c5f18b229ca1e61feb6eb5fb149f43/raw/itch.svg +[badges/npm]: https://raw.githubusercontent.com/gist/cxmeel/56c5f18b229ca1e61feb6eb5fb149f43/raw/npm.svg +[badges/roblox]: https://raw.githubusercontent.com/gist/cxmeel/56c5f18b229ca1e61feb6eb5fb149f43/raw/roblox.svg # Sift +
[![Source code][badges/github]][sift] [![NPM Package][badges/npm]][sift/npm] [![Itch.io store page][badges/itch]][sift/itch.io] [![Roblox library][badges/roblox]][sift/roblox] @@ -41,7 +40,7 @@ Heavily based on [@freddylist's Llama][freddylist/llama] library, which is no lo ## Documentation -Documentation, powered by [moonwave][upliftgames/moonwave], is available at https://csqrl.github.io/sift. +Documentation, powered by [moonwave][upliftgames/moonwave], is available at . ## v0.x @@ -60,17 +59,17 @@ While Sift is 100% free and open source, if you feel like sponsoring, Sift is al ### Wally -Wally is a CLI package manager (much like NPM, Yarn or Cargo) for Roblox by @UpliftGames. Find out more at https://github.com/upliftgames/wally. +Wally is a CLI package manager (much like NPM, Yarn or Cargo) for Roblox by @UpliftGames. Find out more at . ```toml # wally.toml [dependencies] -Sift = "csqrl/sift@0.0.X" # Replace with current version number +Sift = "cxmeel/sift@0.0.X" # Replace with current version number ``` ```shell -$ wally install +wally install ``` ### TypeScript @@ -78,7 +77,7 @@ $ wally install v0.0.1 of Sift includes TypeScript typings. This means Sift is now compatible with roblox-ts. Refer to the Luau docs for API details. ```shell -$ npm install @rbxts/sift +npm install @rbxts/sift ``` ```ts diff --git a/aftman.toml b/aftman.toml index 3cafc84..3faee9f 100644 --- a/aftman.toml +++ b/aftman.toml @@ -1,6 +1,13 @@ +# This file lists tools managed by Aftman, a cross-platform toolchain manager. +# For more information, see https://github.com/LPGhatguy/aftman + +# To add a new tool, add an entry to this table. [tools] -rojo = "rojo-rbx/rojo@7.3.0" +darklua = "seaofvoices/darklua@0.12.1" +luau-lsp = "johnnymorganz/luau-lsp@1.28.1" +# lune = "filiptibell/lune@0.8.0" +rojo = "rojo-rbx/rojo@7.4.1" run-in-roblox = "rojo-rbx/run-in-roblox@0.3.0" +selene = "kampfkarren/selene@0.26.1" +stylua = "johnnymorganz/stylua@0.20.0" wally = "upliftgames/wally@0.3.2" -stylua = "johnnymorganz/stylua@0.18.1" -selene = "kampfkarren/selene@0.25.0" diff --git a/default.project.json b/default.project.json index 91c96e9..43954a7 100644 --- a/default.project.json +++ b/default.project.json @@ -1,6 +1,9 @@ { "name": "Sift", "tree": { - "$path": "src" + "$path": "src", + "Metadata": { + "$path": "wally.toml" + } } } diff --git a/docs/Installation.md b/docs/Installation.md index 5641fde..1756841 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -4,11 +4,11 @@ sidebar_position: 2 -[sift]: https://github.com/csqrl/sift -[sift/releases]: https://github.com/csqrl/sift/releases -[sift/wally]: https://wally.run/package/csqrl/sift +[sift]: https://github.com/cxmeel/sift +[sift/releases]: https://github.com/cxmeel/sift/releases +[sift/wally]: https://wally.run/package/cxmeel/sift [sift/roblox]: https://www.roblox.com/library/9486684823 -[sift/itch.io]: https://csqrl.itch.io/sift +[sift/itch.io]: https://cxmeel.itch.io/sift [sift/npm]: https://npmjs.com/package/@rbxts/sift Sift is available from [Wally][sift/wally], [Itch.io][sift/itch.io], the [Roblox Library][sift/roblox], and [GitHub releases][sift/releases]. @@ -23,7 +23,7 @@ Wally is a CLI package manager (much like NPM, Yarn or Cargo) for Roblox by @Upl # wally.toml [dependencies] -Sift = "csqrl/sift@=0.0.1" +Sift = "cxmeel/sift@=0.0.1" ``` ```shell diff --git a/moonwave.toml b/moonwave.toml index 2a40967..9b18c75 100644 --- a/moonwave.toml +++ b/moonwave.toml @@ -1,16 +1,14 @@ title = "Sift" gitSourceBranch = "main" -changelog = true classOrder = ["Sift"] [home] -# enabled = true includeReadme = true [[navbar.items]] label = "Sponsor" -href = "https://github.com/sponsors/csqrl" +href = "https://github.com/sponsors/cxmeel" position = "right" [docusaurus.themeConfig.colorMode] diff --git a/package.json b/package.json index 5d506bc..9591aca 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/csqrl/sift.git" + "url": "git+https://github.com/cxmeel/sift.git" }, "keywords": [ "array", @@ -29,9 +29,9 @@ ], "license": "MIT", "bugs": { - "url": "https://github.com/csqrl/sift/issues" + "url": "https://github.com/cxmeel/sift/issues" }, - "homepage": "https://csqrl.github.io/sift", + "homepage": "https://cxmeel.github.io/sift", "files": [ "out", "!**/*.tsbuildinfo" @@ -42,7 +42,6 @@ "rbxts-transform-debug": "^1.0.0-rc.1", "rbxts-transform-env": "^1.0.0-rc.0", "typescript": "^4.3.5", - "roblox-ts": "^1.2.7", - "husky": "^8.0.0" + "roblox-ts": "^1.2.7" } } diff --git a/sourcemap.json b/sourcemap.json index 7f9fa46..b17927f 100644 --- a/sourcemap.json +++ b/sourcemap.json @@ -1 +1 @@ -{"name":"Sift","className":"ModuleScript","filePaths":["src\\init.lua","default.project.json"],"children":[{"name":"Array","className":"ModuleScript","filePaths":["src\\Array\\init.lua"],"children":[{"name":"at","className":"ModuleScript","filePaths":["src\\Array\\at.lua"]},{"name":"at.spec","className":"ModuleScript","filePaths":["src\\Array\\at.spec.lua"]},{"name":"concat","className":"ModuleScript","filePaths":["src\\Array\\concat.lua"]},{"name":"concat.spec","className":"ModuleScript","filePaths":["src\\Array\\concat.spec.lua"]},{"name":"concatDeep","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.lua"]},{"name":"concatDeep.spec","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.spec.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Array\\copy.lua"]},{"name":"copy.spec","className":"ModuleScript","filePaths":["src\\Array\\copy.spec.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.lua"]},{"name":"copyDeep.spec","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.spec.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Array\\count.lua"]},{"name":"count.spec","className":"ModuleScript","filePaths":["src\\Array\\count.spec.lua"]},{"name":"create","className":"ModuleScript","filePaths":["src\\Array\\create.lua"]},{"name":"create.spec","className":"ModuleScript","filePaths":["src\\Array\\create.spec.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Array\\difference.lua"]},{"name":"difference.spec","className":"ModuleScript","filePaths":["src\\Array\\difference.spec.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.lua"]},{"name":"differenceSymmetric.spec","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.spec.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Array\\equals.lua"]},{"name":"equals.spec","className":"ModuleScript","filePaths":["src\\Array\\equals.spec.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.lua"]},{"name":"equalsDeep.spec","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.spec.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Array\\every.lua"]},{"name":"every.spec","className":"ModuleScript","filePaths":["src\\Array\\every.spec.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Array\\filter.lua"]},{"name":"filter.spec","className":"ModuleScript","filePaths":["src\\Array\\filter.spec.lua"]},{"name":"find","className":"ModuleScript","filePaths":["src\\Array\\find.lua"]},{"name":"find.spec","className":"ModuleScript","filePaths":["src\\Array\\find.spec.lua"]},{"name":"findLast","className":"ModuleScript","filePaths":["src\\Array\\findLast.lua"]},{"name":"findLast.spec","className":"ModuleScript","filePaths":["src\\Array\\findLast.spec.lua"]},{"name":"findWhere","className":"ModuleScript","filePaths":["src\\Array\\findWhere.lua"]},{"name":"findWhere.spec","className":"ModuleScript","filePaths":["src\\Array\\findWhere.spec.lua"]},{"name":"findWhereLast","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.lua"]},{"name":"findWhereLast.spec","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.spec.lua"]},{"name":"first","className":"ModuleScript","filePaths":["src\\Array\\first.lua"]},{"name":"first.spec","className":"ModuleScript","filePaths":["src\\Array\\first.spec.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Array\\flatten.lua"]},{"name":"flatten.spec","className":"ModuleScript","filePaths":["src\\Array\\flatten.spec.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Array\\freeze.lua"]},{"name":"freeze.spec","className":"ModuleScript","filePaths":["src\\Array\\freeze.spec.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.lua"]},{"name":"freezeDeep.spec","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.spec.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Array\\includes.lua"]},{"name":"includes.spec","className":"ModuleScript","filePaths":["src\\Array\\includes.spec.lua"]},{"name":"insert","className":"ModuleScript","filePaths":["src\\Array\\insert.lua"]},{"name":"insert.spec","className":"ModuleScript","filePaths":["src\\Array\\insert.spec.lua"]},{"name":"is","className":"ModuleScript","filePaths":["src\\Array\\is.lua"]},{"name":"is.spec","className":"ModuleScript","filePaths":["src\\Array\\is.spec.lua"]},{"name":"last","className":"ModuleScript","filePaths":["src\\Array\\last.lua"]},{"name":"last.spec","className":"ModuleScript","filePaths":["src\\Array\\last.spec.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Array\\map.lua"]},{"name":"map.spec","className":"ModuleScript","filePaths":["src\\Array\\map.spec.lua"]},{"name":"pop","className":"ModuleScript","filePaths":["src\\Array\\pop.lua"]},{"name":"pop.spec","className":"ModuleScript","filePaths":["src\\Array\\pop.spec.lua"]},{"name":"push","className":"ModuleScript","filePaths":["src\\Array\\push.lua"]},{"name":"push.spec","className":"ModuleScript","filePaths":["src\\Array\\push.spec.lua"]},{"name":"reduce","className":"ModuleScript","filePaths":["src\\Array\\reduce.lua"]},{"name":"reduce.spec","className":"ModuleScript","filePaths":["src\\Array\\reduce.spec.lua"]},{"name":"reduceRight","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.lua"]},{"name":"reduceRight.spec","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.spec.lua"]},{"name":"removeIndex","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.lua"]},{"name":"removeIndex.spec","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.spec.lua"]},{"name":"removeIndices","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.lua"]},{"name":"removeIndices.spec","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.spec.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Array\\removeValue.lua"]},{"name":"removeValue.spec","className":"ModuleScript","filePaths":["src\\Array\\removeValue.spec.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Array\\removeValues.lua"]},{"name":"removeValues.spec","className":"ModuleScript","filePaths":["src\\Array\\removeValues.spec.lua"]},{"name":"reverse","className":"ModuleScript","filePaths":["src\\Array\\reverse.lua"]},{"name":"reverse.spec","className":"ModuleScript","filePaths":["src\\Array\\reverse.spec.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Array\\set.lua"]},{"name":"set.spec","className":"ModuleScript","filePaths":["src\\Array\\set.spec.lua"]},{"name":"shift","className":"ModuleScript","filePaths":["src\\Array\\shift.lua"]},{"name":"shift.spec","className":"ModuleScript","filePaths":["src\\Array\\shift.spec.lua"]},{"name":"shuffle","className":"ModuleScript","filePaths":["src\\Array\\shuffle.lua"]},{"name":"shuffle.spec","className":"ModuleScript","filePaths":["src\\Array\\shuffle.spec.lua"]},{"name":"slice","className":"ModuleScript","filePaths":["src\\Array\\slice.lua"]},{"name":"slice.spec","className":"ModuleScript","filePaths":["src\\Array\\slice.spec.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Array\\some.lua"]},{"name":"some.spec","className":"ModuleScript","filePaths":["src\\Array\\some.spec.lua"]},{"name":"sort","className":"ModuleScript","filePaths":["src\\Array\\sort.lua"]},{"name":"sort.spec","className":"ModuleScript","filePaths":["src\\Array\\sort.spec.lua"]},{"name":"splice","className":"ModuleScript","filePaths":["src\\Array\\splice.lua"]},{"name":"splice.spec","className":"ModuleScript","filePaths":["src\\Array\\splice.spec.lua"]},{"name":"toSet","className":"ModuleScript","filePaths":["src\\Array\\toSet.lua"]},{"name":"toSet.spec","className":"ModuleScript","filePaths":["src\\Array\\toSet.spec.lua"]},{"name":"unshift","className":"ModuleScript","filePaths":["src\\Array\\unshift.lua"]},{"name":"unshift.spec","className":"ModuleScript","filePaths":["src\\Array\\unshift.spec.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Array\\update.lua"]},{"name":"update.spec","className":"ModuleScript","filePaths":["src\\Array\\update.spec.lua"]},{"name":"zip","className":"ModuleScript","filePaths":["src\\Array\\zip.lua"]},{"name":"zip.spec","className":"ModuleScript","filePaths":["src\\Array\\zip.spec.lua"]},{"name":"zipAll","className":"ModuleScript","filePaths":["src\\Array\\zipAll.lua"]},{"name":"zipAll.spec","className":"ModuleScript","filePaths":["src\\Array\\zipAll.spec.lua"]}]},{"name":"Dictionary","className":"ModuleScript","filePaths":["src\\Dictionary\\init.lua"],"children":[{"name":"copy","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.lua"]},{"name":"copy.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.spec.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.lua"]},{"name":"copyDeep.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.spec.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Dictionary\\count.lua"]},{"name":"count.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\count.spec.lua"]},{"name":"entries","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.lua"]},{"name":"entries.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.spec.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.lua"]},{"name":"equals.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.spec.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.lua"]},{"name":"equalsDeep.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.spec.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Dictionary\\every.lua"]},{"name":"every.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\every.spec.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.lua"]},{"name":"filter.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.spec.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.lua"]},{"name":"flatten.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.spec.lua"]},{"name":"flip","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.lua"]},{"name":"flip.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.spec.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.lua"]},{"name":"freeze.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.spec.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.lua"]},{"name":"freezeDeep.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.spec.lua"]},{"name":"fromArrays","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.lua"]},{"name":"fromArrays.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.spec.lua"]},{"name":"fromEntries","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.lua"]},{"name":"fromEntries.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.spec.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Dictionary\\has.lua"]},{"name":"has.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\has.spec.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.lua"]},{"name":"includes.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.spec.lua"]},{"name":"keys","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.lua"]},{"name":"keys.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.spec.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Dictionary\\map.lua"]},{"name":"map.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\map.spec.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.lua"]},{"name":"merge.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.spec.lua"]},{"name":"mergeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.lua"]},{"name":"mergeDeep.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.spec.lua"]},{"name":"removeKey","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.lua"]},{"name":"removeKey.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.spec.lua"]},{"name":"removeKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.lua"]},{"name":"removeKeys.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.spec.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.lua"]},{"name":"removeValue.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.spec.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.lua"]},{"name":"removeValues.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.spec.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Dictionary\\set.lua"]},{"name":"set.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\set.spec.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Dictionary\\some.lua"]},{"name":"some.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\some.spec.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Dictionary\\update.lua"]},{"name":"update.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\update.spec.lua"]},{"name":"values","className":"ModuleScript","filePaths":["src\\Dictionary\\values.lua"]},{"name":"values.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\values.spec.lua"]},{"name":"withKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.lua"]},{"name":"withKeys.spec","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.spec.lua"]}]},{"name":"None","className":"ModuleScript","filePaths":["src\\None.lua"]},{"name":"Set","className":"ModuleScript","filePaths":["src\\Set\\init.lua"],"children":[{"name":"add","className":"ModuleScript","filePaths":["src\\Set\\add.lua"]},{"name":"add.spec","className":"ModuleScript","filePaths":["src\\Set\\add.spec.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Set\\copy.lua"]},{"name":"copy.spec","className":"ModuleScript","filePaths":["src\\Set\\copy.spec.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Set\\count.lua"]},{"name":"count.spec","className":"ModuleScript","filePaths":["src\\Set\\count.spec.lua"]},{"name":"delete","className":"ModuleScript","filePaths":["src\\Set\\delete.lua"]},{"name":"delete.spec","className":"ModuleScript","filePaths":["src\\Set\\delete.spec.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Set\\difference.lua"]},{"name":"difference.spec","className":"ModuleScript","filePaths":["src\\Set\\difference.spec.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.lua"]},{"name":"differenceSymmetric.spec","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.spec.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Set\\filter.lua"]},{"name":"filter.spec","className":"ModuleScript","filePaths":["src\\Set\\filter.spec.lua"]},{"name":"fromArray","className":"ModuleScript","filePaths":["src\\Set\\fromArray.lua"]},{"name":"fromArray.spec","className":"ModuleScript","filePaths":["src\\Set\\fromArray.spec.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Set\\has.lua"]},{"name":"has.spec","className":"ModuleScript","filePaths":["src\\Set\\has.spec.lua"]},{"name":"intersection","className":"ModuleScript","filePaths":["src\\Set\\intersection.lua"]},{"name":"intersection.spec","className":"ModuleScript","filePaths":["src\\Set\\intersection.spec.lua"]},{"name":"isSubset","className":"ModuleScript","filePaths":["src\\Set\\isSubset.lua"]},{"name":"isSubset.spec","className":"ModuleScript","filePaths":["src\\Set\\isSubset.spec.lua"]},{"name":"isSuperset","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.lua"]},{"name":"isSuperset.spec","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.spec.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Set\\map.lua"]},{"name":"map.spec","className":"ModuleScript","filePaths":["src\\Set\\map.spec.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Set\\merge.lua"]},{"name":"merge.spec","className":"ModuleScript","filePaths":["src\\Set\\merge.spec.lua"]},{"name":"toArray","className":"ModuleScript","filePaths":["src\\Set\\toArray.lua"]},{"name":"toArray.spec","className":"ModuleScript","filePaths":["src\\Set\\toArray.spec.lua"]}]},{"name":"Types","className":"ModuleScript","filePaths":["src\\Types.lua"]},{"name":"Util","className":"ModuleScript","filePaths":["src\\Util\\init.lua"],"children":[{"name":"equalObjects","className":"ModuleScript","filePaths":["src\\Util\\equalObjects.lua"]},{"name":"func","className":"ModuleScript","filePaths":["src\\Util\\func.lua"]},{"name":"isEmpty","className":"ModuleScript","filePaths":["src\\Util\\isEmpty.lua"]}]}]} \ No newline at end of file +{"name":"Sift","className":"ModuleScript","filePaths":["src\\init.lua","default.project.json"],"children":[{"name":"Array","className":"ModuleScript","filePaths":["src\\Array\\init.lua"],"children":[{"name":"at","className":"ModuleScript","filePaths":["src\\Array\\at.lua"]},{"name":"concat","className":"ModuleScript","filePaths":["src\\Array\\concat.lua"]},{"name":"concatDeep","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Array\\copy.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Array\\count.lua"]},{"name":"create","className":"ModuleScript","filePaths":["src\\Array\\create.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Array\\difference.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Array\\equals.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Array\\every.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Array\\filter.lua"]},{"name":"find","className":"ModuleScript","filePaths":["src\\Array\\find.lua"]},{"name":"findLast","className":"ModuleScript","filePaths":["src\\Array\\findLast.lua"]},{"name":"findWhere","className":"ModuleScript","filePaths":["src\\Array\\findWhere.lua"]},{"name":"findWhereLast","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.lua"]},{"name":"first","className":"ModuleScript","filePaths":["src\\Array\\first.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Array\\flatten.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Array\\freeze.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Array\\includes.lua"]},{"name":"insert","className":"ModuleScript","filePaths":["src\\Array\\insert.lua"]},{"name":"is","className":"ModuleScript","filePaths":["src\\Array\\is.lua"]},{"name":"last","className":"ModuleScript","filePaths":["src\\Array\\last.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Array\\map.lua"]},{"name":"pop","className":"ModuleScript","filePaths":["src\\Array\\pop.lua"]},{"name":"push","className":"ModuleScript","filePaths":["src\\Array\\push.lua"]},{"name":"reduce","className":"ModuleScript","filePaths":["src\\Array\\reduce.lua"]},{"name":"reduceRight","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.lua"]},{"name":"removeIndex","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.lua"]},{"name":"removeIndices","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Array\\removeValue.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Array\\removeValues.lua"]},{"name":"reverse","className":"ModuleScript","filePaths":["src\\Array\\reverse.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Array\\set.lua"]},{"name":"shift","className":"ModuleScript","filePaths":["src\\Array\\shift.lua"]},{"name":"shuffle","className":"ModuleScript","filePaths":["src\\Array\\shuffle.lua"]},{"name":"slice","className":"ModuleScript","filePaths":["src\\Array\\slice.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Array\\some.lua"]},{"name":"sort","className":"ModuleScript","filePaths":["src\\Array\\sort.lua"]},{"name":"splice","className":"ModuleScript","filePaths":["src\\Array\\splice.lua"]},{"name":"toSet","className":"ModuleScript","filePaths":["src\\Array\\toSet.lua"]},{"name":"unshift","className":"ModuleScript","filePaths":["src\\Array\\unshift.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Array\\update.lua"]},{"name":"zip","className":"ModuleScript","filePaths":["src\\Array\\zip.lua"]},{"name":"zipAll","className":"ModuleScript","filePaths":["src\\Array\\zipAll.lua"]}]},{"name":"Dictionary","className":"ModuleScript","filePaths":["src\\Dictionary\\init.lua"],"children":[{"name":"copy","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Dictionary\\count.lua"]},{"name":"entries","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Dictionary\\every.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.lua"]},{"name":"flip","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.lua"]},{"name":"fromArrays","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.lua"]},{"name":"fromEntries","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Dictionary\\has.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.lua"]},{"name":"keys","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Dictionary\\map.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.lua"]},{"name":"mergeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.lua"]},{"name":"removeKey","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.lua"]},{"name":"removeKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Dictionary\\set.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Dictionary\\some.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Dictionary\\update.lua"]},{"name":"values","className":"ModuleScript","filePaths":["src\\Dictionary\\values.lua"]},{"name":"withKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.lua"]}]},{"name":"None","className":"ModuleScript","filePaths":["src\\None.lua"]},{"name":"Set","className":"ModuleScript","filePaths":["src\\Set\\init.lua"],"children":[{"name":"add","className":"ModuleScript","filePaths":["src\\Set\\add.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Set\\copy.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Set\\count.lua"]},{"name":"delete","className":"ModuleScript","filePaths":["src\\Set\\delete.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Set\\difference.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Set\\filter.lua"]},{"name":"fromArray","className":"ModuleScript","filePaths":["src\\Set\\fromArray.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Set\\has.lua"]},{"name":"intersection","className":"ModuleScript","filePaths":["src\\Set\\intersection.lua"]},{"name":"isSubset","className":"ModuleScript","filePaths":["src\\Set\\isSubset.lua"]},{"name":"isSuperset","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Set\\map.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Set\\merge.lua"]},{"name":"toArray","className":"ModuleScript","filePaths":["src\\Set\\toArray.lua"]}]},{"name":"Types","className":"ModuleScript","filePaths":["src\\Types.lua"]},{"name":"Util","className":"ModuleScript","filePaths":["src\\Util\\init.lua"],"children":[{"name":"equalObjects","className":"ModuleScript","filePaths":["src\\Util\\equalObjects.lua"]},{"name":"func","className":"ModuleScript","filePaths":["src\\Util\\func.lua"]},{"name":"isEmpty","className":"ModuleScript","filePaths":["src\\Util\\isEmpty.lua"]}]},{"name":"Metadata","className":"ModuleScript","filePaths":["wally.toml"]}]} \ No newline at end of file diff --git a/src/Array/at.spec.lua b/src/Array/at.spec.lua deleted file mode 100644 index 668cea5..0000000 --- a/src/Array/at.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local At = require(script.Parent.at) - - it("should return the value at the given index", function() - local array = { 1, 2, 3 } - - expect(At(array, 1)).to.equal(1) - expect(At(array, 2)).to.equal(2) - expect(At(array, 3)).to.equal(3) - end) - - it("should return nil if the index is out of bounds", function() - local array = { 1, 2, 3 } - - expect(At(array, 4)).to.equal(nil) - end) - - it("should return from the end if the index is negative (or 0)", function() - local array = { 1, 2, 3 } - - expect(At(array, 0)).to.equal(3) - expect(At(array, -1)).to.equal(2) - expect(At(array, -2)).to.equal(1) - end) -end diff --git a/src/Array/concat.spec.lua b/src/Array/concat.spec.lua deleted file mode 100644 index a689f9b..0000000 --- a/src/Array/concat.spec.lua +++ /dev/null @@ -1,53 +0,0 @@ -return function() - local Concat = require(script.Parent.concat) - - it("should join multiple arrays together into a single array", function() - local table1 = { 1, 2, 3 } - local table2 = { 4, 5, 6 } - - local new = Concat(table1, table2) - - expect(new).to.be.a("table") - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(3) - expect(new[4]).to.equal(4) - expect(new[5]).to.equal(5) - expect(new[6]).to.equal(6) - end) - - it("should return an empty array if no arrays are given", function() - local new = Concat() - - expect(new).to.be.a("table") - expect(#new).to.equal(0) - end) - - it("should accept nil values", function() - local new = Concat(nil, { 1, 2, 3 }) - local new2 = Concat({ 1, 2, 3 }, nil) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - - expect(new2).to.be.a("table") - expect(#new2).to.equal(3) - end) - - it("should not copy the nested arrays", function() - local table1 = { 1, 2, { 3, 4 } } - local table2 = { 5, 6, { 7, 8 } } - - local new = Concat(table1, table2) - - expect(new).to.be.a("table") - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(table1[3]) - expect(new[4]).to.equal(5) - expect(new[5]).to.equal(6) - expect(new[6]).to.equal(table2[3]) - end) -end diff --git a/src/Array/concatDeep.spec.lua b/src/Array/concatDeep.spec.lua deleted file mode 100644 index 679c2e0..0000000 --- a/src/Array/concatDeep.spec.lua +++ /dev/null @@ -1,53 +0,0 @@ -return function() - local ConcatDeep = require(script.Parent.concatDeep) - - it("should join multiple arrays together into a single array", function() - local table1 = { 1, 2, 3 } - local table2 = { 4, 5, 6 } - - local new = ConcatDeep(table1, table2) - - expect(new).to.be.a("table") - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(3) - expect(new[4]).to.equal(4) - expect(new[5]).to.equal(5) - expect(new[6]).to.equal(6) - end) - - it("should return an empty array if no arrays are given", function() - local new = ConcatDeep() - - expect(new).to.be.a("table") - expect(#new).to.equal(0) - end) - - it("should accept nil values", function() - local new = ConcatDeep(nil, { 1, 2, 3 }) - local new2 = ConcatDeep({ 1, 2, 3 }, nil) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - - expect(new2).to.be.a("table") - expect(#new2).to.equal(3) - end) - - it("should join multiple arrays, copying nested arrays", function() - local table1 = { 1, 2, { 3, 4 } } - local table2 = { 5, 6, { 7, 8 } } - - local new = ConcatDeep(table1, table2) - - expect(new).to.be.a("table") - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).never.to.equal(table1[3]) - expect(new[4]).to.equal(5) - expect(new[5]).to.equal(6) - expect(new[6]).never.to.equal(table2[3]) - end) -end diff --git a/src/Array/copy.spec.lua b/src/Array/copy.spec.lua deleted file mode 100644 index a734e5e..0000000 --- a/src/Array/copy.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Copy = require(script.Parent.copy) - - it("should return a copy of the given array", function() - local array = { 1, 2, 3 } - - local new = Copy(array) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(3) - end) - - it("should not copy nested arrays", function() - local array = { 1, 2, { 3, 4 } } - - local new = Copy(array) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(array[3]) - end) -end diff --git a/src/Array/copyDeep.spec.lua b/src/Array/copyDeep.spec.lua deleted file mode 100644 index 634c2ca..0000000 --- a/src/Array/copyDeep.spec.lua +++ /dev/null @@ -1,43 +0,0 @@ -return function() - local CopyDeep = require(script.Parent.copyDeep) - - it("should return a copy of the given array", function() - local array = { 1, 2, 3 } - - local new = CopyDeep(array) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(3) - end) - - it("should copy nested arrays", function() - local array = { 1, 2, { 3, 4 } } - - local new = CopyDeep(array) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).never.to.equal(array[3]) - end) - - it("should copy metatables", function() - local meta = setmetatable({}, { __index = function() end }) - local array = { { 1, 2, 3 }, { 4, 5, 6 }, meta } - - local new = CopyDeep(array) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - - expect(function() - return getmetatable(new[3]) - end).to.be.a("function") - end) -end diff --git a/src/Array/count.spec.lua b/src/Array/count.spec.lua deleted file mode 100644 index a6cfedb..0000000 --- a/src/Array/count.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Count = require(script.Parent.count) - - it("should return the number of elements in the given array", function() - local array = { 1, 2, 3 } - - local count = Count(array) - - expect(count).to.equal(3) - end) - - it("should return 0 for an empty array", function() - local array = {} - - local count = Count(array) - - expect(count).to.equal(0) - end) - - it("should return the number of elements matching the given predicate", function() - local array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } - - local count = Count(array, function(value) - return value % 2 == 0 - end) - - expect(count).to.equal(5) - end) -end diff --git a/src/Array/create.spec.lua b/src/Array/create.spec.lua deleted file mode 100644 index aeab9fe..0000000 --- a/src/Array/create.spec.lua +++ /dev/null @@ -1,14 +0,0 @@ -return function() - local Create = require(script.Parent.create) - - it("should return an array of the given length, filled with the given value", function() - local array = Create(3, "Hello") - - expect(array).to.be.a("table") - expect(#array).to.equal(3) - - expect(array[1]).to.equal("Hello") - expect(array[2]).to.equal("Hello") - expect(array[3]).to.equal("Hello") - end) -end diff --git a/src/Array/difference.spec.lua b/src/Array/difference.spec.lua deleted file mode 100644 index 5ae04ab..0000000 --- a/src/Array/difference.spec.lua +++ /dev/null @@ -1,40 +0,0 @@ -return function() - local difference = require(script.Parent.difference) - - it("should return the difference between two arrays", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - - local newArray = difference(array, otherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(1) - - expect(table.find(newArray, "world")).to.be.ok() - end) - - it("should accept vararg nil values", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - - local newArray = difference(array, nil, otherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(1) - - expect(table.find(newArray, "world")).to.be.ok() - end) - - it("should accept multiple arrays", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - local anotherArray = { "hello", "panda" } - - local newArray = difference(array, otherArray, anotherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(1) - - expect(table.find(newArray, "world")).to.be.ok() - end) -end diff --git a/src/Array/differenceSymmetric.spec.lua b/src/Array/differenceSymmetric.spec.lua deleted file mode 100644 index c3b03da..0000000 --- a/src/Array/differenceSymmetric.spec.lua +++ /dev/null @@ -1,47 +0,0 @@ -return function() - local differenceSymmetric = require(script.Parent.differenceSymmetric) - - it("should return the symmetric difference between two arrays", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - - local newArray = differenceSymmetric(array, otherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(3) - - expect(table.find(newArray, "world")).to.be.ok() - expect(table.find(newArray, "cat")).to.be.ok() - expect(table.find(newArray, "dog")).to.be.ok() - end) - - it("should accept vararg nil values", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - - local newArray = differenceSymmetric(array, nil, otherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(3) - - expect(table.find(newArray, "world")).to.be.ok() - expect(table.find(newArray, "cat")).to.be.ok() - expect(table.find(newArray, "dog")).to.be.ok() - end) - - it("should accept multiple arrays", function() - local array = { "hello", "world" } - local otherArray = { "cat", "dog", "hello" } - local anotherArray = { "hello", "panda" } - - local newArray = differenceSymmetric(array, otherArray, anotherArray) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(4) - - expect(table.find(newArray, "world")).to.be.ok() - expect(table.find(newArray, "cat")).to.be.ok() - expect(table.find(newArray, "dog")).to.be.ok() - expect(table.find(newArray, "panda")).to.be.ok() - end) -end diff --git a/src/Array/equals.spec.lua b/src/Array/equals.spec.lua deleted file mode 100644 index cf461e2..0000000 --- a/src/Array/equals.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Equals = require(script.Parent.equals) - - it("should return true if the arrays are equal", function() - local array1 = { 1, 2, 3 } - local array2 = { 1, 2, 3 } - - expect(Equals(array1, array2)).to.equal(true) - end) - - it("should return false if the arrays are not equal", function() - local array1 = { 1, 2, 3 } - local array2 = { 1, 2, 4 } - - expect(Equals(array1, array2)).to.equal(false) - end) - - it("should return false for nested arrays", function() - --[[ - This is because the nested arrays have different memory addresses, - despite having the same values. Use EqualsDeep instead if you want to - compare nested arrays. - --]] - local array1 = { 1, 2, { 3, 4 } } - local array2 = { 1, 2, { 3, 4 } } - - expect(Equals(array1, array2)).to.equal(false) - end) -end diff --git a/src/Array/equalsDeep.spec.lua b/src/Array/equalsDeep.spec.lua deleted file mode 100644 index 0cc546c..0000000 --- a/src/Array/equalsDeep.spec.lua +++ /dev/null @@ -1,24 +0,0 @@ -return function() - local EqualsDeep = require(script.Parent.equalsDeep) - - it("should return true if the arrays are equal", function() - local array1 = { 1, 2, 3 } - local array2 = { 1, 2, 3 } - - expect(EqualsDeep(array1, array2)).to.equal(true) - end) - - it("should return false if the arrays are not equal", function() - local array1 = { 1, 2, 3 } - local array2 = { 1, 2, 4 } - - expect(EqualsDeep(array1, array2)).to.equal(false) - end) - - it("should return true if nested arrays are equal", function() - local array1 = { 1, 2, { 3, 4 } } - local array2 = { 1, 2, { 3, 4 } } - - expect(EqualsDeep(array1, array2)).to.equal(true) - end) -end diff --git a/src/Array/every.spec.lua b/src/Array/every.spec.lua deleted file mode 100644 index f627ee2..0000000 --- a/src/Array/every.spec.lua +++ /dev/null @@ -1,19 +0,0 @@ -return function() - local Every = require(script.Parent.every) - - it("should return true if all elements match the predicate", function() - local array = { 1, 2, 3 } - - expect(Every(array, function(value) - return value % 1 == 0 - end)).to.equal(true) - end) - - it("should return false if any elements do not match the predicate", function() - local array = { 1, 2, 3 } - - expect(Every(array, function(value) - return value % 2 == 0 - end)).to.equal(false) - end) -end diff --git a/src/Array/filter.spec.lua b/src/Array/filter.spec.lua deleted file mode 100644 index 865b1fe..0000000 --- a/src/Array/filter.spec.lua +++ /dev/null @@ -1,36 +0,0 @@ -return function() - local Filter = require(script.Parent.filter) - - it( - "should return a copy of the given array with only the elements that match the predicate", - function() - local array = { 1, 2, 3 } - - local new = Filter(array, function(value) - return value % 2 == 0 - end) - - expect(new).to.be.a("table") - expect(new).never.to.equal(array) - expect(#new).to.equal(1) - - expect(new[1]).to.equal(2) - end - ) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - local new = Filter(array, function(value) - return value % 2 == 0 - end) - - expect(new).never.to.equal(array) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - - expect(new[1]).to.equal(2) - end) -end diff --git a/src/Array/find.spec.lua b/src/Array/find.spec.lua deleted file mode 100644 index ddbd52b..0000000 --- a/src/Array/find.spec.lua +++ /dev/null @@ -1,33 +0,0 @@ -return function() - local Find = require(script.Parent.find) - - it("should return the first element that matches the given value", function() - local array = { 1, 2, 3 } - - expect(Find(array, 2)).to.equal(2) - end) - - it("should return nil if no element matches the given value", function() - local array = { 1, 2, 3 } - - expect(Find(array, 4)).never.to.be.ok() - end) - - it("should return the first element that matches, given a starting index", function() - local array = { 1, 2, 3 } - - expect(Find(array, 3, 2)).to.equal(3) - end) - - it("should return nil if no element matches, given a starting index", function() - local array = { 1, 2, 3 } - - expect(Find(array, 1, 2)).never.to.be.ok() - end) - - it("should accept a negative starting index", function() - local array = { 1, 2, 3 } - - expect(Find(array, 2, -1)).to.equal(2) - end) -end diff --git a/src/Array/findLast.spec.lua b/src/Array/findLast.spec.lua deleted file mode 100644 index b442310..0000000 --- a/src/Array/findLast.spec.lua +++ /dev/null @@ -1,33 +0,0 @@ -return function() - local FindLast = require(script.Parent.findLast) - - it("should return the first element that matches the given value", function() - local array = { 1, 2, 3 } - - expect(FindLast(array, 2)).to.equal(2) - end) - - it("should return nil if no element matches the given value", function() - local array = { 1, 2, 3 } - - expect(FindLast(array, 4)).never.to.be.ok() - end) - - it("should return nil if no element matches, given a starting index", function() - local array = { 1, 2, 3 } - - expect(FindLast(array, 3, 2)).never.to.be.ok() - end) - - it("should return the first element that matches, given a starting index", function() - local array = { 1, 2, 3 } - - expect(FindLast(array, 1, 2)).to.equal(1) - end) - - it("should accept a negative starting index", function() - local array = { 1, 2, 3 } - - expect(FindLast(array, 2, -1)).to.equal(2) - end) -end diff --git a/src/Array/findWhere.spec.lua b/src/Array/findWhere.spec.lua deleted file mode 100644 index a84aa23..0000000 --- a/src/Array/findWhere.spec.lua +++ /dev/null @@ -1,49 +0,0 @@ -return function() - local FindWhere = require(script.Parent.findWhere) - - it("should return the first element in the array that matches the given predicate", function() - local array = { 1, 2, 3 } - - local result = FindWhere(array, function(value) - return value == 2 - end) - - expect(result).to.equal(2) - end) - - it("should return nil if no element matches the given predicate", function() - local array = { 1, 2, 3 } - - local result = FindWhere(array, function(value) - return value == 4 - end) - - expect(result).never.to.be.ok() - end) - - it( - "should return the first element in the array that matches the given predicate, given a starting index", - function() - local array = { 1, 2, 3 } - - local result = FindWhere(array, function(value) - return value == 3 - end, 2) - - expect(result).to.equal(3) - end - ) - - it( - "should return nil if no element matches the given predicate, given a starting index", - function() - local array = { 1, 2, 3 } - - local result = FindWhere(array, function(value) - return value == 1 - end, 2) - - expect(result).never.to.be.ok() - end - ) -end diff --git a/src/Array/findWhereLast.spec.lua b/src/Array/findWhereLast.spec.lua deleted file mode 100644 index 8044325..0000000 --- a/src/Array/findWhereLast.spec.lua +++ /dev/null @@ -1,38 +0,0 @@ -return function() - local FindWhereLast = require(script.Parent.findWhereLast) - - it("should return the last element that matches the predicate", function() - local array = { 1, 2, 3, 4, 5 } - - expect(FindWhereLast(array, function(value) - return value % 2 == 0 - end)).to.equal(4) - end) - - it("should return nil if no element matches the predicate", function() - local array = { 1, 2, 3, 4, 5 } - - expect(FindWhereLast(array, function(value) - return value == 6 - end)).never.to.be.ok() - end) - - it( - "should return the last element that matches the predicate, given a starting index", - function() - local array = { 1, 2, 3, 4, 5 } - - expect(FindWhereLast(array, function(value) - return value % 2 == 0 - end, 2)).to.equal(2) - end - ) - - it("should return nil if no element matches the predicate, given a starting index", function() - local array = { 1, 2, 3, 4, 5 } - - expect(FindWhereLast(array, function(value) - return value == 4 - end, 3)).never.to.be.ok() - end) -end diff --git a/src/Array/first.spec.lua b/src/Array/first.spec.lua deleted file mode 100644 index 5264a5c..0000000 --- a/src/Array/first.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local First = require(script.Parent.first) - - it("should return the first element of the given array", function() - local array = { 1, 2, 3 } - - local first = First(array) - - expect(first).to.equal(1) - end) -end diff --git a/src/Array/flatten.spec.lua b/src/Array/flatten.spec.lua deleted file mode 100644 index fe0747a..0000000 --- a/src/Array/flatten.spec.lua +++ /dev/null @@ -1,48 +0,0 @@ -return function() - local Flatten = require(script.Parent.flatten) - - it("should return a flattened array", function() - local array = { 1, 2, { 3, 4 } } - - local flattened = Flatten(array) - - expect(flattened).to.be.a("table") - expect(#flattened).to.equal(4) - - expect(flattened[1]).to.equal(1) - expect(flattened[2]).to.equal(2) - expect(flattened[3]).to.equal(3) - expect(flattened[4]).to.equal(4) - end) - - it("should not flatten nested arrays if depth = 0", function() - local array = { 1, 2, { 3, 4 } } - - local flattened = Flatten(array, 0) - - expect(flattened).to.be.a("table") - expect(#flattened).to.equal(3) - - expect(flattened[1]).to.equal(1) - expect(flattened[2]).to.equal(2) - expect(flattened[3]).to.equal(array[3]) - end) - - it("should flatten as deeply as possible", function() - local array = { 1, 2, { 3, 4, { 5, 6, { 7, 8 } } } } - - local flattened = Flatten(array) - - expect(flattened).to.be.a("table") - expect(#flattened).to.equal(8) - - expect(flattened[1]).to.equal(1) - expect(flattened[2]).to.equal(2) - expect(flattened[3]).to.equal(3) - expect(flattened[4]).to.equal(4) - expect(flattened[5]).to.equal(5) - expect(flattened[6]).to.equal(6) - expect(flattened[7]).to.equal(7) - expect(flattened[8]).to.equal(8) - end) -end diff --git a/src/Array/freeze.spec.lua b/src/Array/freeze.spec.lua deleted file mode 100644 index ea71549..0000000 --- a/src/Array/freeze.spec.lua +++ /dev/null @@ -1,48 +0,0 @@ -return function() - local Freeze = require(script.Parent.freeze) - - it("should return a read-only copy of the given array", function() - local array = { 1, 2, 3 } - - local frozen = Freeze(array) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(array) - expect(#frozen).to.equal(3) - - expect(frozen[1]).to.equal(1) - expect(frozen[2]).to.equal(2) - expect(frozen[3]).to.equal(3) - - expect(function() - frozen[1] = 4 - end).to.throw() - end) - - it("should not freeze nested arrays", function() - local array = { 1, 2, { 3, 4 } } - - local frozen = Freeze(array) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(array) - expect(#frozen).to.equal(3) - - expect(frozen[1]).to.equal(1) - expect(frozen[2]).to.equal(2) - expect(frozen[3]).to.be.a("table") - expect(frozen[3]).to.equal(array[3]) - expect(#frozen[3]).to.equal(2) - - expect(frozen[3][1]).to.equal(3) - expect(frozen[3][2]).to.equal(4) - - expect(function() - frozen[1] = 4 - end).to.throw() - - expect(function() - frozen[3][1] = 5 - end).never.to.throw() - end) -end diff --git a/src/Array/freezeDeep.spec.lua b/src/Array/freezeDeep.spec.lua deleted file mode 100644 index 407c0cb..0000000 --- a/src/Array/freezeDeep.spec.lua +++ /dev/null @@ -1,48 +0,0 @@ -return function() - local FreezeDeep = require(script.Parent.freezeDeep) - - it("should return a read-only copy of the given array", function() - local array = { 1, 2, 3 } - - local frozen = FreezeDeep(array) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(array) - expect(#frozen).to.equal(3) - - expect(frozen[1]).to.equal(1) - expect(frozen[2]).to.equal(2) - expect(frozen[3]).to.equal(3) - - expect(function() - frozen[1] = 4 - end).to.throw() - end) - - it("should return a read-only copy of nested arrays", function() - local array = { 1, 2, { 3, 4 } } - - local frozen = FreezeDeep(array) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(array) - expect(#frozen).to.equal(3) - - expect(frozen[1]).to.equal(1) - expect(frozen[2]).to.equal(2) - expect(frozen[3]).to.be.a("table") - expect(frozen[3]).never.to.equal(array[3]) - expect(#frozen[3]).to.equal(2) - - expect(frozen[3][1]).to.equal(3) - expect(frozen[3][2]).to.equal(4) - - expect(function() - frozen[1] = 4 - end).to.throw() - - expect(function() - frozen[3][1] = 5 - end).to.throw() - end) -end diff --git a/src/Array/includes.spec.lua b/src/Array/includes.spec.lua deleted file mode 100644 index b2655b5..0000000 --- a/src/Array/includes.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local Includes = require(script.Parent.includes) - - it("should return true if the given array includes the given value", function() - local array = { 1, 2, 3 } - - local includes = Includes(array, 2) - - expect(includes).to.equal(true) - end) -end diff --git a/src/Array/insert.spec.lua b/src/Array/insert.spec.lua deleted file mode 100644 index 9ed0224..0000000 --- a/src/Array/insert.spec.lua +++ /dev/null @@ -1,57 +0,0 @@ -return function() - local Insert = require(script.Parent.insert) - - it( - "should insert the given values into an array at the given index, shifting all values after it to the right", - function() - local array = { 1, 2, 3 } - - local newArray = Insert(array, 2, 4, 5) -- { 1, 4, 5, 2, 3 } - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(5) - - expect(newArray[1]).to.equal(1) - expect(newArray[2]).to.equal(4) - expect(newArray[3]).to.equal(5) - expect(newArray[4]).to.equal(2) - expect(newArray[5]).to.equal(3) - end - ) - - it("should accept negative indices", function() - local array = { 1, 2, 3 } - - local newArray = Insert(array, 0, 4, 5) -- { 1, 2, 3, 4, 5 } - local newArray2 = Insert(array, -1, 4, 5) -- { 1, 2, 4, 5, 3 } - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(5) - expect(newArray[5]).to.equal(5) - - expect(newArray2).to.be.a("table") - expect(#newArray2).to.equal(5) - expect(newArray2[3]).to.equal(4) - expect(newArray2[5]).to.equal(3) - end) - - it("should accept length+1", function() - local array = { 1, 2, 3 } - - local newArray = Insert(array, 4, 4, 5) -- { 1, 2, 3, 4, 5 } - local newArray2 = Insert(array, 5, 4) -- { 1, 2, 3 } - local newArray3 = Insert(array, 0, 4) -- { 1, 2, 3, 4 } - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(5) - expect(newArray[5]).to.equal(5) - - expect(newArray2).to.be.a("table") - expect(#newArray2).to.equal(3) - expect(newArray2[3]).to.equal(3) - - expect(newArray3).to.be.a("table") - expect(#newArray3).to.equal(4) - expect(newArray3[4]).to.equal(4) - end) -end diff --git a/src/Array/is.spec.lua b/src/Array/is.spec.lua deleted file mode 100644 index a5b1603..0000000 --- a/src/Array/is.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local isArray = require(script.Parent.is) - - it("should return whether the given object is an array", function() - expect(isArray({})).to.equal(false) - expect(isArray({ 1, 2, 3 })).to.equal(true) - expect(isArray({ hello = "world" })).to.equal(false) - expect(isArray({ 1, 2, hello = "world" })).to.equal(false) - expect(isArray({ 1, 2, 3, nil, 5 })).to.equal(true) - end) -end diff --git a/src/Array/last.spec.lua b/src/Array/last.spec.lua deleted file mode 100644 index d205704..0000000 --- a/src/Array/last.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local Last = require(script.Parent.last) - - it("should return the last element of the given array", function() - local array = { 1, 2, 3 } - - local last = Last(array) - - expect(last).to.equal(3) - end) -end diff --git a/src/Array/map.spec.lua b/src/Array/map.spec.lua deleted file mode 100644 index fd4fbee..0000000 --- a/src/Array/map.spec.lua +++ /dev/null @@ -1,31 +0,0 @@ -return function() - local Map = require(script.Parent.map) - - it("should return an array where values are the result of the mapper function", function() - local array = Map({ 1, 2, 3 }, function(value) - return value * 2 - end) - - expect(array).to.be.a("table") - expect(#array).to.equal(3) - - expect(array[1]).to.equal(2) - expect(array[2]).to.equal(4) - expect(array[3]).to.equal(6) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Map(array, function(value) - return value * 2 - end) - - expect(array).to.be.a("table") - expect(#array).to.equal(3) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/pop.spec.lua b/src/Array/pop.spec.lua deleted file mode 100644 index 1f19e99..0000000 --- a/src/Array/pop.spec.lua +++ /dev/null @@ -1,32 +0,0 @@ -return function() - local Pop = require(script.Parent.pop) - - it("should remove the last element of the given array", function() - local array = { 1, 2, 3 } - - local popped = Pop(array) - - expect(popped[1]).to.equal(1) - expect(popped[2]).to.equal(2) - expect(popped[3]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Pop(array) - - expect(array[3]).to.equal(3) - end) - - it("should pop multiple elements from the array", function() - local array = { 1, 2, 3, 4, 5 } - - local popped = Pop(array, 2) - - expect(popped[1]).to.equal(1) - expect(popped[2]).to.equal(2) - expect(popped[3]).to.equal(3) - expect(popped[4]).never.to.be.ok() - end) -end diff --git a/src/Array/push.spec.lua b/src/Array/push.spec.lua deleted file mode 100644 index a4cff8c..0000000 --- a/src/Array/push.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Push = require(script.Parent.push) - - it("should return an array with new value(s) added", function() - local array = Push({ 1, 2, 3 }, "Hello") - - expect(array).to.be.a("table") - expect(#array).to.equal(4) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - expect(array[4]).to.equal("Hello") - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Push(array, "Hello") - - expect(array).to.be.a("table") - expect(#array).to.equal(3) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - expect(array[4]).never.to.be.ok() - end) -end diff --git a/src/Array/reduce.spec.lua b/src/Array/reduce.spec.lua deleted file mode 100644 index 68cf1f9..0000000 --- a/src/Array/reduce.spec.lua +++ /dev/null @@ -1,36 +0,0 @@ -return function() - local Reduce = require(script.Parent.reduce) - - it("should reduce the given array to a single value", function() - local array = { 1, 2, 3 } - - local reduced = Reduce(array, function(accumulator, value) - return accumulator + value - end, 0) - - expect(reduced).to.equal(6) - end) - - it( - "should reduce the given array to a single value, using the first element as the initial value", - function() - local array = { 1, 2, 3 } - - local reduced = Reduce(array, function(accumulator, value) - return accumulator - value - end) - - expect(reduced).to.equal(-4) - end - ) - - it("should reduce the array, even if the array has a falsy initial value", function() - local array = { true, false, false } - - local reduced = Reduce(array, function(accumulator, value) - return accumulator or value - end, false) - - expect(reduced).to.equal(true) - end) -end diff --git a/src/Array/reduceRight.spec.lua b/src/Array/reduceRight.spec.lua deleted file mode 100644 index d6b41cc..0000000 --- a/src/Array/reduceRight.spec.lua +++ /dev/null @@ -1,39 +0,0 @@ -return function() - local ReduceRight = require(script.Parent.reduceRight) - - it("should reduce the given array from the right", function() - local array = { 1, 2, 3 } - - local reduced = ReduceRight(array, function(accumulator, value) - return accumulator + value - end, 0) - - expect(reduced).to.equal(6) - end) - - it( - "should reduce the given array from the right, using the last element as the initial value", - function() - local array = { 1, 2, 3 } - - local reduced = ReduceRight(array, function(accumulator, value) - return accumulator - value - end) - - expect(reduced).to.equal(0) - end - ) - - it( - "should reduce the array from the right, even if the array has a falsy initial value", - function() - local array = { true, false, true } - - local reduced = ReduceRight(array, function(accumulator, value) - return accumulator or value - end, false) - - expect(reduced).to.equal(true) - end - ) -end diff --git a/src/Array/removeIndex.spec.lua b/src/Array/removeIndex.spec.lua deleted file mode 100644 index 2a44338..0000000 --- a/src/Array/removeIndex.spec.lua +++ /dev/null @@ -1,31 +0,0 @@ -return function() - local RemoveIndex = require(script.Parent.removeIndex) - - it("should remove the element at the given index", function() - local array = { 1, 2, 3 } - - local removed = RemoveIndex(array, 2) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - RemoveIndex(array, 2) - - expect(array[2]).to.equal(2) - end) - - it("should remove an element at the given negative index", function() - local array = { 1, 2, 3 } - - local removed = RemoveIndex(array, -1) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).never.to.be.ok() - end) -end diff --git a/src/Array/removeIndices.spec.lua b/src/Array/removeIndices.spec.lua deleted file mode 100644 index 64dceba..0000000 --- a/src/Array/removeIndices.spec.lua +++ /dev/null @@ -1,33 +0,0 @@ -return function() - local RemoveIndices = require(script.Parent.removeIndices) - - it("should remove the elements at the given indices", function() - local array = { 1, 2, 3, 4, 5 } - - local removed = RemoveIndices(array, 2, 4) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).to.equal(5) - expect(removed[4]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3, 4, 5 } - - RemoveIndices(array, 2, 4) - - expect(array[4]).to.equal(4) - end) - - it("should remove indices at given negative indices", function() - local array = { 1, 2, 3, 4, 5 } - - local removed = RemoveIndices(array, -1, -3) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).to.equal(5) - expect(removed[4]).never.to.be.ok() - end) -end diff --git a/src/Array/removeValue.spec.lua b/src/Array/removeValue.spec.lua deleted file mode 100644 index 2c8c172..0000000 --- a/src/Array/removeValue.spec.lua +++ /dev/null @@ -1,23 +0,0 @@ -return function() - local RemoveValue = require(script.Parent.removeValue) - - it("should remove the elements with the given value", function() - local array = { 1, 2, 3, 4, 5 } - - local removed = RemoveValue(array, 2) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).to.equal(4) - expect(removed[4]).to.equal(5) - expect(removed[5]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3, 4, 5 } - - RemoveValue(array, 2) - - expect(array[2]).to.equal(2) - end) -end diff --git a/src/Array/removeValues.spec.lua b/src/Array/removeValues.spec.lua deleted file mode 100644 index ffd7313..0000000 --- a/src/Array/removeValues.spec.lua +++ /dev/null @@ -1,22 +0,0 @@ -return function() - local RemoveValues = require(script.Parent.removeValues) - - it("should remove the elements with the given values", function() - local array = { 1, 2, 3, 4, 5 } - - local removed = RemoveValues(array, 2, 4) - - expect(removed[1]).to.equal(1) - expect(removed[2]).to.equal(3) - expect(removed[3]).to.equal(5) - expect(removed[4]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3, 4, 5 } - - RemoveValues(array, 2, 4) - - expect(array[4]).to.equal(4) - end) -end diff --git a/src/Array/reverse.spec.lua b/src/Array/reverse.spec.lua deleted file mode 100644 index 6b00930..0000000 --- a/src/Array/reverse.spec.lua +++ /dev/null @@ -1,23 +0,0 @@ -return function() - local Reverse = require(script.Parent.reverse) - - it("should reverse the given array", function() - local array = { 1, 2, 3 } - - local reversed = Reverse(array) - - expect(reversed[1]).to.equal(3) - expect(reversed[2]).to.equal(2) - expect(reversed[3]).to.equal(1) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Reverse(array) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/set.spec.lua b/src/Array/set.spec.lua deleted file mode 100644 index 202eda2..0000000 --- a/src/Array/set.spec.lua +++ /dev/null @@ -1,21 +0,0 @@ -return function() - local Set = require(script.Parent.set) - - it("should set the given value in the given array", function() - local array = { 1, 2, 3 } - - local new = Set(array, 2, 4) - - expect(new[2]).to.equal(4) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Set(array, 2, 4) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/shift.spec.lua b/src/Array/shift.spec.lua deleted file mode 100644 index 4639d56..0000000 --- a/src/Array/shift.spec.lua +++ /dev/null @@ -1,32 +0,0 @@ -return function() - local Shift = require(script.Parent.shift) - - it("should remove the first item from the array", function() - local array = { 1, 2, 3 } - - local shifted = Shift(array) - - expect(shifted[1]).to.equal(2) - expect(shifted[2]).to.equal(3) - expect(shifted[3]).never.to.be.ok() - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Shift(array) - - expect(array[1]).to.equal(1) - end) - - it("should shift given a number of items to remove", function() - local array = { 1, 2, 3, 4, 5 } - - local shifted = Shift(array, 2) - - expect(shifted[1]).to.equal(3) - expect(shifted[2]).to.equal(4) - expect(shifted[3]).to.equal(5) - expect(shifted[4]).never.to.be.ok() - end) -end diff --git a/src/Array/shuffle.spec.lua b/src/Array/shuffle.spec.lua deleted file mode 100644 index e49628c..0000000 --- a/src/Array/shuffle.spec.lua +++ /dev/null @@ -1,13 +0,0 @@ -return function() - local Shuffle = require(script.Parent.shuffle) - - it("should return a shuffled array", function() - local array = { 1, 2, 3 } - - local shuffled = Shuffle(array) - - expect(shuffled).to.be.a("table") - expect(#shuffled).to.equal(3) - expect(shuffled).never.to.equal(array) - end) -end diff --git a/src/Array/slice.spec.lua b/src/Array/slice.spec.lua deleted file mode 100644 index 048097f..0000000 --- a/src/Array/slice.spec.lua +++ /dev/null @@ -1,47 +0,0 @@ -return function() - local Slice = require(script.Parent.slice) - - it("should return a slice of the given array", function() - local array = { 1, 2, 3 } - - local slice = Slice(array, 2, 3) - - expect(slice).to.be.a("table") - expect(#slice).to.equal(2) - expect(slice[1]).to.equal(2) - expect(slice[2]).to.equal(3) - end) - - it("should return a slice of the given array with a negative start index", function() - local array = { 1, 2, 3 } - - local slice = Slice(array, -1, 3) - - expect(slice).to.be.a("table") - expect(#slice).to.equal(2) - expect(slice[1]).to.equal(2) - expect(slice[2]).to.equal(3) - end) - - it("should return a slice of the given array with a negative end index", function() - local array = { 1, 2, 3 } - - local slice = Slice(array, 1, -1) - - expect(slice).to.be.a("table") - expect(#slice).to.equal(2) - expect(slice[1]).to.equal(1) - expect(slice[2]).to.equal(2) - end) - - it("should return a slice of the given array with a negative start and end index", function() - local array = { 1, 2, 3 } - - local slice = Slice(array, -2, -1) - - expect(slice).to.be.a("table") - expect(#slice).to.equal(2) - expect(slice[1]).to.equal(1) - expect(slice[2]).to.equal(2) - end) -end diff --git a/src/Array/some.spec.lua b/src/Array/some.spec.lua deleted file mode 100644 index 998aa9b..0000000 --- a/src/Array/some.spec.lua +++ /dev/null @@ -1,23 +0,0 @@ -return function() - local Some = require(script.Parent.some) - - it("should return true if the given predicate returns true for any element", function() - local array = { 1, 2, 3 } - - local result = Some(array, function(value) - return value == 2 - end) - - expect(result).to.equal(true) - end) - - it("should return false if the given predicate returns false for all elements", function() - local array = { 1, 2, 3 } - - local result = Some(array, function(value) - return value == 4 - end) - - expect(result).to.equal(false) - end) -end diff --git a/src/Array/sort.spec.lua b/src/Array/sort.spec.lua deleted file mode 100644 index fe3270b..0000000 --- a/src/Array/sort.spec.lua +++ /dev/null @@ -1,44 +0,0 @@ -return function() - local Sort = require(script.Parent.sort) - - it("should sort the given array", function() - local array = { 1, 2, 3 } - - local new = Sort(array, function(a, b) - return a < b - end) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - expect(new[1]).to.equal(1) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(3) - end) - - it("should sort the given array with a custom compare function", function() - local array = { 1, 2, 3 } - - local new = Sort(array, function(a, b) - return a > b - end) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - expect(new[1]).to.equal(3) - expect(new[2]).to.equal(2) - expect(new[3]).to.equal(1) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Sort(array, function(a, b) - return a > b - end) - - expect(array).to.be.a("table") - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/splice.spec.lua b/src/Array/splice.spec.lua deleted file mode 100644 index 8a5b16b..0000000 --- a/src/Array/splice.spec.lua +++ /dev/null @@ -1,27 +0,0 @@ -return function() - local Splice = require(script.Parent.splice) - - it("should insert the given values into the given array", function() - local array = { 1, 2, 3 } - - local spliced = Splice(array, 2, 0, 4, 5) - - expect(spliced).to.be.a("table") - expect(#spliced).to.equal(3) - expect(spliced[1]).to.equal(1) - expect(spliced[2]).to.equal(4) - expect(spliced[3]).to.equal(5) - end) - - it("should insert the given values into the given array with a negative index", function() - local array = { 1, 2, 3 } - - local spliced = Splice(array, -2, 0, 4, 5) - - expect(spliced).to.be.a("table") - expect(#spliced).to.equal(2) - expect(spliced[1]).to.equal(4) - expect(spliced[2]).to.equal(5) - expect(spliced[3]).never.to.be.ok() - end) -end diff --git a/src/Array/toSet.spec.lua b/src/Array/toSet.spec.lua deleted file mode 100644 index 21b94fc..0000000 --- a/src/Array/toSet.spec.lua +++ /dev/null @@ -1,38 +0,0 @@ -return function() - local ToSet = require(script.Parent.toSet) - - it("should return a set", function() - local array = { 1, 2, 3 } - - local set = ToSet(array) - - expect(set).to.be.a("table") - expect(set[1]).to.equal(true) - expect(set[2]).to.equal(true) - expect(set[3]).to.equal(true) - end) - - it("should return a set of strings", function() - local array = { "a", "b", "b", "c" } - - local set = ToSet(array) - - expect(set).to.be.a("table") - expect(set["a"]).to.equal(true) - expect(set["b"]).to.equal(true) - expect(set["c"]).to.equal(true) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - ToSet(array) - - expect(array).to.be.a("table") - expect(#array).to.equal(3) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/unshift.spec.lua b/src/Array/unshift.spec.lua deleted file mode 100644 index 2a1c267..0000000 --- a/src/Array/unshift.spec.lua +++ /dev/null @@ -1,41 +0,0 @@ -return function() - local Unshift = require(script.Parent.unshift) - - it("should return a new array with the given value at the beginning", function() - local array = { 1, 2, 3 } - - local newArray = Unshift(array, 4) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(4) - - expect(newArray[1]).to.equal(4) - expect(newArray[2]).to.equal(1) - expect(newArray[3]).to.equal(2) - expect(newArray[4]).to.equal(3) - end) - - it("should prepend multiple values to the array", function() - local array = { 1, 2, 3 } - - local newArray = Unshift(array, 4, 5, 6) - - expect(newArray).to.be.a("table") - expect(#newArray).to.equal(6) - - expect(newArray[1]).to.equal(4) - expect(newArray[2]).to.equal(5) - expect(newArray[3]).to.equal(6) - expect(newArray[4]).to.equal(1) - expect(newArray[5]).to.equal(2) - expect(newArray[6]).to.equal(3) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Unshift(array, 4) - - expect(array[1]).to.equal(1) - end) -end diff --git a/src/Array/update.spec.lua b/src/Array/update.spec.lua deleted file mode 100644 index aca907f..0000000 --- a/src/Array/update.spec.lua +++ /dev/null @@ -1,48 +0,0 @@ -return function() - local Update = require(script.Parent.update) - - it("should update the value at the given index", function() - local array = { 1, 2, 3 } - - local result = Update(array, 2, function(value) - return value + 1 - end) - - expect(result).to.be.a("table") - expect(#result).to.equal(3) - - expect(result[1]).to.equal(1) - expect(result[2]).to.equal(3) - expect(result[3]).to.equal(3) - end) - - it("should create values using the callback", function() - local array = { 1, 2, 3 } - - local result = Update(array, 4, function(value) - return value + 1 - end, function() - return 5 - end) - - expect(result).to.be.a("table") - expect(#result).to.equal(4) - - expect(result[1]).to.equal(1) - expect(result[2]).to.equal(2) - expect(result[3]).to.equal(3) - expect(result[4]).to.equal(5) - end) - - it("should not modify the original array", function() - local array = { 1, 2, 3 } - - Update(array, 2, function(value) - return value + 1 - end) - - expect(array[1]).to.equal(1) - expect(array[2]).to.equal(2) - expect(array[3]).to.equal(3) - end) -end diff --git a/src/Array/zip.spec.lua b/src/Array/zip.spec.lua deleted file mode 100644 index a6920e4..0000000 --- a/src/Array/zip.spec.lua +++ /dev/null @@ -1,46 +0,0 @@ -return function() - local Zip = require(script.Parent.zip) - - it("should zip together two arrays", function() - local array1 = { 1, 2, 3 } - local array2 = { "a", "b", "c" } - - local new = Zip(array1, array2) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - - expect(new[1]).to.be.a("table") - expect(new[1][1]).to.equal(1) - expect(new[1][2]).to.equal("a") - - expect(new[2]).to.be.a("table") - expect(new[2][1]).to.equal(2) - expect(new[2][2]).to.equal("b") - - expect(new[3]).to.be.a("table") - expect(new[3][1]).to.equal(3) - expect(new[3][2]).to.equal("c") - end) - - it("should not modify the original arrays", function() - local array1 = { 1, 2, 3 } - local array2 = { "a", "b", "c" } - - Zip(array1, array2) - - expect(array1).to.be.a("table") - expect(#array1).to.equal(3) - - expect(array1[1]).to.equal(1) - expect(array1[2]).to.equal(2) - expect(array1[3]).to.equal(3) - - expect(array2).to.be.a("table") - expect(#array2).to.equal(3) - - expect(array2[1]).to.equal("a") - expect(array2[2]).to.equal("b") - expect(array2[3]).to.equal("c") - end) -end diff --git a/src/Array/zipAll.spec.lua b/src/Array/zipAll.spec.lua deleted file mode 100644 index 7c23d6c..0000000 --- a/src/Array/zipAll.spec.lua +++ /dev/null @@ -1,69 +0,0 @@ -return function() - local None = require(script.Parent.Parent.None) - local ZipAll = require(script.Parent.zipAll) - - it("should zip together two arrays", function() - local array1 = { 1, 2, 3 } - local array2 = { "a", "b", "c" } - - local new = ZipAll(array1, array2) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - - expect(new[1]).to.be.a("table") - expect(new[1][1]).to.equal(1) - expect(new[1][2]).to.equal("a") - - expect(new[2]).to.be.a("table") - expect(new[2][1]).to.equal(2) - expect(new[2][2]).to.equal("b") - - expect(new[3]).to.be.a("table") - expect(new[3][1]).to.equal(3) - expect(new[3][2]).to.equal("c") - end) - - it("should not modify the original arrays", function() - local array1 = { 1, 2, 3 } - local array2 = { "a", "b", "c" } - - ZipAll(array1, array2) - - expect(array1).to.be.a("table") - expect(#array1).to.equal(3) - - expect(array1[1]).to.equal(1) - expect(array1[2]).to.equal(2) - expect(array1[3]).to.equal(3) - - expect(array2).to.be.a("table") - expect(#array2).to.equal(3) - - expect(array2[1]).to.equal("a") - expect(array2[2]).to.equal("b") - expect(array2[3]).to.equal("c") - end) - - it("should fill in the blanks with None", function() - local array1 = { 1, 2, 3 } - local array2 = { "a", "b" } - - local new = ZipAll(array1, array2) - - expect(new).to.be.a("table") - expect(#new).to.equal(3) - - expect(new[1]).to.be.a("table") - expect(new[1][1]).to.equal(1) - expect(new[1][2]).to.equal("a") - - expect(new[2]).to.be.a("table") - expect(new[2][1]).to.equal(2) - expect(new[2][2]).to.equal("b") - - expect(new[3]).to.be.a("table") - expect(new[3][1]).to.equal(3) - expect(new[3][2]).to.equal(None) - end) -end diff --git a/src/Dictionary/copy.spec.lua b/src/Dictionary/copy.spec.lua deleted file mode 100644 index 73f5397..0000000 --- a/src/Dictionary/copy.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local Copy = require(script.Parent.copy) - - it("should return a copy of the given dictionary", function() - local dictionary = { hello = "world" } - - local new = Copy(dictionary) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(new.hello).to.equal("world") - end) - - it("should not copy nested dictionaries", function() - local dictionary = { hello = { world = "goodbye" } } - - local new = Copy(dictionary) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(new.hello).to.equal(dictionary.hello) - end) -end diff --git a/src/Dictionary/copyDeep.spec.lua b/src/Dictionary/copyDeep.spec.lua deleted file mode 100644 index 324d2df..0000000 --- a/src/Dictionary/copyDeep.spec.lua +++ /dev/null @@ -1,52 +0,0 @@ -return function() - local CopyDeep = require(script.Parent.copyDeep) - - it("should return a copy of the given dictionary", function() - local dictionary = { - hello = "world", - } - - local new = CopyDeep(dictionary) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(new.hello).to.equal("world") - end) - - it("should copy nested dictionaries", function() - local dictionary = { - hello = { - world = "goodbye", - }, - } - - local new = CopyDeep(dictionary) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(new.hello).to.be.a("table") - expect(new.hello).never.to.equal(dictionary.hello) - - expect(new.hello.world).to.equal("goodbye") - end) - - it("should copy metatables", function() - local meta = setmetatable({}, { __index = function() end }) - local dictionary = { - hello = {}, - world = {}, - meta = meta, - } - - local new = CopyDeep(dictionary) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(function() - return getmetatable(new[3]) - end).to.be.a("function") - end) -end diff --git a/src/Dictionary/count.spec.lua b/src/Dictionary/count.spec.lua deleted file mode 100644 index c4a0582..0000000 --- a/src/Dictionary/count.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Count = require(script.Parent.count) - - it("should return the number of elements in the given dictionary", function() - local dictionary = { hello = "world", goodbye = "world" } - - local count = Count(dictionary) - - expect(count).to.equal(2) - end) - - it("should return 0 for an empty dictionary", function() - local dictionary = {} - - local count = Count(dictionary) - - expect(count).to.equal(0) - end) - - it("should return the number of elements matching the given predicate", function() - local dictionary = { hello = "world", goodbye = "world" } - - local count = Count(dictionary, function(_, key) - return key == "goodbye" - end) - - expect(count).to.equal(1) - end) -end diff --git a/src/Dictionary/entries.spec.lua b/src/Dictionary/entries.spec.lua deleted file mode 100644 index 4d2cb8d..0000000 --- a/src/Dictionary/entries.spec.lua +++ /dev/null @@ -1,22 +0,0 @@ -return function() - local Entries = require(script.Parent.entries) - - it("should return a list of entries as key-value pairs", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local entries = Entries(dictionary) - - expect(entries).to.be.a("table") - expect(#entries).to.equal(2) - - expect(entries[1]).to.be.a("table") - expect(#entries[1]).to.equal(2) - expect(entries[1][1]).to.equal("hello") - expect(entries[1][2]).to.equal("roblox") - - expect(entries[2]).to.be.a("table") - expect(#entries[2]).to.equal(2) - expect(entries[2][1]).to.equal("goodbye") - expect(entries[2][2]).to.equal("world") - end) -end diff --git a/src/Dictionary/equals.spec.lua b/src/Dictionary/equals.spec.lua deleted file mode 100644 index 57a55ea..0000000 --- a/src/Dictionary/equals.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local Equals = require(script.Parent.equals) - - it("should return true if the dictionaries are equal", function() - local dictionary1 = { hello = "world", goodbye = "world" } - local dictionary2 = { hello = "world", goodbye = "world" } - - expect(Equals(dictionary1, dictionary2)).to.equal(true) - end) - - it("should return false if the dictionaries are not equal", function() - local dictionary1 = { hello = "world", goodbye = "world" } - local dictionary2 = { hello = "world", goodbye = "world2" } - - expect(Equals(dictionary1, dictionary2)).to.equal(false) - end) - - it("should return false for nested dictionaries", function() - --[[ - This is because the nested dictionaries have different memory addresses, - despite having the same values. Use EqualsDeep instead if you want to - compare nested dictionaries. - --]] - local dictionary1 = { hello = "world", goodbye = { world = "hello" } } - local dictionary2 = { hello = "world", goodbye = { world = "hello" } } - - expect(Equals(dictionary1, dictionary2)).to.equal(false) - end) -end diff --git a/src/Dictionary/equalsDeep.spec.lua b/src/Dictionary/equalsDeep.spec.lua deleted file mode 100644 index bbcd256..0000000 --- a/src/Dictionary/equalsDeep.spec.lua +++ /dev/null @@ -1,26 +0,0 @@ -return function() - local EqualsDeep = require(script.Parent.equalsDeep) - - it("should return true if the dictionaries are equal", function() - local dictionary1 = { hello = "world", goodbye = "world" } - local dictionary2 = { hello = "world", goodbye = "world" } - - expect(EqualsDeep(dictionary1, dictionary2)).to.equal(true) - end) - - it("should return false if the dictionaries are not equal", function() - local dictionary1 = { hello = "world", goodbye = "world" } - local dictionary2 = { hello = "world", goodbye = "world2" } - - expect(EqualsDeep(dictionary1, dictionary2)).to.equal(false) - end) - - it("should return true for nested dictionaries", function() - local dictionary1 = { hello = "world", goodbye = { world = "hello" } } - local dictionary2 = { hello = "world", goodbye = { world = "hello" } } - local dictionary3 = { hello = "world", goodbye = { world = "world" } } - - expect(EqualsDeep(dictionary1, dictionary2)).to.equal(true) - expect(EqualsDeep(dictionary1, dictionary3)).to.equal(false) - end) -end diff --git a/src/Dictionary/every.spec.lua b/src/Dictionary/every.spec.lua deleted file mode 100644 index 3717db7..0000000 --- a/src/Dictionary/every.spec.lua +++ /dev/null @@ -1,19 +0,0 @@ -return function() - local Every = require(script.Parent.every) - - it("should return true if all elements match the predicate", function() - local dictionary = { hello = "world", goodbye = "world" } - - expect(Every(dictionary, function(value) - return value == "world" - end)).to.equal(true) - end) - - it("should return false if any elements do not match the predicate", function() - local dictionary = { hello = "world", goodbye = "world" } - - expect(Every(dictionary, function(value) - return value == "hello" - end)).to.equal(false) - end) -end diff --git a/src/Dictionary/filter.spec.lua b/src/Dictionary/filter.spec.lua deleted file mode 100644 index dc9bcf2..0000000 --- a/src/Dictionary/filter.spec.lua +++ /dev/null @@ -1,34 +0,0 @@ -return function() - local Filter = require(script.Parent.filter) - - it( - "should return a copy of the given dictionary with only the elements that match the predicate", - function() - local dictionary = { hello = "world", goodbye = "goodbye" } - - local new = Filter(dictionary, function(value) - return value == "world" - end) - - expect(new).to.be.a("table") - expect(new).never.to.equal(dictionary) - - expect(new.hello).to.equal("world") - end - ) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "world", goodbye = "goodbye" } - - local new = Filter(dictionary, function(value) - return value == "world" - end) - - expect(new).never.to.equal(dictionary) - - expect(dictionary.hello).to.equal("world") - expect(dictionary.goodbye).to.equal("goodbye") - - expect(new.hello).to.equal("world") - end) -end diff --git a/src/Dictionary/flatten.spec.lua b/src/Dictionary/flatten.spec.lua deleted file mode 100644 index 5e896bf..0000000 --- a/src/Dictionary/flatten.spec.lua +++ /dev/null @@ -1,64 +0,0 @@ -return function() - local Flatten = require(script.Parent.flatten) - - it("should return a flattened dictionary", function() - local dictionary = { - hello = "world", - goodbye = { - yes = "no", - no = "yes", - }, - } - - local flattened = Flatten(dictionary) - - expect(flattened).to.be.a("table") - - expect(flattened.hello).to.equal("world") - expect(flattened.yes).to.equal("no") - expect(flattened.no).to.equal("yes") - end) - - it("should not flatten nested dictionaries if depth = 0", function() - local dictionary = { - hello = "world", - goodbye = { - yes = "no", - no = "yes", - }, - } - - local flattened = Flatten(dictionary, 0) - - expect(flattened).to.be.a("table") - - expect(flattened.hello).to.equal("world") - expect(flattened.goodbye).to.equal(dictionary.goodbye) - end) - - it("should flatten as deeply as possible", function() - local dictionary = { - hello = "world", - goodbye = { - yes = "no", - no = "yes", - maybe = { - maybe = "ok", - okay = { - experience = "roblox", - }, - }, - }, - } - - local flattened = Flatten(dictionary) - - expect(flattened).to.be.a("table") - - expect(flattened.hello).to.equal("world") - expect(flattened.yes).to.equal("no") - expect(flattened.no).to.equal("yes") - expect(flattened.maybe).to.equal("ok") - expect(flattened.experience).to.equal("roblox") - end) -end diff --git a/src/Dictionary/flip.spec.lua b/src/Dictionary/flip.spec.lua deleted file mode 100644 index 4015a18..0000000 --- a/src/Dictionary/flip.spec.lua +++ /dev/null @@ -1,14 +0,0 @@ -return function() - local Flip = require(script.Parent.flip) - - it("should return a flipped dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local new = Flip(dictionary) - - expect(new).to.be.a("table") - - expect(new.world).to.equal("goodbye") - expect(new.roblox).to.equal("hello") - end) -end diff --git a/src/Dictionary/freeze.spec.lua b/src/Dictionary/freeze.spec.lua deleted file mode 100644 index 090d1b1..0000000 --- a/src/Dictionary/freeze.spec.lua +++ /dev/null @@ -1,42 +0,0 @@ -return function() - local Freeze = require(script.Parent.freeze) - - it("should return a read-only copy of the given dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local frozen = Freeze(dictionary) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(dictionary) - - expect(frozen.hello).to.equal("roblox") - expect(frozen.goodbye).to.equal("world") - - expect(function() - frozen.hello = "world" - end).to.throw() - end) - - it("should not freeze nested dictionaries", function() - local dictionary = { hello = "roblox", goodbye = { world = "goodbye" } } - - local frozen = Freeze(dictionary) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(dictionary) - - expect(frozen.hello).to.equal("roblox") - expect(frozen.goodbye).to.be.a("table") - expect(frozen.goodbye).to.equal(dictionary.goodbye) - - expect(frozen.goodbye.world).to.equal("goodbye") - - expect(function() - frozen.hello = "world" - end).to.throw() - - expect(function() - frozen.goodbye.world = "hello" - end).never.to.throw() - end) -end diff --git a/src/Dictionary/freezeDeep.spec.lua b/src/Dictionary/freezeDeep.spec.lua deleted file mode 100644 index 699ea4d..0000000 --- a/src/Dictionary/freezeDeep.spec.lua +++ /dev/null @@ -1,43 +0,0 @@ -return function() - local FreezeDeep = require(script.Parent.freezeDeep) - - it("should return a read-only copy of the given dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local frozen = FreezeDeep(dictionary) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(dictionary) - - expect(frozen.hello).to.equal("roblox") - expect(frozen.goodbye).to.equal("world") - - expect(function() - frozen.hello = "world" - end).to.throw() - end) - - it("should freeze nested dictionaries", function() - local dictionary = { hello = "roblox", goodbye = { world = "goodbye" } } - - local frozen = FreezeDeep(dictionary) - - expect(frozen).to.be.a("table") - expect(frozen).never.to.equal(dictionary) - - expect(frozen.hello).to.equal("roblox") - - expect(frozen.goodbye).to.be.a("table") - expect(frozen.goodbye).never.to.equal(dictionary.goodbye) - - expect(frozen.goodbye.world).to.equal("goodbye") - - expect(function() - frozen.hello = "world" - end).to.throw() - - expect(function() - frozen.goodbye.world = "hello" - end).to.throw() - end) -end diff --git a/src/Dictionary/fromArrays.spec.lua b/src/Dictionary/fromArrays.spec.lua deleted file mode 100644 index 0b9530e..0000000 --- a/src/Dictionary/fromArrays.spec.lua +++ /dev/null @@ -1,15 +0,0 @@ -return function() - local FromArrays = require(script.Parent.fromArrays) - - it("should return a dictionary composed of the given keys and values", function() - local keys = { "hello", "goodbye" } - local values = { "roblox", "world" } - - local dictionary = FromArrays(keys, values) - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox") - expect(dictionary.goodbye).to.equal("world") - end) -end diff --git a/src/Dictionary/fromEntries.spec.lua b/src/Dictionary/fromEntries.spec.lua deleted file mode 100644 index a3975de..0000000 --- a/src/Dictionary/fromEntries.spec.lua +++ /dev/null @@ -1,14 +0,0 @@ -return function() - local FromEntries = require(script.Parent.fromEntries) - - it("should create a new dictionary from the given key-value pairs", function() - local entries = { { "hello", "roblox" }, { "goodbye", "world" } } - - local dictionary = FromEntries(entries) - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox") - expect(dictionary.goodbye).to.equal("world") - end) -end diff --git a/src/Dictionary/has.spec.lua b/src/Dictionary/has.spec.lua deleted file mode 100644 index 93a8bf9..0000000 --- a/src/Dictionary/has.spec.lua +++ /dev/null @@ -1,19 +0,0 @@ -return function() - local Has = require(script.Parent.has) - - it("should return true if the dictionary has the given key", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local hasHello = Has(dictionary, "hello") - - expect(hasHello).to.equal(true) - end) - - it("should return false if the dictionary does not have the given key", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local hasCat = Has(dictionary, "cat") - - expect(hasCat).to.equal(false) - end) -end diff --git a/src/Dictionary/includes.spec.lua b/src/Dictionary/includes.spec.lua deleted file mode 100644 index 64b8acf..0000000 --- a/src/Dictionary/includes.spec.lua +++ /dev/null @@ -1,19 +0,0 @@ -return function() - local Includes = require(script.Parent.includes) - - it("should return true if the dictionary includes the given value", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local includesRoblox = Includes(dictionary, "roblox") - - expect(includesRoblox).to.equal(true) - end) - - it("should return false if the dictionary does not include the given value", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local includesCat = Includes(dictionary, "cat") - - expect(includesCat).to.equal(false) - end) -end diff --git a/src/Dictionary/keys.spec.lua b/src/Dictionary/keys.spec.lua deleted file mode 100644 index 876458a..0000000 --- a/src/Dictionary/keys.spec.lua +++ /dev/null @@ -1,15 +0,0 @@ -return function() - local Keys = require(script.Parent.keys) - - it("should return an array of the keys in the dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local keys = Keys(dictionary) - - expect(keys).to.be.a("table") - expect(#keys).to.equal(2) - - expect(keys[1]).to.equal("hello") - expect(keys[2]).to.equal("goodbye") - end) -end diff --git a/src/Dictionary/map.spec.lua b/src/Dictionary/map.spec.lua deleted file mode 100644 index 903be9b..0000000 --- a/src/Dictionary/map.spec.lua +++ /dev/null @@ -1,27 +0,0 @@ -return function() - local Map = require(script.Parent.map) - - it("should return a dictionary where entries are the result of the mapper function", function() - local dictionary = Map({ hello = "roblox", goodbye = "world" }, function(value) - return value .. "!" - end) - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox!") - expect(dictionary.goodbye).to.equal("world!") - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - Map(dictionary, function(value) - return value .. "!" - end) - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox") - expect(dictionary.goodbye).to.equal("world") - end) -end diff --git a/src/Dictionary/merge.spec.lua b/src/Dictionary/merge.spec.lua deleted file mode 100644 index ad727b6..0000000 --- a/src/Dictionary/merge.spec.lua +++ /dev/null @@ -1,61 +0,0 @@ -return function() - local Merge = require(script.Parent.merge) - local None = require(script.Parent.Parent.None) - - it( - "should combine two or more dictionaries, where the last value overrides previous", - function() - local dictionary1 = { hello = "roblox", goodbye = "world" } - local dictionary2 = { hello = "hello" } - - local merged = Merge(dictionary1, dictionary2) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("hello") - expect(merged.goodbye).to.equal("world") - end - ) - - it("should not modify the original dictionaries", function() - local dictionary1 = { hello = "roblox", goodbye = "world" } - local dictionary2 = { hello = "hello" } - - Merge(dictionary1, dictionary2) - - expect(dictionary1).to.be.a("table") - expect(dictionary2).to.be.a("table") - - expect(dictionary1.hello).to.equal("roblox") - expect(dictionary2.hello).to.equal("hello") - end) - - it("should accept nil values", function() - local dictionary1 = { hello = "roblox", goodbye = "world" } - - local merged = Merge(dictionary1, nil) - local merged2 = Merge(nil, dictionary1) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("roblox") - expect(merged.goodbye).to.equal("world") - - expect(merged2).to.be.a("table") - - expect(merged2.hello).to.equal("roblox") - expect(merged2.goodbye).to.equal("world") - end) - - it("should remove values set to None", function() - local dictionary1 = { hello = "roblox", goodbye = "world" } - local dictionary2 = { goodbye = None } - - local merged = Merge(dictionary1, dictionary2) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("roblox") - expect(merged.goodbye).to.equal(nil) - end) -end diff --git a/src/Dictionary/mergeDeep.spec.lua b/src/Dictionary/mergeDeep.spec.lua deleted file mode 100644 index 526149f..0000000 --- a/src/Dictionary/mergeDeep.spec.lua +++ /dev/null @@ -1,61 +0,0 @@ -return function() - local MergeDeep = require(script.Parent.mergeDeep) - local None = require(script.Parent.Parent.None) - - it( - "should combine two or more dictionaries, where the last value overrides previous, recursively", - function() - local dictionary1 = { hello = "roblox", goodbye = { world = "world" } } - local dictionary2 = { goodbye = { world = "hello" } } - - local merged = MergeDeep(dictionary1, dictionary2) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("roblox") - expect(merged.goodbye.world).to.equal("hello") - end - ) - - it("should not modify the original dictionaries", function() - local dictionary1 = { hello = "roblox", goodbye = { world = "world" } } - local dictionary2 = { goodbye = { world = "hello" } } - - MergeDeep(dictionary1, dictionary2) - - expect(dictionary1).to.be.a("table") - expect(dictionary2).to.be.a("table") - - expect(dictionary1.hello).to.equal("roblox") - expect(dictionary1.goodbye.world).to.equal("world") - end) - - it("should accept nil values", function() - local dictionary1 = { hello = "roblox", goodbye = { world = "world" } } - - local merged = MergeDeep(dictionary1, nil) - local merged2 = MergeDeep(nil, dictionary1) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("roblox") - expect(merged.goodbye.world).to.equal("world") - - expect(merged2).to.be.a("table") - - expect(merged2.hello).to.equal("roblox") - expect(merged2.goodbye.world).to.equal("world") - end) - - it("should remove values set to None", function() - local dictionary1 = { hello = "roblox", goodbye = { world = "world" } } - local dictionary2 = { goodbye = None } - - local merged = MergeDeep(dictionary1, dictionary2) - - expect(merged).to.be.a("table") - - expect(merged.hello).to.equal("roblox") - expect(merged.goodbye).to.equal(nil) - end) -end diff --git a/src/Dictionary/removeKey.spec.lua b/src/Dictionary/removeKey.spec.lua deleted file mode 100644 index 302d33f..0000000 --- a/src/Dictionary/removeKey.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local RemoveKey = require(script.Parent.removeKey) - - it("should return a new dictionary with the given key removed", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local newDictionary = RemoveKey(dictionary, "goodbye") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal("roblox") - expect(newDictionary.goodbye).to.equal(nil) - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - RemoveKey(dictionary, "goodbye") - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox") - expect(dictionary.goodbye).to.equal("world") - end) -end diff --git a/src/Dictionary/removeKeys.spec.lua b/src/Dictionary/removeKeys.spec.lua deleted file mode 100644 index d0ec246..0000000 --- a/src/Dictionary/removeKeys.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local RemoveKeys = require(script.Parent.removeKeys) - - it("should return a new dictionary with the given keys removed", function() - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - local newDictionary = RemoveKeys(dictionary, "cat", "dog") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal("world") - expect(newDictionary.cat).to.equal(nil) - expect(newDictionary.dog).to.equal(nil) - expect(newDictionary.unicorn).to.equal("rainbow") - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - RemoveKeys(dictionary, "cat", "dog") - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("world") - expect(dictionary.cat).to.equal("meow") - expect(dictionary.dog).to.equal("woof") - expect(dictionary.unicorn).to.equal("rainbow") - end) -end diff --git a/src/Dictionary/removeValue.spec.lua b/src/Dictionary/removeValue.spec.lua deleted file mode 100644 index 2c6b533..0000000 --- a/src/Dictionary/removeValue.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local RemoveValue = require(script.Parent.removeValue) - - it("should return a new dictionary with the given value removed", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local newDictionary = RemoveValue(dictionary, "world") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal("roblox") - expect(newDictionary.goodbye).to.equal(nil) - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - RemoveValue(dictionary, "world") - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("roblox") - expect(dictionary.goodbye).to.equal("world") - end) -end diff --git a/src/Dictionary/removeValues.spec.lua b/src/Dictionary/removeValues.spec.lua deleted file mode 100644 index 31588d5..0000000 --- a/src/Dictionary/removeValues.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local RemoveValues = require(script.Parent.removeValues) - - it("should return a new dictionary with the given values removed", function() - local dictionary = { hello = "world", goodbye = "world", cat = "meow", dog = "woof" } - - local newDictionary = RemoveValues(dictionary, "world") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal(nil) - expect(newDictionary.goodbye).to.equal(nil) - expect(newDictionary.cat).to.equal("meow") - expect(newDictionary.dog).to.equal("woof") - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "world", goodbye = "world", cat = "meow", dog = "woof" } - - RemoveValues(dictionary, "world") - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("world") - expect(dictionary.goodbye).to.equal("world") - expect(dictionary.cat).to.equal("meow") - expect(dictionary.dog).to.equal("woof") - end) -end diff --git a/src/Dictionary/set.spec.lua b/src/Dictionary/set.spec.lua deleted file mode 100644 index 934f9d4..0000000 --- a/src/Dictionary/set.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local Set = require(script.Parent.set) - - it("should return a new dictionary with the given key/value set", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local newDictionary = Set(dictionary, "cat", "meow") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal("roblox") - expect(newDictionary.goodbye).to.equal("world") - expect(newDictionary.cat).to.equal("meow") - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - Set(dictionary, "cat", "woof") - - expect(dictionary).to.be.a("table") - - expect(dictionary.cat).to.equal(nil) - end) -end diff --git a/src/Dictionary/some.spec.lua b/src/Dictionary/some.spec.lua deleted file mode 100644 index a784196..0000000 --- a/src/Dictionary/some.spec.lua +++ /dev/null @@ -1,23 +0,0 @@ -return function() - local Some = require(script.Parent.some) - - it("should return true if the predicate returns true for any of the values", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local result = Some(dictionary, function(value) - return value == "roblox" - end) - - expect(result).to.equal(true) - end) - - it("should return false if the predicate returns false for all of the values", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local result = Some(dictionary, function(value) - return value == "hello" - end) - - expect(result).to.equal(false) - end) -end diff --git a/src/Dictionary/update.spec.lua b/src/Dictionary/update.spec.lua deleted file mode 100644 index 35ca048..0000000 --- a/src/Dictionary/update.spec.lua +++ /dev/null @@ -1,57 +0,0 @@ -return function() - local Update = require(script.Parent.update) - - it("should return a new dictionary with the given key updated", function() - local dictionary = { cats = 2 } - - local new = Update(dictionary, "cats", function(value) - return value + 1 - end) - - expect(new).to.be.a("table") - - expect(new.cats).to.equal(3) - end) - - it("should not modify the original dictionary", function() - local dictionary = { cats = 2 } - - Update(dictionary, "cats", function(value) - return value + 1 - end) - - Update(dictionary, "dogs", nil, function() - return 1 - end) - - expect(dictionary).to.be.a("table") - - expect(dictionary.cats).to.equal(2) - expect(dictionary.dogs).to.equal(nil) - end) - - it("should create the key if it does not exist", function() - local dictionary = { cats = 2 } - - local new = Update(dictionary, "dogs", function(value) - return value + 1 - end, function() - return 1 - end) - - expect(new).to.be.a("table") - - expect(new.cats).to.equal(2) - expect(new.dogs).to.equal(1) - end) - - it("should not create a key if it doesn't exist and no callback is specified", function() - local dictionary = { cats = 2 } - - local new = Update(dictionary, "dogs", function() - return 1 - end) - - expect(new.dogs).to.equal(nil) - end) -end diff --git a/src/Dictionary/values.spec.lua b/src/Dictionary/values.spec.lua deleted file mode 100644 index 5891ddf..0000000 --- a/src/Dictionary/values.spec.lua +++ /dev/null @@ -1,15 +0,0 @@ -return function() - local Values = require(script.Parent.values) - - it("should return a list of the values in the dictionary", function() - local dictionary = { hello = "roblox", goodbye = "world" } - - local values = Values(dictionary) - - expect(values).to.be.a("table") - expect(#values).to.equal(2) - - expect(values[1]).to.equal("roblox") - expect(values[2]).to.equal("world") - end) -end diff --git a/src/Dictionary/withKeys.spec.lua b/src/Dictionary/withKeys.spec.lua deleted file mode 100644 index 623b660..0000000 --- a/src/Dictionary/withKeys.spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -return function() - local WithKeys = require(script.Parent.withKeys) - - it("should return a new dictionary with the given keys kept", function() - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - local newDictionary = WithKeys(dictionary, "cat", "dog") - - expect(newDictionary).to.be.a("table") - - expect(newDictionary.hello).to.equal(nil) - expect(newDictionary.cat).to.equal("meow") - expect(newDictionary.dog).to.equal("woof") - expect(newDictionary.unicorn).to.equal(nil) - end) - - it("should not modify the original dictionary", function() - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - WithKeys(dictionary, "cat", "dog") - - expect(dictionary).to.be.a("table") - - expect(dictionary.hello).to.equal("world") - expect(dictionary.cat).to.equal("meow") - expect(dictionary.dog).to.equal("woof") - expect(dictionary.unicorn).to.equal("rainbow") - end) -end diff --git a/src/Set/add.spec.lua b/src/Set/add.spec.lua deleted file mode 100644 index 09ac8b3..0000000 --- a/src/Set/add.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local add = require(script.Parent.add) - - it("should add values to a set", function() - local set = { hello = true } - - local newSet = add(set, "world") - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(true) - expect(newSet.world).to.equal(true) - end) - - it("should not modify the original set", function() - local set = { hello = true } - - add(set, "world") - - expect(set).to.be.a("table") - - expect(set.hello).to.equal(true) - expect(set.world).to.equal(nil) - end) -end diff --git a/src/Set/copy.spec.lua b/src/Set/copy.spec.lua deleted file mode 100644 index 21e9dd0..0000000 --- a/src/Set/copy.spec.lua +++ /dev/null @@ -1,14 +0,0 @@ -return function() - local copy = require(script.Parent.copy) - - it("should copy a set", function() - local set = { hello = true } - - local newSet = copy(set) - - expect(newSet).to.be.a("table") - expect(newSet).never.to.equal(set) - - expect(newSet.hello).to.equal(true) - end) -end diff --git a/src/Set/count.spec.lua b/src/Set/count.spec.lua deleted file mode 100644 index 14b5638..0000000 --- a/src/Set/count.spec.lua +++ /dev/null @@ -1,17 +0,0 @@ -return function() - local count = require(script.Parent.count) - - it("should count the number of values in a set", function() - local set = { hello = true, world = true } - - expect(count(set)).to.equal(2) - end) - - it("should count the number of values in a set matching the predicate", function() - local set = { hello = true, world = true } - - expect(count(set, function(value) - return value == "hello" - end)).to.equal(1) - end) -end diff --git a/src/Set/delete.spec.lua b/src/Set/delete.spec.lua deleted file mode 100644 index 3ebb89d..0000000 --- a/src/Set/delete.spec.lua +++ /dev/null @@ -1,23 +0,0 @@ -return function() - local delete = require(script.Parent.delete) - - it("should delete a value from a set", function() - local set = { hello = true } - - local newSet = delete(set, "hello") - - expect(newSet).to.be.a("table") - expect(newSet).never.to.equal(set) - - expect(newSet.hello).to.equal(nil) - end) - - it("should not modify the original set", function() - local set = { hello = true } - - delete(set, "hello") - - expect(set).to.be.a("table") - expect(set.hello).to.equal(true) - end) -end diff --git a/src/Set/difference.spec.lua b/src/Set/difference.spec.lua deleted file mode 100644 index eba8c07..0000000 --- a/src/Set/difference.spec.lua +++ /dev/null @@ -1,43 +0,0 @@ -return function() - local difference = require(script.Parent.difference) - - it("should return the difference between two sets", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = difference(set, otherSet) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(true) - expect(newSet.world).to.equal(true) - expect(newSet.panda).to.equal(nil) - expect(newSet.cat).to.equal(nil) - end) - - it("should accept vararg nil values", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = difference(set, nil, otherSet) - - expect(newSet).to.be.a("table") - expect(newSet.hello).to.equal(true) - expect(newSet.panda).to.equal(nil) - end) - - it("should accept multiple sets", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - local anotherSet = { hello = true, panda = true } - - local newSet = difference(set, otherSet, anotherSet) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(nil) - expect(newSet.world).to.equal(true) - expect(newSet.panda).to.equal(nil) - expect(newSet.cat).to.equal(nil) - end) -end diff --git a/src/Set/differenceSymmetric.spec.lua b/src/Set/differenceSymmetric.spec.lua deleted file mode 100644 index 54a78d8..0000000 --- a/src/Set/differenceSymmetric.spec.lua +++ /dev/null @@ -1,43 +0,0 @@ -return function() - local differenceSymmetric = require(script.Parent.differenceSymmetric) - - it("should return the symmetric difference between two sets", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = differenceSymmetric(set, otherSet) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(true) - expect(newSet.world).to.equal(true) - expect(newSet.panda).to.equal(true) - expect(newSet.cat).to.equal(true) - end) - - it("should accept vararg nil values", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = differenceSymmetric(set, nil, otherSet) - - expect(newSet).to.be.a("table") - expect(newSet.hello).to.equal(true) - expect(newSet.panda).to.equal(true) - end) - - it("should accept multiple sets", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - local anotherSet = { hello = true, panda = true } - - local newSet = differenceSymmetric(set, otherSet, anotherSet) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(nil) - expect(newSet.world).to.equal(true) - expect(newSet.panda).to.equal(nil) - expect(newSet.cat).to.equal(true) - end) -end diff --git a/src/Set/filter.spec.lua b/src/Set/filter.spec.lua deleted file mode 100644 index 6e76422..0000000 --- a/src/Set/filter.spec.lua +++ /dev/null @@ -1,28 +0,0 @@ -return function() - local filter = require(script.Parent.filter) - - it("should filter a set", function() - local set = { hello = true, world = true } - - local newSet = filter(set, function(value) - return value ~= "hello" - end) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(nil) - expect(newSet.world).to.equal(true) - end) - - it("should not modify the original set", function() - local set = { hello = true } - - filter(set, function(value) - return value ~= "hello" - end) - - expect(set).to.be.a("table") - - expect(set.hello).to.equal(true) - end) -end diff --git a/src/Set/fromArray.spec.lua b/src/Set/fromArray.spec.lua deleted file mode 100644 index 2dbc287..0000000 --- a/src/Set/fromArray.spec.lua +++ /dev/null @@ -1,12 +0,0 @@ -return function() - local fromArray = require(script.Parent.fromArray) - - it("should create a set from an array", function() - local set = fromArray({ "hello", "world" }) - - expect(set).to.be.a("table") - - expect(set.hello).to.equal(true) - expect(set.world).to.equal(true) - end) -end diff --git a/src/Set/has.spec.lua b/src/Set/has.spec.lua deleted file mode 100644 index 9023e63..0000000 --- a/src/Set/has.spec.lua +++ /dev/null @@ -1,10 +0,0 @@ -return function() - local has = require(script.Parent.has) - - it("should check if a value is in a set", function() - local set = { hello = true } - - expect(has(set, "hello")).to.equal(true) - expect(has(set, "world")).to.equal(false) - end) -end diff --git a/src/Set/intersection.spec.lua b/src/Set/intersection.spec.lua deleted file mode 100644 index 2f23cfb..0000000 --- a/src/Set/intersection.spec.lua +++ /dev/null @@ -1,16 +0,0 @@ -return function() - local intersection = require(script.Parent.intersection) - - it("should return the intersection of two sets", function() - local set1 = { hello = true, world = true } - local set2 = { world = true, cat = true } - - local newSet = intersection(set1, set2) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(nil) - expect(newSet.world).to.equal(true) - expect(newSet.cat).to.equal(nil) - end) -end diff --git a/src/Set/isSubset.spec.lua b/src/Set/isSubset.spec.lua deleted file mode 100644 index 78d541f..0000000 --- a/src/Set/isSubset.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local isSubset = require(script.Parent.isSubset) - - it("should check if a set is a subset of another set", function() - local set = { hello = true, world = true } - local otherSet = { hello = true } - - expect(isSubset(otherSet, set)).to.equal(true) - expect(isSubset(set, otherSet)).to.equal(false) - end) -end diff --git a/src/Set/isSuperset.spec.lua b/src/Set/isSuperset.spec.lua deleted file mode 100644 index da25d55..0000000 --- a/src/Set/isSuperset.spec.lua +++ /dev/null @@ -1,11 +0,0 @@ -return function() - local isSuperset = require(script.Parent.isSuperset) - - it("should check if a set is a superset of another set", function() - local set = { hello = true, world = true } - local otherSet = { hello = true } - - expect(isSuperset(set, otherSet)).to.equal(true) - expect(isSuperset(otherSet, set)).to.equal(false) - end) -end diff --git a/src/Set/map.spec.lua b/src/Set/map.spec.lua deleted file mode 100644 index 04e9c14..0000000 --- a/src/Set/map.spec.lua +++ /dev/null @@ -1,32 +0,0 @@ -return function() - local map = require(script.Parent.map) - - it("should map a set", function() - local set = { hello = true, world = true } - - local newSet = map(set, function(value) - return value .. "!" - end) - - expect(newSet).to.be.a("table") - expect(newSet).never.to.equal(set) - - expect(newSet.hello).to.equal(nil) - expect(newSet.world).to.equal(nil) - - expect(newSet["hello!"]).to.equal(true) - expect(newSet["world!"]).to.equal(true) - end) - - it("should not modify the original set", function() - local set = { hello = true } - - map(set, function(value) - return value .. "!" - end) - - expect(set).to.be.a("table") - - expect(set.hello).to.equal(true) - end) -end diff --git a/src/Set/merge.spec.lua b/src/Set/merge.spec.lua deleted file mode 100644 index 2f39f28..0000000 --- a/src/Set/merge.spec.lua +++ /dev/null @@ -1,33 +0,0 @@ -return function() - local merge = require(script.Parent.merge) - - it("should merge two sets", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = merge(set, otherSet) - - expect(newSet).to.be.a("table") - - expect(newSet.hello).to.equal(true) - expect(newSet.world).to.equal(true) - expect(newSet.panda).to.equal(true) - expect(newSet.cat).to.equal(true) - end) - - it("should accept nil values", function() - local set = { hello = true, world = true } - local otherSet = { panda = true, cat = true } - - local newSet = merge(set, nil, otherSet) - local newSet2 = merge(nil, set, otherSet) - - expect(newSet).to.be.a("table") - expect(newSet.hello).to.equal(true) - expect(newSet.panda).to.equal(true) - - expect(newSet2).to.be.a("table") - expect(newSet2.cat).to.equal(true) - expect(newSet2.world).to.equal(true) - end) -end diff --git a/src/Set/toArray.spec.lua b/src/Set/toArray.spec.lua deleted file mode 100644 index ee2e46b..0000000 --- a/src/Set/toArray.spec.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local toArray = require(script.Parent.toArray) - - it("should convert a set to an array", function() - local set = { hello = true, world = true } - - local array = toArray(set) - - expect(array).to.be.a("table") - expect(array).never.to.equal(set) - - expect(array[1]).to.equal("hello") - expect(array[2]).to.equal("world") - end) - - it("should not modify the original set", function() - local set = { hello = true } - - toArray(set) - - expect(set).to.be.a("table") - - expect(set.hello).to.equal(true) - end) -end diff --git a/src/init.lua b/src/init.lua index 1b5c4f0..0882756 100644 --- a/src/init.lua +++ b/src/init.lua @@ -29,6 +29,8 @@ local Sift = { equalObjects = require(script.Util.equalObjects), isEmpty = require(script.Util.isEmpty), + + meta = require(script.Metadata), } Sift.List = Sift.Array diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..0fa95b6 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,4 @@ +column_width = 96 + +[sort_requires] +enabled = true diff --git a/wally.lock b/wally.lock index e504397..bd4c484 100644 --- a/wally.lock +++ b/wally.lock @@ -4,5 +4,240 @@ registry = "test" [[package]] name = "csqrl/sift" -version = "0.0.1" +version = "0.0.9" +dependencies = [["Jest", "jsdotlua/jest@3.6.1-rc.2"], ["JestGlobals", "jsdotlua/jest-globals@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/boolean" +version = "1.2.6" +dependencies = [["number", "jsdotlua/number@1.2.6"]] + +[[package]] +name = "jsdotlua/chalk" +version = "0.2.1" +dependencies = [] + +[[package]] +name = "jsdotlua/collections" +version = "1.2.6" +dependencies = [["es7-types", "jsdotlua/es7-types@1.2.6"], ["instance-of", "jsdotlua/instance-of@1.2.6"]] + +[[package]] +name = "jsdotlua/console" +version = "1.2.6" +dependencies = [["collections", "jsdotlua/collections@1.2.6"]] + +[[package]] +name = "jsdotlua/diff-sequences" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/emittery" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/es7-types" +version = "1.2.6" +dependencies = [] + +[[package]] +name = "jsdotlua/expect" +version = "3.6.1-rc.2" +dependencies = [["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-matcher-utils", "jsdotlua/jest-matcher-utils@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-snapshot", "jsdotlua/jest-snapshot@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/instance-of" +version = "1.2.6" dependencies = [] + +[[package]] +name = "jsdotlua/jest" +version = "3.6.1-rc.2" +dependencies = [["jest-core", "jsdotlua/jest-core@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-circus" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["expect", "jsdotlua/expect@3.6.1-rc.2"], ["jest-each", "jsdotlua/jest-each@3.6.1-rc.2"], ["jest-environment", "jsdotlua/jest-environment@3.6.1-rc.2"], ["jest-matcher-utils", "jsdotlua/jest-matcher-utils@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-runtime", "jsdotlua/jest-runtime@3.6.1-rc.2"], ["jest-snapshot", "jsdotlua/jest-snapshot@3.6.1-rc.2"], ["jest-test-result", "jsdotlua/jest-test-result@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"], ["promise", "jsdotlua/promise@3.5.2"], ["throat", "jsdotlua/throat@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-config" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-each", "jsdotlua/jest-each@3.6.1-rc.2"], ["jest-environment-roblox", "jsdotlua/jest-environment-roblox@3.6.1-rc.2"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["jest-validate", "jsdotlua/jest-validate@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-console" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-each", "jsdotlua/jest-each@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-core" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["emittery", "jsdotlua/emittery@3.6.1-rc.2"], ["jest-config", "jsdotlua/jest-config@3.6.1-rc.2"], ["jest-console", "jsdotlua/jest-console@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-reporters", "jsdotlua/jest-reporters@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-runner", "jsdotlua/jest-runner@3.6.1-rc.2"], ["jest-runtime", "jsdotlua/jest-runtime@3.6.1-rc.2"], ["jest-snapshot", "jsdotlua/jest-snapshot@3.6.1-rc.2"], ["jest-test-result", "jsdotlua/jest-test-result@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-diff" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["diff-sequences", "jsdotlua/diff-sequences@3.6.1-rc.2"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-each" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-environment" +version = "3.6.1-rc.2" +dependencies = [["jest-fake-timers", "jsdotlua/jest-fake-timers@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-environment-roblox" +version = "3.6.1-rc.2" +dependencies = [["jest-environment", "jsdotlua/jest-environment@3.6.1-rc.2"], ["jest-fake-timers", "jsdotlua/jest-fake-timers@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-fake-timers" +version = "3.6.1-rc.2" +dependencies = [["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-get-type" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"]] + +[[package]] +name = "jsdotlua/jest-globals" +version = "3.6.1-rc.2" +dependencies = [["expect", "jsdotlua/expect@3.6.1-rc.2"], ["jest-environment", "jsdotlua/jest-environment@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-matcher-utils" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-diff", "jsdotlua/jest-diff@3.6.1-rc.2"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-message-util" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-mock" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-reporters" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-console", "jsdotlua/jest-console@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-test-result", "jsdotlua/jest-test-result@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["path", "jsdotlua/path@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-roblox-shared" +version = "3.6.1-rc.2" +dependencies = [["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-runner" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["emittery", "jsdotlua/emittery@3.6.1-rc.2"], ["jest-circus", "jsdotlua/jest-circus@3.6.1-rc.2"], ["jest-console", "jsdotlua/jest-console@3.6.1-rc.2"], ["jest-environment", "jsdotlua/jest-environment@3.6.1-rc.2"], ["jest-message-util", "jsdotlua/jest-message-util@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-runtime", "jsdotlua/jest-runtime@3.6.1-rc.2"], ["jest-test-result", "jsdotlua/jest-test-result@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["jest-util", "jsdotlua/jest-util@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"], ["promise", "jsdotlua/promise@3.5.2"], ["throat", "jsdotlua/throat@3.6.1-rc.2"]] + +[[package]] +name = "jsdotlua/jest-runtime" +version = "3.6.1-rc.2" +dependencies = [["emittery", "jsdotlua/emittery@3.6.1-rc.2"], ["expect", "jsdotlua/expect@3.6.1-rc.2"], ["jest-fake-timers", "jsdotlua/jest-fake-timers@3.6.1-rc.2"], ["jest-mock", "jsdotlua/jest-mock@3.6.1-rc.2"], ["jest-snapshot", "jsdotlua/jest-snapshot@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-snapshot" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-diff", "jsdotlua/jest-diff@3.6.1-rc.2"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-matcher-utils", "jsdotlua/jest-matcher-utils@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["pretty-format", "jsdotlua/pretty-format@3.6.1-rc.2"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-test-result" +version = "3.6.1-rc.2" +dependencies = [["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/jest-types" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"]] + +[[package]] +name = "jsdotlua/jest-util" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["jest-types", "jsdotlua/jest-types@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["picomatch", "jsdotlua/picomatch@0.4.0"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/jest-validate" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/luau-polyfill" +version = "1.2.6" +dependencies = [["boolean", "jsdotlua/boolean@1.2.6"], ["collections", "jsdotlua/collections@1.2.6"], ["console", "jsdotlua/console@1.2.6"], ["es7-types", "jsdotlua/es7-types@1.2.6"], ["instance-of", "jsdotlua/instance-of@1.2.6"], ["math", "jsdotlua/math@1.2.6"], ["number", "jsdotlua/number@1.2.6"], ["string", "jsdotlua/string@1.2.6"], ["symbol-luau", "jsdotlua/symbol-luau@1.0.1"], ["timers", "jsdotlua/timers@1.2.6"]] + +[[package]] +name = "jsdotlua/luau-regexp" +version = "0.2.1" +dependencies = [] + +[[package]] +name = "jsdotlua/math" +version = "1.2.6" +dependencies = [] + +[[package]] +name = "jsdotlua/number" +version = "1.2.6" +dependencies = [] + +[[package]] +name = "jsdotlua/path" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/picomatch" +version = "0.4.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/pretty-format" +version = "3.6.1-rc.2" +dependencies = [["chalk", "jsdotlua/chalk@0.2.1"], ["jest-get-type", "jsdotlua/jest-get-type@3.6.1-rc.2"], ["jest-roblox-shared", "jsdotlua/jest-roblox-shared@3.6.1-rc.2"], ["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["luau-regexp", "jsdotlua/luau-regexp@0.2.1"], ["react-is", "jsdotlua/react-is@17.1.0"]] + +[[package]] +name = "jsdotlua/promise" +version = "3.5.2" +dependencies = [] + +[[package]] +name = "jsdotlua/react-is" +version = "17.1.0" +dependencies = [["shared", "jsdotlua/shared@17.1.0"]] + +[[package]] +name = "jsdotlua/shared" +version = "17.1.0" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"]] + +[[package]] +name = "jsdotlua/string" +version = "1.2.6" +dependencies = [["es7-types", "jsdotlua/es7-types@1.2.6"], ["number", "jsdotlua/number@1.2.6"]] + +[[package]] +name = "jsdotlua/symbol-luau" +version = "1.0.1" +dependencies = [] + +[[package]] +name = "jsdotlua/throat" +version = "3.6.1-rc.2" +dependencies = [["luau-polyfill", "jsdotlua/luau-polyfill@1.2.6"], ["promise", "jsdotlua/promise@3.5.2"]] + +[[package]] +name = "jsdotlua/timers" +version = "1.2.6" +dependencies = [["collections", "jsdotlua/collections@1.2.6"]] diff --git a/wally.toml b/wally.toml index dd436fc..1ccbfd2 100644 --- a/wally.toml +++ b/wally.toml @@ -1,12 +1,12 @@ [package] name = "csqrl/sift" description = "Immutable data library for Luau" -version = "0.0.8" -license = "MIT" -author = "csqrl (https://csqrl.dev)" +version = "0.0.9" registry = "https://github.com/upliftgames/wally-index" -homepage = "https://csqrl.github.io/sift" -repo = "https://github.com/csqrl/sift" realm = "shared" exclude = ["**"] include = ["src", "src/**", "wally.toml", "wally.lock", "default.project.json"] + +[dev-dependencies] +Jest = "jsdotlua/jest@3.6.1-rc.2" +JestGlobals = "jsdotlua/jest-globals@3.6.1-rc.2" From 87738d219441a4867667f30dc2180e2e42e7580f Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:10:26 +0000 Subject: [PATCH 03/43] Move TS to `@types/...` --- {src => @types}/Array.d.ts | 0 {src => @types}/Dictionary.d.ts | 0 {src => @types}/Set.d.ts | 0 {src => @types}/Util.d.ts | 0 {src => @types}/index.d.ts | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {src => @types}/Array.d.ts (100%) rename {src => @types}/Dictionary.d.ts (100%) rename {src => @types}/Set.d.ts (100%) rename {src => @types}/Util.d.ts (100%) rename {src => @types}/index.d.ts (100%) diff --git a/src/Array.d.ts b/@types/Array.d.ts similarity index 100% rename from src/Array.d.ts rename to @types/Array.d.ts diff --git a/src/Dictionary.d.ts b/@types/Dictionary.d.ts similarity index 100% rename from src/Dictionary.d.ts rename to @types/Dictionary.d.ts diff --git a/src/Set.d.ts b/@types/Set.d.ts similarity index 100% rename from src/Set.d.ts rename to @types/Set.d.ts diff --git a/src/Util.d.ts b/@types/Util.d.ts similarity index 100% rename from src/Util.d.ts rename to @types/Util.d.ts diff --git a/src/index.d.ts b/@types/index.d.ts similarity index 100% rename from src/index.d.ts rename to @types/index.d.ts From 02c8cea2eb7d5efcfc9f6dfc935094ce5c94d765 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:53:35 +0000 Subject: [PATCH 04/43] Convert *.lua to *.luau --- .vscode/settings.json | 4 ++++ TestRunner.server.lua | 8 -------- default.project.json | 5 +---- selene.toml | 2 +- serve.project.json | 12 ------------ sourcemap.json | 2 +- src/Array/{at.lua => at.luau} | 0 src/Array/{concat.lua => concat.luau} | 0 src/Array/{concatDeep.lua => concatDeep.luau} | 0 src/Array/{copy.lua => copy.luau} | 0 src/Array/{copyDeep.lua => copyDeep.luau} | 0 src/Array/{count.lua => count.luau} | 0 src/Array/{create.lua => create.luau} | 0 src/Array/{difference.lua => difference.luau} | 0 ...ferenceSymmetric.lua => differenceSymmetric.luau} | 0 src/Array/{equals.lua => equals.luau} | 0 src/Array/{equalsDeep.lua => equalsDeep.luau} | 0 src/Array/{every.lua => every.luau} | 0 src/Array/{filter.lua => filter.luau} | 0 src/Array/{find.lua => find.luau} | 0 src/Array/{findLast.lua => findLast.luau} | 0 src/Array/{findWhere.lua => findWhere.luau} | 0 src/Array/{findWhereLast.lua => findWhereLast.luau} | 0 src/Array/{first.lua => first.luau} | 0 src/Array/{flatten.lua => flatten.luau} | 0 src/Array/{freeze.lua => freeze.luau} | 0 src/Array/{freezeDeep.lua => freezeDeep.luau} | 0 src/Array/{includes.lua => includes.luau} | 0 src/Array/{init.lua => init.luau} | 0 src/Array/{insert.lua => insert.luau} | 0 src/Array/{is.lua => is.luau} | 0 src/Array/{last.lua => last.luau} | 0 src/Array/{map.lua => map.luau} | 0 src/Array/{pop.lua => pop.luau} | 0 src/Array/{push.lua => push.luau} | 0 src/Array/{reduce.lua => reduce.luau} | 0 src/Array/{reduceRight.lua => reduceRight.luau} | 0 src/Array/{removeIndex.lua => removeIndex.luau} | 0 src/Array/{removeIndices.lua => removeIndices.luau} | 0 src/Array/{removeValue.lua => removeValue.luau} | 0 src/Array/{removeValues.lua => removeValues.luau} | 0 src/Array/{reverse.lua => reverse.luau} | 0 src/Array/{set.lua => set.luau} | 0 src/Array/{shift.lua => shift.luau} | 0 src/Array/{shuffle.lua => shuffle.luau} | 0 src/Array/{slice.lua => slice.luau} | 0 src/Array/{some.lua => some.luau} | 0 src/Array/{sort.lua => sort.luau} | 0 src/Array/{splice.lua => splice.luau} | 0 src/Array/{toSet.lua => toSet.luau} | 0 src/Array/{unshift.lua => unshift.luau} | 0 src/Array/{update.lua => update.luau} | 0 src/Array/{zip.lua => zip.luau} | 0 src/Array/{zipAll.lua => zipAll.luau} | 0 src/Dictionary/{copy.lua => copy.luau} | 0 src/Dictionary/{copyDeep.lua => copyDeep.luau} | 0 src/Dictionary/{count.lua => count.luau} | 0 src/Dictionary/{entries.lua => entries.luau} | 0 src/Dictionary/{equals.lua => equals.luau} | 0 src/Dictionary/{equalsDeep.lua => equalsDeep.luau} | 0 src/Dictionary/{every.lua => every.luau} | 0 src/Dictionary/{filter.lua => filter.luau} | 0 src/Dictionary/{flatten.lua => flatten.luau} | 0 src/Dictionary/{flip.lua => flip.luau} | 0 src/Dictionary/{freeze.lua => freeze.luau} | 0 src/Dictionary/{freezeDeep.lua => freezeDeep.luau} | 0 src/Dictionary/{fromArrays.lua => fromArrays.luau} | 0 src/Dictionary/{fromEntries.lua => fromEntries.luau} | 0 src/Dictionary/{has.lua => has.luau} | 0 src/Dictionary/{includes.lua => includes.luau} | 0 src/Dictionary/{init.lua => init.luau} | 0 src/Dictionary/{keys.lua => keys.luau} | 0 src/Dictionary/{map.lua => map.luau} | 0 src/Dictionary/{merge.lua => merge.luau} | 0 src/Dictionary/{mergeDeep.lua => mergeDeep.luau} | 0 src/Dictionary/{removeKey.lua => removeKey.luau} | 0 src/Dictionary/{removeKeys.lua => removeKeys.luau} | 0 src/Dictionary/{removeValue.lua => removeValue.luau} | 0 .../{removeValues.lua => removeValues.luau} | 0 src/Dictionary/{set.lua => set.luau} | 0 src/Dictionary/{some.lua => some.luau} | 0 src/Dictionary/{update.lua => update.luau} | 0 src/Dictionary/{values.lua => values.luau} | 0 src/Dictionary/{withKeys.lua => withKeys.luau} | 0 src/{None.lua => None.luau} | 0 src/Set/{add.lua => add.luau} | 0 src/Set/{copy.lua => copy.luau} | 0 src/Set/{count.lua => count.luau} | 0 src/Set/{delete.lua => delete.luau} | 0 src/Set/{difference.lua => difference.luau} | 0 ...ferenceSymmetric.lua => differenceSymmetric.luau} | 0 src/Set/{filter.lua => filter.luau} | 0 src/Set/{fromArray.lua => fromArray.luau} | 0 src/Set/{has.lua => has.luau} | 0 src/Set/{init.lua => init.luau} | 0 src/Set/{intersection.lua => intersection.luau} | 0 src/Set/{isSubset.lua => isSubset.luau} | 0 src/Set/{isSuperset.lua => isSuperset.luau} | 0 src/Set/{map.lua => map.luau} | 0 src/Set/{merge.lua => merge.luau} | 0 src/Set/{toArray.lua => toArray.luau} | 0 src/{Types.lua => Types.luau} | 0 src/Util/{equalObjects.lua => equalObjects.luau} | 0 src/Util/{func.lua => func.luau} | 0 src/Util/{init.lua => init.luau} | 0 src/Util/{isEmpty.lua => isEmpty.luau} | 0 src/{init.lua => init.luau} | 0 107 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 TestRunner.server.lua delete mode 100644 serve.project.json rename src/Array/{at.lua => at.luau} (100%) rename src/Array/{concat.lua => concat.luau} (100%) rename src/Array/{concatDeep.lua => concatDeep.luau} (100%) rename src/Array/{copy.lua => copy.luau} (100%) rename src/Array/{copyDeep.lua => copyDeep.luau} (100%) rename src/Array/{count.lua => count.luau} (100%) rename src/Array/{create.lua => create.luau} (100%) rename src/Array/{difference.lua => difference.luau} (100%) rename src/Array/{differenceSymmetric.lua => differenceSymmetric.luau} (100%) rename src/Array/{equals.lua => equals.luau} (100%) rename src/Array/{equalsDeep.lua => equalsDeep.luau} (100%) rename src/Array/{every.lua => every.luau} (100%) rename src/Array/{filter.lua => filter.luau} (100%) rename src/Array/{find.lua => find.luau} (100%) rename src/Array/{findLast.lua => findLast.luau} (100%) rename src/Array/{findWhere.lua => findWhere.luau} (100%) rename src/Array/{findWhereLast.lua => findWhereLast.luau} (100%) rename src/Array/{first.lua => first.luau} (100%) rename src/Array/{flatten.lua => flatten.luau} (100%) rename src/Array/{freeze.lua => freeze.luau} (100%) rename src/Array/{freezeDeep.lua => freezeDeep.luau} (100%) rename src/Array/{includes.lua => includes.luau} (100%) rename src/Array/{init.lua => init.luau} (100%) rename src/Array/{insert.lua => insert.luau} (100%) rename src/Array/{is.lua => is.luau} (100%) rename src/Array/{last.lua => last.luau} (100%) rename src/Array/{map.lua => map.luau} (100%) rename src/Array/{pop.lua => pop.luau} (100%) rename src/Array/{push.lua => push.luau} (100%) rename src/Array/{reduce.lua => reduce.luau} (100%) rename src/Array/{reduceRight.lua => reduceRight.luau} (100%) rename src/Array/{removeIndex.lua => removeIndex.luau} (100%) rename src/Array/{removeIndices.lua => removeIndices.luau} (100%) rename src/Array/{removeValue.lua => removeValue.luau} (100%) rename src/Array/{removeValues.lua => removeValues.luau} (100%) rename src/Array/{reverse.lua => reverse.luau} (100%) rename src/Array/{set.lua => set.luau} (100%) rename src/Array/{shift.lua => shift.luau} (100%) rename src/Array/{shuffle.lua => shuffle.luau} (100%) rename src/Array/{slice.lua => slice.luau} (100%) rename src/Array/{some.lua => some.luau} (100%) rename src/Array/{sort.lua => sort.luau} (100%) rename src/Array/{splice.lua => splice.luau} (100%) rename src/Array/{toSet.lua => toSet.luau} (100%) rename src/Array/{unshift.lua => unshift.luau} (100%) rename src/Array/{update.lua => update.luau} (100%) rename src/Array/{zip.lua => zip.luau} (100%) rename src/Array/{zipAll.lua => zipAll.luau} (100%) rename src/Dictionary/{copy.lua => copy.luau} (100%) rename src/Dictionary/{copyDeep.lua => copyDeep.luau} (100%) rename src/Dictionary/{count.lua => count.luau} (100%) rename src/Dictionary/{entries.lua => entries.luau} (100%) rename src/Dictionary/{equals.lua => equals.luau} (100%) rename src/Dictionary/{equalsDeep.lua => equalsDeep.luau} (100%) rename src/Dictionary/{every.lua => every.luau} (100%) rename src/Dictionary/{filter.lua => filter.luau} (100%) rename src/Dictionary/{flatten.lua => flatten.luau} (100%) rename src/Dictionary/{flip.lua => flip.luau} (100%) rename src/Dictionary/{freeze.lua => freeze.luau} (100%) rename src/Dictionary/{freezeDeep.lua => freezeDeep.luau} (100%) rename src/Dictionary/{fromArrays.lua => fromArrays.luau} (100%) rename src/Dictionary/{fromEntries.lua => fromEntries.luau} (100%) rename src/Dictionary/{has.lua => has.luau} (100%) rename src/Dictionary/{includes.lua => includes.luau} (100%) rename src/Dictionary/{init.lua => init.luau} (100%) rename src/Dictionary/{keys.lua => keys.luau} (100%) rename src/Dictionary/{map.lua => map.luau} (100%) rename src/Dictionary/{merge.lua => merge.luau} (100%) rename src/Dictionary/{mergeDeep.lua => mergeDeep.luau} (100%) rename src/Dictionary/{removeKey.lua => removeKey.luau} (100%) rename src/Dictionary/{removeKeys.lua => removeKeys.luau} (100%) rename src/Dictionary/{removeValue.lua => removeValue.luau} (100%) rename src/Dictionary/{removeValues.lua => removeValues.luau} (100%) rename src/Dictionary/{set.lua => set.luau} (100%) rename src/Dictionary/{some.lua => some.luau} (100%) rename src/Dictionary/{update.lua => update.luau} (100%) rename src/Dictionary/{values.lua => values.luau} (100%) rename src/Dictionary/{withKeys.lua => withKeys.luau} (100%) rename src/{None.lua => None.luau} (100%) rename src/Set/{add.lua => add.luau} (100%) rename src/Set/{copy.lua => copy.luau} (100%) rename src/Set/{count.lua => count.luau} (100%) rename src/Set/{delete.lua => delete.luau} (100%) rename src/Set/{difference.lua => difference.luau} (100%) rename src/Set/{differenceSymmetric.lua => differenceSymmetric.luau} (100%) rename src/Set/{filter.lua => filter.luau} (100%) rename src/Set/{fromArray.lua => fromArray.luau} (100%) rename src/Set/{has.lua => has.luau} (100%) rename src/Set/{init.lua => init.luau} (100%) rename src/Set/{intersection.lua => intersection.luau} (100%) rename src/Set/{isSubset.lua => isSubset.luau} (100%) rename src/Set/{isSuperset.lua => isSuperset.luau} (100%) rename src/Set/{map.lua => map.luau} (100%) rename src/Set/{merge.lua => merge.luau} (100%) rename src/Set/{toArray.lua => toArray.luau} (100%) rename src/{Types.lua => Types.luau} (100%) rename src/Util/{equalObjects.lua => equalObjects.luau} (100%) rename src/Util/{func.lua => func.luau} (100%) rename src/Util/{init.lua => init.luau} (100%) rename src/Util/{isEmpty.lua => isEmpty.luau} (100%) rename src/{init.lua => init.luau} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 669c6bd..1acaf69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,9 @@ }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "luau-lsp.require.directoryAliases": { + "@Pkg": "Packages", + "@DevPkg": "DevPackages" } } diff --git a/TestRunner.server.lua b/TestRunner.server.lua deleted file mode 100644 index e35a3a4..0000000 --- a/TestRunner.server.lua +++ /dev/null @@ -1,8 +0,0 @@ -local ServerScripts = game:GetService("ServerScriptService") -local TestService = game:GetService("TestService") - -local TestEZ = require(TestService.Packages.TestEZ) - -TestEZ.TestBootstrap:run({ - ServerScripts.Sift, -}) diff --git a/default.project.json b/default.project.json index 43954a7..91c96e9 100644 --- a/default.project.json +++ b/default.project.json @@ -1,9 +1,6 @@ { "name": "Sift", "tree": { - "$path": "src", - "Metadata": { - "$path": "wally.toml" - } + "$path": "src" } } diff --git a/selene.toml b/selene.toml index c4ddb46..a30015a 100644 --- a/selene.toml +++ b/selene.toml @@ -1 +1 @@ -std = "roblox" +std = "luau" diff --git a/serve.project.json b/serve.project.json deleted file mode 100644 index c664f99..0000000 --- a/serve.project.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "SiftServe", - "tree": { - "$className": "DataModel", - "ServerScriptService": { - "$className": "ServerScriptService", - "Sift": { - "$path": "default.project.json" - } - } - } -} diff --git a/sourcemap.json b/sourcemap.json index b17927f..a41e6c4 100644 --- a/sourcemap.json +++ b/sourcemap.json @@ -1 +1 @@ -{"name":"Sift","className":"ModuleScript","filePaths":["src\\init.lua","default.project.json"],"children":[{"name":"Array","className":"ModuleScript","filePaths":["src\\Array\\init.lua"],"children":[{"name":"at","className":"ModuleScript","filePaths":["src\\Array\\at.lua"]},{"name":"concat","className":"ModuleScript","filePaths":["src\\Array\\concat.lua"]},{"name":"concatDeep","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Array\\copy.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Array\\count.lua"]},{"name":"create","className":"ModuleScript","filePaths":["src\\Array\\create.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Array\\difference.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Array\\equals.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Array\\every.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Array\\filter.lua"]},{"name":"find","className":"ModuleScript","filePaths":["src\\Array\\find.lua"]},{"name":"findLast","className":"ModuleScript","filePaths":["src\\Array\\findLast.lua"]},{"name":"findWhere","className":"ModuleScript","filePaths":["src\\Array\\findWhere.lua"]},{"name":"findWhereLast","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.lua"]},{"name":"first","className":"ModuleScript","filePaths":["src\\Array\\first.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Array\\flatten.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Array\\freeze.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Array\\includes.lua"]},{"name":"insert","className":"ModuleScript","filePaths":["src\\Array\\insert.lua"]},{"name":"is","className":"ModuleScript","filePaths":["src\\Array\\is.lua"]},{"name":"last","className":"ModuleScript","filePaths":["src\\Array\\last.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Array\\map.lua"]},{"name":"pop","className":"ModuleScript","filePaths":["src\\Array\\pop.lua"]},{"name":"push","className":"ModuleScript","filePaths":["src\\Array\\push.lua"]},{"name":"reduce","className":"ModuleScript","filePaths":["src\\Array\\reduce.lua"]},{"name":"reduceRight","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.lua"]},{"name":"removeIndex","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.lua"]},{"name":"removeIndices","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Array\\removeValue.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Array\\removeValues.lua"]},{"name":"reverse","className":"ModuleScript","filePaths":["src\\Array\\reverse.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Array\\set.lua"]},{"name":"shift","className":"ModuleScript","filePaths":["src\\Array\\shift.lua"]},{"name":"shuffle","className":"ModuleScript","filePaths":["src\\Array\\shuffle.lua"]},{"name":"slice","className":"ModuleScript","filePaths":["src\\Array\\slice.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Array\\some.lua"]},{"name":"sort","className":"ModuleScript","filePaths":["src\\Array\\sort.lua"]},{"name":"splice","className":"ModuleScript","filePaths":["src\\Array\\splice.lua"]},{"name":"toSet","className":"ModuleScript","filePaths":["src\\Array\\toSet.lua"]},{"name":"unshift","className":"ModuleScript","filePaths":["src\\Array\\unshift.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Array\\update.lua"]},{"name":"zip","className":"ModuleScript","filePaths":["src\\Array\\zip.lua"]},{"name":"zipAll","className":"ModuleScript","filePaths":["src\\Array\\zipAll.lua"]}]},{"name":"Dictionary","className":"ModuleScript","filePaths":["src\\Dictionary\\init.lua"],"children":[{"name":"copy","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.lua"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Dictionary\\count.lua"]},{"name":"entries","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.lua"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.lua"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.lua"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Dictionary\\every.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.lua"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.lua"]},{"name":"flip","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.lua"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.lua"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.lua"]},{"name":"fromArrays","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.lua"]},{"name":"fromEntries","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Dictionary\\has.lua"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.lua"]},{"name":"keys","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Dictionary\\map.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.lua"]},{"name":"mergeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.lua"]},{"name":"removeKey","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.lua"]},{"name":"removeKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.lua"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.lua"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.lua"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Dictionary\\set.lua"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Dictionary\\some.lua"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Dictionary\\update.lua"]},{"name":"values","className":"ModuleScript","filePaths":["src\\Dictionary\\values.lua"]},{"name":"withKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.lua"]}]},{"name":"None","className":"ModuleScript","filePaths":["src\\None.lua"]},{"name":"Set","className":"ModuleScript","filePaths":["src\\Set\\init.lua"],"children":[{"name":"add","className":"ModuleScript","filePaths":["src\\Set\\add.lua"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Set\\copy.lua"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Set\\count.lua"]},{"name":"delete","className":"ModuleScript","filePaths":["src\\Set\\delete.lua"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Set\\difference.lua"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.lua"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Set\\filter.lua"]},{"name":"fromArray","className":"ModuleScript","filePaths":["src\\Set\\fromArray.lua"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Set\\has.lua"]},{"name":"intersection","className":"ModuleScript","filePaths":["src\\Set\\intersection.lua"]},{"name":"isSubset","className":"ModuleScript","filePaths":["src\\Set\\isSubset.lua"]},{"name":"isSuperset","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.lua"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Set\\map.lua"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Set\\merge.lua"]},{"name":"toArray","className":"ModuleScript","filePaths":["src\\Set\\toArray.lua"]}]},{"name":"Types","className":"ModuleScript","filePaths":["src\\Types.lua"]},{"name":"Util","className":"ModuleScript","filePaths":["src\\Util\\init.lua"],"children":[{"name":"equalObjects","className":"ModuleScript","filePaths":["src\\Util\\equalObjects.lua"]},{"name":"func","className":"ModuleScript","filePaths":["src\\Util\\func.lua"]},{"name":"isEmpty","className":"ModuleScript","filePaths":["src\\Util\\isEmpty.lua"]}]},{"name":"Metadata","className":"ModuleScript","filePaths":["wally.toml"]}]} \ No newline at end of file +{"name":"Sift","className":"ModuleScript","filePaths":["src\\init.luau","default.project.json"],"children":[{"name":"Array","className":"ModuleScript","filePaths":["src\\Array\\init.luau"],"children":[{"name":"concatDeep","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Array\\copy.luau"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Array\\count.luau"]},{"name":"create","className":"ModuleScript","filePaths":["src\\Array\\create.luau"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Array\\difference.luau"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.luau"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Array\\equals.luau"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.luau"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Array\\every.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Array\\filter.luau"]},{"name":"find","className":"ModuleScript","filePaths":["src\\Array\\find.luau"]},{"name":"findLast","className":"ModuleScript","filePaths":["src\\Array\\findLast.luau"]},{"name":"findWhere","className":"ModuleScript","filePaths":["src\\Array\\findWhere.luau"]},{"name":"findWhereLast","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.luau"]},{"name":"first","className":"ModuleScript","filePaths":["src\\Array\\first.luau"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Array\\flatten.luau"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Array\\freeze.luau"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.luau"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Array\\includes.luau"]},{"name":"insert","className":"ModuleScript","filePaths":["src\\Array\\insert.luau"]},{"name":"is","className":"ModuleScript","filePaths":["src\\Array\\is.luau"]},{"name":"last","className":"ModuleScript","filePaths":["src\\Array\\last.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Array\\map.luau"]},{"name":"pop","className":"ModuleScript","filePaths":["src\\Array\\pop.luau"]},{"name":"push","className":"ModuleScript","filePaths":["src\\Array\\push.luau"]},{"name":"reduce","className":"ModuleScript","filePaths":["src\\Array\\reduce.luau"]},{"name":"reduceRight","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.luau"]},{"name":"removeIndex","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.luau"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Array\\removeValues.luau"]},{"name":"reverse","className":"ModuleScript","filePaths":["src\\Array\\reverse.luau"]},{"name":"slice","className":"ModuleScript","filePaths":["src\\Array\\slice.luau"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Array\\update.luau"]},{"name":"zip","className":"ModuleScript","filePaths":["src\\Array\\zip.luau"]},{"name":"zipAll","className":"ModuleScript","filePaths":["src\\Array\\zipAll.luau"]},{"name":"at","className":"ModuleScript","filePaths":["src\\Array\\at.luau"]},{"name":"concat","className":"ModuleScript","filePaths":["src\\Array\\concat.luau"]},{"name":"removeIndices","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.luau"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Array\\removeValue.luau"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Array\\set.luau"]},{"name":"shift","className":"ModuleScript","filePaths":["src\\Array\\shift.luau"]},{"name":"shuffle","className":"ModuleScript","filePaths":["src\\Array\\shuffle.luau"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Array\\some.luau"]},{"name":"sort","className":"ModuleScript","filePaths":["src\\Array\\sort.luau"]},{"name":"splice","className":"ModuleScript","filePaths":["src\\Array\\splice.luau"]},{"name":"toSet","className":"ModuleScript","filePaths":["src\\Array\\toSet.luau"]},{"name":"unshift","className":"ModuleScript","filePaths":["src\\Array\\unshift.luau"]}]},{"name":"Dictionary","className":"ModuleScript","filePaths":["src\\Dictionary\\init.luau"],"children":[{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Dictionary\\count.luau"]},{"name":"entries","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.luau"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.luau"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.luau"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Dictionary\\every.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.luau"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.luau"]},{"name":"flip","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.luau"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.luau"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.luau"]},{"name":"fromArrays","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.luau"]},{"name":"fromEntries","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.luau"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Dictionary\\has.luau"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.luau"]},{"name":"keys","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Dictionary\\map.luau"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.luau"]},{"name":"mergeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.luau"]},{"name":"removeKey","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.luau"]},{"name":"removeKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.luau"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.luau"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.luau"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Dictionary\\set.luau"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Dictionary\\some.luau"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Dictionary\\update.luau"]},{"name":"values","className":"ModuleScript","filePaths":["src\\Dictionary\\values.luau"]},{"name":"withKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.luau"]}]},{"name":"Set","className":"ModuleScript","filePaths":["src\\Set\\init.luau"],"children":[{"name":"add","className":"ModuleScript","filePaths":["src\\Set\\add.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Set\\copy.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Set\\count.luau"]},{"name":"delete","className":"ModuleScript","filePaths":["src\\Set\\delete.luau"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Set\\difference.luau"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Set\\filter.luau"]},{"name":"fromArray","className":"ModuleScript","filePaths":["src\\Set\\fromArray.luau"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Set\\has.luau"]},{"name":"intersection","className":"ModuleScript","filePaths":["src\\Set\\intersection.luau"]},{"name":"isSubset","className":"ModuleScript","filePaths":["src\\Set\\isSubset.luau"]},{"name":"isSuperset","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Set\\map.luau"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Set\\merge.luau"]},{"name":"toArray","className":"ModuleScript","filePaths":["src\\Set\\toArray.luau"]}]},{"name":"Util","className":"ModuleScript","filePaths":["src\\Util\\init.luau"],"children":[{"name":"equalObjects","className":"ModuleScript","filePaths":["src\\Util\\equalObjects.luau"]},{"name":"func","className":"ModuleScript","filePaths":["src\\Util\\func.luau"]},{"name":"isEmpty","className":"ModuleScript","filePaths":["src\\Util\\isEmpty.luau"]}]},{"name":"Types","className":"ModuleScript","filePaths":["src\\Types.luau"]},{"name":"None","className":"ModuleScript","filePaths":["src\\None.luau"]}]} \ No newline at end of file diff --git a/src/Array/at.lua b/src/Array/at.luau similarity index 100% rename from src/Array/at.lua rename to src/Array/at.luau diff --git a/src/Array/concat.lua b/src/Array/concat.luau similarity index 100% rename from src/Array/concat.lua rename to src/Array/concat.luau diff --git a/src/Array/concatDeep.lua b/src/Array/concatDeep.luau similarity index 100% rename from src/Array/concatDeep.lua rename to src/Array/concatDeep.luau diff --git a/src/Array/copy.lua b/src/Array/copy.luau similarity index 100% rename from src/Array/copy.lua rename to src/Array/copy.luau diff --git a/src/Array/copyDeep.lua b/src/Array/copyDeep.luau similarity index 100% rename from src/Array/copyDeep.lua rename to src/Array/copyDeep.luau diff --git a/src/Array/count.lua b/src/Array/count.luau similarity index 100% rename from src/Array/count.lua rename to src/Array/count.luau diff --git a/src/Array/create.lua b/src/Array/create.luau similarity index 100% rename from src/Array/create.lua rename to src/Array/create.luau diff --git a/src/Array/difference.lua b/src/Array/difference.luau similarity index 100% rename from src/Array/difference.lua rename to src/Array/difference.luau diff --git a/src/Array/differenceSymmetric.lua b/src/Array/differenceSymmetric.luau similarity index 100% rename from src/Array/differenceSymmetric.lua rename to src/Array/differenceSymmetric.luau diff --git a/src/Array/equals.lua b/src/Array/equals.luau similarity index 100% rename from src/Array/equals.lua rename to src/Array/equals.luau diff --git a/src/Array/equalsDeep.lua b/src/Array/equalsDeep.luau similarity index 100% rename from src/Array/equalsDeep.lua rename to src/Array/equalsDeep.luau diff --git a/src/Array/every.lua b/src/Array/every.luau similarity index 100% rename from src/Array/every.lua rename to src/Array/every.luau diff --git a/src/Array/filter.lua b/src/Array/filter.luau similarity index 100% rename from src/Array/filter.lua rename to src/Array/filter.luau diff --git a/src/Array/find.lua b/src/Array/find.luau similarity index 100% rename from src/Array/find.lua rename to src/Array/find.luau diff --git a/src/Array/findLast.lua b/src/Array/findLast.luau similarity index 100% rename from src/Array/findLast.lua rename to src/Array/findLast.luau diff --git a/src/Array/findWhere.lua b/src/Array/findWhere.luau similarity index 100% rename from src/Array/findWhere.lua rename to src/Array/findWhere.luau diff --git a/src/Array/findWhereLast.lua b/src/Array/findWhereLast.luau similarity index 100% rename from src/Array/findWhereLast.lua rename to src/Array/findWhereLast.luau diff --git a/src/Array/first.lua b/src/Array/first.luau similarity index 100% rename from src/Array/first.lua rename to src/Array/first.luau diff --git a/src/Array/flatten.lua b/src/Array/flatten.luau similarity index 100% rename from src/Array/flatten.lua rename to src/Array/flatten.luau diff --git a/src/Array/freeze.lua b/src/Array/freeze.luau similarity index 100% rename from src/Array/freeze.lua rename to src/Array/freeze.luau diff --git a/src/Array/freezeDeep.lua b/src/Array/freezeDeep.luau similarity index 100% rename from src/Array/freezeDeep.lua rename to src/Array/freezeDeep.luau diff --git a/src/Array/includes.lua b/src/Array/includes.luau similarity index 100% rename from src/Array/includes.lua rename to src/Array/includes.luau diff --git a/src/Array/init.lua b/src/Array/init.luau similarity index 100% rename from src/Array/init.lua rename to src/Array/init.luau diff --git a/src/Array/insert.lua b/src/Array/insert.luau similarity index 100% rename from src/Array/insert.lua rename to src/Array/insert.luau diff --git a/src/Array/is.lua b/src/Array/is.luau similarity index 100% rename from src/Array/is.lua rename to src/Array/is.luau diff --git a/src/Array/last.lua b/src/Array/last.luau similarity index 100% rename from src/Array/last.lua rename to src/Array/last.luau diff --git a/src/Array/map.lua b/src/Array/map.luau similarity index 100% rename from src/Array/map.lua rename to src/Array/map.luau diff --git a/src/Array/pop.lua b/src/Array/pop.luau similarity index 100% rename from src/Array/pop.lua rename to src/Array/pop.luau diff --git a/src/Array/push.lua b/src/Array/push.luau similarity index 100% rename from src/Array/push.lua rename to src/Array/push.luau diff --git a/src/Array/reduce.lua b/src/Array/reduce.luau similarity index 100% rename from src/Array/reduce.lua rename to src/Array/reduce.luau diff --git a/src/Array/reduceRight.lua b/src/Array/reduceRight.luau similarity index 100% rename from src/Array/reduceRight.lua rename to src/Array/reduceRight.luau diff --git a/src/Array/removeIndex.lua b/src/Array/removeIndex.luau similarity index 100% rename from src/Array/removeIndex.lua rename to src/Array/removeIndex.luau diff --git a/src/Array/removeIndices.lua b/src/Array/removeIndices.luau similarity index 100% rename from src/Array/removeIndices.lua rename to src/Array/removeIndices.luau diff --git a/src/Array/removeValue.lua b/src/Array/removeValue.luau similarity index 100% rename from src/Array/removeValue.lua rename to src/Array/removeValue.luau diff --git a/src/Array/removeValues.lua b/src/Array/removeValues.luau similarity index 100% rename from src/Array/removeValues.lua rename to src/Array/removeValues.luau diff --git a/src/Array/reverse.lua b/src/Array/reverse.luau similarity index 100% rename from src/Array/reverse.lua rename to src/Array/reverse.luau diff --git a/src/Array/set.lua b/src/Array/set.luau similarity index 100% rename from src/Array/set.lua rename to src/Array/set.luau diff --git a/src/Array/shift.lua b/src/Array/shift.luau similarity index 100% rename from src/Array/shift.lua rename to src/Array/shift.luau diff --git a/src/Array/shuffle.lua b/src/Array/shuffle.luau similarity index 100% rename from src/Array/shuffle.lua rename to src/Array/shuffle.luau diff --git a/src/Array/slice.lua b/src/Array/slice.luau similarity index 100% rename from src/Array/slice.lua rename to src/Array/slice.luau diff --git a/src/Array/some.lua b/src/Array/some.luau similarity index 100% rename from src/Array/some.lua rename to src/Array/some.luau diff --git a/src/Array/sort.lua b/src/Array/sort.luau similarity index 100% rename from src/Array/sort.lua rename to src/Array/sort.luau diff --git a/src/Array/splice.lua b/src/Array/splice.luau similarity index 100% rename from src/Array/splice.lua rename to src/Array/splice.luau diff --git a/src/Array/toSet.lua b/src/Array/toSet.luau similarity index 100% rename from src/Array/toSet.lua rename to src/Array/toSet.luau diff --git a/src/Array/unshift.lua b/src/Array/unshift.luau similarity index 100% rename from src/Array/unshift.lua rename to src/Array/unshift.luau diff --git a/src/Array/update.lua b/src/Array/update.luau similarity index 100% rename from src/Array/update.lua rename to src/Array/update.luau diff --git a/src/Array/zip.lua b/src/Array/zip.luau similarity index 100% rename from src/Array/zip.lua rename to src/Array/zip.luau diff --git a/src/Array/zipAll.lua b/src/Array/zipAll.luau similarity index 100% rename from src/Array/zipAll.lua rename to src/Array/zipAll.luau diff --git a/src/Dictionary/copy.lua b/src/Dictionary/copy.luau similarity index 100% rename from src/Dictionary/copy.lua rename to src/Dictionary/copy.luau diff --git a/src/Dictionary/copyDeep.lua b/src/Dictionary/copyDeep.luau similarity index 100% rename from src/Dictionary/copyDeep.lua rename to src/Dictionary/copyDeep.luau diff --git a/src/Dictionary/count.lua b/src/Dictionary/count.luau similarity index 100% rename from src/Dictionary/count.lua rename to src/Dictionary/count.luau diff --git a/src/Dictionary/entries.lua b/src/Dictionary/entries.luau similarity index 100% rename from src/Dictionary/entries.lua rename to src/Dictionary/entries.luau diff --git a/src/Dictionary/equals.lua b/src/Dictionary/equals.luau similarity index 100% rename from src/Dictionary/equals.lua rename to src/Dictionary/equals.luau diff --git a/src/Dictionary/equalsDeep.lua b/src/Dictionary/equalsDeep.luau similarity index 100% rename from src/Dictionary/equalsDeep.lua rename to src/Dictionary/equalsDeep.luau diff --git a/src/Dictionary/every.lua b/src/Dictionary/every.luau similarity index 100% rename from src/Dictionary/every.lua rename to src/Dictionary/every.luau diff --git a/src/Dictionary/filter.lua b/src/Dictionary/filter.luau similarity index 100% rename from src/Dictionary/filter.lua rename to src/Dictionary/filter.luau diff --git a/src/Dictionary/flatten.lua b/src/Dictionary/flatten.luau similarity index 100% rename from src/Dictionary/flatten.lua rename to src/Dictionary/flatten.luau diff --git a/src/Dictionary/flip.lua b/src/Dictionary/flip.luau similarity index 100% rename from src/Dictionary/flip.lua rename to src/Dictionary/flip.luau diff --git a/src/Dictionary/freeze.lua b/src/Dictionary/freeze.luau similarity index 100% rename from src/Dictionary/freeze.lua rename to src/Dictionary/freeze.luau diff --git a/src/Dictionary/freezeDeep.lua b/src/Dictionary/freezeDeep.luau similarity index 100% rename from src/Dictionary/freezeDeep.lua rename to src/Dictionary/freezeDeep.luau diff --git a/src/Dictionary/fromArrays.lua b/src/Dictionary/fromArrays.luau similarity index 100% rename from src/Dictionary/fromArrays.lua rename to src/Dictionary/fromArrays.luau diff --git a/src/Dictionary/fromEntries.lua b/src/Dictionary/fromEntries.luau similarity index 100% rename from src/Dictionary/fromEntries.lua rename to src/Dictionary/fromEntries.luau diff --git a/src/Dictionary/has.lua b/src/Dictionary/has.luau similarity index 100% rename from src/Dictionary/has.lua rename to src/Dictionary/has.luau diff --git a/src/Dictionary/includes.lua b/src/Dictionary/includes.luau similarity index 100% rename from src/Dictionary/includes.lua rename to src/Dictionary/includes.luau diff --git a/src/Dictionary/init.lua b/src/Dictionary/init.luau similarity index 100% rename from src/Dictionary/init.lua rename to src/Dictionary/init.luau diff --git a/src/Dictionary/keys.lua b/src/Dictionary/keys.luau similarity index 100% rename from src/Dictionary/keys.lua rename to src/Dictionary/keys.luau diff --git a/src/Dictionary/map.lua b/src/Dictionary/map.luau similarity index 100% rename from src/Dictionary/map.lua rename to src/Dictionary/map.luau diff --git a/src/Dictionary/merge.lua b/src/Dictionary/merge.luau similarity index 100% rename from src/Dictionary/merge.lua rename to src/Dictionary/merge.luau diff --git a/src/Dictionary/mergeDeep.lua b/src/Dictionary/mergeDeep.luau similarity index 100% rename from src/Dictionary/mergeDeep.lua rename to src/Dictionary/mergeDeep.luau diff --git a/src/Dictionary/removeKey.lua b/src/Dictionary/removeKey.luau similarity index 100% rename from src/Dictionary/removeKey.lua rename to src/Dictionary/removeKey.luau diff --git a/src/Dictionary/removeKeys.lua b/src/Dictionary/removeKeys.luau similarity index 100% rename from src/Dictionary/removeKeys.lua rename to src/Dictionary/removeKeys.luau diff --git a/src/Dictionary/removeValue.lua b/src/Dictionary/removeValue.luau similarity index 100% rename from src/Dictionary/removeValue.lua rename to src/Dictionary/removeValue.luau diff --git a/src/Dictionary/removeValues.lua b/src/Dictionary/removeValues.luau similarity index 100% rename from src/Dictionary/removeValues.lua rename to src/Dictionary/removeValues.luau diff --git a/src/Dictionary/set.lua b/src/Dictionary/set.luau similarity index 100% rename from src/Dictionary/set.lua rename to src/Dictionary/set.luau diff --git a/src/Dictionary/some.lua b/src/Dictionary/some.luau similarity index 100% rename from src/Dictionary/some.lua rename to src/Dictionary/some.luau diff --git a/src/Dictionary/update.lua b/src/Dictionary/update.luau similarity index 100% rename from src/Dictionary/update.lua rename to src/Dictionary/update.luau diff --git a/src/Dictionary/values.lua b/src/Dictionary/values.luau similarity index 100% rename from src/Dictionary/values.lua rename to src/Dictionary/values.luau diff --git a/src/Dictionary/withKeys.lua b/src/Dictionary/withKeys.luau similarity index 100% rename from src/Dictionary/withKeys.lua rename to src/Dictionary/withKeys.luau diff --git a/src/None.lua b/src/None.luau similarity index 100% rename from src/None.lua rename to src/None.luau diff --git a/src/Set/add.lua b/src/Set/add.luau similarity index 100% rename from src/Set/add.lua rename to src/Set/add.luau diff --git a/src/Set/copy.lua b/src/Set/copy.luau similarity index 100% rename from src/Set/copy.lua rename to src/Set/copy.luau diff --git a/src/Set/count.lua b/src/Set/count.luau similarity index 100% rename from src/Set/count.lua rename to src/Set/count.luau diff --git a/src/Set/delete.lua b/src/Set/delete.luau similarity index 100% rename from src/Set/delete.lua rename to src/Set/delete.luau diff --git a/src/Set/difference.lua b/src/Set/difference.luau similarity index 100% rename from src/Set/difference.lua rename to src/Set/difference.luau diff --git a/src/Set/differenceSymmetric.lua b/src/Set/differenceSymmetric.luau similarity index 100% rename from src/Set/differenceSymmetric.lua rename to src/Set/differenceSymmetric.luau diff --git a/src/Set/filter.lua b/src/Set/filter.luau similarity index 100% rename from src/Set/filter.lua rename to src/Set/filter.luau diff --git a/src/Set/fromArray.lua b/src/Set/fromArray.luau similarity index 100% rename from src/Set/fromArray.lua rename to src/Set/fromArray.luau diff --git a/src/Set/has.lua b/src/Set/has.luau similarity index 100% rename from src/Set/has.lua rename to src/Set/has.luau diff --git a/src/Set/init.lua b/src/Set/init.luau similarity index 100% rename from src/Set/init.lua rename to src/Set/init.luau diff --git a/src/Set/intersection.lua b/src/Set/intersection.luau similarity index 100% rename from src/Set/intersection.lua rename to src/Set/intersection.luau diff --git a/src/Set/isSubset.lua b/src/Set/isSubset.luau similarity index 100% rename from src/Set/isSubset.lua rename to src/Set/isSubset.luau diff --git a/src/Set/isSuperset.lua b/src/Set/isSuperset.luau similarity index 100% rename from src/Set/isSuperset.lua rename to src/Set/isSuperset.luau diff --git a/src/Set/map.lua b/src/Set/map.luau similarity index 100% rename from src/Set/map.lua rename to src/Set/map.luau diff --git a/src/Set/merge.lua b/src/Set/merge.luau similarity index 100% rename from src/Set/merge.lua rename to src/Set/merge.luau diff --git a/src/Set/toArray.lua b/src/Set/toArray.luau similarity index 100% rename from src/Set/toArray.lua rename to src/Set/toArray.luau diff --git a/src/Types.lua b/src/Types.luau similarity index 100% rename from src/Types.lua rename to src/Types.luau diff --git a/src/Util/equalObjects.lua b/src/Util/equalObjects.luau similarity index 100% rename from src/Util/equalObjects.lua rename to src/Util/equalObjects.luau diff --git a/src/Util/func.lua b/src/Util/func.luau similarity index 100% rename from src/Util/func.lua rename to src/Util/func.luau diff --git a/src/Util/init.lua b/src/Util/init.luau similarity index 100% rename from src/Util/init.lua rename to src/Util/init.luau diff --git a/src/Util/isEmpty.lua b/src/Util/isEmpty.luau similarity index 100% rename from src/Util/isEmpty.lua rename to src/Util/isEmpty.luau diff --git a/src/init.lua b/src/init.luau similarity index 100% rename from src/init.lua rename to src/init.luau From 922bcdd9af0d6c3e9b275e193f749883a0039bbe Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:43:14 +0000 Subject: [PATCH 05/43] Luau rewrite --- .gitignore | 1 + .luaurc | 3 +- .vscode/settings.json | 8 +- @types/Array.d.ts | 187 ------------------------ @types/Dictionary.d.ts | 166 --------------------- @types/Set.d.ts | 53 ------- @types/Util.d.ts | 49 ------- @types/index.d.ts | 19 --- README.md | 25 ---- docs/Examples.md | 77 ---------- docs/Installation.md | 61 -------- package.json | 7 +- sourcemap.json | 1 - src/Array/at.luau | 29 ++-- src/Array/concat.luau | 47 ++---- src/Array/concatDeep.luau | 52 ------- src/Array/copy.luau | 22 +-- src/Array/copyDeep.luau | 33 ++--- src/Array/count.luau | 41 ++---- src/Array/create.luau | 28 ++-- src/Array/difference.luau | 42 ------ src/Array/difference.luau.todo | 1 + src/Array/differenceSymmetric.luau | 42 ------ src/Array/differenceSymmetric.luau.todo | 1 + src/Array/equals.luau | 51 +++---- src/Array/equalsDeep.luau | 51 +++---- src/Array/every.luau | 35 ++--- src/Array/filter.luau | 44 ++---- src/Array/find.luau | 37 ++--- src/Array/findLast.luau | 40 +++-- src/Array/findWhere.luau | 39 ++--- src/Array/findWhereLast.luau | 43 ++---- src/Array/first.luau | 21 +-- src/Array/flatten.luau | 57 ++++---- src/Array/freeze.luau | 31 ++-- src/Array/freezeDeep.luau | 40 ++--- src/Array/includes.luau | 32 +--- src/Array/init.luau | 82 +---------- src/Array/insert.luau | 55 +++---- src/Array/is.luau | 28 ++-- src/Array/last.luau | 21 +-- src/Array/map.luau | 38 ++--- src/Array/partition.luau | 30 ++++ src/Array/pop.luau | 37 +++-- src/Array/push.luau | 36 +---- src/Array/reduce.luau | 45 ++---- src/Array/reduceRight.luau | 46 ++---- src/Array/removeIndex.luau | 36 +---- src/Array/removeIndices.luau | 47 +++--- src/Array/removeValue.luau | 30 +--- src/Array/removeValues.luau | 40 ++--- src/Array/reverse.luau | 23 +-- src/Array/set.luau | 44 +++--- src/Array/shift.luau | 37 +++-- src/Array/shuffle.luau | 38 ++--- src/Array/slice.luau | 50 +++---- src/Array/some.luau | 35 ++--- src/Array/sort.luau | 30 ++-- src/Array/splice.luau | 58 ++++---- src/Array/toSet.luau | 32 ++-- src/Array/unshift.luau | 30 +--- src/Array/update.luau | 71 +++------ src/Array/zip.luau | 52 +++---- src/Array/zipAll.luau | 58 ++++---- src/Dictionary/copy.luau | 20 --- src/Dictionary/copy.luau.todo | 0 src/Dictionary/copyDeep.luau | 32 ---- src/Dictionary/copyDeep.luau.todo | 0 src/Dictionary/count.luau | 42 ------ src/Dictionary/count.luau.todo | 0 src/Dictionary/entries.luau | 27 ---- src/Dictionary/entries.luau.todo | 0 src/Dictionary/equals.luau | 64 -------- src/Dictionary/equals.luau.todo | 0 src/Dictionary/equalsDeep.luau | 64 -------- src/Dictionary/equalsDeep.luau.todo | 0 src/Dictionary/every.luau | 37 ----- src/Dictionary/every.luau.todo | 0 src/Dictionary/filter.luau | 41 ------ src/Dictionary/filter.luau.todo | 0 src/Dictionary/flatten.luau | 52 ------- src/Dictionary/flatten.luau.todo | 0 src/Dictionary/flip.luau | 27 ---- src/Dictionary/flip.luau.todo | 0 src/Dictionary/freeze.luau | 31 ---- src/Dictionary/freeze.luau.todo | 0 src/Dictionary/freezeDeep.luau | 38 ----- src/Dictionary/freezeDeep.luau.todo | 0 src/Dictionary/fromArrays.luau | 31 ---- src/Dictionary/fromArrays.luau.todo | 0 src/Dictionary/fromEntries.luau | 27 ---- src/Dictionary/fromEntries.luau.todo | 0 src/Dictionary/has.luau | 25 ---- src/Dictionary/has.luau.todo | 0 src/Dictionary/includes.luau | 29 ---- src/Dictionary/includes.luau.todo | 0 src/Dictionary/init.luau | 51 +------ src/Dictionary/keys.luau | 27 ---- src/Dictionary/keys.luau.todo | 0 src/Dictionary/map.luau | 40 ----- src/Dictionary/map.luau.todo | 0 src/Dictionary/merge.luau | 45 ------ src/Dictionary/merge.luau.todo | 0 src/Dictionary/mergeDeep.luau | 56 ------- src/Dictionary/mergeDeep.luau.todo | 0 src/Dictionary/removeKey.luau | 29 ---- src/Dictionary/removeKey.luau.todo | 0 src/Dictionary/removeKeys.luau | 30 ---- src/Dictionary/removeKeys.luau.todo | 0 src/Dictionary/removeValue.luau | 31 ---- src/Dictionary/removeValue.luau.todo | 0 src/Dictionary/removeValues.luau | 36 ----- src/Dictionary/removeValues.luau.todo | 0 src/Dictionary/set.luau | 29 ---- src/Dictionary/set.luau.todo | 0 src/Dictionary/some.luau | 37 ----- src/Dictionary/some.luau.todo | 0 src/Dictionary/update.luau | 60 -------- src/Dictionary/update.luau.todo | 0 src/Dictionary/values.luau | 27 ---- src/Dictionary/values.luau.todo | 0 src/Dictionary/withKeys.luau | 29 ---- src/Dictionary/withKeys.luau.todo | 0 src/None.luau | 16 +- src/Set/add.luau | 32 ---- src/Set/add.luau.todo | 0 src/Set/copy.luau | 21 --- src/Set/copy.luau.todo | 0 src/Set/count.luau | 42 ------ src/Set/count.luau.todo | 0 src/Set/delete.luau | 34 ----- src/Set/delete.luau.todo | 0 src/Set/difference.luau | 37 ----- src/Set/difference.luau.todo | 0 src/Set/differenceSymmetric.luau | 41 ------ src/Set/differenceSymmetric.luau.todo | 0 src/Set/filter.luau | 41 ------ src/Set/filter.luau.todo | 0 src/Set/fromArray.luau | 30 ---- src/Set/fromArray.luau.todo | 0 src/Set/has.luau | 22 --- src/Set/has.luau.todo | 0 src/Set/init.luau | 38 +---- src/Set/intersection.luau | 46 ------ src/Set/intersection.luau.todo | 0 src/Set/isSubset.luau | 29 ---- src/Set/isSubset.luau.todo | 0 src/Set/isSuperset.luau | 25 ---- src/Set/isSuperset.luau.todo | 0 src/Set/map.luau | 34 ----- src/Set/map.luau.todo | 0 src/Set/merge.luau | 38 ----- src/Set/merge.luau.todo | 0 src/Set/toArray.luau | 27 ---- src/Set/toArray.luau.todo | 0 src/Types.luau | 13 +- src/Util.luau | 36 +++++ src/Util/equalObjects.luau | 32 ---- src/Util/func.luau | 15 -- src/Util/init.luau | 5 - src/Util/isEmpty.luau | 26 ---- src/init.luau | 56 ++----- test.project.json | 33 ----- wally.toml | 2 +- 164 files changed, 747 insertions(+), 3783 deletions(-) delete mode 100644 @types/Array.d.ts delete mode 100644 @types/Dictionary.d.ts delete mode 100644 @types/Set.d.ts delete mode 100644 @types/Util.d.ts delete mode 100644 @types/index.d.ts delete mode 100644 docs/Examples.md delete mode 100644 docs/Installation.md delete mode 100644 sourcemap.json delete mode 100644 src/Array/concatDeep.luau delete mode 100644 src/Array/difference.luau create mode 100644 src/Array/difference.luau.todo delete mode 100644 src/Array/differenceSymmetric.luau create mode 100644 src/Array/differenceSymmetric.luau.todo create mode 100644 src/Array/partition.luau delete mode 100644 src/Dictionary/copy.luau create mode 100644 src/Dictionary/copy.luau.todo delete mode 100644 src/Dictionary/copyDeep.luau create mode 100644 src/Dictionary/copyDeep.luau.todo delete mode 100644 src/Dictionary/count.luau create mode 100644 src/Dictionary/count.luau.todo delete mode 100644 src/Dictionary/entries.luau create mode 100644 src/Dictionary/entries.luau.todo delete mode 100644 src/Dictionary/equals.luau create mode 100644 src/Dictionary/equals.luau.todo delete mode 100644 src/Dictionary/equalsDeep.luau create mode 100644 src/Dictionary/equalsDeep.luau.todo delete mode 100644 src/Dictionary/every.luau create mode 100644 src/Dictionary/every.luau.todo delete mode 100644 src/Dictionary/filter.luau create mode 100644 src/Dictionary/filter.luau.todo delete mode 100644 src/Dictionary/flatten.luau create mode 100644 src/Dictionary/flatten.luau.todo delete mode 100644 src/Dictionary/flip.luau create mode 100644 src/Dictionary/flip.luau.todo delete mode 100644 src/Dictionary/freeze.luau create mode 100644 src/Dictionary/freeze.luau.todo delete mode 100644 src/Dictionary/freezeDeep.luau create mode 100644 src/Dictionary/freezeDeep.luau.todo delete mode 100644 src/Dictionary/fromArrays.luau create mode 100644 src/Dictionary/fromArrays.luau.todo delete mode 100644 src/Dictionary/fromEntries.luau create mode 100644 src/Dictionary/fromEntries.luau.todo delete mode 100644 src/Dictionary/has.luau create mode 100644 src/Dictionary/has.luau.todo delete mode 100644 src/Dictionary/includes.luau create mode 100644 src/Dictionary/includes.luau.todo delete mode 100644 src/Dictionary/keys.luau create mode 100644 src/Dictionary/keys.luau.todo delete mode 100644 src/Dictionary/map.luau create mode 100644 src/Dictionary/map.luau.todo delete mode 100644 src/Dictionary/merge.luau create mode 100644 src/Dictionary/merge.luau.todo delete mode 100644 src/Dictionary/mergeDeep.luau create mode 100644 src/Dictionary/mergeDeep.luau.todo delete mode 100644 src/Dictionary/removeKey.luau create mode 100644 src/Dictionary/removeKey.luau.todo delete mode 100644 src/Dictionary/removeKeys.luau create mode 100644 src/Dictionary/removeKeys.luau.todo delete mode 100644 src/Dictionary/removeValue.luau create mode 100644 src/Dictionary/removeValue.luau.todo delete mode 100644 src/Dictionary/removeValues.luau create mode 100644 src/Dictionary/removeValues.luau.todo delete mode 100644 src/Dictionary/set.luau create mode 100644 src/Dictionary/set.luau.todo delete mode 100644 src/Dictionary/some.luau create mode 100644 src/Dictionary/some.luau.todo delete mode 100644 src/Dictionary/update.luau create mode 100644 src/Dictionary/update.luau.todo delete mode 100644 src/Dictionary/values.luau create mode 100644 src/Dictionary/values.luau.todo delete mode 100644 src/Dictionary/withKeys.luau create mode 100644 src/Dictionary/withKeys.luau.todo delete mode 100644 src/Set/add.luau create mode 100644 src/Set/add.luau.todo delete mode 100644 src/Set/copy.luau create mode 100644 src/Set/copy.luau.todo delete mode 100644 src/Set/count.luau create mode 100644 src/Set/count.luau.todo delete mode 100644 src/Set/delete.luau create mode 100644 src/Set/delete.luau.todo delete mode 100644 src/Set/difference.luau create mode 100644 src/Set/difference.luau.todo delete mode 100644 src/Set/differenceSymmetric.luau create mode 100644 src/Set/differenceSymmetric.luau.todo delete mode 100644 src/Set/filter.luau create mode 100644 src/Set/filter.luau.todo delete mode 100644 src/Set/fromArray.luau create mode 100644 src/Set/fromArray.luau.todo delete mode 100644 src/Set/has.luau create mode 100644 src/Set/has.luau.todo delete mode 100644 src/Set/intersection.luau create mode 100644 src/Set/intersection.luau.todo delete mode 100644 src/Set/isSubset.luau create mode 100644 src/Set/isSubset.luau.todo delete mode 100644 src/Set/isSuperset.luau create mode 100644 src/Set/isSuperset.luau.todo delete mode 100644 src/Set/map.luau create mode 100644 src/Set/map.luau.todo delete mode 100644 src/Set/merge.luau create mode 100644 src/Set/merge.luau.todo delete mode 100644 src/Set/toArray.luau create mode 100644 src/Set/toArray.luau.todo create mode 100644 src/Util.luau delete mode 100644 src/Util/equalObjects.luau delete mode 100644 src/Util/func.luau delete mode 100644 src/Util/init.luau delete mode 100644 src/Util/isEmpty.luau delete mode 100644 test.project.json diff --git a/.gitignore b/.gitignore index f0deb4d..77b402b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .env .env.* *.tsbuildinfo +sourcemap.json /Packages /DevPackages diff --git a/.luaurc b/.luaurc index cfbdb52..06b85fb 100644 --- a/.luaurc +++ b/.luaurc @@ -3,6 +3,7 @@ "lint": { "*": false }, "aliases": { "Pkg": "Packages", - "DevPkg": "DevPackages" + "DevPkg": "DevPackages", + "Sift": "src" } } diff --git a/.vscode/settings.json b/.vscode/settings.json index 1acaf69..5a1a07f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,10 @@ }, "luau-lsp.require.directoryAliases": { "@Pkg": "Packages", - "@DevPkg": "DevPackages" - } + "@DevPkg": "DevPackages", + "@Sift": "src" + }, + "luau-lsp.types.roblox": false, + "luau-lsp.require.mode": "relativeToFile", + "luau-lsp.completion.imports.suggestRequires": false } diff --git a/@types/Array.d.ts b/@types/Array.d.ts deleted file mode 100644 index 6ef8f70..0000000 --- a/@types/Array.d.ts +++ /dev/null @@ -1,187 +0,0 @@ -import type { ReadonlyDeep, ReplaceType, SiftNone } from "./Util" - -declare namespace SiftArray { - export function at( - array: V[], - index: number - ): V | undefined - - export function concat(...arrays: T[]): T - - export function concatDeep(...arrays: T[]): T - - export function copy(array: T): T - - export function copyDeep(array: T): T - - export function count( - array: T[], - predicate: (value: T, index: number, array: Readonly) => unknown - ): number - - export function create(length: number, value?: T): T[] - - export function difference(array: T[], ...values: T[]): T[] - - export function differenceSymmetric(array: T[], ...values: T[]): T[] - - export function equals(...arrays: unknown[]): boolean - - export function equalsDeep(...arrays: unknown[]): boolean - - export function every( - array: T[], - predicate: (value: T, index: number, array: Readonly) => unknown - ): boolean - - export function filter( - array: T[], - filterer?: (value: T, index: number, array: Readonly) => unknown - ): T[] - - export function find( - array: T[], - value?: T, - from?: number - ): number | undefined - - export function findLast( - array: T[], - value?: T, - from?: number - ): number | undefined - - export function findWhere( - array: T[], - predicate: (value: T, index: number, array: Readonly) => unknown, - from?: number - ): number - - export function findWhereLast( - array: T[], - predicate: (value: T, index: number, array: Readonly) => unknown, - from?: number - ): number - - export function first(array: T[]): T - - export function flatten(array: T[], depth?: number): T[] - - export function freeze(array: T[]): Readonly - - export function freezeDeep(array: T[]): ReadonlyDeep - - export function includes(array: T[], value: T, from?: number): boolean - - export function insert(array: T[], index: number, ...values: T[]): T[] - - export function is(value: any): boolean - - export function last(array: T[]): T - - export function map( - array: T[], - mapper: (value: T, index: number, array: Readonly) => U - ): U[] - - export function pop(array: T[], count?: number): T[] - - export function push(array: T[], ...values: T[]): T[] - - export function reduce( - array: T[], - reducer: ( - accumulator: U, - value: T, - index: number, - array: Readonly - ) => U, - initialValue?: U - ): U - - export function reduceRight( - array: T[], - reducer: ( - accumulator: U, - value: T, - index: number, - array: Readonly - ) => U, - initialValue?: U - ): U - - export function removeIndex(array: T[], index: number): T[] - - export function removeIndices(array: T[], ...indices: number[]): T[] - - export function removeValue(array: T[], value: T): T[] - - export function removeValues(array: T[], ...values: T[]): T[] - - export function reverse(array: T[]): T[] - - export function set(array: T[], index: number, value: T): T[] - - export function shift(array: T[], count?: number): T[] - - export function shuffle(array: T[]): T[] - - export function slice(array: T[], from?: number, to?: number): T[] - - export function some( - array: T[], - predicate: (value: T, index: number, array: Readonly) => unknown - ): boolean - - export function sort(array: T[], comparator?: (a: T, b: T) => unknown): T[] - - export function splice( - array: T[], - start?: number, - end?: number, - ...values: T[] - ): T[] - - export function toSet(array: T[]): Set - - export function unshift(array: T[], ...values: T[]): T[] - - export function update( - array: T[], - index: number, - updater?: (value: T, index: number) => T, - callback?: (index: number) => T - ): T[] - - export function zip( - ...arrays: T - ): { - [K in keyof T]: T[K] extends (infer V)[] ? V : never - }[] - - export function zipAll( - ...arrays: T - ): { - [K in keyof T]: ReplaceType< - T[K] extends (infer V)[] ? V : never, - undefined, - SiftNone - > - }[] - - // Aliases - export { - concat as join, - concat as merge, - concatDeep as joinDeep, - concatDeep as mergeDeep, - find as indexOf, - includes as contains, - includes as has, - push as append, - unshift as prepend, - is as isArray, - } -} - -export = SiftArray diff --git a/@types/Dictionary.d.ts b/@types/Dictionary.d.ts deleted file mode 100644 index dd71e15..0000000 --- a/@types/Dictionary.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { - ExcludeNone, - FromEntries, - ObjectFromKeyValueArrays, - ObjectKey, - ReadonlyDeep, - TryIndex -} from "./Util" - -declare namespace SiftDictionary { - export function copy(dictionary: T): T - - export function copyDeep(dictionary: T): T - - export function count( - dictionary: T, - predicate?: (value: T[K], key: K, dictionary: T) => unknown - ): number - - export function entries( - dictionary: T - ): [K, T[K]][] - - export function equals(...dictionaries: object[]): boolean - - export function equalsDeep(...dictionaries: object[]): boolean - - export function every( - dictionary: T, - predicate: (value: T[K], key: K, dictionary: Readonly) => unknown - ): boolean - - export function filter( - dictionary: T, - predicate: (value: T[K], key: K, dictionary: Readonly) => unknown - ): Partial - - export function flatten( - dictionary: T, - depth?: number - ): Record - - export function flip( - dictionary: T - ): Record - - export function freeze(dictionary: T): Readonly - - export function freezeDeep(dictionary: T): ReadonlyDeep - - export function fromArrays( - keys: K[], - values: V[] - ): ObjectFromKeyValueArrays - - export function fromEntries( - entries: T - ): FromEntries - - export function has(dictionary: T, key: unknown): boolean - - export function includes( - dictionary: T, - value: unknown - ): boolean - - export function keys(dictionary: T): K[] - - export function map< - T extends object, - MV, - MK extends ObjectKey, - K extends keyof T - >( - dictionary: T, - mapper: ( - value: T[K], - key: K, - dictionary: Readonly - ) => LuaTuple<[newValue: MV, newKey: MK]> | undefined - ): { - [key in MK]: MV - } - - export function map( - dictionary: T, - mapper: (value: T[K], key: K, dictionary: Readonly) => MV | undefined - ): { - [key in K]: MV - } - - export function merge( - ...dictionaries: T - ): ExcludeNone> - - export function mergeDeep( - ...dictionaries: T - ): ExcludeNone> - - export function removeKey( - dictionary: T, - key: K - ): Omit - - export function removeKeys( - dictionary: T, - ...keys: K[] - ): Omit - - export function removeValue( - dictionary: T, - value: V - ): ExcludeMembers - - export function removeValues( - dictionary: T, - ...values: V - ): ExcludeMembers - - export function set( - dictionary: T, - key: K, - value: V - ): T & { [key in K]: V } - - export function set( - dictionary: T, - key: K, - value: V - ): T & { [key in K]: V } - - export function some( - dictionary: T, - predicate: (value: T[K], key: K, dictionary: Readonly) => unknown - ): boolean - - export function update< - T extends object, - K extends ObjectKey, - X = TryIndex, - Y = undefined - >( - dictionary: T, - key: K, - updater?: (value: TryIndex, key: K) => X, - callback?: (key: K) => Y - ): (TryIndex extends undefined - ? { - [key in keyof T]: key extends K ? X : T[key] - } - : { - [key in keyof T]: key extends K ? Y : T[key] - }) & { [key in K]: X } - - export function values(dictionary: T): T[keyof T][] - - export function withKeys( - dictionary: T, - ...keys: K[] - ): Pick - - // Aliases - export { merge as join, mergeDeep as joinDeep } -} - -export = SiftDictionary diff --git a/@types/Set.d.ts b/@types/Set.d.ts deleted file mode 100644 index 843a702..0000000 --- a/@types/Set.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { AnySet } from "./Util" - -declare namespace SiftSet { - export function add(set: Set, ...values: I[]): Set - - export function copy(set: T): T - - export function count>( - set: S, - predicate?: (item: T) => unknown - ): number - - export function difference(set: Set, ...sets: Set[]): Set - - export function differenceSymmetric(set: Set, ...sets: Set[]): Set - - export function filter>( - set: S, - predicate: (item: T, set: Readonly) => unknown - ): Set - - export function fromArray(array: T[]): Set - - export function has(set: AnySet, item: unknown): boolean - - export function intersection(...sets: Set[]): Set - - export function isSubset( - subset: A, - superset: B - ): boolean - - export function isSuperset( - superset: A, - subset: B - ): boolean - - export function map>( - set: S, - mapper: (item: T, set: Readonly) => R - ): Set - - export function merge(...sets: Set[]): Set - - export function subtract(set: S, ...values: unknown[]): S - - export function toArray(set: Set): T[] - - // Aliases - export { merge as join, merge as union, subtract as delete } -} - -export = SiftSet diff --git a/@types/Util.d.ts b/@types/Util.d.ts deleted file mode 100644 index e2d8c0a..0000000 --- a/@types/Util.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -export type SiftNone = { readonly __none__: unique symbol } -export type ExcludeNone = Exclude -export type ObjectKey = string | number | symbol -export type AnySet = Set - -export type FromEntries = { - [P in T[number][0]]: Extract[1] -} - -export type ReadonlyDeep = T extends (infer U)[] - ? ReadonlyDeepArray - : T extends Callback - ? T - : T extends object - ? ReadonlyDeepObject - : T - -export type ObjectFromKeyValueArrays< - Keys extends Array, - Values extends Array -> = ObjectFromKeyValuePairs> - -export type ReplaceType = F extends T ? Exclude | R : T - -export type TryIndex = K extends keyof T ? T[K] : undefined - -interface ReadonlyDeepArray extends ReadonlyArray> {} - -type ReadonlyDeepObject = { - readonly [P in keyof T]: ReadonlyDeep -} - -type KeyValuePairsFromLists< - Keys extends Array, - Values extends Array -> = { - [index in keyof Keys]: index extends keyof Values - ? [Keys[index], Values[index]] - : never -} - -type ObjectFromKeyValuePairs< - KV extends [ObjectKey, any][], - T = { - [index in keyof KV]: KV[index] extends [ObjectKey, any] - ? Record - : never - } -> = UnionToIntersection diff --git a/@types/index.d.ts b/@types/index.d.ts deleted file mode 100644 index 05946dc..0000000 --- a/@types/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { SiftNone } from "./Util" - -import SiftArray from "./Array" -import SiftDictionary from "./Dictionary" -import SiftSet from "./Set" - -declare namespace Sift { - export const None: SiftNone - export type None = SiftNone - - export { - SiftArray as Array, - SiftArray as List, - SiftDictionary as Dictionary, - SiftSet as Set, - } -} - -export = Sift diff --git a/README.md b/README.md index bb2b1a8..90e3175 100644 --- a/README.md +++ b/README.md @@ -100,28 +100,3 @@ As per the recommendations in [Llama's README][freddylist/llama], the following - Organised tests. `*.spec` files are now alongside their source files, making it easier to locate them. - Documentation is now generated using [@upliftgames' moonwave][upliftgames/moonwave] (Docusaurus). This makes it quick and easy to add new documentation, and provides a pleasant experience for the user. - Built-in TypeScript typings. - -## What's New? - -### Arrays (Lists) - -- `at`: Get an element at a specific index (negative indices are supported). -- `difference`: Returns an array of values that are in the first array, but not in the other arrays. -- `differenceSymmetric`: Returns an array of values that are in the first array, but not in the other arrays, and vice versa. -- `freeze`: Freeze an array. -- `freezeDeep`: Freeze an array and all nested arrays. -- `is`: Check if the passed value is an array. -- `shuffle`: Shuffle the elements of an array to a random order. - -### Dictionaries - -- `entries`: Get the entries of a dictionary as an array of key-value pairs. -- `freeze`: Freeze a dictionary. -- `freezeDeep`: Freeze a dictionary and all nested dictionaries. -- `fromEntries`: Create a dictionary from an array of key-value pairs. - -### Sets - -- `count`: Get the number of elements in a set. -- `difference`: Returns a set of values that are in the first set, but not in the other sets. -- `differenceSymmetric`: Returns a set of values that are in the first set, but not in the other sets, and vice versa. diff --git a/docs/Examples.md b/docs/Examples.md deleted file mode 100644 index 2ef92b5..0000000 --- a/docs/Examples.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -sidebar_position: 3 ---- - -Sift contains a number of useful functions for working with data structures. These functions are available as static methods on the Sift module (refer to the [API documentation](/api) for more details). - -```lua -local Sift = require(path.to.Sift) -``` - -Sift also exports Luau types, which can be accessed from the Sift module itself, or via the dedicated Types module, which is exported as `Sift.Types`. - -### Combining Data - -```lua -local dictionary1 = { a = 1, b = 2 } -local dictionary2 = { c = 3, d = 4 } - -local result = Sift.Dictionary.merge(dictionary1, dictionary2) -- { a = 1, b = 2, c = 3, d = 4 } -``` - -```lua -local array1 = { 1, 2, 3 } -local array2 = { 4, 5, 6 } - -local result = Sift.Array.concat(array1, array2) -- { 1, 2, 3, 4, 5, 6 } -``` - -### Filtering Data - -The following example filters out all uneven numbers from an array of numbers. - -```lua -local array = { 1, 2, 3, 4, 5, 6 } - -local result = Sift.Array.filter(array, function(value) - return value % 2 == 0 -end) -- { 2, 4, 6 } -``` - -Dictionaries can also be filtered in Sift! - -```lua -local dictionary = { a = 1, b = 2, c = 3, d = 4 } - -local result = Sift.Dictionary.filter(dictionary, function(value) - return value % 2 == 0 -end) -- { b = 2, d = 4 } -``` - -### Removing Duplicates - -There's a few different methods for removing duplicates from an array or dictionary. - -The following example removes all duplicate values from an array using sets. - -```lua -local array = { "hello", "world", "world", "cat", "dog" } - -local set = Sift.Set.fromArray(array) -- { "hello" = true, "world" = true, "cat" = true, "dog" = true } - -local result = Sift.Set.toArray(set) -- { "hello", "world", "cat", "dog" } -``` - -The same could also be accomplished using a reducer. - -```lua -local array = { "hello", "world", "world", "cat", "dog" } - -local result = Sift.Array.reduce(array, function(accumulator, value) - if not Sift.Array.includes(accumulator, value) then - return Sift.Array.push(accumulator, value) - end - - return accumulator -end, {}) -- { "hello", "world", "cat", "dog" } -``` diff --git a/docs/Installation.md b/docs/Installation.md deleted file mode 100644 index 1756841..0000000 --- a/docs/Installation.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -sidebar_position: 2 ---- - - - -[sift]: https://github.com/cxmeel/sift -[sift/releases]: https://github.com/cxmeel/sift/releases -[sift/wally]: https://wally.run/package/cxmeel/sift -[sift/roblox]: https://www.roblox.com/library/9486684823 -[sift/itch.io]: https://cxmeel.itch.io/sift -[sift/npm]: https://npmjs.com/package/@rbxts/sift - -Sift is available from [Wally][sift/wally], [Itch.io][sift/itch.io], the [Roblox Library][sift/roblox], and [GitHub releases][sift/releases]. - -While Sift is 100% free and open source, if you feel like sponsoring, Sift is also available on [Itch.io][sift/itch.io]. - -### Wally - -Wally is a CLI package manager (much like NPM, Yarn or Cargo) for Roblox by @UpliftGames. Find out more at https://github.com/upliftgames/wally. - -```toml -# wally.toml - -[dependencies] -Sift = "cxmeel/sift@=0.0.1" -``` - -```shell -$ wally install -``` - -### TypeScript - -v0.0.1 of Sift includes TypeScript definitions. This means Sift is now compatible with roblox-ts. Refer to the Luau docs for API details. - -```shell -$ npm install @rbxts/sift -``` - -[View on NPM →][sift/npm] - -```ts -// example.ts -import Sift from "@rbxts/sift" - -Sift.Dictionary.merge({ a: 1, c: 2 }, { b: 3, c: Sift.None }) // { a: 1, b: 3 } -``` - -Alternatively, you can use tree-shaking to access the modules directly. - -```ts -// example.ts -import { Dictionary, None } from "@rbxts/sift" - -Dictionary.merge({ a: 1, c: 2 }, { b: 3, c: None }) // { a: 1, b: 3 } -``` - -### Manual Installation - -Grab a copy [from the Roblox Library][sift/roblox] or [GitHub releases][sift/releases], and drop it into Studio. The Sift model file can be synced in using Rojo. diff --git a/package.json b/package.json index 9591aca..4b791aa 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,16 @@ { "name": "@rbxts/sift", - "version": "0.0.8", + "version": "0.1.0", "description": "Immutable data library for Luau", "main": "out/init.lua", - "types": "out/index.d.ts", + "types": "@types/index.d.ts", "publishConfig": { "access": "public" }, "scripts": { "build": "rbxtsc --type=package --rojo=''", "watch": "rbxtsc -w", - "prepublishOnly": "npm run build", - "prepare": "husky install" + "prepublishOnly": "npm run build" }, "repository": { "type": "git", diff --git a/sourcemap.json b/sourcemap.json deleted file mode 100644 index a41e6c4..0000000 --- a/sourcemap.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"Sift","className":"ModuleScript","filePaths":["src\\init.luau","default.project.json"],"children":[{"name":"Array","className":"ModuleScript","filePaths":["src\\Array\\init.luau"],"children":[{"name":"concatDeep","className":"ModuleScript","filePaths":["src\\Array\\concatDeep.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Array\\copy.luau"]},{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Array\\copyDeep.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Array\\count.luau"]},{"name":"create","className":"ModuleScript","filePaths":["src\\Array\\create.luau"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Array\\difference.luau"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Array\\differenceSymmetric.luau"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Array\\equals.luau"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Array\\equalsDeep.luau"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Array\\every.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Array\\filter.luau"]},{"name":"find","className":"ModuleScript","filePaths":["src\\Array\\find.luau"]},{"name":"findLast","className":"ModuleScript","filePaths":["src\\Array\\findLast.luau"]},{"name":"findWhere","className":"ModuleScript","filePaths":["src\\Array\\findWhere.luau"]},{"name":"findWhereLast","className":"ModuleScript","filePaths":["src\\Array\\findWhereLast.luau"]},{"name":"first","className":"ModuleScript","filePaths":["src\\Array\\first.luau"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Array\\flatten.luau"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Array\\freeze.luau"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Array\\freezeDeep.luau"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Array\\includes.luau"]},{"name":"insert","className":"ModuleScript","filePaths":["src\\Array\\insert.luau"]},{"name":"is","className":"ModuleScript","filePaths":["src\\Array\\is.luau"]},{"name":"last","className":"ModuleScript","filePaths":["src\\Array\\last.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Array\\map.luau"]},{"name":"pop","className":"ModuleScript","filePaths":["src\\Array\\pop.luau"]},{"name":"push","className":"ModuleScript","filePaths":["src\\Array\\push.luau"]},{"name":"reduce","className":"ModuleScript","filePaths":["src\\Array\\reduce.luau"]},{"name":"reduceRight","className":"ModuleScript","filePaths":["src\\Array\\reduceRight.luau"]},{"name":"removeIndex","className":"ModuleScript","filePaths":["src\\Array\\removeIndex.luau"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Array\\removeValues.luau"]},{"name":"reverse","className":"ModuleScript","filePaths":["src\\Array\\reverse.luau"]},{"name":"slice","className":"ModuleScript","filePaths":["src\\Array\\slice.luau"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Array\\update.luau"]},{"name":"zip","className":"ModuleScript","filePaths":["src\\Array\\zip.luau"]},{"name":"zipAll","className":"ModuleScript","filePaths":["src\\Array\\zipAll.luau"]},{"name":"at","className":"ModuleScript","filePaths":["src\\Array\\at.luau"]},{"name":"concat","className":"ModuleScript","filePaths":["src\\Array\\concat.luau"]},{"name":"removeIndices","className":"ModuleScript","filePaths":["src\\Array\\removeIndices.luau"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Array\\removeValue.luau"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Array\\set.luau"]},{"name":"shift","className":"ModuleScript","filePaths":["src\\Array\\shift.luau"]},{"name":"shuffle","className":"ModuleScript","filePaths":["src\\Array\\shuffle.luau"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Array\\some.luau"]},{"name":"sort","className":"ModuleScript","filePaths":["src\\Array\\sort.luau"]},{"name":"splice","className":"ModuleScript","filePaths":["src\\Array\\splice.luau"]},{"name":"toSet","className":"ModuleScript","filePaths":["src\\Array\\toSet.luau"]},{"name":"unshift","className":"ModuleScript","filePaths":["src\\Array\\unshift.luau"]}]},{"name":"Dictionary","className":"ModuleScript","filePaths":["src\\Dictionary\\init.luau"],"children":[{"name":"copyDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\copyDeep.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Dictionary\\count.luau"]},{"name":"entries","className":"ModuleScript","filePaths":["src\\Dictionary\\entries.luau"]},{"name":"equals","className":"ModuleScript","filePaths":["src\\Dictionary\\equals.luau"]},{"name":"equalsDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\equalsDeep.luau"]},{"name":"every","className":"ModuleScript","filePaths":["src\\Dictionary\\every.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Dictionary\\filter.luau"]},{"name":"flatten","className":"ModuleScript","filePaths":["src\\Dictionary\\flatten.luau"]},{"name":"flip","className":"ModuleScript","filePaths":["src\\Dictionary\\flip.luau"]},{"name":"freeze","className":"ModuleScript","filePaths":["src\\Dictionary\\freeze.luau"]},{"name":"freezeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\freezeDeep.luau"]},{"name":"fromArrays","className":"ModuleScript","filePaths":["src\\Dictionary\\fromArrays.luau"]},{"name":"fromEntries","className":"ModuleScript","filePaths":["src\\Dictionary\\fromEntries.luau"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Dictionary\\has.luau"]},{"name":"includes","className":"ModuleScript","filePaths":["src\\Dictionary\\includes.luau"]},{"name":"keys","className":"ModuleScript","filePaths":["src\\Dictionary\\keys.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Dictionary\\map.luau"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Dictionary\\merge.luau"]},{"name":"mergeDeep","className":"ModuleScript","filePaths":["src\\Dictionary\\mergeDeep.luau"]},{"name":"removeKey","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKey.luau"]},{"name":"removeKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\removeKeys.luau"]},{"name":"removeValue","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValue.luau"]},{"name":"removeValues","className":"ModuleScript","filePaths":["src\\Dictionary\\removeValues.luau"]},{"name":"set","className":"ModuleScript","filePaths":["src\\Dictionary\\set.luau"]},{"name":"some","className":"ModuleScript","filePaths":["src\\Dictionary\\some.luau"]},{"name":"update","className":"ModuleScript","filePaths":["src\\Dictionary\\update.luau"]},{"name":"values","className":"ModuleScript","filePaths":["src\\Dictionary\\values.luau"]},{"name":"withKeys","className":"ModuleScript","filePaths":["src\\Dictionary\\withKeys.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Dictionary\\copy.luau"]}]},{"name":"Set","className":"ModuleScript","filePaths":["src\\Set\\init.luau"],"children":[{"name":"add","className":"ModuleScript","filePaths":["src\\Set\\add.luau"]},{"name":"copy","className":"ModuleScript","filePaths":["src\\Set\\copy.luau"]},{"name":"count","className":"ModuleScript","filePaths":["src\\Set\\count.luau"]},{"name":"delete","className":"ModuleScript","filePaths":["src\\Set\\delete.luau"]},{"name":"difference","className":"ModuleScript","filePaths":["src\\Set\\difference.luau"]},{"name":"differenceSymmetric","className":"ModuleScript","filePaths":["src\\Set\\differenceSymmetric.luau"]},{"name":"filter","className":"ModuleScript","filePaths":["src\\Set\\filter.luau"]},{"name":"fromArray","className":"ModuleScript","filePaths":["src\\Set\\fromArray.luau"]},{"name":"has","className":"ModuleScript","filePaths":["src\\Set\\has.luau"]},{"name":"intersection","className":"ModuleScript","filePaths":["src\\Set\\intersection.luau"]},{"name":"isSubset","className":"ModuleScript","filePaths":["src\\Set\\isSubset.luau"]},{"name":"isSuperset","className":"ModuleScript","filePaths":["src\\Set\\isSuperset.luau"]},{"name":"map","className":"ModuleScript","filePaths":["src\\Set\\map.luau"]},{"name":"merge","className":"ModuleScript","filePaths":["src\\Set\\merge.luau"]},{"name":"toArray","className":"ModuleScript","filePaths":["src\\Set\\toArray.luau"]}]},{"name":"Util","className":"ModuleScript","filePaths":["src\\Util\\init.luau"],"children":[{"name":"equalObjects","className":"ModuleScript","filePaths":["src\\Util\\equalObjects.luau"]},{"name":"func","className":"ModuleScript","filePaths":["src\\Util\\func.luau"]},{"name":"isEmpty","className":"ModuleScript","filePaths":["src\\Util\\isEmpty.luau"]}]},{"name":"Types","className":"ModuleScript","filePaths":["src\\Types.luau"]},{"name":"None","className":"ModuleScript","filePaths":["src\\None.luau"]}]} \ No newline at end of file diff --git a/src/Array/at.luau b/src/Array/at.luau index b7cdbd5..dbe90fc 100644 --- a/src/Array/at.luau +++ b/src/Array/at.luau @@ -1,26 +1,19 @@ ---!strict --[=[ - @function at - @within Array + @within Array - @param array {T} -- The array to get the value from. - @param index number -- The index to get the value from (can be negative). - @return T -- The value at the given index. + Pick out a value from an array by index, with support for negative indices. + Negative indices are counted from the end of the array. Because Lua uses 1-based indexing, an index of 0 will be treated as 1. - Gets a value from an array at the given index. - - ```lua - local array = { 1, 2, 3 } - - local value = At(array, 1) -- 1 - local value = At(array, 0) -- 3 - ``` + ```lua + at({ "a", "b", "c", "d", "e" }, 2) -- "b" + at({ "a", "b", "c", "d", "e" }, -1) -- "e" + ``` ]=] local function at(array: { T }, index: number): T - local length = #array - - if index < 1 then - index += length + if index == 0 then + index = 1 + elseif index < 0 then + index += #array + 1 end return array[index] diff --git a/src/Array/concat.luau b/src/Array/concat.luau index 76e8abb..1808944 100644 --- a/src/Array/concat.luau +++ b/src/Array/concat.luau @@ -1,46 +1,25 @@ ---!strict -local Sift = script.Parent.Parent - -local None = require(Sift.None) - --[=[ - @function concat - @within Array - - @param ... ...any -- The arrays to concatenate. - @return {T} -- The concatenated array. - - Joins multiple arrays together into a single array. + @within Array - #### Aliases + Concatenates the elements of the given arrays into a new array. - `join`, `merge` + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 4, 5, 6 } - ```lua - local table1 = { 1, 2, 3 } - local table2 = { 4, 5, 6 } - - local new = Concat(table1, table2) -- { 1, 2, 3, 4, 5, 6 } - ``` + concat(array1, array2) -- {1, 2, 3, 4, 5, 6} + ``` ]=] -local function concat(...: any): { T } - local result = {} - - for arrayIndex = 1, select("#", ...) do - local array = select(arrayIndex, ...) - - if type(array) ~= "table" then - continue - end +local function concat(...: { T }) + local out = {} - for _, item in ipairs(array) do - if item ~= None then - table.insert(result, item) - end + for _, array in { ... } do + for _, value in array do + table.insert(out, value) end end - return result + return out end return concat diff --git a/src/Array/concatDeep.luau b/src/Array/concatDeep.luau deleted file mode 100644 index 519b4f2..0000000 --- a/src/Array/concatDeep.luau +++ /dev/null @@ -1,52 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local CopyDeep = require(script.Parent.copyDeep) -local None = require(Sift.None) - ---[=[ - @function concatDeep - @within Array - - @param ... ...any -- The arrays to concatenate. - @return {T} -- The concatenated array. - - Joins multiple arrays together into a single array, with deep copies of all - nested arrays. - - #### Aliases - - `joinDeep`, `mergeDeep` - - ```lua - local table1 = { 1, 2, { 3, 4 } } - local table2 = { 5, 6, { 7, 8 } } - - local new = ConcatDeep(table1, table2) -- { 1, 2, { 3, 4 }, 5, 6, { 7, 8 } } - ``` -]=] -local function concatDeep(...: any): { T } - local result = {} - - for arrayIndex = 1, select("#", ...) do - local array = select(arrayIndex, ...) - - if type(array) ~= "table" then - continue - end - - for _, value in ipairs(array) do - if value ~= None then - if type(value) == "table" then - table.insert(result, CopyDeep(value)) - else - table.insert(result, value) - end - end - end - end - - return result -end - -return concatDeep diff --git a/src/Array/copy.luau b/src/Array/copy.luau index bc31cc6..49a14f7 100644 --- a/src/Array/copy.luau +++ b/src/Array/copy.luau @@ -1,19 +1,13 @@ ---!strict --[=[ - @function copy - @within Array + @within Array + @function copy + @param array { T } + @return { T } - @param array {T} -- The array to copy. - @return {T} -- The copied array. + Returns a shallow copy of the array. Use [Array.copyDeep] to copy nested arrays. - Copies an array. - - ```lua - local array = { 1, 2, 3 } - - local new = Copy(array) -- { 1, 2, 3 } - - print(new == array) -- false - ``` + ```lua + copy({ 1, 2, 3 }) -- { 1, 2, 3 } + ``` ]=] return table.clone diff --git a/src/Array/copyDeep.luau b/src/Array/copyDeep.luau index 36ea759..1e4e203 100644 --- a/src/Array/copyDeep.luau +++ b/src/Array/copyDeep.luau @@ -1,32 +1,25 @@ ---!strict --[=[ - @function copyDeep - @within Array + @within Array - @param array {T} -- The array to copy. - @return {T} -- The copied array. + Returns a deep copy of the given array. This means that all tables within the array are also copied. - Copies an array, with deep copies of all nested arrays. - - ```lua - local array = { 1, 2, 3, { 4, 5 } } - - local result = CopyDeep(array) -- { 1, 2, 3, { 4, 5 } } - - print(result == array) -- false - print(result[4] == array[4]) -- false - ``` + ```lua + local array = {{ 1, 2 }, { 3, 4 }} + copyDeep(array) -- {{ 1, 2 }, { 3, 4 }} + ``` ]=] local function copyDeep(array: { T }): { T } - local result = table.clone(array) + local out: any = {} - for index, value in array do - if type(value) == "table" then - result[index] = copyDeep(value) :: any + for _, value in array do + if typeof(value) == "table" then + table.insert(out, copyDeep(value)) + else + table.insert(out, value) end end - return result + return out end return copyDeep diff --git a/src/Array/count.luau b/src/Array/count.luau index ae569fc..4c63418 100644 --- a/src/Array/count.luau +++ b/src/Array/count.luau @@ -1,38 +1,23 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - --[=[ - @function count - @within Array + @within Array - @param array {T} -- The array to count the number of items in. - @param predicate? (value: T, index: number, array: {T}) -> any -- The predicate to use to filter the array. - @return number -- The number of items in the array. + Returns the number of elements in the array, optionally filtered by a predicate. - Counts the number of items in an array. + ```lua + local array = { 1, 2, 3, 4, 5 } - ```lua - local array = { 1, 2, 3 } - - local value = Count(array) -- 3 - local value = Count(array, function(item, index) - return item == 2 - end) -- 1 - ``` + count(array) -- 5 + count(array, function(value) + return value > 3 + end) -- 2 + ``` ]=] -local function count( - array: { T }, - predicate: ((value: T, index: number, array: { T }) -> any)? -): number +local function count(array: { T }, predicate: ((value: T, index: number) -> boolean)?): number local counter = 0 - predicate = if type(predicate) == "function" then predicate else Util.func.truthy - - for index, value in ipairs(array) do - if predicate(value, index, array) then - counter += 1 + for index, value in array do + if not predicate or predicate(value, index) then + counter = counter + 1 end end diff --git a/src/Array/create.luau b/src/Array/create.luau index b6e081c..0071060 100644 --- a/src/Array/create.luau +++ b/src/Array/create.luau @@ -1,19 +1,15 @@ ---!strict --[=[ - @function create - @within Array - - @param length number -- The length of the array to create. - @param value? T -- The value to fill the array with. - @return {T} -- The created array. - - Creates an array of the given length, filled with the given value. - This is just a wrapper around `table.create`. - - ```lua - local array = Create(3, "Hello") - - print(array) -- { "Hello", "Hello", "Hello" } - ``` + @within Array + @function create + @param count number + @param value T? + @return { T } + + Creates a new array with `count` elements, each initialized to `value`. + + ```lua + create(3) -- { nil, nil, nil } + create(3, true) -- { true, true, true } + ``` ]=] return table.create diff --git a/src/Array/difference.luau b/src/Array/difference.luau deleted file mode 100644 index 90c5ab5..0000000 --- a/src/Array/difference.luau +++ /dev/null @@ -1,42 +0,0 @@ ---!strict -local T = require(script.Parent.Parent.Types) - -local toSet = require(script.Parent.toSet) -local toArray = require(script.Parent.Parent.Set.toArray) -local setDifference = require(script.Parent.Parent.Set.difference) - ---[=[ - @function difference - @within Array - - @param array Array -- The array to compare. - @param ... ...Array -- The arrays to compare against. - @return Array -- The difference between the arrays. - - Returns an array of values that are in the first array, but not in the other arrays. - - ```lua - local array1 = { "hello", "world" } - local array2 = { "cat", "dog", "hello" } - - local difference = Difference(array1, array2) -- { "world" } - ``` -]=] -local function difference(array: T.Array, ...: T.Array): T.Array - local arraySet = toSet(array) - local otherSets = {} - - for _, nextArray in { ... } do - if typeof(nextArray) ~= "table" then - continue - end - - table.insert(otherSets, toSet(nextArray)) - end - - local differenceSet = setDifference(arraySet, unpack(otherSets)) - - return toArray(differenceSet) -end - -return difference diff --git a/src/Array/difference.luau.todo b/src/Array/difference.luau.todo new file mode 100644 index 0000000..6c399e6 --- /dev/null +++ b/src/Array/difference.luau.todo @@ -0,0 +1 @@ +requires sets diff --git a/src/Array/differenceSymmetric.luau b/src/Array/differenceSymmetric.luau deleted file mode 100644 index 54e358b..0000000 --- a/src/Array/differenceSymmetric.luau +++ /dev/null @@ -1,42 +0,0 @@ ---!strict -local T = require(script.Parent.Parent.Types) - -local toSet = require(script.Parent.toSet) -local toArray = require(script.Parent.Parent.Set.toArray) -local setDifferenceSymmetric = require(script.Parent.Parent.Set.differenceSymmetric) - ---[=[ - @function differenceSymmetric - @within Array - - @param array Array -- The array to compare. - @param ... ...Array -- The arrays to compare against. - @return Array -- The symmetric difference between the arrays. - - Returns an array of values that are in the first array, but not in the other arrays, and vice versa. - - ```lua - local array1 = { "hello", "world" } - local array2 = { "cat", "dog", "hello" } - - local difference = DifferenceSymmetric(array1, array2) -- { "world", "cat", "dog" } - ``` -]=] -local function differenceSymmetric(array: T.Array, ...: T.Array): T.Array - local arraySet = toSet(array) - local otherSets = {} - - for _, nextArray in { ... } do - if typeof(nextArray) ~= "table" then - continue - end - - table.insert(otherSets, toSet(nextArray)) - end - - local differenceSet = setDifferenceSymmetric(arraySet, unpack(otherSets)) - - return toArray(differenceSet) -end - -return differenceSymmetric diff --git a/src/Array/differenceSymmetric.luau.todo b/src/Array/differenceSymmetric.luau.todo new file mode 100644 index 0000000..6c399e6 --- /dev/null +++ b/src/Array/differenceSymmetric.luau.todo @@ -0,0 +1 @@ +requires sets diff --git a/src/Array/equals.luau b/src/Array/equals.luau index c468d79..02a9bb5 100644 --- a/src/Array/equals.luau +++ b/src/Array/equals.luau @@ -1,21 +1,16 @@ ---!strict -local Sift = script.Parent.Parent +local Util = require("@Sift/Util") -local Util = require(Sift.Util) - -local function compare(a, b) - if type(a) ~= "table" or type(b) ~= "table" then +local function compare(a: any, b: any) + if typeof(a) ~= "table" or typeof(b) ~= "table" then return a == b end - local aLength = #a - - if #b ~= aLength then + if #a ~= #b then return false end - for i = 1, aLength do - if a[i] ~= b[i] then + for index, value in a do + if value ~= b[index] then return false end end @@ -24,35 +19,27 @@ local function compare(a, b) end --[=[ - @function equals - @within Array + @within Array - @param ... ...{any} -- The arrays to compare. - @return boolean -- Whether the arrays are equal. + Returns whether or not all of the given arrays are equal to each other. - Compares two arrays for equality. + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 1, 2, 3 } - ```lua - local array = { 1, 2, 3 } - local other = { 1, 2, 3 } - - local value = Equals(array, other) -- true - local value = Equals(array, other, { 1, 2, 3 }) -- true - local value = Equals(array, other, { 1, 2, 4 }) -- false - ``` + equals(array1, array2) -- true + ``` ]=] -local function equals(...: { T }): boolean - if Util.equalObjects(...) then +local function equals(...: any): boolean + if Util.areEqual(...) then return true end - local totalArgs = select("#", ...) - local firstItem = select(1, ...) - - for i = 2, totalArgs do - local item = select(i, ...) + local args = { ... } + local first = table.remove(args, 1) - if not compare(firstItem, item) then + for _, array in args do + if not compare(first, array) then return false end end diff --git a/src/Array/equalsDeep.luau b/src/Array/equalsDeep.luau index 3e8225a..7fa3628 100644 --- a/src/Array/equalsDeep.luau +++ b/src/Array/equalsDeep.luau @@ -1,21 +1,16 @@ ---!strict -local Sift = script.Parent.Parent +local Util = require("@Sift/Util") -local Util = require(Sift.Util) - -local function compareDeep(a, b) - if type(a) ~= "table" or type(b) ~= "table" then +local function compare(a: any, b: any) + if typeof(a) ~= "table" or typeof(b) ~= "table" then return a == b end - local aLength = #a - - if #b ~= aLength then + if #a ~= #b then return false end - for i = 1, aLength do - if not compareDeep(a[i], b[i]) then + for index, value in a do + if not compare(value, b[index]) then return false end end @@ -24,35 +19,27 @@ local function compareDeep(a, b) end --[=[ - @function equalsDeep - @within Array + @within Array - @param ... ...{any} -- The arrays to compare. - @return boolean -- Whether the arrays are equal. + Returns whether or not all of the provided values are deeply equal to each other. Use this function to compare nested arrays. - Compares two arrays for equality using deep comparison. + ```lua + local array1 = {{ 1, 2 }, { 3, 4 }} + local array2 = {{ 1, 2 }, { 4, 5 }} - ```lua - local array = { 1, 2, 3, { 4, 5 } } - local other = { 1, 2, 3, { 4, 5 } } - - local value = EqualsDeep(array, other) -- true - local value = EqualsDeep(array, other, { 1, 2, 3, { 4, 5 } }) -- true - local value = EqualsDeep(array, other, { 1, 2, 3, { 4, 6 } }) -- false - ``` + equalsDeep(array1, array2) -- false + ``` ]=] -local function equalsDeep(...: { T }): boolean - if Util.equalObjects(...) then +local function equalsDeep(...: any): boolean + if Util.areEqual(...) then return true end - local totalArgs = select("#", ...) - local firstItem = select(1, ...) - - for i = 2, totalArgs do - local item = select(i, ...) + local args = { ... } + local first = table.remove(args, 1) - if not compareDeep(firstItem, item) then + for _, value in args do + if not compare(first, value) then return false end end diff --git a/src/Array/every.luau b/src/Array/every.luau index d42399e..6548526 100644 --- a/src/Array/every.luau +++ b/src/Array/every.luau @@ -1,32 +1,17 @@ ---!strict --[=[ - @function every - @within Array + @within Array - @param array {T} -- The array to check. - @param predicate (value: T, index: number, array: {T}) -> any -- The predicate to use to check the array. - @return boolean -- Whether every item in the array passes the predicate. + Returns `true` if every element in the array passes the test implemented by the provided function. Otherwise, it returns `false`. - Checks whether every item in the array passes the predicate. - - ```lua - local array = { 1, 2, 3 } - - local value = Every(array, function(item, index) - return item > 0 - end) -- true - - local value = Every(array, function(item, index) - return item > 1 - end) -- false - ``` + ```lua + every({ 1, 2, 3, 4, 5 }, function(value) + return value > 0 + }) -- true + ``` ]=] -local function every( - array: { T }, - predicate: (value: T, index: number, array: { T }) -> any -): boolean - for index, value in ipairs(array) do - if not predicate(value, index, array) then +local function every(array: { T }, predicate: (value: T, index: number) -> boolean): boolean + for index, value in array do + if not predicate(value, index) then return false end end diff --git a/src/Array/filter.luau b/src/Array/filter.luau index 877b98c..cdbb1ca 100644 --- a/src/Array/filter.luau +++ b/src/Array/filter.luau @@ -1,43 +1,23 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - --[=[ - @function filter - @within Array - - @param array {T} -- The array to filter. - @param filterer? (value: T, index: number, array: {T}) -> any -- The callback to use to filter the array. - @return {T} -- The filtered array. + @within Array - Filters an array using a filterer callback. Any items that do not pass the filterer will be removed from the array. + Filters out elements from an array based on a filter function. The filter function should return `true` to keep the element, and `false` to remove it. - If no filterer is provided, all items will be kept. - - ```lua - local array = { 1, 2, 3 } - - local result = Filter(array, function(item, index) - return item > 1 - end) -- { 2, 3 } - ``` + ```lua + filter({ 1, 2, 3, 4, 5}, function(value) + return value > 3 + end) -- { 4, 5 } ]=] -local function filter( - array: { T }, - predicate: ((value: T, index: number, array: { T }) -> boolean?)? -): { T } - local result = {} - - predicate = if type(predicate) == "function" then predicate else Util.func.truthy +local function filter(array: { T }, filterer: (value: T, index: number) -> boolean): { T } + local out = {} - for index, value in ipairs(array) do - if predicate(value, index, array) then - table.insert(result, value) + for index, value in array do + if filterer(value, index) then + table.insert(out, value) end end - return result + return out end return filter diff --git a/src/Array/find.luau b/src/Array/find.luau index 5bca288..209d0f5 100644 --- a/src/Array/find.luau +++ b/src/Array/find.luau @@ -1,31 +1,22 @@ ---!strict --[=[ - @function find - @within Array + @within Array - @param array {T} -- The array to search. - @param value? any -- The value to search for. - @param from? number -- The index to start searching from. - @return number? -- The index of the first item in the array that matches the value. + Returns the index of the first occurrence of a value in an array, or `nil` if the value is not found. The search starts at the optional `from` index. If `from` is negative, it is treated as an offset from the end of the array. - Finds the index of the first item in the array that matches the value. This is - mostly a wrapper around `table.find`, with the ability to specify a negative - number as the start index (to search relative to the end of the array). + ```lua + local array = { "a", "b", "c", "a", "b" } - #### Aliases - `indexOf` - - ```lua - local array = { "hello", "world", "hello" } - - local index = Find(array, "hello") -- 1 - local index = Find(array, "hello", 2) -- 3 - ``` + find(array, "a") -- 1 + find(array, "a", 2) -- 4 + find(array, "b", -2) -- 5 + ``` ]=] -local function find(array: { T }, value: any?, from: number?): number? - local length = #array - - from = if type(from) == "number" then if from < 1 then length + from else from else 1 +local function find(array: { T }, value: T, from: number?): number? + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end return table.find(array, value, from) end diff --git a/src/Array/findLast.luau b/src/Array/findLast.luau index 5755fda..f294068 100644 --- a/src/Array/findLast.luau +++ b/src/Array/findLast.luau @@ -1,34 +1,30 @@ ---!strict --[=[ - @function findLast - @within Array + @within Array - @param array {T} -- The array to search. - @param value? any -- The value to search for. - @param from? number -- The index to start searching from. - @return number? -- The index of the last item in the array that matches the value. + Returns the last index at which a given element can be found in the array, or `nil` if it is not present. The array is searched backwards, starting at the optional `from` index. If `from` is negative, it is used as the offset from the end of the array. - Finds the index of the last item in the array that matches the value. + ```lua + local array = { "a", "b", "c", "a", "b" } - ```lua - local array = { "hello", "world", "hello" } - - local index = FindLast(array, "hello") -- 3 - local index = FindLast(array, "hello", 2) -- 1 - ``` + findLast(array, "b") -- 5 + findLast(array, "b", 3) -- 2 + findLast(array, "b", -3) -- 2 + ``` ]=] -local function findLast(array: { T }, value: any?, from: number?): number? - local length = #array - - from = if type(from) == "number" then if from < 1 then length + from else from else length +local function findLast(array: { T }, value: T, from: number?): number? + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for index = from, 1, -1 do - if array[index] == value then - return index + for i = from or #array, 1, -1 do + if array[i] == value then + return i end end - return + return nil end return findLast diff --git a/src/Array/findWhere.luau b/src/Array/findWhere.luau index a48be9c..4387895 100644 --- a/src/Array/findWhere.luau +++ b/src/Array/findWhere.luau @@ -1,39 +1,32 @@ ---!strict --[=[ - @function findWhere - @within Array + @within Array - @param array {T} -- The array to search. - @param predicate (value: T, index: number, array: {T}) -> any -- The predicate to use to check the array. - @param from? number -- The index to start searching from. - @return number -- The index of the first item in the array that matches the predicate. + Returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns `nil`. - Finds the index of the first item in the array that passes the predicate. - - ```lua - local array = { 1, 2, 3 } - - local index = FindWhere(array, function(item, index) - return item > 1 - end) -- 2 - ``` + ```lua + findWhere({ 1, 2, 3, 4, 5 }, function(value) + return value % 2 == 0 + end) -- 2 + ``` ]=] local function findWhere( array: { T }, - predicate: (value: T, index: number, array: { T }) -> any, + predicate: (value: T, index: number) -> boolean, from: number? ): number? - local length = #array - - from = if type(from) == "number" then if from < 1 then length + from else from else 1 + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for index = from, #array do - if predicate(array[index], index, array) then + for index = from or 1, #array do + if predicate(array[index], index) then return index end end - return + return nil end return findWhere diff --git a/src/Array/findWhereLast.luau b/src/Array/findWhereLast.luau index aff4c38..d051972 100644 --- a/src/Array/findWhereLast.luau +++ b/src/Array/findWhereLast.luau @@ -1,43 +1,32 @@ ---!strict --[=[ - @function findWhereLast - @within Array + @within Array - @param array {T} -- The array to search. - @param predicate (value: T, index: number, array: {T}) -> any -- The predicate to use to check the array. - @param from? number -- The index to start searching from. - @return number -- The index of the last item in the array that matches the predicate. + Returns the index of the last element in the array that satisfies the provided testing function. Otherwise, it returns `nil`. - Finds the index of the last item in the array that passes the predicate. - - ```lua - local array = { "hello", "world", "hello" } - - local index = FindWhereLast(array, function(item, index) - return item == "hello" - end) -- 3 - - local index = FindWhereLast(array, function(item, index) - return item == "hello" - end, 2) -- 1 - ``` + ```lua + findWhereLast({ 1, 2, 3, 4, 5 }, function(value) + return value % 2 == 0 + end) -- 4 + ``` ]=] local function findWhereLast( array: { T }, - predicate: (value: T, index: number, array: { T }) -> any, + predicate: (value: T, index: number) -> boolean, from: number? ): number? - local length = #array - - from = if type(from) == "number" then if from < 1 then length + from else from else length + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for index = from, 1, -1 do - if predicate(array[index], index, array) then + for index = from or #array, 1, -1 do + if predicate(array[index], index) then return index end end - return + return nil end return findWhereLast diff --git a/src/Array/first.luau b/src/Array/first.luau index 84304b4..b992f48 100644 --- a/src/Array/first.luau +++ b/src/Array/first.luau @@ -1,23 +1,16 @@ ---!strict -local At = require(script.Parent.at) +local at = require("./at") --[=[ - @function first - @within Array + @within Array - @param array {T} -- The array to get the first item from. - @return T -- The first item in the array. + Returns the first element of an array. - Gets the first item in the array. - - ```lua - local array = { 1, 2, 3 } - - local value = First(array) -- 1 - ``` + ```lua + first({ "a", "b", "c" }) -- "a" + ``` ]=] local function first(array: { T }): T - return At(array, 1) + return at(array, 1) end return first diff --git a/src/Array/flatten.luau b/src/Array/flatten.luau index cf5b561..88aaa2a 100644 --- a/src/Array/flatten.luau +++ b/src/Array/flatten.luau @@ -1,44 +1,37 @@ ---!strict +local INF = newproxy(false) + --[=[ - @function flatten - @within Array - - @param array {T} -- The array to flatten. - @param depth? number -- The depth to flatten the array to. - @return {T} -- The flattened array. - - Flattens an array. If depth is not specified, it will flatten - the array as far as it can go. - - ```lua - local array = { - { 1, 2, 3 }, - { 4, 5, 6 }, - { 7, { 8, 9 } }, - } - - local new = Flatten(array) -- { 1, 2, 3, 4, 5, 6, 7, 8, 9 } - local new = Flatten(array, 1) -- { 1, 2, 3, 4, 5, 6, 7, { 8, 9 } } - ``` + @within Array + + Flattens an array of arrays into a single array. The `depth` parameter specifies the depth of the flattening. If `depth` is not specified, the array is flattened as much as possible. + + ```lua + local array = { 1, { 2, 3, { 4, 5 }}, 6 } + + flatten(array) -- { 1, 2, 3, 4, 5, 6 } + flatten(array, 1) -- { 1, 2, 3, { 4, 5 }, 6 } + ``` ]=] local function flatten(array: { T }, depth: number?): { T } - depth = if type(depth) == "number" then depth else math.huge + local withDepth = depth or INF + local out = {} - local result = {} + for _, value in array do + if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flatten(value, useDepth) - for _, value in ipairs(array) do - if type(value) == "table" and depth > 0 then - local nested = flatten(value, depth - 1) - - for _, nestedValue in ipairs(nested) do - table.insert(result, nestedValue) + for _, nestedValue in nested do + table.insert(out, nestedValue) end - else - table.insert(result, value) + + continue end + + table.insert(out, value) end - return result + return out end return flatten diff --git a/src/Array/freeze.luau b/src/Array/freeze.luau index 42963a4..478aebb 100644 --- a/src/Array/freeze.luau +++ b/src/Array/freeze.luau @@ -1,30 +1,21 @@ ---!strict -local Copy = require(script.Parent.copy) +local copy = require("./copy") --[=[ - @function freeze - @within Array + @within Array - @param array {T} -- The array to freeze. - @return {T} -- The frozen array. + Returns a shallow copy of the array that is frozen. This means that the array cannot be modified in any way; i.e. it is read-only. Use [Array.freezeDeep] to freeze nested arrays as well. - Freezes the top level of the array, making it read-only. + ```lua + local frozen = freeze({ "anna", "elsa", "kristoff" }) - ```lua - local array = { 1, 2, 3, { 4, 5, 6 } } - - local new = Freeze(array) - - new[1] = 4 -- error! - new[4][1] = 7 -- still works! - ``` + table.insert(frozen, "olaf") -- error! + frozen[4] = "jorgen" -- error! + frozen[2] = "sven" -- error! + ``` ]=] local function freeze(array: { T }): { T } - local new = Copy(array) - - table.freeze(new) - - return new + local out = copy(array) + return table.freeze(out) end return freeze diff --git a/src/Array/freezeDeep.luau b/src/Array/freezeDeep.luau index 3b63964..8f3bbed 100644 --- a/src/Array/freezeDeep.luau +++ b/src/Array/freezeDeep.luau @@ -1,39 +1,29 @@ ---!strict --[=[ - @function freezeDeep - @within Array + @within Array - @param array {T} -- The array to freeze. - @return {T} -- The frozen array. + Recursively freezes an array and its nested arrays. Using [Array.freeze] will only freeze the top level of the array, leaving nested arrays mutable. - Freezes the entire array, making it read-only, including all - nested arrays. + ```lua + local frozen = freezeDeep({ 1, 2, { 3, 4, { 5, 6 }}}) - ```lua - local array = { 1, 2, 3, { 4, 5, 6 } } - - local new = FreezeDeep(array) - - new[1] = 4 -- error! - new[4][1] = 7 -- error! - ``` + frozen[1] = 2 -- error! + frozen[3][1] = 4 -- error! ]=] local function freezeDeep(array: { T }): { T } - local result = {} + local out: { T } = {} - for i = 1, #array do - local value = array[i] + for _, value in array do + if typeof(value) == "table" then + local nested: any = freezeDeep(value) + table.insert(out, nested) - if type(value) == "table" then - table.insert(result, freezeDeep(value)) - else - table.insert(result, value) + continue end - end - table.freeze(result) + table.insert(out, value) + end - return result + return table.freeze(out) end return freezeDeep diff --git a/src/Array/includes.luau b/src/Array/includes.luau index 7683ec9..e63b46d 100644 --- a/src/Array/includes.luau +++ b/src/Array/includes.luau @@ -1,32 +1,16 @@ ---!strict -local Find = require(script.Parent.find) +local find = require("./find") --[=[ - @function includes - @within Array + @within Array - @param array {T} -- The array to search. - @param value any -- The value to search for. - @param from? number -- The index to start searching from. - @return boolean -- Whether the array contains the value. + Returns `true` if the given value is present in the array, otherwise `false`. - Checks whether the array contains the value. This is a wrapper - around `Find`. - - #### Aliases - - `contains`, `has` - - ```lua - local array = { "hello", "world", "goodbye" } - - local value = Includes(array, "hello") -- true - local value = Includes(array, "sift") -- false - local value = Includes(array, "hello", 2) -- false - ``` + ```lua + includes({ "a", "b", "c" }, "b") -- true + ``` ]=] -local function includes(array: { T }, value: any, from: number?): boolean - return Find(array, value, from) ~= nil +local function includes(array: { T }, value: T, from: number?): boolean + return find(array, value, from) ~= nil end return includes diff --git a/src/Array/init.luau b/src/Array/init.luau index 1fdde97..7d42d9b 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -1,82 +1,12 @@ ---!strict --[=[ - @class Array + @class Array - An array is a table consisting of index-value pairs. You don't need to - manually specify the indices when you create an array. + An array is a collection of values, each identified by a numeric index. Luau arrays are 1-based, meaning the first element is at index 1, the second element is at index 2, and so on. - ```lua - local array = { - "hello", - "world", - } - ``` - -

- - #### Aliases - - `List` + ```lua + local array = { 1, 2, 3 } + ``` ]=] -local Array = { - at = require(script.at), - concat = require(script.concat), - concatDeep = require(script.concatDeep), - copy = require(script.copy), - copyDeep = require(script.copyDeep), - count = require(script.count), - create = require(script.create), - difference = require(script.difference), - differenceSymmetric = require(script.differenceSymmetric), - equals = require(script.equals), - equalsDeep = require(script.equalsDeep), - every = require(script.every), - filter = require(script.filter), - find = require(script.find), - findLast = require(script.findLast), - findWhere = require(script.findWhere), - findWhereLast = require(script.findWhereLast), - first = require(script.first), - flatten = require(script.flatten), - freeze = require(script.freeze), - freezeDeep = require(script.freezeDeep), - includes = require(script.includes), - insert = require(script.insert), - is = require(script.is), - last = require(script.last), - map = require(script.map), - pop = require(script.pop), - push = require(script.push), - reduce = require(script.reduce), - reduceRight = require(script.reduceRight), - removeIndex = require(script.removeIndex), - removeIndices = require(script.removeIndices), - removeValue = require(script.removeValue), - removeValues = require(script.removeValues), - reverse = require(script.reverse), - set = require(script.set), - shift = require(script.shift), - shuffle = require(script.shuffle), - slice = require(script.slice), - some = require(script.some), - sort = require(script.sort), - splice = require(script.splice), - toSet = require(script.toSet), - unshift = require(script.unshift), - update = require(script.update), - zip = require(script.zip), - zipAll = require(script.zipAll), -} - -Array.join = Array.concat -Array.merge = Array.concat -Array.joinDeep = Array.concatDeep -Array.mergeDeep = Array.concatDeep -Array.append = Array.push -Array.prepend = Array.unshift -Array.indexOf = Array.find -Array.has = Array.includes -Array.contains = Array.includes -Array.isArray = Array.is +local Array = {} return Array diff --git a/src/Array/insert.luau b/src/Array/insert.luau index 400a129..f6aea5c 100644 --- a/src/Array/insert.luau +++ b/src/Array/insert.luau @@ -1,52 +1,31 @@ ---!strict ---[=[ - @function insert - @within Array - - @param array {T} -- The array to insert the value into. - @param index number -- The index to insert the value at (can be negative). - @param values ...T -- The values to insert. - @return {T} -- The array with the value inserted. +local copy = require("./copy") - Inserts the given values into an array at the given index, shifting all values after it to the right. If the index is negative (or 0), it is counted from the end of the array. +--[=[ + @within Array - If the index to insert at is out of range, the array is not modified. + Inserts the given values into the array at the specified index. - ```lua - local array = { 1, 2, 3 } + ```lua + local array = { "a", "b", "c" } - local newArray = Insert(array, 2, 4) -- { 1, 4, 2, 3 } - ``` + insert(array, 2, "x", "y") -- { "a", "x", "y", "b", "c" } + insert(array, -1, "x", "y") -- { "a", "b", "x", "y", "c" } + ``` ]=] local function insert(array: { T }, index: number, ...: T): { T } - local length = #array - - if index < 1 then - index += length + 1 + if index == 0 then + index = 1 + elseif index < 0 then + index += #array + 1 end - if index > length then - if index > length + 1 then - return array - end - - index = length + 1 - length += 1 - end - - local result = {} - - for i = 1, length do - if i == index then - for _, value in ipairs({ ... }) do - table.insert(result, value) - end - end + local out = copy(array) - table.insert(result, array[i]) + for i = 1, select("#", ...) do + table.insert(out, index + i - 1, select(i, ...)) end - return result + return out end return insert diff --git a/src/Array/is.luau b/src/Array/is.luau index 7c8c90b..144895b 100644 --- a/src/Array/is.luau +++ b/src/Array/is.luau @@ -1,25 +1,17 @@ ---!strict --[=[ - @function is - @within Array + @within Array - @param object any -- The object to check. - @return boolean -- Whether the object is an array. + Checks if `value` is an array. - Checks if the given object is an array. - - ```lua - local array = { 1, 2, 3 } - local dictionary = { hello = "world" } - local mixed = { 1, 2, hello = "world" } - - Array.is(array) -- true - Array.is(dictionary) -- false - Array.is(mixed) -- false - ``` + ```lua + is({ 1, 2, 3 }) -- true + is({ a = 1, b = 2, c = 3 }) -- false + is("hello") -- false + is({}) -- false + ``` ]=] -local function is(object: any): boolean - return typeof(object) == "table" and #object > 0 and next(object, #object) == nil +local function is(value: any): boolean + return typeof(value) == "table" and #value > 0 and next(value, #value) == nil end return is diff --git a/src/Array/last.luau b/src/Array/last.luau index 3bd1a2a..10097ff 100644 --- a/src/Array/last.luau +++ b/src/Array/last.luau @@ -1,23 +1,16 @@ ---!strict -local At = require(script.Parent.at) +local at = require("./at") --[=[ - @function last - @within Array + @within Array - @param array {T} -- The array to get the last element of. - @return T -- The last element of the array. + Returns the last element of an array. - Gets the last element of the array. - - ```lua - local array = { 1, 2, 3 } - - local value = Last(array) -- 3 - ``` + ```lua + last({ "a", "b", "c" }) --> "c" + ``` ]=] local function last(array: { T }): T - return At(array, 0) + return at(array, -1) end return last diff --git a/src/Array/map.luau b/src/Array/map.luau index f9bdb18..d48a1ad 100644 --- a/src/Array/map.luau +++ b/src/Array/map.luau @@ -1,34 +1,28 @@ ---!strict ---[=[ - @function map - @within Array - - @param array {T} -- The array to map. - @param mapper (value: T, index: number, array: {T}) -> U? -- The mapper function. - @return {U} -- The mapped array. +local None = require("@Sift/None") - Maps the array using the mapper function. +--[=[ + @within Array - ```lua - local array = { 1, 2, 3 } + Processes each element of an array with a mapper function and returns a new array with the results. - local new = Map(array, function(value, index) - return value * 2 - end) -- { 2, 4, 6 } - ``` + ```lua + map({ 1, 2, 3, 4, 5 }, function(value) + return value * 2 + end) -- { 2, 4, 6, 8, 10 } + ``` ]=] -local function map(array: { T }, mapper: (value: T, index: number, array: { T }) -> U?): { U } - local mapped = {} +local function map(array: { T }, mapper: (value: T, index: number) -> U?): { U } + local out: { U } = {} - for index, value in ipairs(array) do - local mappedValue = mapper(value, index, array) + for index, value in array do + local mapped = mapper(value, index) - if mappedValue ~= nil then - table.insert(mapped, mappedValue) + if mapped ~= nil and mapped ~= None then + table.insert(out, mapped) end end - return mapped + return out end return map diff --git a/src/Array/partition.luau b/src/Array/partition.luau new file mode 100644 index 0000000..9a9f8a0 --- /dev/null +++ b/src/Array/partition.luau @@ -0,0 +1,30 @@ +--[=[ + @within Array + + Filters an array into two arrays based on a filter function. The first array contains all elements that pass the filter, and the second array contains all elements that fail the filter. + + ```lua + local even, odd = partition({ 1, 2, 3, 4, 5 }, function(value) + return value % 2 == 0 + end) + + -- even: { 2, 4 } + -- odd: { 1, 3, 5 } + ``` +]=] +local function partition(array: { T }, filterer: (value: T, index: number) -> boolean) + local pass = {} + local fail = {} + + for index, value in array do + if filterer(value, index) then + table.insert(pass, value) + else + table.insert(fail, value) + end + end + + return pass, fail +end + +return partition diff --git a/src/Array/pop.luau b/src/Array/pop.luau index 7a42515..c22ee80 100644 --- a/src/Array/pop.luau +++ b/src/Array/pop.luau @@ -1,33 +1,30 @@ ---!strict ---[=[ - @function pop - @within Array +local removeIndices = require("./removeIndices") - @param array {T} -- The array to pop an element from. - @param count? number = 1 -- The number of elements to pop. - @return {T} -- An array with the popped elements removed. +--[=[ + @within Array - Removes an element from the end of the array, and returns - the array with the popped elements removed. + Returns a new array with the last `count` elements removed. If `count` is not provided, it defaults to `1`. - ```lua - local array = { 1, 2, 3 } + ```lua + local array = { 1, 2, 3, 4, 5 } - local new = Pop(array) -- { 1, 2 } - local new = Pop(array, 2) -- { 1 } - ``` + pop(array) -- { 1, 2, 3, 4 } + pop(array, 3) -- { 1, 2 } + ``` ]=] local function pop(array: { T }, count: number?): { T } - local length = #array - local result = {} + local useCount = count or 1 + local indices = {} - count = if type(count) == "number" then count else 1 + if useCount > #array then + return {} + end - for i = 1, length - count do - table.insert(result, array[i]) + for index = 1, useCount do + table.insert(indices, #array - index + 1) end - return result + return removeIndices(array, table.unpack(indices)) end return pop diff --git a/src/Array/push.luau b/src/Array/push.luau index 707d41e..bffe75b 100644 --- a/src/Array/push.luau +++ b/src/Array/push.luau @@ -1,36 +1,16 @@ ---!strict ---[=[ - @function push - @within Array - - @param array {T} -- The array to push an element to. - @param ... ...T -- The elements to push. - @return {T} -- The array with the pushed elements. - - Adds elements to the end of the array. - - #### Aliases +local insert = require("./insert") - `append` +--[=[ + @within Array - ```lua - local array = { 1, 2, 3 } + Returns a new array with the provided values appended to the end. - local new = Push(array, 4, 5, 6) -- { 1, 2, 3, 4, 5, 6 } - ``` + ```lua + push({ 1, 2, 3 }, 4, 5) -- {1, 2, 3, 4, 5} + ``` ]=] local function push(array: { T }, ...: T): { T } - local result = {} - - for _, value in ipairs(array) do - table.insert(result, value) - end - - for _, value in ipairs({ ... }) do - table.insert(result, value) - end - - return result + return insert(array, #array + 1, ...) end return push diff --git a/src/Array/reduce.luau b/src/Array/reduce.luau index d0bfb5e..554019b 100644 --- a/src/Array/reduce.luau +++ b/src/Array/reduce.luau @@ -1,47 +1,34 @@ ---!strict ---[=[ - @function reduce - @within Array - - @param array {T} -- The array to reduce. - @param reducer (accumulator: U, value: T, index: number, array: {T}) -> U -- The reducer to use. - @param initialReduction? U = {T}[1] -- The initial accumulator value. - @return U -- The final accumulator value. +local None = require("@Sift/None") - Reduces the array using the given reducer and initial accumulator value. - If no `initialReduction` value is given, the first item in the array is used. - - ```lua - local array = { 1, 2, 3 } +--[=[ + @within Array - local value = Reduce(array, function(accumulator, item, index) - return accumulator - item - end) -- -4 + Reduces an array to a single value using a reducer function. - local value = Reduce(array, function(accumulator, item, index) - table.insert(accumulator, item) - return accumulator - end, {}) -- { 1, 2, 3 } - ``` + ```lua + reduce({ 1, 2, 3 }, function(accumulator, value) + return accumulator + value + end) -- 6 + ``` ]=] local function reduce( array: { T }, - reducer: (accumulator: U, value: T, index: number, array: { T }) -> U, - initReduction: U? + reducer: (accumulator: U, value: T, index: number) -> U, + initAccumulator: U? ): U - local result = initReduction + local out = initAccumulator :: U local start = 1 - if result == nil then - result = array[1] + if out == nil or out == None then + out = array[1] :: any start = 2 end for index = start, #array do - result = reducer(result, array[index], index, array) + out = reducer(out, array[index], index) end - return result + return out end return reduce diff --git a/src/Array/reduceRight.luau b/src/Array/reduceRight.luau index 7d79e77..f39620b 100644 --- a/src/Array/reduceRight.luau +++ b/src/Array/reduceRight.luau @@ -1,48 +1,34 @@ ---!strict ---[=[ - @function reduceRight - @within Array - - @param array {T} -- The array to reduce. - @param reducer (accumulator: U, value: T, index: number, array: {T}) -> U -- The reducer to use. - @param initialReduction? U = {T}[#{T}] -- The initial accumulator value. - @return U -- The final accumulator value. +local None = require("@Sift/None") - Reduces the array using the given reducer and initial accumulator value, - starting from the end of the array. If no `initialReduction` value is given, - the last item in the array is used. - - ```lua - local array = { 1, 2, 3 } +--[=[ + @within Array - local value = ReduceRight(array, function(accumulator, item, index) - return accumulator - item - end) -- 0 + Reduces an array into a single value from end to start. - local value = ReduceRight(array, function(accumulator, item, index) - table.insert(accumulator, item) - return accumulator - end, {}) -- { 3, 2, 1 } - ``` + ```lua + reduceRight({ 1, 2, 3 }, function(accumulator, value) + return accumulator - value + end) -- 0 + ``` ]=] local function reduceRight( array: { T }, - reducer: (accumulator: U, value: T, index: number, array: { T }) -> U, - initReduction: U? + reducer: (accumulator: U, value: T, index: number) -> U, + initAccumulator: U? ): U - local result = initReduction + local out = initAccumulator :: U local start = #array - if result == nil then - result = array[start] + if out == nil or out == None then + out = array[start] :: any start -= 1 end for index = start, 1, -1 do - result = reducer(result, array[index], index, array) + out = reducer(out, array[index], index) end - return result + return out end return reduceRight diff --git a/src/Array/removeIndex.luau b/src/Array/removeIndex.luau index c98a8cc..a7cbabc 100644 --- a/src/Array/removeIndex.luau +++ b/src/Array/removeIndex.luau @@ -1,36 +1,16 @@ ---!strict ---[=[ - @function removeIndex - @within Array - - @param array {T} -- The array to remove the value from. - @param index number -- The index to remove the value from (can be negative). - @return {T} -- The array with the value removed. +local removeIndices = require("./removeIndices") - Removes a value from an array at the given index. +--[=[ + @within Array - ```lua - local array = { 1, 2, 3 } + Returns a new array with the element at the specified index removed. - local new = RemoveIndex(array, 1) -- { 2, 3 } - local new = RemoveIndex(array, -1) -- { 1, 3 } - ``` + ```lua + removeIndex({ 1, 2, 3 }, 2) -- {1, 3} + ``` ]=] local function removeIndex(array: { T }, index: number): { T } - local length = #array - local result = {} - - if index < 1 then - index += length - end - - for arrIndex, value in ipairs(array) do - if arrIndex ~= index then - table.insert(result, value) - end - end - - return result + return removeIndices(array, index) end return removeIndex diff --git a/src/Array/removeIndices.luau b/src/Array/removeIndices.luau index 8a6f8c8..f3bb844 100644 --- a/src/Array/removeIndices.luau +++ b/src/Array/removeIndices.luau @@ -1,41 +1,36 @@ ---!strict ---[=[ - @function removeIndices - @within Array - - @param array {T} -- The array to remove the indices from. - @param ... ...number -- The indices to remove the values from (can be negative). - @return {T} -- The array with the values removed. +local reduce = require("./reduce") - Removes values from an array at the given indices. +--[=[ + @within Array - ```lua - local array = { 1, 2, 3 } + Returns a new array with the elements at the specified indices removed. - local new = RemoveIndices(array, 1, 2) -- { 3 } - local new = RemoveIndices(array, 0, -1) -- { 1 } - ``` + ```lua + removeIndices({ 1, 2, 3, 4, 5 }, 2, 4) -- {1, 3, 5} + ``` ]=] local function removeIndices(array: { T }, ...: number): { T } - local length = #array - local indices = {} - local result = {} - - for _, index in ipairs({ ... }) do - if index < 1 then - index += length + local indices = reduce({ ... }, function(acc, value) + if value == 0 then + value = 1 + elseif value < 0 then + value += #array + 1 end - indices[index] = true - end + acc[value] = true + + return acc + end, {}) + + local out = {} - for index, value in ipairs(array) do + for index, value in array do if not indices[index] then - table.insert(result, value) + table.insert(out, value) end end - return result + return out end return removeIndices diff --git a/src/Array/removeValue.luau b/src/Array/removeValue.luau index 390c22a..d3b191e 100644 --- a/src/Array/removeValue.luau +++ b/src/Array/removeValue.luau @@ -1,30 +1,16 @@ ---!strict ---[=[ - @function removeValue - @within Array - - @param array {T} -- The array to remove the value from. - @param value T -- The value to remove. - @return {T} -- The array with the value removed. +local removeValues = require("./removeValues") - Removes a value from an array. +--[=[ + @within Array - ```lua - local array = { 1, 2, 3 } + Removes all instances of a value from an array. - local new = RemoveValue(array, 2) -- { 1, 3 } - ``` + ```lua + removeValue({ "a", "b", "c", "a" }, "a") -- { "b", "c" } + ``` ]=] local function removeValue(array: { T }, value: T): { T } - local result = {} - - for _, arrValue in ipairs(array) do - if arrValue ~= value then - table.insert(result, arrValue) - end - end - - return result + return removeValues(array, value) end return removeValue diff --git a/src/Array/removeValues.luau b/src/Array/removeValues.luau index 4a6928e..644b777 100644 --- a/src/Array/removeValues.luau +++ b/src/Array/removeValues.luau @@ -1,33 +1,25 @@ ---!strict -local ToSet = require(script.Parent.toSet) +local filter = require("./filter") +local reduce = require("./reduce") --[=[ - @function removeValues - @within Array + @within Array - @param array {T} -- The array to remove values from. - @param ... T -- The values to remove. - @return {T} -- The array with the values removed. + Removes all instances of the given values from the array. - Removes values from an array. - - ```lua - local array = { "a", "b", "c", "c", "d", "e" } - - local new = RemoveValues(array, "c", "d") -- { "a", "b", "e" } - ``` + ```lua + removeValues({ "a", "a", "c", "b", "c", "a", "d" }, "a", "c") + -- { "b", "d" } + ``` ]=] local function removeValues(array: { T }, ...: T): { T } - local valueSet = ToSet({ ... }) - local result = {} - - for _, value in ipairs(array) do - if not valueSet[value] then - table.insert(result, value) - end - end - - return result + local values = reduce({ ... }, function(acc, value) + acc[value] = true + return acc + end, {}) + + return filter(array, function(value) + return not values[value] + end) end return removeValues diff --git a/src/Array/reverse.luau b/src/Array/reverse.luau index 192be65..64db68d 100644 --- a/src/Array/reverse.luau +++ b/src/Array/reverse.luau @@ -1,27 +1,20 @@ ---!strict --[=[ - @function reverse - @within Array + @within Array - @param array {T} -- The array to reverse. - @return {T} -- The reversed array. + Returns a new array with the elements in reverse order. - Reverses the order of the items in an array. - - ```lua - local array = { 1, 2, 3 } - - local new = Reverse(array) -- { 3, 2, 1 } - ``` + ```lua + reverse({ "a", "b", "c" }) -- { "c", "b", "a" } + ``` ]=] local function reverse(array: { T }): { T } - local result = {} + local out = {} for index = #array, 1, -1 do - table.insert(result, array[index]) + table.insert(out, array[index]) end - return result + return out end return reverse diff --git a/src/Array/set.luau b/src/Array/set.luau index 51b26d6..d8366b8 100644 --- a/src/Array/set.luau +++ b/src/Array/set.luau @@ -1,39 +1,29 @@ ---!strict ---[=[ - @function set - @within Array +local copy = require("./copy") - @param array {T} -- The array to set the value on. - @param index number -- The index to set the value at (can be negative). - @param value T -- The value to set. - @return {T} -- The array with the value set. +--[=[ + @within Array - Sets a value on an array at the given index. + Sets the value at the given index in the array and returns a new array. - ```lua - local array = { 1, 2, 3 } + ```lua + local array = { "a", "b", "c", "d" } - local new = Set(array, 2, 4) -- { 1, 4, 3 } - local new = Set(array, -1, 4) -- { 1, 2, 4 } - ``` + set(array, 2, "z") -- { "a", "z", "c", "d" } + set(array, -1, "x") -- { "a", "b", "c", "x" } + ``` ]=] -local function set(array: { T }, index: number, value: T?): { T } - local length = #array - local result = {} +local function set(array: { T }, index: number, value: T): { T } + local out = copy(array) - if index < 1 then - index += length + if index == 0 then + index = 1 + elseif index < 0 then + index += #out + 1 end - for arrIndex, arrValue in ipairs(array) do - if arrIndex == index then - table.insert(result, value) - else - table.insert(result, arrValue) - end - end + out[index] = value - return result + return out end return set diff --git a/src/Array/shift.luau b/src/Array/shift.luau index 0c55fe6..4858541 100644 --- a/src/Array/shift.luau +++ b/src/Array/shift.luau @@ -1,33 +1,30 @@ ---!strict ---[=[ - @function shift - @within Array +local removeIndices = require("./removeIndices") - @param array {T} -- The array to shift. - @param count? number -- The number of items to shift. - @return {T} -- The shifted array. +--[=[ + @within Array - Removes the first item from an array and returns the array - with the item removed. + Returns a new array with the first `count` elements removed. If `count` is not provided, it defaults to `1`. - ```lua - local array = { 1, 2, 3 } + ```lua + local array = { "a", "b", "c", "d" } - local new = Shift(array) -- { 2, 3 } - local new = Shift(array, 2) -- { 3 } - ``` + shift(array) -- { "b", "c", "d" } + shift(array, 2) -- { "c", "d" } + ``` ]=] local function shift(array: { T }, count: number?): { T } - local length = #array - local result = {} + local useCount = count or 1 + local indices = {} - count = if type(count) == "number" then count + 1 else 2 + if useCount > #array then + return {} + end - for i = count, length do - table.insert(result, array[i]) + for index = #array, useCount, -1 do + table.insert(indices, index) end - return result + return removeIndices(array, table.unpack(indices)) end return shift diff --git a/src/Array/shuffle.luau b/src/Array/shuffle.luau index e237d42..d339e3f 100644 --- a/src/Array/shuffle.luau +++ b/src/Array/shuffle.luau @@ -1,34 +1,28 @@ ---!strict -local Copy = require(script.Parent.copy) +local copy = require("./copy") --[=[ - @function shuffle - @within Array + @within Array - @param array {T} -- The array to shuffle. - @return {T} -- The shuffled array. + Copies an array with a randomized order. - Randomises the order of the items in an array. - - ```lua - local array = { 1, 2, 3 } - - local new = Shuffle(array) -- { 2, 3, 1 } - ``` + ```lua + shuffle({ "a", "b", "c" }) -- { "c", "a", "b" } + ``` ]=] -local function shuffle(array: { T }): { T } - local random = Random.new(os.time() * #array) - local result = Copy(array) +local function shuffle(array: { T }, seed: number?): { T } + math.randomseed(seed or os.clock() * #array) + + local out = copy(array) - for index = #result, 1, -1 do - local randomIndex = random:NextInteger(1, index) - local temp = result[index] + for index = #out, 1, -1 do + local randomIndex = math.random(1, index) + local temp = out[index] - result[index] = result[randomIndex] - result[randomIndex] = temp + out[index] = out[randomIndex] + out[randomIndex] = temp end - return result + return out end return shuffle diff --git a/src/Array/slice.luau b/src/Array/slice.luau index 7d6c20e..14b872f 100644 --- a/src/Array/slice.luau +++ b/src/Array/slice.luau @@ -1,43 +1,39 @@ ---!strict --[=[ - @function slice - @within Array + @within Array - @param array {T} -- The array to slice. - @param from? number -- The index to start from (can be negative). - @param to? number -- The index to end at (can be negative). - @return {T} -- The sliced array. + Returns a slice of an array from `from` to `to` (inclusive). `from` and `to` can be negative, in which case they will be treated as an offset from the end of the array. - Slices an array. + ```lua + local array = { "a", "b", "c", "d", "e", "f" } - ```lua - local array = { 1, 2, 3, 4, 5 } - - local new = Slice(array, 2, 3) -- { 2, 3 } - local new = Slice(array, -2, -1) -- { 3, 4 } - local new = Slice(array, 3) -- { 3, 4, 5 } - ``` + slice(array, 2, 4) -- { "b", "c", "d" } + slice(array, 2, -2) -- { "b", "c", "d", "e" } + ``` ]=] local function slice(array: { T }, from: number?, to: number?): { T } - local length = #array - local result = {} - - from = if type(from) == "number" then from else 1 - to = if type(to) == "number" then to else length + if not from or from == 0 then + from = 1 + elseif from < 0 then + from += #array + 1 + end - if from < 1 then - from += length + if not to or to == 0 then + to = #array + elseif to < 0 then + to += #array + 1 end - if to < 1 then - to += length + if from == to then + return {} end - for i = from, to do - table.insert(result, array[i]) + local out = {} + + for index = from :: number, to :: number do + table.insert(out, array[index]) end - return result + return out end return slice diff --git a/src/Array/some.luau b/src/Array/some.luau index 0c5be36..d456e98 100644 --- a/src/Array/some.luau +++ b/src/Array/some.luau @@ -1,32 +1,17 @@ ---!strict --[=[ - @function some - @within Array + @within Array - @param array {T} -- The array to check. - @param predicate (value: T, index: number, array: {T}) -> any -- The predicate to use to check the array. - @return boolean -- Whether some item in the array passes the predicate. + Returns `true` if at least one element in the array satisfies the provided testing function. Otherwise, `false` is returned. - Checks whether some item in the array passes the predicate. - - ```lua - local array = { 1, 2, 3 } - - local value = Some(array, function(item, index) - return item > 1 - end) -- true - - local value = Some(array, function(item, index) - return item > 3 - end) -- false - ``` + ```lua + some({ 1, 2, 3, 4, 5 }, function(value) + return value % 2 == 0 + end) -- true + ``` ]=] -local function some( - array: { T }, - predicate: (value: T, index: number, array: { T }) -> any -): boolean - for index, value in ipairs(array) do - if predicate(value, index, array) then +local function some(array: { T }, predicate: (value: T, index: number) -> boolean): boolean + for index, value in array do + if predicate(value, index) then return true end end diff --git a/src/Array/sort.luau b/src/Array/sort.luau index 72c6833..e81b552 100644 --- a/src/Array/sort.luau +++ b/src/Array/sort.luau @@ -1,28 +1,18 @@ ---!strict -local Copy = require(script.Parent.copy) +local copy = require("./copy") --[=[ - @function sort - @within Array + @within Array - @param array {T} -- The array to sort. - @param comparator? (a: T, b: T) -> boolean -- The comparator function. - @return {T} -- The sorted array. + Returns a new array with the elements sorted. The optional `comparer` function is used to compare elements. If not provided, the default comparer will be used (ascending order). - Sorts an array. - - ```lua - local array = { "a", "b", "c", "d", "e" } - - local new = Sort(array, function(a, b) - return a > b - end) -- { "e", "d", "c", "b", "a" } - ``` + ```lua + sort({ 3, 1, 2 }) -- { 1, 2, 3 } + sort({ "c", "a", "b" }) -- { "a", "b", "c" } + ``` ]=] -local function sort(array: { T }, comparator: ((firstValue: T, secondValue: T) -> boolean)?): { T } - local result = Copy(array) - - table.sort(result, comparator) +local function sort(array: { T }, comparer: ((a: T, b: T) -> boolean)?): { T } + local result = copy(array) + table.sort(result, comparer) return result end diff --git a/src/Array/splice.luau b/src/Array/splice.luau index e0c4a22..8497dd3 100644 --- a/src/Array/splice.luau +++ b/src/Array/splice.luau @@ -1,52 +1,44 @@ ---!strict --[=[ - @function splice - @within Array + @within Array - @param array {T} -- The array to splice. - @param start? number -- The index to start splicing at (can be negative). - @param end? number -- The index to end splicing at (can be negative). - @param ... ...T -- The values to insert. - @return {T} -- The spliced array. + Returns a new array with elements removed and/or added. The `at` parameter specifies the index at which to start removing or adding elements. The `replaceCount` parameter specifies the number of elements to remove. Finally, the rest of the parameters are the elements to add to the array. - Splices an array. + ```lua + local array = { "a", "b", "c", "d" } - ```lua - local array = { 1, 2, 3, 4, 5 } - - local new = Splice(array, 3, 4, 6, 7) -- { 1, 2, 6, 7, 4, 5 } - local new = Splice(array, -1, 0, 6, 7) -- { 1, 2, 3, 4, 6, 7 } - local new = Splice(array, 4, -1, 6, 7) -- { 1, 2, 3, 6, 7, 5 } - ``` + splice(array, 2, 1, "x", "y", "z") -- { "a", "x", "y", "z", "c", "d" } + splice(array, 2, 0, "x", "y", "z") -- { "a", "x", "y", "z", "b", "c", "d" } + splice(array, 2, 1) -- { "a", "c", "d" } + ``` ]=] -local function splice(array: { T }, from: number?, to: number?, ...: T?): { T } - local length = #array - local result = {} - - from = if type(from) == "number" then from else 1 - to = if type(to) == "number" then to else length +local function splice(array: { T }, at: number?, replaceCount: number?, ...: T?): { T } + local useAt, useReplaceCount = 0, 0 - if from < 1 then - from += length + if not at or at == 0 then + useAt = 1 + elseif at < 0 then + useAt = at + #array + 1 end - if to < 1 then - to += length + if not replaceCount or replaceCount < 0 then + useReplaceCount = 0 end - for index = 1, from - 1 do - table.insert(result, array[index]) + local out = {} + + for index = 1, useAt - 1 do + table.insert(out, array[index]) end - for _, value in ipairs({ ... }) do - table.insert(result, value) + for index = 1, select("#", ...) do + table.insert(out, select(index, ...)) end - for index = to + 1, length do - table.insert(result, array[index]) + for index = useAt + useReplaceCount, #array do + table.insert(out, array[index]) end - return result + return out end return splice diff --git a/src/Array/toSet.luau b/src/Array/toSet.luau index 205774e..bd2ebe1 100644 --- a/src/Array/toSet.luau +++ b/src/Array/toSet.luau @@ -1,30 +1,20 @@ ---!strict -local Sift = script.Parent.Parent -local _T = require(Sift.Types) +local reduce = require("./reduce") --[=[ - @function toSet - @within Array + @within Array - @param array {T} -- The array to convert to a set. - @return Set -- The set. + Converts an array into a set, where each value in the array is a key in the set, and the value is `true`. - Converts an array to a set. - - ```lua - local array = { "a", "b", "b", "c", "d" } - - local set = ToSet(array) -- { a = true, b = true, c = true, d = true } - ``` + ```lua + toSet({ "a", "b", "c", "a", "a", "d" }) + -- { a = true, b = true, c = true, d = true } + ``` ]=] -local function toSet(array: { T }): _T.Set - local set = {} - - for _, value in ipairs(array) do +local function toSet(array: { T }): { [T]: boolean } + return reduce(array, function(set, value) set[value] = true - end - - return set + return set + end, {}) end return toSet diff --git a/src/Array/unshift.luau b/src/Array/unshift.luau index 9e453a2..3cbdf76 100644 --- a/src/Array/unshift.luau +++ b/src/Array/unshift.luau @@ -1,32 +1,10 @@ ---!strict ---[=[ - @function unshift - @within Array - - @param array {T} -- The array to insert the values to. - @param ... ...T -- The values to insert. - @return {T} -- The array with the values inserted. - - Inserts values to the beginning of an array. - - #### Aliases - - `prepend` +local insert = require("./insert") - ```lua - local array = { 1, 2, 3 } - - local new = Unshift(array, 4, 5) -- { 4, 5, 1, 2, 3 } - ``` +--[=[ + @within Array ]=] local function unshift(array: { T }, ...: T): { T } - local result = { ... } - - for _, value in ipairs(array) do - table.insert(result, value) - end - - return result + return insert(array, 1, ...) end return unshift diff --git a/src/Array/update.luau b/src/Array/update.luau index e3e96da..0aac09c 100644 --- a/src/Array/update.luau +++ b/src/Array/update.luau @@ -1,68 +1,43 @@ ---!strict -local Sift = script.Parent.Parent +local None = require("@Sift/None") +local Util = require("@Sift/Util") -local Util = require(Sift.Util) -local Copy = require(script.Parent.copy) - -type Callback = (index: number) -> T -type Updater = (currentValue: T, index: number) -> T - -local function call(callback: Callback, index: number) - if type(callback) == "function" then - return callback(index) - end -end +local copy = require("./copy") --[=[ - @function update - @within Array - - @param array {T} -- The array to update. - @param index number -- The index to update. - @param updater? (value: T, index: number) -> T -- The updater function. - @param callback? (index: number) -> T -- The callback function. - @return {T} -- The updated array. + @within Array - Updates an array at the given index. If the value at the given index does - not exist, `callback` will be called, and its return value will be used - as the value at the given index. + Updates the value at the given index in the array. If the value at the given index is `nil` or `None`, the `adder` function will be called to add a new value to the array. If the value at the given index is not `nil` or `None`, the `updater` function will be called to update the value at the given index. - ```lua - local array = { 1, 2, 3 } + ```lua + local array = { "a", "b", "c" } - local new = Update(array, 2, function(value) - return value + 1 - end) -- { 2, 3, 3 } + update(array, 2, function(value, index) + return value .. "!" + }) -- { "a", "b!", "c" } - local new = Update(array, 4, function(value) - return value + 1 - end, function(value) - return 10 - end) -- { 1, 2, 3, 10 } - ``` + update(array, 4, nil, function(index) + return "d" + }) -- { "a", "b", "c", "d" } + ``` ]=] local function update( array: { T }, index: number, - updater: Updater?, - callback: Callback? + updater: ((value: T, index: number) -> T)?, + adder: ((index: number) -> T)? ): { T } - local length = #array - local result = Copy(array) + local out = copy(array) + index = Util.normalizeIndex(index, #array) - if index < 1 then - index += length + if updater and out[index] ~= nil and out[index] ~= None then + out[index] = updater(out[index], index) end - updater = if type(updater) == "function" then updater else Util.func.returned - - if result[index] ~= nil then - result[index] = updater(result[index], index) - else - result[index] = call(callback, index) + if adder and (out[index] == nil or out[index] == None) then + out[index] = adder(index) end - return result + return out end return update diff --git a/src/Array/zip.luau b/src/Array/zip.luau index c30f3ec..2ebee7f 100644 --- a/src/Array/zip.luau +++ b/src/Array/zip.luau @@ -1,47 +1,41 @@ ---!strict -local Reduce = require(script.Parent.reduce) +local reduce = require("./reduce") --[=[ - @function zip - @within Array + @within Array - @param ... {any} -- The arrays to zip together. - @return {any} -- The zipped array. + Links together the values of multiple arrays into a single array of arrays, where each index of the new array contains the values of the original arrays at that index. If the arrays are of different lengths, the new array will be the length of the shortest array. - Zips multiple arrays together into a single array. + ```lua + local array1 = { "a", "b", "c", "d" } + local array2 = { 1, 2, 3 } - ```lua - local table1 = { 1, 2, 3 } - local table2 = { "hello", "world", "goodbye" } - - local new = Zip(table1, table2) -- { { 1, "hello" }, { 2, "world" }, { 3, "goodbye" } } - ``` + zip(array1, array2) + -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } + ``` ]=] -local function zip(...: { any }): T - local argCount = select("#", ...) - local arguments = { ... } - - local result = {} - - if argCount == 0 then - return result +local function zip(...: { any }): { { any } } + if select("#", ...) == 0 then + return {} end - local minLength: number = Reduce(arguments, function(acc, val) - return math.min(acc, #val) - end, #arguments[1]) + local arrays = { ... } + local length = reduce(arrays, function(acc, array) + return math.min(acc, #array) + end, math.huge) + + local out = {} - for index = 1, minLength do + for index = 1, length do local values = {} - for _, argArray in ipairs(arguments) do - table.insert(values, argArray[index]) + for _, array in arrays do + table.insert(values, array[index]) end - table.insert(result, values) + table.insert(out, values) end - return result + return out end return zip diff --git a/src/Array/zipAll.luau b/src/Array/zipAll.luau index 33612a2..6050316 100644 --- a/src/Array/zipAll.luau +++ b/src/Array/zipAll.luau @@ -1,51 +1,43 @@ ---!strict -local Sift = script.Parent.Parent - -local Reduce = require(script.Parent.reduce) -local None = require(Sift.None) +local None = require("@Sift/None") +local reduce = require("./reduce") --[=[ - @function zipAll - @within Array - - @param ... ...{any} -- The arrays to zip. - @return {any} -- The zipped array. + @within Array - Zips multiple arrays together into a single array, filling - in missing values with `None`. + Links together the values of multiple arrays into a single array of arrays, where each index of the new array contains the values of the original arrays at that index. If the arrays are of different lengths, the shorter arrays will be padded with `None`. - ```lua - local table1 = { 1, 2, 3, 4 } - local table2 = { "hello", "world", "goodbye" } + ```lua + local array1 = { 1, 2, 3 } + local array2 = { "a", "b", "c", "d" } - local new = ZipAll(table1, table2) -- { { 1, "hello" }, { 2, "world" }, { 3, "goodbye" }, { 4, None } } - ``` + zipAll(array1, array2) + -- { { 1, "a" }, { 2, "b" }, { 3, "c" }, { None, "d" } } + ``` ]=] -local function zipAll(...: { any }): T - local argCount = select("#", ...) - local arguments = { ... } - local result = {} - - if argCount == 0 then - return result +local function zipAll(...: { any }): { { any } } + if select("#", ...) == 0 then + return {} end - local maxLength = Reduce(arguments, function(acc, val) - return math.max(acc, #val) - end, #arguments[1]) + local arrays = { ... } + local length = reduce(arrays, function(acc, array) + return math.max(acc, #array) + end, 0) + + local out = {} - for index = 1, maxLength do + for i = 1, length do local values = {} - for _, argArray in ipairs(arguments) do - local value = argArray[index] - table.insert(values, if value == nil then None else value) + for _, array in arrays do + local value = if array[i] == nil then None else array[i] + table.insert(values, value) end - table.insert(result, values) + table.insert(out, values) end - return result + return out end return zipAll diff --git a/src/Dictionary/copy.luau b/src/Dictionary/copy.luau deleted file mode 100644 index 60c30aa..0000000 --- a/src/Dictionary/copy.luau +++ /dev/null @@ -1,20 +0,0 @@ ---!strict ---[=[ - @function copy - @within Dictionary - - @param dictionary T -- The dictionary to copy. - @return T -- The copied dictionary. - - Copies a dictionary. - - ```lua - local dictionary = { hello = "world" } - - local new = Copy(dictionary) -- { hello = "world" } - - print(new == dictionary) -- false - print(new.hello == dictionary.hello) -- true - ``` -]=] -return table.clone diff --git a/src/Dictionary/copy.luau.todo b/src/Dictionary/copy.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/copyDeep.luau b/src/Dictionary/copyDeep.luau deleted file mode 100644 index 5734f51..0000000 --- a/src/Dictionary/copyDeep.luau +++ /dev/null @@ -1,32 +0,0 @@ ---!strict ---[=[ - @function copyDeep - @within Dictionary - - @param dictionary T -- The dictionary to copy. - @return T -- The copied dictionary. - - Copies a dictionary recursively. - - ```lua - local dictionary = { hello = { world = "goodbye" } } - - local new = CopyDeep(dictionary) -- { hello = { world = "goodbye" } } - - print(new == dictionary) -- false - print(new.hello == dictionary.hello) -- false - ``` -]=] -local function copyDeep(dictionary: T): T - local new = table.clone(dictionary) - - for key, value in pairs(dictionary) do - if type(value) == "table" then - new[key] = copyDeep(value) - end - end - - return new -end - -return copyDeep diff --git a/src/Dictionary/copyDeep.luau.todo b/src/Dictionary/copyDeep.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/count.luau b/src/Dictionary/count.luau deleted file mode 100644 index 0000ef5..0000000 --- a/src/Dictionary/count.luau +++ /dev/null @@ -1,42 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - ---[=[ - @function count - @within Dictionary - - @param dictionary T -- The dictionary to count. - @param predicate? (value: T, key: K, dictionary: T) -> any -- The predicate to use to filter the dictionary. - @return number -- The number of items in the dictionary. - - Counts the number of items in a dictionary. - - ```lua - local dictionary = { hello = "world", goodbye = "world" } - - local value = Count(dictionary) -- 2 - local value = Count(dictionary, function(item, key) - return item == "world" - end) -- 1 - ``` -]=] -local function count( - dictionary: { [K]: V }, - predicate: ((value: V, key: K, dictionary: { [K]: V }) -> any)? -): number - local counter = 0 - - predicate = if type(predicate) == "function" then predicate else Util.func.truthy - - for key, value in pairs(dictionary) do - if predicate(value, key, dictionary) then - counter += 1 - end - end - - return counter -end - -return count diff --git a/src/Dictionary/count.luau.todo b/src/Dictionary/count.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/entries.luau b/src/Dictionary/entries.luau deleted file mode 100644 index ca8a966..0000000 --- a/src/Dictionary/entries.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function entries - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to get the entries from. - @return {{ K, V }} -- The entries in the dictionary. - - Returns the entries in the given dictionary as an array of key-value pairs. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local entries = Entries(dictionary) -- { { "hello", "roblox" }, { "goodbye", "world" } } - ``` -]=] -local function entries(dictionary: { [K]: V }): { [number]: { [number]: K | V } } - local result = {} - - for key, value in pairs(dictionary) do - table.insert(result, { key, value }) - end - - return result -end - -return entries diff --git a/src/Dictionary/entries.luau.todo b/src/Dictionary/entries.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/equals.luau b/src/Dictionary/equals.luau deleted file mode 100644 index 7d7e725..0000000 --- a/src/Dictionary/equals.luau +++ /dev/null @@ -1,64 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) -local _T = require(Sift.Types) - -local function compare(a, b) - if type(a) ~= "table" or type(b) ~= "table" then - return a == b - end - - for key, value in pairs(a) do - if b[key] ~= value then - return false - end - end - - for key, value in pairs(b) do - if a[key] ~= value then - return false - end - end - - return true -end - ---[=[ - @function equals - @within Dictionary - - @param ... ...{ [any]: any } -- The dictionaries to compare. - @return boolean -- Whether the dictionaries are equal. - - Compares two dictionaries for equality. - - ```lua - local dictionary = { hello = "world", goodbye = "world" } - local other1 = { hello = "world", goodbye = "world" } - local other2 = { hello = "hello", world = "goodbye" } - - local value = Equals(dictionary, other1) -- true - local value = Equals(dictionary, other1, other2) -- false - ``` -]=] -local function equals(...: _T.AnyDictionary): boolean - if Util.equalObjects(...) then - return true - end - - local totalArgs = select("#", ...) - local firstItem = select(1, ...) - - for i = 2, totalArgs do - local item = select(i, ...) - - if not compare(firstItem, item) then - return false - end - end - - return true -end - -return equals diff --git a/src/Dictionary/equals.luau.todo b/src/Dictionary/equals.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/equalsDeep.luau b/src/Dictionary/equalsDeep.luau deleted file mode 100644 index fba460f..0000000 --- a/src/Dictionary/equalsDeep.luau +++ /dev/null @@ -1,64 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) -local _T = require(Sift.Types) - -local function compareDeep(a, b) - if type(a) ~= "table" or type(b) ~= "table" then - return a == b - end - - for key, value in pairs(a) do - if not compareDeep(value, b[key]) then - return false - end - end - - for key, value in pairs(b) do - if not compareDeep(value, a[key]) then - return false - end - end - - return true -end - ---[=[ - @function equalsDeep - @within Dictionary - - @param ... ...{ [any]: any } -- The dictionaries to compare. - @return boolean -- Whether the dictionaries are equal. - - Compares two dictionaries for equality using deep comparison. - - ```lua - local dictionary = { hello = "world", goodbye = { world = "hello" } } - local other1 = { hello = "world", goodbye = { world = "hello" } } - local other2 = { hello = "hello", world = "goodbye" } - - local value = EqualsDeep(dictionary, other1) -- true - local value = EqualsDeep(dictionary, other1, other2) -- false - ``` -]=] -local function equalsDeep(...: _T.AnyDictionary): boolean - if Util.equalObjects(...) then - return true - end - - local totalArgs = select("#", ...) - local firstItem = select(1, ...) - - for i = 2, totalArgs do - local item = select(i, ...) - - if not compareDeep(firstItem, item) then - return false - end - end - - return true -end - -return equalsDeep diff --git a/src/Dictionary/equalsDeep.luau.todo b/src/Dictionary/equalsDeep.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/every.luau b/src/Dictionary/every.luau deleted file mode 100644 index 03337d0..0000000 --- a/src/Dictionary/every.luau +++ /dev/null @@ -1,37 +0,0 @@ ---!strict ---[=[ - @function every - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to check. - @param predicate (value: V, key: K, dictionary: {[K]: V}) -> any -- The predicate to use to check the dictionary. - @return boolean -- Whether every item in the dictionary passes the predicate. - - Checks whether every item in the dictionary passes the predicate. - - ```lua - local dictionary = { hello = "world", goodbye = "world" } - - local value = Every(dictionary, function(value, key) - return value == "world" - end) -- true - - local value = Every(dictionary, function(value, key) - return value == "hello" - end) -- false - ``` -]=] -local function every( - dictionary: { [K]: V }, - predicate: (value: V, key: K, dictionary: { [K]: V }) -> any -): boolean - for key, value in pairs(dictionary) do - if not predicate(value, key, dictionary) then - return false - end - end - - return true -end - -return every diff --git a/src/Dictionary/every.luau.todo b/src/Dictionary/every.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/filter.luau b/src/Dictionary/filter.luau deleted file mode 100644 index 56f8ff3..0000000 --- a/src/Dictionary/filter.luau +++ /dev/null @@ -1,41 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - ---[=[ - @function filter - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to filter. - @param predicate? (value: V, key: K, dictionary: {[K]: V}) -> any -- The predicate to use to filter the dictionary. - @return {[K]: V} -- The filtered dictionary. - - Filters a dictionary using a predicate. Any items that do not pass the predicate will be removed from the dictionary. - - ```lua - local dictionary = { hello = "world", goodbye = "goodbye" } - - local result = Filter(dictionary, function(value, key) - return value == "world" - end) -- { hello = "world" } - ``` -]=] -local function filter( - dictionary: { [K]: V }, - predicate: ((value: V, key: K, dictionary: { [K]: V }) -> any)? -): { [K]: V } - local result = {} - - predicate = if type(predicate) == "function" then predicate else Util.func.truthy - - for key, value in pairs(dictionary) do - if predicate(value, key, dictionary) then - result[key] = value - end - end - - return result -end - -return filter diff --git a/src/Dictionary/filter.luau.todo b/src/Dictionary/filter.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/flatten.luau b/src/Dictionary/flatten.luau deleted file mode 100644 index e4c4b00..0000000 --- a/src/Dictionary/flatten.luau +++ /dev/null @@ -1,52 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) - ---[=[ - @function flatten - @within Dictionary - - @param dictionary T -- The dictionary to flatten. - @param depth? number -- The depth to flatten the dictionary to. - @return T -- The flattened dictionary. - - Flattens a dictionary. If depth is not specified, it will flatten the dictionary as far as it can go. - - ```lua - local dictionary = { - hello = "world", - goodbye = { - world = "hello", - roblox = { - yes = "no", - no = "yes", - } - } - } - - local new = Flatten(dictionary) -- { hello = "world", world = "hello", yes = "no", no = "yes" } - local new = Flatten(dictionary, 1) -- { hello = "world", world = "hello", roblox = { yes = "no", no = "yes" } } - ``` -]=] -local function flatten(dictionary: _T.AnyDictionary, depth: number?): _T.AnyDictionary - depth = if type(depth) == "number" then depth else math.huge - - local result = {} - - for key, value in pairs(dictionary :: _T.AnyDictionary) do - if type(value) == "table" and depth > 0 then - local nested = flatten(value, depth - 1) - - for resultKey, resultValue in pairs(result) do - nested[resultKey] = resultValue - end - - result = nested - else - result[key] = value - end - end - - return result -end - -return flatten diff --git a/src/Dictionary/flatten.luau.todo b/src/Dictionary/flatten.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/flip.luau b/src/Dictionary/flip.luau deleted file mode 100644 index 6af59d1..0000000 --- a/src/Dictionary/flip.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function flip - @within Dictionary - - @param dictionary { [K]: V } -- The dictionary to flip. - @return { [V]: K } -- The flipped dictionary. - - Flips a dictionary. Keys become values and values become keys. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local new = Flip(dictionary) -- { world = "goodbye", roblox = "hello" } - ``` -]=] -local function flip(dictionary: { [K]: V }): { [V]: K } - local result = {} - - for key, value in pairs(dictionary) do - result[value] = key - end - - return result -end - -return flip diff --git a/src/Dictionary/flip.luau.todo b/src/Dictionary/flip.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/freeze.luau b/src/Dictionary/freeze.luau deleted file mode 100644 index 3f32a46..0000000 --- a/src/Dictionary/freeze.luau +++ /dev/null @@ -1,31 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) -local Copy = require(script.Parent.copy) - ---[=[ - @function freeze - @within Dictionary - - @param dictionary T -- The dictionary to freeze. - @return T -- The frozen dictionary. - - Freezes the given dictionary at the top level, making it read-only. - - ```lua - local dictionary = { hello = "roblox", goodbye = { world = "world" } } - - local new = Freeze(dictionary) - - new.hello = "world" -- error! - new.goodbye.world = "hello" -- still works! - ``` -]=] -local function freeze(dictionary: _T.AnyDictionary): _T.AnyDictionary - local new = Copy(dictionary) - - table.freeze(new) - - return new -end - -return freeze diff --git a/src/Dictionary/freeze.luau.todo b/src/Dictionary/freeze.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/freezeDeep.luau b/src/Dictionary/freezeDeep.luau deleted file mode 100644 index 4356357..0000000 --- a/src/Dictionary/freezeDeep.luau +++ /dev/null @@ -1,38 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) - ---[=[ - @function freezeDeep - @within Dictionary - - @param dictionary T -- The dictionary to freeze. - @return T -- The frozen dictionary. - - Freezes the entire dictionary, making it read-only, including all nested dictionaries. - - ```lua - local dictionary = { hello = "roblox", goodbye = { world = "world" } } - - local new = FreezeDeep(dictionary) - - new.hello = "world" -- error! - new.goodbye.world = "hello" -- error! - ``` -]=] -local function freezeDeep(dictionary: _T.AnyDictionary): _T.AnyDictionary - local result = {} - - for key, value in pairs(dictionary) do - if type(value) == "table" then - result[key] = freezeDeep(value) - else - result[key] = value - end - end - - table.freeze(result) - - return result -end - -return freezeDeep diff --git a/src/Dictionary/freezeDeep.luau.todo b/src/Dictionary/freezeDeep.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/fromArrays.luau b/src/Dictionary/fromArrays.luau deleted file mode 100644 index ed6e99d..0000000 --- a/src/Dictionary/fromArrays.luau +++ /dev/null @@ -1,31 +0,0 @@ ---!strict ---[=[ - @function fromArrays - @within Dictionary - - @param keys {K} -- An array containing values to be used as keys. - @param values {V} -- An array containing values to be used as values. - @return {[K]: V} -- A dictionary composed of the given keys and values. - - Creates a dictionary from the given arrays, where the first array is used - as keys and the second array is used as values. - - ```lua - local keys = { "hello", "goodbye" } - local values = { "roblox", "world" } - - local dictionary = FromArrays(keys, values) -- { hello = "roblox", goodbye = "world" } - ``` -]=] -local function fromArrays(keys: { K }, values: { V }): { [K]: V } - local keysLength = #keys - local result = {} - - for i = 1, keysLength do - result[keys[i]] = values[i] - end - - return result -end - -return fromArrays diff --git a/src/Dictionary/fromArrays.luau.todo b/src/Dictionary/fromArrays.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/fromEntries.luau b/src/Dictionary/fromEntries.luau deleted file mode 100644 index 7ae818a..0000000 --- a/src/Dictionary/fromEntries.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function fromEntries - @within Dictionary - - @param entries {{ K, V }} -- An array of key-value pairs. - @return {[K]: V} -- A dictionary composed of the given key-value pairs. - - Creates a dictionary from the given key-value pairs. - - ```lua - local entries = { { "hello", "roblox" }, { "goodbye", "world" } } - - local dictionary = FromEntries(entries) -- { hello = "roblox", goodbye = "world" } - ``` -]=] -local function fromEntries(entries: { [number]: { [number]: K | V } }): { [K]: V } - local result = {} - - for _, entry in ipairs(entries) do - result[entry[1]] = entry[2] - end - - return result -end - -return fromEntries diff --git a/src/Dictionary/fromEntries.luau.todo b/src/Dictionary/fromEntries.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/has.luau b/src/Dictionary/has.luau deleted file mode 100644 index 97e9952..0000000 --- a/src/Dictionary/has.luau +++ /dev/null @@ -1,25 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) - ---[=[ - @function has - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to check. - @param key any -- The key to check for. - @return boolean -- Whether or not the dictionary has the given key. - - Checks whether or not the given dictionary has the given key. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local hasHello = Has(dictionary, "hello") -- true - local hasCat = Has(dictionary, "cat") -- false - ``` -]=] -local function has(dictionary: _T.AnyDictionary, key: any): boolean - return dictionary[key] ~= nil -end - -return has diff --git a/src/Dictionary/has.luau.todo b/src/Dictionary/has.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/includes.luau b/src/Dictionary/includes.luau deleted file mode 100644 index 3106cd4..0000000 --- a/src/Dictionary/includes.luau +++ /dev/null @@ -1,29 +0,0 @@ ---!strict ---[=[ - @function includes - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to check. - @param value V -- The value to check for. - @return boolean -- Whether or not the dictionary includes the given value. - - Checks whether or not the given dictionary includes the given value. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local includesRoblox = Includes(dictionary, "roblox") -- true - local includesCat = Includes(dictionary, "cat") -- false - ``` -]=] -local function includes(dictionary: { [K]: V }, value: V): boolean - for _, v in pairs(dictionary) do - if v == value then - return true - end - end - - return false -end - -return includes diff --git a/src/Dictionary/includes.luau.todo b/src/Dictionary/includes.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index f68e6eb..85ae286 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -1,51 +1,4 @@ ---!strict --[=[ - @class Dictionary - - Dictionaries are a type of data structure that can be used to store key-value pairs. - - ```lua - local dictionary = { - cats = 2, - dogs = 1 - } - - print(dictionary.cats) -- 2 - ``` + @class Dictionary ]=] -local Dictionary = { - copy = require(script.copy), - copyDeep = require(script.copyDeep), - count = require(script.count), - entries = require(script.entries), - equals = require(script.equals), - equalsDeep = require(script.equalsDeep), - every = require(script.every), - filter = require(script.filter), - flatten = require(script.flatten), - flip = require(script.flip), - freeze = require(script.freeze), - freezeDeep = require(script.freezeDeep), - fromArrays = require(script.fromArrays), - fromEntries = require(script.fromEntries), - has = require(script.has), - includes = require(script.includes), - keys = require(script.keys), - map = require(script.map), - merge = require(script.merge), - mergeDeep = require(script.mergeDeep), - removeKey = require(script.removeKey), - removeKeys = require(script.removeKeys), - removeValue = require(script.removeValue), - removeValues = require(script.removeValues), - set = require(script.set), - some = require(script.some), - update = require(script.update), - values = require(script.values), - withKeys = require(script.withKeys), -} - -Dictionary.join = Dictionary.merge -Dictionary.joinDeep = Dictionary.mergeDeep - -return Dictionary +return {} diff --git a/src/Dictionary/keys.luau b/src/Dictionary/keys.luau deleted file mode 100644 index 40fe565..0000000 --- a/src/Dictionary/keys.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function keys - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to get the keys of. - @return {K} -- An array containing the keys of the given dictionary. - - Gets the keys of the given dictionary as an array. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local keys = Keys(dictionary) -- { "hello", "goodbye" } - ``` -]=] -local function keys(dictionary: { [K]: V }): { K } - local result = {} - - for key in pairs(dictionary) do - table.insert(result, key) - end - - return result -end - -return keys diff --git a/src/Dictionary/keys.luau.todo b/src/Dictionary/keys.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/map.luau b/src/Dictionary/map.luau deleted file mode 100644 index f878da3..0000000 --- a/src/Dictionary/map.luau +++ /dev/null @@ -1,40 +0,0 @@ ---!strict ---[=[ - @function map - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to map. - @param mapper (value: V, key: K, dictionary: {[K]: V}) -> (Y?, X?) -- The mapper function. - @return {[X]: Y} -- The mapped dictionary. - - Maps the dictionary using the mapper function. The mapper function can - return a value and a key. If the mapper function does not return a key, - the original key will be used. - - ```lua - local dictionary = { hello = 10, goodbye = 20 } - - local new = Map(dictionary, function(value, key) - return value * 2, key .. "!" - end) -- { ["hello!"] = 20, ["goodbye!"] = 40 } - - local new = Map(dictionary, function(value, key) - return value * 10 - end) -- { hello = 100, goodbye = 200 } - ``` -]=] -local function map( - dictionary: { [K]: V }, - mapper: (value: V, key: K, dictionary: { [K]: V }) -> (Y?, X?) -): { [X]: Y } - local mapped = {} - - for key, value in pairs(dictionary) do - local mappedValue, mappedKey = mapper(value, key, dictionary) - mapped[mappedKey or key] = mappedValue - end - - return mapped -end - -return map diff --git a/src/Dictionary/map.luau.todo b/src/Dictionary/map.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/merge.luau b/src/Dictionary/merge.luau deleted file mode 100644 index f02804d..0000000 --- a/src/Dictionary/merge.luau +++ /dev/null @@ -1,45 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local None = require(Sift.None) - ---[=[ - @function merge - @within Dictionary - - @param dictionaries? ...any -- The dictionaries to merge. - @return T -- The merged dictionary. - - Merges the given dictionaries into a single dictionary. If the - value is `None`, it will be removed from the result. The - parameters may be any number of dictionaries or `nil`. - Non-dictonaries will be ignored. - - Aliases: `join` - - ```lua - local dictionary1 = { hello = "roblox", goodbye = "world" } - local dictionary2 = { goodbye = "goodbye" } - - local merged = Merge(dictionary1, dictionary2) -- { hello = "roblox", goodbye = "goodbye" } - ``` -]=] -local function merge(...: any): T - local result = {} - - for dictionaryIndex = 1, select("#", ...) do - local dictionary = select(dictionaryIndex, ...) - - if type(dictionary) ~= "table" then - continue - end - - for key, value in pairs(dictionary) do - result[key] = if value == None then nil else value - end - end - - return result -end - -return merge diff --git a/src/Dictionary/merge.luau.todo b/src/Dictionary/merge.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/mergeDeep.luau b/src/Dictionary/mergeDeep.luau deleted file mode 100644 index e0ba505..0000000 --- a/src/Dictionary/mergeDeep.luau +++ /dev/null @@ -1,56 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local None = require(Sift.None) -local copyDeep = require(script.Parent.copyDeep) - ---[=[ - @function mergeDeep - @within Dictionary - - @param dictionaries? ...any -- The dictionaries to merge. - @return T -- The merged dictionary. - - Merges the given dictionaries into a single dictionary. If the - value is `None`, it will be removed from the result. This is - recursive. The parameters may be any number of dictionaries or - `nil`. Non-dictonaries will be ignored. - - Aliases: `joinDeep` - - ```lua - local dictionary1 = { hello = "roblox", goodbye = { world = "goodbye" } } - local dictionary2 = { goodbye = { world = "world" } } - - local merged = MergeDeep(dictionary1, dictionary2) -- { hello = "roblox", goodbye = { world = "world" } } - ``` -]=] -local function mergeDeep(...: any): T - local result = {} - - for dictionaryIndex = 1, select("#", ...) do - local dictionary = select(dictionaryIndex, ...) - - if type(dictionary) ~= "table" then - continue - end - - for key, value in pairs(dictionary) do - if value == None then - result[key] = nil - elseif type(value) == "table" then - if result[key] == nil or type(result[key]) ~= "table" then - result[key] = copyDeep(value) - else - result[key] = mergeDeep(result[key], value) - end - else - result[key] = value - end - end - end - - return result -end - -return mergeDeep diff --git a/src/Dictionary/mergeDeep.luau.todo b/src/Dictionary/mergeDeep.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/removeKey.luau b/src/Dictionary/removeKey.luau deleted file mode 100644 index 6659fac..0000000 --- a/src/Dictionary/removeKey.luau +++ /dev/null @@ -1,29 +0,0 @@ ---!strict -local copy = require(script.Parent.copy) - ---[=[ - @function removeKey - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to remove the key from. - @param key K -- The key to remove. - @return {[K]: V} -- The dictionary without the given key. - - Removes the given key from the given dictionary. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local withoutHello = RemoveKey(dictionary, "hello") -- { goodbye = "world" } - local withoutGoodbye = RemoveKey(dictionary, "goodbye") -- { hello = "roblox" } - ``` -]=] -local function removeKey(dictionary: { [K]: V }, key: K): { [K]: V } - local result = copy(dictionary) - - result[key] = nil - - return result -end - -return removeKey diff --git a/src/Dictionary/removeKey.luau.todo b/src/Dictionary/removeKey.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/removeKeys.luau b/src/Dictionary/removeKeys.luau deleted file mode 100644 index 93ff109..0000000 --- a/src/Dictionary/removeKeys.luau +++ /dev/null @@ -1,30 +0,0 @@ ---!strict -local copy = require(script.Parent.copy) - ---[=[ - @function removeKeys - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to remove the keys from. - @param keys ...K -- The keys to remove. - @return {[K]: V} -- The dictionary without the given keys. - - Removes the given keys from the given dictionary. - - ```lua - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - local withoutCatDog = RemoveKeys(dictionary, "cat", "dog") -- { hello = "world", unicorn = "rainbow" } - ``` -]=] -local function removeKeys(dictionary: { [K]: V }, ...: K): { [K]: V } - local result = copy(dictionary) - - for _, key in ipairs({ ... }) do - result[key] = nil - end - - return result -end - -return removeKeys diff --git a/src/Dictionary/removeKeys.luau.todo b/src/Dictionary/removeKeys.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/removeValue.luau b/src/Dictionary/removeValue.luau deleted file mode 100644 index e8280a8..0000000 --- a/src/Dictionary/removeValue.luau +++ /dev/null @@ -1,31 +0,0 @@ ---!strict ---[=[ - @function removeValue - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to remove the value from. - @param value V -- The value to remove. - @return {[K]: V} -- The dictionary without the given value. - - Removes the given value from the given dictionary. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local withoutHello = RemoveValue(dictionary, "roblox") -- { goodbye = "world" } - local withoutGoodbye = RemoveValue(dictionary, "world") -- { hello = "roblox" } - ``` -]=] -local function removeValue(dictionary: { [K]: V }, value: V): { [K]: V } - local result = {} - - for key, v in pairs(dictionary) do - if v ~= value then - result[key] = v - end - end - - return result -end - -return removeValue diff --git a/src/Dictionary/removeValue.luau.todo b/src/Dictionary/removeValue.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/removeValues.luau b/src/Dictionary/removeValues.luau deleted file mode 100644 index 0ece520..0000000 --- a/src/Dictionary/removeValues.luau +++ /dev/null @@ -1,36 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local ToSet = require(Sift.Array.toSet) - ---[=[ - @function removeValues - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to remove the values from. - @param values ...V -- The values to remove. - @return {[K]: V} -- The dictionary without the given values. - - Removes the given values from the given dictionary. - - ```lua - local dictionary = { hello = "world", cat = "meow", unicorn = "rainbow", goodbye = "world" } - - local withoutWorld = RemoveValues(dictionary, "world") -- { cat = "meow", unicorn = "rainbow" } - local onlyWorld = RemoveValues(dictionary, "meow", "rainbow") -- { hello = "world", goodbye = "world" } - ``` -]=] -local function removeValues(dictionary: { [K]: V }, ...: V): { [K]: V } - local values = ToSet({ ... }) - local result = {} - - for key, value in pairs(dictionary) do - if not values[value] then - result[key] = value - end - end - - return result -end - -return removeValues diff --git a/src/Dictionary/removeValues.luau.todo b/src/Dictionary/removeValues.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/set.luau b/src/Dictionary/set.luau deleted file mode 100644 index 9cd2d5e..0000000 --- a/src/Dictionary/set.luau +++ /dev/null @@ -1,29 +0,0 @@ ---!strict -local copy = require(script.Parent.copy) - ---[=[ - @function set - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to set the value in. - @param key K -- The key to set the value in. - @param value V -- The value to set. - @return {[K]: V} -- The dictionary with the given value set. - - Sets the given value in the given dictionary. - - ```lua - local dictionary = { hello = "world", cat = "meow", unicorn = "rainbow" } - - local setCat = Set(dictionary, "cat", "woof") -- { hello = "world", cat = "woof", unicorn = "rainbow" } - ``` -]=] -local function set(dictionary: { [K]: V }, key: K, value: V): { [K]: V } - local result = copy(dictionary) - - result[key] = value - - return result -end - -return set diff --git a/src/Dictionary/set.luau.todo b/src/Dictionary/set.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/some.luau b/src/Dictionary/some.luau deleted file mode 100644 index af416be..0000000 --- a/src/Dictionary/some.luau +++ /dev/null @@ -1,37 +0,0 @@ ---!strict ---[=[ - @function some - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to check. - @param predicate (value: V, key: K, dictionary: { [K]: V }) -> any -- The predicate to check against. - @return boolean -- Whether or not the predicate returned true for any value. - - Checks whether or not the predicate returned true for any value in the dictionary. - - ```lua - local dictionary = { hello = "world", cat = "meow", unicorn = "rainbow" } - - local hasMeow = Some(dictionary, function(value) - return value == "meow" - end) -- true - - local hasDog = Some(dictionary, function(_, key) - return key == "dog" - end) -- false - ``` -]=] -local function some( - dictionary: { [K]: V }, - predicate: (value: V, key: V, dictionary: { [K]: V }) -> any -): boolean - for key, value in pairs(dictionary) do - if predicate(value, key, dictionary) then - return true - end - end - - return false -end - -return some diff --git a/src/Dictionary/some.luau.todo b/src/Dictionary/some.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/update.luau b/src/Dictionary/update.luau deleted file mode 100644 index 4a5ff6b..0000000 --- a/src/Dictionary/update.luau +++ /dev/null @@ -1,60 +0,0 @@ ---!strict -local copy = require(script.Parent.copy) - -type Callback = (key: K) -> V -type Updater = (value: V, key: K) -> V - -local function call(callback: Callback, key: K) - if type(callback) == "function" then - return callback(key) - end -end - ---[=[ - @function update - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to update. - @param key K -- The key to update. - @param updater? (value: V, key: K) -> U -- The updater function. - @param callback? (key: K) -> C -- The callback function. - @return {[K]: V & U & C } -- The updated dictionary. - - Updates a value in a dictionary at the given key. If the value at the given key does not exist, `callback` will be called, and its return value will be used as the value at the given key. - - ```lua - local dictionary = { cats = 2 } - - local new = Update(dictionary, "cats", function(value) - return value + 1 - end) -- { cats = 3 } - - local new = Update(dictionary, "dogs", function(value) - return value + 1 - end, function(value) - return 1 - end) -- { cats = 3, dogs = 1 } - ``` -]=] -local function update( - dictionary: { [K]: V }, - key: K, - updater: ((value: V, key: K) -> U)?, - callback: ((key: K) -> C)? -): { [K]: V & U & C } - local result = copy(dictionary) - - if result[key] ~= nil then - if updater then - result[key] = updater(result[key], key) - end - else - if callback then - result[key] = call(callback, key) - end - end - - return result -end - -return update diff --git a/src/Dictionary/update.luau.todo b/src/Dictionary/update.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/values.luau b/src/Dictionary/values.luau deleted file mode 100644 index 6db73b3..0000000 --- a/src/Dictionary/values.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function values - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to get the values from. - @return {V} -- The values in the dictionary. - - Gets the values in the given dictionary. - - ```lua - local dictionary = { hello = "roblox", goodbye = "world" } - - local values = Values(dictionary) -- { "roblox", "world" } - ``` -]=] -local function values(dictionary: { [K]: V }): { V } - local result = {} - - for _, value in pairs(dictionary) do - table.insert(result, value) - end - - return result -end - -return values diff --git a/src/Dictionary/values.luau.todo b/src/Dictionary/values.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Dictionary/withKeys.luau b/src/Dictionary/withKeys.luau deleted file mode 100644 index d69ed43..0000000 --- a/src/Dictionary/withKeys.luau +++ /dev/null @@ -1,29 +0,0 @@ ---!strict - ---[=[ - @function withKeys - @within Dictionary - - @param dictionary {[K]: V} -- The dictionary to select the keys from. - @param keys ...K -- The keys to keep. - @return {[K]: V} -- The dictionary with only the given keys. - - Returns a dictionary with the given keys. - - ```lua - local dictionary = { hello = "world", cat = "meow", dog = "woof", unicorn = "rainbow" } - - local withoutCatDog = WithKeys(dictionary, "cat", "dog") -- { cat = "meow", dog = "woof" } - ``` -]=] -local function withKeys(dictionary: { [K]: V }, ...: K): { [K]: V } - local result = {} - - for _, key in ipairs({ ... }) do - result[key] = dictionary[key] - end - - return result -end - -return withKeys diff --git a/src/Dictionary/withKeys.luau.todo b/src/Dictionary/withKeys.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/None.luau b/src/None.luau index 35621e7..15d886e 100644 --- a/src/None.luau +++ b/src/None.luau @@ -1,16 +1,20 @@ ---!strict --[=[ - @prop None None @within Sift + @prop None None - Luau can't distinguish between a nil value and a non-existent value. This - constant is used to represent a non-existent value. It can be used in methods - like `Array.Concat` or `Dictionary.Merge` to remove the value from the result. + Luau doesn't have a built-in `undefined` type, so Sift provides a `None` value to represent the absence of a value. + + ```lua + merge({ foo = "bar", baz = "qux" }, { foo = Sift.None }) + -- { baz = "qux" } + ``` ]=] -local None = newproxy(true) +local None: unknown = newproxy(true) getmetatable(None :: any).__tostring = function() return "Sift.None" end +export type None = typeof(None) + return None diff --git a/src/Set/add.luau b/src/Set/add.luau deleted file mode 100644 index e388d54..0000000 --- a/src/Set/add.luau +++ /dev/null @@ -1,32 +0,0 @@ ---!strict ---[=[ - @function add - @within Set - - @param set { [T]: boolean } -- The set to add the value to. - @param ... ...T -- The values to add. - @return { [T]: boolean } -- The set with the values added. - - Adds values to a set. - - ```lua - local set = { hello = true } - - local newSet = Add(set, "world") -- { hello = true, world = true } - ``` -]=] -local function add(set: { [T]: boolean }, ...: T): { [T]: boolean } - local result = {} - - for key, _ in pairs(set) do - result[key] = true - end - - for _, value in ipairs({ ... }) do - result[value] = true - end - - return result -end - -return add diff --git a/src/Set/add.luau.todo b/src/Set/add.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/copy.luau b/src/Set/copy.luau deleted file mode 100644 index c074e8c..0000000 --- a/src/Set/copy.luau +++ /dev/null @@ -1,21 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local copy = require(Sift.Dictionary.copy) - ---[=[ - @function copy - @within Set - - @param set { [T]: boolean } -- The set to copy. - @return { [T]: boolean } -- A copy of the set. - - Creates a copy of a set. - - ```lua - local set = { hello = true } - - local newSet = Copy(set) -- { hello = true } - ``` -]=] -return copy diff --git a/src/Set/copy.luau.todo b/src/Set/copy.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/count.luau b/src/Set/count.luau deleted file mode 100644 index 2608fae..0000000 --- a/src/Set/count.luau +++ /dev/null @@ -1,42 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - ---[=[ - @function count - @within Set - - @param set { [T]: boolean } -- The set to count. - @param predicate? (item: T, set: { [T]: boolean }) -> boolean? -- The predicate to use to count. - @return number -- The number of items in the set. - - Counts the number of items in a set. - - ```lua - local set = { hello = true, world = true } - - local count = Count(set) -- 2 - local count = Count(set, function(item) - return item == "hello" - end) -- 1 - ``` -]=] -local function count( - set: { [T]: boolean }, - predicate: ((item: T, set: { [T]: boolean }) -> boolean?)? -): number - local counter = 0 - - predicate = if type(predicate) == "function" then predicate else Util.func.truthy - - for item, _ in pairs(set) do - if predicate(item, set) then - counter += 1 - end - end - - return counter -end - -return count diff --git a/src/Set/count.luau.todo b/src/Set/count.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/delete.luau b/src/Set/delete.luau deleted file mode 100644 index 27086bc..0000000 --- a/src/Set/delete.luau +++ /dev/null @@ -1,34 +0,0 @@ ---!strict ---[=[ - @function delete - @within Set - - @param set { [T]: boolean } -- The set to delete from. - @param ... ...T -- The values to delete. - @return { [T]: boolean } -- The set with the values deleted. - - Deletes values from a set. - - Aliases: `subtract` - - ```lua - local set = { hello = true, world = true } - - local newSet = Delete(set, "hello") -- { world = true } - ``` -]=] -local function delete(set: { [T]: boolean }, ...: T): { [T]: boolean } - local result = {} - - for key, _ in pairs(set) do - result[key] = true - end - - for _, value in ipairs({ ... }) do - result[value] = nil - end - - return result -end - -return delete diff --git a/src/Set/delete.luau.todo b/src/Set/delete.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/difference.luau b/src/Set/difference.luau deleted file mode 100644 index 981306c..0000000 --- a/src/Set/difference.luau +++ /dev/null @@ -1,37 +0,0 @@ ---!strict -local T = require(script.Parent.Parent.Types) - ---[=[ - @function difference - @within Set - - @param set Set -- The set to compare. - @param ... ...Set -- The sets to compare against. - @return Set -- The difference between the sets. - - Returns a set of values that are in the first set, but not in the other sets. - - ```lua - local set1 = { hello = true, world = true } - local set2 = { cat = true, dog = true, hello = true } - - local difference = Difference(set1, set2) -- { world = true } - ``` -]=] -local function difference(set: T.Set, ...: T.Set): T.Set - local diff = table.clone(set) - - for _, nextSet in { ... } do - if typeof(nextSet) ~= "table" then - continue - end - - for value in nextSet do - diff[value] = nil - end - end - - return diff -end - -return difference diff --git a/src/Set/difference.luau.todo b/src/Set/difference.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/differenceSymmetric.luau b/src/Set/differenceSymmetric.luau deleted file mode 100644 index 0b25d29..0000000 --- a/src/Set/differenceSymmetric.luau +++ /dev/null @@ -1,41 +0,0 @@ ---!strict -local T = require(script.Parent.Parent.Types) - ---[=[ - @function differenceSymmetric - @within Set - - @param set Set -- The set to compare. - @param ... ...Set -- The sets to compare against. - @return Set -- The symmetric difference between the sets. - - Returns a set of values that are in the first set, but not in the other sets, and vice versa. - - ```lua - local set1 = { hello = true, world = true } - local set2 = { cat = true, dog = true, hello = true } - - local differenceSymmetric = DifferenceSymmetric(set1, set2) -- { world = true, cat = true, dog = true } - ``` -]=] -local function differenceSymmetric(set: T.Set, ...: T.Set): T.Set - local diff = table.clone(set) - - for _, nextSet in { ... } do - if typeof(nextSet) ~= "table" then - continue - end - - for value in nextSet do - diff[value] = if diff[value] == nil then true else false - end - end - - for value, keep in diff do - diff[value] = if keep then true else nil - end - - return diff -end - -return differenceSymmetric diff --git a/src/Set/differenceSymmetric.luau.todo b/src/Set/differenceSymmetric.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/filter.luau b/src/Set/filter.luau deleted file mode 100644 index cf7d5e2..0000000 --- a/src/Set/filter.luau +++ /dev/null @@ -1,41 +0,0 @@ ---!strict -local Sift = script.Parent.Parent - -local Util = require(Sift.Util) - ---[=[ - @function filter - @within Set - - @param set { [T]: boolean } -- The set to filter. - @param predicate? (item: T, set: { [T]: boolean }) -> any -- The function to filter the set with. - @return { [T]: boolean } -- The filtered set. - - Filters a set using a predicate. Any items that do not pass the predicate will be removed from the set. - - ```lua - local set = { hello = true, world = true } - - local newSet = Filter(set, function(value) - return value ~= "hello" - end) -- { world = true } - ``` -]=] -local function filter( - set: { [T]: boolean }, - predicate: ((T, { [T]: boolean }) -> any)? -): { [T]: boolean } - local result = {} - - predicate = if type(predicate) == "function" then predicate else Util.func.truthy - - for key, _ in pairs(set) do - if predicate(key, set) then - result[key] = true - end - end - - return result -end - -return filter diff --git a/src/Set/filter.luau.todo b/src/Set/filter.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/fromArray.luau b/src/Set/fromArray.luau deleted file mode 100644 index 2603e2d..0000000 --- a/src/Set/fromArray.luau +++ /dev/null @@ -1,30 +0,0 @@ ---!strict ---[=[ - @function fromArray - @within Set - - @param array {T} -- The array to convert to a set. - @return {[T]: boolean} -- The set. - - Converts an array to a set, where each item is mapped to true. - Duplicate items are discarded. - - Aliases: `fromList` - - ```lua - local array = { "hello", "world", "hello" } - - local set = FromArray(array) -- { hello = true, world = true } - ``` -]=] -local function fromArray(array: { T }): { [T]: boolean } - local result = table.create(#array) - - for _, value in ipairs(array) do - result[value] = true - end - - return result -end - -return fromArray diff --git a/src/Set/fromArray.luau.todo b/src/Set/fromArray.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/has.luau b/src/Set/has.luau deleted file mode 100644 index 60a9ffc..0000000 --- a/src/Set/has.luau +++ /dev/null @@ -1,22 +0,0 @@ ---!strict ---[=[ - @function has - @within Set - - @param set { [T]: boolean } -- The set to check. - @param value any -- The value to check for. - @return boolean -- Whether the value is in the set. - - Checks whether a value is in a set. - - ```lua - local set = { hello = true } - - local has = Has(set, "hello") -- true - ``` -]=] -local function has(set: { [T]: boolean }, value: any): boolean - return set[value] == true -end - -return has diff --git a/src/Set/has.luau.todo b/src/Set/has.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/init.luau b/src/Set/init.luau index a3290e8..1435ca7 100644 --- a/src/Set/init.luau +++ b/src/Set/init.luau @@ -1,38 +1,4 @@ ---!strict --[=[ - @class Set - - Sets are a collection of values. They are used to store unique values. - They are essentially a dictionary, but each value is stored as a boolean. - This means that a value can only be in a set once. - - ```lua - local set = { hello = true } - - local newSet = Add(set, "world") -- { hello = true, world = true } - ``` + @class Set ]=] -local set = { - add = require(script.add), - copy = require(script.copy), - count = require(script.count), - delete = require(script.delete), - difference = require(script.difference), - differenceSymmetric = require(script.differenceSymmetric), - filter = require(script.filter), - fromArray = require(script.fromArray), - has = require(script.has), - intersection = require(script.intersection), - isSubset = require(script.isSubset), - isSuperset = require(script.isSuperset), - map = require(script.map), - merge = require(script.merge), - toArray = require(script.toArray), -} - -set.fromList = set.fromArray -set.join = set.merge -set.subtract = set.delete -set.union = set.merge - -return set +return {} diff --git a/src/Set/intersection.luau b/src/Set/intersection.luau deleted file mode 100644 index 5ad9dd9..0000000 --- a/src/Set/intersection.luau +++ /dev/null @@ -1,46 +0,0 @@ ---!strict ---[=[ - @function intersection - @within Set - - @param ... ...{ [any]: boolean } -- The sets to intersect. - @return { [T]: boolean } -- The intersection of the sets. - - Creates the intersection of multiple sets. The intersection - is when both sets have a value in common. Unmatched values - are discarded. - - ```lua - local set1 = { hello = true, world = true } - local set2 = { world = true, universe = true } - - local intersection = Intersection(set1, set2) -- { world = true } - ``` -]=] -local function intersection(...: { [any]: boolean }): { [T]: boolean } - local setCount = select("#", ...) - local firstSet = select(1, ...) - - local result = {} - - for key, _ in pairs(firstSet) do - local intersects = true - - for index = 2, setCount do - local set = select(index, ...) - - if set[key] ~= true then - intersects = false - break - end - end - - if intersects then - result[key] = true - end - end - - return result -end - -return intersection diff --git a/src/Set/intersection.luau.todo b/src/Set/intersection.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/isSubset.luau b/src/Set/isSubset.luau deleted file mode 100644 index bc6d554..0000000 --- a/src/Set/isSubset.luau +++ /dev/null @@ -1,29 +0,0 @@ ---!strict ---[=[ - @function isSubset - @within Set - - @param subset { [any]: boolean } -- The subset to check. - @param superset { [any]: boolean } -- The superset to check against. - @return boolean -- Whether the subset is a subset of the superset. - - Checks whether a set is a subset of another set. - - ```lua - local set = { hello = true, world = true } - local subset = { hello = true } - - local isSubset = IsSubset(subset, set) -- true - ``` -]=] -local function isSubset(subset: { [any]: boolean }, superset: { [any]: boolean }): boolean - for key, value in pairs(subset) do - if superset[key] ~= value then - return false - end - end - - return true -end - -return isSubset diff --git a/src/Set/isSubset.luau.todo b/src/Set/isSubset.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/isSuperset.luau b/src/Set/isSuperset.luau deleted file mode 100644 index 20fd656..0000000 --- a/src/Set/isSuperset.luau +++ /dev/null @@ -1,25 +0,0 @@ ---!strict -local isSubset = require(script.Parent.isSubset) - ---[=[ - @function isSuperset - @within Set - - @param superset { [any]: boolean } -- The superset to check. - @param subset { [any]: boolean } -- The subset to check against. - @return boolean -- Whether the superset is a superset of the subset. - - Checks whether a set is a superset of another set. - - ```lua - local set = { hello = true, world = true } - local subset = { hello = true } - - local isSuperset = IsSuperset(set, subset) -- true - ``` -]=] -local function isSuperset(superset: { [any]: boolean }, subset: { [any]: boolean }): boolean - return isSubset(subset, superset) -end - -return isSuperset diff --git a/src/Set/isSuperset.luau.todo b/src/Set/isSuperset.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/map.luau b/src/Set/map.luau deleted file mode 100644 index 98d7ef9..0000000 --- a/src/Set/map.luau +++ /dev/null @@ -1,34 +0,0 @@ ---!strict ---[=[ - @function map - @within Set - - @param set { [T]: boolean } -- The set to map. - @param mapper (T, {[T]: boolean}) -> U -- The mapper function. - @return {[U]: boolean} -- The mapped set. - - Iterates over a set, calling a mapper function for each item. - - ```lua - local set = { hello = true, world = true } - - local mappedSet = Map(set, function(value) - return value .. "!" - end) -- { ["hello!"] = true, ["world!"] = true } - ``` -]=] -local function map(set: { [T]: boolean }, mapper: (T, { [T]: boolean }) -> U): { [U]: boolean } - local result = {} - - for key, _ in pairs(set) do - local mappedKey = mapper(key, set) - - if mappedKey ~= nil then - result[mappedKey] = true - end - end - - return result -end - -return map diff --git a/src/Set/map.luau.todo b/src/Set/map.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/merge.luau b/src/Set/merge.luau deleted file mode 100644 index 2206eb9..0000000 --- a/src/Set/merge.luau +++ /dev/null @@ -1,38 +0,0 @@ ---!strict ---[=[ - @function merge - @within Set - - @param ... ...any -- The sets to merge. - @return { [T]: boolean } -- The merged set. - - Combines one or more sets into a single set. - - Aliases: `join`, `union` - - ```lua - local set1 = { hello = true, world = true } - local set2 = { cat = true, dog = true, hello = true } - - local merge = Merge(set1, set2) -- { hello = true, world = true, cat = true, dog = true } - ``` -]=] -local function merge(...: any): { [T]: boolean } - local result = {} - - for setIndex = 1, select("#", ...) do - local set = select(setIndex, ...) - - if type(set) ~= "table" then - continue - end - - for key, _ in pairs(set) do - result[key] = true - end - end - - return result -end - -return merge diff --git a/src/Set/merge.luau.todo b/src/Set/merge.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Set/toArray.luau b/src/Set/toArray.luau deleted file mode 100644 index 47af022..0000000 --- a/src/Set/toArray.luau +++ /dev/null @@ -1,27 +0,0 @@ ---!strict ---[=[ - @function toArray - @within Set - - @param set { [T]: boolean } -- The set to convert to an array. - @return {T} -- The array. - - Converts a set to an array. - - ```lua - local set = { hello = true, world = true } - - local array = ToArray(set) -- { "hello", "world" } - ``` -]=] -local function toArray(set: { [T]: boolean }): { T } - local result = {} - - for key, _ in pairs(set) do - table.insert(result, key) - end - - return result -end - -return toArray diff --git a/src/Set/toArray.luau.todo b/src/Set/toArray.luau.todo new file mode 100644 index 0000000..e69de29 diff --git a/src/Types.luau b/src/Types.luau index 6888931..4eb43dd 100644 --- a/src/Types.luau +++ b/src/Types.luau @@ -1,16 +1,13 @@ --selene: allow(unused_variable) -local None = require(script.Parent.None) +local None = require("./Types") --[=[ @type None None @within Sift ]=] export type None = typeof(None) -export type Dictionary = { [K]: V } -export type Array = Dictionary -export type Set = Dictionary -export type Table = Dictionary +export type Dictionary = { [K]: V } +export type Array = Dictionary +export type Set = Dictionary -export type AnyDictionary = Dictionary - -return nil +return {} diff --git a/src/Util.luau b/src/Util.luau new file mode 100644 index 0000000..199a12d --- /dev/null +++ b/src/Util.luau @@ -0,0 +1,36 @@ +local function isEmpty(value) + if typeof(value) == "table" then + return next(value) == nil + end + + return value == nil +end + +local function areEqual(...) + local args = { ... } + local first = table.remove(args, 1) + + for _, value in args do + if first ~= value then + return false + end + end + + return true +end + +local function normalizeIndex(index, length) + if index == 0 then + return 1 + elseif index < 0 then + return index + length + 1 + end + + return index +end + +return { + isEmpty = isEmpty, + areEqual = areEqual, + normalizeIndex = normalizeIndex, +} diff --git a/src/Util/equalObjects.luau b/src/Util/equalObjects.luau deleted file mode 100644 index be3eb8d..0000000 --- a/src/Util/equalObjects.luau +++ /dev/null @@ -1,32 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) - ---[=[ - @function equalObjects - @within Sift - - @param ... ...table -- The tables to compare. - @return boolean -- Whether or not the tables are equal. - - Compares two or more tables to see if they are equal. - - ```lua - local a = { hello = "world" } - local b = { hello = "world" } - - local equal = EqualObjects(a, b) -- true - ``` -]=] -local function equalObjects(...: _T.Table): boolean - local firstItem = select(1, ...) - - for i = 2, select("#", ...) do - if firstItem ~= select(i, ...) then - return false - end - end - - return true -end - -return equalObjects diff --git a/src/Util/func.luau b/src/Util/func.luau deleted file mode 100644 index 241013c..0000000 --- a/src/Util/func.luau +++ /dev/null @@ -1,15 +0,0 @@ -local function truthy() - return true -end - -local function noop() end - -local function returned(...) - return ... -end - -return { - truthy = truthy, - noop = noop, - returned = returned, -} diff --git a/src/Util/init.luau b/src/Util/init.luau deleted file mode 100644 index cb5ec52..0000000 --- a/src/Util/init.luau +++ /dev/null @@ -1,5 +0,0 @@ -return { - equalObjects = require(script.equalObjects), - func = require(script.func), - isEmpty = require(script.isEmpty), -} diff --git a/src/Util/isEmpty.luau b/src/Util/isEmpty.luau deleted file mode 100644 index 8cdc666..0000000 --- a/src/Util/isEmpty.luau +++ /dev/null @@ -1,26 +0,0 @@ ---!strict -local _T = require(script.Parent.Parent.Types) - ---[=[ - @function isEmpty - @within Sift - @since v0.0.1 - - @param table table -- The table to check. - @return boolean -- Whether or not the table is empty. - - Checks whether or not a table is empty. - - ```lua - local a = {} - local b = { hello = "world" } - - local value = isEmpty(a) -- true - local value = isEmpty(b) -- false - ``` -]=] -local function isEmpty(table: _T.Table): boolean - return next(table) == nil -end - -return isEmpty diff --git a/src/init.luau b/src/init.luau index 0882756..754dc10 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,60 +1,22 @@ ---!strict -local Types = require(script.Types) +-- local T = require("@Sift/Types") --[=[ @class Sift - Sift is a library for manipulating arrays. It provides a number of - functions for manipulating arrays (lists), dictionaries, and sets. - - Sift is comprised of a number of submodules. Each submodule provides - a number of functions for manipulating a specific type of data, and - can be accessed via their respective names within the Sift module - (e.g. `Sift.Array.At()`), or accessed directly (e.g. `local At = require(Sift.Array.At)`). - - Some methods and modules also have aliases, which can are documented in the - corresponding submodule/method's documentation. - - See the individual submodule pages for full documentation. - - The Luau types `Dictionary`, `Array` (aliased as `List`) and `Set` are exported from the Sift module (e.g. they can be used via `Sift.Array`), but are also available from [Sift.Types]. + Sift is a library for working with immutable data structures. It provides a collection of methods for working with arrays, dictionaries and sets. ]=] local Sift = { - Array = require(script.Array), - Dictionary = require(script.Dictionary), - Set = require(script.Set), - - None = require(script.None), - Types = require(script.Types), + Array = require("@Sift/Array"), + Dictionary = require("@Sift/Dictionary"), + Set = require("@Sift/Set"), - equalObjects = require(script.Util.equalObjects), - isEmpty = require(script.Util.isEmpty), + None = require("@Sift/None"), + Types = require("@Sift/Types"), - meta = require(script.Metadata), + equalObjects = require("@Sift/Util/equalObjects"), + isEmpty = require("@Sift/Util/isEmpty"), } Sift.List = Sift.Array ---- @prop Array Array ---- @within Sift - ---- @prop List Array ---- @within Sift ---- @tag Alias - ---- @prop Dictionary Dictionary ---- @within Sift - ---- @prop Set Set ---- @within Sift - ---- @prop Types Types ---- @within Sift - -export type Dictionary = Types.Dictionary - -export type Array = Types.Array -export type List = Array -export type Set = Types.Set - return Sift diff --git a/test.project.json b/test.project.json deleted file mode 100644 index c762d13..0000000 --- a/test.project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "SiftTest", - "tree": { - "$className": "DataModel", - "ServerScriptService": { - "$className": "ServerScriptService", - "Sift": { - "$path": "default.project.json" - } - }, - "TestService": { - "$className": "TestService", - "$properties": { - "ExecuteWithStudioRun": true - }, - "Packages": { - "$className": "Folder", - "TestEZ": { - "$path": "modules/testez" - } - }, - "TestRunner": { - "$path": "TestRunner.server.lua" - } - }, - "Players": { - "$className": "Players", - "$properties": { - "CharacterAutoLoads": false - } - } - } -} diff --git a/wally.toml b/wally.toml index 1ccbfd2..e6588b6 100644 --- a/wally.toml +++ b/wally.toml @@ -1,7 +1,7 @@ [package] name = "csqrl/sift" description = "Immutable data library for Luau" -version = "0.0.9" +version = "0.1.0" registry = "https://github.com/upliftgames/wally-index" realm = "shared" exclude = ["**"] From 0672a520ec1af68011a751970dc0ece54db598bf Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:23:42 +0000 Subject: [PATCH 06/43] Reimplement sets and array diffs --- src/Array/count.luau | 2 +- src/Array/difference.luau | 29 ++++++++++++++ src/Array/difference.luau.todo | 1 - src/Array/differenceSymmetric.luau | 29 ++++++++++++++ src/Array/differenceSymmetric.luau.todo | 1 - src/Array/init.luau | 52 ++++++++++++++++++++++++- src/Array/partition.luau | 5 ++- src/Set/add.luau | 20 ++++++++++ src/Set/add.luau.todo | 0 src/Set/copy.luau | 20 ++++++++++ src/Set/copy.luau.todo | 0 src/Set/count.luau | 27 +++++++++++++ src/Set/count.luau.todo | 0 src/Set/delete.luau | 21 ++++++++++ src/Set/delete.luau.todo | 0 src/Set/difference.luau | 27 +++++++++++++ src/Set/difference.luau.todo | 0 src/Set/differenceSymmetric.luau | 36 +++++++++++++++++ src/Set/differenceSymmetric.luau.todo | 0 src/Set/filter.luau | 24 ++++++++++++ src/Set/filter.luau.todo | 0 src/Set/fromArray.luau | 21 ++++++++++ src/Set/fromArray.luau.todo | 0 src/Set/has.luau | 14 +++++++ src/Set/has.luau.todo | 0 src/Set/init.luau | 28 ++++++++++++- src/Set/intersection.luau | 34 ++++++++++++++++ src/Set/intersection.luau.todo | 0 src/Set/isSubset.luau | 23 +++++++++++ src/Set/isSubset.luau.todo | 0 src/Set/isSuperset.luau | 19 +++++++++ src/Set/isSuperset.luau.todo | 0 src/Set/map.luau | 28 +++++++++++++ src/Set/map.luau.todo | 0 src/Set/merge.luau | 29 ++++++++++++++ src/Set/merge.luau.todo | 0 src/Set/partition.luau | 32 +++++++++++++++ src/Set/toArray.luau | 21 ++++++++++ src/Set/toArray.luau.todo | 0 src/Types.luau | 13 ------- src/init.luau | 18 ++++----- 41 files changed, 544 insertions(+), 30 deletions(-) create mode 100644 src/Array/difference.luau delete mode 100644 src/Array/difference.luau.todo create mode 100644 src/Array/differenceSymmetric.luau delete mode 100644 src/Array/differenceSymmetric.luau.todo create mode 100644 src/Set/add.luau delete mode 100644 src/Set/add.luau.todo create mode 100644 src/Set/copy.luau delete mode 100644 src/Set/copy.luau.todo create mode 100644 src/Set/count.luau delete mode 100644 src/Set/count.luau.todo create mode 100644 src/Set/delete.luau delete mode 100644 src/Set/delete.luau.todo create mode 100644 src/Set/difference.luau delete mode 100644 src/Set/difference.luau.todo create mode 100644 src/Set/differenceSymmetric.luau delete mode 100644 src/Set/differenceSymmetric.luau.todo create mode 100644 src/Set/filter.luau delete mode 100644 src/Set/filter.luau.todo create mode 100644 src/Set/fromArray.luau delete mode 100644 src/Set/fromArray.luau.todo create mode 100644 src/Set/has.luau delete mode 100644 src/Set/has.luau.todo create mode 100644 src/Set/intersection.luau delete mode 100644 src/Set/intersection.luau.todo create mode 100644 src/Set/isSubset.luau delete mode 100644 src/Set/isSubset.luau.todo create mode 100644 src/Set/isSuperset.luau delete mode 100644 src/Set/isSuperset.luau.todo create mode 100644 src/Set/map.luau delete mode 100644 src/Set/map.luau.todo create mode 100644 src/Set/merge.luau delete mode 100644 src/Set/merge.luau.todo create mode 100644 src/Set/partition.luau create mode 100644 src/Set/toArray.luau delete mode 100644 src/Set/toArray.luau.todo delete mode 100644 src/Types.luau diff --git a/src/Array/count.luau b/src/Array/count.luau index 4c63418..07f6e93 100644 --- a/src/Array/count.luau +++ b/src/Array/count.luau @@ -17,7 +17,7 @@ local function count(array: { T }, predicate: ((value: T, index: number) -> b for index, value in array do if not predicate or predicate(value, index) then - counter = counter + 1 + counter += 1 end end diff --git a/src/Array/difference.luau b/src/Array/difference.luau new file mode 100644 index 0000000..5b19715 --- /dev/null +++ b/src/Array/difference.luau @@ -0,0 +1,29 @@ +local setDifference = require("@Sift/Set/difference") +local toArray = require("@Sift/Set/toArray") +local toSet = require("./toSet") + +--[=[ + @within Array + + Returns a new array containing only values that are in the first array and not in any of the other arrays. + + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 2, 3, 4 } + + difference(array1, array2) -- { 1 } + ``` +]=] +local function difference(array: { T }, ...: { T }): { T } + local arraySet = toSet(array) + local otherSets = {} + + for _, other in { ... } do + table.insert(otherSets, toSet(other)) + end + + local differenceSet = setDifference(arraySet, unpack(otherSets)) + return toArray(differenceSet) +end + +return difference diff --git a/src/Array/difference.luau.todo b/src/Array/difference.luau.todo deleted file mode 100644 index 6c399e6..0000000 --- a/src/Array/difference.luau.todo +++ /dev/null @@ -1 +0,0 @@ -requires sets diff --git a/src/Array/differenceSymmetric.luau b/src/Array/differenceSymmetric.luau new file mode 100644 index 0000000..baf4383 --- /dev/null +++ b/src/Array/differenceSymmetric.luau @@ -0,0 +1,29 @@ +local setDifferenceSymmetric = require("@Sift/Set/differenceSymmetric") +local toArray = require("@Sift/Set/toArray") +local toSet = require("./toSet") + +--[=[ + @within Array + + Returns a new array containing the values that are only present in one of the input array. + + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 2, 3, 4 } + + differenceSymmetric(array1, array2) -- { 1, 4 } + ``` +]=] +local function differenceSymmetric(array: { T }, ...: { T }): { T } + local arraySet = toSet(array) + local otherSets = {} + + for _, other in { ... } do + table.insert(otherSets, toSet(other)) + end + + local differenceSet = setDifferenceSymmetric(arraySet, unpack(otherSets)) + return toArray(differenceSet) +end + +return differenceSymmetric diff --git a/src/Array/differenceSymmetric.luau.todo b/src/Array/differenceSymmetric.luau.todo deleted file mode 100644 index 6c399e6..0000000 --- a/src/Array/differenceSymmetric.luau.todo +++ /dev/null @@ -1 +0,0 @@ -requires sets diff --git a/src/Array/init.luau b/src/Array/init.luau index 7d42d9b..735a0a9 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -7,6 +7,54 @@ local array = { 1, 2, 3 } ``` ]=] -local Array = {} +local array = { + at = require("./at"), + concat = require("./concat"), + copy = require("./copy"), + copyDeep = require("./copyDeep"), + count = require("./count"), + create = require("./create"), + difference = require("./difference"), + differenceSymmetric = require("./differenceSymmetric"), + equals = require("./equals"), + equalsDeep = require("./equalsDeep"), + every = require("./every"), + filter = require("./filter"), + find = require("./find"), + findLast = require("./findLast"), + findWhere = require("./findWhere"), + findWhereLast = require("./findWhereLast"), + first = require("./first"), + flatten = require("./flatten"), + freeze = require("./freeze"), + freezeDeep = require("./freezeDeep"), + includes = require("./includes"), + insert = require("./insert"), + is = require("./is"), + last = require("./last"), + map = require("./map"), + partition = require("./partition"), + pop = require("./pop"), + push = require("./push"), + reduce = require("./reduce"), + reduceRight = require("./reduceRight"), + removeIndex = require("./removeIndex"), + removeIndices = require("./removeIndices"), + removeValue = require("./removeValue"), + removeValues = require("./removeValues"), + reverse = require("./reverse"), + set = require("./set"), + shift = require("./shift"), + shuffle = require("./shuffle"), + slice = require("./slice"), + some = require("./some"), + sort = require("./sort"), + splice = require("./splice"), + toSet = require("./toSet"), + unshift = require("./unshift"), + update = require("./update"), + zip = require("./zip"), + zipAll = require("./zipAll"), +} -return Array +return array diff --git a/src/Array/partition.luau b/src/Array/partition.luau index 9a9f8a0..64f1c7f 100644 --- a/src/Array/partition.luau +++ b/src/Array/partition.luau @@ -12,7 +12,10 @@ -- odd: { 1, 3, 5 } ``` ]=] -local function partition(array: { T }, filterer: (value: T, index: number) -> boolean) +local function partition( + array: { T }, + filterer: (value: T, index: number) -> boolean +): ({ T }, { T }) local pass = {} local fail = {} diff --git a/src/Set/add.luau b/src/Set/add.luau new file mode 100644 index 0000000..cb06a0a --- /dev/null +++ b/src/Set/add.luau @@ -0,0 +1,20 @@ +local copy = require("./copy") + +--[=[ + @within Set + + Returns a new set with the given value added to it. + + ```lua + local set = { a = true, b = true } + add(set, "c") -- { a = true, b = true, c = true } + ``` +]=] +local function add(set: { [T]: boolean }, value: T): { [T]: boolean } + local newSet = copy(set) + newSet[value] = true + + return newSet +end + +return add diff --git a/src/Set/add.luau.todo b/src/Set/add.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/copy.luau b/src/Set/copy.luau new file mode 100644 index 0000000..be0cd57 --- /dev/null +++ b/src/Set/copy.luau @@ -0,0 +1,20 @@ +--[=[ + @within Set + + Returns a shallow copy of the set. + + ```lua + copy({ a = true, b = true }) -- { a = true, b = true } + ``` +]=] +local function copy(set: { [T]: boolean }): { [T]: boolean } + local out = {} + + for value in set do + out[value] = true + end + + return out +end + +return copy diff --git a/src/Set/copy.luau.todo b/src/Set/copy.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/count.luau b/src/Set/count.luau new file mode 100644 index 0000000..0d44e64 --- /dev/null +++ b/src/Set/count.luau @@ -0,0 +1,27 @@ +--[=[ + @within Set + + Returns the number of elements in the set that satisfy the provided predicate. + + ```lua + local set = { a = true, b = true, c = true } + + count(set) -- 3 + count(set, function(value) + return value ~= "b" + end) -- 2 + ``` +]=] +local function count(set: { [T]: boolean }, predicate: ((value: T) -> boolean)?): number + local counter = 0 + + for value in set do + if not predicate or predicate(value) then + counter += 1 + end + end + + return counter +end + +return count diff --git a/src/Set/count.luau.todo b/src/Set/count.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/delete.luau b/src/Set/delete.luau new file mode 100644 index 0000000..415248c --- /dev/null +++ b/src/Set/delete.luau @@ -0,0 +1,21 @@ +local filter = require("./filter") + +--[=[ + @within Set + + Returns a new set with the given value removed. + + ```lua + local set = { a = true, b = true, c = true } + delete(set, "b", "c") -- { a = true } + ``` +]=] +local function delete(set: { [T]: boolean }, ...: T): { [T]: boolean } + local values = { ... } + + return filter(set, function(value: T): boolean + return table.find(values, value) == nil + end) +end + +return delete diff --git a/src/Set/delete.luau.todo b/src/Set/delete.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/difference.luau b/src/Set/difference.luau new file mode 100644 index 0000000..6578b70 --- /dev/null +++ b/src/Set/difference.luau @@ -0,0 +1,27 @@ +local copy = require("./copy") + +--[=[ + @within Set + + Returns a new set containing only values that are in the first set and not in any of the other sets. + + ```lua + local set1 = { a = true, b = true, c = true } + local set2 = { b = true, c = true, d = true } + + difference(set1, set2) -- { a = true } + ``` +]=] +local function difference(set: { [T]: boolean }, ...: { [T]: boolean }): { [T]: boolean } + local out = copy(set) + + for _, other in { ... } do + for value in other do + out[value] = nil + end + end + + return out +end + +return difference diff --git a/src/Set/difference.luau.todo b/src/Set/difference.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/differenceSymmetric.luau b/src/Set/differenceSymmetric.luau new file mode 100644 index 0000000..7c9f02e --- /dev/null +++ b/src/Set/differenceSymmetric.luau @@ -0,0 +1,36 @@ +local copy = require("./copy") + +--[=[ + @within Set + + Returns a new set containing the values that are only present in one of the input sets. + + ```lua + local set1 = { a = true, b = true, c = true } + local set2 = { b = true, c = true, d = true } + + differenceSymmetric(set1, set2) -- { a = true, d = true } + ``` +]=] +local function differenceSymmetric( + set: { [T]: boolean }, + ...: { [T]: boolean } +): { [T]: boolean } + local out = copy(set) + + for _, other in { ... } do + for value in other do + out[value] = out[value] == nil + end + end + + for value, keep in out do + if not keep then + out[value] = nil + end + end + + return out +end + +return differenceSymmetric diff --git a/src/Set/differenceSymmetric.luau.todo b/src/Set/differenceSymmetric.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/filter.luau b/src/Set/filter.luau new file mode 100644 index 0000000..8685caf --- /dev/null +++ b/src/Set/filter.luau @@ -0,0 +1,24 @@ +--[=[ + @within Set + + Returns a new set containing only the elements of the input set for which the filterer function returns `true`. + + ```lua + filter({ a = true, b = true, c = true }, function(value) + return value ~= "b" + end) -- { a = true, c = true } + ``` +]=] +local function filter(set: { [T]: boolean }, filterer: (value: T) -> boolean): { [T]: boolean } + local out = {} + + for value in set do + if filterer(value) then + out[value] = true + end + end + + return out +end + +return filter diff --git a/src/Set/filter.luau.todo b/src/Set/filter.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/fromArray.luau b/src/Set/fromArray.luau new file mode 100644 index 0000000..db96598 --- /dev/null +++ b/src/Set/fromArray.luau @@ -0,0 +1,21 @@ +--[=[ + @within Set + + Returns a set from an array. The set will contain all the unique values from the array. + + ```lua + fromArray({ "a", "b", "c" }) + -- { a = true, b = true, c = true } + ``` +]=] +local function fromArray(array: { T }): { [T]: boolean } + local out = {} + + for _, value in array do + out[value] = true + end + + return out +end + +return fromArray diff --git a/src/Set/fromArray.luau.todo b/src/Set/fromArray.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/has.luau b/src/Set/has.luau new file mode 100644 index 0000000..f4b7e6c --- /dev/null +++ b/src/Set/has.luau @@ -0,0 +1,14 @@ +--[=[ + @within Set + + Returns whether the set contains the given value. + + ```lua + has({ a = true, b = true }, "a") -- true + ``` +]=] +local function has(set: { [T]: boolean }, value: T): boolean + return set[value] == true +end + +return has diff --git a/src/Set/has.luau.todo b/src/Set/has.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/init.luau b/src/Set/init.luau index 1435ca7..9f39de7 100644 --- a/src/Set/init.luau +++ b/src/Set/init.luau @@ -1,4 +1,30 @@ --[=[ @class Set + + A set is a collection of unique values. + + ```lua + local set = { a = true, b = true, c = true } + fromArray({ 1, 2, 3 }) -- { [1] = true, [2] = true, [3] = true } + ``` ]=] -return {} +local set = { + add = require("./add"), + copy = require("./copy"), + count = require("./count"), + delete = require("./delete"), + difference = require("./difference"), + differenceSymmetric = require("./differenceSymmetric"), + filter = require("./filter"), + fromArray = require("./fromArray"), + has = require("./has"), + intersection = require("./intersection"), + isSubset = require("./isSubset"), + isSuperset = require("./isSuperset"), + map = require("./map"), + merge = require("./merge"), + partition = require("./partition"), + toArray = require("./toArray"), +} + +return set diff --git a/src/Set/intersection.luau b/src/Set/intersection.luau new file mode 100644 index 0000000..1283f70 --- /dev/null +++ b/src/Set/intersection.luau @@ -0,0 +1,34 @@ +--[=[ + @within Set + + Returns a new set containing values that appear in all of the input sets. + + ```lua + local set1 = { a = true, b = true, c = true } + local set2 = { b = true, c = true, d = true } + + intersection(set1, set2) -- { b = true, c = true } + ``` +]=] +local function intersection(set: { [T]: boolean }, ...: { [T]: boolean }): { [T]: boolean } + local out = {} + + for value in set do + local intersects = true + + for _, other in { ... } do + if not other[value] then + intersects = false + break + end + end + + if intersects then + out[value] = true + end + end + + return out +end + +return intersection diff --git a/src/Set/intersection.luau.todo b/src/Set/intersection.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/isSubset.luau b/src/Set/isSubset.luau new file mode 100644 index 0000000..0d69de8 --- /dev/null +++ b/src/Set/isSubset.luau @@ -0,0 +1,23 @@ +--[=[ + @within Set + + Returns whether or not the first set is a subset of the second set. + + ```lua + local superset = { a = true, b = true, c = true } + local subset = { a = true, b = true } + + isSubset(subset, superset) -- true + ``` +]=] +local function isSubset(subset: { [T]: boolean }, superset: { [T]: boolean }): boolean + for value in subset do + if not superset[value] then + return false + end + end + + return true +end + +return isSubset diff --git a/src/Set/isSubset.luau.todo b/src/Set/isSubset.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/isSuperset.luau b/src/Set/isSuperset.luau new file mode 100644 index 0000000..c41ea2e --- /dev/null +++ b/src/Set/isSuperset.luau @@ -0,0 +1,19 @@ +local isSubset = require("./isSubset") + +--[=[ + @within Set + + Returns whether or not the first set is the superset of the second set. + + ```lua + local superset = { a = true, b = true, c = true } + local subset = { a = true, b = true } + + isSuperset(superset, subset) -- true + ``` +]=] +local function isSuperset(superset: { [T]: boolean }, subset: { [T]: boolean }): boolean + return isSubset(subset, superset) +end + +return isSuperset diff --git a/src/Set/isSuperset.luau.todo b/src/Set/isSuperset.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/map.luau b/src/Set/map.luau new file mode 100644 index 0000000..ce7e64b --- /dev/null +++ b/src/Set/map.luau @@ -0,0 +1,28 @@ +local None = require("@Sift/None") + +--[=[ + @within Set + + Returns a new set with the results of applying the provided function to each element of the original set. + + ```lua + map({ a = true, b = true, c = true }, function(value) + return value .. "!" + end) -- { ["a!"] = true, ["b!"] = true, ["c!"] = true } + ``` +]=] +local function map(set: { [T]: boolean }, mapper: (value: T) -> U): { [U]: boolean } + local out = {} + + for value in set do + local mapped = mapper(value) + + if mapped ~= nil and mapped ~= None then + out[mapped] = true + end + end + + return out +end + +return map diff --git a/src/Set/map.luau.todo b/src/Set/map.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/merge.luau b/src/Set/merge.luau new file mode 100644 index 0000000..9c7b7d2 --- /dev/null +++ b/src/Set/merge.luau @@ -0,0 +1,29 @@ +local None = require("@Sift/None") + +--[=[ + @within Set + + Combines multiple sets into a single set. + + ```lua + local set1 = { a = true, b = true } + local set2 = { b = true, c = true } + + merge(set1, set2) -- { a = true, b = true, c = true } + ``` +]=] +local function merge(...: { [T]: boolean }): { [T]: boolean } + local out = {} + + for _, set in { ... } do + for value in set do + if value ~= None then + out[value] = true + end + end + end + + return out +end + +return merge diff --git a/src/Set/merge.luau.todo b/src/Set/merge.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Set/partition.luau b/src/Set/partition.luau new file mode 100644 index 0000000..446c453 --- /dev/null +++ b/src/Set/partition.luau @@ -0,0 +1,32 @@ +--[=[ + @within Set + + Filters a set into two sets based on a filter function. The first set contains all values that pass the filter, and the second set contains all values that fail the filter. + + ```lua + local set = { a = true, b = true, c = true, d = true } + + partition(set, function(value) + return value ~= "c" + end) -- { a = true, b = true, d = true }, { c = true } + ``` +]=] +local function partition( + set: { [T]: boolean }, + predicate: (value: T) -> boolean +): ({ [T]: boolean }, { [T]: boolean }) + local pass = {} + local fail = {} + + for value in set do + if predicate(value) then + pass[value] = true + else + fail[value] = true + end + end + + return pass, fail +end + +return partition diff --git a/src/Set/toArray.luau b/src/Set/toArray.luau new file mode 100644 index 0000000..2e946c2 --- /dev/null +++ b/src/Set/toArray.luau @@ -0,0 +1,21 @@ +--[=[ + @within Set + + Converts a set to an array. + + ```lua + local set = { a = true, b = true, c = true } + toArray(set) -- { "a", "b", "c" } + ``` +]=] +local function toArray(set: { [T]: boolean }): { T } + local out = {} + + for value in set do + table.insert(out, value) + end + + return out +end + +return toArray diff --git a/src/Set/toArray.luau.todo b/src/Set/toArray.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Types.luau b/src/Types.luau deleted file mode 100644 index 4eb43dd..0000000 --- a/src/Types.luau +++ /dev/null @@ -1,13 +0,0 @@ ---selene: allow(unused_variable) -local None = require("./Types") - ---[=[ - @type None None - @within Sift -]=] -export type None = typeof(None) -export type Dictionary = { [K]: V } -export type Array = Dictionary -export type Set = Dictionary - -return {} diff --git a/src/init.luau b/src/init.luau index 754dc10..c35150c 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,22 +1,20 @@ --- local T = require("@Sift/Types") +local Util = require("@Sift/Util") --[=[ @class Sift Sift is a library for working with immutable data structures. It provides a collection of methods for working with arrays, dictionaries and sets. ]=] -local Sift = { +local sift = { + None = require("@Sift/None"), + Array = require("@Sift/Array"), Dictionary = require("@Sift/Dictionary"), Set = require("@Sift/Set"), - None = require("@Sift/None"), - Types = require("@Sift/Types"), - - equalObjects = require("@Sift/Util/equalObjects"), - isEmpty = require("@Sift/Util/isEmpty"), + areEqual = Util.areEqual, + isEmpty = Util.isEmpty, + normalizeIndex = Util.normalizeIndex, } -Sift.List = Sift.Array - -return Sift +return sift From 2cfeb7ca4762c193e21730b68b347a6107cf70dd Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:20:32 +0000 Subject: [PATCH 07/43] Update .gitattributes --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 9de76e4..23894f8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,4 @@ * text=auto # Highlight Luau as Lua files -*.lua linguist-language=Luau +*.luau linguist-language=Lua From 293274cdcc4ddaf7aca78ab8b8443c7bce8a657d Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:21:26 +0000 Subject: [PATCH 08/43] Update .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 23894f8..9ffdc1f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ # Highlight Luau as Lua files *.luau linguist-language=Lua +*.luau.todo linguist-language=Lua From 79d405208be143d4508851665bf7cfa1e19523df Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:41:44 +0000 Subject: [PATCH 09/43] Refactor `Array.includes` and partial Dictionary reimplementation --- src/Array/includes.luau | 3 ++- src/Dictionary/copy.luau | 13 ++++++++++ src/Dictionary/copyDeep.luau | 25 +++++++++++++++++++ .../{copy.luau.todo => difference.luau.todo} | 0 ...uau.todo => differenceSymmetric.luau.todo} | 0 src/Dictionary/flip.luau | 21 ++++++++++++++++ src/Dictionary/flip.luau.todo | 0 src/Dictionary/freeze.luau | 20 +++++++++++++++ src/Dictionary/freeze.luau.todo | 0 src/Dictionary/get.luau | 24 ++++++++++++++++++ src/Dictionary/has.luau | 14 +++++++++++ src/Dictionary/has.luau.todo | 0 src/Dictionary/includes.luau | 20 +++++++++++++++ src/Dictionary/includes.luau.todo | 0 src/Dictionary/keys.luau | 20 +++++++++++++++ src/Dictionary/keys.luau.todo | 0 src/Dictionary/set.luau | 19 ++++++++++++++ src/Dictionary/set.luau.todo | 0 src/Dictionary/values.luau | 20 +++++++++++++++ src/Dictionary/values.luau.todo | 0 20 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 src/Dictionary/copy.luau create mode 100644 src/Dictionary/copyDeep.luau rename src/Dictionary/{copy.luau.todo => difference.luau.todo} (100%) rename src/Dictionary/{copyDeep.luau.todo => differenceSymmetric.luau.todo} (100%) create mode 100644 src/Dictionary/flip.luau delete mode 100644 src/Dictionary/flip.luau.todo create mode 100644 src/Dictionary/freeze.luau delete mode 100644 src/Dictionary/freeze.luau.todo create mode 100644 src/Dictionary/get.luau create mode 100644 src/Dictionary/has.luau delete mode 100644 src/Dictionary/has.luau.todo create mode 100644 src/Dictionary/includes.luau delete mode 100644 src/Dictionary/includes.luau.todo create mode 100644 src/Dictionary/keys.luau delete mode 100644 src/Dictionary/keys.luau.todo create mode 100644 src/Dictionary/set.luau delete mode 100644 src/Dictionary/set.luau.todo create mode 100644 src/Dictionary/values.luau delete mode 100644 src/Dictionary/values.luau.todo diff --git a/src/Array/includes.luau b/src/Array/includes.luau index e63b46d..76cee10 100644 --- a/src/Array/includes.luau +++ b/src/Array/includes.luau @@ -10,7 +10,8 @@ local find = require("./find") ``` ]=] local function includes(array: { T }, value: T, from: number?): boolean - return find(array, value, from) ~= nil + local index = find(array, value, from) + return index ~= nil end return includes diff --git a/src/Dictionary/copy.luau b/src/Dictionary/copy.luau new file mode 100644 index 0000000..490eae1 --- /dev/null +++ b/src/Dictionary/copy.luau @@ -0,0 +1,13 @@ +--[=[ + @within Dictionary + @function copy + @param dictionary { [K]: V } + @return { [K]: V } + + Returns a shallow copy of the dictionary. Use [Dictionary.copyDeep] to copy nested arrays. + + ```lua + copy({ a = 1, b = 2 }) -- { a = 1, b = 2 } + ``` +]=] +return table.clone diff --git a/src/Dictionary/copyDeep.luau b/src/Dictionary/copyDeep.luau new file mode 100644 index 0000000..772f1dd --- /dev/null +++ b/src/Dictionary/copyDeep.luau @@ -0,0 +1,25 @@ +--[=[ + @within Dictionary + + Returns a deep copy of the given dictionary. This means that all nested tables are also copied. + + ```lua + local dictionary = { a = 1, b = { c = 2 } } + copyDeep(dictionary) -- { a = 1, b = { c = 2 } } + ``` +]=] +local function copyDeep(dictionary: { [K]: V }): { [K]: V } + local out: { [K]: V } = {} + + for key, value in dictionary do + if typeof(value) == "table" then + out[key] = copyDeep(value) :: any + else + out[key] = value + end + end + + return out +end + +return copyDeep diff --git a/src/Dictionary/copy.luau.todo b/src/Dictionary/difference.luau.todo similarity index 100% rename from src/Dictionary/copy.luau.todo rename to src/Dictionary/difference.luau.todo diff --git a/src/Dictionary/copyDeep.luau.todo b/src/Dictionary/differenceSymmetric.luau.todo similarity index 100% rename from src/Dictionary/copyDeep.luau.todo rename to src/Dictionary/differenceSymmetric.luau.todo diff --git a/src/Dictionary/flip.luau b/src/Dictionary/flip.luau new file mode 100644 index 0000000..f16dbfd --- /dev/null +++ b/src/Dictionary/flip.luau @@ -0,0 +1,21 @@ +--[=[ + @within Dictionary + + Returns a new dictionary with the keys and values of the input dictionary swapped. + + ```lua + local dictionary = { a = "apple", b = "banana" } + flip(dictionary) -- { apple = "a", banana = "b" } + ``` +]=] +local function flip(dictionary: { [K]: V }): { [V]: K } + local out = {} + + for key, value in dictionary do + out[value] = key + end + + return out +end + +return flip diff --git a/src/Dictionary/flip.luau.todo b/src/Dictionary/flip.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/freeze.luau b/src/Dictionary/freeze.luau new file mode 100644 index 0000000..254908e --- /dev/null +++ b/src/Dictionary/freeze.luau @@ -0,0 +1,20 @@ +local copy = require("./copy") + +--[=[ + @within Dictionary + + Returns a new dictionary that is a shallow copy of the input dictionary, but is frozen. This means that the dictionary cannot be modified in any way. This is useful for ensuring that a dictionary is not modified after it has been created. Use [Dictionary.freezeDeep] to freeze a dictionary and all of its nested dictionaries. + + ```lua + local frozen = freeze({ queen = "elsa", princess = "anna" }) + + frozen.princess = "elsa" -- error! + frozen.spirit = "bruni" -- error! + ``` +]=] +local function freeze(dictionary: { [K]: V }): { [K]: V } + local out = copy(dictionary) + return table.freeze(out) +end + +return freeze diff --git a/src/Dictionary/freeze.luau.todo b/src/Dictionary/freeze.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau new file mode 100644 index 0000000..205c9c7 --- /dev/null +++ b/src/Dictionary/get.luau @@ -0,0 +1,24 @@ +--[=[ + @within Dictionary +]=] +local function get(dictionary: { [K]: V }, key: K, dotSeparated: boolean?): V? + if not dotSeparated then + return dictionary[key] + end + + local parts: { string } = (key :: any):split(".") + local value: any = dictionary + + while #parts > 0 do + local part = table.remove(parts, 1) + value = value[part] + + if value == nil then + return nil + end + end + + return value +end + +return get diff --git a/src/Dictionary/has.luau b/src/Dictionary/has.luau new file mode 100644 index 0000000..609e386 --- /dev/null +++ b/src/Dictionary/has.luau @@ -0,0 +1,14 @@ +--[=[ + @within Dictionary + + Returns whether the given dictionary contains the given key. + + ```lua + has({ a = 1, b = 2 }, "a") -- true + ``` +]=] +local function has(dictionary: { [K]: V }, key: K): boolean + return dictionary[key] ~= nil +end + +return has diff --git a/src/Dictionary/has.luau.todo b/src/Dictionary/has.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/includes.luau b/src/Dictionary/includes.luau new file mode 100644 index 0000000..6205a7d --- /dev/null +++ b/src/Dictionary/includes.luau @@ -0,0 +1,20 @@ +--[=[ + @within Dictionary + + Returns whether the dictionary includes a certain value or not. If the value is found, the function also returns the key associated with the value. + + ```lua + includes({ a = 1, b = 3 }, 2) -- false + ``` +]=] +local function includes(dictionary: { [K]: V }, value: V): (boolean, K?) + for key, val in dictionary do + if val == value then + return true, key + end + end + + return false, nil +end + +return includes diff --git a/src/Dictionary/includes.luau.todo b/src/Dictionary/includes.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/keys.luau b/src/Dictionary/keys.luau new file mode 100644 index 0000000..f9a165a --- /dev/null +++ b/src/Dictionary/keys.luau @@ -0,0 +1,20 @@ +--[=[ + @within Dictionary + + Returns an array of all the keys in a dictionary. + + ```lua + keys({ a = 1, b = 2, c = 3 }) -- { "a", "b", "c" } + ``` +]=] +local function keys(dictionary: { [K]: V }): { K } + local out = {} + + for key in dictionary do + table.insert(out, key) + end + + return out +end + +return keys diff --git a/src/Dictionary/keys.luau.todo b/src/Dictionary/keys.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/set.luau b/src/Dictionary/set.luau new file mode 100644 index 0000000..272109b --- /dev/null +++ b/src/Dictionary/set.luau @@ -0,0 +1,19 @@ +local copy = require("./copy") + +--[=[ + @within Dictionary + + Returns a new dictionary with the given key set to the given value. + + ```lua + set({ a = 1 }, "b", 2) -- { a = 1, b = 2 } + ``` +]=] +local function set(dictionary: { [K]: V }, key: K, value: V): { [K]: V } + local out = copy(dictionary) + out[key] = value + + return out +end + +return set diff --git a/src/Dictionary/set.luau.todo b/src/Dictionary/set.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/values.luau b/src/Dictionary/values.luau new file mode 100644 index 0000000..da5a86e --- /dev/null +++ b/src/Dictionary/values.luau @@ -0,0 +1,20 @@ +--[=[ + @within Dictionary + + Returns an array of all the values in a dictionary. + + ```lua + values({ a = 1, b = 2, c = 3 }) -- { 1, 2, 3 } + ``` +]=] +local function values(dictionary: { [K]: V }): { V } + local out = {} + + for _, value in dictionary do + table.insert(out, value) + end + + return out +end + +return values diff --git a/src/Dictionary/values.luau.todo b/src/Dictionary/values.luau.todo deleted file mode 100644 index e69de29..0000000 From 5d1ecac03f94e33eb519bb1aaa29388ec8f7c2bc Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:23:26 +0000 Subject: [PATCH 10/43] Partial Dictionary reimplementations and new Dictionary methods --- luauspec.toml | 2 ++ src/Array/concat.luau | 2 +- src/Array/count.luau | 12 +++---- src/Array/flatten.luau | 2 +- src/Dictionary/count.luau | 30 ++++++++++++++++++ src/Dictionary/count.luau.todo | 0 src/Dictionary/entries.luau | 21 +++++++++++++ src/Dictionary/entries.luau.todo | 0 src/Dictionary/every.luau | 22 +++++++++++++ src/Dictionary/every.luau.todo | 0 src/Dictionary/expandKeys.luau | 45 +++++++++++++++++++++++++++ src/Dictionary/filter.luau | 27 ++++++++++++++++ src/Dictionary/filter.luau.todo | 0 src/Dictionary/flatten.luau | 30 ++++++++++++++++++ src/Dictionary/flatten.luau.todo | 0 src/Dictionary/flattenKeys.luau | 36 +++++++++++++++++++++ src/Dictionary/freezeDeep.luau | 34 ++++++++++++++++++++ src/Dictionary/freezeDeep.luau.todo | 0 src/Dictionary/fromArrays.luau | 23 ++++++++++++++ src/Dictionary/fromArrays.luau.todo | 0 src/Dictionary/fromEntries.luau | 21 +++++++++++++ src/Dictionary/fromEntries.luau.todo | 0 src/Dictionary/get.luau | 15 +++++++++ src/Dictionary/map.luau | 34 ++++++++++++++++++++ src/Dictionary/map.luau.todo | 0 src/Dictionary/merge.luau | 29 +++++++++++++++++ src/Dictionary/merge.luau.todo | 0 src/Dictionary/mergeDeep.luau | 44 ++++++++++++++++++++++++++ src/Dictionary/mergeDeep.luau.todo | 0 src/Dictionary/removeKey.luau | 17 ++++++++++ src/Dictionary/removeKey.luau.todo | 0 src/Dictionary/removeKeys.luau | 21 +++++++++++++ src/Dictionary/removeKeys.luau.todo | 0 src/Dictionary/removeValue.luau | 16 ++++++++++ src/Dictionary/removeValue.luau.todo | 0 src/Dictionary/removeValues.luau | 21 +++++++++++++ src/Dictionary/removeValues.luau.todo | 0 src/Dictionary/some.luau | 22 +++++++++++++ src/Dictionary/some.luau.todo | 0 src/Dictionary/withKeys.luau | 21 +++++++++++++ src/Dictionary/withKeys.luau.todo | 0 wally.toml | 2 -- 42 files changed, 539 insertions(+), 10 deletions(-) create mode 100644 luauspec.toml create mode 100644 src/Dictionary/count.luau delete mode 100644 src/Dictionary/count.luau.todo create mode 100644 src/Dictionary/entries.luau delete mode 100644 src/Dictionary/entries.luau.todo create mode 100644 src/Dictionary/every.luau delete mode 100644 src/Dictionary/every.luau.todo create mode 100644 src/Dictionary/expandKeys.luau create mode 100644 src/Dictionary/filter.luau delete mode 100644 src/Dictionary/filter.luau.todo create mode 100644 src/Dictionary/flatten.luau delete mode 100644 src/Dictionary/flatten.luau.todo create mode 100644 src/Dictionary/flattenKeys.luau create mode 100644 src/Dictionary/freezeDeep.luau delete mode 100644 src/Dictionary/freezeDeep.luau.todo create mode 100644 src/Dictionary/fromArrays.luau delete mode 100644 src/Dictionary/fromArrays.luau.todo create mode 100644 src/Dictionary/fromEntries.luau delete mode 100644 src/Dictionary/fromEntries.luau.todo create mode 100644 src/Dictionary/map.luau delete mode 100644 src/Dictionary/map.luau.todo create mode 100644 src/Dictionary/merge.luau delete mode 100644 src/Dictionary/merge.luau.todo create mode 100644 src/Dictionary/mergeDeep.luau delete mode 100644 src/Dictionary/mergeDeep.luau.todo create mode 100644 src/Dictionary/removeKey.luau delete mode 100644 src/Dictionary/removeKey.luau.todo create mode 100644 src/Dictionary/removeKeys.luau delete mode 100644 src/Dictionary/removeKeys.luau.todo create mode 100644 src/Dictionary/removeValue.luau delete mode 100644 src/Dictionary/removeValue.luau.todo create mode 100644 src/Dictionary/removeValues.luau delete mode 100644 src/Dictionary/removeValues.luau.todo create mode 100644 src/Dictionary/some.luau delete mode 100644 src/Dictionary/some.luau.todo create mode 100644 src/Dictionary/withKeys.luau delete mode 100644 src/Dictionary/withKeys.luau.todo diff --git a/luauspec.toml b/luauspec.toml new file mode 100644 index 0000000..f46a883 --- /dev/null +++ b/luauspec.toml @@ -0,0 +1,2 @@ +#! use("wally.toml") +name = "cxmeel/sift" diff --git a/src/Array/concat.luau b/src/Array/concat.luau index 1808944..52a61cb 100644 --- a/src/Array/concat.luau +++ b/src/Array/concat.luau @@ -10,7 +10,7 @@ concat(array1, array2) -- {1, 2, 3, 4, 5, 6} ``` ]=] -local function concat(...: { T }) +local function concat(...: { any }): { T } local out = {} for _, array in { ... } do diff --git a/src/Array/count.luau b/src/Array/count.luau index 07f6e93..dd25cc6 100644 --- a/src/Array/count.luau +++ b/src/Array/count.luau @@ -1,3 +1,5 @@ +local reduce = require("./reduce") + --[=[ @within Array @@ -13,15 +15,13 @@ ``` ]=] local function count(array: { T }, predicate: ((value: T, index: number) -> boolean)?): number - local counter = 0 - - for index, value in array do + return reduce(array, function(acc: number, value, index) if not predicate or predicate(value, index) then - counter += 1 + return acc + 1 end - end - return counter + return acc + end, 0) end return count diff --git a/src/Array/flatten.luau b/src/Array/flatten.luau index 88aaa2a..c4ff9d3 100644 --- a/src/Array/flatten.luau +++ b/src/Array/flatten.luau @@ -1,4 +1,4 @@ -local INF = newproxy(false) +local INF = newproxy() --[=[ @within Array diff --git a/src/Dictionary/count.luau b/src/Dictionary/count.luau new file mode 100644 index 0000000..a5a8660 --- /dev/null +++ b/src/Dictionary/count.luau @@ -0,0 +1,30 @@ +--[=[ + @within Dictionary + + Returns the number of elements in the dictionary. If a `predicate` is provided, it will only count the elements that satisfy the predicate. + + ```lua + local dictionary = { a = 1, b = 2, c = 3 } + + count(dictionary) -- 3 + count(dictionary, function(value) + return value > 1 + end) -- 2 + ``` +]=] +local function count( + dictionary: { [K]: V }, + predicate: ((value: V, key: K) -> boolean)? +): number + local counter = 0 + + for key, value in dictionary do + if not predicate or predicate(value, key) then + counter += 1 + end + end + + return counter +end + +return count diff --git a/src/Dictionary/count.luau.todo b/src/Dictionary/count.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/entries.luau b/src/Dictionary/entries.luau new file mode 100644 index 0000000..b56db2b --- /dev/null +++ b/src/Dictionary/entries.luau @@ -0,0 +1,21 @@ +--[=[ + @within Dictionary + + Returns an array of key-value pairs from a dictionary. + + ```lua + entries({ a = 1, b = 2, c = 3 }) + -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } + ``` +]=] +local function entries(dictionary: { [K]: V }): { { K | V } } + local out = {} + + for key, value in dictionary do + table.insert(out, { key, value :: any }) + end + + return out +end + +return entries diff --git a/src/Dictionary/entries.luau.todo b/src/Dictionary/entries.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/every.luau b/src/Dictionary/every.luau new file mode 100644 index 0000000..f12a889 --- /dev/null +++ b/src/Dictionary/every.luau @@ -0,0 +1,22 @@ +--[=[ + @within Dictionary + + Returns `true` if all values in the dictionary pass the test implemented by the provided function. + + ```lua + every({ a = 1, b = 3, c = 5 }, function(value) + return value % 2 == 0 + }) -- false + ``` +]=] +local function every(dictionary: { [K]: V }, predicate: (value: V, key: K) -> boolean): boolean + for key, value in dictionary do + if not predicate(value, key) then + return false + end + end + + return true +end + +return every diff --git a/src/Dictionary/every.luau.todo b/src/Dictionary/every.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/expandKeys.luau b/src/Dictionary/expandKeys.luau new file mode 100644 index 0000000..eb3cfc2 --- /dev/null +++ b/src/Dictionary/expandKeys.luau @@ -0,0 +1,45 @@ +type ExpandedDictionary = { [string]: ExpandedDictionary | V } + +--[=[ + @within Dictionary + + Expands a dictionary with keys that contain a separator into a nested dictionary. + + ```lua + local dictionary = { + ["a"] = 1, + ["b.c"] = 2, + ["b.d"] = 3, + } + + expandKeys(dictionary) -- { a = 1, b = { c = 2, d = 3 } } + ``` +]=] +local function expandKeys( + dictionary: { [string]: V }, + separator: string? +): ExpandedDictionary + local withSeparator = separator or "." + local out = {} + + for key, value in dictionary do + local parts = key:split(withSeparator) + local current = out + + while #parts > 1 do + local part = table.remove(parts, 1) + + if not current[part] then + current[part] = {} + end + + current = current[part] + end + + current[parts[1]] = value :: any + end + + return out :: any +end + +return expandKeys diff --git a/src/Dictionary/filter.luau b/src/Dictionary/filter.luau new file mode 100644 index 0000000..cf6939f --- /dev/null +++ b/src/Dictionary/filter.luau @@ -0,0 +1,27 @@ +--[=[ + @within Dictionary + + Filters out elements from a dictionary based on a filter function. The filter function should return `true` to keep the element, and `false` to remove it. + + ```lua + filter({ a = 1, b = 2, c = 3 }, function(value) + return value > 1 + end) -- { b = 2, c = 3 } + ``` +]=] +local function filter( + dictionary: { [K]: V }, + filterer: (value: V, key: K) -> boolean +): { [K]: V } + local out = {} + + for key, value in dictionary do + if filterer(value, key) then + out[key] = value + end + end + + return out +end + +return filter diff --git a/src/Dictionary/filter.luau.todo b/src/Dictionary/filter.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/flatten.luau b/src/Dictionary/flatten.luau new file mode 100644 index 0000000..c0a83f9 --- /dev/null +++ b/src/Dictionary/flatten.luau @@ -0,0 +1,30 @@ +local INF = newproxy() + +--[=[ + @within Dictionary + + Flattens nested dictionaries into a single dictionary. The `depth` parameter specifies the depth of the flattening. If `depth` is not specified, the dictionary is flattened as much as possible. +]=] +local function flatten(dictionary: { [any]: any }, depth: number?): { [K]: V } + local withDepth = depth or INF + local out = {} + + for key, value in dictionary do + if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flatten(value, useDepth) + + for nestedKey, nestedValue in nested do + out[nestedKey] = nestedValue + end + + continue + end + + out[key] = value + end + + return out +end + +return flatten diff --git a/src/Dictionary/flatten.luau.todo b/src/Dictionary/flatten.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/flattenKeys.luau b/src/Dictionary/flattenKeys.luau new file mode 100644 index 0000000..94fcae7 --- /dev/null +++ b/src/Dictionary/flattenKeys.luau @@ -0,0 +1,36 @@ +local INF = newproxy() + +type FlattenableDictionary = { [string]: FlattenableDictionary | V } + +--[=[ + @within Dictionary +]=] +local function flattenKeys( + dictionary: FlattenableDictionary, + depth: number?, + separator: string? +): { [string]: V } + local withSeparator = separator or "." + local withDepth = depth or INF + + local out: { [string]: V } = {} + + for key, value in dictionary do + if typeof(value) == "table" and depth > 0 then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flattenKeys(value, useDepth, withSeparator) + + for nestedKey, nestedValue in nested do + out[`{key}{withSeparator}{nestedKey}`] = nestedValue + end + + continue + end + + out[key] = value :: V + end + + return out +end + +return flattenKeys diff --git a/src/Dictionary/freezeDeep.luau b/src/Dictionary/freezeDeep.luau new file mode 100644 index 0000000..3c7359a --- /dev/null +++ b/src/Dictionary/freezeDeep.luau @@ -0,0 +1,34 @@ +--[=[ + @within Dictionary + + Recursively freezes a dictionary and all of its nested dictionaries. Using [Dictionary.freeze] will only freeze the top level of the dictionary, leaving nested dictionaries mutable. + + ```lua + local frozen = freezeDeep({ + a = "apple", + b = { c = "carrot" }, + }) + + frozen.a = "avocado" -- error! + frozen.b.c = "cabbage" -- error! + frozen.c = "coconut" -- error! + ``` +]=] +local function freezeDeep(dictionary: { [K]: V }): { [K]: V } + local out = {} + + for key, value in dictionary do + if typeof(value) == "table" then + local nested: any = freezeDeep(value) + out[key] = nested + + continue + end + + out[key] = value + end + + return table.freeze(out) +end + +return freezeDeep diff --git a/src/Dictionary/freezeDeep.luau.todo b/src/Dictionary/freezeDeep.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/fromArrays.luau b/src/Dictionary/fromArrays.luau new file mode 100644 index 0000000..7a0522a --- /dev/null +++ b/src/Dictionary/fromArrays.luau @@ -0,0 +1,23 @@ +--[=[ + @within Dictionary + + Constructs a dictionary from two arrays, one containing the keys and the other containing the values. + + ```lua + local keys = { "a", "b", "c" } + local values = { 1, 2, 3 } + + fromArrays(keys, values) -- { a = 1, b = 2, c = 3 } + ``` +]=] +local function fromArrays(keys: { K }, values: { V }): { [K]: V } + local out = {} + + for index, key in keys do + out[key] = values[index] + end + + return out +end + +return fromArrays diff --git a/src/Dictionary/fromArrays.luau.todo b/src/Dictionary/fromArrays.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/fromEntries.luau b/src/Dictionary/fromEntries.luau new file mode 100644 index 0000000..f2cb3b5 --- /dev/null +++ b/src/Dictionary/fromEntries.luau @@ -0,0 +1,21 @@ +--[=[ + @within Dictionary + + Constructs a dictionary from an array of key-value pairs. + + ```lua + fromEntries({ { "a", 1 }, { "b", 2 }, { "c", 3 } }) + -- { a = 1, b = 2, c = 3 } + ``` +]=] +local function fromEntries(entries: { { K | V } }): { [K]: V } + local out = {} + + for _, entry in entries do + out[entry[1] :: K] = entry[2] :: V + end + + return out +end + +return fromEntries diff --git a/src/Dictionary/fromEntries.luau.todo b/src/Dictionary/fromEntries.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau index 205c9c7..226a66b 100644 --- a/src/Dictionary/get.luau +++ b/src/Dictionary/get.luau @@ -1,5 +1,20 @@ --[=[ @within Dictionary + + Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `dotSeparated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If the key is not found, the function will return `nil`. + + ```lua + local dictionary = { + foo = { + bar = { + baz = "qux" + } + } + } + + get(dictionary, "foo.bar.baz") -- nil + get(dictionary, "foo.bar.baz", true) -- "qux" + ``` ]=] local function get(dictionary: { [K]: V }, key: K, dotSeparated: boolean?): V? if not dotSeparated then diff --git a/src/Dictionary/map.luau b/src/Dictionary/map.luau new file mode 100644 index 0000000..c698538 --- /dev/null +++ b/src/Dictionary/map.luau @@ -0,0 +1,34 @@ +local None = require("@Sift/None") + +--[=[ + @within Dictionary + + Processes each value and key of a dictionary with a mapper function and returns a new dictionary with the results. If no key is returned by the mapper, the original key is used. + + ```lua + map({ hello = "world" }, function(value, key) + return `{value}!`, key:upper() + end) -- { HELLO = "world!" } + + map({ hello = "world" }, function(value) + return value:upper() + end) -- { hello = "WORLD" } + ``` +]=] +local function map(dictionary: { [K]: V }, mapper: (value: V, key: K) -> (Y, X)): { [X]: Y } + local out: { [X]: Y } = {} + + for key, value in dictionary do + local mappedValue, mappedKey = mapper(value, key) + + if mappedKey == None or mappedValue == None then + continue + end + + out[mappedKey or key :: any] = mappedValue + end + + return out +end + +return map diff --git a/src/Dictionary/map.luau.todo b/src/Dictionary/map.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/merge.luau b/src/Dictionary/merge.luau new file mode 100644 index 0000000..3b758b3 --- /dev/null +++ b/src/Dictionary/merge.luau @@ -0,0 +1,29 @@ +local None = require("@Sift/None") + +--[=[ + @within Dictionary + + Merges multiple dictionaries into a single dictionary. If a key is present in multiple dictionaries, the value from the last dictionary in the list will be used. + + ```lua + local dictionary1 = { a = 1, b = 2 } + local dictionary2 = { b = 3, c = 4 } + + merge(dictionary1, dictionary2) -- { a = 1, b = 3, c = 4 } + ``` +]=] +local function merge(...: { [any]: any }): { [K]: V } + local out = {} + + for _, dictionary in { ... } do + for key, value in dictionary do + if key ~= None and value ~= None then + out[key] = value + end + end + end + + return out +end + +return merge diff --git a/src/Dictionary/merge.luau.todo b/src/Dictionary/merge.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/mergeDeep.luau b/src/Dictionary/mergeDeep.luau new file mode 100644 index 0000000..9b49f8e --- /dev/null +++ b/src/Dictionary/mergeDeep.luau @@ -0,0 +1,44 @@ +local None = require("@Sift/None") +local copyDeep = require("./copyDeep") + +--[=[ + @within Dictionary + + Combines multiple dictionaries into a single dictionary, including nested dictionaries. + + ```lua + local dictionary1 = { foo = "bar", deep = { foo = "bar" } } + local dictionary2 = { deep = { foo = "baz" } } + + mergeDeep(dictionary1, dictionary2) + -- { foo = "bar", deep = { foo = "baz" } } + ``` +]=] +local function mergeDeep(...: { [any]: any }): { [K]: V } + local out: any = {} + + for _, dictionary in { ... } do + for key, value in dictionary do + if value == None then + out[key] = nil + continue + end + + if typeof(value) == "table" then + if out[key] == nil or typeof(out[key]) ~= "table" then + out[key] = copyDeep(value) + continue + end + + out[key] = mergeDeep(out[key], value) + continue + end + + out[key] = value + end + end + + return out +end + +return mergeDeep diff --git a/src/Dictionary/mergeDeep.luau.todo b/src/Dictionary/mergeDeep.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/removeKey.luau b/src/Dictionary/removeKey.luau new file mode 100644 index 0000000..25b3956 --- /dev/null +++ b/src/Dictionary/removeKey.luau @@ -0,0 +1,17 @@ +local removeKeys = require("./removeKeys") + +--[=[ + @within Dictionary + + Returns a new dictionary with the specified key removed. + + ```lua + removeKey({ a = 1, b = 2, c = 3 }, "b") + -- { a = 1, c = 3 } + ``` +]=] +local function removeKey(dictionary: { [K]: V }, key: K): { [K]: V } + return removeKeys(dictionary, key) +end + +return removeKey diff --git a/src/Dictionary/removeKey.luau.todo b/src/Dictionary/removeKey.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/removeKeys.luau b/src/Dictionary/removeKeys.luau new file mode 100644 index 0000000..8d522b6 --- /dev/null +++ b/src/Dictionary/removeKeys.luau @@ -0,0 +1,21 @@ +local filter = require("./filter") + +--[=[ + @within Dictionary + + Returns a new dictionary with the specified keys removed. + + ```lua + removeKeys({ a = 1, b = 2, c = 3 }, "a", "c") + -- { b = 2 } + ``` +]=] +local function removeKeys(dictionary: { [K]: V }, ...: K): { [K]: V } + local keys = { ... } + + return filter(dictionary, function(_, key) + return table.find(keys, key) == nil + end) +end + +return removeKeys diff --git a/src/Dictionary/removeKeys.luau.todo b/src/Dictionary/removeKeys.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/removeValue.luau b/src/Dictionary/removeValue.luau new file mode 100644 index 0000000..5985c65 --- /dev/null +++ b/src/Dictionary/removeValue.luau @@ -0,0 +1,16 @@ +local removeValues = require("./removeValues") + +--[=[ + @within Dictionary + + Removes the specified value from the dictionary. This function will remove all instances of the value from the dictionary. + + ```lua + removeValue({ a = 1, b = 2, c = 1 }, 1) -- { b = 2 } + ``` +]=] +local function removeValue(dictionary: { [K]: V }, value: V): { [K]: V } + return removeValues(dictionary, value) +end + +return removeValue diff --git a/src/Dictionary/removeValue.luau.todo b/src/Dictionary/removeValue.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/removeValues.luau b/src/Dictionary/removeValues.luau new file mode 100644 index 0000000..b858de7 --- /dev/null +++ b/src/Dictionary/removeValues.luau @@ -0,0 +1,21 @@ +local filter = require("./filter") + +--[=[ + @within Dictionary + + Returns a new dictionary with all specified values removed. + + ```lua + removeValues({ a = 2, b = 1, c = 3, d = 2 }, 1, 2) + -- { c = 3 } + ``` +]=] +local function removeValues(dictionary: { [K]: V }, ...: V): { [K]: V } + local values = { ... } + + return filter(dictionary, function(value) + return table.find(values, value) == nil + end) +end + +return removeValues diff --git a/src/Dictionary/removeValues.luau.todo b/src/Dictionary/removeValues.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/some.luau b/src/Dictionary/some.luau new file mode 100644 index 0000000..12093dd --- /dev/null +++ b/src/Dictionary/some.luau @@ -0,0 +1,22 @@ +--[=[ + @within Dictionary + + Returns `true` if at least one value in the dictionary passes the test implemented by the provided function. + + ```lua + some({ a = 1, b = 2, c = 3 }, function(value) + return value > 2 + end) -- true + ``` +]=] +local function some(dictionary: { [K]: V }, predicate: (value: V, key: K) -> boolean): boolean + for key, value in dictionary do + if predicate(value, key) then + return true + end + end + + return false +end + +return some diff --git a/src/Dictionary/some.luau.todo b/src/Dictionary/some.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/withKeys.luau b/src/Dictionary/withKeys.luau new file mode 100644 index 0000000..8c27ee3 --- /dev/null +++ b/src/Dictionary/withKeys.luau @@ -0,0 +1,21 @@ +--[=[ + @within Dictionary + + Returns a new dictionary with only the specified keys. + + ```lua + local dict = { a = 1, b = 2, c = 3 } + withKeys(dict, "a", "c") -- { a = 1, c = 3 } + ``` +]=] +local function withKeys(dictionary: { [K]: V }, ...: K): { [K]: V } + local out = {} + + for _, key in { ... } do + out[key] = dictionary[key] + end + + return out +end + +return withKeys diff --git a/src/Dictionary/withKeys.luau.todo b/src/Dictionary/withKeys.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/wally.toml b/wally.toml index e6588b6..0814065 100644 --- a/wally.toml +++ b/wally.toml @@ -4,8 +4,6 @@ description = "Immutable data library for Luau" version = "0.1.0" registry = "https://github.com/upliftgames/wally-index" realm = "shared" -exclude = ["**"] -include = ["src", "src/**", "wally.toml", "wally.lock", "default.project.json"] [dev-dependencies] Jest = "jsdotlua/jest@3.6.1-rc.2" From d29f2bc08ff44ffd283f07fb17400ff9e59e291e Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:18:02 +0000 Subject: [PATCH 11/43] Update Array and Dictionary functions --- src/Array/update.luau | 4 +--- src/Dictionary/get.luau | 10 +++++---- src/Dictionary/set.luau | 34 ++++++++++++++++++++++++++--- src/Dictionary/update.luau | 38 +++++++++++++++++++++++++++++++++ src/Dictionary/update.luau.todo | 0 5 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 src/Dictionary/update.luau delete mode 100644 src/Dictionary/update.luau.todo diff --git a/src/Array/update.luau b/src/Array/update.luau index 0aac09c..7afc9d7 100644 --- a/src/Array/update.luau +++ b/src/Array/update.luau @@ -31,9 +31,7 @@ local function update( if updater and out[index] ~= nil and out[index] ~= None then out[index] = updater(out[index], index) - end - - if adder and (out[index] == nil or out[index] == None) then + elseif adder and (out[index] == nil or out[index] == None) then out[index] = adder(index) end diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau index 226a66b..f132b35 100644 --- a/src/Dictionary/get.luau +++ b/src/Dictionary/get.luau @@ -1,7 +1,7 @@ --[=[ @within Dictionary - Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `dotSeparated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If the key is not found, the function will return `nil`. + Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `separated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If `separated` is a string, it'll be used as the separator. If the key is not found, the function will return `nil`. ```lua local dictionary = { @@ -14,14 +14,16 @@ get(dictionary, "foo.bar.baz") -- nil get(dictionary, "foo.bar.baz", true) -- "qux" + get(dictionary, "foo$bar$baz", "$") -- "qux" ``` ]=] -local function get(dictionary: { [K]: V }, key: K, dotSeparated: boolean?): V? - if not dotSeparated then +local function get(dictionary: { [K]: V }, key: K, separated: (string | boolean)?): V? + if not separated then return dictionary[key] end - local parts: { string } = (key :: any):split(".") + local separator = type(separated) == "string" and separated or "." + local parts: { string } = (key :: any):split(separator) local value: any = dictionary while #parts > 0 do diff --git a/src/Dictionary/set.luau b/src/Dictionary/set.luau index 272109b..efcbc12 100644 --- a/src/Dictionary/set.luau +++ b/src/Dictionary/set.luau @@ -3,15 +3,43 @@ local copy = require("./copy") --[=[ @within Dictionary - Returns a new dictionary with the given key set to the given value. + Returns a new dictionary with the given key set to the given value. If `separated` is a string, it will be used to split the key into parts and create nested dictionaries. If `separated` is `true`, the key will be split by periods. ```lua set({ a = 1 }, "b", 2) -- { a = 1, b = 2 } + set({ a = { b = 1 } }, "a.b", 2) -- { ["a.b"] = 2 } + set({ a = { b = 1 } }, "a.b", 2, true) -- { a = { b = 2 } } + set({ a = { b = 1 } }, "a$b", 2, "$") -- { a = { b = 2 } } ``` ]=] -local function set(dictionary: { [K]: V }, key: K, value: V): { [K]: V } +local function set( + dictionary: { [K]: V }, + key: K, + value: V, + separated: (string | boolean)? +): { [K]: V } local out = copy(dictionary) - out[key] = value + + if not separated then + out[key] = value + return out + end + + local separator = type(separated) == "string" and separated or "." + local parts: { K } = (key :: any):split(separator) + local current: any = out + + while #parts > 1 do + local part = table.remove(parts, 1) :: K + + if not current[part] then + current[part] = {} + end + + current = current[part] + end + + current[parts[1]] = value return out end diff --git a/src/Dictionary/update.luau b/src/Dictionary/update.luau new file mode 100644 index 0000000..2e84bf2 --- /dev/null +++ b/src/Dictionary/update.luau @@ -0,0 +1,38 @@ +local None = require("@Sift/None") +local copy = require("./copy") + +--[=[ + @within Dictionary + + Updates a value in a dictionary with a given key. If the key does not exist, the value is added to the dictionary using the provided adder function. + + ```lua + local dictionary = { a = 1, b = 2 } + + update(dictionary, "b", function(value) + return value + 1 + end) -- { a = 1, b = 3 } + + update(dictionary, "c", nil, function() + return 3 + end) -- { a = 1, b = 2, c = 3 } + ``` +]=] +local function update( + dictionary: { [K]: V }, + key: K, + updater: ((value: V, key: K) -> T)?, + adder: ((key: K) -> T)? +): { [K]: T } + local out: { [K]: any } = copy(dictionary) + + if updater and out[key] ~= nil and out[key] ~= None then + out[key] = updater(out[key], key) :: any + elseif adder and (out[key] == nil or out[key] == None) then + out[key] = adder(key) :: any + end + + return out +end + +return update diff --git a/src/Dictionary/update.luau.todo b/src/Dictionary/update.luau.todo deleted file mode 100644 index e69de29..0000000 From eacb45e159891c8712e065d44a2f21cfa32820c5 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:24:49 +0000 Subject: [PATCH 12/43] Implement Dictionary equality methods --- src/Dictionary/equals.luau | 54 +++++++++++++++++++++++++++++ src/Dictionary/equals.luau.todo | 0 src/Dictionary/equalsDeep.luau | 54 +++++++++++++++++++++++++++++ src/Dictionary/equalsDeep.luau.todo | 0 4 files changed, 108 insertions(+) create mode 100644 src/Dictionary/equals.luau delete mode 100644 src/Dictionary/equals.luau.todo create mode 100644 src/Dictionary/equalsDeep.luau delete mode 100644 src/Dictionary/equalsDeep.luau.todo diff --git a/src/Dictionary/equals.luau b/src/Dictionary/equals.luau new file mode 100644 index 0000000..842cc49 --- /dev/null +++ b/src/Dictionary/equals.luau @@ -0,0 +1,54 @@ +local Util = require("@Sift/Util") + +local function compare(a, b) + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end + + for key, value in a do + if b[key] ~= value then + return false + end + end + + for key, value in b do + if a[key] ~= value then + return false + end + end + + return true +end + +--[=[ + @within Dictionary + + Performs a shallow comparison between two or more dictionaries. Returns `true` if all dictionaries are equal. + + ```lua + local dictionary1 = { a = "foo", b = { c = "bar" } } + local dictionary2 = { a = "foo", b = { c = "bar" } } + local dictionary3 = { a = "foo", c = "baz" } + + equals(dictionary1, dictionary2) -- true + equals(dictionary1, dictionary2, dictionary3) -- false + ``` +]=] +local function equals(...: { [any]: any }): boolean + if Util.areEqual(...) then + return true + end + + local args = { ... } + local first = table.remove(args, 1) :: { [any]: any } + + for _, dictionary in args do + if not compare(first, dictionary) then + return false + end + end + + return true +end + +return equals diff --git a/src/Dictionary/equals.luau.todo b/src/Dictionary/equals.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/equalsDeep.luau b/src/Dictionary/equalsDeep.luau new file mode 100644 index 0000000..e635c4c --- /dev/null +++ b/src/Dictionary/equalsDeep.luau @@ -0,0 +1,54 @@ +local Util = require("@Sift/Util") + +local function compareDeep(a, b) + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end + + for key, value in a do + if not compareDeep(value, b[key]) then + return false + end + end + + for key, value in b do + if not compareDeep(value, a[key]) then + return false + end + end + + return true +end + +--[=[ + @within Dictionary + + Performs a deep comparison of two or more dictionaries. This function will return `true` if all dictionaries are equal. + + ```lua + local dictionary1 = { a = "foo", b = { c = "bar" } } + local dictionary2 = { a = "foo", b = { c = "bar" } } + local dictionary3 = { a = "foo", c = "baz" } + + equalsDeep(dictionary1, dictionary2) -- true + equalsDeep(dictionary1, dictionary2, dictionary3) -- false + ``` +]=] +local function equalsDeep(...: { [any]: any }): boolean + if Util.areEqual(...) then + return true + end + + local args = { ... } + local first = table.remove(args, 1) :: { [any]: any } + + for _, dictionary in args do + if not compareDeep(first, dictionary) then + return false + end + end + + return true +end + +return equalsDeep diff --git a/src/Dictionary/equalsDeep.luau.todo b/src/Dictionary/equalsDeep.luau.todo deleted file mode 100644 index e69de29..0000000 From 156e49341dd46311b42e669c2a6ec71e14013fad Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:27:38 +0000 Subject: [PATCH 13/43] Create Dictionary entry point --- src/Dictionary/init.luau | 49 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 85ae286..03cd807 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -1,4 +1,51 @@ --[=[ @class Dictionary + + A collection of functions for working with dictionaries (tables with keys of any type). + + ```lua + local dictionary = { + hello = "world", + foo = "bar", + baz = "qux", + } + ``` ]=] -return {} +local dictionary = { + copy = require("./copy"), + copyDeep = require("./copyDeep"), + count = require("./count"), + difference = require("./difference"), + differenceSymmetric = require("./differenceSymmetric"), + entries = require("./entries"), + equals = require("./equals"), + equalsDeep = require("./equalsDeep"), + every = require("./every"), + expandKeys = require("./expandKeys"), + filter = require("./filter"), + flatten = require("./flatten"), + flattenKeys = require("./flattenKeys"), + flip = require("./flip"), + freeze = require("./freeze"), + freezeDeep = require("./freezeDeep"), + fromArrays = require("./fromArrays"), + fromEntries = require("./fromEntries"), + get = require("./get"), + has = require("./has"), + includes = require("./includes"), + keys = require("./keys"), + map = require("./map"), + merge = require("./merge"), + mergeDeep = require("./mergeDeep"), + removeKey = require("./removeKey"), + removeKeys = require("./removeKeys"), + removeValue = require("./removeValue"), + removeValues = require("./removeValues"), + set = require("./set"), + some = require("./some"), + update = require("./update"), + values = require("./values"), + withKeys = require("./withKeys"), +} + +return dictionary From 8bda0cc415ef2d46c294caa2297bfffe25cf4a66 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:51:13 +0000 Subject: [PATCH 14/43] Add cartesian function to Array module --- src/Array/cartesian.luau | 26 ++++++++++++++++++++++++++ src/Array/init.luau | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/Array/cartesian.luau diff --git a/src/Array/cartesian.luau b/src/Array/cartesian.luau new file mode 100644 index 0000000..6739797 --- /dev/null +++ b/src/Array/cartesian.luau @@ -0,0 +1,26 @@ +--[=[ + @within Array + + Returns the cartesian product of two arrays. The cartesian product is a set of all possible combinations of elements from two arrays. + + ```lua + local array1 = { 1, 2 } + local array2 = { "a", "b" } + + cartesian(array1, array2) + -- { { 1, "a" }, { 1, "b" }, { 2, "a" }, { 2, "b" } } + ``` +]=] +local function cartesian(array: { T }, other: { U }): { { T | U } } + local out = {} + + for i = 1, #array do + for j = 1, #other do + table.insert(out, { array[i], other[j] :: any }) + end + end + + return out +end + +return cartesian diff --git a/src/Array/init.luau b/src/Array/init.luau index 735a0a9..4a30fbb 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -9,6 +9,7 @@ ]=] local array = { at = require("./at"), + cartesian = require("./cartesian"), concat = require("./concat"), copy = require("./copy"), copyDeep = require("./copyDeep"), From a3913c26919202af273cc48f975ab1a7e310722d Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:53:06 +0000 Subject: [PATCH 15/43] Add unique function to Array module --- src/Array/init.luau | 1 + src/Array/unique.luau | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/Array/unique.luau diff --git a/src/Array/init.luau b/src/Array/init.luau index 4a30fbb..bd29e78 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -52,6 +52,7 @@ local array = { sort = require("./sort"), splice = require("./splice"), toSet = require("./toSet"), + unique = require("./unique"), unshift = require("./unshift"), update = require("./update"), zip = require("./zip"), diff --git a/src/Array/unique.luau b/src/Array/unique.luau new file mode 100644 index 0000000..0fb3189 --- /dev/null +++ b/src/Array/unique.luau @@ -0,0 +1,18 @@ +local toArray = require("@Sift/Set/toArray") +local toSet = require("./toSet") + +--[=[ + @within Array + + Returns a new array with all duplicate values removed. + + ```lua + unique({1, 2, 3, 4, 4, 5, 5, 6}) -- {1, 2, 3, 4, 5, 6} + ``` +]=] +local function unique(array: { T }): { T } + local set = toSet(array) + return toArray(set) +end + +return unique From 6720bcf285cba04d04992c7a842d2403bb817e1d Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:04:02 +0000 Subject: [PATCH 16/43] Add permutations function to Array module --- src/Array/init.luau | 1 + src/Array/permutations.luau | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/Array/permutations.luau diff --git a/src/Array/init.luau b/src/Array/init.luau index bd29e78..d878629 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -35,6 +35,7 @@ local array = { last = require("./last"), map = require("./map"), partition = require("./partition"), + permutations = require("./permutations"), pop = require("./pop"), push = require("./push"), reduce = require("./reduce"), diff --git a/src/Array/permutations.luau b/src/Array/permutations.luau new file mode 100644 index 0000000..cbdecd8 --- /dev/null +++ b/src/Array/permutations.luau @@ -0,0 +1,42 @@ +local copy = require("./copy") + +--[=[ + @within Array + + Returns a table of all permutations of the input array. + + ```lua + permutations({ 1, 2, 3 }) --[[ + { + { 1, 2, 3 }, + { 2, 1, 3 }, + { 3, 1, 2 }, + { 1, 3, 2 }, + { 2, 3, 1 }, + { 3, 2, 1 } + } + ]] + ``` +]=] +local function permutations(array: { T }): { { T } } + local out: { { T } } = {} + + local function permute(arr, n) + if n == 0 then + table.insert(out, copy(arr)) + return + end + + for i = 1, n do + arr[n], arr[i] = arr[i], arr[n] + permute(arr, n - 1) + arr[n], arr[i] = arr[i], arr[n] + end + end + + permute(array, #array) + + return out +end + +return permutations From d7c2bd6af6102155021c7cdc360bd34e2732f561 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:09:35 +0000 Subject: [PATCH 17/43] Add group function to Array module --- src/Array/group.luau | 28 ++++++++++++++++++++++++++++ src/Array/init.luau | 1 + 2 files changed, 29 insertions(+) create mode 100644 src/Array/group.luau diff --git a/src/Array/group.luau b/src/Array/group.luau new file mode 100644 index 0000000..5ff3ea6 --- /dev/null +++ b/src/Array/group.luau @@ -0,0 +1,28 @@ +--[=[ + @within Array + + Groups the elements of an array into a dictionary, based on the result of the grouper function. + + ```lua + group({ 1, 2, 3, 4, 5, 6 }, function(value) + return value % 2 == 0 and "even" or "odd" + end) -- { even = { 2, 4, 6 }, odd = { 1, 3, 5 } } + ``` +]=] +local function group(array: { T }, grouper: (value: T, index: number) -> K): { [K]: { T } } + local out = {} + + for index, value in array do + local key = grouper(value, index) + + if out[key] == nil then + out[key] = {} + end + + table.insert(out[key], value) + end + + return out +end + +return group diff --git a/src/Array/init.luau b/src/Array/init.luau index d878629..4a8bf23 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -29,6 +29,7 @@ local array = { flatten = require("./flatten"), freeze = require("./freeze"), freezeDeep = require("./freezeDeep"), + group = require("./group"), includes = require("./includes"), insert = require("./insert"), is = require("./is"), From 5702f95b42d921345eaa5da686040f1e451a92be Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:13:18 +0000 Subject: [PATCH 18/43] Add pick function to Dictionary module --- src/Dictionary/init.luau | 2 +- src/Dictionary/{withKeys.luau => pick.luau} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/Dictionary/{withKeys.luau => pick.luau} (64%) diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 03cd807..139ae78 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -45,7 +45,7 @@ local dictionary = { some = require("./some"), update = require("./update"), values = require("./values"), - withKeys = require("./withKeys"), + pick = require("./pick"), } return dictionary diff --git a/src/Dictionary/withKeys.luau b/src/Dictionary/pick.luau similarity index 64% rename from src/Dictionary/withKeys.luau rename to src/Dictionary/pick.luau index 8c27ee3..62aaf5a 100644 --- a/src/Dictionary/withKeys.luau +++ b/src/Dictionary/pick.luau @@ -5,10 +5,10 @@ ```lua local dict = { a = 1, b = 2, c = 3 } - withKeys(dict, "a", "c") -- { a = 1, c = 3 } + pick(dict, "a", "c") -- { a = 1, c = 3 } ``` ]=] -local function withKeys(dictionary: { [K]: V }, ...: K): { [K]: V } +local function pick(dictionary: { [K]: V }, ...: K): { [K]: V } local out = {} for _, key in { ... } do @@ -18,4 +18,4 @@ local function withKeys(dictionary: { [K]: V }, ...: K): { [K]: V } return out end -return withKeys +return pick From 965b4343dba329820ead3608fe2fb63f20385f21 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:19:50 +0000 Subject: [PATCH 19/43] Implement Dictionary difference methods --- src/Dictionary/difference.luau | 27 +++++++++++++++ src/Dictionary/difference.luau.todo | 0 src/Dictionary/differenceDeep.luau | 36 ++++++++++++++++++++ src/Dictionary/differenceSymmetric.luau.todo | 0 src/Dictionary/init.luau | 2 +- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/Dictionary/difference.luau delete mode 100644 src/Dictionary/difference.luau.todo create mode 100644 src/Dictionary/differenceDeep.luau delete mode 100644 src/Dictionary/differenceSymmetric.luau.todo diff --git a/src/Dictionary/difference.luau b/src/Dictionary/difference.luau new file mode 100644 index 0000000..24971d5 --- /dev/null +++ b/src/Dictionary/difference.luau @@ -0,0 +1,27 @@ +local Util = require("@Sift/Util") + +--[=[ + @within Dictionary + + Returns a new dictionary containing the differences between two dictionaries. The difference is calculated by comparing the values of each key in the first dictionary with the values of the same key in the second dictionary. If the values are not equal, the key-value pair is added to the new dictionary. + + ```lua + local dictionary1 = { a = 3, b = 4, c = 5 } + local dictionary2 = { a = 1, b = 4, d = 2 } + + difference(dictionary1, dictionary2) -- { a = 3, c = 5 } + ``` +]=] +local function difference(dictionary: { [K]: V }, other: { [K]: V }): { [K]: V } + local out = {} + + for key, value in dictionary do + if not Util.areEqual(value, other[key]) then + out[key] = value + end + end + + return out +end + +return difference diff --git a/src/Dictionary/difference.luau.todo b/src/Dictionary/difference.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/differenceDeep.luau b/src/Dictionary/differenceDeep.luau new file mode 100644 index 0000000..fcbe184 --- /dev/null +++ b/src/Dictionary/differenceDeep.luau @@ -0,0 +1,36 @@ +--[=[ + @within Dictionary + + Returns a new dictionary containing only the key-value pairs that are different between the two dictionaries. + + ```lua + local dictionary1 = { a = 1, b = { c = 2, d = 3 } } + local dictionary2 = { a = 1, b = true } + + differenceDeep(dictionary1, dictionary2) + -- { b = { c = 2, d = 3 } } + ``` +]=] +local function differenceDeep(dictionary: { [K]: V }, other: { [K]: V }): { [K]: V } + local out: { [K]: any } = {} + + for key, value in dictionary do + if typeof(value) == "table" then + if typeof(other[key]) == "table" then + out[key] = differenceDeep(value, other[key]) + continue + end + + out[key] = value + continue + end + + if other[key] == nil or other[key] ~= value then + out[key] = value + end + end + + return out +end + +return differenceDeep diff --git a/src/Dictionary/differenceSymmetric.luau.todo b/src/Dictionary/differenceSymmetric.luau.todo deleted file mode 100644 index e69de29..0000000 diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 139ae78..0f58136 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -16,7 +16,7 @@ local dictionary = { copyDeep = require("./copyDeep"), count = require("./count"), difference = require("./difference"), - differenceSymmetric = require("./differenceSymmetric"), + differenceDeep = require("./differenceDeep"), entries = require("./entries"), equals = require("./equals"), equalsDeep = require("./equalsDeep"), From f46c37243c1b39cbc8d6bf7a87f44a50063439c0 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Wed, 13 Mar 2024 23:37:05 +0000 Subject: [PATCH 20/43] Add patchDiff module to Dictionary --- src/Dictionary/init.luau | 1 + src/Dictionary/patchDiff.luau | 96 +++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/Dictionary/patchDiff.luau diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 0f58136..533b1ae 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -37,6 +37,7 @@ local dictionary = { map = require("./map"), merge = require("./merge"), mergeDeep = require("./mergeDeep"), + patchDiff = require("./patchDiff"), removeKey = require("./removeKey"), removeKeys = require("./removeKeys"), removeValue = require("./removeValue"), diff --git a/src/Dictionary/patchDiff.luau b/src/Dictionary/patchDiff.luau new file mode 100644 index 0000000..a122c31 --- /dev/null +++ b/src/Dictionary/patchDiff.luau @@ -0,0 +1,96 @@ +export type Operation = "add" | "remove" | "replace" + +export type Patch = { + op: Operation, + path: { K }, + value: V, +} + +--[=[ + @within Dictionary + + Returns an array of patches that can be applied to `dictionary` to make it equal to `other`. This is a deep comparison. The patches are similar to those used in JSON Patch. + + ```lua + local dictionary1 = { + foo = "bar", + qux = { + baz = "quux", + }, + } + + local dictionary2 = { + foo = "bar", + qux = { + baz = "quuz", + }, + baz = "quux", + } + + patchDiff(dictionary1, dictionary2) --[[ + { + { + op = "replace", + path = { "qux", "baz" }, + value = "quuz", + }, + { + op = "add", + path = { "baz" }, + value = "quux", + }, + } + ]] + ``` +]=] +local function patchDiff(dictionary: { [K]: V }, other: { [K]: V }): { Patch } + local out: { any } = {} + + for key, value in dictionary do + if other[key] == nil then + table.insert(out, { + op = "remove", + path = { key }, + value = value, + }) + + continue + end + + if typeof(value) == "table" then + local subpatches = patchDiff(value, other[key]) + + for _, patch in subpatches do + table.insert(out, { + op = patch.op :: any, + path = { key, table.unpack(patch.path) }, + value = patch.value, + }) + end + + continue + end + + if value ~= other[key] then + table.insert(out, { + op = "replace", + path = { key }, + value = other[key], + }) + end + end + + for key, value in other do + if dictionary[key] == nil then + table.insert(out, { + op = "add", + path = { key }, + value = value, + }) + end + end + + return out +end + +return patchDiff From e2b26dbc7305f670bf8b3c0e3bcdfaa48f0a75b1 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:22:56 +0000 Subject: [PATCH 21/43] Version parity CI script --- .vscode/settings.json | 5 +- luauspec.toml | 4 +- lune/ensure-version-parity.luau | 95 ++++++++++++++++++++++++++++++ lune/lib/_index/crayon/init.luau | 94 +++++++++++++++++++++++++++++ lune/lib/_index/crayon/styles.luau | 59 +++++++++++++++++++ lune/lib/_index/semver/init.luau | 74 +++++++++++++++++++++++ lune/lib/crayon.luau | 2 + lune/lib/semver.luau | 5 ++ 8 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 lune/ensure-version-parity.luau create mode 100644 lune/lib/_index/crayon/init.luau create mode 100644 lune/lib/_index/crayon/styles.luau create mode 100644 lune/lib/_index/semver/init.luau create mode 100644 lune/lib/crayon.luau create mode 100644 lune/lib/semver.luau diff --git a/.vscode/settings.json b/.vscode/settings.json index 5a1a07f..62289db 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,9 +15,10 @@ "luau-lsp.require.directoryAliases": { "@Pkg": "Packages", "@DevPkg": "DevPackages", - "@Sift": "src" + "@Sift": "src", + "@lune/": "~/.lune/.typedefs/0.8.0/" }, "luau-lsp.types.roblox": false, "luau-lsp.require.mode": "relativeToFile", "luau-lsp.completion.imports.suggestRequires": false -} +} \ No newline at end of file diff --git a/luauspec.toml b/luauspec.toml index f46a883..756c177 100644 --- a/luauspec.toml +++ b/luauspec.toml @@ -1,2 +1,4 @@ -#! use("wally.toml") +[package] name = "cxmeel/sift" + +[dependencies] diff --git a/lune/ensure-version-parity.luau b/lune/ensure-version-parity.luau new file mode 100644 index 0000000..5642215 --- /dev/null +++ b/lune/ensure-version-parity.luau @@ -0,0 +1,95 @@ +local fs = require("@lune/fs") +local process = require("@lune/process") +local serde = require("@lune/serde") + +local crayon = require("./lib/crayon") +local semver = require("./lib/semver") + +local FILES = { + { + file = "wally.toml", + path = { "package", "version" }, + decode = "toml", + }, + { + file = "package.json", + path = { "version" }, + decode = "json", + }, + { + file = "luauspec.toml", + path = { "package", "version" }, + decode = "toml", + optional = true, + }, +} + +local function get_versions() + local versions = {} + + local longestFileName = 0 + + for index, meta in FILES do + local contents = fs.readFile(`{process.cwd}/{meta.file}`) + local data = serde.decode(meta.decode :: any, contents) + + local version: string = data + local failure = false + + for _, part in meta.path do + if not (version :: any)[part] then + failure = true + break + end + + version = (version :: any)[part] + end + + if failure and meta.optional then + continue + end + + longestFileName = math.max(longestFileName, #meta.file + 1) + versions[index] = version + end + + for index, meta in FILES do + local fileName = `{meta.file}{(" "):rep(longestFileName - #meta.file)}` + + if not versions[index] then + print(crayon.label("FILE", crayon.bgBlue), crayon.grey(`{fileName} -> skipped`)) + continue + end + + print( + crayon.label("FILE", crayon.bgBlue), + crayon.grey(`{fileName} ->`), + versions[index] + ) + end + + return versions +end + +local function main() + local versions = get_versions() + local base = semver.greatest(versions) + + for _, version in versions do + local compare = semver.compare(version, base) + + if compare ~= 0 then + print( + crayon.label("ERROR", crayon.bgRed), + "Versions do not match:", + crayon.bold(version), + crayon.grey("<"), + crayon.bold(semver.stringify(base)) + ) + + process.exit(1) + end + end +end + +main() diff --git a/lune/lib/_index/crayon/init.luau b/lune/lib/_index/crayon/init.luau new file mode 100644 index 0000000..d2f4f6f --- /dev/null +++ b/lune/lib/_index/crayon/init.luau @@ -0,0 +1,94 @@ +local ANSI_STYLES = require("./styles") + +local process = require("@lune/process") +local env, args = process.env, process.args + +local isColorSupported = (function() + local isNoColor = env.NO_COLOR + or table.find(args, "--no-color") + or table.find(args, "--color=false") + local isForcedColor = env.FORCE_COLOR + or table.find(args, "--color") + or table.find(args, "--color=true") + local isWindows = process.os == "windows" + local isDumbTerminal = env.TERM == "dumb" + + local isCompatible = env.TERM and env.TERM ~= "dumb" + local isCI = env.CI and (env.GITHUB_ACTIONS or env.GITLAB_CI or env.CIRCLECI) + + -- selene: allow(shadowing) + local isColorSupported = not isNoColor + and (isForcedColor or (isWindows and not isDumbTerminal) or isCompatible or isCI) + + return isColorSupported +end)() + +local function styler(codepoint: { number }) + local open, close = codepoint[1], codepoint[2] + + return function(text: string) + if not isColorSupported then + return text + end + + return `\27[{open}m{text}\27[{close}m` + end +end + +local Crayon = { + -- Modifiers + reset = styler(ANSI_STYLES.MODIFIERS.RESET), + bold = styler(ANSI_STYLES.MODIFIERS.BOLD), + dim = styler(ANSI_STYLES.MODIFIERS.DIM), + italic = styler(ANSI_STYLES.MODIFIERS.ITALIC), + underline = styler(ANSI_STYLES.MODIFIERS.UNDERLINE), + overline = styler(ANSI_STYLES.MODIFIERS.OVERLINE), + inverse = styler(ANSI_STYLES.MODIFIERS.INVERSE), + hidden = styler(ANSI_STYLES.MODIFIERS.HIDDEN), + strikethrough = styler(ANSI_STYLES.MODIFIERS.STRIKETHROUGH), + + -- Foreground colors + black = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK), + red = styler(ANSI_STYLES.FOREGROUND_COLORS.RED), + green = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN), + yellow = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW), + blue = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE), + magenta = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA), + cyan = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN), + white = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE), + grey = styler(ANSI_STYLES.FOREGROUND_COLORS.GREY), + blackBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK_BRIGHT), + redBright = styler(ANSI_STYLES.FOREGROUND_COLORS.RED_BRIGHT), + greenBright = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN_BRIGHT), + yellowBright = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW_BRIGHT), + blueBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE_BRIGHT), + magentaBright = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA_BRIGHT), + cyanBright = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN_BRIGHT), + whiteBright = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE_BRIGHT), + + -- Background colors + bgBlack = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK), + bgRed = styler(ANSI_STYLES.BACKGROUND_COLORS.RED), + bgGreen = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN), + bgYellow = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW), + bgBlue = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE), + bgMagenta = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA), + bgCyan = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN), + bgWhite = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE), + bgGrey = styler(ANSI_STYLES.BACKGROUND_COLORS.GREY), + bgBlackBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK_BRIGHT), + bgRedBright = styler(ANSI_STYLES.BACKGROUND_COLORS.RED_BRIGHT), + bgGreenBright = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN_BRIGHT), + bgYellowBright = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW_BRIGHT), + bgBlueBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE_BRIGHT), + bgMagentaBright = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA_BRIGHT), + bgCyanBright = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN_BRIGHT), + bgWhiteBright = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE_BRIGHT), +} + +-- selene: allow(shadowing) +function Crayon.label(text: string, styler: (string) -> string) + return styler(Crayon.bold(` {text:upper()} `)) +end + +return Crayon diff --git a/lune/lib/_index/crayon/styles.luau b/lune/lib/_index/crayon/styles.luau new file mode 100644 index 0000000..f9423cc --- /dev/null +++ b/lune/lib/_index/crayon/styles.luau @@ -0,0 +1,59 @@ +local MODIFIERS = table.freeze({ + RESET = { 0, 0 }, + BOLD = { 1, 22 }, + DIM = { 2, 22 }, + ITALIC = { 3, 23 }, + UNDERLINE = { 4, 24 }, + OVERLINE = { 53, 55 }, + INVERSE = { 7, 27 }, + HIDDEN = { 8, 28 }, + STRIKETHROUGH = { 9, 29 }, +}) + +local FOREGROUND_COLORS = table.freeze({ + BLACK = { 30, 39 }, + RED = { 31, 39 }, + GREEN = { 32, 39 }, + YELLOW = { 33, 39 }, + BLUE = { 34, 39 }, + MAGENTA = { 35, 39 }, + CYAN = { 36, 39 }, + WHITE = { 37, 39 }, + + GREY = { 90, 39 }, + BLACK_BRIGHT = { 90, 39 }, + RED_BRIGHT = { 91, 39 }, + GREEN_BRIGHT = { 92, 39 }, + YELLOW_BRIGHT = { 93, 39 }, + BLUE_BRIGHT = { 94, 39 }, + MAGENTA_BRIGHT = { 95, 39 }, + CYAN_BRIGHT = { 96, 39 }, + WHITE_BRIGHT = { 97, 39 }, +}) + +local BACKGROUND_COLORS = table.freeze({ + BLACK = { 40, 49 }, + RED = { 41, 49 }, + GREEN = { 42, 49 }, + YELLOW = { 43, 49 }, + BLUE = { 44, 49 }, + MAGENTA = { 45, 49 }, + CYAN = { 46, 49 }, + WHITE = { 47, 49 }, + + GREY = { 100, 49 }, + BLACK_BRIGHT = { 100, 49 }, + RED_BRIGHT = { 101, 49 }, + GREEN_BRIGHT = { 102, 49 }, + YELLOW_BRIGHT = { 103, 49 }, + BLUE_BRIGHT = { 104, 49 }, + MAGENTA_BRIGHT = { 105, 49 }, + CYAN_BRIGHT = { 106, 49 }, + WHITE_BRIGHT = { 107, 49 }, +}) + +return table.freeze({ + MODIFIERS = MODIFIERS, + FOREGROUND_COLORS = FOREGROUND_COLORS, + BACKGROUND_COLORS = BACKGROUND_COLORS, +}) diff --git a/lune/lib/_index/semver/init.luau b/lune/lib/_index/semver/init.luau new file mode 100644 index 0000000..9f53994 --- /dev/null +++ b/lune/lib/_index/semver/init.luau @@ -0,0 +1,74 @@ +export type Semver = { major: number, minor: number, patch: number } + +local function parse(version: string | Semver): Semver + if typeof(version) == "table" then + return version + end + + local major, minor, patch = version:match("(%d+)%.(%d+)%.(%d+)") + + return { + major = tonumber(major) or 0, + minor = tonumber(minor) or 0, + patch = tonumber(patch) or 0, + } +end + +local function stringify(version: Semver): string + return `{version.major}.{version.minor}.{version.patch}` +end + +local function compare(a: string | Semver, b: string | Semver) + local verA = if typeof(a) == "table" then a else parse(a) + local verB = if typeof(b) == "table" then b else parse(b) + + if verA.major < verB.major then + return -1 + end + + if verA.major > verB.major then + return 1 + end + + if verA.minor < verB.minor then + return -1 + end + + if verA.minor > verB.minor then + return 1 + end + + if verA.patch < verB.patch then + return -1 + end + + if verA.patch > verB.patch then + return 1 + end + + return 0 +end + +local function greatest(versions: { string | Semver }): Semver + local out + + for _, version in versions do + if out == nil then + out = version + continue + end + + if compare(version, out) > 0 then + out = version + end + end + + return parse(out) +end + +return { + parse = parse, + stringify = stringify, + compare = compare, + greatest = greatest, +} diff --git a/lune/lib/crayon.luau b/lune/lib/crayon.luau new file mode 100644 index 0000000..ae13dbc --- /dev/null +++ b/lune/lib/crayon.luau @@ -0,0 +1,2 @@ +local TARGET = require("./_index/crayon/init") +return TARGET diff --git a/lune/lib/semver.luau b/lune/lib/semver.luau new file mode 100644 index 0000000..497554b --- /dev/null +++ b/lune/lib/semver.luau @@ -0,0 +1,5 @@ +local TARGET = require("./_index/semver/init") + +export type Semver = TARGET.Semver + +return TARGET From 74768ea36ce9587a5961de989f39cb8e11ab5ada Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:27:38 +0000 Subject: [PATCH 22/43] Update code formatting --- aftman.toml | 2 +- src/Array/at.luau | 12 ++-- src/Array/cartesian.luau | 14 ++-- src/Array/concat.luau | 14 ++-- src/Array/copyDeep.luau | 18 ++--- src/Array/count.luau | 12 ++-- src/Array/difference.luau | 14 ++-- src/Array/differenceSymmetric.luau | 14 ++-- src/Array/equals.luau | 46 ++++++------- src/Array/equalsDeep.luau | 46 ++++++------- src/Array/every.luau | 12 ++-- src/Array/filter.luau | 14 ++-- src/Array/find.luau | 12 ++-- src/Array/findLast.luau | 22 +++---- src/Array/findWhere.luau | 28 ++++---- src/Array/findWhereLast.luau | 28 ++++---- src/Array/first.luau | 2 +- src/Array/flatten.luau | 28 ++++---- src/Array/freeze.luau | 4 +- src/Array/freezeDeep.luau | 20 +++--- src/Array/group.luau | 18 ++--- src/Array/includes.luau | 4 +- src/Array/init.luau | 102 ++++++++++++++--------------- src/Array/insert.luau | 20 +++--- src/Array/is.luau | 2 +- src/Array/last.luau | 2 +- src/Array/map.luau | 16 ++--- src/Array/partition.luau | 24 +++---- src/Array/permutations.luau | 28 ++++---- src/Array/pop.luau | 18 ++--- src/Array/push.luau | 2 +- src/Array/reduce.luau | 26 ++++---- src/Array/reduceRight.luau | 26 ++++---- src/Array/removeIndex.luau | 2 +- src/Array/removeIndices.luau | 32 ++++----- src/Array/removeValue.luau | 2 +- src/Array/removeValues.luau | 14 ++-- src/Array/reverse.luau | 10 +-- src/Array/set.luau | 16 ++--- src/Array/shift.luau | 18 ++--- src/Array/shuffle.luau | 18 ++--- src/Array/slice.luau | 36 +++++----- src/Array/some.luau | 12 ++-- src/Array/sort.luau | 6 +- src/Array/splice.luau | 40 +++++------ src/Array/toSet.luau | 8 +-- src/Array/unique.luau | 4 +- src/Array/unshift.luau | 2 +- src/Array/update.luau | 24 +++---- src/Array/zip.luau | 32 ++++----- src/Array/zipAll.luau | 34 +++++----- src/Dictionary/copyDeep.luau | 18 ++--- src/Dictionary/count.luau | 18 ++--- src/Dictionary/difference.luau | 14 ++-- src/Dictionary/differenceDeep.luau | 30 ++++----- src/Dictionary/entries.luau | 10 +-- src/Dictionary/equals.luau | 56 ++++++++-------- src/Dictionary/equalsDeep.luau | 56 ++++++++-------- src/Dictionary/every.luau | 12 ++-- src/Dictionary/expandKeys.luau | 34 +++++----- src/Dictionary/filter.luau | 18 ++--- src/Dictionary/flatten.luau | 28 ++++---- src/Dictionary/flattenKeys.luau | 36 +++++----- src/Dictionary/flip.luau | 10 +-- src/Dictionary/freeze.luau | 4 +- src/Dictionary/freezeDeep.luau | 20 +++--- src/Dictionary/fromArrays.luau | 10 +-- src/Dictionary/fromEntries.luau | 10 +-- src/Dictionary/get.luau | 28 ++++---- src/Dictionary/has.luau | 2 +- src/Dictionary/includes.luau | 12 ++-- src/Dictionary/init.luau | 70 ++++++++++---------- src/Dictionary/keys.luau | 10 +-- src/Dictionary/map.luau | 18 ++--- src/Dictionary/merge.luau | 18 ++--- src/Dictionary/mergeDeep.luau | 48 +++++++------- src/Dictionary/patchDiff.luau | 84 ++++++++++++------------ src/Dictionary/pick.luau | 10 +-- src/Dictionary/removeKey.luau | 2 +- src/Dictionary/removeKeys.luau | 8 +-- src/Dictionary/removeValue.luau | 2 +- src/Dictionary/removeValues.luau | 8 +-- src/Dictionary/set.luau | 42 ++++++------ src/Dictionary/some.luau | 12 ++-- src/Dictionary/update.luau | 22 +++---- src/Dictionary/values.luau | 10 +-- src/None.luau | 2 +- src/Set/add.luau | 6 +- src/Set/copy.luau | 10 +-- src/Set/count.luau | 14 ++-- src/Set/delete.luau | 8 +-- src/Set/difference.luau | 14 ++-- src/Set/differenceSymmetric.luau | 28 ++++---- src/Set/filter.luau | 14 ++-- src/Set/fromArray.luau | 10 +-- src/Set/has.luau | 2 +- src/Set/init.luau | 32 ++++----- src/Set/intersection.luau | 28 ++++---- src/Set/isSubset.luau | 12 ++-- src/Set/isSuperset.luau | 2 +- src/Set/map.luau | 16 ++--- src/Set/merge.luau | 18 ++--- src/Set/partition.luau | 24 +++---- src/Set/toArray.luau | 10 +-- src/Util.luau | 42 ++++++------ src/init.luau | 14 ++-- stylua.toml | 2 + 107 files changed, 1030 insertions(+), 1028 deletions(-) diff --git a/aftman.toml b/aftman.toml index 3faee9f..330eb0c 100644 --- a/aftman.toml +++ b/aftman.toml @@ -5,9 +5,9 @@ [tools] darklua = "seaofvoices/darklua@0.12.1" luau-lsp = "johnnymorganz/luau-lsp@1.28.1" -# lune = "filiptibell/lune@0.8.0" rojo = "rojo-rbx/rojo@7.4.1" run-in-roblox = "rojo-rbx/run-in-roblox@0.3.0" selene = "kampfkarren/selene@0.26.1" stylua = "johnnymorganz/stylua@0.20.0" wally = "upliftgames/wally@0.3.2" +lune = "filiptibell/lune@0.8.2" diff --git a/src/Array/at.luau b/src/Array/at.luau index dbe90fc..3771c06 100644 --- a/src/Array/at.luau +++ b/src/Array/at.luau @@ -10,13 +10,13 @@ ``` ]=] local function at(array: { T }, index: number): T - if index == 0 then - index = 1 - elseif index < 0 then - index += #array + 1 - end + if index == 0 then + index = 1 + elseif index < 0 then + index += #array + 1 + end - return array[index] + return array[index] end return at diff --git a/src/Array/cartesian.luau b/src/Array/cartesian.luau index 6739797..f8f6a68 100644 --- a/src/Array/cartesian.luau +++ b/src/Array/cartesian.luau @@ -12,15 +12,15 @@ ``` ]=] local function cartesian(array: { T }, other: { U }): { { T | U } } - local out = {} + local out = {} - for i = 1, #array do - for j = 1, #other do - table.insert(out, { array[i], other[j] :: any }) - end - end + for i = 1, #array do + for j = 1, #other do + table.insert(out, { array[i], other[j] :: any }) + end + end - return out + return out end return cartesian diff --git a/src/Array/concat.luau b/src/Array/concat.luau index 52a61cb..fc0d392 100644 --- a/src/Array/concat.luau +++ b/src/Array/concat.luau @@ -11,15 +11,15 @@ ``` ]=] local function concat(...: { any }): { T } - local out = {} + local out = {} - for _, array in { ... } do - for _, value in array do - table.insert(out, value) - end - end + for _, array in { ... } do + for _, value in array do + table.insert(out, value) + end + end - return out + return out end return concat diff --git a/src/Array/copyDeep.luau b/src/Array/copyDeep.luau index 1e4e203..bde5c0c 100644 --- a/src/Array/copyDeep.luau +++ b/src/Array/copyDeep.luau @@ -9,17 +9,17 @@ ``` ]=] local function copyDeep(array: { T }): { T } - local out: any = {} + local out: any = {} - for _, value in array do - if typeof(value) == "table" then - table.insert(out, copyDeep(value)) - else - table.insert(out, value) - end - end + for _, value in array do + if typeof(value) == "table" then + table.insert(out, copyDeep(value)) + else + table.insert(out, value) + end + end - return out + return out end return copyDeep diff --git a/src/Array/count.luau b/src/Array/count.luau index dd25cc6..64a3ad8 100644 --- a/src/Array/count.luau +++ b/src/Array/count.luau @@ -15,13 +15,13 @@ local reduce = require("./reduce") ``` ]=] local function count(array: { T }, predicate: ((value: T, index: number) -> boolean)?): number - return reduce(array, function(acc: number, value, index) - if not predicate or predicate(value, index) then - return acc + 1 - end + return reduce(array, function(acc: number, value, index) + if not predicate or predicate(value, index) then + return acc + 1 + end - return acc - end, 0) + return acc + end, 0) end return count diff --git a/src/Array/difference.luau b/src/Array/difference.luau index 5b19715..07966e1 100644 --- a/src/Array/difference.luau +++ b/src/Array/difference.luau @@ -15,15 +15,15 @@ local toSet = require("./toSet") ``` ]=] local function difference(array: { T }, ...: { T }): { T } - local arraySet = toSet(array) - local otherSets = {} + local arraySet = toSet(array) + local otherSets = {} - for _, other in { ... } do - table.insert(otherSets, toSet(other)) - end + for _, other in { ... } do + table.insert(otherSets, toSet(other)) + end - local differenceSet = setDifference(arraySet, unpack(otherSets)) - return toArray(differenceSet) + local differenceSet = setDifference(arraySet, unpack(otherSets)) + return toArray(differenceSet) end return difference diff --git a/src/Array/differenceSymmetric.luau b/src/Array/differenceSymmetric.luau index baf4383..ba9bbd1 100644 --- a/src/Array/differenceSymmetric.luau +++ b/src/Array/differenceSymmetric.luau @@ -15,15 +15,15 @@ local toSet = require("./toSet") ``` ]=] local function differenceSymmetric(array: { T }, ...: { T }): { T } - local arraySet = toSet(array) - local otherSets = {} + local arraySet = toSet(array) + local otherSets = {} - for _, other in { ... } do - table.insert(otherSets, toSet(other)) - end + for _, other in { ... } do + table.insert(otherSets, toSet(other)) + end - local differenceSet = setDifferenceSymmetric(arraySet, unpack(otherSets)) - return toArray(differenceSet) + local differenceSet = setDifferenceSymmetric(arraySet, unpack(otherSets)) + return toArray(differenceSet) end return differenceSymmetric diff --git a/src/Array/equals.luau b/src/Array/equals.luau index 02a9bb5..2ff4436 100644 --- a/src/Array/equals.luau +++ b/src/Array/equals.luau @@ -1,21 +1,21 @@ local Util = require("@Sift/Util") local function compare(a: any, b: any) - if typeof(a) ~= "table" or typeof(b) ~= "table" then - return a == b - end + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end - if #a ~= #b then - return false - end + if #a ~= #b then + return false + end - for index, value in a do - if value ~= b[index] then - return false - end - end + for index, value in a do + if value ~= b[index] then + return false + end + end - return true + return true end --[=[ @@ -31,20 +31,20 @@ end ``` ]=] local function equals(...: any): boolean - if Util.areEqual(...) then - return true - end + if Util.areEqual(...) then + return true + end - local args = { ... } - local first = table.remove(args, 1) + local args = { ... } + local first = table.remove(args, 1) - for _, array in args do - if not compare(first, array) then - return false - end - end + for _, array in args do + if not compare(first, array) then + return false + end + end - return true + return true end return equals diff --git a/src/Array/equalsDeep.luau b/src/Array/equalsDeep.luau index 7fa3628..ab3845d 100644 --- a/src/Array/equalsDeep.luau +++ b/src/Array/equalsDeep.luau @@ -1,21 +1,21 @@ local Util = require("@Sift/Util") local function compare(a: any, b: any) - if typeof(a) ~= "table" or typeof(b) ~= "table" then - return a == b - end + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end - if #a ~= #b then - return false - end + if #a ~= #b then + return false + end - for index, value in a do - if not compare(value, b[index]) then - return false - end - end + for index, value in a do + if not compare(value, b[index]) then + return false + end + end - return true + return true end --[=[ @@ -31,20 +31,20 @@ end ``` ]=] local function equalsDeep(...: any): boolean - if Util.areEqual(...) then - return true - end + if Util.areEqual(...) then + return true + end - local args = { ... } - local first = table.remove(args, 1) + local args = { ... } + local first = table.remove(args, 1) - for _, value in args do - if not compare(first, value) then - return false - end - end + for _, value in args do + if not compare(first, value) then + return false + end + end - return true + return true end return equalsDeep diff --git a/src/Array/every.luau b/src/Array/every.luau index 6548526..cbb3fe6 100644 --- a/src/Array/every.luau +++ b/src/Array/every.luau @@ -10,13 +10,13 @@ ``` ]=] local function every(array: { T }, predicate: (value: T, index: number) -> boolean): boolean - for index, value in array do - if not predicate(value, index) then - return false - end - end + for index, value in array do + if not predicate(value, index) then + return false + end + end - return true + return true end return every diff --git a/src/Array/filter.luau b/src/Array/filter.luau index cdbb1ca..37b4691 100644 --- a/src/Array/filter.luau +++ b/src/Array/filter.luau @@ -9,15 +9,15 @@ end) -- { 4, 5 } ]=] local function filter(array: { T }, filterer: (value: T, index: number) -> boolean): { T } - local out = {} + local out = {} - for index, value in array do - if filterer(value, index) then - table.insert(out, value) - end - end + for index, value in array do + if filterer(value, index) then + table.insert(out, value) + end + end - return out + return out end return filter diff --git a/src/Array/find.luau b/src/Array/find.luau index 209d0f5..c60a47c 100644 --- a/src/Array/find.luau +++ b/src/Array/find.luau @@ -12,13 +12,13 @@ ``` ]=] local function find(array: { T }, value: T, from: number?): number? - if from == 0 then - from = 1 - elseif from and from < 0 then - from += #array + 1 - end + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - return table.find(array, value, from) + return table.find(array, value, from) end return find diff --git a/src/Array/findLast.luau b/src/Array/findLast.luau index f294068..853821b 100644 --- a/src/Array/findLast.luau +++ b/src/Array/findLast.luau @@ -12,19 +12,19 @@ ``` ]=] local function findLast(array: { T }, value: T, from: number?): number? - if from == 0 then - from = 1 - elseif from and from < 0 then - from += #array + 1 - end + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for i = from or #array, 1, -1 do - if array[i] == value then - return i - end - end + for i = from or #array, 1, -1 do + if array[i] == value then + return i + end + end - return nil + return nil end return findLast diff --git a/src/Array/findWhere.luau b/src/Array/findWhere.luau index 4387895..fe3294f 100644 --- a/src/Array/findWhere.luau +++ b/src/Array/findWhere.luau @@ -10,23 +10,23 @@ ``` ]=] local function findWhere( - array: { T }, - predicate: (value: T, index: number) -> boolean, - from: number? + array: { T }, + predicate: (value: T, index: number) -> boolean, + from: number? ): number? - if from == 0 then - from = 1 - elseif from and from < 0 then - from += #array + 1 - end + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for index = from or 1, #array do - if predicate(array[index], index) then - return index - end - end + for index = from or 1, #array do + if predicate(array[index], index) then + return index + end + end - return nil + return nil end return findWhere diff --git a/src/Array/findWhereLast.luau b/src/Array/findWhereLast.luau index d051972..196c38a 100644 --- a/src/Array/findWhereLast.luau +++ b/src/Array/findWhereLast.luau @@ -10,23 +10,23 @@ ``` ]=] local function findWhereLast( - array: { T }, - predicate: (value: T, index: number) -> boolean, - from: number? + array: { T }, + predicate: (value: T, index: number) -> boolean, + from: number? ): number? - if from == 0 then - from = 1 - elseif from and from < 0 then - from += #array + 1 - end + if from == 0 then + from = 1 + elseif from and from < 0 then + from += #array + 1 + end - for index = from or #array, 1, -1 do - if predicate(array[index], index) then - return index - end - end + for index = from or #array, 1, -1 do + if predicate(array[index], index) then + return index + end + end - return nil + return nil end return findWhereLast diff --git a/src/Array/first.luau b/src/Array/first.luau index b992f48..dededa3 100644 --- a/src/Array/first.luau +++ b/src/Array/first.luau @@ -10,7 +10,7 @@ local at = require("./at") ``` ]=] local function first(array: { T }): T - return at(array, 1) + return at(array, 1) end return first diff --git a/src/Array/flatten.luau b/src/Array/flatten.luau index c4ff9d3..a104b32 100644 --- a/src/Array/flatten.luau +++ b/src/Array/flatten.luau @@ -13,25 +13,25 @@ local INF = newproxy() ``` ]=] local function flatten(array: { T }, depth: number?): { T } - local withDepth = depth or INF - local out = {} + local withDepth = depth or INF + local out = {} - for _, value in array do - if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then - local useDepth = withDepth == INF and INF or withDepth - 1 - local nested = flatten(value, useDepth) + for _, value in array do + if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flatten(value, useDepth) - for _, nestedValue in nested do - table.insert(out, nestedValue) - end + for _, nestedValue in nested do + table.insert(out, nestedValue) + end - continue - end + continue + end - table.insert(out, value) - end + table.insert(out, value) + end - return out + return out end return flatten diff --git a/src/Array/freeze.luau b/src/Array/freeze.luau index 478aebb..424cebc 100644 --- a/src/Array/freeze.luau +++ b/src/Array/freeze.luau @@ -14,8 +14,8 @@ local copy = require("./copy") ``` ]=] local function freeze(array: { T }): { T } - local out = copy(array) - return table.freeze(out) + local out = copy(array) + return table.freeze(out) end return freeze diff --git a/src/Array/freezeDeep.luau b/src/Array/freezeDeep.luau index 8f3bbed..0c30884 100644 --- a/src/Array/freezeDeep.luau +++ b/src/Array/freezeDeep.luau @@ -10,20 +10,20 @@ frozen[3][1] = 4 -- error! ]=] local function freezeDeep(array: { T }): { T } - local out: { T } = {} + local out: { T } = {} - for _, value in array do - if typeof(value) == "table" then - local nested: any = freezeDeep(value) - table.insert(out, nested) + for _, value in array do + if typeof(value) == "table" then + local nested: any = freezeDeep(value) + table.insert(out, nested) - continue - end + continue + end - table.insert(out, value) - end + table.insert(out, value) + end - return table.freeze(out) + return table.freeze(out) end return freezeDeep diff --git a/src/Array/group.luau b/src/Array/group.luau index 5ff3ea6..675f4d6 100644 --- a/src/Array/group.luau +++ b/src/Array/group.luau @@ -10,19 +10,19 @@ ``` ]=] local function group(array: { T }, grouper: (value: T, index: number) -> K): { [K]: { T } } - local out = {} + local out = {} - for index, value in array do - local key = grouper(value, index) + for index, value in array do + local key = grouper(value, index) - if out[key] == nil then - out[key] = {} - end + if out[key] == nil then + out[key] = {} + end - table.insert(out[key], value) - end + table.insert(out[key], value) + end - return out + return out end return group diff --git a/src/Array/includes.luau b/src/Array/includes.luau index 76cee10..1ea8a15 100644 --- a/src/Array/includes.luau +++ b/src/Array/includes.luau @@ -10,8 +10,8 @@ local find = require("./find") ``` ]=] local function includes(array: { T }, value: T, from: number?): boolean - local index = find(array, value, from) - return index ~= nil + local index = find(array, value, from) + return index ~= nil end return includes diff --git a/src/Array/init.luau b/src/Array/init.luau index 4a8bf23..a6ca499 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -8,57 +8,57 @@ ``` ]=] local array = { - at = require("./at"), - cartesian = require("./cartesian"), - concat = require("./concat"), - copy = require("./copy"), - copyDeep = require("./copyDeep"), - count = require("./count"), - create = require("./create"), - difference = require("./difference"), - differenceSymmetric = require("./differenceSymmetric"), - equals = require("./equals"), - equalsDeep = require("./equalsDeep"), - every = require("./every"), - filter = require("./filter"), - find = require("./find"), - findLast = require("./findLast"), - findWhere = require("./findWhere"), - findWhereLast = require("./findWhereLast"), - first = require("./first"), - flatten = require("./flatten"), - freeze = require("./freeze"), - freezeDeep = require("./freezeDeep"), - group = require("./group"), - includes = require("./includes"), - insert = require("./insert"), - is = require("./is"), - last = require("./last"), - map = require("./map"), - partition = require("./partition"), - permutations = require("./permutations"), - pop = require("./pop"), - push = require("./push"), - reduce = require("./reduce"), - reduceRight = require("./reduceRight"), - removeIndex = require("./removeIndex"), - removeIndices = require("./removeIndices"), - removeValue = require("./removeValue"), - removeValues = require("./removeValues"), - reverse = require("./reverse"), - set = require("./set"), - shift = require("./shift"), - shuffle = require("./shuffle"), - slice = require("./slice"), - some = require("./some"), - sort = require("./sort"), - splice = require("./splice"), - toSet = require("./toSet"), - unique = require("./unique"), - unshift = require("./unshift"), - update = require("./update"), - zip = require("./zip"), - zipAll = require("./zipAll"), + at = require("./at"), + cartesian = require("./cartesian"), + concat = require("./concat"), + copy = require("./copy"), + copyDeep = require("./copyDeep"), + count = require("./count"), + create = require("./create"), + difference = require("./difference"), + differenceSymmetric = require("./differenceSymmetric"), + equals = require("./equals"), + equalsDeep = require("./equalsDeep"), + every = require("./every"), + filter = require("./filter"), + find = require("./find"), + findLast = require("./findLast"), + findWhere = require("./findWhere"), + findWhereLast = require("./findWhereLast"), + first = require("./first"), + flatten = require("./flatten"), + freeze = require("./freeze"), + freezeDeep = require("./freezeDeep"), + group = require("./group"), + includes = require("./includes"), + insert = require("./insert"), + is = require("./is"), + last = require("./last"), + map = require("./map"), + partition = require("./partition"), + permutations = require("./permutations"), + pop = require("./pop"), + push = require("./push"), + reduce = require("./reduce"), + reduceRight = require("./reduceRight"), + removeIndex = require("./removeIndex"), + removeIndices = require("./removeIndices"), + removeValue = require("./removeValue"), + removeValues = require("./removeValues"), + reverse = require("./reverse"), + set = require("./set"), + shift = require("./shift"), + shuffle = require("./shuffle"), + slice = require("./slice"), + some = require("./some"), + sort = require("./sort"), + splice = require("./splice"), + toSet = require("./toSet"), + unique = require("./unique"), + unshift = require("./unshift"), + update = require("./update"), + zip = require("./zip"), + zipAll = require("./zipAll"), } return array diff --git a/src/Array/insert.luau b/src/Array/insert.luau index f6aea5c..718fced 100644 --- a/src/Array/insert.luau +++ b/src/Array/insert.luau @@ -13,19 +13,19 @@ local copy = require("./copy") ``` ]=] local function insert(array: { T }, index: number, ...: T): { T } - if index == 0 then - index = 1 - elseif index < 0 then - index += #array + 1 - end + if index == 0 then + index = 1 + elseif index < 0 then + index += #array + 1 + end - local out = copy(array) + local out = copy(array) - for i = 1, select("#", ...) do - table.insert(out, index + i - 1, select(i, ...)) - end + for i = 1, select("#", ...) do + table.insert(out, index + i - 1, select(i, ...)) + end - return out + return out end return insert diff --git a/src/Array/is.luau b/src/Array/is.luau index 144895b..b6414fd 100644 --- a/src/Array/is.luau +++ b/src/Array/is.luau @@ -11,7 +11,7 @@ ``` ]=] local function is(value: any): boolean - return typeof(value) == "table" and #value > 0 and next(value, #value) == nil + return typeof(value) == "table" and #value > 0 and next(value, #value) == nil end return is diff --git a/src/Array/last.luau b/src/Array/last.luau index 10097ff..caa6fc9 100644 --- a/src/Array/last.luau +++ b/src/Array/last.luau @@ -10,7 +10,7 @@ local at = require("./at") ``` ]=] local function last(array: { T }): T - return at(array, -1) + return at(array, -1) end return last diff --git a/src/Array/map.luau b/src/Array/map.luau index d48a1ad..24d39d5 100644 --- a/src/Array/map.luau +++ b/src/Array/map.luau @@ -12,17 +12,17 @@ local None = require("@Sift/None") ``` ]=] local function map(array: { T }, mapper: (value: T, index: number) -> U?): { U } - local out: { U } = {} + local out: { U } = {} - for index, value in array do - local mapped = mapper(value, index) + for index, value in array do + local mapped = mapper(value, index) - if mapped ~= nil and mapped ~= None then - table.insert(out, mapped) - end - end + if mapped ~= nil and mapped ~= None then + table.insert(out, mapped) + end + end - return out + return out end return map diff --git a/src/Array/partition.luau b/src/Array/partition.luau index 64f1c7f..b0341ee 100644 --- a/src/Array/partition.luau +++ b/src/Array/partition.luau @@ -13,21 +13,21 @@ ``` ]=] local function partition( - array: { T }, - filterer: (value: T, index: number) -> boolean + array: { T }, + filterer: (value: T, index: number) -> boolean ): ({ T }, { T }) - local pass = {} - local fail = {} + local pass = {} + local fail = {} - for index, value in array do - if filterer(value, index) then - table.insert(pass, value) - else - table.insert(fail, value) - end - end + for index, value in array do + if filterer(value, index) then + table.insert(pass, value) + else + table.insert(fail, value) + end + end - return pass, fail + return pass, fail end return partition diff --git a/src/Array/permutations.luau b/src/Array/permutations.luau index cbdecd8..f75ba27 100644 --- a/src/Array/permutations.luau +++ b/src/Array/permutations.luau @@ -19,24 +19,24 @@ local copy = require("./copy") ``` ]=] local function permutations(array: { T }): { { T } } - local out: { { T } } = {} + local out: { { T } } = {} - local function permute(arr, n) - if n == 0 then - table.insert(out, copy(arr)) - return - end + local function permute(arr, n) + if n == 0 then + table.insert(out, copy(arr)) + return + end - for i = 1, n do - arr[n], arr[i] = arr[i], arr[n] - permute(arr, n - 1) - arr[n], arr[i] = arr[i], arr[n] - end - end + for i = 1, n do + arr[n], arr[i] = arr[i], arr[n] + permute(arr, n - 1) + arr[n], arr[i] = arr[i], arr[n] + end + end - permute(array, #array) + permute(array, #array) - return out + return out end return permutations diff --git a/src/Array/pop.luau b/src/Array/pop.luau index c22ee80..520d864 100644 --- a/src/Array/pop.luau +++ b/src/Array/pop.luau @@ -13,18 +13,18 @@ local removeIndices = require("./removeIndices") ``` ]=] local function pop(array: { T }, count: number?): { T } - local useCount = count or 1 - local indices = {} + local useCount = count or 1 + local indices = {} - if useCount > #array then - return {} - end + if useCount > #array then + return {} + end - for index = 1, useCount do - table.insert(indices, #array - index + 1) - end + for index = 1, useCount do + table.insert(indices, #array - index + 1) + end - return removeIndices(array, table.unpack(indices)) + return removeIndices(array, table.unpack(indices)) end return pop diff --git a/src/Array/push.luau b/src/Array/push.luau index bffe75b..6233559 100644 --- a/src/Array/push.luau +++ b/src/Array/push.luau @@ -10,7 +10,7 @@ local insert = require("./insert") ``` ]=] local function push(array: { T }, ...: T): { T } - return insert(array, #array + 1, ...) + return insert(array, #array + 1, ...) end return push diff --git a/src/Array/reduce.luau b/src/Array/reduce.luau index 554019b..89b2f96 100644 --- a/src/Array/reduce.luau +++ b/src/Array/reduce.luau @@ -12,23 +12,23 @@ local None = require("@Sift/None") ``` ]=] local function reduce( - array: { T }, - reducer: (accumulator: U, value: T, index: number) -> U, - initAccumulator: U? + array: { T }, + reducer: (accumulator: U, value: T, index: number) -> U, + initAccumulator: U? ): U - local out = initAccumulator :: U - local start = 1 + local out = initAccumulator :: U + local start = 1 - if out == nil or out == None then - out = array[1] :: any - start = 2 - end + if out == nil or out == None then + out = array[1] :: any + start = 2 + end - for index = start, #array do - out = reducer(out, array[index], index) - end + for index = start, #array do + out = reducer(out, array[index], index) + end - return out + return out end return reduce diff --git a/src/Array/reduceRight.luau b/src/Array/reduceRight.luau index f39620b..61d285d 100644 --- a/src/Array/reduceRight.luau +++ b/src/Array/reduceRight.luau @@ -12,23 +12,23 @@ local None = require("@Sift/None") ``` ]=] local function reduceRight( - array: { T }, - reducer: (accumulator: U, value: T, index: number) -> U, - initAccumulator: U? + array: { T }, + reducer: (accumulator: U, value: T, index: number) -> U, + initAccumulator: U? ): U - local out = initAccumulator :: U - local start = #array + local out = initAccumulator :: U + local start = #array - if out == nil or out == None then - out = array[start] :: any - start -= 1 - end + if out == nil or out == None then + out = array[start] :: any + start -= 1 + end - for index = start, 1, -1 do - out = reducer(out, array[index], index) - end + for index = start, 1, -1 do + out = reducer(out, array[index], index) + end - return out + return out end return reduceRight diff --git a/src/Array/removeIndex.luau b/src/Array/removeIndex.luau index a7cbabc..30973fe 100644 --- a/src/Array/removeIndex.luau +++ b/src/Array/removeIndex.luau @@ -10,7 +10,7 @@ local removeIndices = require("./removeIndices") ``` ]=] local function removeIndex(array: { T }, index: number): { T } - return removeIndices(array, index) + return removeIndices(array, index) end return removeIndex diff --git a/src/Array/removeIndices.luau b/src/Array/removeIndices.luau index f3bb844..1ec506d 100644 --- a/src/Array/removeIndices.luau +++ b/src/Array/removeIndices.luau @@ -10,27 +10,27 @@ local reduce = require("./reduce") ``` ]=] local function removeIndices(array: { T }, ...: number): { T } - local indices = reduce({ ... }, function(acc, value) - if value == 0 then - value = 1 - elseif value < 0 then - value += #array + 1 - end + local indices = reduce({ ... }, function(acc, value) + if value == 0 then + value = 1 + elseif value < 0 then + value += #array + 1 + end - acc[value] = true + acc[value] = true - return acc - end, {}) + return acc + end, {}) - local out = {} + local out = {} - for index, value in array do - if not indices[index] then - table.insert(out, value) - end - end + for index, value in array do + if not indices[index] then + table.insert(out, value) + end + end - return out + return out end return removeIndices diff --git a/src/Array/removeValue.luau b/src/Array/removeValue.luau index d3b191e..931f4e8 100644 --- a/src/Array/removeValue.luau +++ b/src/Array/removeValue.luau @@ -10,7 +10,7 @@ local removeValues = require("./removeValues") ``` ]=] local function removeValue(array: { T }, value: T): { T } - return removeValues(array, value) + return removeValues(array, value) end return removeValue diff --git a/src/Array/removeValues.luau b/src/Array/removeValues.luau index 644b777..b075b18 100644 --- a/src/Array/removeValues.luau +++ b/src/Array/removeValues.luau @@ -12,14 +12,14 @@ local reduce = require("./reduce") ``` ]=] local function removeValues(array: { T }, ...: T): { T } - local values = reduce({ ... }, function(acc, value) - acc[value] = true - return acc - end, {}) + local values = reduce({ ... }, function(acc, value) + acc[value] = true + return acc + end, {}) - return filter(array, function(value) - return not values[value] - end) + return filter(array, function(value) + return not values[value] + end) end return removeValues diff --git a/src/Array/reverse.luau b/src/Array/reverse.luau index 64db68d..f546b49 100644 --- a/src/Array/reverse.luau +++ b/src/Array/reverse.luau @@ -8,13 +8,13 @@ ``` ]=] local function reverse(array: { T }): { T } - local out = {} + local out = {} - for index = #array, 1, -1 do - table.insert(out, array[index]) - end + for index = #array, 1, -1 do + table.insert(out, array[index]) + end - return out + return out end return reverse diff --git a/src/Array/set.luau b/src/Array/set.luau index d8366b8..ed42115 100644 --- a/src/Array/set.luau +++ b/src/Array/set.luau @@ -13,17 +13,17 @@ local copy = require("./copy") ``` ]=] local function set(array: { T }, index: number, value: T): { T } - local out = copy(array) + local out = copy(array) - if index == 0 then - index = 1 - elseif index < 0 then - index += #out + 1 - end + if index == 0 then + index = 1 + elseif index < 0 then + index += #out + 1 + end - out[index] = value + out[index] = value - return out + return out end return set diff --git a/src/Array/shift.luau b/src/Array/shift.luau index 4858541..013bec3 100644 --- a/src/Array/shift.luau +++ b/src/Array/shift.luau @@ -13,18 +13,18 @@ local removeIndices = require("./removeIndices") ``` ]=] local function shift(array: { T }, count: number?): { T } - local useCount = count or 1 - local indices = {} + local useCount = count or 1 + local indices = {} - if useCount > #array then - return {} - end + if useCount > #array then + return {} + end - for index = #array, useCount, -1 do - table.insert(indices, index) - end + for index = #array, useCount, -1 do + table.insert(indices, index) + end - return removeIndices(array, table.unpack(indices)) + return removeIndices(array, table.unpack(indices)) end return shift diff --git a/src/Array/shuffle.luau b/src/Array/shuffle.luau index d339e3f..8d47db6 100644 --- a/src/Array/shuffle.luau +++ b/src/Array/shuffle.luau @@ -10,19 +10,19 @@ local copy = require("./copy") ``` ]=] local function shuffle(array: { T }, seed: number?): { T } - math.randomseed(seed or os.clock() * #array) + math.randomseed(seed or os.clock() * #array) - local out = copy(array) + local out = copy(array) - for index = #out, 1, -1 do - local randomIndex = math.random(1, index) - local temp = out[index] + for index = #out, 1, -1 do + local randomIndex = math.random(1, index) + local temp = out[index] - out[index] = out[randomIndex] - out[randomIndex] = temp - end + out[index] = out[randomIndex] + out[randomIndex] = temp + end - return out + return out end return shuffle diff --git a/src/Array/slice.luau b/src/Array/slice.luau index 14b872f..b81baa0 100644 --- a/src/Array/slice.luau +++ b/src/Array/slice.luau @@ -11,29 +11,29 @@ ``` ]=] local function slice(array: { T }, from: number?, to: number?): { T } - if not from or from == 0 then - from = 1 - elseif from < 0 then - from += #array + 1 - end + if not from or from == 0 then + from = 1 + elseif from < 0 then + from += #array + 1 + end - if not to or to == 0 then - to = #array - elseif to < 0 then - to += #array + 1 - end + if not to or to == 0 then + to = #array + elseif to < 0 then + to += #array + 1 + end - if from == to then - return {} - end + if from == to then + return {} + end - local out = {} + local out = {} - for index = from :: number, to :: number do - table.insert(out, array[index]) - end + for index = from :: number, to :: number do + table.insert(out, array[index]) + end - return out + return out end return slice diff --git a/src/Array/some.luau b/src/Array/some.luau index d456e98..2bb2d07 100644 --- a/src/Array/some.luau +++ b/src/Array/some.luau @@ -10,13 +10,13 @@ ``` ]=] local function some(array: { T }, predicate: (value: T, index: number) -> boolean): boolean - for index, value in array do - if predicate(value, index) then - return true - end - end + for index, value in array do + if predicate(value, index) then + return true + end + end - return false + return false end return some diff --git a/src/Array/sort.luau b/src/Array/sort.luau index e81b552..80b1a1d 100644 --- a/src/Array/sort.luau +++ b/src/Array/sort.luau @@ -11,10 +11,10 @@ local copy = require("./copy") ``` ]=] local function sort(array: { T }, comparer: ((a: T, b: T) -> boolean)?): { T } - local result = copy(array) - table.sort(result, comparer) + local result = copy(array) + table.sort(result, comparer) - return result + return result end return sort diff --git a/src/Array/splice.luau b/src/Array/splice.luau index 8497dd3..d3fbc87 100644 --- a/src/Array/splice.luau +++ b/src/Array/splice.luau @@ -12,33 +12,33 @@ ``` ]=] local function splice(array: { T }, at: number?, replaceCount: number?, ...: T?): { T } - local useAt, useReplaceCount = 0, 0 + local useAt, useReplaceCount = 0, 0 - if not at or at == 0 then - useAt = 1 - elseif at < 0 then - useAt = at + #array + 1 - end + if not at or at == 0 then + useAt = 1 + elseif at < 0 then + useAt = at + #array + 1 + end - if not replaceCount or replaceCount < 0 then - useReplaceCount = 0 - end + if not replaceCount or replaceCount < 0 then + useReplaceCount = 0 + end - local out = {} + local out = {} - for index = 1, useAt - 1 do - table.insert(out, array[index]) - end + for index = 1, useAt - 1 do + table.insert(out, array[index]) + end - for index = 1, select("#", ...) do - table.insert(out, select(index, ...)) - end + for index = 1, select("#", ...) do + table.insert(out, select(index, ...)) + end - for index = useAt + useReplaceCount, #array do - table.insert(out, array[index]) - end + for index = useAt + useReplaceCount, #array do + table.insert(out, array[index]) + end - return out + return out end return splice diff --git a/src/Array/toSet.luau b/src/Array/toSet.luau index bd2ebe1..4df0332 100644 --- a/src/Array/toSet.luau +++ b/src/Array/toSet.luau @@ -11,10 +11,10 @@ local reduce = require("./reduce") ``` ]=] local function toSet(array: { T }): { [T]: boolean } - return reduce(array, function(set, value) - set[value] = true - return set - end, {}) + return reduce(array, function(set, value) + set[value] = true + return set + end, {}) end return toSet diff --git a/src/Array/unique.luau b/src/Array/unique.luau index 0fb3189..0bb8123 100644 --- a/src/Array/unique.luau +++ b/src/Array/unique.luau @@ -11,8 +11,8 @@ local toSet = require("./toSet") ``` ]=] local function unique(array: { T }): { T } - local set = toSet(array) - return toArray(set) + local set = toSet(array) + return toArray(set) end return unique diff --git a/src/Array/unshift.luau b/src/Array/unshift.luau index 3cbdf76..31a783d 100644 --- a/src/Array/unshift.luau +++ b/src/Array/unshift.luau @@ -4,7 +4,7 @@ local insert = require("./insert") @within Array ]=] local function unshift(array: { T }, ...: T): { T } - return insert(array, 1, ...) + return insert(array, 1, ...) end return unshift diff --git a/src/Array/update.luau b/src/Array/update.luau index 7afc9d7..be7972c 100644 --- a/src/Array/update.luau +++ b/src/Array/update.luau @@ -21,21 +21,21 @@ local copy = require("./copy") ``` ]=] local function update( - array: { T }, - index: number, - updater: ((value: T, index: number) -> T)?, - adder: ((index: number) -> T)? + array: { T }, + index: number, + updater: ((value: T, index: number) -> T)?, + adder: ((index: number) -> T)? ): { T } - local out = copy(array) - index = Util.normalizeIndex(index, #array) + local out = copy(array) + index = Util.normalizeIndex(index, #array) - if updater and out[index] ~= nil and out[index] ~= None then - out[index] = updater(out[index], index) - elseif adder and (out[index] == nil or out[index] == None) then - out[index] = adder(index) - end + if updater and out[index] ~= nil and out[index] ~= None then + out[index] = updater(out[index], index) + elseif adder and (out[index] == nil or out[index] == None) then + out[index] = adder(index) + end - return out + return out end return update diff --git a/src/Array/zip.luau b/src/Array/zip.luau index 2ebee7f..fe5b5b5 100644 --- a/src/Array/zip.luau +++ b/src/Array/zip.luau @@ -14,28 +14,28 @@ local reduce = require("./reduce") ``` ]=] local function zip(...: { any }): { { any } } - if select("#", ...) == 0 then - return {} - end + if select("#", ...) == 0 then + return {} + end - local arrays = { ... } - local length = reduce(arrays, function(acc, array) - return math.min(acc, #array) - end, math.huge) + local arrays = { ... } + local length = reduce(arrays, function(acc, array) + return math.min(acc, #array) + end, math.huge) - local out = {} + local out = {} - for index = 1, length do - local values = {} + for index = 1, length do + local values = {} - for _, array in arrays do - table.insert(values, array[index]) - end + for _, array in arrays do + table.insert(values, array[index]) + end - table.insert(out, values) - end + table.insert(out, values) + end - return out + return out end return zip diff --git a/src/Array/zipAll.luau b/src/Array/zipAll.luau index 6050316..447f7cb 100644 --- a/src/Array/zipAll.luau +++ b/src/Array/zipAll.luau @@ -15,29 +15,29 @@ local reduce = require("./reduce") ``` ]=] local function zipAll(...: { any }): { { any } } - if select("#", ...) == 0 then - return {} - end + if select("#", ...) == 0 then + return {} + end - local arrays = { ... } - local length = reduce(arrays, function(acc, array) - return math.max(acc, #array) - end, 0) + local arrays = { ... } + local length = reduce(arrays, function(acc, array) + return math.max(acc, #array) + end, 0) - local out = {} + local out = {} - for i = 1, length do - local values = {} + for i = 1, length do + local values = {} - for _, array in arrays do - local value = if array[i] == nil then None else array[i] - table.insert(values, value) - end + for _, array in arrays do + local value = if array[i] == nil then None else array[i] + table.insert(values, value) + end - table.insert(out, values) - end + table.insert(out, values) + end - return out + return out end return zipAll diff --git a/src/Dictionary/copyDeep.luau b/src/Dictionary/copyDeep.luau index 772f1dd..2eac03f 100644 --- a/src/Dictionary/copyDeep.luau +++ b/src/Dictionary/copyDeep.luau @@ -9,17 +9,17 @@ ``` ]=] local function copyDeep(dictionary: { [K]: V }): { [K]: V } - local out: { [K]: V } = {} + local out: { [K]: V } = {} - for key, value in dictionary do - if typeof(value) == "table" then - out[key] = copyDeep(value) :: any - else - out[key] = value - end - end + for key, value in dictionary do + if typeof(value) == "table" then + out[key] = copyDeep(value) :: any + else + out[key] = value + end + end - return out + return out end return copyDeep diff --git a/src/Dictionary/count.luau b/src/Dictionary/count.luau index a5a8660..97157eb 100644 --- a/src/Dictionary/count.luau +++ b/src/Dictionary/count.luau @@ -13,18 +13,18 @@ ``` ]=] local function count( - dictionary: { [K]: V }, - predicate: ((value: V, key: K) -> boolean)? + dictionary: { [K]: V }, + predicate: ((value: V, key: K) -> boolean)? ): number - local counter = 0 + local counter = 0 - for key, value in dictionary do - if not predicate or predicate(value, key) then - counter += 1 - end - end + for key, value in dictionary do + if not predicate or predicate(value, key) then + counter += 1 + end + end - return counter + return counter end return count diff --git a/src/Dictionary/difference.luau b/src/Dictionary/difference.luau index 24971d5..e16f9e8 100644 --- a/src/Dictionary/difference.luau +++ b/src/Dictionary/difference.luau @@ -13,15 +13,15 @@ local Util = require("@Sift/Util") ``` ]=] local function difference(dictionary: { [K]: V }, other: { [K]: V }): { [K]: V } - local out = {} + local out = {} - for key, value in dictionary do - if not Util.areEqual(value, other[key]) then - out[key] = value - end - end + for key, value in dictionary do + if not Util.areEqual(value, other[key]) then + out[key] = value + end + end - return out + return out end return difference diff --git a/src/Dictionary/differenceDeep.luau b/src/Dictionary/differenceDeep.luau index fcbe184..ba1e15c 100644 --- a/src/Dictionary/differenceDeep.luau +++ b/src/Dictionary/differenceDeep.luau @@ -12,25 +12,25 @@ ``` ]=] local function differenceDeep(dictionary: { [K]: V }, other: { [K]: V }): { [K]: V } - local out: { [K]: any } = {} + local out: { [K]: any } = {} - for key, value in dictionary do - if typeof(value) == "table" then - if typeof(other[key]) == "table" then - out[key] = differenceDeep(value, other[key]) - continue - end + for key, value in dictionary do + if typeof(value) == "table" then + if typeof(other[key]) == "table" then + out[key] = differenceDeep(value, other[key]) + continue + end - out[key] = value - continue - end + out[key] = value + continue + end - if other[key] == nil or other[key] ~= value then - out[key] = value - end - end + if other[key] == nil or other[key] ~= value then + out[key] = value + end + end - return out + return out end return differenceDeep diff --git a/src/Dictionary/entries.luau b/src/Dictionary/entries.luau index b56db2b..ff8910e 100644 --- a/src/Dictionary/entries.luau +++ b/src/Dictionary/entries.luau @@ -9,13 +9,13 @@ ``` ]=] local function entries(dictionary: { [K]: V }): { { K | V } } - local out = {} + local out = {} - for key, value in dictionary do - table.insert(out, { key, value :: any }) - end + for key, value in dictionary do + table.insert(out, { key, value :: any }) + end - return out + return out end return entries diff --git a/src/Dictionary/equals.luau b/src/Dictionary/equals.luau index 842cc49..ca8bbcc 100644 --- a/src/Dictionary/equals.luau +++ b/src/Dictionary/equals.luau @@ -1,23 +1,23 @@ local Util = require("@Sift/Util") local function compare(a, b) - if typeof(a) ~= "table" or typeof(b) ~= "table" then - return a == b - end - - for key, value in a do - if b[key] ~= value then - return false - end - end - - for key, value in b do - if a[key] ~= value then - return false - end - end - - return true + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end + + for key, value in a do + if b[key] ~= value then + return false + end + end + + for key, value in b do + if a[key] ~= value then + return false + end + end + + return true end --[=[ @@ -35,20 +35,20 @@ end ``` ]=] local function equals(...: { [any]: any }): boolean - if Util.areEqual(...) then - return true - end + if Util.areEqual(...) then + return true + end - local args = { ... } - local first = table.remove(args, 1) :: { [any]: any } + local args = { ... } + local first = table.remove(args, 1) :: { [any]: any } - for _, dictionary in args do - if not compare(first, dictionary) then - return false - end - end + for _, dictionary in args do + if not compare(first, dictionary) then + return false + end + end - return true + return true end return equals diff --git a/src/Dictionary/equalsDeep.luau b/src/Dictionary/equalsDeep.luau index e635c4c..e81ec67 100644 --- a/src/Dictionary/equalsDeep.luau +++ b/src/Dictionary/equalsDeep.luau @@ -1,23 +1,23 @@ local Util = require("@Sift/Util") local function compareDeep(a, b) - if typeof(a) ~= "table" or typeof(b) ~= "table" then - return a == b - end - - for key, value in a do - if not compareDeep(value, b[key]) then - return false - end - end - - for key, value in b do - if not compareDeep(value, a[key]) then - return false - end - end - - return true + if typeof(a) ~= "table" or typeof(b) ~= "table" then + return a == b + end + + for key, value in a do + if not compareDeep(value, b[key]) then + return false + end + end + + for key, value in b do + if not compareDeep(value, a[key]) then + return false + end + end + + return true end --[=[ @@ -35,20 +35,20 @@ end ``` ]=] local function equalsDeep(...: { [any]: any }): boolean - if Util.areEqual(...) then - return true - end + if Util.areEqual(...) then + return true + end - local args = { ... } - local first = table.remove(args, 1) :: { [any]: any } + local args = { ... } + local first = table.remove(args, 1) :: { [any]: any } - for _, dictionary in args do - if not compareDeep(first, dictionary) then - return false - end - end + for _, dictionary in args do + if not compareDeep(first, dictionary) then + return false + end + end - return true + return true end return equalsDeep diff --git a/src/Dictionary/every.luau b/src/Dictionary/every.luau index f12a889..4e9e1e6 100644 --- a/src/Dictionary/every.luau +++ b/src/Dictionary/every.luau @@ -10,13 +10,13 @@ ``` ]=] local function every(dictionary: { [K]: V }, predicate: (value: V, key: K) -> boolean): boolean - for key, value in dictionary do - if not predicate(value, key) then - return false - end - end + for key, value in dictionary do + if not predicate(value, key) then + return false + end + end - return true + return true end return every diff --git a/src/Dictionary/expandKeys.luau b/src/Dictionary/expandKeys.luau index eb3cfc2..941904b 100644 --- a/src/Dictionary/expandKeys.luau +++ b/src/Dictionary/expandKeys.luau @@ -16,30 +16,30 @@ type ExpandedDictionary = { [string]: ExpandedDictionary | V } ``` ]=] local function expandKeys( - dictionary: { [string]: V }, - separator: string? + dictionary: { [string]: V }, + separator: string? ): ExpandedDictionary - local withSeparator = separator or "." - local out = {} + local withSeparator = separator or "." + local out = {} - for key, value in dictionary do - local parts = key:split(withSeparator) - local current = out + for key, value in dictionary do + local parts = key:split(withSeparator) + local current = out - while #parts > 1 do - local part = table.remove(parts, 1) + while #parts > 1 do + local part = table.remove(parts, 1) - if not current[part] then - current[part] = {} - end + if not current[part] then + current[part] = {} + end - current = current[part] - end + current = current[part] + end - current[parts[1]] = value :: any - end + current[parts[1]] = value :: any + end - return out :: any + return out :: any end return expandKeys diff --git a/src/Dictionary/filter.luau b/src/Dictionary/filter.luau index cf6939f..229971d 100644 --- a/src/Dictionary/filter.luau +++ b/src/Dictionary/filter.luau @@ -10,18 +10,18 @@ ``` ]=] local function filter( - dictionary: { [K]: V }, - filterer: (value: V, key: K) -> boolean + dictionary: { [K]: V }, + filterer: (value: V, key: K) -> boolean ): { [K]: V } - local out = {} + local out = {} - for key, value in dictionary do - if filterer(value, key) then - out[key] = value - end - end + for key, value in dictionary do + if filterer(value, key) then + out[key] = value + end + end - return out + return out end return filter diff --git a/src/Dictionary/flatten.luau b/src/Dictionary/flatten.luau index c0a83f9..116a4cc 100644 --- a/src/Dictionary/flatten.luau +++ b/src/Dictionary/flatten.luau @@ -6,25 +6,25 @@ local INF = newproxy() Flattens nested dictionaries into a single dictionary. The `depth` parameter specifies the depth of the flattening. If `depth` is not specified, the dictionary is flattened as much as possible. ]=] local function flatten(dictionary: { [any]: any }, depth: number?): { [K]: V } - local withDepth = depth or INF - local out = {} + local withDepth = depth or INF + local out = {} - for key, value in dictionary do - if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then - local useDepth = withDepth == INF and INF or withDepth - 1 - local nested = flatten(value, useDepth) + for key, value in dictionary do + if typeof(value) == "table" and (withDepth == INF or withDepth > 0) then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flatten(value, useDepth) - for nestedKey, nestedValue in nested do - out[nestedKey] = nestedValue - end + for nestedKey, nestedValue in nested do + out[nestedKey] = nestedValue + end - continue - end + continue + end - out[key] = value - end + out[key] = value + end - return out + return out end return flatten diff --git a/src/Dictionary/flattenKeys.luau b/src/Dictionary/flattenKeys.luau index 94fcae7..65627ca 100644 --- a/src/Dictionary/flattenKeys.luau +++ b/src/Dictionary/flattenKeys.luau @@ -6,31 +6,31 @@ type FlattenableDictionary = { [string]: FlattenableDictionary | V } @within Dictionary ]=] local function flattenKeys( - dictionary: FlattenableDictionary, - depth: number?, - separator: string? + dictionary: FlattenableDictionary, + depth: number?, + separator: string? ): { [string]: V } - local withSeparator = separator or "." - local withDepth = depth or INF + local withSeparator = separator or "." + local withDepth = depth or INF - local out: { [string]: V } = {} + local out: { [string]: V } = {} - for key, value in dictionary do - if typeof(value) == "table" and depth > 0 then - local useDepth = withDepth == INF and INF or withDepth - 1 - local nested = flattenKeys(value, useDepth, withSeparator) + for key, value in dictionary do + if typeof(value) == "table" and depth > 0 then + local useDepth = withDepth == INF and INF or withDepth - 1 + local nested = flattenKeys(value, useDepth, withSeparator) - for nestedKey, nestedValue in nested do - out[`{key}{withSeparator}{nestedKey}`] = nestedValue - end + for nestedKey, nestedValue in nested do + out[`{key}{withSeparator}{nestedKey}`] = nestedValue + end - continue - end + continue + end - out[key] = value :: V - end + out[key] = value :: V + end - return out + return out end return flattenKeys diff --git a/src/Dictionary/flip.luau b/src/Dictionary/flip.luau index f16dbfd..3759359 100644 --- a/src/Dictionary/flip.luau +++ b/src/Dictionary/flip.luau @@ -9,13 +9,13 @@ ``` ]=] local function flip(dictionary: { [K]: V }): { [V]: K } - local out = {} + local out = {} - for key, value in dictionary do - out[value] = key - end + for key, value in dictionary do + out[value] = key + end - return out + return out end return flip diff --git a/src/Dictionary/freeze.luau b/src/Dictionary/freeze.luau index 254908e..a7e4662 100644 --- a/src/Dictionary/freeze.luau +++ b/src/Dictionary/freeze.luau @@ -13,8 +13,8 @@ local copy = require("./copy") ``` ]=] local function freeze(dictionary: { [K]: V }): { [K]: V } - local out = copy(dictionary) - return table.freeze(out) + local out = copy(dictionary) + return table.freeze(out) end return freeze diff --git a/src/Dictionary/freezeDeep.luau b/src/Dictionary/freezeDeep.luau index 3c7359a..a472be8 100644 --- a/src/Dictionary/freezeDeep.luau +++ b/src/Dictionary/freezeDeep.luau @@ -15,20 +15,20 @@ ``` ]=] local function freezeDeep(dictionary: { [K]: V }): { [K]: V } - local out = {} + local out = {} - for key, value in dictionary do - if typeof(value) == "table" then - local nested: any = freezeDeep(value) - out[key] = nested + for key, value in dictionary do + if typeof(value) == "table" then + local nested: any = freezeDeep(value) + out[key] = nested - continue - end + continue + end - out[key] = value - end + out[key] = value + end - return table.freeze(out) + return table.freeze(out) end return freezeDeep diff --git a/src/Dictionary/fromArrays.luau b/src/Dictionary/fromArrays.luau index 7a0522a..22c2efa 100644 --- a/src/Dictionary/fromArrays.luau +++ b/src/Dictionary/fromArrays.luau @@ -11,13 +11,13 @@ ``` ]=] local function fromArrays(keys: { K }, values: { V }): { [K]: V } - local out = {} + local out = {} - for index, key in keys do - out[key] = values[index] - end + for index, key in keys do + out[key] = values[index] + end - return out + return out end return fromArrays diff --git a/src/Dictionary/fromEntries.luau b/src/Dictionary/fromEntries.luau index f2cb3b5..46764f4 100644 --- a/src/Dictionary/fromEntries.luau +++ b/src/Dictionary/fromEntries.luau @@ -9,13 +9,13 @@ ``` ]=] local function fromEntries(entries: { { K | V } }): { [K]: V } - local out = {} + local out = {} - for _, entry in entries do - out[entry[1] :: K] = entry[2] :: V - end + for _, entry in entries do + out[entry[1] :: K] = entry[2] :: V + end - return out + return out end return fromEntries diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau index f132b35..f41481d 100644 --- a/src/Dictionary/get.luau +++ b/src/Dictionary/get.luau @@ -18,24 +18,24 @@ ``` ]=] local function get(dictionary: { [K]: V }, key: K, separated: (string | boolean)?): V? - if not separated then - return dictionary[key] - end + if not separated then + return dictionary[key] + end - local separator = type(separated) == "string" and separated or "." - local parts: { string } = (key :: any):split(separator) - local value: any = dictionary + local separator = type(separated) == "string" and separated or "." + local parts: { string } = (key :: any):split(separator) + local value: any = dictionary - while #parts > 0 do - local part = table.remove(parts, 1) - value = value[part] + while #parts > 0 do + local part = table.remove(parts, 1) + value = value[part] - if value == nil then - return nil - end - end + if value == nil then + return nil + end + end - return value + return value end return get diff --git a/src/Dictionary/has.luau b/src/Dictionary/has.luau index 609e386..07c4414 100644 --- a/src/Dictionary/has.luau +++ b/src/Dictionary/has.luau @@ -8,7 +8,7 @@ ``` ]=] local function has(dictionary: { [K]: V }, key: K): boolean - return dictionary[key] ~= nil + return dictionary[key] ~= nil end return has diff --git a/src/Dictionary/includes.luau b/src/Dictionary/includes.luau index 6205a7d..77a2382 100644 --- a/src/Dictionary/includes.luau +++ b/src/Dictionary/includes.luau @@ -8,13 +8,13 @@ ``` ]=] local function includes(dictionary: { [K]: V }, value: V): (boolean, K?) - for key, val in dictionary do - if val == value then - return true, key - end - end + for key, val in dictionary do + if val == value then + return true, key + end + end - return false, nil + return false, nil end return includes diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 533b1ae..99bd641 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -12,41 +12,41 @@ ``` ]=] local dictionary = { - copy = require("./copy"), - copyDeep = require("./copyDeep"), - count = require("./count"), - difference = require("./difference"), - differenceDeep = require("./differenceDeep"), - entries = require("./entries"), - equals = require("./equals"), - equalsDeep = require("./equalsDeep"), - every = require("./every"), - expandKeys = require("./expandKeys"), - filter = require("./filter"), - flatten = require("./flatten"), - flattenKeys = require("./flattenKeys"), - flip = require("./flip"), - freeze = require("./freeze"), - freezeDeep = require("./freezeDeep"), - fromArrays = require("./fromArrays"), - fromEntries = require("./fromEntries"), - get = require("./get"), - has = require("./has"), - includes = require("./includes"), - keys = require("./keys"), - map = require("./map"), - merge = require("./merge"), - mergeDeep = require("./mergeDeep"), - patchDiff = require("./patchDiff"), - removeKey = require("./removeKey"), - removeKeys = require("./removeKeys"), - removeValue = require("./removeValue"), - removeValues = require("./removeValues"), - set = require("./set"), - some = require("./some"), - update = require("./update"), - values = require("./values"), - pick = require("./pick"), + copy = require("./copy"), + copyDeep = require("./copyDeep"), + count = require("./count"), + difference = require("./difference"), + differenceDeep = require("./differenceDeep"), + entries = require("./entries"), + equals = require("./equals"), + equalsDeep = require("./equalsDeep"), + every = require("./every"), + expandKeys = require("./expandKeys"), + filter = require("./filter"), + flatten = require("./flatten"), + flattenKeys = require("./flattenKeys"), + flip = require("./flip"), + freeze = require("./freeze"), + freezeDeep = require("./freezeDeep"), + fromArrays = require("./fromArrays"), + fromEntries = require("./fromEntries"), + get = require("./get"), + has = require("./has"), + includes = require("./includes"), + keys = require("./keys"), + map = require("./map"), + merge = require("./merge"), + mergeDeep = require("./mergeDeep"), + patchDiff = require("./patchDiff"), + removeKey = require("./removeKey"), + removeKeys = require("./removeKeys"), + removeValue = require("./removeValue"), + removeValues = require("./removeValues"), + set = require("./set"), + some = require("./some"), + update = require("./update"), + values = require("./values"), + pick = require("./pick"), } return dictionary diff --git a/src/Dictionary/keys.luau b/src/Dictionary/keys.luau index f9a165a..04f49da 100644 --- a/src/Dictionary/keys.luau +++ b/src/Dictionary/keys.luau @@ -8,13 +8,13 @@ ``` ]=] local function keys(dictionary: { [K]: V }): { K } - local out = {} + local out = {} - for key in dictionary do - table.insert(out, key) - end + for key in dictionary do + table.insert(out, key) + end - return out + return out end return keys diff --git a/src/Dictionary/map.luau b/src/Dictionary/map.luau index c698538..3c9856e 100644 --- a/src/Dictionary/map.luau +++ b/src/Dictionary/map.luau @@ -16,19 +16,19 @@ local None = require("@Sift/None") ``` ]=] local function map(dictionary: { [K]: V }, mapper: (value: V, key: K) -> (Y, X)): { [X]: Y } - local out: { [X]: Y } = {} + local out: { [X]: Y } = {} - for key, value in dictionary do - local mappedValue, mappedKey = mapper(value, key) + for key, value in dictionary do + local mappedValue, mappedKey = mapper(value, key) - if mappedKey == None or mappedValue == None then - continue - end + if mappedKey == None or mappedValue == None then + continue + end - out[mappedKey or key :: any] = mappedValue - end + out[mappedKey or key :: any] = mappedValue + end - return out + return out end return map diff --git a/src/Dictionary/merge.luau b/src/Dictionary/merge.luau index 3b758b3..ba22ca6 100644 --- a/src/Dictionary/merge.luau +++ b/src/Dictionary/merge.luau @@ -13,17 +13,17 @@ local None = require("@Sift/None") ``` ]=] local function merge(...: { [any]: any }): { [K]: V } - local out = {} + local out = {} - for _, dictionary in { ... } do - for key, value in dictionary do - if key ~= None and value ~= None then - out[key] = value - end - end - end + for _, dictionary in { ... } do + for key, value in dictionary do + if key ~= None and value ~= None then + out[key] = value + end + end + end - return out + return out end return merge diff --git a/src/Dictionary/mergeDeep.luau b/src/Dictionary/mergeDeep.luau index 9b49f8e..31ab2c1 100644 --- a/src/Dictionary/mergeDeep.luau +++ b/src/Dictionary/mergeDeep.luau @@ -15,30 +15,30 @@ local copyDeep = require("./copyDeep") ``` ]=] local function mergeDeep(...: { [any]: any }): { [K]: V } - local out: any = {} - - for _, dictionary in { ... } do - for key, value in dictionary do - if value == None then - out[key] = nil - continue - end - - if typeof(value) == "table" then - if out[key] == nil or typeof(out[key]) ~= "table" then - out[key] = copyDeep(value) - continue - end - - out[key] = mergeDeep(out[key], value) - continue - end - - out[key] = value - end - end - - return out + local out: any = {} + + for _, dictionary in { ... } do + for key, value in dictionary do + if value == None then + out[key] = nil + continue + end + + if typeof(value) == "table" then + if out[key] == nil or typeof(out[key]) ~= "table" then + out[key] = copyDeep(value) + continue + end + + out[key] = mergeDeep(out[key], value) + continue + end + + out[key] = value + end + end + + return out end return mergeDeep diff --git a/src/Dictionary/patchDiff.luau b/src/Dictionary/patchDiff.luau index a122c31..aa8685c 100644 --- a/src/Dictionary/patchDiff.luau +++ b/src/Dictionary/patchDiff.luau @@ -1,9 +1,9 @@ export type Operation = "add" | "remove" | "replace" export type Patch = { - op: Operation, - path: { K }, - value: V, + op: Operation, + path: { K }, + value: V, } --[=[ @@ -44,53 +44,53 @@ export type Patch = { ``` ]=] local function patchDiff(dictionary: { [K]: V }, other: { [K]: V }): { Patch } - local out: { any } = {} + local out: { any } = {} - for key, value in dictionary do - if other[key] == nil then - table.insert(out, { - op = "remove", - path = { key }, - value = value, - }) + for key, value in dictionary do + if other[key] == nil then + table.insert(out, { + op = "remove", + path = { key }, + value = value, + }) - continue - end + continue + end - if typeof(value) == "table" then - local subpatches = patchDiff(value, other[key]) + if typeof(value) == "table" then + local subpatches = patchDiff(value, other[key]) - for _, patch in subpatches do - table.insert(out, { - op = patch.op :: any, - path = { key, table.unpack(patch.path) }, - value = patch.value, - }) - end + for _, patch in subpatches do + table.insert(out, { + op = patch.op :: any, + path = { key, table.unpack(patch.path) }, + value = patch.value, + }) + end - continue - end + continue + end - if value ~= other[key] then - table.insert(out, { - op = "replace", - path = { key }, - value = other[key], - }) - end - end + if value ~= other[key] then + table.insert(out, { + op = "replace", + path = { key }, + value = other[key], + }) + end + end - for key, value in other do - if dictionary[key] == nil then - table.insert(out, { - op = "add", - path = { key }, - value = value, - }) - end - end + for key, value in other do + if dictionary[key] == nil then + table.insert(out, { + op = "add", + path = { key }, + value = value, + }) + end + end - return out + return out end return patchDiff diff --git a/src/Dictionary/pick.luau b/src/Dictionary/pick.luau index 62aaf5a..cf88c31 100644 --- a/src/Dictionary/pick.luau +++ b/src/Dictionary/pick.luau @@ -9,13 +9,13 @@ ``` ]=] local function pick(dictionary: { [K]: V }, ...: K): { [K]: V } - local out = {} + local out = {} - for _, key in { ... } do - out[key] = dictionary[key] - end + for _, key in { ... } do + out[key] = dictionary[key] + end - return out + return out end return pick diff --git a/src/Dictionary/removeKey.luau b/src/Dictionary/removeKey.luau index 25b3956..63577f0 100644 --- a/src/Dictionary/removeKey.luau +++ b/src/Dictionary/removeKey.luau @@ -11,7 +11,7 @@ local removeKeys = require("./removeKeys") ``` ]=] local function removeKey(dictionary: { [K]: V }, key: K): { [K]: V } - return removeKeys(dictionary, key) + return removeKeys(dictionary, key) end return removeKey diff --git a/src/Dictionary/removeKeys.luau b/src/Dictionary/removeKeys.luau index 8d522b6..dd9ff5f 100644 --- a/src/Dictionary/removeKeys.luau +++ b/src/Dictionary/removeKeys.luau @@ -11,11 +11,11 @@ local filter = require("./filter") ``` ]=] local function removeKeys(dictionary: { [K]: V }, ...: K): { [K]: V } - local keys = { ... } + local keys = { ... } - return filter(dictionary, function(_, key) - return table.find(keys, key) == nil - end) + return filter(dictionary, function(_, key) + return table.find(keys, key) == nil + end) end return removeKeys diff --git a/src/Dictionary/removeValue.luau b/src/Dictionary/removeValue.luau index 5985c65..6758fc0 100644 --- a/src/Dictionary/removeValue.luau +++ b/src/Dictionary/removeValue.luau @@ -10,7 +10,7 @@ local removeValues = require("./removeValues") ``` ]=] local function removeValue(dictionary: { [K]: V }, value: V): { [K]: V } - return removeValues(dictionary, value) + return removeValues(dictionary, value) end return removeValue diff --git a/src/Dictionary/removeValues.luau b/src/Dictionary/removeValues.luau index b858de7..e539a6d 100644 --- a/src/Dictionary/removeValues.luau +++ b/src/Dictionary/removeValues.luau @@ -11,11 +11,11 @@ local filter = require("./filter") ``` ]=] local function removeValues(dictionary: { [K]: V }, ...: V): { [K]: V } - local values = { ... } + local values = { ... } - return filter(dictionary, function(value) - return table.find(values, value) == nil - end) + return filter(dictionary, function(value) + return table.find(values, value) == nil + end) end return removeValues diff --git a/src/Dictionary/set.luau b/src/Dictionary/set.luau index efcbc12..280d2bc 100644 --- a/src/Dictionary/set.luau +++ b/src/Dictionary/set.luau @@ -13,35 +13,35 @@ local copy = require("./copy") ``` ]=] local function set( - dictionary: { [K]: V }, - key: K, - value: V, - separated: (string | boolean)? + dictionary: { [K]: V }, + key: K, + value: V, + separated: (string | boolean)? ): { [K]: V } - local out = copy(dictionary) + local out = copy(dictionary) - if not separated then - out[key] = value - return out - end + if not separated then + out[key] = value + return out + end - local separator = type(separated) == "string" and separated or "." - local parts: { K } = (key :: any):split(separator) - local current: any = out + local separator = type(separated) == "string" and separated or "." + local parts: { K } = (key :: any):split(separator) + local current: any = out - while #parts > 1 do - local part = table.remove(parts, 1) :: K + while #parts > 1 do + local part = table.remove(parts, 1) :: K - if not current[part] then - current[part] = {} - end + if not current[part] then + current[part] = {} + end - current = current[part] - end + current = current[part] + end - current[parts[1]] = value + current[parts[1]] = value - return out + return out end return set diff --git a/src/Dictionary/some.luau b/src/Dictionary/some.luau index 12093dd..6182f6a 100644 --- a/src/Dictionary/some.luau +++ b/src/Dictionary/some.luau @@ -10,13 +10,13 @@ ``` ]=] local function some(dictionary: { [K]: V }, predicate: (value: V, key: K) -> boolean): boolean - for key, value in dictionary do - if predicate(value, key) then - return true - end - end + for key, value in dictionary do + if predicate(value, key) then + return true + end + end - return false + return false end return some diff --git a/src/Dictionary/update.luau b/src/Dictionary/update.luau index 2e84bf2..8c2a935 100644 --- a/src/Dictionary/update.luau +++ b/src/Dictionary/update.luau @@ -19,20 +19,20 @@ local copy = require("./copy") ``` ]=] local function update( - dictionary: { [K]: V }, - key: K, - updater: ((value: V, key: K) -> T)?, - adder: ((key: K) -> T)? + dictionary: { [K]: V }, + key: K, + updater: ((value: V, key: K) -> T)?, + adder: ((key: K) -> T)? ): { [K]: T } - local out: { [K]: any } = copy(dictionary) + local out: { [K]: any } = copy(dictionary) - if updater and out[key] ~= nil and out[key] ~= None then - out[key] = updater(out[key], key) :: any - elseif adder and (out[key] == nil or out[key] == None) then - out[key] = adder(key) :: any - end + if updater and out[key] ~= nil and out[key] ~= None then + out[key] = updater(out[key], key) :: any + elseif adder and (out[key] == nil or out[key] == None) then + out[key] = adder(key) :: any + end - return out + return out end return update diff --git a/src/Dictionary/values.luau b/src/Dictionary/values.luau index da5a86e..8204ad8 100644 --- a/src/Dictionary/values.luau +++ b/src/Dictionary/values.luau @@ -8,13 +8,13 @@ ``` ]=] local function values(dictionary: { [K]: V }): { V } - local out = {} + local out = {} - for _, value in dictionary do - table.insert(out, value) - end + for _, value in dictionary do + table.insert(out, value) + end - return out + return out end return values diff --git a/src/None.luau b/src/None.luau index 15d886e..17aac5d 100644 --- a/src/None.luau +++ b/src/None.luau @@ -12,7 +12,7 @@ local None: unknown = newproxy(true) getmetatable(None :: any).__tostring = function() - return "Sift.None" + return "Sift.None" end export type None = typeof(None) diff --git a/src/Set/add.luau b/src/Set/add.luau index cb06a0a..a838d74 100644 --- a/src/Set/add.luau +++ b/src/Set/add.luau @@ -11,10 +11,10 @@ local copy = require("./copy") ``` ]=] local function add(set: { [T]: boolean }, value: T): { [T]: boolean } - local newSet = copy(set) - newSet[value] = true + local newSet = copy(set) + newSet[value] = true - return newSet + return newSet end return add diff --git a/src/Set/copy.luau b/src/Set/copy.luau index be0cd57..8269234 100644 --- a/src/Set/copy.luau +++ b/src/Set/copy.luau @@ -8,13 +8,13 @@ ``` ]=] local function copy(set: { [T]: boolean }): { [T]: boolean } - local out = {} + local out = {} - for value in set do - out[value] = true - end + for value in set do + out[value] = true + end - return out + return out end return copy diff --git a/src/Set/count.luau b/src/Set/count.luau index 0d44e64..55462fb 100644 --- a/src/Set/count.luau +++ b/src/Set/count.luau @@ -13,15 +13,15 @@ ``` ]=] local function count(set: { [T]: boolean }, predicate: ((value: T) -> boolean)?): number - local counter = 0 + local counter = 0 - for value in set do - if not predicate or predicate(value) then - counter += 1 - end - end + for value in set do + if not predicate or predicate(value) then + counter += 1 + end + end - return counter + return counter end return count diff --git a/src/Set/delete.luau b/src/Set/delete.luau index 415248c..5a66e3f 100644 --- a/src/Set/delete.luau +++ b/src/Set/delete.luau @@ -11,11 +11,11 @@ local filter = require("./filter") ``` ]=] local function delete(set: { [T]: boolean }, ...: T): { [T]: boolean } - local values = { ... } + local values = { ... } - return filter(set, function(value: T): boolean - return table.find(values, value) == nil - end) + return filter(set, function(value: T): boolean + return table.find(values, value) == nil + end) end return delete diff --git a/src/Set/difference.luau b/src/Set/difference.luau index 6578b70..3f6998b 100644 --- a/src/Set/difference.luau +++ b/src/Set/difference.luau @@ -13,15 +13,15 @@ local copy = require("./copy") ``` ]=] local function difference(set: { [T]: boolean }, ...: { [T]: boolean }): { [T]: boolean } - local out = copy(set) + local out = copy(set) - for _, other in { ... } do - for value in other do - out[value] = nil - end - end + for _, other in { ... } do + for value in other do + out[value] = nil + end + end - return out + return out end return difference diff --git a/src/Set/differenceSymmetric.luau b/src/Set/differenceSymmetric.luau index 7c9f02e..005e2cf 100644 --- a/src/Set/differenceSymmetric.luau +++ b/src/Set/differenceSymmetric.luau @@ -13,24 +13,24 @@ local copy = require("./copy") ``` ]=] local function differenceSymmetric( - set: { [T]: boolean }, - ...: { [T]: boolean } + set: { [T]: boolean }, + ...: { [T]: boolean } ): { [T]: boolean } - local out = copy(set) + local out = copy(set) - for _, other in { ... } do - for value in other do - out[value] = out[value] == nil - end - end + for _, other in { ... } do + for value in other do + out[value] = out[value] == nil + end + end - for value, keep in out do - if not keep then - out[value] = nil - end - end + for value, keep in out do + if not keep then + out[value] = nil + end + end - return out + return out end return differenceSymmetric diff --git a/src/Set/filter.luau b/src/Set/filter.luau index 8685caf..5210ef0 100644 --- a/src/Set/filter.luau +++ b/src/Set/filter.luau @@ -10,15 +10,15 @@ ``` ]=] local function filter(set: { [T]: boolean }, filterer: (value: T) -> boolean): { [T]: boolean } - local out = {} + local out = {} - for value in set do - if filterer(value) then - out[value] = true - end - end + for value in set do + if filterer(value) then + out[value] = true + end + end - return out + return out end return filter diff --git a/src/Set/fromArray.luau b/src/Set/fromArray.luau index db96598..958d8b8 100644 --- a/src/Set/fromArray.luau +++ b/src/Set/fromArray.luau @@ -9,13 +9,13 @@ ``` ]=] local function fromArray(array: { T }): { [T]: boolean } - local out = {} + local out = {} - for _, value in array do - out[value] = true - end + for _, value in array do + out[value] = true + end - return out + return out end return fromArray diff --git a/src/Set/has.luau b/src/Set/has.luau index f4b7e6c..a1efc77 100644 --- a/src/Set/has.luau +++ b/src/Set/has.luau @@ -8,7 +8,7 @@ ``` ]=] local function has(set: { [T]: boolean }, value: T): boolean - return set[value] == true + return set[value] == true end return has diff --git a/src/Set/init.luau b/src/Set/init.luau index 9f39de7..8ce9311 100644 --- a/src/Set/init.luau +++ b/src/Set/init.luau @@ -9,22 +9,22 @@ ``` ]=] local set = { - add = require("./add"), - copy = require("./copy"), - count = require("./count"), - delete = require("./delete"), - difference = require("./difference"), - differenceSymmetric = require("./differenceSymmetric"), - filter = require("./filter"), - fromArray = require("./fromArray"), - has = require("./has"), - intersection = require("./intersection"), - isSubset = require("./isSubset"), - isSuperset = require("./isSuperset"), - map = require("./map"), - merge = require("./merge"), - partition = require("./partition"), - toArray = require("./toArray"), + add = require("./add"), + copy = require("./copy"), + count = require("./count"), + delete = require("./delete"), + difference = require("./difference"), + differenceSymmetric = require("./differenceSymmetric"), + filter = require("./filter"), + fromArray = require("./fromArray"), + has = require("./has"), + intersection = require("./intersection"), + isSubset = require("./isSubset"), + isSuperset = require("./isSuperset"), + map = require("./map"), + merge = require("./merge"), + partition = require("./partition"), + toArray = require("./toArray"), } return set diff --git a/src/Set/intersection.luau b/src/Set/intersection.luau index 1283f70..6356c2e 100644 --- a/src/Set/intersection.luau +++ b/src/Set/intersection.luau @@ -11,24 +11,24 @@ ``` ]=] local function intersection(set: { [T]: boolean }, ...: { [T]: boolean }): { [T]: boolean } - local out = {} + local out = {} - for value in set do - local intersects = true + for value in set do + local intersects = true - for _, other in { ... } do - if not other[value] then - intersects = false - break - end - end + for _, other in { ... } do + if not other[value] then + intersects = false + break + end + end - if intersects then - out[value] = true - end - end + if intersects then + out[value] = true + end + end - return out + return out end return intersection diff --git a/src/Set/isSubset.luau b/src/Set/isSubset.luau index 0d69de8..3009ac0 100644 --- a/src/Set/isSubset.luau +++ b/src/Set/isSubset.luau @@ -11,13 +11,13 @@ ``` ]=] local function isSubset(subset: { [T]: boolean }, superset: { [T]: boolean }): boolean - for value in subset do - if not superset[value] then - return false - end - end + for value in subset do + if not superset[value] then + return false + end + end - return true + return true end return isSubset diff --git a/src/Set/isSuperset.luau b/src/Set/isSuperset.luau index c41ea2e..dd47a2a 100644 --- a/src/Set/isSuperset.luau +++ b/src/Set/isSuperset.luau @@ -13,7 +13,7 @@ local isSubset = require("./isSubset") ``` ]=] local function isSuperset(superset: { [T]: boolean }, subset: { [T]: boolean }): boolean - return isSubset(subset, superset) + return isSubset(subset, superset) end return isSuperset diff --git a/src/Set/map.luau b/src/Set/map.luau index ce7e64b..55fd2ae 100644 --- a/src/Set/map.luau +++ b/src/Set/map.luau @@ -12,17 +12,17 @@ local None = require("@Sift/None") ``` ]=] local function map(set: { [T]: boolean }, mapper: (value: T) -> U): { [U]: boolean } - local out = {} + local out = {} - for value in set do - local mapped = mapper(value) + for value in set do + local mapped = mapper(value) - if mapped ~= nil and mapped ~= None then - out[mapped] = true - end - end + if mapped ~= nil and mapped ~= None then + out[mapped] = true + end + end - return out + return out end return map diff --git a/src/Set/merge.luau b/src/Set/merge.luau index 9c7b7d2..6bd6fdf 100644 --- a/src/Set/merge.luau +++ b/src/Set/merge.luau @@ -13,17 +13,17 @@ local None = require("@Sift/None") ``` ]=] local function merge(...: { [T]: boolean }): { [T]: boolean } - local out = {} + local out = {} - for _, set in { ... } do - for value in set do - if value ~= None then - out[value] = true - end - end - end + for _, set in { ... } do + for value in set do + if value ~= None then + out[value] = true + end + end + end - return out + return out end return merge diff --git a/src/Set/partition.luau b/src/Set/partition.luau index 446c453..4b669bd 100644 --- a/src/Set/partition.luau +++ b/src/Set/partition.luau @@ -12,21 +12,21 @@ ``` ]=] local function partition( - set: { [T]: boolean }, - predicate: (value: T) -> boolean + set: { [T]: boolean }, + predicate: (value: T) -> boolean ): ({ [T]: boolean }, { [T]: boolean }) - local pass = {} - local fail = {} + local pass = {} + local fail = {} - for value in set do - if predicate(value) then - pass[value] = true - else - fail[value] = true - end - end + for value in set do + if predicate(value) then + pass[value] = true + else + fail[value] = true + end + end - return pass, fail + return pass, fail end return partition diff --git a/src/Set/toArray.luau b/src/Set/toArray.luau index 2e946c2..1e4b33f 100644 --- a/src/Set/toArray.luau +++ b/src/Set/toArray.luau @@ -9,13 +9,13 @@ ``` ]=] local function toArray(set: { [T]: boolean }): { T } - local out = {} + local out = {} - for value in set do - table.insert(out, value) - end + for value in set do + table.insert(out, value) + end - return out + return out end return toArray diff --git a/src/Util.luau b/src/Util.luau index 199a12d..1bac839 100644 --- a/src/Util.luau +++ b/src/Util.luau @@ -1,36 +1,36 @@ local function isEmpty(value) - if typeof(value) == "table" then - return next(value) == nil - end + if typeof(value) == "table" then + return next(value) == nil + end - return value == nil + return value == nil end local function areEqual(...) - local args = { ... } - local first = table.remove(args, 1) + local args = { ... } + local first = table.remove(args, 1) - for _, value in args do - if first ~= value then - return false - end - end + for _, value in args do + if first ~= value then + return false + end + end - return true + return true end local function normalizeIndex(index, length) - if index == 0 then - return 1 - elseif index < 0 then - return index + length + 1 - end + if index == 0 then + return 1 + elseif index < 0 then + return index + length + 1 + end - return index + return index end return { - isEmpty = isEmpty, - areEqual = areEqual, - normalizeIndex = normalizeIndex, + isEmpty = isEmpty, + areEqual = areEqual, + normalizeIndex = normalizeIndex, } diff --git a/src/init.luau b/src/init.luau index c35150c..b62a6f3 100644 --- a/src/init.luau +++ b/src/init.luau @@ -6,15 +6,15 @@ local Util = require("@Sift/Util") Sift is a library for working with immutable data structures. It provides a collection of methods for working with arrays, dictionaries and sets. ]=] local sift = { - None = require("@Sift/None"), + None = require("@Sift/None"), - Array = require("@Sift/Array"), - Dictionary = require("@Sift/Dictionary"), - Set = require("@Sift/Set"), + Array = require("@Sift/Array"), + Dictionary = require("@Sift/Dictionary"), + Set = require("@Sift/Set"), - areEqual = Util.areEqual, - isEmpty = Util.isEmpty, - normalizeIndex = Util.normalizeIndex, + areEqual = Util.areEqual, + isEmpty = Util.isEmpty, + normalizeIndex = Util.normalizeIndex, } return sift diff --git a/stylua.toml b/stylua.toml index 0fa95b6..aba1ad0 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,4 +1,6 @@ column_width = 96 +indent_type = "Spaces" +indent_width = 4 [sort_requires] enabled = true From 0d8a693f2b15f72af877766d5bd3eabf1f7aaea1 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:19:10 +0000 Subject: [PATCH 23/43] Add code for formatting files and running stylua --- lune/format-files.luau | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lune/format-files.luau diff --git a/lune/format-files.luau b/lune/format-files.luau new file mode 100644 index 0000000..3ea4f17 --- /dev/null +++ b/lune/format-files.luau @@ -0,0 +1,75 @@ +local fs = require("@lune/fs") +local process = require("@lune/process") + +local crayon = require("./lib/crayon") + +local cwd = process.cwd:gsub("\\", "/"):gsub("//", "/"):gsub("/$", "") +local dir = process.args[1]:gsub("\\", "/"):gsub("//", "/"):gsub("/$", "") +local activeRoot = `{cwd}/{dir}` + +local function get_file_paths(root: string) + local paths = {} + + for _, path in fs.readDir(root) do + local fullPath = `{root}/{path}` + + if fs.isFile(fullPath) then + table.insert(paths, fullPath) + continue + end + + for _, subpath in get_file_paths(fullPath) do + table.insert(paths, subpath) + end + end + + return paths +end + +local function main() + -- Replace tabs with spaces + print( + crayon.label("INFO", crayon.bgCyan), + "scanning for files in", + crayon.yellow(`"./{dir}"`) + ) + + for _, file in get_file_paths(activeRoot) do + if not file:match("%.luau?$") then + continue + end + + local contents = fs.readFile(file) + local newContents = contents:gsub( + "(\t+)([^\n]+)", + function(tabs, rest) + return `{(" "):rep(#tabs * 4)}{rest}` + end :: any + ) + + if contents == newContents then + continue + end + + print( + crayon.label("FORMAT", crayon.bgGreen), + "fixed indentation in", + crayon.yellow(`"./{file:sub(#cwd + 2)}"`) + ) + + fs.writeFile(file, newContents) + end + + -- Format code with stylua + local status = process.spawn("stylua", { activeRoot }) + + if not status.ok then + print(crayon.label("ERROR", crayon.bgRed), "failed to format code with stylua") + process.exit(1) + return + end + + print(crayon.label("SUCCESS", crayon.bgGreen), "formatted code with stylua") +end + +main() From 77a310cfcb6d2eba469b673beba56ee478727b28 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:19:27 +0000 Subject: [PATCH 24/43] Add aliases for array, dictionary, and set methods --- src/Array/init.luau | 9 +++++++++ src/Dictionary/init.luau | 3 +++ src/Set/init.luau | 5 +++++ src/init.luau | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Array/init.luau b/src/Array/init.luau index a6ca499..4c2432f 100644 --- a/src/Array/init.luau +++ b/src/Array/init.luau @@ -61,4 +61,13 @@ local array = { zipAll = require("./zipAll"), } +array.join = array.concat +array.merge = array.concat +array.append = array.push +array.prepend = array.unshift +array.indexOf = array.find +array.has = array.includes +array.contains = array.includes +array.isArray = array.is + return array diff --git a/src/Dictionary/init.luau b/src/Dictionary/init.luau index 99bd641..d96703c 100644 --- a/src/Dictionary/init.luau +++ b/src/Dictionary/init.luau @@ -49,4 +49,7 @@ local dictionary = { pick = require("./pick"), } +dictionary.join = dictionary.merge +dictionary.joinDeep = dictionary.mergeDeep + return dictionary diff --git a/src/Set/init.luau b/src/Set/init.luau index 8ce9311..faa4bc5 100644 --- a/src/Set/init.luau +++ b/src/Set/init.luau @@ -27,4 +27,9 @@ local set = { toArray = require("./toArray"), } +set.fromList = set.fromArray +set.join = set.merge +set.subtract = set.delete +set.union = set.merge + return set diff --git a/src/init.luau b/src/init.luau index b62a6f3..4bfaf8f 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,9 +1,9 @@ local Util = require("@Sift/Util") --[=[ - @class Sift + @class Sift - Sift is a library for working with immutable data structures. It provides a collection of methods for working with arrays, dictionaries and sets. + Sift is a library for working with immutable data structures. It provides a collection of methods for working with arrays, dictionaries and sets. ]=] local sift = { None = require("@Sift/None"), @@ -17,4 +17,15 @@ local sift = { normalizeIndex = Util.normalizeIndex, } +sift.List = sift.Array + +--- @prop Array Array +--- @within Sift + +--- @prop Dictionary Dictionary +--- @within Sift + +--- @prop Set Set +--- @within Sift + return sift From 5b0b65ca01851524e0f3cdfede58ee6df16e55f5 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:19:40 +0000 Subject: [PATCH 25/43] Update code formatting --- src/Array/difference.luau | 10 +++---- src/Array/zip.luau | 2 +- src/Dictionary/get.luau | 30 ++++++++++---------- src/Dictionary/mergeDeep.luau | 14 +++++----- src/Dictionary/patchDiff.luau | 52 +++++++++++++++-------------------- src/Dictionary/update.luau | 20 +++++++------- src/None.luau | 14 +++++----- src/Set/copy.luau | 8 +++--- 8 files changed, 71 insertions(+), 79 deletions(-) diff --git a/src/Array/difference.luau b/src/Array/difference.luau index 07966e1..121a2aa 100644 --- a/src/Array/difference.luau +++ b/src/Array/difference.luau @@ -7,12 +7,12 @@ local toSet = require("./toSet") Returns a new array containing only values that are in the first array and not in any of the other arrays. - ```lua - local array1 = { 1, 2, 3 } - local array2 = { 2, 3, 4 } + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 2, 3, 4 } - difference(array1, array2) -- { 1 } - ``` + difference(array1, array2) -- { 1 } + ``` ]=] local function difference(array: { T }, ...: { T }): { T } local arraySet = toSet(array) diff --git a/src/Array/zip.luau b/src/Array/zip.luau index fe5b5b5..21f43df 100644 --- a/src/Array/zip.luau +++ b/src/Array/zip.luau @@ -10,7 +10,7 @@ local reduce = require("./reduce") local array2 = { 1, 2, 3 } zip(array1, array2) - -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } + -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } ``` ]=] local function zip(...: { any }): { { any } } diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau index f41481d..61ff4b3 100644 --- a/src/Dictionary/get.luau +++ b/src/Dictionary/get.luau @@ -1,21 +1,21 @@ --[=[ @within Dictionary - Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `separated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If `separated` is a string, it'll be used as the separator. If the key is not found, the function will return `nil`. - - ```lua - local dictionary = { - foo = { - bar = { - baz = "qux" - } - } - } - - get(dictionary, "foo.bar.baz") -- nil - get(dictionary, "foo.bar.baz", true) -- "qux" - get(dictionary, "foo$bar$baz", "$") -- "qux" - ``` + Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `separated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If `separated` is a string, it'll be used as the separator. If the key is not found, the function will return `nil`. + + ```lua + local dictionary = { + foo = { + bar = { + baz = "qux" + } + } + } + + get(dictionary, "foo.bar.baz") -- nil + get(dictionary, "foo.bar.baz", true) -- "qux" + get(dictionary, "foo$bar$baz", "$") -- "qux" + ``` ]=] local function get(dictionary: { [K]: V }, key: K, separated: (string | boolean)?): V? if not separated then diff --git a/src/Dictionary/mergeDeep.luau b/src/Dictionary/mergeDeep.luau index 31ab2c1..c8bfefa 100644 --- a/src/Dictionary/mergeDeep.luau +++ b/src/Dictionary/mergeDeep.luau @@ -4,15 +4,15 @@ local copyDeep = require("./copyDeep") --[=[ @within Dictionary - Combines multiple dictionaries into a single dictionary, including nested dictionaries. + Combines multiple dictionaries into a single dictionary, including nested dictionaries. - ```lua - local dictionary1 = { foo = "bar", deep = { foo = "bar" } } - local dictionary2 = { deep = { foo = "baz" } } + ```lua + local dictionary1 = { foo = "bar", deep = { foo = "bar" } } + local dictionary2 = { deep = { foo = "baz" } } - mergeDeep(dictionary1, dictionary2) - -- { foo = "bar", deep = { foo = "baz" } } - ``` + mergeDeep(dictionary1, dictionary2) + -- { foo = "bar", deep = { foo = "baz" } } + ``` ]=] local function mergeDeep(...: { [any]: any }): { [K]: V } local out: any = {} diff --git a/src/Dictionary/patchDiff.luau b/src/Dictionary/patchDiff.luau index aa8685c..852d43d 100644 --- a/src/Dictionary/patchDiff.luau +++ b/src/Dictionary/patchDiff.luau @@ -9,39 +9,31 @@ export type Patch = { --[=[ @within Dictionary - Returns an array of patches that can be applied to `dictionary` to make it equal to `other`. This is a deep comparison. The patches are similar to those used in JSON Patch. + Returns an array of patches that can be applied to `dictionary` to make it equal to `other`. This is a deep comparison. The patches are similar to those used in [JSON Patch](https://jsonpatch.com/). - ```lua - local dictionary1 = { - foo = "bar", - qux = { - baz = "quux", - }, - } + ```lua + local dictionary1 = { + foo = "bar", + qux = { + baz = "quux", + }, + } - local dictionary2 = { - foo = "bar", - qux = { - baz = "quuz", - }, - baz = "quux", - } + local dictionary2 = { + foo = "bar", + qux = { + baz = "quuz", + }, + baz = "quux", + } - patchDiff(dictionary1, dictionary2) --[[ - { - { - op = "replace", - path = { "qux", "baz" }, - value = "quuz", - }, - { - op = "add", - path = { "baz" }, - value = "quux", - }, - } - ]] - ``` + patchDiff(dictionary1, dictionary2) --[[ + { + { op = "replace", path = { "qux", "baz" }, value = "quuz" }, + { op = "add", path = { "baz" }, value = "quux" }, + } + ]] + ``` ]=] local function patchDiff(dictionary: { [K]: V }, other: { [K]: V }): { Patch } local out: { any } = {} diff --git a/src/Dictionary/update.luau b/src/Dictionary/update.luau index 8c2a935..dc63b75 100644 --- a/src/Dictionary/update.luau +++ b/src/Dictionary/update.luau @@ -4,19 +4,19 @@ local copy = require("./copy") --[=[ @within Dictionary - Updates a value in a dictionary with a given key. If the key does not exist, the value is added to the dictionary using the provided adder function. + Updates a value in a dictionary with a given key. If the key does not exist, the value is added to the dictionary using the provided adder function. - ```lua - local dictionary = { a = 1, b = 2 } + ```lua + local dictionary = { a = 1, b = 2 } - update(dictionary, "b", function(value) - return value + 1 - end) -- { a = 1, b = 3 } + update(dictionary, "b", function(value) + return value + 1 + end) -- { a = 1, b = 3 } - update(dictionary, "c", nil, function() - return 3 - end) -- { a = 1, b = 2, c = 3 } - ``` + update(dictionary, "c", nil, function() + return 3 + end) -- { a = 1, b = 2, c = 3 } + ``` ]=] local function update( dictionary: { [K]: V }, diff --git a/src/None.luau b/src/None.luau index 17aac5d..16326e2 100644 --- a/src/None.luau +++ b/src/None.luau @@ -1,13 +1,13 @@ --[=[ - @within Sift - @prop None None + @within Sift + @prop None None - Luau doesn't have a built-in `undefined` type, so Sift provides a `None` value to represent the absence of a value. + Luau doesn't have a built-in `undefined` type, so Sift provides a `None` value to represent the absence of a value. - ```lua - merge({ foo = "bar", baz = "qux" }, { foo = Sift.None }) - -- { baz = "qux" } - ``` + ```lua + merge({ foo = "bar", baz = "qux" }, { foo = Sift.None }) + -- { baz = "qux" } + ``` ]=] local None: unknown = newproxy(true) diff --git a/src/Set/copy.luau b/src/Set/copy.luau index 8269234..b53379d 100644 --- a/src/Set/copy.luau +++ b/src/Set/copy.luau @@ -1,11 +1,11 @@ --[=[ @within Set - Returns a shallow copy of the set. + Returns a shallow copy of the set. - ```lua - copy({ a = true, b = true }) -- { a = true, b = true } - ``` + ```lua + copy({ a = true, b = true }) -- { a = true, b = true } + ``` ]=] local function copy(set: { [T]: boolean }): { [T]: boolean } local out = {} From 293f4596b9c37080e5cb0e5f6452792d6a904897 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:22:16 +0000 Subject: [PATCH 26/43] Remove broken links from docs/intro.md --- docs/intro.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/intro.md b/docs/intro.md index 5356270..3d515e2 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -8,9 +8,7 @@ Sift is a utility library for working with immutable data structures in Luau and ## Get Started -- [Installation guide](/docs/Installation) - [**API Documentation**](/api) -- [Examples](/docs/Examples) ## Why Immutable? From b85520d7c3c184ba6b143fd4eb4aaedaff307f55 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:17:04 +0000 Subject: [PATCH 27/43] Update luauspec.toml --- luauspec.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/luauspec.toml b/luauspec.toml index 756c177..7739815 100644 --- a/luauspec.toml +++ b/luauspec.toml @@ -1,4 +1,18 @@ [package] name = "cxmeel/sift" +# description = "" # pulled from `wally.toml` +# version = "" # pulled from `wally.toml` +# main = "" # pulled from `default.project.json` +# registry = "https://github.com" # not applicable right now + +[project.aliases] +dependencies = "Pkg" +dev-dependencies = "DevPkg" [dependencies] + +[dev-dependencies] +# Crayon = "cxmeel/crayon@0.1.0" +Jest = "jsdotlua/jest@3.6.1-rc.2" +JestGlobals = "jsdotlua/jest-globals@3.6.1-rc.2" +# Semver = "cxmeel/semver@0.1.0" From e3da0cc6c4e6bce1aa6582d1936165984da33148 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:29:30 +0000 Subject: [PATCH 28/43] Ensure all files have tests associated --- lune/ensure-tests.luau | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lune/ensure-tests.luau diff --git a/lune/ensure-tests.luau b/lune/ensure-tests.luau new file mode 100644 index 0000000..9a90873 --- /dev/null +++ b/lune/ensure-tests.luau @@ -0,0 +1,78 @@ +local fs = require("@lune/fs") +local process = require("@lune/process") + +local crayon = require("./lib/crayon") + +local cwd = process.cwd:gsub("\\", "/"):gsub("/$", "") +local src = `{cwd}/src` +local tests = `{src}/__tests__` + +local IGNORED_FILES = { + `{src}/Array/init.luau`, + `{src}/Dictionary/init.luau`, + `{src}/Set/init.luau`, + `{src}/init.luau`, + `{src}/None.luau`, + `{src}/Util.luau`, +} + +local function get_file_paths(root: string) + local paths = {} + + for _, path in fs.readDir(root) do + local fullPath = `{root}/{path}` + + if fs.isFile(fullPath) then + table.insert(paths, fullPath) + continue + end + + if fs.isDir(fullPath) and fullPath == tests then + continue + end + + for _, subpath in get_file_paths(fullPath) do + table.insert(paths, subpath) + end + end + + return paths +end + +local function main() + local files = get_file_paths(src) + local missing = 0 + + for _, file in files do + if not file:match("%.luau$") or table.find(IGNORED_FILES, file) then + continue + end + + local relativePath = file:sub(#src + 2) + local testFilePath = (`{tests}/{relativePath}`):gsub("%.luau$", ".spec.luau") + + if not fs.isFile(testFilePath) then + print( + crayon.label("MISSING", crayon.bgRed), + "No test found for", + crayon.yellow(`"./{relativePath}"`) + ) + + missing += 1 + continue + end + end + + if missing > 0 then + print( + crayon.label("FAIL", crayon.bgRed), + "Missing", + crayon.bold(tostring(missing)), + "test files." + ) + + process.exit(1) + end +end + +main() From fb0742c5b2661473a8868b82287bf13316ab92c1 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:31:01 +0000 Subject: [PATCH 29/43] Update lune scripts --- lune/ensure-tests.luau | 2 +- lune/format-files.luau | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lune/ensure-tests.luau b/lune/ensure-tests.luau index 9a90873..88bb548 100644 --- a/lune/ensure-tests.luau +++ b/lune/ensure-tests.luau @@ -53,7 +53,7 @@ local function main() if not fs.isFile(testFilePath) then print( - crayon.label("MISSING", crayon.bgRed), + crayon.label("MISSING", crayon.bgRedBright), "No test found for", crayon.yellow(`"./{relativePath}"`) ) diff --git a/lune/format-files.luau b/lune/format-files.luau index 3ea4f17..6a809aa 100644 --- a/lune/format-files.luau +++ b/lune/format-files.luau @@ -29,7 +29,7 @@ end local function main() -- Replace tabs with spaces print( - crayon.label("INFO", crayon.bgCyan), + crayon.label("INFO", crayon.bgBlue), "scanning for files in", crayon.yellow(`"./{dir}"`) ) From a6c49b0fc7c3afe0bd71d0974e490c610d8b3933 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:32:02 +0000 Subject: [PATCH 30/43] Fix file matching pattern in ensure-tests.luau --- lune/ensure-tests.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lune/ensure-tests.luau b/lune/ensure-tests.luau index 88bb548..0463233 100644 --- a/lune/ensure-tests.luau +++ b/lune/ensure-tests.luau @@ -44,7 +44,7 @@ local function main() local missing = 0 for _, file in files do - if not file:match("%.luau$") or table.find(IGNORED_FILES, file) then + if not file:match("%.luau?$") or table.find(IGNORED_FILES, file) then continue end From 6b6d340d871188d89e863cd8c1ed2791581a0abd Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:20:31 +0000 Subject: [PATCH 31/43] Remove unnecessary files and update workflow triggers --- .github/workflows/auto-format.yml | 30 +++++++++++++++ .github/workflows/ci.yml | 62 ------------------------------- .github/workflows/docs.yml | 13 +++---- 3 files changed, 36 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/auto-format.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml new file mode 100644 index 0000000..b1162d4 --- /dev/null +++ b/.github/workflows/auto-format.yml @@ -0,0 +1,30 @@ +name: auto-format + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + format: + if: github.repository != github.event.pull_request.head.repo.full_name + runs-on: ubuntu-latest + timeout-minutes: 10 + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - uses: ok-nick/setup-aftman@v0.4.2 + with: + cache: true + + - name: Format files + run: lune run format-files src + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Auto-format files" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 054f062..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: ci - -on: - pull_request: - types: [opened, reopened, synchronize, ready_for_review] - push: - branches: [main] - -env: - COMMIT_HASH: ${{github.sha}} # default to the commit hash of the event - -jobs: - format-lint: - runs-on: ubuntu-latest - timeout-minutes: 5 - - steps: - - uses: actions/checkout@v2 - - uses: ok-nick/setup-aftman@v0.3.0 - - - name: Format - run: stylua --check src/ - - - name: Lint - run: selene src/ - - test-docs-build: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: lts/* - - - name: Install Moonwave - run: npm install -g moonwave - - - name: Build docs - run: moonwave build - - test-package-build: - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: [format-lint] - - steps: - - uses: actions/checkout@v2 - - uses: ok-nick/setup-aftman@v0.3.0 - - - name: Build - run: rojo build default.project.json -o build.rbxm - - - name: Set environment variables - run: echo "COMMIT_HASH=$(git rev-parse --short ${{github.sha}})" >> $GITHUB_ENV - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{github.event.repository.name}}-${{env.COMMIT_HASH}}.rbxm - path: build.rbxm diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7b739f7..36ffcd1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,8 +8,6 @@ on: paths: - "src/**" - "moonwave.toml" - - "wally.toml" - - "package.json" - "**/*.md" jobs: @@ -30,12 +28,13 @@ jobs: - name: Install Moonwave run: npm install -g moonwave - - name: Publish Docs + - name: Setup Git run: | git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - git config --global user.email "support+actions@github.com" - git config --global user.name "github-actions-bot" - - moonwave build --publish + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish Docs + run: moonwave build --publish From 0256956e35f3ef06aa9044145bfebbe1aec1b6c1 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:36:18 +0000 Subject: [PATCH 32/43] Update PR workflow --- .github/workflows/auto-format.yml | 30 ---------------- .github/workflows/pull-request.yml | 55 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/auto-format.yml create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml deleted file mode 100644 index b1162d4..0000000 --- a/.github/workflows/auto-format.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: auto-format - -on: - pull_request: - types: - - opened - - synchronize - -jobs: - format: - if: github.repository != github.event.pull_request.head.repo.full_name - runs-on: ubuntu-latest - timeout-minutes: 10 - - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - - - uses: ok-nick/setup-aftman@v0.4.2 - with: - cache: true - - - name: Format files - run: lune run format-files src - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Auto-format files" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..628456f --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,55 @@ +name: auto-format + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +on: + pull_request: + types: + - opened + - synchronize + +jobs: + perform-checks: + if: github.repository == github.event.pull_request.head.repo.full_name + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - uses: ok-nick/setup-aftman@v0.4.2 + with: + cache: true + + - name: Lint + run: selene src + + - name: Ensure tests exist + run: lune run ensure-tests src + + - name: Ensure version parity + run: lune run ensure-version-parity + + format: + needs: perform-checks + runs-on: ubuntu-latest + timeout-minutes: 10 + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - uses: ok-nick/setup-aftman@v0.4.2 + with: + cache: true + + - name: Format files + run: lune run format-files src + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Auto-format files" From c0c0519f1a4d9b5db6a342edffd202c7deeed7fb Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:38:45 +0000 Subject: [PATCH 33/43] Add foreground color logic in Crayon module --- lune/lib/_index/crayon/init.luau | 149 +++++++++++++++++-------------- 1 file changed, 81 insertions(+), 68 deletions(-) diff --git a/lune/lib/_index/crayon/init.luau b/lune/lib/_index/crayon/init.luau index d2f4f6f..fe9ca3a 100644 --- a/lune/lib/_index/crayon/init.luau +++ b/lune/lib/_index/crayon/init.luau @@ -4,91 +4,104 @@ local process = require("@lune/process") local env, args = process.env, process.args local isColorSupported = (function() - local isNoColor = env.NO_COLOR - or table.find(args, "--no-color") - or table.find(args, "--color=false") - local isForcedColor = env.FORCE_COLOR - or table.find(args, "--color") - or table.find(args, "--color=true") - local isWindows = process.os == "windows" - local isDumbTerminal = env.TERM == "dumb" + local isNoColor = env.NO_COLOR + or table.find(args, "--no-color") + or table.find(args, "--color=false") + local isForcedColor = env.FORCE_COLOR + or table.find(args, "--color") + or table.find(args, "--color=true") + local isWindows = process.os == "windows" + local isDumbTerminal = env.TERM == "dumb" - local isCompatible = env.TERM and env.TERM ~= "dumb" - local isCI = env.CI and (env.GITHUB_ACTIONS or env.GITLAB_CI or env.CIRCLECI) + local isCompatible = env.TERM and env.TERM ~= "dumb" + local isCI = env.CI and (env.GITHUB_ACTIONS or env.GITLAB_CI or env.CIRCLECI) - -- selene: allow(shadowing) - local isColorSupported = not isNoColor - and (isForcedColor or (isWindows and not isDumbTerminal) or isCompatible or isCI) + -- selene: allow(shadowing) + local isColorSupported = not isNoColor + and (isForcedColor or (isWindows and not isDumbTerminal) or isCompatible or isCI) - return isColorSupported + return isColorSupported end)() local function styler(codepoint: { number }) - local open, close = codepoint[1], codepoint[2] + local open, close = codepoint[1], codepoint[2] - return function(text: string) - if not isColorSupported then - return text - end + return function(text: string) + if not isColorSupported then + return text + end - return `\27[{open}m{text}\27[{close}m` - end + return `\27[{open}m{text}\27[{close}m` + end end local Crayon = { - -- Modifiers - reset = styler(ANSI_STYLES.MODIFIERS.RESET), - bold = styler(ANSI_STYLES.MODIFIERS.BOLD), - dim = styler(ANSI_STYLES.MODIFIERS.DIM), - italic = styler(ANSI_STYLES.MODIFIERS.ITALIC), - underline = styler(ANSI_STYLES.MODIFIERS.UNDERLINE), - overline = styler(ANSI_STYLES.MODIFIERS.OVERLINE), - inverse = styler(ANSI_STYLES.MODIFIERS.INVERSE), - hidden = styler(ANSI_STYLES.MODIFIERS.HIDDEN), - strikethrough = styler(ANSI_STYLES.MODIFIERS.STRIKETHROUGH), + -- Modifiers + reset = styler(ANSI_STYLES.MODIFIERS.RESET), + bold = styler(ANSI_STYLES.MODIFIERS.BOLD), + dim = styler(ANSI_STYLES.MODIFIERS.DIM), + italic = styler(ANSI_STYLES.MODIFIERS.ITALIC), + underline = styler(ANSI_STYLES.MODIFIERS.UNDERLINE), + overline = styler(ANSI_STYLES.MODIFIERS.OVERLINE), + inverse = styler(ANSI_STYLES.MODIFIERS.INVERSE), + hidden = styler(ANSI_STYLES.MODIFIERS.HIDDEN), + strikethrough = styler(ANSI_STYLES.MODIFIERS.STRIKETHROUGH), - -- Foreground colors - black = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK), - red = styler(ANSI_STYLES.FOREGROUND_COLORS.RED), - green = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN), - yellow = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW), - blue = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE), - magenta = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA), - cyan = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN), - white = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE), - grey = styler(ANSI_STYLES.FOREGROUND_COLORS.GREY), - blackBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK_BRIGHT), - redBright = styler(ANSI_STYLES.FOREGROUND_COLORS.RED_BRIGHT), - greenBright = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN_BRIGHT), - yellowBright = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW_BRIGHT), - blueBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE_BRIGHT), - magentaBright = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA_BRIGHT), - cyanBright = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN_BRIGHT), - whiteBright = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE_BRIGHT), + -- Foreground colors + black = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK), + red = styler(ANSI_STYLES.FOREGROUND_COLORS.RED), + green = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN), + yellow = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW), + blue = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE), + magenta = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA), + cyan = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN), + white = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE), + grey = styler(ANSI_STYLES.FOREGROUND_COLORS.GREY), + blackBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLACK_BRIGHT), + redBright = styler(ANSI_STYLES.FOREGROUND_COLORS.RED_BRIGHT), + greenBright = styler(ANSI_STYLES.FOREGROUND_COLORS.GREEN_BRIGHT), + yellowBright = styler(ANSI_STYLES.FOREGROUND_COLORS.YELLOW_BRIGHT), + blueBright = styler(ANSI_STYLES.FOREGROUND_COLORS.BLUE_BRIGHT), + magentaBright = styler(ANSI_STYLES.FOREGROUND_COLORS.MAGENTA_BRIGHT), + cyanBright = styler(ANSI_STYLES.FOREGROUND_COLORS.CYAN_BRIGHT), + whiteBright = styler(ANSI_STYLES.FOREGROUND_COLORS.WHITE_BRIGHT), - -- Background colors - bgBlack = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK), - bgRed = styler(ANSI_STYLES.BACKGROUND_COLORS.RED), - bgGreen = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN), - bgYellow = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW), - bgBlue = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE), - bgMagenta = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA), - bgCyan = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN), - bgWhite = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE), - bgGrey = styler(ANSI_STYLES.BACKGROUND_COLORS.GREY), - bgBlackBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK_BRIGHT), - bgRedBright = styler(ANSI_STYLES.BACKGROUND_COLORS.RED_BRIGHT), - bgGreenBright = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN_BRIGHT), - bgYellowBright = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW_BRIGHT), - bgBlueBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE_BRIGHT), - bgMagentaBright = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA_BRIGHT), - bgCyanBright = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN_BRIGHT), - bgWhiteBright = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE_BRIGHT), + -- Background colors + bgBlack = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK), + bgRed = styler(ANSI_STYLES.BACKGROUND_COLORS.RED), + bgGreen = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN), + bgYellow = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW), + bgBlue = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE), + bgMagenta = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA), + bgCyan = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN), + bgWhite = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE), + bgGrey = styler(ANSI_STYLES.BACKGROUND_COLORS.GREY), + bgBlackBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLACK_BRIGHT), + bgRedBright = styler(ANSI_STYLES.BACKGROUND_COLORS.RED_BRIGHT), + bgGreenBright = styler(ANSI_STYLES.BACKGROUND_COLORS.GREEN_BRIGHT), + bgYellowBright = styler(ANSI_STYLES.BACKGROUND_COLORS.YELLOW_BRIGHT), + bgBlueBright = styler(ANSI_STYLES.BACKGROUND_COLORS.BLUE_BRIGHT), + bgMagentaBright = styler(ANSI_STYLES.BACKGROUND_COLORS.MAGENTA_BRIGHT), + bgCyanBright = styler(ANSI_STYLES.BACKGROUND_COLORS.CYAN_BRIGHT), + bgWhiteBright = styler(ANSI_STYLES.BACKGROUND_COLORS.WHITE_BRIGHT), +} + +local LIGHT_BACKGROUNDS = { + Crayon.bgGrey, + Crayon.bgBlackBright, + Crayon.bgRedBright, + Crayon.bgGreenBright, + Crayon.bgYellowBright, + Crayon.bgBlueBright, + Crayon.bgMagentaBright, + Crayon.bgCyanBright, + Crayon.bgWhiteBright, } -- selene: allow(shadowing) function Crayon.label(text: string, styler: (string) -> string) - return styler(Crayon.bold(` {text:upper()} `)) + local foreground = table.find(LIGHT_BACKGROUNDS, styler) and Crayon.black or Crayon.white + return styler(Crayon.bold(foreground(` {text:upper()} `))) end return Crayon From 30f00583f7aa50d1efb3f9d362894c05c015a0ad Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:39:53 +0000 Subject: [PATCH 34/43] Update pull-request.yml workflow --- .github/workflows/pull-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 628456f..567fd4b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -26,12 +26,12 @@ jobs: - name: Lint run: selene src - - name: Ensure tests exist - run: lune run ensure-tests src - - name: Ensure version parity run: lune run ensure-version-parity + - name: Ensure tests exist + run: lune run ensure-tests src + format: needs: perform-checks runs-on: ubuntu-latest From 1e7e8d70ddbfcd8296d6f3f890da52620dbbf8f6 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:41:45 +0000 Subject: [PATCH 35/43] Update pull request workflow conditions --- .github/workflows/pull-request.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 567fd4b..8bc17a3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -12,7 +12,9 @@ on: jobs: perform-checks: - if: github.repository == github.event.pull_request.head.repo.full_name + if: | + github.repository == github.event.pull_request.head.repo.full_name + && github.event.pull_request.draft == false runs-on: ubuntu-latest timeout-minutes: 10 From c33e2fd3c7251aca3031a68a1212280405375746 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:43:06 +0000 Subject: [PATCH 36/43] Run pull-request workflow on all PR events --- .github/workflows/pull-request.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8bc17a3..f7e56f1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,11 +4,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true -on: - pull_request: - types: - - opened - - synchronize +on: pull_request jobs: perform-checks: From f43b9a078eb121fa88f4fb9650bb280241016a2d Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:44:28 +0000 Subject: [PATCH 37/43] Update pull_request.yml to trigger workflow on additional pull request events --- .github/workflows/pull-request.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f7e56f1..376dae2 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,7 +4,14 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true -on: pull_request +on: + pull_request: + types: + - opened + - reopened + - ready_for_review + - synchronize + - unlocked jobs: perform-checks: From 3d73df5cb76f188a7ce19afdc98903ef16ec57b6 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:05:36 +0000 Subject: [PATCH 38/43] Add version check in pull-request workflow --- .github/workflows/pull-request.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 376dae2..47c0354 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -37,6 +37,17 @@ jobs: - name: Ensure tests exist run: lune run ensure-tests src + - name: Fetch version from package.json + id: current-version + run: jq -r '.version' package.json >> $GITHUB_ENV + + - name: Get previous release version + id: previous-version + run: git describe --tags --abbrev=0 >> $GITHUB_ENV + + - name: Ensure version has changed + run: ${{ steps.current-version.outputs.current-version != steps.previous-version.outputs.previous-version }} + format: needs: perform-checks runs-on: ubuntu-latest From 352db487e1db02f95465de2686e7b9ecce8f68b1 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:06:16 +0000 Subject: [PATCH 39/43] Move version check up --- .github/workflows/pull-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 47c0354..35cfe86 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -34,9 +34,6 @@ jobs: - name: Ensure version parity run: lune run ensure-version-parity - - name: Ensure tests exist - run: lune run ensure-tests src - - name: Fetch version from package.json id: current-version run: jq -r '.version' package.json >> $GITHUB_ENV @@ -48,6 +45,9 @@ jobs: - name: Ensure version has changed run: ${{ steps.current-version.outputs.current-version != steps.previous-version.outputs.previous-version }} + - name: Ensure tests exist + run: lune run ensure-tests src + format: needs: perform-checks runs-on: ubuntu-latest From b533be655fb7c50b64df0d72c35400c418e2196a Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:09:03 +0000 Subject: [PATCH 40/43] Update version retrieval in pull-request.yml --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 35cfe86..2cc9b25 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -36,11 +36,11 @@ jobs: - name: Fetch version from package.json id: current-version - run: jq -r '.version' package.json >> $GITHUB_ENV + run: echo "current-version=$(jq -r .version package.json)" >> $GITHUB_ENV - name: Get previous release version id: previous-version - run: git describe --tags --abbrev=0 >> $GITHUB_ENV + run: echo "previous-version=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - name: Ensure version has changed run: ${{ steps.current-version.outputs.current-version != steps.previous-version.outputs.previous-version }} From 961c890ab5ed59ac6bad97c9ead30ab66bcd86fb Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:14:01 +0000 Subject: [PATCH 41/43] Refactor version check in pull-request.yml --- .github/workflows/pull-request.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2cc9b25..9262e5b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -34,16 +34,15 @@ jobs: - name: Ensure version parity run: lune run ensure-version-parity - - name: Fetch version from package.json - id: current-version - run: echo "current-version=$(jq -r .version package.json)" >> $GITHUB_ENV - - - name: Get previous release version - id: previous-version - run: echo "previous-version=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - - name: Ensure version has changed - run: ${{ steps.current-version.outputs.current-version != steps.previous-version.outputs.previous-version }} + run: | + current_version=$(jq -r .version package.json) + previous_version=$(git show origin/main:package.json | jq -r .version) + + if [ "$current_version" == "$previous_version" ]; then + echo "Version has not changed" + exit 1 + fi - name: Ensure tests exist run: lune run ensure-tests src From 36e979d41331d063670d725b96886a3dbf3eaf09 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:19:17 +0000 Subject: [PATCH 42/43] Update pull-request.yml workflow to use check-version action --- .github/workflows/pull-request.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9262e5b..aa1e963 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -34,15 +34,7 @@ jobs: - name: Ensure version parity run: lune run ensure-version-parity - - name: Ensure version has changed - run: | - current_version=$(jq -r .version package.json) - previous_version=$(git show origin/main:package.json | jq -r .version) - - if [ "$current_version" == "$previous_version" ]; then - echo "Version has not changed" - exit 1 - fi + - uses: kriasoft/check-version@v1 - name: Ensure tests exist run: lune run ensure-tests src From 3fce30b2af59cbd986ebd432e7c25615dcadaff3 Mon Sep 17 00:00:00 2001 From: Cam <21029087+cxmeel@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:07:41 +0000 Subject: [PATCH 43/43] Create darklua configs --- .github/workflows/docs.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .gitignore | 1 + standalone.darklua.json | 21 +++++++++++++++++++++ wally.darklua.json | 20 ++++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 standalone.darklua.json create mode 100644 wally.darklua.json diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 36ffcd1..981f857 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Deploy Docs +name: deploy-docs on: workflow_dispatch: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index aa1e963..fc004ec 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,4 +1,4 @@ -name: auto-format +name: pull-request concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} diff --git a/.gitignore b/.gitignore index 77b402b..08fa77c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ sourcemap.json /out /include /build +/dist diff --git a/standalone.darklua.json b/standalone.darklua.json new file mode 100644 index 0000000..43beeb0 --- /dev/null +++ b/standalone.darklua.json @@ -0,0 +1,21 @@ +{ + "bundle": { + "require_mode": { + "name": "path", + "sources": { + "@Pkg": "Packages", + "@DevPkg": "DevPackages", + "@Sift": "src" + } + } + }, + "rules": [ + "compute_expression", + "filter_after_early_return", + "remove_empty_do", + "remove_nil_declaration", + "remove_unused_if_branch", + "remove_unused_while" + ], + "generator": "dense" +} diff --git a/wally.darklua.json b/wally.darklua.json new file mode 100644 index 0000000..2d9473a --- /dev/null +++ b/wally.darklua.json @@ -0,0 +1,20 @@ +{ + "process": [ + { + "rule": "convert_require", + "current": { + "name": "path", + "sources": { + "@Pkg": "Packages", + "@DevPkg": "DevPackages", + "@Sift": "src" + } + }, + "target": { + "name": "roblox", + "rojo_sourcemap": "./sourcemap.json", + "indexing_style": "wait_for_child" + } + } + ] +}