feat: Add data type wrappers
Resolves #75 Resolves #77
Looks OK to me. I'd probably group them by type instead of alphabetically. Might want to add aliases to the Signed* functions without the "Signed" (ie. Int, BigInt, etc).
Does the spread operator work when the value is a string instead of an object? If not, I think the functions should all return objects.
Spread operator does work on strings but not in the way we want. It essentially will split each character in the string with a space:
function SignedBigInt() {
return '20i0';
}
console.log('Signed Big Int:', ...SignedBigInt()) // Signed Big Int: 2 0 i 0
I agree we should return an object with type key set to the return value.
I think we also should we add checks to enforce length parameter was passed for
- Char
- Varchar
- LongVarchar
As is if no length is provided to these functions we end up something like this:
> const { Varchar } = require('itoolkit');
> console.log({...itoolkit.Varchar()})
{ type: 'undefineda', varying: '2' }
Check could be something like ...
function Varchar(length) {
if (!length) { throw TypeError('Must provide valid length for Varchar'); }
return { type: `${length}a`, varying: '2' };
}
> const { Varchar } = require('itoolkit');
> console.log({...itoolkit.Varchar()})
Uncaught TypeError: Must provide length for Varchar
Alternatively we could have a default length or no-op when no length is passed.
:wave: Hi! This pull request has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed.