@jalik/observer
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,85 +0,35 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var _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; }; }(); | ||
var _observer = require('./observer'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _observer2 = _interopRequireDefault(_observer); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var Observer = exports.Observer = function () { | ||
function Observer(context) { | ||
_classCallCheck(this, Observer); | ||
this._context = context; | ||
this._events = {}; | ||
} | ||
_createClass(Observer, [{ | ||
key: "attach", | ||
value: function attach(event, listener) { | ||
if (typeof event !== "string") { | ||
throw new TypeError("Event is not a string"); | ||
} | ||
if (typeof listener !== "function") { | ||
throw new TypeError("Callback is not a function"); | ||
} | ||
if (!this._events[event]) { | ||
this._events[event] = []; | ||
} | ||
this._events[event].push(listener); | ||
} | ||
}, { | ||
key: "detach", | ||
value: function detach(event, listener) { | ||
if (this._events[event]) { | ||
if (typeof listener === "function") { | ||
var index = this._events[event].indexOf(listener); | ||
this._events[event].splice(index, 1); | ||
} else { | ||
delete this._events[event]; | ||
} | ||
} | ||
} | ||
}, { | ||
key: "notify", | ||
value: function notify() { | ||
var args = Array.prototype.slice.call(arguments); | ||
if (args.length < 1) { | ||
throw new TypeError("Wrong number of arguments"); | ||
} | ||
var event = args.shift(); | ||
if (typeof event !== "string") { | ||
throw new TypeError("Event is not a string"); | ||
} | ||
if (this._events[event] instanceof Array) { | ||
for (var i = 0; i < this._events[event].length; i += 1) { | ||
this._events[event][i].apply(this._context, args); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "setContext", | ||
value: function setContext(context) { | ||
this._context = context; | ||
} | ||
}]); | ||
return Observer; | ||
}(); | ||
exports.default = Observer; | ||
exports.default = _observer2.default; /* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2018 Karl STEIN | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ |
{ | ||
"name": "@jalik/observer", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A library to observe events and trigger callbacks.", | ||
@@ -12,3 +12,3 @@ "license": "MIT", | ||
"author": { | ||
"name": "Karl STEIN", | ||
"name": "Karl Stein", | ||
"email": "karl.stein.pro@gmail.com", | ||
@@ -27,21 +27,31 @@ "url": "https://github.com/jalik" | ||
"build": "./node_modules/.bin/gulp build", | ||
"build:prod": "./node_modules/.bin/gulp prepublish", | ||
"package": "./node_modules/.bin/webpack && ./node_modules/.bin/webpack -p", | ||
"prepare": "npm run build:prod && npm test", | ||
"bundle": "./node_modules/.bin/webpack -p", | ||
"lint": "./node_modules/.bin/eslint .", | ||
"lint-fix": "./node_modules/.bin/eslint --fix .", | ||
"prepare": "./node_modules/.bin/gulp prepare", | ||
"prepublishOnly": "npm test", | ||
"test": "jest", | ||
"test": "./node_modules/.bin/jest", | ||
"watch": "./node_modules/.bin/gulp watch" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-loader": "^7.1.4", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"gulp": "^3.9.1", | ||
"babel-preset-env": "^1.7.0", | ||
"del": "^3.0.0", | ||
"eslint": "^4.19.1", | ||
"eslint-config-airbnb": "^16.1.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"eslint-plugin-jest": "^21.17.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.3", | ||
"eslint-plugin-react": "^7.9.1", | ||
"gulp": "^4.0.0", | ||
"gulp-babel": "^7.0.1", | ||
"gulp-eslint": "^4.0.2", | ||
"gulp-strip-comments": "^2.5.2", | ||
"gulp-watch": "^5.0.0", | ||
"jest": "^21.2.1", | ||
"webpack": "^3.11.0" | ||
"jest": "^23.1.0", | ||
"webpack": "^4.12.0", | ||
"webpack-cli": "^3.0.3" | ||
} | ||
} |
@@ -74,11 +74,4 @@ # Observer | ||
### v1.0.2 | ||
- Exports `Observer` using ES6 default export | ||
History of releases is in the [changelog](./CHANGELOG.md). | ||
### v1.0.1 | ||
- Updates documentation | ||
### v1.0.0 | ||
- First public release | ||
## License | ||
@@ -85,0 +78,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11556
6
141
19
83
1