Razen Documentation

Learn how to use the Razen Programming Language.

Libraries Tokens

# Libraries Tokens Let me introduce you to the in-built libraries of razens and there names ## Libraries ### Array Library - `arrlib` These are the Array Library Functions - `push` -> Push a value to the end of an array - `pop` -> Pop a value from the end of an array - `join` -> Join array elements with a separator - `length` -> Get the length of an array - `unique` -> Get unique elements from an array Check out the Examples of the `arrlib` **[here](/examples/libs/arrlib.mdx)** ### String library - `strlib` These are the String Library Functions - `upper` -> Convert a string to uppercase - `lower` -> Convert a string to lowercase - `substring` -> Get a substring from a string - `replace` -> Replace occurrences of a substring in a string - `length` -> Get the length of a string - `split` -> Split a string by a delimiter - `trim` -> Trim whitespace from a string - `starts_with` -> Check if a string starts with a prefix - `ends_with` -> Check if a string ends with a suffix - `contains` -> Check if a string contains a substring - `repeat` -> Repeat a string multiple times Check out the Examples of the `strlib` **[here](/examples/libs/strlib.mdx)** ### Math library - `mathlib` These are the Math Library Functions - `add` -> Add two numbers - `subtrack` -> Subtract two numbers - `multiply` -> Multiply two numbers - `divide` -> Divide two numbers - `power` -> Raise a number to a power - `sqrt` -> Calculate the square root of a number - `abs` -> Calculate the absolute value of a number - `round` -> Round a number to the nearest integer - `floor` -> Round a number down to the nearest integer - `ceil` -> Round a number up to the nearest integer - `sin` -> Calculate the sine of an angle (in radians) - `cos` -> Calculate the cosine of an angle (in radians) - `tan` -> Calculate the tangent of an angle (in radians) - `log` -> Calculate the logarithm of a number with a given base - `exp` -> Calculate e raised to the power of a number - `random` -> Generate a random number between 0 and 1 - `max` -> Find the maximum value among a list of numbers - `min` -> Find the minimum value among a list of numbers - `modulo` -> Calculate the modulo (remainder) of a division Check out the Examples of the `mathlib` **[here](/examples/libs/mathlib.mdx)** ### Time Library - `timelib` These are the Time Library Functions - `now` -> Get the current timestamp - `format` -> Format a timestamp according to a format string - `parse` -> Parse a date string into a timestamp - `add` -> Add a duration to a timestamp - `year` -> Get the year from a timestamp - `month` -> Get the month from a timestamp (1-12) - `day` -> Get the day of the month from a timestamp (1-31) Check out the Examples of the `timelib` **[here](/examples/libs/timelib.mdx)** ### Date Library - `date` These are the Date Library Functions - `now` -> Get the current timestamp in seconds since the Unix epoch - `year` -> Get the current year - `month` -> Get the current month (1-12) - `day` -> Get the current day of month - `format` -> Format a timestamp as a string - `parse` -> Parse a date string with a format - `add_days` -> Add days to a timestamp - `add_months` -> Add months to a timestamp - `add_years` -> Add years to a timestamp - `weekday` -> Get the day of week (0 = Sunday, 6 = Saturday) - `weekday_name` -> Get the name of the weekday - `days_in_month` -> Get the number of days in a month - `is_leap_year` -> Check if a year is a leap year - `diff_days` -> Get the difference in days between two dates Check out the Examples of the `date` **[here](/examples/libs/date.mdx)** ### Random Library - `random` These are the Random Library Functions - `int` -> Generate a random integer between min and max (inclusive) - `float` -> Generate a random float between min and max (inclusive) - `choise` -> Choose a random element from an array - `shuffle` -> Shuffle an array Check out the Examples of the `random` **[here](/examples/libs/random.mdx)** ### File System Library - `filesystem` These are the File System Library Functions - `exists` -> Checks if a path exists - `is_file` -> Checks if a path is a file - `is_dir` -> Checks if a path is a directory - `create_dir` -> Creates a new directory - `remove` -> Removes a file or directory - `read_file` -> Reads the contents of a file - `write_file` -> Writes content to a file - `list_dir` -> Lists the contents of a directory - `metadata` -> Gets file/directory metadata - `absolute_path` -> Gets the absolute path of a file or directory - `copy_file` -> Copies a file or directory - `copy_dir_all` -> Recursively copies a directory - `move_file` -> Moves a file or directory - `extension` -> Gets the file extension - `file_stem` -> Gets the file name without extension - `parent_dir` -> Gets the parent directory - `join_path` -> Joins path components - `change_dir` -> Changes the current working directory - `current_dir` -> Gets the current working directory - `temp_file` -> Creates a temporary file - `temp_dir` -> Creates a temporary directory Check out the Examples of the `filesystem` **[here](/examples/libs/filesystem.mdx)** ### JSON Library - `json` These are the JSON Library Functions - `parse` -> Parse a JSON string into a Razen value - `stringify` -> Convert a Razen value to a JSON string Check out the Examples of the `json` **[here](/examples/libs/json.mdx)** ### Bolt Library - `bolt` These are the Bolt Library Functions - `run` -> Run a task with a given name - `parallel` -> Run multiple tasks in parallel - `threads` -> Run a task with true parallelism using threads Check out the Examples of the `bolt` **[here](/examples/libs/bolt.mdx)** ### Seed Library - `seed` These are the Seed Library Functions - `generate` -> Generate a random seed string of a given length - `map_seed` -> Create a 2D map from a seed string - `noise_map` -> Generate a noise map using Perlin noise - `name` -> Generate a random name based on a seed Check out the Examples of the `seed` **[here](/examples/libs/seed.mdx)** ### Syscall library for system operations - `systemlib` These are the System Library Functions - `getpid` -> Get the current process ID - `getcwd` -> Get the current working directory - `execute` -> Execute a system command - `getenv` -> Get an environment variable - `setenv` -> Set an environment variable - `environ` -> Get all environment variables - `args` -> Get command line arguments - `path_exists` -> Check if a path exists - `realpath` -> Get the absolute path - `exit` -> Exit the program with a status code - `sleep` -> Sleep for a specified Int of milliseconds - `hostname` -> Get the hostname of the system - `username` -> Get the username of the current user Check out the Examples of the `systemlib` **[here](/examples/libs/systemlib.mdx)** ### Process library for process management - `processlib` These are the Process Library Functions - `create` -> Create a new process - `wait` -> Wait for a process to complete - `is_running` -> Check if a process is running - `kill` -> Kill a process - `signal` -> Send a signal to a process - `info` -> Get information about a process - `read_stdout` -> Read the standard output of a process - `read_stderr` -> Read the standard error of a process - `write_stdin` -> Write to the standard input of a process Check out the Examples of the `processlib` **[here](/examples/libs/processlib.mdx)** ### Color Library - `color` These are the Color Library Functions - `hex_to_rgb` -> Converts a hex color string to RGB array - `rgb_to_hex` -> Converts an RGB array to a hex color string - `lighten` -> Lightens a hex color by a percentage - `darken` -> Darkens a hex color by a percentage - `get_ansi_color` -> Get ANSI color code for terminal output Check out the Examples of the `color` **[here](/examples/libs/color.mdx)** ### Crypto Library - `crypto` These are the Crypto Library Functions - `hash` -> Hashes a string using SHA-256 - `encrypt` -> Encrypts a string with a key using AES-256-GCM - `decrypt` -> Decrypts a string with a key using AES-256-GCM Check out the Examples of the `crypto` **[here](/examples/libs/crypto.mdx)** ### Regex Library - `regex` These are the Regex Library Functions - `match` -> Checks if a pattern matches a string - `search` -> Searches for a pattern in a string and returns the first match - `replace` -> Replaces all occurrences of a pattern in a string Check out the Examples of the `regex` **[here](/examples/libs/regex.mdx)** ### UUID Library - `uuid` These are the UUID Library Functions - `generate` -> Generates a new UUID string - `parse` -> Parses a UUID string and returns its components - `is_valid` -> Checks if a string is a valid UUID Check out the Examples of the `uuid` **[here](/examples/libs/uuid.mdx)** ### OS Library - `os` These are the OS Library Functions - `platform` -> Gets the platform name (e.g., "linux", "windows") Check out the Examples of the `os` **[here](/examples/libs/os.mdx)** ### Validation Library - `validation` These are the Validation Library Functions - `email` -> Validates if a string is a valid email - `phone` -> Validates if a string is a valid phone number - `required` -> Checks if a value is not null or empty - `min_length` -> Checks if a string has at least the minimum length Check out the Examples of the `validation` **[here](/examples/libs/validation.mdx)** ### System Library - `system` (Remaining Functions from `systemlib`) These are the System Library Functions - `uptime` -> Returns system uptime in seconds - `info` -> Returns system information Check out the Examples of the `system` **[here](/examples/libs/system.mdx)** ### Box Util Library - `boxlib` These are the Box Util Library Functions - `put` -> Stores a value in a box and returns a boxed representation. - `get` -> Returns the value stored in the box. - `is_box` -> Check if a value is a box Check out the Examples of the `boxlib` **[here](/examples/libs/boxlib.mdx)** ### Log Library - `loglib` These are the Log Library Functions - `info` -> Logs an info message - `warn` -> Logs a warning message - `error` -> Logs an error message - `debug` -> Logs a debug message Check out the Examples of the `loglib` **[here](/examples/libs/loglib.mdx)** ### HT (Head/Tails) Library - `htlib` These are the HT Library Functions - `coin` -> Flips a coin, returns "head" or "tail" - `bool_tos` -> Returns true or false randomly Check out the Examples of the `htlib` **[here](/examples/libs/htlib.mdx)** ### Audio Library - `audio` (Expremental Library) These are the Audio Library Functions - `play` -> Plays an audio file - `pause` -> Pauses the current audio playback - `stop` -> Stops the current audio playback - `record` -> Starts recording audio Check out the Examples of the `audio` **[here](/examples/libs/audio.mdx)** ### Image Library - `image` (Expremental Library) These are the Image Library Functions - `load` -> Loads an image from a file - `save` -> Saves an image to a file - `resize` -> Resizes an image to the specified dimensions - `crop` -> Crops an image to the specified region Check out the Examples of the `image` **[here](/examples/libs/image.mdx)** ### Network Library - `netlib` These are the Network Library Functions - `ping` -> Ping a host to check connectivity Check out the Examples of the `netlib` **[here](/examples/libs/netlib.mdx)** ### API Library - `apilib` (Expremental Library) These are the API Library Functions - `get` -> Make a GET request to an API endpoint - `post` -> Make a POST request to an API endpoint - `putmethod` -> Make a PUT request to an API endpoint - `delete` -> Make a DELETE request to an API endpoint - `patch` -> Make a PATCH request to an API endpoint - `call` -> Call an API with the given options - `parse_json` -> Parse a JSON string into a Razen Value - `to_json` -> Convert a Razen Value to a JSON string - `create_api` -> Create an API configuration with authentication - `execute_api` -> Execute an API call with the given API configuration - `url_encode` -> URL encode a string - `url_decode` -> URL decode a string - `form_data` -> Create form data from a map or array - `is_success` -> Check if a status code indicates success (2xx) - `is_client_error` -> Check if a status code indicates client error (4xx) - `is_server_error` -> Check if a status code indicates server error (5xx) Check out the Examples of the `apilib` **[here](/examples/libs/apilib.mdx)** ## Next Steps Now that you've know all Libraries and there functions in Razen Programming Language, you're ready to learn more about the language. Check out the **[Variables & Datatypes Usage](/docs/language-basics/variables_datatypes.mdx)** guide to continue your journey!