Name: puglify
Owner: Formidable
Description: ? a multithreaded wrapper around `uglify`
Created: 2017-04-26 20:22:39.0
Updated: 2017-11-11 21:13:16.0
Pushed: 2017-11-10 07:41:29.0
Size: 229
Language: C++
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
puglify
is a multithreaded wrapper around uglify
. It speeds up batch
minification of many small modules.
puglify
stands for:
Start a Puglifier
instance:
t puglifier = new Puglifier({
Optional. Number of threads to utilize. Defaults to `os.cpus().length`.
readCount: os.cpus().length
Then, use either the Promise or Observable interfaces:
romise interface, single code string
ifier
inify({
code: 'var pug = "lify"; function puglify() { return true; }'
hen(batch => console.log(batch))
atch(err => console.error(err))
If you're not running `puglify` frequently, feel free to
terminate the instance. Persisting it eliminates subsequent startup
times, which is useful for interactive applications.
hen(() => puglifier.terminate());
romise interface, multiple code strings
ifier
inify({
code: {
// Keys don't have to be valid filenames. They're just useful
// for identifying which code strings get emitted from `next()`
// when subscribing to an observable.
'one.js': 'var pug = "lify"; function puglify() { return true; }',
'two.js': 'var two = 1 + 1; function add(a, b) { return a + b; }'
}
bservable interface, single code string
ifier
inifyWithObservable({
code: 'var pug = "lify"; function puglify() { return true; }'
ubscribe({
next: code => {
console.log(code);
},
error: err => {
console.error(error)
},
complete: () => puglifier.terminate();
romise interface, multiple code strings
ifier
inifyWithObservable({
code: {
// Keys don't have to be valid filenames. They're just useful
// for identifying which code strings get emitted from `next()`
// when subscribing to an observable.
'one.js': 'var pug = "lify"; functwion puglify() { return true; }',
'two.js': 'var two = 1 + 1; function add(a, b) { return a + b; }'
}
For each code string, the result type looks like:
We return Buffers so we can pass code off easily to gzip
de: Buffer,
ror: string
Multi-string results are just an object with names as keys and code/error objects as values.
puglify
is wildly unstable! Use at your own risk until 1.0.0.