{"id":17891354,"url":"https://github.com/alvarolorentedev/web-threads","last_synced_at":"2025-03-22T20:33:05.941Z","repository":{"id":38272785,"uuid":"146128444","full_name":"alvarolorentedev/web-threads","owner":"alvarolorentedev","description":"generic threads using web workers for the web","archived":false,"fork":false,"pushed_at":"2024-03-16T01:36:44.000Z","size":1288,"stargazers_count":11,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-14T04:35:22.137Z","etag":null,"topics":["hacktoberfest","multithreading","parallel","promise","ui","webworker","webworkers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/alvarolorentedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["kanekotic"],"custom":["https://www.paypal.me/kanekotic/"]}},"created_at":"2018-08-25T20:44:53.000Z","updated_at":"2023-10-20T10:43:02.000Z","dependencies_parsed_at":"2024-01-27T09:06:41.140Z","dependency_job_id":"7808aa21-57a0-409d-bf98-fa9c42e88bb2","html_url":"https://github.com/alvarolorentedev/web-threads","commit_stats":null,"previous_names":["alvarolorentedev/web-threads","kanekotic/web-threads"],"tags_count":139,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fweb-threads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fweb-threads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fweb-threads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fweb-threads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alvarolorentedev","download_url":"https://codeload.github.com/alvarolorentedev/web-threads/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221839142,"owners_count":16889590,"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":["hacktoberfest","multithreading","parallel","promise","ui","webworker","webworkers"],"created_at":"2024-10-28T14:16:44.407Z","updated_at":"2024-10-28T14:16:45.244Z","avatar_url":"https://github.com/alvarolorentedev.png","language":"JavaScript","funding_links":["https://github.com/sponsors/kanekotic","https://www.paypal.me/kanekotic/"],"categories":[],"sub_categories":[],"readme":"# ![logomakr_09u4zz](https://user-images.githubusercontent.com/3071208/44622482-88a91a80-a8b9-11e8-976c-fdd422ac5c98.png)\n[![Build Status](https://travis-ci.org/kanekotic/web-threads.svg?branch=master)](https://travis-ci.org/kanekotic/web-threads)\n[![codecov](https://codecov.io/gh/kanekotic/web-threads/branch/master/graph/badge.svg)](https://codecov.io/gh/kanekotic/web-threads)\n[![npm](https://img.shields.io/npm/dt/web-threads.svg)](https://github.com/kanekotic/web-threads)\n[![GitHub license](https://img.shields.io/github/license/kanekotic/web-threads.svg)](https://github.com/kanekotic/web-threads/blob/master/LICENSE)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/kanekotic/web-threads/graphs/commit-activity)\n\ngeneric threads using web workers for the web\n\n## Installation\n\nadd it to your project using `npm install web-threads --save` or `yarn add web-threads`\n\n## Usage\n\n### Simple function with arguments\n\n```js\nimport { execute } from 'web-threads'\n\nlet func = (value) =\u003e {\n    return value * value\n}\nlet params = {\n    fn: func.toString(),\n    args: [2]\n} \nexecute(params)\n    .then(console.log)\n    .catch(console.error)\n```\n\n### Function with context\n\n```js\nimport { execute } from 'web-threads'\n\nfunction Func(value){\n    this.value = value\n}\nFunc.prototype.foo = function(){\n    return this.value * this.value\n};\nvar instance = new Func(2)\nlet params = {\n    fn: instance.foo,\n    context: instance\n} \nexecute(params)\n    .then(console.log)\n    .catch(console.error)\n```\n\n### Function with context and arguments\n\n```js\nimport { execute } from 'web-threads'\n\nfunction Func(value){\n    this.value = value\n}\nFunc.prototype.foo = function(otherValue){\n    return this.value * otherValue\n};\nvar instance = new Func(2)\nlet params = {\n    fn: instance.foo,\n    context: instance,\n    args: [4]\n} \nexecute(params)\n    .then(console.log)\n    .catch(console.error)\n```\n\n### ES6 class call function with arguments\n\n```js\nimport { execute } from 'web-threads'\n\nclass someClass {\n    constructor(val){\n        this.val = val\n    }\n    foo(some){\n        return this.val * some\n    }\n}\n\nvar instance = new someClass(2)\nlet params = {\n    fn: instance.foo,\n    context: instance,\n    args: [4]\n} \nexecute(params)\n    .then(console.log)\n    .catch(console.error)\n```\n#### Inspired in:\n - [work done pairing with @kmruiz for ui.wind.js](https://github.com/CodeInBrackets/ui.wind.js)\n - [scottlogic.com post](https://blog.scottlogic.com/2011/02/24/web-workers-part-3-creating-a-generic-worker.html)\n - [@vkiryukhin](http://www.eslinstructor.net/vkthread/)\n\n \n##### Web graphic by \u003ca href=\"http://www.flaticon.com/authors/picol\"\u003epicol\u003c/a\u003e from \u003ca href=\"http://www.flaticon.com/\"\u003eFlaticon\u003c/a\u003e is licensed under \u003ca href=\"http://creativecommons.org/licenses/by/3.0/\" title=\"Creative Commons BY 3.0\"\u003eCC BY 3.0\u003c/a\u003e. Check out the new logo that I created on \u003ca href=\"http://logomakr.com\" title=\"Logo Makr\"\u003eLogoMakr.com\u003c/a\u003e https://logomakr.com/09u4Zz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarolorentedev%2Fweb-threads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvarolorentedev%2Fweb-threads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarolorentedev%2Fweb-threads/lists"}