New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

arch-stream

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arch-stream - npm Package Compare versions

Comparing version 0.0.25 to 0.0.26

src/lib/array.js

128

dist/arch-stream.js

@@ -1,2 +0,2 @@

/*! arch-stream v0.0.25 | (c) 2015, falsandtru | MIT Licence */
/*! arch-stream v0.0.26 | (c) 2015, falsandtru | MIT Licence */
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

@@ -14,2 +14,12 @@ 'use strict';

'use strict';
function clone(arr) {
var arr2 = [];
for (var i = 0; i < arr.length; ++i) {
arr2[i] = arr[i];
}
return arr2;
}
exports.clone = clone;
},{}],4:[function(_dereq_,module,exports){
'use strict';
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {

@@ -146,3 +156,3 @@ if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')

}
},{"../decorator":1,"../lib/thenable":7,"./tick":9}],4:[function(_dereq_,module,exports){
},{"../decorator":1,"../lib/thenable":8,"./tick":10}],5:[function(_dereq_,module,exports){
'use strict';

@@ -154,4 +164,5 @@ function noop() {

exports.default = noop;
},{}],5:[function(_dereq_,module,exports){
},{}],6:[function(_dereq_,module,exports){
'use strict';
var Array_ = _dereq_('./array');
var Observable = function () {

@@ -168,15 +179,15 @@ function Observable() {

case 1: {
return this.namespace_(map, types.shift());
return namespace(map, types.shift());
}
default: {
return this.seek_(this.namespace_(map, types.shift()).map, types);
return this.seek_(namespace(map, types.shift()).map, types);
}
}
function namespace(map, type) {
return map[type] && map[type].map ? map[type] : map[type] = {
map: Object.create(null),
list: []
};
}
};
Observable.prototype.namespace_ = function (map, type) {
return map[type] && map[type].map ? map[type] : map[type] = {
map: Object.create(null),
list: []
};
};
Observable.prototype.on = function (type, listener) {

@@ -225,15 +236,14 @@ void this.seek_(this.map_, type.toString().split(this.separator_)).list.push(listener);

};
Observable.prototype.collect_ = function (_a) {
var _this = this;
var map = _a.map, list = _a.list;
return Object.keys(map).reduce(function (list, type) {
void list.unshift.apply(list, _this.collect_(map[type]));
return list;
}, list.slice());
};
Observable.prototype.emit = function (type, data) {
void this.collect_(this.seek_(this.map_, type.toString().split(this.separator_))).reduce(function (_, listener) {
void collect(this.seek_(this.map_, type.toString().split(this.separator_))).reduce(function (_, listener) {
return listener(data);
}, void 0);
return this;
function collect(_a) {
var map = _a.map, list = _a.list;
return Object.keys(map).reduce(function (list, type) {
void list.unshift.apply(list, collect(map[type]));
return list;
}, Array_.clone(list));
}
};

@@ -244,3 +254,3 @@ return Observable;

exports.default = Observable;
},{}],6:[function(_dereq_,module,exports){
},{"./array":3}],7:[function(_dereq_,module,exports){
'use strict';

@@ -256,3 +266,3 @@ var case_1 = _dereq_('../proxy/case');

};
},{"../proxy/case":10,"../proxy/hook":11,"../proxy/responsibility":12}],7:[function(_dereq_,module,exports){
},{"../proxy/case":11,"../proxy/hook":12,"../proxy/responsibility":13}],8:[function(_dereq_,module,exports){
'use strict';

@@ -263,3 +273,3 @@ function isThenable(target) {

exports.isThenable = isThenable;
},{}],8:[function(_dereq_,module,exports){
},{}],9:[function(_dereq_,module,exports){
'use strict';

@@ -323,3 +333,3 @@ var Throttle = function () {

exports.default = Throttle;
},{}],9:[function(_dereq_,module,exports){
},{}],10:[function(_dereq_,module,exports){
'use strict';

@@ -370,3 +380,3 @@ var Tick;

exports.default = IS_NODE ? Function('return fn => process.nextTick(fn)')() : Tick.queue;
},{}],10:[function(_dereq_,module,exports){
},{}],11:[function(_dereq_,module,exports){
'use strict';

@@ -396,3 +406,3 @@ function default_1(index, indexer) {

exports.default = default_1;
},{}],11:[function(_dereq_,module,exports){
},{}],12:[function(_dereq_,module,exports){
'use strict';

@@ -421,3 +431,3 @@ var noop_1 = _dereq_('../lib/noop');

exports.default = default_1;
},{"../lib/noop":4}],12:[function(_dereq_,module,exports){
},{"../lib/noop":5}],13:[function(_dereq_,module,exports){
'use strict';

@@ -456,3 +466,3 @@ function default_1() {

exports.default = default_1;
},{}],13:[function(_dereq_,module,exports){
},{}],14:[function(_dereq_,module,exports){
'use strict';

@@ -514,3 +524,3 @@ var modular_1 = _dereq_('./modular');

exports.default = ComposeStream;
},{"./modular":14}],14:[function(_dereq_,module,exports){
},{"./modular":15}],15:[function(_dereq_,module,exports){
'use strict';

@@ -638,3 +648,3 @@ var __decorate = this && this.__decorate || function (decorators, target, key, desc) {

exports.default = ModularStream;
},{"../decorator":1,"../lib/noop":4,"../lib/throttle":8,"../lib/tick":9}],15:[function(_dereq_,module,exports){
},{"../decorator":1,"../lib/noop":5,"../lib/throttle":9,"../lib/tick":10}],16:[function(_dereq_,module,exports){
'use strict';

@@ -668,28 +678,2 @@ var message_1 = _dereq_('../lib/message');

};
ArchStream.prototype.proxy_ = function (method, args) {
var params = this.proxies_.filter(function (proxy) {
return typeof proxy[method] === 'function';
}).reduce(function (args, proxy) {
return toArray(proxy[method].apply(void 0, args) || args);
}, args);
var base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(this, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return (_a = ArchStream.prototype[method]).call.apply(_a, [this.proxy_(base, params)].concat(args));
}
default: {
return this.proxy_(base, params);
}
}
function toArray(target) {
return Array.isArray(target) ? target : [target];
}
var _a;
};
ArchStream.prototype.proxy = function (gen) {

@@ -709,6 +693,32 @@ var _this = this;

}
return _this.proxy_(method, args);
return compose(_this, method, args);
};
}, void 0);
return this;
function compose(self, method, args) {
var params = self.proxies_.filter(function (proxy) {
return typeof proxy[method] === 'function';
}).reduce(function (args, proxy) {
return toArray(proxy[method].apply(void 0, args) || args);
}, args);
var base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(self, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return (_a = ArchStream.prototype[method]).call.apply(_a, [compose(self, base, params)].concat(args));
}
default: {
return compose(self, base, params);
}
}
function toArray(target) {
return Array.isArray(target) ? target : [target];
}
var _a;
}
};

@@ -719,3 +729,3 @@ return ArchStream;

exports.default = ArchStream;
},{"../lib/message":3,"./compose":13,"./modular":14}],"arch-stream":[function(_dereq_,module,exports){
},{"../lib/message":4,"./compose":14,"./modular":15}],"arch-stream":[function(_dereq_,module,exports){
'use strict';

@@ -752,3 +762,3 @@ var transform_1 = _dereq_('./stream/transform');

exports.Msg = Msg;
},{"./lib/message":3,"./lib/observable":5,"./lib/proxy":6,"./lib/tick":9,"./stream/transform":15}]},{},[1,2,"arch-stream",3,4,5,6,7,8,9,10,11,12,13,14,15]);
},{"./lib/message":4,"./lib/observable":6,"./lib/proxy":7,"./lib/tick":10,"./stream/transform":16}]},{},[1,2,"arch-stream",3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
typeof module === "object" && module && "exports" in module && (module.exports = require("arch-stream"));

@@ -1,2 +0,2 @@

/*! arch-stream v0.0.25 | (c) 2015, falsandtru | MIT Licence */
require=function t(e,r,o){function n(u,s){if(!r[u]){if(!e[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var p=r[u]={exports:{}};e[u][0].call(p.exports,function(t){var r=e[u][1][t];return n(r?r:t)},p,p.exports,t,e,r,o)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)n(o[u]);return n}({1:[function(t,e,r){"use strict";var o=t("./decorator/bind");r.bind=o.bind},{"./decorator/bind":2}],2:[function(t,e,r){"use strict";function o(t,e,r){t[e]=t[e].bind(t)}r.bind=o},{}],3:[function(t,e,r){"use strict";function o(t){return t}var n=this&&this.__decorate||function(t,e,r,o){if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)return Reflect.decorate(t,e,r,o);switch(arguments.length){case 2:return t.reduceRight(function(t,e){return e&&e(t)||t},e);case 3:return t.reduceRight(function(t,o){return void(o&&o(e,r))},void 0);case 4:return t.reduceRight(function(t,o){return o&&o(e,r,t)||t},o)}},i=t("../decorator"),u=t("../lib/thenable"),s=t("./tick"),c=Object.create(null),a=function(){function t(t,e){void 0===e&&(e=o),this.parent=t,this.listener=e,this.memory_=c,this.collection_=[],this.listeners_=[],t&&(this.parent.child_=this)}return t.prototype.root=function(){return this.parent?this.parent.root():this},t.prototype.collect_=function(){if(this.collection_.length>0)return this.collection_;var t=this,e=[];do void e.push(t);while(t=t.child_);return this.collection_=e},t.prototype.transport_=function(t,e){function r(e){return e.every(function(e){e.memory_=t;var r=e.listener(t);return u.isThenable(r)?(n=e,s=!1,void r.then(o,o),s):!0})}function o(){s=!0,i&&n.child_&&void n.child_.send(t,e)}var n,i=!1,s=!1,c=r(this.collect_());i=!0,c&&"function"==typeof e&&void e(t)},t.prototype.clone=function(){function e(r){return r.parent?new t(e(r.parent),r.listener):new t(void 0,r.listener)}return e(this)},t.prototype.connect=function(t){return this.parent.child_=t,t.parent=this.parent,this},t.prototype.send=function(t,e,r){switch(!0){case"function"==typeof e:return this.send(t,!1,e);case!e:return void this.transport_(t,r),this;default:return void s["default"](this.transport_.bind(this,t,r)),this}},t.prototype.recv=function(e){return this.listener=e,this.collection_=[],this.memory_!==c&&void this.send(this.memory_),new t(this)},t.prototype.then=function(t,e){function r(t){if(0!==o.length)for(s["default"](r.bind(this,t));o.length>0;)o.shift()(t)}var o=this.listeners_;return o.push(t),this.recv(r)},Object.defineProperty(t.prototype,"send",n([i.bind],t.prototype,"send",Object.getOwnPropertyDescriptor(t.prototype,"send"))),Object.defineProperty(t.prototype,"recv",n([i.bind],t.prototype,"recv",Object.getOwnPropertyDescriptor(t.prototype,"recv"))),t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=a},{"../decorator":1,"../lib/thenable":7,"./tick":9}],4:[function(t,e,r){"use strict";function o(){}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],5:[function(t,e,r){"use strict";var o=function(){function t(){this.separator_=".",this.map_=Object.create(null)}return t.prototype.seek_=function(t,e){switch(e.length){case 0:throw new Error("ArchStream: Observable: Cannot use empty string for event type and namespace.");case 1:return this.namespace_(t,e.shift());default:return this.seek_(this.namespace_(t,e.shift()).map,e)}},t.prototype.namespace_=function(t,e){return t[e]&&t[e].map?t[e]:t[e]={map:Object.create(null),list:[]}},t.prototype.on=function(t,e){return void this.seek_(this.map_,t.toString().split(this.separator_)).list.push(e),this},t.prototype.off=function(t,e){switch(typeof e){case"function":var r=this.seek_(this.map_,t.toString().split(this.separator_)).list,o=r.indexOf(e);switch(o){case-1:break;case 0:void r.shift();break;default:void r.splice(o,1)}return this;case"undefined":var n=this.seek_(this.map_,t.toString().split(this.separator_));return n.map=Object.create(null),n.list=[],this;default:throw new TypeError("ArchStream: Observable: Invalid type argument: "+e)}},t.prototype.once=function(t,e){var r=this,o=function(n){void r.off(t,o),void e(n)};return void this.on(t,o),this},t.prototype.collect_=function(t){var e=this,r=t.map,o=t.list;return Object.keys(r).reduce(function(t,o){return void t.unshift.apply(t,e.collect_(r[o])),t},o.slice())},t.prototype.emit=function(t,e){return void this.collect_(this.seek_(this.map_,t.toString().split(this.separator_))).reduce(function(t,r){return r(e)},void 0),this},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],6:[function(t,e,r){"use strict";var o=t("../proxy/case"),n=t("../proxy/hook"),i=t("../proxy/responsibility");Object.defineProperty(r,"__esModule",{value:!0}),r["default"]={Case:o["default"],Hook:n["default"],Responsibility:i["default"]}},{"../proxy/case":10,"../proxy/hook":11,"../proxy/responsibility":12}],7:[function(t,e,r){"use strict";function o(t){return!!t&&"object"==typeof t&&!!t.then}r.isThenable=o},{}],8:[function(t,e,r){"use strict";var o=function(){function t(){this.queue_=[],this.processing_=[],this.limit_=1/0,this.volume_=1/0}return t.prototype.isDrainable_=function(){return this.processing_.length<this.volume_},t.prototype.discharger_=function(t,e){},t.prototype.flow=function(t,e,r){void 0===e&&(e=1/0),void 0===r&&(r=function(){return null}),this.volume_=t,this.limit_=e,this.discharger_=r},t.prototype.enqueue=function(t){if(this.isDrainable_())return void this.processing_.push(t),void this.resolver_(t),!0;this.queue_.push(t);do void this.discharger_(this.queue_,this.processing_);while(this.processing_.length+this.queue_.length>this.limit_);return!1},t.prototype.dequeue=function(t){var e=this.processing_.indexOf(t);e>0?void this.processing_.splice(e,1):void this.processing_.shift(),this.queue_.length>0&&this.isDrainable_()&&void this.enqueue(this.queue_.shift())},t.prototype.register=function(t){this.resolver_=t},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],9:[function(t,e,r){"use strict";var o;!function(t){function e(t){void n.push(t),void o()}function r(){void--i,void o();for(var t=n.length;t-- >0;)void n.shift()()}function o(){if(0!==n.length)if(u)for(;2>i;)void Promise.resolve().then(r),void++i;else for(;i<s.length;)void setTimeout(r,s[i%s.length]),void++i}t.queue=e;var n=[],i=0,u="function"==typeof Promise,s=[0,4,10,20,25].reverse()}(o||(o={}));var n=Function("return typeof process === 'object' && typeof window !== 'object'")();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n?Function("return fn => process.nextTick(fn)")():o.queue},{}],10:[function(t,e,r){"use strict";function o(t,e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r-0]=arguments[r];return function(r){var n=+o[e(r)+""];n>-1&&n<t.length&&t[n](r)}}var o=Object.create(null);return void t.reduce(function(t,e,r){return o[e+""]=r},void 0),function(t){return{pipe:r}}}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],11:[function(t,e,r){"use strict";function o(t){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return t.map(function(t){return function(e){o(e),t(e),u(e)}})}var r=t.pre,o=void 0===r?n["default"]:r,i=t.post,u=void 0===i?n["default"]:i;return function(t){return{pipe:e}}}var n=t("../lib/noop");Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{"../lib/noop":4}],12:[function(t,e,r){"use strict";function o(){function t(t,r){e.pipe=function(){for(var e=[],o=0;o<arguments.length;o++)e[o-0]=arguments[o];return e.map(function(e){return function(o){if(!(r(o)instanceof t))throw TypeError("ArchStream: ResponsibilityProxy: Uncovered internal entity: "+r(o).constructor);e(o)}})},e["export"]=function(){return function(e){r(e)instanceof t&&void Object.freeze(r(e))}}}var e;return function(r){return e={rule:t}}}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],13:[function(t,e,r){"use strict";var o=t("./modular"),n=function(){function t(t){this.extract_=t,this.procs_=[],this.branched_=0}return t.prototype.register=function(t){var e=this.procs_.length;return void t.reduceRight(function(t,r,o){return t[o+e]=r,t},this.procs_),this},t.prototype["import"]=function(e,r){var o=this;return void this.throwErrorIfNotImportable_(e,r),r&&(e=(new t)["import"](e)["export"]().wrap(function(t,e){return o.extract_(t)instanceof r?e(t):0})),void--e.count,e.count<0&&void e.throwCountExceededError(),void this.register(e.procs),this},t.prototype["export"]=function(t){return new o["default"](this.procs_,t,this.branched_)},t.prototype.throwErrorIfNotImportable_=function(t,e){e?((t.branched>0||this.branched_>1)&&(void--t.count,void this.throwConditionalImportError()),this.branched_=1):(t.branched>0&&this.branched_>0&&(void--t.count,void this.throwConditionalImportError()),this.branched_=t.branched>0?t.branched+1:t.branched)},t.prototype.throwConditionalImportError=function(){throw new Error("ArchStream: Conditional import cannot call from different streams.")},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n},{"./modular":14}],14:[function(t,e,r){"use strict";var o=this&&this.__decorate||function(t,e,r,o){if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)return Reflect.decorate(t,e,r,o);switch(arguments.length){case 2:return t.reduceRight(function(t,e){return e&&e(t)||t},e);case 3:return t.reduceRight(function(t,o){return void(o&&o(e,r))},void 0);case 4:return t.reduceRight(function(t,o){return o&&o(e,r,t)||t},o)}},n=t("../decorator"),i=t("../lib/throttle"),u=t("../lib/tick"),s=t("../lib/noop"),c=function(){function t(t,e,r){var o=this;void 0===e&&(e=1),this.procs=t,this.count=e,this.branched=r,void u["default"](function(t){return 0<o.count&&o.count<1/0&&o.throwCountDeprivedError()})}return t.prototype.compose_=function(){this.last_=this.procs.map(function(t){return t.clone()}).reduce(function(t,e){return t.connect(e.root())&&e}),this.first_=this.last_.root()},t.prototype.wrap=function(t){function e(e){return function(r){return t(r,e)}}void this.compose_();var r=this.last_;do r=r.parent,r.listener=e(r.listener);while(r.parent);return this.procs=[this.last_],this},t.prototype.read_=function(t){void--this.count,this.count<0&&void this.throwCountExceededError(),void this.compose_(),void this.last_.recv(t)},t.prototype.read=function(t){var e=this;void 0===t&&(t=s["default"]);var r=!1;return void this.read_(function(o){e.flow_&&void u["default"](function(){return void e.flow_.dequeue(o)}),r&&void t(o)}),r=!0,this},t.prototype.write_=function(t,e){void this.first_.send(t,e)},t.prototype.write=function(t,e){return this.flow_?void this.flow_.enqueue(t):void this.write_(t,e),this},t.prototype.flow=function(t,e,r){var o=this;return void 0===e&&(e=1/0),this.flow_=new i["default"],void this.flow_.flow(t,e,r),void this.flow_.register(function(t){return o.write_(t)}),this},t.prototype.throwCountExceededError=function(){throw new Error("ArchStream: Import and read counts are exeeded.")},t.prototype.throwCountDeprivedError=function(){throw this.count=0,new Error("ArchStream: Import and read counts are not deprived.")},Object.defineProperty(t.prototype,"read",o([n.bind],t.prototype,"read",Object.getOwnPropertyDescriptor(t.prototype,"read"))),Object.defineProperty(t.prototype,"write",o([n.bind],t.prototype,"write",Object.getOwnPropertyDescriptor(t.prototype,"write"))),t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=c},{"../decorator":1,"../lib/noop":4,"../lib/throttle":8,"../lib/tick":9}],15:[function(t,e,r){"use strict";var o=t("../lib/message"),n=t("./compose"),i=t("./modular"),u=function(){function t(t,e){var r=this;void 0===e&&(e=new o["default"]),this.parent_=t,this.message_=e,this.proxies_=[],this.parent_&&void this.parent_.proxies_.reduce(function(t,e){return r.proxy(e)},void 0)}return t.prototype.pipe=function(e){return new t(this,this.message_.recv(e))},t.prototype["import"]=function(t,e){return t instanceof i["default"]?(new n["default"])["import"](t,e):new n["default"](t)},t.prototype["export"]=function(t){return(new n["default"]).register([this.message_])["export"](t)},t.prototype.proxy_=function(e,r){function o(t){return Array.isArray(t)?t:[t]}var n=this.proxies_.filter(function(t){return"function"==typeof t[e]}).reduce(function(t,r){return o(r[e].apply(void 0,t)||t)},r),i="pipe";switch(e){case i:return t.prototype[e].call(this,n[0]);case"import":throw new Error("ArchStream: `import` method cannot extend by proxy.");case"export":return(u=t.prototype[e]).call.apply(u,[this.proxy_(i,n)].concat(r));default:return this.proxy_(i,n)}var u},t.prototype.proxy=function(t){var e=this,r="function"==typeof t?t():t;return this.proxies_.push(r),void Object.keys(r).filter(function(t){return t.length>0&&"_"!==t[0]&&"_"!==t[t.length-1]}).filter(function(t){return"function"==typeof r[t]}).reduce(function(t,r){return e[r]=function(){for(var t=[],o=0;o<arguments.length;o++)t[o-0]=arguments[o];return e.proxy_(r,t)}},void 0),this},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=u},{"../lib/message":3,"./compose":13,"./modular":14}],"arch-stream":[function(t,e,r){"use strict";function o(){return new i["default"]}function n(){return new u["default"]}var i=t("./stream/transform");r.ArchStream=i["default"];var u=t("./lib/message");r.Message=u["default"];var s=t("./lib/proxy");r.Proxy=s["default"];var c=t("./lib/tick");r.Tick=c["default"];var a=t("./lib/observable");r.Observable=a["default"],Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o;var o,p={Msg:n,Proxy:s["default"],Tick:c["default"]};!function(t){t.Msg=p.Msg,t.Proxy=p.Proxy,t.Tick=p.Tick}(o||(o={})),r.Msg=n},{"./lib/message":3,"./lib/observable":5,"./lib/proxy":6,"./lib/tick":9,"./stream/transform":15}]},{},[1,2,"arch-stream",3,4,5,6,7,8,9,10,11,12,13,14,15]),"object"==typeof module&&module&&"exports"in module&&(module.exports=require("arch-stream"));
/*! arch-stream v0.0.26 | (c) 2015, falsandtru | MIT Licence */
require=function t(e,r,o){function n(u,s){if(!r[u]){if(!e[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var f=r[u]={exports:{}};e[u][0].call(f.exports,function(t){var r=e[u][1][t];return n(r?r:t)},f,f.exports,t,e,r,o)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)n(o[u]);return n}({1:[function(t,e,r){"use strict";var o=t("./decorator/bind");r.bind=o.bind},{"./decorator/bind":2}],2:[function(t,e,r){"use strict";function o(t,e,r){t[e]=t[e].bind(t)}r.bind=o},{}],3:[function(t,e,r){"use strict";function o(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e}r.clone=o},{}],4:[function(t,e,r){"use strict";function o(t){return t}var n=this&&this.__decorate||function(t,e,r,o){if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)return Reflect.decorate(t,e,r,o);switch(arguments.length){case 2:return t.reduceRight(function(t,e){return e&&e(t)||t},e);case 3:return t.reduceRight(function(t,o){return void(o&&o(e,r))},void 0);case 4:return t.reduceRight(function(t,o){return o&&o(e,r,t)||t},o)}},i=t("../decorator"),u=t("../lib/thenable"),s=t("./tick"),c=Object.create(null),a=function(){function t(t,e){void 0===e&&(e=o),this.parent=t,this.listener=e,this.memory_=c,this.collection_=[],this.listeners_=[],t&&(this.parent.child_=this)}return t.prototype.root=function(){return this.parent?this.parent.root():this},t.prototype.collect_=function(){if(this.collection_.length>0)return this.collection_;var t=this,e=[];do void e.push(t);while(t=t.child_);return this.collection_=e},t.prototype.transport_=function(t,e){function r(e){return e.every(function(e){e.memory_=t;var r=e.listener(t);return u.isThenable(r)?(n=e,s=!1,void r.then(o,o),s):!0})}function o(){s=!0,i&&n.child_&&void n.child_.send(t,e)}var n,i=!1,s=!1,c=r(this.collect_());i=!0,c&&"function"==typeof e&&void e(t)},t.prototype.clone=function(){function e(r){return r.parent?new t(e(r.parent),r.listener):new t(void 0,r.listener)}return e(this)},t.prototype.connect=function(t){return this.parent.child_=t,t.parent=this.parent,this},t.prototype.send=function(t,e,r){switch(!0){case"function"==typeof e:return this.send(t,!1,e);case!e:return void this.transport_(t,r),this;default:return void s["default"](this.transport_.bind(this,t,r)),this}},t.prototype.recv=function(e){return this.listener=e,this.collection_=[],this.memory_!==c&&void this.send(this.memory_),new t(this)},t.prototype.then=function(t,e){function r(t){if(0!==o.length)for(s["default"](r.bind(this,t));o.length>0;)o.shift()(t)}var o=this.listeners_;return o.push(t),this.recv(r)},Object.defineProperty(t.prototype,"send",n([i.bind],t.prototype,"send",Object.getOwnPropertyDescriptor(t.prototype,"send"))),Object.defineProperty(t.prototype,"recv",n([i.bind],t.prototype,"recv",Object.getOwnPropertyDescriptor(t.prototype,"recv"))),t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=a},{"../decorator":1,"../lib/thenable":8,"./tick":10}],5:[function(t,e,r){"use strict";function o(){}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],6:[function(t,e,r){"use strict";var o=t("./array"),n=function(){function t(){this.separator_=".",this.map_=Object.create(null)}return t.prototype.seek_=function(t,e){function r(t,e){return t[e]&&t[e].map?t[e]:t[e]={map:Object.create(null),list:[]}}switch(e.length){case 0:throw new Error("ArchStream: Observable: Cannot use empty string for event type and namespace.");case 1:return r(t,e.shift());default:return this.seek_(r(t,e.shift()).map,e)}},t.prototype.on=function(t,e){return void this.seek_(this.map_,t.toString().split(this.separator_)).list.push(e),this},t.prototype.off=function(t,e){switch(typeof e){case"function":var r=this.seek_(this.map_,t.toString().split(this.separator_)).list,o=r.indexOf(e);switch(o){case-1:break;case 0:void r.shift();break;default:void r.splice(o,1)}return this;case"undefined":var n=this.seek_(this.map_,t.toString().split(this.separator_));return n.map=Object.create(null),n.list=[],this;default:throw new TypeError("ArchStream: Observable: Invalid type argument: "+e)}},t.prototype.once=function(t,e){var r=this,o=function(n){void r.off(t,o),void e(n)};return void this.on(t,o),this},t.prototype.emit=function(t,e){function r(t){var e=t.map,n=t.list;return Object.keys(e).reduce(function(t,o){return void t.unshift.apply(t,r(e[o])),t},o.clone(n))}return void r(this.seek_(this.map_,t.toString().split(this.separator_))).reduce(function(t,r){return r(e)},void 0),this},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n},{"./array":3}],7:[function(t,e,r){"use strict";var o=t("../proxy/case"),n=t("../proxy/hook"),i=t("../proxy/responsibility");Object.defineProperty(r,"__esModule",{value:!0}),r["default"]={Case:o["default"],Hook:n["default"],Responsibility:i["default"]}},{"../proxy/case":11,"../proxy/hook":12,"../proxy/responsibility":13}],8:[function(t,e,r){"use strict";function o(t){return!!t&&"object"==typeof t&&!!t.then}r.isThenable=o},{}],9:[function(t,e,r){"use strict";var o=function(){function t(){this.queue_=[],this.processing_=[],this.limit_=1/0,this.volume_=1/0}return t.prototype.isDrainable_=function(){return this.processing_.length<this.volume_},t.prototype.discharger_=function(t,e){},t.prototype.flow=function(t,e,r){void 0===e&&(e=1/0),void 0===r&&(r=function(){return null}),this.volume_=t,this.limit_=e,this.discharger_=r},t.prototype.enqueue=function(t){if(this.isDrainable_())return void this.processing_.push(t),void this.resolver_(t),!0;this.queue_.push(t);do void this.discharger_(this.queue_,this.processing_);while(this.processing_.length+this.queue_.length>this.limit_);return!1},t.prototype.dequeue=function(t){var e=this.processing_.indexOf(t);e>0?void this.processing_.splice(e,1):void this.processing_.shift(),this.queue_.length>0&&this.isDrainable_()&&void this.enqueue(this.queue_.shift())},t.prototype.register=function(t){this.resolver_=t},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],10:[function(t,e,r){"use strict";var o;!function(t){function e(t){void n.push(t),void o()}function r(){void--i,void o();for(var t=n.length;t-- >0;)void n.shift()()}function o(){if(0!==n.length)if(u)for(;2>i;)void Promise.resolve().then(r),void++i;else for(;i<s.length;)void setTimeout(r,s[i%s.length]),void++i}t.queue=e;var n=[],i=0,u="function"==typeof Promise,s=[0,4,10,20,25].reverse()}(o||(o={}));var n=Function("return typeof process === 'object' && typeof window !== 'object'")();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n?Function("return fn => process.nextTick(fn)")():o.queue},{}],11:[function(t,e,r){"use strict";function o(t,e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r-0]=arguments[r];return function(r){var n=+o[e(r)+""];n>-1&&n<t.length&&t[n](r)}}var o=Object.create(null);return void t.reduce(function(t,e,r){return o[e+""]=r},void 0),function(t){return{pipe:r}}}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],12:[function(t,e,r){"use strict";function o(t){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return t.map(function(t){return function(e){o(e),t(e),u(e)}})}var r=t.pre,o=void 0===r?n["default"]:r,i=t.post,u=void 0===i?n["default"]:i;return function(t){return{pipe:e}}}var n=t("../lib/noop");Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{"../lib/noop":5}],13:[function(t,e,r){"use strict";function o(){function t(t,r){e.pipe=function(){for(var e=[],o=0;o<arguments.length;o++)e[o-0]=arguments[o];return e.map(function(e){return function(o){if(!(r(o)instanceof t))throw TypeError("ArchStream: ResponsibilityProxy: Uncovered internal entity: "+r(o).constructor);e(o)}})},e["export"]=function(){return function(e){r(e)instanceof t&&void Object.freeze(r(e))}}}var e;return function(r){return e={rule:t}}}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o},{}],14:[function(t,e,r){"use strict";var o=t("./modular"),n=function(){function t(t){this.extract_=t,this.procs_=[],this.branched_=0}return t.prototype.register=function(t){var e=this.procs_.length;return void t.reduceRight(function(t,r,o){return t[o+e]=r,t},this.procs_),this},t.prototype["import"]=function(e,r){var o=this;return void this.throwErrorIfNotImportable_(e,r),r&&(e=(new t)["import"](e)["export"]().wrap(function(t,e){return o.extract_(t)instanceof r?e(t):0})),void--e.count,e.count<0&&void e.throwCountExceededError(),void this.register(e.procs),this},t.prototype["export"]=function(t){return new o["default"](this.procs_,t,this.branched_)},t.prototype.throwErrorIfNotImportable_=function(t,e){e?((t.branched>0||this.branched_>1)&&(void--t.count,void this.throwConditionalImportError()),this.branched_=1):(t.branched>0&&this.branched_>0&&(void--t.count,void this.throwConditionalImportError()),this.branched_=t.branched>0?t.branched+1:t.branched)},t.prototype.throwConditionalImportError=function(){throw new Error("ArchStream: Conditional import cannot call from different streams.")},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=n},{"./modular":15}],15:[function(t,e,r){"use strict";var o=this&&this.__decorate||function(t,e,r,o){if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)return Reflect.decorate(t,e,r,o);switch(arguments.length){case 2:return t.reduceRight(function(t,e){return e&&e(t)||t},e);case 3:return t.reduceRight(function(t,o){return void(o&&o(e,r))},void 0);case 4:return t.reduceRight(function(t,o){return o&&o(e,r,t)||t},o)}},n=t("../decorator"),i=t("../lib/throttle"),u=t("../lib/tick"),s=t("../lib/noop"),c=function(){function t(t,e,r){var o=this;void 0===e&&(e=1),this.procs=t,this.count=e,this.branched=r,void u["default"](function(t){return 0<o.count&&o.count<1/0&&o.throwCountDeprivedError()})}return t.prototype.compose_=function(){this.last_=this.procs.map(function(t){return t.clone()}).reduce(function(t,e){return t.connect(e.root())&&e}),this.first_=this.last_.root()},t.prototype.wrap=function(t){function e(e){return function(r){return t(r,e)}}void this.compose_();var r=this.last_;do r=r.parent,r.listener=e(r.listener);while(r.parent);return this.procs=[this.last_],this},t.prototype.read_=function(t){void--this.count,this.count<0&&void this.throwCountExceededError(),void this.compose_(),void this.last_.recv(t)},t.prototype.read=function(t){var e=this;void 0===t&&(t=s["default"]);var r=!1;return void this.read_(function(o){e.flow_&&void u["default"](function(){return void e.flow_.dequeue(o)}),r&&void t(o)}),r=!0,this},t.prototype.write_=function(t,e){void this.first_.send(t,e)},t.prototype.write=function(t,e){return this.flow_?void this.flow_.enqueue(t):void this.write_(t,e),this},t.prototype.flow=function(t,e,r){var o=this;return void 0===e&&(e=1/0),this.flow_=new i["default"],void this.flow_.flow(t,e,r),void this.flow_.register(function(t){return o.write_(t)}),this},t.prototype.throwCountExceededError=function(){throw new Error("ArchStream: Import and read counts are exeeded.")},t.prototype.throwCountDeprivedError=function(){throw this.count=0,new Error("ArchStream: Import and read counts are not deprived.")},Object.defineProperty(t.prototype,"read",o([n.bind],t.prototype,"read",Object.getOwnPropertyDescriptor(t.prototype,"read"))),Object.defineProperty(t.prototype,"write",o([n.bind],t.prototype,"write",Object.getOwnPropertyDescriptor(t.prototype,"write"))),t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=c},{"../decorator":1,"../lib/noop":5,"../lib/throttle":9,"../lib/tick":10}],16:[function(t,e,r){"use strict";var o=t("../lib/message"),n=t("./compose"),i=t("./modular"),u=function(){function t(t,e){var r=this;void 0===e&&(e=new o["default"]),this.parent_=t,this.message_=e,this.proxies_=[],this.parent_&&void this.parent_.proxies_.reduce(function(t,e){return r.proxy(e)},void 0)}return t.prototype.pipe=function(e){return new t(this,this.message_.recv(e))},t.prototype["import"]=function(t,e){return t instanceof i["default"]?(new n["default"])["import"](t,e):new n["default"](t)},t.prototype["export"]=function(t){return(new n["default"]).register([this.message_])["export"](t)},t.prototype.proxy=function(e){function r(e,o,n){function i(t){return Array.isArray(t)?t:[t]}var u=e.proxies_.filter(function(t){return"function"==typeof t[o]}).reduce(function(t,e){return i(e[o].apply(void 0,t)||t)},n),s="pipe";switch(o){case s:return t.prototype[o].call(e,u[0]);case"import":throw new Error("ArchStream: `import` method cannot extend by proxy.");case"export":return(c=t.prototype[o]).call.apply(c,[r(e,s,u)].concat(n));default:return r(e,s,u)}var c}var o=this,n="function"==typeof e?e():e;return this.proxies_.push(n),void Object.keys(n).filter(function(t){return t.length>0&&"_"!==t[0]&&"_"!==t[t.length-1]}).filter(function(t){return"function"==typeof n[t]}).reduce(function(t,e){return o[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n-0]=arguments[n];return r(o,e,t)}},void 0),this},t}();Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=u},{"../lib/message":4,"./compose":14,"./modular":15}],"arch-stream":[function(t,e,r){"use strict";function o(){return new i["default"]}function n(){return new u["default"]}var i=t("./stream/transform");r.ArchStream=i["default"];var u=t("./lib/message");r.Message=u["default"];var s=t("./lib/proxy");r.Proxy=s["default"];var c=t("./lib/tick");r.Tick=c["default"];var a=t("./lib/observable");r.Observable=a["default"],Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=o;var o,f={Msg:n,Proxy:s["default"],Tick:c["default"]};!function(t){t.Msg=f.Msg,t.Proxy=f.Proxy,t.Tick=f.Tick}(o||(o={})),r.Msg=n},{"./lib/message":4,"./lib/observable":6,"./lib/proxy":7,"./lib/tick":10,"./stream/transform":16}]},{},[1,2,"arch-stream",3,4,5,6,7,8,9,10,11,12,13,14,15,16]),"object"==typeof module&&module&&"exports"in module&&(module.exports=require("arch-stream"));
{
"name": "arch-stream",
"version": "0.0.25",
"version": "0.0.26",
"description": "Pipeline stream for software architecture of Domain-Driven Design and Data-Oriented Design.",

@@ -5,0 +5,0 @@ "private": false,

@@ -0,1 +1,2 @@

var Array_ = require('./array');
var Observable = (function () {

@@ -13,18 +14,18 @@ function Observable() {

case 1: {
return this.namespace_(map, types.shift());
return namespace(map, types.shift());
}
default: {
return this.seek_(this.namespace_(map, types.shift()).map, types);
return this.seek_(namespace(map, types.shift()).map, types);
}
}
assert(false);
function namespace(map, type) {
return map[type] && map[type].map
? map[type]
: map[type] = {
map: Object.create(null),
list: []
};
}
};
Observable.prototype.namespace_ = function (map, type) {
return map[type] && map[type].map
? map[type]
: map[type] = {
map: Object.create(null),
list: []
};
};
Observable.prototype.on = function (type, listener) {

@@ -76,15 +77,14 @@ assert(typeof listener === 'function');

};
Observable.prototype.collect_ = function (_a) {
var _this = this;
var map = _a.map, list = _a.list;
return Object.keys(map)
.reduce(function (list, type) {
void list.unshift.apply(list, _this.collect_(map[type]));
return list;
}, list.slice());
};
Observable.prototype.emit = function (type, data) {
void this.collect_(this.seek_(this.map_, type.toString().split(this.separator_)))
void collect(this.seek_(this.map_, type.toString().split(this.separator_)))
.reduce(function (_, listener) { return listener(data); }, void 0);
return this;
function collect(_a) {
var map = _a.map, list = _a.list;
return Object.keys(map)
.reduce(function (list, type) {
void list.unshift.apply(list, collect(map[type]));
return list;
}, Array_.clone(list));
}
};

@@ -91,0 +91,0 @@ return Observable;

import {Observable as IObservable} from 'arch-stream';
import * as Array_ from './array';

@@ -24,6 +25,6 @@ interface ListenerMap<T> {

case 1: {
return this.namespace_(map, types.shift());
return namespace(map, types.shift());
}
default: {
return this.seek_(this.namespace_(map, types.shift()).map, types);
return this.seek_(namespace(map, types.shift()).map, types);
}

@@ -33,11 +34,11 @@ }

function namespace(map: ListenerMap<T>, type: string): ListenerSet<T> {
return map[type] && map[type].map
? map[type]
: map[type] = {
map: <ListenerMap<T>>Object.create(null),
list: <Listener<T>[]>[]
};
}
}
private namespace_(map: ListenerMap<T>, type: string): ListenerSet<T> {
return map[type] && map[type].map
? map[type]
: map[type] = {
map: <ListenerMap<T>>Object.create(null),
list: <Listener<T>[]>[]
};
}
public on(type: S, listener: Listener<T>): Observable<S, T> {

@@ -89,14 +90,15 @@ assert(typeof listener === 'function');

}
private collect_({map, list}: ListenerSet<T>): Listener<T>[] {
return Object.keys(map)
.reduce((list, type) => {
void list.unshift(...this.collect_(map[type]));
return list;
}, list.slice());
}
public emit(type: S, data: T): Observable<S, T> {
void this.collect_(this.seek_(this.map_, type.toString().split(this.separator_)))
void collect(this.seek_(this.map_, type.toString().split(this.separator_)))
.reduce((_, listener) => listener(data), void 0);
return this;
function collect({map, list}: ListenerSet<T>): Listener<T>[] {
return Object.keys(map)
.reduce((list, type) => {
void list.unshift(...collect(map[type]));
return list;
}, Array_.clone(list));
}
}
}

@@ -34,28 +34,2 @@ var message_1 = require('../lib/message');

};
ArchStream.prototype.proxy_ = function (method, args) {
assert(this.proxies_.length > 0);
var params = this.proxies_
.filter(function (proxy) { return typeof proxy[method] === 'function'; })
.reduce(function (args, proxy) { return toArray(proxy[method].apply(void 0, args) || args); }, args);
var base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(this, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return (_a = ArchStream.prototype[method]).call.apply(_a, [this.proxy_(base, params)].concat(args));
}
default: {
return this.proxy_(base, params);
}
}
assert(false);
function toArray(target) {
return Array.isArray(target) ? target : [target];
}
var _a;
};
ArchStream.prototype.proxy = function (gen) {

@@ -73,5 +47,31 @@ var _this = this;

}
return _this.proxy_(method, args);
return compose(_this, method, args);
}; }, void 0);
return this;
function compose(self, method, args) {
assert(self.proxies_.length > 0);
var params = self.proxies_
.filter(function (proxy) { return typeof proxy[method] === 'function'; })
.reduce(function (args, proxy) { return toArray(proxy[method].apply(void 0, args) || args); }, args);
var base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(self, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return (_a = ArchStream.prototype[method]).call.apply(_a, [compose(self, base, params)].concat(args));
}
default: {
return compose(self, base, params);
}
}
assert(false);
function toArray(target) {
return Array.isArray(target) ? target : [target];
}
var _a;
}
};

@@ -78,0 +78,0 @@ return ArchStream;

@@ -39,28 +39,2 @@ import {ArchStream as IArchStream, ITransformStream, ICallback} from 'arch-stream';

private proxies_: IProxy<T>[] = [];
private proxy_<S>(method: string, args: ICallback<T>[]): ArchStream<T>&S {
assert(this.proxies_.length > 0);
const params = this.proxies_
.filter(proxy => typeof proxy[method] === 'function')
.reduce((args, proxy) => toArray(<ICallback<T>|ICallback<T>[]>proxy[method].apply(void 0, args) || args), args);
const base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(this, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return ArchStream.prototype[method].call(this.proxy_<S>(base, params), ...args);
}
default: {
return this.proxy_<S>(base, params);
}
}
assert(false);
function toArray<T>(target: T|T[]): T[] {
return Array.isArray(target) ? target : [target];
}
}
public proxy<S extends IProxy<T>>(gen: S|((shadow?: ITransformStream<T, {}>) => S)): ArchStream<T>&S {

@@ -72,5 +46,32 @@ const proxy = typeof gen === 'function' ? (<() => S>gen)() : <S>gen;

.filter(prop => typeof proxy[prop] === 'function')
.reduce((_, method) => this[method] = (...args: any[]) => this.proxy_<S>(method, args), void 0);
.reduce((_, method) => this[method] = (...args: any[]) => compose<S>(this, method, args), void 0);
return <ArchStream<T>&S>this;
function compose<S>(self: ArchStream<T>, method: string, args: ICallback<T>[]): ArchStream<T> & S {
assert(self.proxies_.length > 0);
const params = self.proxies_
.filter(proxy => typeof proxy[method] === 'function')
.reduce((args, proxy) => toArray(<ICallback<T> | ICallback<T>[]>proxy[method].apply(void 0, args) || args), args);
const base = 'pipe';
switch (method) {
case base: {
return ArchStream.prototype[method].call(self, params[0]);
}
case 'import': {
throw new Error('ArchStream: `import` method cannot extend by proxy.');
}
case 'export': {
return ArchStream.prototype[method].call(compose<S>(self, base, params), ...args);
}
default: {
return compose<S>(self, base, params);
}
}
assert(false);
function toArray<T>(target: T | T[]): T[] {
return Array.isArray(target) ? target : [target];
}
}
}
}
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