web-threads
generic threads using web workers for the web
Last updated 3 days ago by kanekotic .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install web-threads 
SYNC missed versions from official npm registry.

logomakr_09u4zz

Build Status codecov npm GitHub license Maintenance Donate

generic threads using web workers for the web

Installation

add it to your project using npm install web-threads --save or yarn add web-threads

Usage

Simple function with arguments

import { execute } from 'web-threads'

let func = (value) => {
    return value * value
}
let params = {
    fn: func.toString(),
    args: [2]
} 
execute(params)
    .then(console.log)
    .catch(console.error)

Function with context

import { execute } from 'web-threads'

function Func(value){
    this.value = value
}
Func.prototype.foo = function(){
    return this.value * this.value
};
var instance = new Func(2)
let params = {
    fn: instance.foo,
    context: instance
} 
execute(params)
    .then(console.log)
    .catch(console.error)

Function with context and arguments

import { execute } from 'web-threads'

function Func(value){
    this.value = value
}
Func.prototype.foo = function(otherValue){
    return this.value * otherValue
};
var instance = new Func(2)
let params = {
    fn: instance.foo,
    context: instance,
    args: [4]
} 
execute(params)
    .then(console.log)
    .catch(console.error)

ES6 class call function with arguments

import { execute } from 'web-threads'

class someClass {
    constructor(val){
        this.val = val
    }
    foo(some){
        return this.val * some
    }
}

var instance = new someClass(2)
let params = {
    fn: instance.foo,
    context: instance,
    args: [4]
} 
execute(params)
    .then(console.log)
    .catch(console.error)

Inspired in:

Web graphic by picol from Flaticon is licensed under CC BY 3.0. Check out the new logo that I created on LogoMakr.com https://logomakr.com/09u4Zz

Current Tags

  • 1.0.59                                ...           latest (3 days ago)

63 Versions

  • 1.0.59                                ...           3 days ago
  • 1.0.58                                ...           10 days ago
  • 1.0.57                                ...           17 days ago
  • 1.0.56                                ...           24 days ago
  • 1.0.55                                ...           a month ago
  • 1.0.54                                ...           a month ago
  • 1.0.53                                ...           a month ago
  • 1.0.52                                ...           2 months ago
  • 1.0.51                                ...           2 months ago
  • 1.0.50                                ...           2 months ago
  • 1.0.49                                ...           2 months ago
  • 1.0.48                                ...           3 months ago
  • 1.0.47                                ...           3 months ago
  • 1.0.46                                ...           3 months ago
  • 1.0.45                                ...           3 months ago
  • 1.0.44                                ...           4 months ago
  • 1.0.43                                ...           4 months ago
  • 1.0.42                                ...           4 months ago
  • 1.0.41                                ...           4 months ago
  • 1.0.40                                ...           4 months ago
  • 1.0.39                                ...           5 months ago
  • 1.0.38                                ...           5 months ago
  • 1.0.37                                ...           5 months ago
  • 1.0.36                                ...           5 months ago
  • 1.0.35                                ...           6 months ago
  • 1.0.34                                ...           6 months ago
  • 1.0.33                                ...           6 months ago
  • 1.0.32                                ...           6 months ago
  • 1.0.31                                ...           6 months ago
  • 1.0.30                                ...           7 months ago
  • 1.0.29                                ...           7 months ago
  • 1.0.28                                ...           7 months ago
  • 1.0.27                                ...           7 months ago
  • 1.0.26                                ...           8 months ago
  • 1.0.25                                ...           8 months ago
  • 1.0.24                                ...           8 months ago
  • 1.0.23                                ...           8 months ago
  • 1.0.22                                ...           10 months ago
  • 1.0.21                                ...           10 months ago
  • 1.0.20                                ...           10 months ago
  • 1.0.19                                ...           a year ago
  • 1.0.18                                ...           a year ago
  • 1.0.17                                ...           a year ago
  • 1.0.16                                ...           a year ago
  • 1.0.15                                ...           a year ago
  • 1.0.14                                ...           a year ago
  • 1.0.13                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.2.0                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 45
Last Day 2
Last Week 12
Last Month 186
Dependencies (0)
None
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |