{"id":17775157,"url":"https://github.com/daehyeonmun2021/react-native-worklet-functions","last_synced_at":"2025-09-09T07:42:56.487Z","repository":{"id":195539161,"uuid":"693121023","full_name":"daehyeonmun2021/react-native-worklet-functions","owner":"daehyeonmun2021","description":"Util functions available on UI thread in React Native","archived":false,"fork":false,"pushed_at":"2024-06-29T08:31:22.000Z","size":193,"stargazers_count":27,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T16:55:53.818Z","etag":null,"topics":["reactnative","reanimated"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daehyeonmun2021.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-18T11:48:42.000Z","updated_at":"2025-02-08T02:38:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"0859318e-a0a2-4e6a-9a78-dfa7d3b9c719","html_url":"https://github.com/daehyeonmun2021/react-native-worklet-functions","commit_stats":null,"previous_names":["daehyeonmun2021/react-native-worklet-functions"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daehyeonmun2021%2Freact-native-worklet-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daehyeonmun2021%2Freact-native-worklet-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daehyeonmun2021%2Freact-native-worklet-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daehyeonmun2021%2Freact-native-worklet-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daehyeonmun2021","download_url":"https://codeload.github.com/daehyeonmun2021/react-native-worklet-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250150657,"owners_count":21383207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["reactnative","reanimated"],"created_at":"2024-10-26T21:54:53.685Z","updated_at":"2025-04-21T23:31:12.037Z","avatar_url":"https://github.com/daehyeonmun2021.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-worklet-functions\n\nUtil functions available on both JS and UI thread in React Native\n\n## Installation\n\nInstall the library using yarn:\n\n```sh\nyarn add react-native-worklet-functions\n```\n\nOr using npm:\n\n```sh\nnpm install react-native-worklet-functions\n```\n\n## Motivation\n\nOne of the keys to make smooth animations in React Native is to run animation logic on UI thread. \u003cbr/\u003e\nBut when you make animation with utils like lodash, you have to make them \"workletized function\" to run them on UI thread. \u003cbr/\u003e\nWith this library, you can use useful util functions on UI thread directly.\n\n## Usage\n\nUse workletized util on UI thread.\n\n```TypeScript\nimport { random } from 'react-native-worklet-functions';\n\nconst tap = Gesture.Tap()\n  .onEnd(() =\u003e {\n    // You can use util functions on UI thread like below.\n    width.value = withTiming(random(100, 300));\n    height.value = withTiming(random(100, 300));\n  });\n```\n\n### Methods\n\n#### String\n\n| Name                     | Description                      |\n| ------------------------ | -------------------------------- |\n| `camelCase(str:string)`  | Converts a string to camel case  |\n| `snakeCase(str:string)`  | Converts a string to snake case  |\n| `kebabCase(str:string)`  | Converts a string to kebab case  |\n| `pascalCase(str:string)` | Converts a string to Pascal case |\n\n#### Color\n\n| Name                                           | Description                                                                                    |\n| ---------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| `rgb(r:number, g:number, b:number)`            | Converts the given RGB values to a CSS RGB string.                                             |\n| `rgba(r:number, g:number, b:number, a:number)` | Returns the RGBA color value as a string.                                                      |\n| `hslToRgb(h:number, s:number, l:number)`       | Converts HSL (Hue, Saturation, Lightness) color values to RGB (Red, Green, Blue) color values. |\n| `hexToRgb(hex:string)`                         | Converts a hexadecimal color code to an RGB color array.                                       |\n| `hexToHsl(hex:string)`                         | Converts a hexadecimal color code to HSL (Hue, Saturation, Lightness) format.                  |\n\n#### Util\n\n| Name                                                 | Description                                                                                                              |\n| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |\n| `array1d(length: number)`                            | Creates a one-dimensional array of the specified length. The elements of the array are the numbers from 0 to length - 1. |\n| `chunk(arr: T[], size: number)`                      | Divide array into chunks of size                                                                                         |\n| `clamp(value: number, lower: number, upper: number)` | Clamp a number between lower and upper limits                                                                            |\n| `concat(...args: any[][])`                           | Concatenate multiple arrays                                                                                              |\n| `count(arr: any[])`                                  | Get the length of the array                                                                                              |\n| `debounce(func: T, wait = 0)`                        | Debounce function calls                                                                                                  |\n| `find(arr: T[], predicate: (v: T) =\u003e boolean)`       | Find first element that satisfies the predicate                                                                          |\n| `findIndex(arr: T[], predicate: (v: T) =\u003e boolean)`  | Find index of the first element that satisfies the predicate                                                             |\n| `groupBy(arr: Array\u003cT\u003e, iteratee: (v: T) =\u003e any)`    | Group elements in array based on iteratee                                                                                |\n| `head(arr: T[])`                                     | Get the first element of an array                                                                                        |\n| `isEmpty(arr: any[])`                                | Check if array is empty                                                                                                  |\n| `isEqual(a: any, b: any)`                            | Check if two values are equal                                                                                            |\n| `isNil(value: T)`                                    | Check if value is null or undefined                                                                                      |\n| `isNull(value: any)`                                 | Check if value is null                                                                                                   |\n| `isUndefined(value: any)`                            | Check if value is undefined                                                                                              |\n| `keys(obj: T)`                                       | Get keys of an object                                                                                                    |\n| `nth(arr: T[], index: number)`                       | Get the nth element of an array                                                                                          |\n| `random(min: number, max: number)`                   | Generate a random number between min and max                                                                             |\n| `range(start: number, end: number, step = 1)`        | Generate an array of numbers between start and end, stepping by step                                                     |\n| `sample(arr: T[])`                                   | Pick a random element from an array                                                                                      |\n| `sampleSize(arr: T[], n: number)`                    | Pick n random elements from an array                                                                                     |\n| `shuffle(arr: T[])`                                  | Shuffle an array                                                                                                         |\n| `tail(arr: T[])`                                     | Get the last element of an array                                                                                         |\n| `take(arr: T[], n: number)`                          | Take first n elements of an array                                                                                        |\n| `throttle(func: T, wait = 0)`                        | Throttle function calls                                                                                                  |\n| `times(n: number, iteratee: (index: number) =\u003e T)`   | Repeat an action n times and collect results                                                                             |\n| `values(obj: T)`                                     | Get values of an object                                                                                                  |\n| `without(arr: T[], ...values: T[])`                  | Remove specified values from an array                                                                                    |\n| `zip(arr1: T[], arr2: U[])`                          | Zip two arrays together                                                                                                  |\n| `zipObject(props: T[], values: U[])`                 | Create an object from arrays of keys and values                                                                          |\n\n#### Math\n\n| Name                                                   | Description                                                                      |\n| ------------------------------------------------------ | -------------------------------------------------------------------------------- |\n| `abs(value: number)`                                   | Return the absolute value of the number                                          |\n| `acos(value: number)`                                  | Calculates the arccosine of a number in radians                                  |\n| `add(a: number, b: number)`                            | Add a, b                                                                         |\n| `asin(value: number)`                                  | Calculates the arcsine of a number in radians                                    |\n| `atan(value: number)`                                  | Calculates the arctangent of a number in radians                                 |\n| `atan2(y: number, x: number)`                          | Calculates the arctangent of the quotient of its arguments (y, x) in radians     |\n| `between(value: number, lower: number, upper: number)` | Check if the value is between lower and upper, inclusive                         |\n| `ceil(value: number, precision = 0)`                   | Round the value up to the nearest integer or to the specified decimal places     |\n| `cos(radian: number)`                                  | Calculates the cosine of a given angle in radians                                |\n| `divide(a: number, b: number)`                         | Divide a, b                                                                      |\n| `floor(value: number, precision = 0)`                  | Round the value down to the nearest integer or to the specified decimal places   |\n| `max(...args: number[])`                               | Return the largest number among the arguments                                    |\n| `median(...args: number[])`                            | Return the median of an array of numbers                                         |\n| `min(...args: number[])`                               | Return the smallest number among the arguments                                   |\n| `multiply(a: number, b: number)`                       | Multiply a, b                                                                    |\n| `round(value: number, precision = 0)`                  | Round the value to the nearest integer or to the specified decimal places        |\n| `sin(radian: number)`                                  | Calculates the sine of a given angle in radians                                  |\n| `sqrt(value: number)`                                  | Return the square root of the number                                             |\n| `subtract(a: number, b: number)`                       | Subtract a, b                                                                    |\n| `tan(radian: number)`                                  | Calculates the tangent of a given angle in radians                               |\n| `toDeg(rad: number)`                                   | Convert radians to degrees                                                       |\n| `toRad(deg: number)`                                   | Convert degrees to radians                                                       |\n| `isOdd(v: number)`                                     | Checks if a number is odd. Returns true if the number is odd, false otherwise.   |\n| `isEven(v: number)`                                    | Checks if a number is even. Returns true if the number is even, false otherwise. |\n\n#### Vector\n\n| Name                                                  | Description                                 |\n| ----------------------------------------------------- | ------------------------------------------- |\n| `vec(x: number, y?: number)`                          | Create a vector                             |\n| `vector.add(v1: Vector, v2: Vector \\| number)`        | Add two vectors or add a scalar to a vector |\n| `vector.subtract(v1: Vector, v2: Vector \\| number)`   | Subtract a vector or scalar from a vector   |\n| `vector.divide(v1: Vector, v2: Vector \\| number)`     | Divide a vector or scalar by a vector       |\n| `vector.multiply(v1: Vector, v2: Vector \\| number)`   | Multiply a vector or scalar by a vector     |\n| `vector.distance(v1: Vector, v2: Vector)`             | Calculate distance between two vectors      |\n| `vector.angleBetween(v1: Vector, v2: Vector)`         | Calculate angle between two vectors         |\n| `vector.normalize(v: Vector)`                         | Normalize a vector                          |\n| `vector.dot(v1: Vector, v2: Vector)`                  | Dot product of two vectors                  |\n| `vector.cross(v1: Vector, v2: Vector)`                | Cross product of two vectors                |\n| `vector.magnitude(v: Vector)`                         | Calculate the magnitude of a vector         |\n| `vector.rotate(v: Vector, radian: number)`            | Rotate a vector by a given radian           |\n| `vector.lerp(v1: Vector, v2: Vector, amount: number)` | Linearly interpolate between two vectors    |\n| `vector.clone(v: Vector)`                             | Clone a vector                              |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaehyeonmun2021%2Freact-native-worklet-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaehyeonmun2021%2Freact-native-worklet-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaehyeonmun2021%2Freact-native-worklet-functions/lists"}