Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra function suggestions. #110

Open
Designer023 opened this issue Aug 9, 2023 · 1 comment
Open

Extra function suggestions. #110

Designer023 opened this issue Aug 9, 2023 · 1 comment

Comments

@Designer023
Copy link

Hey 👋

I would like to suggest some functions to add to the GROQ queries if possible. I would love to add them myself, but not sure how or where to start. I have managed to create one by chaining the existing functions, but for the others I require functions that don't exists.

My suggestions are:

// truncate a string to N chars
string::truncate(string, number)
// Extra rounding functions
math::floor(number)
math::ceil(number)
// Convert/coherse string into a number - Not sure how to implement to float or int (Maybe a flag)
number(string)
// or:
number::int(string)
number::float(string)

Currently I am truncating a string with array::join(string::split((pt::text(body)), "")[0..255], "") which is not ideal 😬

@Designer023
Copy link
Author

Designer023 commented Aug 12, 2023

For reference to create a floor() I am using string::split(string(myNumber), ".")[0] which works, but returns a string, not a number. I can't make a ceil() alternative because I need the result of the floor as a number so that I can add 1 to the resulting value. I'm open to any suggestions or ideas to get around this 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant