Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: refactor whitespace check in createWorklet function #146

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cpp/WKTJsiWorklet.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ class JsiWorklet : public JsiHostObject,
}
}

/**
Returns true if the character is a whitespace character
*/
static bool isWhitespace(unsigned char c) {
return std::isspace(c);
}

private:
/**
Installs the worklet function into the worklet runtime
Expand Down Expand Up @@ -303,7 +310,7 @@ class JsiWorklet : public JsiHostObject,
}

// Double-check if the code property is valid.
bool isCodeEmpty = std::all_of(_code.begin(), _code.end(), std::isspace);
bool isCodeEmpty = std::all_of(_code.begin(), _code.end(), isWhitespace);
if (isCodeEmpty) {
std::string error = "Failed to create Worklet, the provided code is empty. Tips:\n"
"* Is the babel plugin correctly installed?\n"
Expand Down
Loading