Comparing version 1.0.1 to 1.0.2
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Model_O = f()}})(function(){var define,module,exports;return (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(require,module,exports){ | ||
'use strict'; | ||
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; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/* | ||
@@ -8,39 +18,51 @@ | ||
const EventEmitter = require('wolfy87-eventemitter'); | ||
var EventEmitter = require('wolfy87-eventemitter'); | ||
class Model_O extends EventEmitter { | ||
var Model_O = function (_EventEmitter) { | ||
_inherits(Model_O, _EventEmitter); | ||
constructor(obj) { | ||
super(); | ||
this._properties = Object.assign({}, obj); // clone just to be safe | ||
Object.keys(this._properties).forEach(key => { | ||
this.define(key, this._properties[key]); | ||
function Model_O(obj) { | ||
_classCallCheck(this, Model_O); | ||
var _this = _possibleConstructorReturn(this, (Model_O.__proto__ || Object.getPrototypeOf(Model_O)).call(this)); | ||
_this._properties = Object.assign({}, obj); // clone just to be safe | ||
Object.keys(_this._properties).forEach(function (key) { | ||
_this.define(key, _this._properties[key]); | ||
}); | ||
return _this; | ||
} | ||
toJSON() { | ||
return this._properties; | ||
} | ||
_createClass(Model_O, [{ | ||
key: 'toJSON', | ||
value: function toJSON() { | ||
return this._properties; | ||
} | ||
}, { | ||
key: 'define', | ||
value: function define(key, defaultValue) { | ||
define(key, defaultValue) { | ||
this._properties[key] = defaultValue; | ||
this._properties[key] = defaultValue; | ||
Object.defineProperty(this, key, { | ||
get: function get() { | ||
return this._properties[key]; | ||
}, | ||
set: function set(newValue) { | ||
// ignore if value is unchanged | ||
// only works for primitives | ||
if (newValue === this._properties[key]) return; | ||
var oldValue = this._properties[key]; | ||
this._properties[key] = newValue; | ||
this.emit(key, newValue, oldValue, key); | ||
}, | ||
Object.defineProperty(this, key, { | ||
get() { | ||
return this._properties[key]; | ||
}, | ||
set(newValue) { | ||
// ignore if value is unchanged | ||
// only works for primitives | ||
if (newValue === this._properties[key]) return; | ||
var oldValue = this._properties[key]; | ||
this._properties[key] = newValue; | ||
this.emit(key, newValue, oldValue, key); | ||
}, | ||
enumerable: true | ||
}); | ||
} | ||
} | ||
enumerable: true | ||
}); | ||
} | ||
}]); | ||
return Model_O; | ||
}(EventEmitter); | ||
module.exports = Model_O; | ||
@@ -47,0 +69,0 @@ |
{ | ||
"name": "model-o", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Simple observable model. Fires change events when values are assigned.", | ||
@@ -8,3 +8,3 @@ "main": "dist/model-o.min.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "browserify --standalone Model_O ./model-o.js -o ./dist/model-o.min.js -t [ babelify --presets [ es2016 ] ]" | ||
"build": "browserify --standalone Model_O ./model-o.js -o ./dist/model-o.min.js -t [ babelify --presets [ es2015 ] ]" | ||
}, | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"devDependencies": { | ||
"babel-preset-es2016": "^6.16.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babelify": "^7.3.0", | ||
@@ -29,0 +29,0 @@ "wolfy87-eventemitter": "^5.1.0" |
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
27624
521