diff --git a/README.md b/README.md index 4f038ae..b381ea9 100644 --- a/README.md +++ b/README.md @@ -116,3 +116,8 @@ In the above example despite being called 3x the container will only have to res ### Does this work with Vue 1.x? It probably should, given that Vue manages it's hooks the same way, but it hasn't been tested yet, if you do feel free to make an issue and report any problems you run into. + +### What's new? +- 21/04/2017 + - added `unregister` to remove bindings and `bindings` to get all registered services. + - added `has` method to check if a container has a binding diff --git a/dist/vuec.js b/dist/vuec.js index 981437c..e377148 100644 --- a/dist/vuec.js +++ b/dist/vuec.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vuec=t():e.vuec=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:null,n=e.toString().match(/^function\s*[^(]*\(\s*([^)]*)\)/m);if(null===n)return e.toString().indexOf("function")===-1?console.warn("Parsing "+e.name+" failed:","ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).","Use a transpiler or ES5 notation."):console.warn("Extraction failed for "+e.name),e.bind(t);var o=n[1].replace(/ /g,"").split(",").map(this.resolve.bind(this));return e.bind.apply(e,[t].concat(r(o)))}}]),e}();t.default=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=r(o),u=function(e,t,n){var r=e.$options[t];r&&r.length>0&&(r[r.length-1]=n.prepare(r[r.length-1],e))},a=new i.default;t.default={install:function(e){e.prototype.$ioc=a,e.$ioc=a,e.mixin({beforeCreate:function(){u(this,"created",a),u(this,"beforeMount",a),u(this,"mounted",a),u(this,"beforeUpdate",a),u(this,"updated",a),u(this,"beforeDestroy",a),u(this,"destroyed",a)}})}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var o=n(0);Object.defineProperty(t,"Container",{enumerable:!0,get:function(){return r(o).default}});var i=n(1),u=r(i);t.default=u.default}])}); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.vuec=t():e.vuec=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:null,n=e.toString().match(/^function\s*[^(]*\(\s*([^)]*)\)/m);if(null===n)return e.toString().indexOf("function")===-1?console.warn("Parsing "+e.name+" failed:","ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).","Use a transpiler or ES5 notation."):console.warn("Extraction failed for "+e.name),e.bind(t);var o=n[1].replace(/ /g,"").split(",").map(this.resolve.bind(this));return e.bind.apply(e,[t].concat(r(o)))}}]),e}();t.default=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=r(o),u=function(e,t,n){var r=e.$options[t];r&&r.length>0&&(r[r.length-1]=n.prepare(r[r.length-1],e))},a=new i.default;t.default={install:function(e){e.prototype.$ioc=a,e.$ioc=a,e.mixin({beforeCreate:function(){u(this,"created",a),u(this,"beforeMount",a),u(this,"mounted",a),u(this,"beforeUpdate",a),u(this,"updated",a),u(this,"beforeDestroy",a),u(this,"destroyed",a)}})}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var o=n(0);Object.defineProperty(t,"Container",{enumerable:!0,get:function(){return r(o).default}});var i=n(1),u=r(i);t.default=u.default}])}); //# sourceMappingURL=vuec.js.map \ No newline at end of file diff --git a/dist/vuec.js.map b/dist/vuec.js.map index bee22d6..14766c0 100644 --- a/dist/vuec.js.map +++ b/dist/vuec.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///vuec.js","webpack:///webpack/bootstrap ce3476faba87a9f74359","webpack:///./src/Container.js","webpack:///./src/Vue.js","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_toConsumableArray","arr","Array","isArray","arr2","length","from","_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","descriptor","writable","key","protoProps","staticProps","Container","$cache","Map","set","has","func","self","arguments","undefined","extracted","toString","match","indexOf","console","warn","bind","params","replace","split","map","resolve","apply","concat","default","_interopRequireDefault","obj","_Container","_Container2","patchHook","$vm","hook","container","hooks","$options","prepare","install","Vue","$ioc","mixin","beforeCreate","_Vue","_Vue2"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA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UnD,EAAQD,EAASM,GAEjC,YAWA,SAASsE,GAAuBC,GAAO,MAAOA,IAAOA,EAAIpD,WAAaoD,GAAQF,QAASE,GARvF1D,OAAOC,eAAepB,EAAS,cAC9Bc,OAAO,GGtJR,IAAAgE,GAAAxE,EAAA,GH2JIyE,EAAcH,EAAuBE,GGzJnCE,EAAY,SAACC,EAAKC,EAAMC,GAC7B,GAAMC,GAAQH,EAAII,SAASH,EACvBE,IAASA,EAAM/C,OAAS,IAC3B+C,EAAMA,EAAM/C,OAAS,GAAK8C,EAAUG,QAAQF,EAAMA,EAAM/C,OAAS,GAAI4C,KAIjEE,EAAY,GAAAJ,GAAAJ,OH8JlB3E,GAAQ2E,SG5JPY,QADc,SACNC,GACPA,EAAI5D,UAAU6D,KAAON,EACrBK,EAAIC,KAAON,EACXK,EAAIE,OACHC,aADS,WAERX,EAAU5E,KAAM,UAAW+E,GAC3BH,EAAU5E,KAAM,cAAe+E,GAC/BH,EAAU5E,KAAM,UAAW+E,GAC3BH,EAAU5E,KAAM,eAAgB+E,GAChCH,EAAU5E,KAAM,UAAW+E,GAC3BH,EAAU5E,KAAM,gBAAiB+E,GACjCH,EAAU5E,KAAM,YAAa+E,SHqK3B,SAAUlF,EAAQD,EAASM,GAEjC,YAqBA,SAASsE,GAAuBC,GAAO,MAAOA,IAAOA,EAAIpD,WAAaoD,GAAQF,QAASE,GAlBvF1D,OAAOC,eAAepB,EAAS,cAC7Bc,OAAO,IAETd,EAAQoD,UAAYQ,MAEpB,IAAIkB,GAAaxE,EAAoB,EAErCa,QAAOC,eAAepB,EAAS,aAC7BsB,YAAY,EACZC,IAAK,WACH,MAAOqD,GAAuBE,GIzMzBH,UADT,IAAAiB,GAAAtF,EAAA,GJgNIuF,EAAQjB,EAAuBgB,EAInC5F,GAAQ2E,QAAUkB,EAAMlB","file":"vuec.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"vuec\"] = factory();\n\telse\n\t\troot[\"vuec\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"vuec\"] = factory();\n\telse\n\t\troot[\"vuec\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Container = function () {\n\tfunction Container() {\n\t\t_classCallCheck(this, Container);\n\n\t\tthis.$cache = new Map();\n\t}\n\n\t_createClass(Container, [{\n\t\tkey: 'register',\n\t\tvalue: function register(name, value) {\n\t\t\tthis.$cache.set(name, value);\n\t\t}\n\t}, {\n\t\tkey: 'resolve',\n\t\tvalue: function resolve(name) {\n\t\t\tif (this.$cache.has(name)) {\n\t\t\t\treturn this.$cache.get(name);\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t}\n\t}, {\n\t\tkey: 'prepare',\n\t\tvalue: function prepare(func) {\n\t\t\tvar self = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n\t\t\tvar extracted = func.toString().match(/^function\\s*[^(]*\\(\\s*([^)]*)\\)/m);\n\t\t\tif (extracted === null) {\n\t\t\t\tif (func.toString().indexOf('function') === -1) {\n\t\t\t\t\tconsole.warn('Parsing ' + func.name + ' failed:', 'ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).', 'Use a transpiler or ES5 notation.');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Extraction failed for ' + func.name);\n\t\t\t\t}\n\t\t\t\treturn func.bind(self);\n\t\t\t}\n\n\t\t\tvar params = extracted[1].replace(/ /g, '').split(',').map(this.resolve.bind(this));\n\n\t\t\treturn func.bind.apply(func, [self].concat(_toConsumableArray(params)));\n\t\t}\n\t}]);\n\n\treturn Container;\n}();\n\nexports.default = Container;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _Container = __webpack_require__(0);\n\nvar _Container2 = _interopRequireDefault(_Container);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar patchHook = function patchHook($vm, hook, container) {\n\tvar hooks = $vm.$options[hook];\n\tif (hooks && hooks.length > 0) {\n\t\thooks[hooks.length - 1] = container.prepare(hooks[hooks.length - 1], $vm);\n\t}\n};\n\nvar container = new _Container2.default(); // eslint-disable-line\nexports.default = {\n\tinstall: function install(Vue) {\n\t\tVue.prototype.$ioc = container;\n\t\tVue.$ioc = container;\n\t\tVue.mixin({\n\t\t\tbeforeCreate: function beforeCreate() {\n\t\t\t\tpatchHook(this, 'created', container);\n\t\t\t\tpatchHook(this, 'beforeMount', container);\n\t\t\t\tpatchHook(this, 'mounted', container);\n\t\t\t\tpatchHook(this, 'beforeUpdate', container);\n\t\t\t\tpatchHook(this, 'updated', container);\n\t\t\t\tpatchHook(this, 'beforeDestroy', container);\n\t\t\t\tpatchHook(this, 'destroyed', container);\n\t\t\t}\n\t\t});\n\t}\n};\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Container = undefined;\n\nvar _Container = __webpack_require__(0);\n\nObject.defineProperty(exports, 'Container', {\n enumerable: true,\n get: function get() {\n return _interopRequireDefault(_Container).default;\n }\n});\n\nvar _Vue = __webpack_require__(1);\n\nvar _Vue2 = _interopRequireDefault(_Vue);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = _Vue2.default;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// vuec.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ce3476faba87a9f74359","export default class Container {\n\tconstructor() {\n\t\tthis.$cache = new Map();\n\t}\n\n\tregister(name, value) {\n\t\tthis.$cache.set(name, value);\n\t}\n\n\tresolve(name) {\n\t\tif (this.$cache.has(name)) {\n\t\t\treturn this.$cache.get(name);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprepare(func, self = null) {\n\t\tconst extracted = func.toString().match(/^function\\s*[^(]*\\(\\s*([^)]*)\\)/m);\n\t\tif (extracted === null) {\n\t\t\tif (func.toString().indexOf('function') === -1) {\n\t\t\t\tconsole.warn(`Parsing ${func.name} failed:`,\n\t\t\t\t\t'ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).',\n\t\t\t\t\t'Use a transpiler or ES5 notation.');\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Extraction failed for ${func.name}`);\n\t\t\t}\n\t\t\treturn func.bind(self);\n\t\t}\n\n\t\tconst params = extracted[1]\n\t\t\t.replace(/ /g, '')\n\t\t\t.split(',')\n\t\t\t.map(this.resolve.bind(this));\n\n\t\treturn func.bind(self, ...params);\n\t}\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/Container.js","import Container from './Container';\n\nconst patchHook = ($vm, hook, container) => {\n\tconst hooks = $vm.$options[hook];\n\tif (hooks && hooks.length > 0) {\n\t\thooks[hooks.length - 1] = container.prepare(hooks[hooks.length - 1], $vm);\n\t}\n};\n\nconst container = new Container; // eslint-disable-line\nexport default {\n\tinstall(Vue) {\n\t\tVue.prototype.$ioc = container;\n\t\tVue.$ioc = container;\n\t\tVue.mixin({\n\t\t\tbeforeCreate() {\n\t\t\t\tpatchHook(this, 'created', container);\n\t\t\t\tpatchHook(this, 'beforeMount', container);\n\t\t\t\tpatchHook(this, 'mounted', container);\n\t\t\t\tpatchHook(this, 'beforeUpdate', container);\n\t\t\t\tpatchHook(this, 'updated', container);\n\t\t\t\tpatchHook(this, 'beforeDestroy', container);\n\t\t\t\tpatchHook(this, 'destroyed', container);\n\t\t\t},\n\t\t});\n\t},\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/Vue.js","import Vuebindings from './Vue';\nexport { default as Container } from './Container';\n\nexport default Vuebindings;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///vuec.js","webpack:///webpack/bootstrap ee1215d4cb35c9e91271","webpack:///./src/Container.js","webpack:///./src/Vue.js","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_toConsumableArray","arr","Array","isArray","arr2","length","from","_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","descriptor","writable","key","protoProps","staticProps","Container","$cache","Map","set","has","delete","entries","func","self","arguments","undefined","extracted","toString","match","indexOf","console","warn","bind","params","replace","split","map","resolve","apply","concat","default","_interopRequireDefault","obj","_Container","_Container2","patchHook","$vm","hook","container","hooks","$options","prepare","install","Vue","$ioc","mixin","beforeCreate","_Vue","_Vue2"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,KAAAD,IAEAD,EAAA,KAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA+DA,OAnCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAG,EAAA,SAAAK,GAA2C,MAAAA,IAG3CR,EAAAS,EAAA,SAAAf,EAAAgB,EAAAC,GACAX,EAAAY,EAAAlB,EAAAgB,IACAG,OAAAC,eAAApB,EAAAgB,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAX,EAAAkB,EAAA,SAAAvB,GACA,GAAAgB,GAAAhB,KAAAwB,WACA,WAA2B,MAAAxB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,EAAAC,IAGtDrB,EAAAwB,EAAA,GAGAxB,IAAAyB,EAAA,KDgBM,SAAU9B,EAAQD,EAASM,GAEjC,YASA,SAAS0B,GAAmBC,GAAO,GAAIC,MAAMC,QAAQF,GAAM,CAAE,IAAK,GAAIxB,GAAI,EAAG2B,EAAO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9E,KAAM,YAAaiF,SHsL3B,SAAUpF,EAAQD,EAASM,GAEjC,YAqBA,SAASwE,GAAuBC,GAAO,MAAOA,IAAOA,EAAItD,WAAasD,GAAQF,QAASE,GAlBvF5D,OAAOC,eAAepB,EAAS,cAC7Bc,OAAO,IAETd,EAAQoD,UAAYU,MAEpB,IAAIkB,GAAa1E,EAAoB,EAErCa,QAAOC,eAAepB,EAAS,aAC7BsB,YAAY,EACZC,IAAK,WACH,MAAOuD,GAAuBE,GI1NzBH,UADT,IAAAiB,GAAAxF,EAAA,GJiOIyF,EAAQjB,EAAuBgB,EAInC9F,GAAQ6E,QAAUkB,EAAMlB","file":"vuec.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"vuec\"] = factory();\n\telse\n\t\troot[\"vuec\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"vuec\"] = factory();\n\telse\n\t\troot[\"vuec\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 2);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Container = function () {\n\tfunction Container() {\n\t\t_classCallCheck(this, Container);\n\n\t\tthis.$cache = new Map();\n\t}\n\n\t_createClass(Container, [{\n\t\tkey: 'register',\n\t\tvalue: function register(name, value) {\n\t\t\tthis.$cache.set(name, value);\n\t\t}\n\t}, {\n\t\tkey: 'unregister',\n\t\tvalue: function unregister(name) {\n\t\t\tif (this.$cache.has(name)) {\n\t\t\t\tthis.$cache.delete(name);\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: 'has',\n\t\tvalue: function has(name) {\n\t\t\treturn this.$cache.has(name);\n\t\t}\n\t}, {\n\t\tkey: 'bindings',\n\t\tvalue: function bindings() {\n\t\t\treturn this.$cache.entries();\n\t\t}\n\t}, {\n\t\tkey: 'resolve',\n\t\tvalue: function resolve(name) {\n\t\t\tif (this.$cache.has(name)) {\n\t\t\t\treturn this.$cache.get(name);\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t}\n\t}, {\n\t\tkey: 'prepare',\n\t\tvalue: function prepare(func) {\n\t\t\tvar self = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n\t\t\tvar extracted = func.toString().match(/^function\\s*[^(]*\\(\\s*([^)]*)\\)/m);\n\t\t\tif (extracted === null) {\n\t\t\t\tif (func.toString().indexOf('function') === -1) {\n\t\t\t\t\tconsole.warn('Parsing ' + func.name + ' failed:', 'ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).', 'Use a transpiler or ES5 notation.');\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('Extraction failed for ' + func.name);\n\t\t\t\t}\n\t\t\t\treturn func.bind(self);\n\t\t\t}\n\n\t\t\tvar params = extracted[1].replace(/ /g, '').split(',').map(this.resolve.bind(this));\n\n\t\t\treturn func.bind.apply(func, [self].concat(_toConsumableArray(params)));\n\t\t}\n\t}]);\n\n\treturn Container;\n}();\n\nexports.default = Container;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _Container = __webpack_require__(0);\n\nvar _Container2 = _interopRequireDefault(_Container);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar patchHook = function patchHook($vm, hook, container) {\n\tvar hooks = $vm.$options[hook];\n\tif (hooks && hooks.length > 0) {\n\t\thooks[hooks.length - 1] = container.prepare(hooks[hooks.length - 1], $vm);\n\t}\n};\n\nvar container = new _Container2.default(); // eslint-disable-line\nexports.default = {\n\tinstall: function install(Vue) {\n\t\tVue.prototype.$ioc = container;\n\t\tVue.$ioc = container;\n\t\tVue.mixin({\n\t\t\tbeforeCreate: function beforeCreate() {\n\t\t\t\tpatchHook(this, 'created', container);\n\t\t\t\tpatchHook(this, 'beforeMount', container);\n\t\t\t\tpatchHook(this, 'mounted', container);\n\t\t\t\tpatchHook(this, 'beforeUpdate', container);\n\t\t\t\tpatchHook(this, 'updated', container);\n\t\t\t\tpatchHook(this, 'beforeDestroy', container);\n\t\t\t\tpatchHook(this, 'destroyed', container);\n\t\t\t}\n\t\t});\n\t}\n};\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Container = undefined;\n\nvar _Container = __webpack_require__(0);\n\nObject.defineProperty(exports, 'Container', {\n enumerable: true,\n get: function get() {\n return _interopRequireDefault(_Container).default;\n }\n});\n\nvar _Vue = __webpack_require__(1);\n\nvar _Vue2 = _interopRequireDefault(_Vue);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = _Vue2.default;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// vuec.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ee1215d4cb35c9e91271","export default class Container {\n\tconstructor() {\n\t\tthis.$cache = new Map();\n\t}\n\n\tregister(name, value) {\n\t\tthis.$cache.set(name, value);\n\t}\n\n\tunregister(name) {\n\t\tif (this.$cache.has(name)) {\n\t\t\tthis.$cache.delete(name);\n\t\t}\n\t}\n\n\thas(name) {\n\t\treturn this.$cache.has(name);\n\t}\n\n\tbindings() {\n\t\treturn this.$cache.entries();\n\t}\n\n\tresolve(name) {\n\t\tif (this.$cache.has(name)) {\n\t\t\treturn this.$cache.get(name);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprepare(func, self = null) {\n\t\tconst extracted = func.toString().match(/^function\\s*[^(]*\\(\\s*([^)]*)\\)/m);\n\t\tif (extracted === null) {\n\t\t\tif (func.toString().indexOf('function') === -1) {\n\t\t\t\tconsole.warn(`Parsing ${func.name} failed:`,\n\t\t\t\t\t'ES6 method notation is not supported yet (see https://goo.gl/YKfg9R).',\n\t\t\t\t\t'Use a transpiler or ES5 notation.');\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Extraction failed for ${func.name}`);\n\t\t\t}\n\t\t\treturn func.bind(self);\n\t\t}\n\n\t\tconst params = extracted[1]\n\t\t\t.replace(/ /g, '')\n\t\t\t.split(',')\n\t\t\t.map(this.resolve.bind(this));\n\n\t\treturn func.bind(self, ...params);\n\t}\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/Container.js","import Container from './Container';\n\nconst patchHook = ($vm, hook, container) => {\n\tconst hooks = $vm.$options[hook];\n\tif (hooks && hooks.length > 0) {\n\t\thooks[hooks.length - 1] = container.prepare(hooks[hooks.length - 1], $vm);\n\t}\n};\n\nconst container = new Container; // eslint-disable-line\nexport default {\n\tinstall(Vue) {\n\t\tVue.prototype.$ioc = container;\n\t\tVue.$ioc = container;\n\t\tVue.mixin({\n\t\t\tbeforeCreate() {\n\t\t\t\tpatchHook(this, 'created', container);\n\t\t\t\tpatchHook(this, 'beforeMount', container);\n\t\t\t\tpatchHook(this, 'mounted', container);\n\t\t\t\tpatchHook(this, 'beforeUpdate', container);\n\t\t\t\tpatchHook(this, 'updated', container);\n\t\t\t\tpatchHook(this, 'beforeDestroy', container);\n\t\t\t\tpatchHook(this, 'destroyed', container);\n\t\t\t},\n\t\t});\n\t},\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/Vue.js","import Vuebindings from './Vue';\nexport { default as Container } from './Container';\n\nexport default Vuebindings;\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""} \ No newline at end of file diff --git a/src/Container.js b/src/Container.js index fbbd611..cac901f 100644 --- a/src/Container.js +++ b/src/Container.js @@ -7,6 +7,20 @@ export default class Container { this.$cache.set(name, value); } + unregister(name) { + if (this.$cache.has(name)) { + this.$cache.delete(name); + } + } + + has(name) { + return this.$cache.has(name); + } + + bindings() { + return this.$cache.entries(); + } + resolve(name) { if (this.$cache.has(name)) { return this.$cache.get(name); diff --git a/tests/container.js b/tests/container.js index be70965..854ed6f 100644 --- a/tests/container.js +++ b/tests/container.js @@ -48,4 +48,29 @@ describe('Container', function() { assert.equal(container.resolve('function')(), 12345); }); }); + describe('#has', function () { + it('Should return false when a binding doesn\'t exist', function () { + const container = new vuec.Container(); + assert.equal(container.has('foo'), false); + }); + it('Should return true when a binding exists', function () { + const container = new vuec.Container(); + container.register('foo', 'foobar'); + assert.equal(container.has('foo'), true); + }); + }); + describe('#unregister', function () { + it('Should remove a registered binding', function () { + const container = new vuec.Container(); + container.register('foo', 'Hello world'); + assert.equal(container.has('foo'), true); + container.unregister('foo'); + assert.equal(container.has('foo'), false); + }); + it('Should ignore an unregistered binding', function () { + const container = new vuec.Container(); + container.unregister('foo'); + assert.equal(container.has('foo'), false); + }); + }); });