UNPKG

spiritjs

Version:

The animation toolkit for the web

83 lines (60 loc) 3.22 kB
'use strict'; Object.defineProperty(exports, "__esModule", { 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; }; }(); exports.ArrayLike = ArrayLike; var _context = require('./context'); 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; } function ArrayLike(targetClass, list) { return function (_targetClass) { _inherits(_class, _targetClass); _createClass(_class, null, [{ key: 'name', get: function get() { return targetClass.name; } }]); function _class() { var _ref; var _ret2; _classCallCheck(this, _class); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var _this = _possibleConstructorReturn(this, (_ref = _class.__proto__ || Object.getPrototypeOf(_class)).call.apply(_ref, [this].concat(args))); if ((0, _context.isBrowser)() && !('Proxy' in window)) { var _ret; return _ret = _this, _possibleConstructorReturn(_this, _ret); } _this[Symbol.iterator] = function () { var index = -1; var l = this[list]; return { next: function next() { return { value: l[++index], done: !(index in l) }; } }; }; return _ret2 = new Proxy(_this, { get: function get(target, key, receiver) { var isIndex = false; try { isIndex = Number.isInteger(parseInt(key)); } catch (err) {} if (isIndex) { return _this[list][key]; } if (key === Symbol.iterator) { return _this[Symbol.iterator]; } else { return Reflect.get(_this, key, receiver); } } }), _possibleConstructorReturn(_this, _ret2); } return _class; }(targetClass); }