Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@lopatnov/worker-from-string

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lopatnov/worker-from-string

Creates worker from string variable in a browser

Source
npmnpm
Version
1.3.2
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

@lopatnov/worker-from-string

NPM version License Twitter

String value to worker converter

Install

https://nodei.co/npm/@lopatnov/worker-from-string.png?downloads=true&downloadRank=true&stars=true

npm install @lopatnov/worker-from-string

Browser

<script src="//lopatnov.github.io/worker-from-string/dist/worker-from-string.min.js"></script>

Bower

bower install worker-from-string --save

Import package to the project

import workerFromString from 'worker-from-string';

or

var workerFromString = require("worker-from-string")

Convert String values into Worker

workerFromString(...textValues: string[]) => Worker

Example

  var workerString = "self.onmessage = function onmessage(e){ postMessage('Hello ' + e.data); }";

  var worker = workerFromString(workerString);

  worker.onmessage = function(e) {
      console.log(e.data); // expected 'Hello world' from worker after worker.postMessage('world')
  };

  worker.postMessage('world');

Demo

QUnit tests: https://lopatnov.github.io/worker-from-string/test/index.html

Rights and Agreements

License Apache-2.0

Copyright 2019 Oleksandr Lopatnov

Keywords

TypeScript

FAQs

Package last updated on 07 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts