Comparing version 1.0.1 to 1.0.3
@@ -121,3 +121,3 @@ const { | ||
complete(err) { | ||
(--this.context.nLife) === 0 && super.complete(err) | ||
if (err || (--this.context.nLife) === 0) super.complete(err) | ||
} | ||
@@ -124,0 +124,0 @@ } |
48
index.js
@@ -100,11 +100,41 @@ const { | ||
//该代理可以实现将pipe模式转成链式编程 | ||
const rxProxy = { | ||
get: (target, prop) => target[prop] || ((...args) => new Proxy(exports[prop](...args)(target), rxProxy)) | ||
if(Proxy){ | ||
//该代理可以实现将pipe模式转成链式编程 | ||
const rxProxy = { | ||
get: (target, prop) => target[prop] || ((...args) => new Proxy(exports[prop](...args)(target), rxProxy)) | ||
} | ||
exports.rx = new Proxy(f => new Proxy(f, rxProxy), { | ||
get: (target, prop) => (...args) => new Proxy(exports[prop](...args), rxProxy), | ||
set: (target, prop, value) => exports[prop] = value | ||
}) | ||
} | ||
exports.rx = new Proxy(f => new Proxy(f, rxProxy), { | ||
get: (target, prop) => (...args) => new Proxy(exports[prop](...args), rxProxy), | ||
set: (target, prop, value) => exports[prop] = value | ||
}) | ||
else{ | ||
const keys = Object.keys(exports).filter(key=>{ | ||
switch(key){ | ||
case 'Sink': | ||
case 'pipe': | ||
case 'reusePipe': | ||
return false | ||
default: return true | ||
} | ||
}) | ||
function setProps(t){ | ||
keys.forEach(key=>{ | ||
Object.defineProperty(t,key,{ | ||
get(){ | ||
return (...args) =>setProps(exports[key](...args)(t)) | ||
} | ||
}) | ||
}) | ||
return t | ||
} | ||
const rx = f => setProps(f) | ||
keys.forEach(key=>{ | ||
Object.defineProperty(rx,key,{ | ||
get(){ | ||
return (...args) =>setProps(exports[key](...args)) | ||
} | ||
}) | ||
}) | ||
exports.rx = rx | ||
} |
{ | ||
"name": "fastrx", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "fast rxjs implemention", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -100,3 +100,3 @@ const { | ||
exports.bindNodeCallback = (call, thisArg, ...args) => sink => { | ||
const inArgs = args.concat((err, ...rargs) => (err && sink.complete(err)) || (sink.next(rargs.length > 1 ? rargs : rargs[0]), sink.complete())); | ||
const inArgs = args.concat((err, ...rargs) => err ? sink.complete(err) : (sink.next(rargs.length > 1 ? rargs : rargs[0]), sink.complete())); | ||
call.apply ? call.apply(thisArg, inArgs) : call(...inArgs) | ||
@@ -103,0 +103,0 @@ } |
35088
1074