UNPKG

nes-emu

Version:

A NES emulator

27 lines (26 loc) 811 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _lodash = _interopRequireDefault(require("lodash")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** A mixin for anything that has a context. */ var _default = exports.default = { /** Applies the mixin. */ apply(obj) { _lodash.default.defaults(obj, _lodash.default.omit(this, "apply")); }, /** The current execution context. */ context: null, /** Loads an execution context. */ loadContext(context) { this.context = context; if (this.onLoad) this.onLoad(context); return this; }, /** Asserts that a current context exists. */ requireContext() { if (!this.context) throw new Error("Execution context not found."); } };