{"_id":"subscription","_rev":"17-a503476fdf69104b067c7c4d1bdcb763","name":"subscription","time":{"modified":"2022-06-27T01:51:26.915Z","created":"2013-10-28T00:41:04.463Z","0.0.0":"2013-10-28T00:41:07.245Z","0.0.1":"2013-11-02T08:56:01.658Z","0.0.2":"2013-11-02T11:29:34.753Z","0.0.5":"2013-11-10T02:51:04.108Z","2.0.0":"2016-03-22T23:51:52.010Z","0.0.1-security":"2016-03-23T22:24:23.898Z","3.0.0":"2016-06-09T20:52:36.141Z"},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}],"dist-tags":{"latest":"3.0.0"},"readme":"# Subscription\n\nA subscription is an object that emits events. Rather than overloading\nobjects with other roles to emit events, and having a single object\nemit several types, as in `.addEventListener` style events, a\nsubscription is a dedicated object representing a single event source.\n\n    // Instead of adding listeners by string type\n    object.addEventListener(\"message\", m => { ... })\n    \n    // You create a subscription object when you construct the base\n    // object...\n    class MyObject {\n      constructor() {\n        this.message = new Subscription\n        ...\n      }\n    }\n    \n    // ...and add handlers directly to that:\n    myObject.message.add(m => { ... })\n\nThe interface of a subscription is roughly based on\n[`js-signals`](https://millermedeiros.github.io/js-signals/), but\nwhereas `js-signals` have a fixed dispatch algorithm, subscriptions\ncome in several forms.\n\nThe perceived benefits of subscriptions are that they are easier to\ncheck statically (instead of a single method dispatching on a bunch of\nstrings, you have actual objects representing your event types, each\nof which expects a single type of handler function), and lead to more\nexplicit code.\n\n## Distribution\n\nThis module is licensed under an MIT license. The recommended way to\ninstall it is with [NPM](https://www.npmjs.com/package/subscription).\n\n## API\n\n### class `Subscription`\n\nA subscription is an object that you can add subscribers (functions)\nto, which will be called every time the subscription is dispatched.\n\n**`add`**`(f: Function, priority: ?number)`\n\nAdd a function of the appropriate type for this subscription to be\ncalled whenever the subscription is dispatched. When `priority` is\nprovided (default is zero), it determines when the function is called\nrelative to other handlers—those with a high priority come first.\n\n**`addOnce`**`(f: Function, priority: ?number)`\n\nAdd a function to be called once, the next time this subscription is\ndispatched.\n\n**`remove`**`(f: Function)`\n\nRemove the given subscriber from the subscription.\n\n**`hasHandler`**`() → bool`\n\nReturns true if there are any functions registered with this\nsubscription.\n\n**`dispatch`**`(...args: [any])`\n\nCall all handlers for this subscription with the given arguments.\n\n### class `PipelineSubscription` extends `Subscription`\n\nA type of subscription that passes the value it is dispatched with\nthrough all its subscribers, feeding the return value from each\nsubcriber to the next one, and finally returning the result.\n\n**`dispatch`**`(value: any) → any`\n\nRun all handlers on the given value, returning the result.\n\n### class `StoppableSubscription` extends `Subscription`\n\nA stoppable subscription is a subscription that stops calling further\nsubscribers as soon as a subscriber returns a truthy value.\n\n**`dispatch`**`(...args: [any]) → any`\n\nCall handlers with the given arguments. When one of them returns a\ntruthy value, immediately return that value.\n\n### class `DOMSubscription` extends `Subscription`\n\nA DOM subscription can be used to register intermediate handlers for\nDOM events. It will call subscribers until one of them returns a\ntruthy value or calls `preventDefault` on the DOM event.\n\n**`dispatch`**`(event: Event) → bool`\n\nRun handlers on the given DOM event until one of them returns a truty\nvalue or prevents the event's default behavior. Returns true if the\nevent was handled.\n","versions":{"2.0.0":{"name":"subscription","version":"2.0.0","description":"","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"ISC","_id":"subscription@2.0.0","_shasum":"c6e9a8f1c9a4be4a5ff7960b34d6e186b2b1bd74","_from":".","_npmVersion":"3.7.2","_nodeVersion":"4.3.0","_npmUser":{"name":"nj48","email":"spam@njohnson.me"},"dist":{"shasum":"c6e9a8f1c9a4be4a5ff7960b34d6e186b2b1bd74","tarball":"https://registry.npmjs.org/subscription/-/subscription-2.0.0.tgz","integrity":"sha512-jRC3vH44seKYlZNuHrffP/KEMhZv4xTlogUg0YGs5MnnfbOrKYW3t1HdUgwf2cA0CKulvbzxbi5uDNHGxiKyvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQ9taXu41BBfrTMyIzMBPEtnaZsDXAXDwt6kILIvzogwIhALi9Va350rzQrYA3JqjKbNjlC0Av2AQ7QmB/BmQO/gKd"}]},"maintainers":[{"name":"nj48","email":"spam@njohnson.me"}],"directories":{}},"0.0.1-security":{"name":"subscription","version":"0.0.1-security","description":"This package name is not currently in use, but was formerly occupied by a popular package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/npm/security-holder.git"},"keywords":[],"author":"","license":"ISC","bugs":{"url":"https://github.com/npm/security-holder/issues"},"homepage":"https://github.com/npm/security-holder#readme","gitHead":"d1719e2a152734ed854065de56039770c9104d83","_id":"subscription@0.0.1-security","_shasum":"9fb69f48b8615c491427842a3910961d14fcc6f8","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.1.0","_npmUser":{"name":"npm","email":"npm@npmjs.com"},"dist":{"shasum":"9fb69f48b8615c491427842a3910961d14fcc6f8","tarball":"https://registry.npmjs.org/subscription/-/subscription-0.0.1-security.tgz","integrity":"sha512-/3fBeTvpinHz6UU/skY89hew6hqKGw/i67K0L5QmaBVxHsaUQJEAivSQszRYoD8HZdNfWf540noCf3L6JjMPmw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIERLQhwDiJ+j2FbaqqKOuGUlALo4gyPJtNANwTHpfD3RAiEA7kI3LNK9XZD5zTXb9ccUBRbC9RNc2dq8K1SOrFAJMD4="}]},"maintainers":[{"name":"nj48","email":"spam@njohnson.me"}],"directories":{}},"0.0.0":{"name":"subscription","version":"0.0.0","description":"Library to store and manage paid subscriptions via Stripe and LevelDB","main":"index.js","scripts":{"test":"fox"},"dependencies":{"level-json":"*","stripe":"*","property":"0.0.0","english-time":"0.0.8","local-debug":"0.0.0"},"devDependencies":{"fox":"*","call-all":"*"},"keywords":["customers","payments","stripe","subscription"],"repository":{"url":"git@github.com:azer/subscription.git","type":"git"},"author":"Azer Koçulu <azer@kodfabrik.com>","license":"BSD","_id":"subscription@0.0.0","_npmVersion":"0.0.0-fake","_nodeVersion":"0.0.0-fake","_shasum":"6ecfbae3b3a3c1b0e66d921132f04f8fb32747ba","_npmUser":{"name":"npm","email":"support@npmjs.com"},"_from":".","dist":{"shasum":"6ecfbae3b3a3c1b0e66d921132f04f8fb32747ba","tarball":"https://registry.npmjs.org/subscription/-/subscription-0.0.0.tgz","integrity":"sha512-0poVdcrnHdNlOoUGC0umKlZ2cQBT+PWuN/tOopIFq77J2Wqhc2MR6zkuSDjZsPn8B4ueJ6SyENplrl6p7g0Gdg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGL168Z7QB+BG29jJPfaOdm65FDJ3ezxsgVIw7cgy7+3AiADrS42eliQhpl6x4GsnTI6VLGGlEAqZSWfaNE8Sne7FA=="}]},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}]},"0.0.1":{"name":"subscription","version":"0.0.1","description":"Library to store and manage paid subscriptions via Stripe and LevelDB","main":"index.js","scripts":{"test":"fox"},"dependencies":{"level-json":"*","stripe":"*","property":"0.0.0","english-time":"0.0.8","local-debug":"0.0.0","new-error":"0.0.0"},"devDependencies":{"fox":"*","call-all":"*","map":"*","iter":"*"},"keywords":["customers","payments","stripe","subscription"],"repository":{"url":"git@github.com:azer/subscription.git","type":"git"},"author":"Azer Koçulu <azer@kodfabrik.com>","license":"BSD","_id":"subscription@0.0.1","_npmVersion":"0.0.0-fake","_nodeVersion":"0.0.0-fake","_shasum":"ed32ad11a734cf6841e869c25677f4f70ae6b333","_npmUser":{"name":"npm","email":"support@npmjs.com"},"_from":".","dist":{"shasum":"ed32ad11a734cf6841e869c25677f4f70ae6b333","tarball":"https://registry.npmjs.org/subscription/-/subscription-0.0.1.tgz","integrity":"sha512-wP5Lqphynd4ftWUEqhzWfyQCsPwLAV/edFJUN5wr1AfSt+2Z97BJsuzPraTWExu1ZCzvE1wTa6g0ir3gkhp4uA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHlxt0rtYXiQllzsBtGwOmtn2URfUvqYgPQOL8UXulykAiB3FquO36Bu6h/TvdUVoVNX3xczvro7xNy3s3UR19y3jw=="}]},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}]},"0.0.2":{"name":"subscription","version":"0.0.2","description":"Library to store and manage paid subscriptions via Stripe and LevelDB","main":"index.js","scripts":{"test":"fox"},"dependencies":{"level-json":"*","stripe":"*","property":"0.0.0","english-time":"0.0.8","local-debug":"0.0.0","new-error":"0.0.0"},"devDependencies":{"fox":"*","call-all":"*","map":"*","iter":"*"},"keywords":["customers","payments","stripe","subscription"],"repository":{"url":"git@github.com:azer/subscription.git","type":"git"},"author":"Azer Koçulu <azer@kodfabrik.com>","license":"BSD","_id":"subscription@0.0.2","_npmVersion":"0.0.0-fake","_nodeVersion":"0.0.0-fake","_shasum":"9bf4f82635d3ea3bfb35d57b75fcfcb7b3e3ed5d","_npmUser":{"name":"npm","email":"support@npmjs.com"},"_from":".","dist":{"shasum":"9bf4f82635d3ea3bfb35d57b75fcfcb7b3e3ed5d","tarball":"https://registry.npmjs.org/subscription/-/subscription-0.0.2.tgz","integrity":"sha512-9l6YZlSKaotrHd0EBnOj/V0P8ETAeDgrqtkQjqzh7OaIDMbfWv0FItdTesSsJu27jWQB/c/q0sYz4PyT2LqoZA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID22TVn5Cyf1P3JABRasvK7rP3KzHAOCTaKBtT93leDpAiEA0l4CnuLo2lG93Sip2mkQcaVmpko6o/lwSl7GAi6Rq8s="}]},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}]},"0.0.5":{"name":"subscription","version":"0.0.5","description":"Library to store and manage paid subscriptions via Stripe and LevelDB","main":"index.js","scripts":{"test":"fox"},"dependencies":{"level-json":"*","stripe":"*","property":"0.0.0","english-time":"0.0.8","local-debug":"0.0.0","new-error":"0.0.0"},"devDependencies":{"fox":"*","call-all":"*","map":"*","iter":"*"},"keywords":["customers","payments","stripe","subscription"],"repository":{"url":"git@github.com:azer/subscription.git","type":"git"},"author":"Azer Koçulu <azer@kodfabrik.com>","license":"BSD","_id":"subscription@0.0.5","_npmVersion":"0.0.0-fake","_nodeVersion":"0.0.0-fake","_shasum":"1c451fdf6cb03b734f51060101eebced80b19573","_npmUser":{"name":"npm","email":"support@npmjs.com"},"_from":".","dist":{"shasum":"1c451fdf6cb03b734f51060101eebced80b19573","tarball":"https://registry.npmjs.org/subscription/-/subscription-0.0.5.tgz","integrity":"sha512-H1dA3XXiquLsapzFKa0qmCvy9zwFHIuLJfc0D+BlDW5rhDXPOkeIZ7TDm91y94SqXr6XuMiftKnqG/94+i/3ow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFBUAxQJEUn2nMlacoi99ATaAARfRHgnRaVBDLaBXKEAIhAL3cPu16fM3jkXotzsQZIv1YZXuE/G4MamZTzHSrY4d8"}]},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}]},"3.0.0":{"name":"subscription","version":"3.0.0","description":"Simple abstraction for first-class event emitters","main":"index.js","repository":{"type":"git","url":"git+https://github.com/marijnh/subscription.git"},"keywords":["event","signal","listener","emitter"],"author":{"name":"Marijn Haverbeke","email":"marijnh@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/marijnh/subscription/issues"},"homepage":"https://github.com/marijnh/subscription#readme","gitHead":"aa96bc71a1684013bf4a31d08f0c80caa75e882f","_id":"subscription@3.0.0","scripts":{},"_shasum":"0e3169263ea9889a7d71aa34ff4465f2d1ac26e2","_from":".","_npmVersion":"3.9.3","_nodeVersion":"6.2.1","_npmUser":{"name":"marijn","email":"marijnh@gmail.com"},"maintainers":[{"name":"npm","email":"npm@npmjs.com"}],"dist":{"shasum":"0e3169263ea9889a7d71aa34ff4465f2d1ac26e2","tarball":"https://registry.npmjs.org/subscription/-/subscription-3.0.0.tgz","integrity":"sha512-W0xDn7QYcDo9HhHqsmoj4U8pJVqYqnggBUoJixAQXc2MoX71Ef551Np9tyTMX+9Ta6br9MdTbvdpQ/+JP31uPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID8TRunouHSq8aEIms8+YkeqwO6wLye+CifO5+wvxVX8AiEAm30I6R7pAnmwbXSOb8wtrfsYyAjb8IBnu/5Ni+ZxtbA="}]},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/subscription-3.0.0.tgz_1465505553472_0.25156067544594407"}}},"license":"MIT","readmeFilename":"README.md","description":"Simple abstraction for first-class event emitters","homepage":"https://github.com/marijnh/subscription#readme","keywords":["event","signal","listener","emitter"],"repository":{"type":"git","url":"git+https://github.com/marijnh/subscription.git"},"bugs":{"url":"https://github.com/marijnh/subscription/issues"},"author":{"name":"Marijn Haverbeke","email":"marijnh@gmail.com"}}