UNPKG

hap-nodejs

Version:

HAP-NodeJS is a Node.js implementation of HomeKit Accessory Server.

27 lines 847 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.once = once; var tslib_1 = require("tslib"); /** * Function wrapper to ensure a function/callback is only called once. * * @group Utils */ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type function once(func) { var called = false; return (function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (called) { throw new Error("This callback function has already been called by someone else; it can only be called one time."); } else { called = true; return func.apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false)); } }); } //# sourceMappingURL=once.js.map