Comparing version 0.4.0-next.0 to 0.4.1
@@ -1,2 +0,2 @@ | ||
function t(t,e,n){Object.defineProperty(t,e,{get:()=>n(),enumerable:!0})}class e extends Error{}class n extends e{}class s extends e{}class i extends class extends class{}{on(t,e){return this.ee.on(t,e)}constructor(){super(),this._cache={},this._context={},this.ee=void 0,this.ee={events:{},emit(t,...e){(this.events[t]||[]).forEach(t=>t(...e))},on(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=(this.events[t]||[]).filter(t=>t!==e)}}}get(t){if(null!=this._context[t]){const e=this._cache[t];if(null!=e)return e;const n=(t,e)=>{this._cache[t]=e,this.ee.emit("containerUpserted",{key:t,newContainer:e})},s=this._context[t];if("function"==typeof s){const e=s();return n(t,e),e}return n(t,s),s}throw new n(`Can't find token '${t}' value`)}_updateContext(t){for(const[e,n]of Object.entries(t))null!=this._context[e]&&this.ee.emit("containerUpdated",{key:e,newContainer:n}),this._context[e]=n,this._cache[e]=null,this.ee.emit("containerUpserted",{key:e,newContainer:n})}subscribeToContiner(t,e){var n=this;return this.ee.on("containerUpserted",async function(s){if(t===s.key)try{const s=await n.get(t);e(null,s)}catch(t){e(t,void 0)}})}getTokens(){return Object.fromEntries(Object.keys(this._context).map(t=>[t,t]))}}{constructor(){super()}upsert(t){let e="function"==typeof t?t(this.containers,this):t;return this._updateContext(e),this}add(t){let e="function"==typeof t?t(this.containers,this):t,n=Object.keys(this.getTokens()).filter(t=>null!=e[t]);if(0!==n.length)throw new s(`Tokens already exist: ['${n.join("', '")}']`);return this.upsert(e)}_extractTokens(t){return"function"==typeof t?t(this.getTokens()):t}subscribeToContinerSet(t,e){var n=this;let s=this._extractTokens(t);return this.ee.on("containerUpserted",async function(t){if(s.includes(t.key))try{const t=await n.getContainerSet(s);e(null,t)}catch(t){e(t,void 0)}})}async getContainerSet(t){let e=this._extractTokens(t),n=[],s=[];for(let t of e)this.containers[t]instanceof Promise&&(n.push(t),s.push(this.containers[t]));let i={};e.forEach(t=>{i[t]=this.containers[t]});const r=await Promise.all(s);return n.forEach((t,e)=>{i[t]=r[e]}),i}get containers(){let e={};for(let n in this.getTokens())t(e,n,()=>this.get(n));return e}}function r(){return new i}export{i as NodeApi,r as makeRoot}; | ||
function t(t,e,n){Object.defineProperty(t,e,{get:()=>n(),enumerable:!0})}class e extends Error{}class n extends e{}class s extends e{}class i extends class extends class{}{on(t,e){return this.ee.on(t,e)}constructor(){super(),this._cache={},this._context={},this.ee=void 0,this.ee={events:{},emit(t,...e){(this.events[t]||[]).forEach(t=>t(...e))},on(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=(this.events[t]||[]).filter(t=>t!==e)}}}get(t){if(null!=this._context[t]){const e=this._cache[t];if(null!=e)return e;const n=(t,e)=>{this._cache[t]=e,this.ee.emit("containerUpserted",{key:t,newContainer:e})},s=this._context[t];if("function"==typeof s){const e=s();return n(t,e),e}return n(t,s),s}throw new n(`Can't find token '${String(t)}' value`)}_updateContext(t){for(const[e,n]of Object.entries(t))null!=this._context[e]&&this.ee.emit("containerUpdated",{key:e,newContainer:n}),this._context[e]=n,this._cache[e]=null,this.ee.emit("containerUpserted",{key:e,newContainer:n})}subscribeToContiner(t,e){var n=this;return this.ee.on("containerUpserted",async function(s){if(t===s.key)try{const s=await n.get(t);e(null,s)}catch(t){e(t,void 0)}})}getTokens(){return Object.fromEntries(Object.keys(this._context).map(t=>[t,t]))}}{constructor(){super()}upsert(t){let e="function"==typeof t?t(this.containers,this):t;return this._updateContext(e),this}add(t){let e="function"==typeof t?t(this.containers,this):t,n=Object.keys(this.getTokens()).filter(t=>null!=e[t]);if(0!==n.length)throw new s(`Tokens already exist: ['${n.join("', '")}']`);return this.upsert(e)}_extractTokens(t){return"function"==typeof t?t(this.getTokens()):t}subscribeToContinerSet(t,e){var n=this;let s=this._extractTokens(t);return this.ee.on("containerUpserted",async function(t){if(s.includes(t.key))try{const t=await n.getContainerSet(s);e(null,t)}catch(t){e(t,void 0)}})}async getContainerSet(t){let e=this._extractTokens(t),n=[],s=[];for(let t of e)this.containers[t]instanceof Promise&&(n.push(t),s.push(this.containers[t]));let i={};e.forEach(t=>{i[t]=this.containers[t]});const r=await Promise.all(s);return n.forEach((t,e)=>{i[t]=r[e]}),i}get containers(){let e={};for(let n in this.getTokens())t(e,n,()=>this.get(n));return e}}function r(){return new i}export{i as NodeApi,r as makeRoot}; | ||
//# sourceMappingURL=iti.modern.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function e(t,n){return e=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},e(t,n)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function o(t,n,i){return o=r()?Reflect.construct:function(t,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(t,o));return r&&e(i,r.prototype),i},o.apply(null,arguments)}function i(t){var r="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,i)}function i(){return o(t,arguments,n(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),e(i,t)},i(t)}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var c=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(/*#__PURE__*/i(Error)),f=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(c),a=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(c);function s(t,n){try{var e=t()}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}var l=/*#__PURE__*/function(n){function e(){return n.call(this)||this}t(e,n);var r,o,i=e.prototype;return i.upsert=function(t){var n="function"==typeof t?t(this.containers,this):t;return this._updateContext(n),this},i.add=function(t){var n="function"==typeof t?t(this.containers,this):t,e=Object.keys(this.getTokens()).filter(function(t){return null!=n[t]});if(0!==e.length)throw new a("Tokens already exist: ['"+e.join("', '")+"']");return this.upsert(n)},i._extractTokens=function(t){return"function"==typeof t?t(this.getTokens()):t},i.subscribeToContinerSet=function(t,n){var e=this,r=this._extractTokens(t);return this.ee.on("containerUpserted",function(t){try{var o=function(){if(r.includes(t.key)){var o=s(function(){return Promise.resolve(e.getContainerSet(r)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},i.getContainerSet=function(t){try{for(var n,e=this,r=e._extractTokens(t),o=[],i=[],c=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return u(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,n):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(n=c()).done;){var f=n.value;e.containers[f]instanceof Promise&&(o.push(f),i.push(e.containers[f]))}var a={};return r.forEach(function(t){a[t]=e.containers[t]}),Promise.resolve(Promise.all(i)).then(function(t){return o.forEach(function(n,e){a[n]=t[e]}),a})}catch(t){return Promise.reject(t)}},r=e,(o=[{key:"containers",get:function(){var t=this,n={},e=function(e){!function(t,n,e){Object.defineProperty(t,n,{get:function(){return e()},enumerable:!0})}(n,e,function(){return t.get(e)})};for(var r in this.getTokens())e(r);return n}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,o),Object.defineProperty(r,"prototype",{writable:!1}),e}(/*#__PURE__*/function(n){t(r,n);var e=r.prototype;function r(){var t;return(t=n.call(this)||this)._cache={},t._context={},t.ee=void 0,t.ee={events:{},emit:function(t){var n=arguments;(this.events[t]||[]).forEach(function(t){return t.apply(void 0,[].slice.call(n,1))})},on:function(t,n){var e=this;return(this.events[t]=this.events[t]||[]).push(n),function(){return e.events[t]=(e.events[t]||[]).filter(function(t){return t!==n})}}},t}return e.on=function(t,n){return this.ee.on(t,n)},e.get=function(t){var n=this;if(null!=this._context[t]){var e=this._cache[t];if(null!=e)return e;var r=function(t,e){n._cache[t]=e,n.ee.emit("containerUpserted",{key:t,newContainer:e})},o=this._context[t];if("function"==typeof o){var i=o();return r(t,i),i}return r(t,o),o}throw new f("Can't find token '"+t+"' value")},e._updateContext=function(t){for(var n=0,e=Object.entries(t);n<e.length;n++){var r=e[n],o=r[0],i=r[1];null!=this._context[o]&&this.ee.emit("containerUpdated",{key:o,newContainer:i}),this._context[o]=i,this._cache[o]=null,this.ee.emit("containerUpserted",{key:o,newContainer:i})}},e.subscribeToContiner=function(t,n){var e=this;return this.ee.on("containerUpserted",function(r){try{var o=function(){if(t===r.key){var o=s(function(){return Promise.resolve(e.get(t)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},e.getTokens=function(){return Object.fromEntries(Object.keys(this._context).map(function(t){return[t,t]}))},r}(function(){}));function h(){return new l}export{l as NodeApi,h as makeRoot}; | ||
function t(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function e(t,n){return e=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},e(t,n)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function o(t,n,i){return o=r()?Reflect.construct:function(t,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(t,o));return r&&e(i,r.prototype),i},o.apply(null,arguments)}function i(t){var r="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,i)}function i(){return o(t,arguments,n(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),e(i,t)},i(t)}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var c=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(/*#__PURE__*/i(Error)),f=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(c),a=/*#__PURE__*/function(n){function e(){return n.apply(this,arguments)||this}return t(e,n),e}(c);function s(t,n){try{var e=t()}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}var l=/*#__PURE__*/function(n){function e(){return n.call(this)||this}t(e,n);var r,o,i=e.prototype;return i.upsert=function(t){var n="function"==typeof t?t(this.containers,this):t;return this._updateContext(n),this},i.add=function(t){var n="function"==typeof t?t(this.containers,this):t,e=Object.keys(this.getTokens()).filter(function(t){return null!=n[t]});if(0!==e.length)throw new a("Tokens already exist: ['"+e.join("', '")+"']");return this.upsert(n)},i._extractTokens=function(t){return"function"==typeof t?t(this.getTokens()):t},i.subscribeToContinerSet=function(t,n){var e=this,r=this._extractTokens(t);return this.ee.on("containerUpserted",function(t){try{var o=function(){if(r.includes(t.key)){var o=s(function(){return Promise.resolve(e.getContainerSet(r)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},i.getContainerSet=function(t){try{for(var n,e=this,r=e._extractTokens(t),o=[],i=[],c=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return u(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,n):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(n=c()).done;){var f=n.value;e.containers[f]instanceof Promise&&(o.push(f),i.push(e.containers[f]))}var a={};return r.forEach(function(t){a[t]=e.containers[t]}),Promise.resolve(Promise.all(i)).then(function(t){return o.forEach(function(n,e){a[n]=t[e]}),a})}catch(t){return Promise.reject(t)}},r=e,(o=[{key:"containers",get:function(){var t=this,n={},e=function(e){!function(t,n,e){Object.defineProperty(t,n,{get:function(){return e()},enumerable:!0})}(n,e,function(){return t.get(e)})};for(var r in this.getTokens())e(r);return n}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,o),Object.defineProperty(r,"prototype",{writable:!1}),e}(/*#__PURE__*/function(n){t(r,n);var e=r.prototype;function r(){var t;return(t=n.call(this)||this)._cache={},t._context={},t.ee=void 0,t.ee={events:{},emit:function(t){var n=arguments;(this.events[t]||[]).forEach(function(t){return t.apply(void 0,[].slice.call(n,1))})},on:function(t,n){var e=this;return(this.events[t]=this.events[t]||[]).push(n),function(){return e.events[t]=(e.events[t]||[]).filter(function(t){return t!==n})}}},t}return e.on=function(t,n){return this.ee.on(t,n)},e.get=function(t){var n=this;if(null!=this._context[t]){var e=this._cache[t];if(null!=e)return e;var r=function(t,e){n._cache[t]=e,n.ee.emit("containerUpserted",{key:t,newContainer:e})},o=this._context[t];if("function"==typeof o){var i=o();return r(t,i),i}return r(t,o),o}throw new f("Can't find token '"+String(t)+"' value")},e._updateContext=function(t){for(var n=0,e=Object.entries(t);n<e.length;n++){var r=e[n],o=r[0],i=r[1];null!=this._context[o]&&this.ee.emit("containerUpdated",{key:o,newContainer:i}),this._context[o]=i,this._cache[o]=null,this.ee.emit("containerUpserted",{key:o,newContainer:i})}},e.subscribeToContiner=function(t,n){var e=this;return this.ee.on("containerUpserted",function(r){try{var o=function(){if(t===r.key){var o=s(function(){return Promise.resolve(e.get(t)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},e.getTokens=function(){return Object.fromEntries(Object.keys(this._context).map(function(t){return[t,t]}))},r}(function(){}));function h(){return new l}export{l as NodeApi,h as makeRoot}; | ||
//# sourceMappingURL=iti.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t||self).iti={})}(this,function(t){function n(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n)}function e(t){return e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(t)}function r(t,n){return r=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},r(t,n)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function i(t,n,e){return i=o()?Reflect.construct:function(t,n,e){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(t,o));return e&&r(i,e.prototype),i},i.apply(null,arguments)}function u(t){var n="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,o)}function o(){return i(t,arguments,e(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,t)},u(t)}function c(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var f=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(/*#__PURE__*/u(Error)),a=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(f),s=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(f);function l(t,n){try{var e=t()}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}var h=/*#__PURE__*/function(t){n(r,t);var e=r.prototype;function r(){var n;return(n=t.call(this)||this)._cache={},n._context={},n.ee=void 0,n.ee={events:{},emit:function(t){var n=arguments;(this.events[t]||[]).forEach(function(t){return t.apply(void 0,[].slice.call(n,1))})},on:function(t,n){var e=this;return(this.events[t]=this.events[t]||[]).push(n),function(){return e.events[t]=(e.events[t]||[]).filter(function(t){return t!==n})}}},n}return e.on=function(t,n){return this.ee.on(t,n)},e.get=function(t){var n=this;if(null!=this._context[t]){var e=this._cache[t];if(null!=e)return e;var r=function(t,e){n._cache[t]=e,n.ee.emit("containerUpserted",{key:t,newContainer:e})},o=this._context[t];if("function"==typeof o){var i=o();return r(t,i),i}return r(t,o),o}throw new a("Can't find token '"+t+"' value")},e._updateContext=function(t){for(var n=0,e=Object.entries(t);n<e.length;n++){var r=e[n],o=r[0],i=r[1];null!=this._context[o]&&this.ee.emit("containerUpdated",{key:o,newContainer:i}),this._context[o]=i,this._cache[o]=null,this.ee.emit("containerUpserted",{key:o,newContainer:i})}},e.subscribeToContiner=function(t,n){var e=this;return this.ee.on("containerUpserted",function(r){try{var o=function(){if(t===r.key){var o=l(function(){return Promise.resolve(e.get(t)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},e.getTokens=function(){return Object.fromEntries(Object.keys(this._context).map(function(t){return[t,t]}))},r}(function(){}),p=/*#__PURE__*/function(t){function e(){return t.call(this)||this}n(e,t);var r,o,i=e.prototype;return i.upsert=function(t){var n="function"==typeof t?t(this.containers,this):t;return this._updateContext(n),this},i.add=function(t){var n="function"==typeof t?t(this.containers,this):t,e=Object.keys(this.getTokens()).filter(function(t){return null!=n[t]});if(0!==e.length)throw new s("Tokens already exist: ['"+e.join("', '")+"']");return this.upsert(n)},i._extractTokens=function(t){return"function"==typeof t?t(this.getTokens()):t},i.subscribeToContinerSet=function(t,n){var e=this,r=this._extractTokens(t);return this.ee.on("containerUpserted",function(t){try{var o=function(){if(r.includes(t.key)){var o=l(function(){return Promise.resolve(e.getContainerSet(r)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},i.getContainerSet=function(t){try{for(var n,e=this,r=e._extractTokens(t),o=[],i=[],u=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return c(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?c(t,n):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(n=u()).done;){var f=n.value;e.containers[f]instanceof Promise&&(o.push(f),i.push(e.containers[f]))}var a={};return r.forEach(function(t){a[t]=e.containers[t]}),Promise.resolve(Promise.all(i)).then(function(t){return o.forEach(function(n,e){a[n]=t[e]}),a})}catch(t){return Promise.reject(t)}},r=e,(o=[{key:"containers",get:function(){var t=this,n={},e=function(e){!function(t,n,e){Object.defineProperty(t,n,{get:function(){return e()},enumerable:!0})}(n,e,function(){return t.get(e)})};for(var r in this.getTokens())e(r);return n}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,o),Object.defineProperty(r,"prototype",{writable:!1}),e}(h);t.NodeApi=p,t.makeRoot=function(){return new p}}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t||self).iti={})}(this,function(t){function n(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n)}function e(t){return e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(t)}function r(t,n){return r=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t},r(t,n)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function i(t,n,e){return i=o()?Reflect.construct:function(t,n,e){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(t,o));return e&&r(i,e.prototype),i},i.apply(null,arguments)}function u(t){var n="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,o)}function o(){return i(t,arguments,e(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,t)},u(t)}function c(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var f=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(/*#__PURE__*/u(Error)),a=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(f),s=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}return n(e,t),e}(f);function l(t,n){try{var e=t()}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}var h=/*#__PURE__*/function(t){n(r,t);var e=r.prototype;function r(){var n;return(n=t.call(this)||this)._cache={},n._context={},n.ee=void 0,n.ee={events:{},emit:function(t){var n=arguments;(this.events[t]||[]).forEach(function(t){return t.apply(void 0,[].slice.call(n,1))})},on:function(t,n){var e=this;return(this.events[t]=this.events[t]||[]).push(n),function(){return e.events[t]=(e.events[t]||[]).filter(function(t){return t!==n})}}},n}return e.on=function(t,n){return this.ee.on(t,n)},e.get=function(t){var n=this;if(null!=this._context[t]){var e=this._cache[t];if(null!=e)return e;var r=function(t,e){n._cache[t]=e,n.ee.emit("containerUpserted",{key:t,newContainer:e})},o=this._context[t];if("function"==typeof o){var i=o();return r(t,i),i}return r(t,o),o}throw new a("Can't find token '"+String(t)+"' value")},e._updateContext=function(t){for(var n=0,e=Object.entries(t);n<e.length;n++){var r=e[n],o=r[0],i=r[1];null!=this._context[o]&&this.ee.emit("containerUpdated",{key:o,newContainer:i}),this._context[o]=i,this._cache[o]=null,this.ee.emit("containerUpserted",{key:o,newContainer:i})}},e.subscribeToContiner=function(t,n){var e=this;return this.ee.on("containerUpserted",function(r){try{var o=function(){if(t===r.key){var o=l(function(){return Promise.resolve(e.get(t)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},e.getTokens=function(){return Object.fromEntries(Object.keys(this._context).map(function(t){return[t,t]}))},r}(function(){}),p=/*#__PURE__*/function(t){function e(){return t.call(this)||this}n(e,t);var r,o,i=e.prototype;return i.upsert=function(t){var n="function"==typeof t?t(this.containers,this):t;return this._updateContext(n),this},i.add=function(t){var n="function"==typeof t?t(this.containers,this):t,e=Object.keys(this.getTokens()).filter(function(t){return null!=n[t]});if(0!==e.length)throw new s("Tokens already exist: ['"+e.join("', '")+"']");return this.upsert(n)},i._extractTokens=function(t){return"function"==typeof t?t(this.getTokens()):t},i.subscribeToContinerSet=function(t,n){var e=this,r=this._extractTokens(t);return this.ee.on("containerUpserted",function(t){try{var o=function(){if(r.includes(t.key)){var o=l(function(){return Promise.resolve(e.getContainerSet(r)).then(function(t){n(null,t)})},function(t){n(t,void 0)});if(o&&o.then)return o.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}})},i.getContainerSet=function(t){try{for(var n,e=this,r=e._extractTokens(t),o=[],i=[],u=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return c(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?c(t,n):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(n=u()).done;){var f=n.value;e.containers[f]instanceof Promise&&(o.push(f),i.push(e.containers[f]))}var a={};return r.forEach(function(t){a[t]=e.containers[t]}),Promise.resolve(Promise.all(i)).then(function(t){return o.forEach(function(n,e){a[n]=t[e]}),a})}catch(t){return Promise.reject(t)}},r=e,(o=[{key:"containers",get:function(){var t=this,n={},e=function(e){!function(t,n,e){Object.defineProperty(t,n,{get:function(){return e()},enumerable:!0})}(n,e,function(){return t.get(e)})};for(var r in this.getTokens())e(r);return n}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(r.prototype,o),Object.defineProperty(r,"prototype",{writable:!1}),e}(h);t.NodeApi=p,t.makeRoot=function(){return new p}}); | ||
//# sourceMappingURL=iti.umd.js.map |
{ | ||
"name": "iti", | ||
"version": "0.4.0-next.0", | ||
"version": "0.4.1", | ||
"description": "~1kB inversion of control container for Typescript/Javascrith with a focus on async flow", | ||
@@ -20,2 +20,5 @@ "type": "module", | ||
"build": "rm -rf ./dist && microbundle build -o dist/", | ||
"jest": "jest", | ||
"stryker": "stryker", | ||
"stryker:run": "stryker run", | ||
"test": "yarn jest && yarn tsd", | ||
@@ -26,15 +29,17 @@ "jestWatch": "jest --watch --verbose", | ||
"dependencies": { | ||
"stryker-cli": "^1.0.2", | ||
"utility-types": "^3.10.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/react": "^12.1.4", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@stryker-mutator/core": "^6.1.2", | ||
"@stryker-mutator/jest-runner": "^6.1.2", | ||
"@stryker-mutator/typescript-checker": "^6.1.2", | ||
"@types/jest": "^27.4.1", | ||
"@types/react": "^17.0.40", | ||
"@types/react": "^18.0.15", | ||
"jest": "^27.4.7", | ||
"microbundle": "^0.14.2", | ||
"nodemon": "^2.0.15", | ||
"microbundle": "^0.15.0", | ||
"nodemon": "^2.0.19", | ||
"ts-jest": "^27.1.3", | ||
"tsd": "^0.19.1", | ||
"typescript": "^4.6.2" | ||
"tsd": "^0.22.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
@@ -41,0 +46,0 @@ "engines": { |
@@ -1,11 +0,16 @@ | ||
# Iti [![CI status][ci-img]][ci-url] [![Gzip][gzip-img]][gzip-url] [![npm version][npm-img]][npm-url] | ||
<p align="center"> | ||
<a href="https://itijs.org" target="_blank" rel="noopener noreferrer"> | ||
<img width="180" src="./docs/logo.svg" alt="ITI Logo"> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://github.com/molszanski/iti/actions?query=branch%3Amaster"><img src="https://github.com/molszanski/iti/actions/workflows/lib-test.yml/badge.svg" alt="CI Statu"></a> | ||
<a href="https://www.npmjs.org/package/iti"><img src="https://img.shields.io/npm/v/iti.svg" alt="npm version"></a> | ||
<a href="https://unpkg.com/iti/dist/iti.modern.js"><img src="https://img.badgesize.io/https://unpkg.com/iti/dist/iti.modern.js?compression=gzip" alt="gzip"></a> | ||
<a href="https://dashboard.stryker-mutator.io/reports/github.com/molszanski/iti/master"><img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fmolszanski%2Fiti%2Fmaster" alt="Mutation Score"></a> | ||
</p> | ||
[gzip-url]: https://unpkg.com/iti/dist/iti.modern.js | ||
[gzip-img]: https://img.badgesize.io/https://unpkg.com/iti/dist/iti.modern.js?compression=gzip | ||
[ci-url]: https://github.com/molszanski/iti/actions?query=branch%3Amaster | ||
[ci-img]: https://github.com/molszanski/iti/actions/workflows/lib-test.yml/badge.svg | ||
[npm-url]: https://www.npmjs.org/package/iti | ||
[npm-img]: https://img.shields.io/npm/v/iti.svg | ||
# Iti | ||
> 1kB inversion of control container for Typescript and Javascript with a unique feature that supports **async flow** | ||
> 1kB Depenendency Injection Framework for Typescript and Javascript with a unique feature that supports **async flow** | ||
@@ -12,0 +17,0 @@ - **supports async(!):** merges async code and constructor injection via plain **async** functions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106966
425
2
11
+ Addedstryker-cli@^1.0.2
+ Addedansi-escapes@3.2.0(transitive)
+ Addedansi-regex@3.0.14.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@2.1.0(transitive)
+ Addedcli-width@2.2.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedfigures@2.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinquirer@6.5.2(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmimic-fn@1.2.0(transitive)
+ Addedmute-stream@0.0.7(transitive)
+ Addedonetime@2.0.1(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedrestore-cursor@2.0.0(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.05.2.0(transitive)
+ Addedstryker-cli@1.0.2(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@1.14.1(transitive)