@filemonger/main
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -5,1 +5,2 @@ import { Filemonger, IDict, Transform } from "@filemonger/types"; | ||
export declare function makeFilemonger<Opts extends IDict<any>>(transform: Transform<Opts>): Filemonger<Opts>; | ||
export declare const passthrumonger: Filemonger<{}>; |
@@ -7,5 +7,5 @@ "use strict"; | ||
const rxjs_1 = require("rxjs"); | ||
const { f, tmp, symlinkFile, filesInDir } = helpers; | ||
function makeFilemonger(transform) { | ||
const { f, tmp, symlinkFile, filesInDir } = helpers; | ||
return (patternOrFileStream = "**/*", opts = {}) => { | ||
return (patternOrFileStream = "**/*.*", opts = {}) => { | ||
const unit = (srcDir, destDir) => { | ||
@@ -17,3 +17,3 @@ const resolvedSrcDir = f.dir(f.abs(path_1.resolve(process.cwd(), srcDir))); | ||
: patternOrFileStream; | ||
return rxjs_1.Observable.defer(() => transform(file$, resolvedSrcDir, finalDestDir, opts)); | ||
return transform(file$, resolvedSrcDir, finalDestDir, opts); | ||
}; | ||
@@ -33,10 +33,8 @@ const run = (srcDir, destDir, complete) => { | ||
}; | ||
const bind = fn => { | ||
const bindingmonger = makeFilemonger((_, srcDir, destDir) => tmp(tmpDir => fn(unit(srcDir, tmpDir)).unit(tmpDir, destDir))); | ||
const bind = mongerFactory => { | ||
const bindingmonger = makeFilemonger((_, srcDir, destDir) => tmp(tmpDir => mongerFactory(unit(srcDir, tmpDir)).unit(tmpDir, destDir))); | ||
return bindingmonger(); | ||
}; | ||
const bypass = (predicate, fn) => { | ||
const inversePredicate = x => !predicate(x); | ||
const passthrumonger = makeFilemonger((file$, srcDir, destDir) => file$.delayWhen(file => symlinkFile(f.fullPath(f.abs(path_1.join(srcDir, file))), f.fullPath(f.abs(path_1.join(destDir, file)))))); | ||
return multicast(f$ => fn(f$.filter(predicate)), f$ => passthrumonger(f$.filter(inversePredicate))); | ||
return multicast(f$ => fn(f$.filter(predicate)), f$ => exports.passthrumonger(f$.filter(f => !predicate(f)))); | ||
}; | ||
@@ -66,1 +64,2 @@ const merge = (...others) => { | ||
exports.makeFilemonger = makeFilemonger; | ||
exports.passthrumonger = makeFilemonger((file$, srcDir, destDir) => file$.delayWhen(file => symlinkFile(f.fullPath(f.abs(path_1.join(srcDir, file))), f.fullPath(f.abs(path_1.join(destDir, file)))))); |
{ | ||
"name": "@filemonger/main", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Process files with streams", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
11104