Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-transforms

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-transforms - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

lib/internal-worker.js

16

package.json
{
"name": "async-transforms",
"version": "1.0.0",
"version": "1.0.1",
"description": "Asynchronous stream transforms",
"type": "module",
"module": "./transforms.js",
"main": "./dist/transforms.cjs",
"module": "./lib/transforms.js",
"main": "./require/transforms.cjs",
"exports": {
"import": "./transforms.js",
"default": "./dist/transforms.cjs"
"import": "./lib/transforms.js",
"require": "./require/transforms.cjs",
"./worker": {
"import": "./lib/worker.js",
"require": "./require/worker.cjs"
}
},

@@ -21,5 +25,5 @@ "repository": "https://github.com/samthor/async-transforms",

"scripts": {
"prepare": "rollup --format=cjs --file=dist/transforms.cjs -- transforms.js",
"prepare": "bash build.sh",
"test": "mocha"
}
}

@@ -66,2 +66,32 @@ [![Build](https://api.travis-ci.org/samthor/async-transforms.svg?branch=master)](https://travis-ci.org/samthor/async-transforms)

While Gulp plugins for Less already exist, this makes it easier to write general-purpose, modern plugins with `async` and `await` syntax.
While Gulp plugins for Less already exist, this makes it easier to write general-purpose, modern plugins with `async` and `await` syntax.
## Worker Pool
This includes a submodule which provides a worker pool.
It's useful when combined with the above transforms handler.
For example:
```js
import {pool} from 'async-transforms/worker';
const compilationPool = pool(path.resolve('./compile.js'));
// use directly
compilationPool(123, {tasks: 2})
.then((result) => console.info('result from passing value to worker', result));
// or as part of a transform
stream.Readable.from([object1, object2])
.pipe(transforms.map(compilationPool))
.pipe(transforms.map(() => {
// do something with the result
}));
```
The pool invokes the default export (or `module.exports` for CJS) of the target file.
By default, it utilizes 75% of your local CPUs, but set `tasks` to control this—use a fraction from 0-1 to set a ratio, and higher for absolute.
Use this for CPU-bound tasks like JS minification.
This doesn't really belong in this module.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc