UNPKG

513 BJavaScriptView Raw
1"use strict";
2
3// Copyright 2017-2018 Jaco Greeff
4// This software may be modified and distributed under the terms
5// of the ISC license. See the LICENSE file for details.
6module.exports = async function unsubscribe(self, _, id) {
7 const method = self.subscriptionMap[id];
8 self.l.debug(() => ['unsubscribe', id, method]);
9
10 if (!method) {
11 throw new Error(`Unable to find subscription for ${id}`);
12 }
13
14 delete self.subscriptionMap[id];
15 delete self.subscriptions[method].callbacks[id];
16 return true;
17};
\No newline at end of file