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 object from string variable in a browser

latest
Source
npmnpm
Version
1.3.5
Version published
Maintainers
1
Created
Source

@lopatnov/worker-from-string Twitter

String value to Worker object converter.

NPM version License GitHub issues GitHub forks GitHub stars GitHub top language

Patreon LinkedIn sobe.ru

npm

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="https://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

TypeScript

import workerFromString from 'worker-from-string';

JavaScript (npm package)

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

JavaScript (browser)

var workerFromString = window.workerFromString;

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

Worker Code Editor Demo: https://lopatnov.github.io/worker-from-string/

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

Rights and Agreements

License Apache-2.0

Copyright 2019-2020 Oleksandr Lopatnov

Keywords

TypeScript

FAQs

Package last updated on 09 Jul 2021

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