From 2f3913894a480cdecc741bfe81ea8e794cdda93f Mon Sep 17 00:00:00 2001 From: osyrisrblx Date: Sat, 3 Feb 2024 23:58:55 -0500 Subject: [PATCH 1/2] Add t.buffer, t.vector --- lib/init.lua | 18 ++++++++++++++++++ lib/t.d.ts | 4 ++++ lib/ts.lua | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/lib/init.lua b/lib/init.lua index 2953c3a..d68ccc8 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -50,6 +50,15 @@ end **--]] t.boolean = t.typeof("boolean") +--[[** + ensures Lua primitive buffer type + + @param value The value to check against + + @returns True iff the condition is satisfied, false otherwise +**--]] +t.buffer = t.typeof("buffer") + --[[** ensures Lua primitive thread type @@ -106,6 +115,15 @@ t.table = t.typeof("table") **--]] t.userdata = t.type("userdata") +--[[** + ensures Lua primitive vector type + + @param value The value to check against + + @returns True iff the condition is satisfied, false otherwise +**--]] +t.vector = t.typeof("vector") + --[[** ensures value is a number and non-NaN diff --git a/lib/t.d.ts b/lib/t.d.ts index f9f46df..97fdd3c 100644 --- a/lib/t.d.ts +++ b/lib/t.d.ts @@ -12,6 +12,8 @@ interface t { any: t.check; /** checks to see if `value` is a boolean */ boolean: t.check; + /** checks to see if `value` is a buffer */ + buffer: t.check; /** checks to see if `value` is a thread */ thread: t.check; /** checks to see if `value` is a function */ @@ -32,6 +34,8 @@ interface t { table: t.check; /** checks to see if `value` is a userdata */ userdata: t.check; + /** checks to see if `value` is a vector (Vector3 in Roblox) */ + vector: t.check; // roblox types /** checks to see if `value` is an Axes */ diff --git a/lib/ts.lua b/lib/ts.lua index fb594a3..d2eebd2 100644 --- a/lib/ts.lua +++ b/lib/ts.lua @@ -50,6 +50,15 @@ end **--]] t.boolean = t.typeof("boolean") +--[[** + ensures Lua primitive buffer type + + @param value The value to check against + + @returns True iff the condition is satisfied, false otherwise +**--]] +t.buffer = t.typeof("buffer") + --[[** ensures Lua primitive thread type @@ -106,6 +115,15 @@ t.table = t.typeof("table") **--]] t.userdata = t.type("userdata") +--[[** + ensures Lua primitive vector type + + @param value The value to check against + + @returns True iff the condition is satisfied, false otherwise +**--]] +t.vector = t.typeof("vector") + --[[** ensures value is a number and non-NaN From 7ddc273c417b16ddd6d6a49c88816b0dca0c3465 Mon Sep 17 00:00:00 2001 From: osyrisrblx Date: Sun, 4 Feb 2024 00:03:20 -0500 Subject: [PATCH 2/2] `t.vector` should use `t.type()` --- lib/init.lua | 2 +- lib/ts.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index d68ccc8..63bb787 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -122,7 +122,7 @@ t.userdata = t.type("userdata") @returns True iff the condition is satisfied, false otherwise **--]] -t.vector = t.typeof("vector") +t.vector = t.type("vector") --[[** ensures value is a number and non-NaN diff --git a/lib/ts.lua b/lib/ts.lua index d2eebd2..cb66d1b 100644 --- a/lib/ts.lua +++ b/lib/ts.lua @@ -122,7 +122,7 @@ t.userdata = t.type("userdata") @returns True iff the condition is satisfied, false otherwise **--]] -t.vector = t.typeof("vector") +t.vector = t.type("vector") --[[** ensures value is a number and non-NaN