Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

object.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. 'use strict'; // A simple class system, more documentation to come
  2. 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); } }
  3. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  5. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6. var EventEmitter = require('events');
  7. var lib = require('./lib');
  8. function parentWrap(parent, prop) {
  9. if (typeof parent !== 'function' || typeof prop !== 'function') {
  10. return prop;
  11. }
  12. return function wrap() {
  13. // Save the current parent method
  14. var tmp = this.parent; // Set parent to the previous method, call, and restore
  15. this.parent = parent;
  16. var res = prop.apply(this, arguments);
  17. this.parent = tmp;
  18. return res;
  19. };
  20. }
  21. function extendClass(cls, name, props) {
  22. props = props || {};
  23. lib.keys(props).forEach(function (k) {
  24. props[k] = parentWrap(cls.prototype[k], props[k]);
  25. });
  26. var subclass = /*#__PURE__*/function (_cls) {
  27. _inheritsLoose(subclass, _cls);
  28. function subclass() {
  29. return _cls.apply(this, arguments) || this;
  30. }
  31. _createClass(subclass, [{
  32. key: "typename",
  33. get: function get() {
  34. return name;
  35. }
  36. }]);
  37. return subclass;
  38. }(cls);
  39. lib._assign(subclass.prototype, props);
  40. return subclass;
  41. }
  42. var Obj = /*#__PURE__*/function () {
  43. function Obj() {
  44. // Unfortunately necessary for backwards compatibility
  45. this.init.apply(this, arguments);
  46. }
  47. var _proto = Obj.prototype;
  48. _proto.init = function init() {};
  49. Obj.extend = function extend(name, props) {
  50. if (typeof name === 'object') {
  51. props = name;
  52. name = 'anonymous';
  53. }
  54. return extendClass(this, name, props);
  55. };
  56. _createClass(Obj, [{
  57. key: "typename",
  58. get: function get() {
  59. return this.constructor.name;
  60. }
  61. }]);
  62. return Obj;
  63. }();
  64. var EmitterObj = /*#__PURE__*/function (_EventEmitter) {
  65. _inheritsLoose(EmitterObj, _EventEmitter);
  66. function EmitterObj() {
  67. var _this2;
  68. var _this;
  69. _this = _EventEmitter.call(this) || this; // Unfortunately necessary for backwards compatibility
  70. (_this2 = _this).init.apply(_this2, arguments);
  71. return _this;
  72. }
  73. var _proto2 = EmitterObj.prototype;
  74. _proto2.init = function init() {};
  75. EmitterObj.extend = function extend(name, props) {
  76. if (typeof name === 'object') {
  77. props = name;
  78. name = 'anonymous';
  79. }
  80. return extendClass(this, name, props);
  81. };
  82. _createClass(EmitterObj, [{
  83. key: "typename",
  84. get: function get() {
  85. return this.constructor.name;
  86. }
  87. }]);
  88. return EmitterObj;
  89. }(EventEmitter);
  90. module.exports = {
  91. Obj: Obj,
  92. EmitterObj: EmitterObj
  93. };