{"_id":"@carlosvpi/flux","_rev":"3-113860acf1b302bd1e1ce0c049533477","name":"@carlosvpi/flux","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.0":{"name":"@carlosvpi/flux","version":"0.0.0","description":"Reactive programming made easy","main":"index.js","repository":{"type":"git","url":"git+https://github.com/carlosvpi/flux.git"},"author":{"name":"CarlosVazPI","email":"carlos.vazpi@gmail.com"},"license":"MIT","devDependencies":{"mocha":"^9.0.3"},"scripts":{"test":"mocha index.test.js"},"gitHead":"49cf8a545c43b527bbd8e3951143f328cbef361f","bugs":{"url":"https://github.com/carlosvpi/flux/issues"},"homepage":"https://github.com/carlosvpi/flux#readme","_id":"@carlosvpi/flux@0.0.0","_nodeVersion":"16.17.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-7b6z/fMe67GKCEnEbf70iLBi3WXCZZfeK93uZzcWvHiTnQFzUaQ/8ZvyJ4elgm+bO6YU0j9qeJoQLZ1/TP9HsA==","shasum":"a14a79fdaf7414c691c64cea7347b7cc3720e4b1","tarball":"https://registry.npmjs.org/@carlosvpi/flux/-/flux-0.0.0.tgz","fileCount":8,"unpackedSize":21111,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEguO75KON9ht+cOLE++zB9uByt0YquifMkq3oWiCLM/AiEAx9Azq0ZWaDvsUX6Gb3t6RfAm0XPxctvlbCRgMBd3y0I="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzFYgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmriDw//ZH+wReZg3SH+Ul7YCm1n79fKMR41EGZ+5hx/DISNi5vC9U7R\r\nbiCa58Qra/OH6Edqprz1BhMAnHOUVsXp7QMNXdBTzF/HoRzbSHxNtfY4bnsp\r\ngRhMNGoFvZQMy0oTiWCJaGtOW/pwaZAUkx048e2OQIQDDNULcF0/hc37fWWK\r\nsC3YLwPYOxeub4tQiVfPJr/WkIW3U3BtyAlIYjtC8hBFAkDyA+Tpqlnm4GFu\r\nVOFog1znS+Nh9yW8EZ9ViyqE0fg3linjCNV/cI2pyO4jagt4PhIwwwiGmsZM\r\niKudlzfK1Sim2w4ewE7++bE2S4kd+y3uHILz0zmWjS+hAwmNADNGsXh1bayL\r\nUmfc0Mef47QbeoE7HIgB1lF3EbEjr3jm+XwYWaPCUP9DNBppCPX0wH3LUWJi\r\nLSnOsf/+kKwCfAqGBhgMIRTlyCV1HO3UN0nDA1KKqEbSqREcjsB+4vanK/+0\r\nvKUXucMQ63dp7GO2Y1sJtNanNnOjDS0upFB4y2tGn4j7BMVUDeqe+ctr/GK+\r\ndNWgyy5BazEtEDQSG45wWVLrcKF/MdL88p2A3sbwImF7Y0lKX8vyjzBAbYBg\r\nproEWplgeAfvW/ccEenPzLq8hVCm19mstexNc4sJ0I4ZAPqVfOQJE8S+fPYs\r\nn196QG9IU3PrPjo/2zkXNTbyF6gKrcIHeX8=\r\n=6eM4\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"},"directories":{},"maintainers":[{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flux_0.0.0_1674335776292_0.42074137120081945"},"_hasShrinkwrap":false},"0.0.1":{"name":"@carlosvpi/flux","version":"0.0.1","description":"Reactive programming made easy","main":"flux.js","repository":{"type":"git","url":"git+https://github.com/carlosvpi/flux.git"},"author":{"name":"CarlosVazPI","email":"carlos.vazpi@gmail.com"},"license":"MIT","devDependencies":{"mocha":"^9.0.3"},"scripts":{"build":"browserify flux.js --standalone Flux > _temp.js && minify _temp.js > dist/flux.min.js && rm _temp.js","test":"mocha test/flux.test.js"},"gitHead":"ec89def94764c81344c4c9f400152b9e19087fc8","bugs":{"url":"https://github.com/carlosvpi/flux/issues"},"homepage":"https://github.com/carlosvpi/flux#readme","_id":"@carlosvpi/flux@0.0.1","_nodeVersion":"16.17.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-/Hou/kfXyBO9/3b1yXZQnFoXMIJR+nlNKVpZGgoIWCVjrhlMU/xQ4kobZ5qzyA/pOmwFN8S5f/aZqVu6wwACEw==","shasum":"5313210d40cb23cfa8974c563a94adde188db6f0","tarball":"https://registry.npmjs.org/@carlosvpi/flux/-/flux-0.0.1.tgz","fileCount":7,"unpackedSize":21273,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDG8StQ12eUWh3kDbkR3ezxD/DPQ+a2IMav2PbjCYCTpwIhAKTgZXAdIgj+cH+SYsFJI78a8awsES3wzsGUTrlP2BT0"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzHQMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo9IQ//bX0S0MiD4Wv6CFvURmnhUEX2TW9lnnV6buAscKgBrj/cef38\r\nIMnm5o7Glij8hBDwBzRUFbE3wL7X9fL0e4KWIMvGZBV2Tvoi+VIaYhAqzH8+\r\n2zsueinIHOY6ls0mIP7NGwulMEIHSJ5YiT0yIPA5m9YipERmEpWiNtAboBA0\r\npNah+f5QXeEsxJyqZNcaDwExKkjt7bW0mZWRoERqWOxdViZZJ4M2DcdumCX1\r\nmX07iIi3Hq/zX/+l9MLYA1pfVGSrCPrmvw4sxMKgz7uh3pih+JEQkw5EPC1W\r\nDoQV+eJMjLXIsV51AcKVqlYeaOAjRNOnZuDVCwEpP5xWs9xvNlaV9ZxoBOVI\r\ntqqegk6SyuTfIkwhv8WxykJppG/fW3CGZriFaHHA8ZsME0uHMhxSZZu1k7Wg\r\nJZpNr4vsj8bVv1UX2ETU5uAlC3g/ldyypX4bpURxdEmsH+6H2beJxdEvB7Bq\r\nIF4SKWF6+t618O81BpDiBJdBCFuFFoLIYGbKr7cGg9ix37wtJlu4Jd323GIs\r\nZH9ALkthy2Cn9BxTWo8YRsNTPUronGkj/0/ghnyxhlPP8wjOgc+aCPc1Ujwh\r\nQSy3vsRYvXjzTh18LUg/BQxxaLaJShztb9bLZvkqnclT0RsbpPqY2BTw+QcZ\r\nCFShozKD022PpqSqN3VPYBgRDSbc311nP2Q=\r\n=DIKG\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"},"directories":{},"maintainers":[{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flux_0.0.1_1674343435919_0.9036507656701447"},"_hasShrinkwrap":false},"0.0.2":{"name":"@carlosvpi/flux","version":"0.0.2","description":"Reactive programming made easy","main":"flux.js","repository":{"type":"git","url":"git+https://github.com/carlosvpi/flux.git"},"author":{"name":"CarlosVazPI","email":"carlos.vazpi@gmail.com"},"license":"MIT","devDependencies":{"mocha":"^9.0.3"},"scripts":{"build":"browserify flux.js --standalone Flux > _temp.js && minify _temp.js > dist/flux.min.js && rm _temp.js","test":"mocha test/flux.test.js"},"gitHead":"f6e54d03ce372a4220aa024767c7f561758bfb0d","bugs":{"url":"https://github.com/carlosvpi/flux/issues"},"homepage":"https://github.com/carlosvpi/flux#readme","_id":"@carlosvpi/flux@0.0.2","_nodeVersion":"16.17.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-gP2Ltl0lvwcrBh7EC3hKV+C/yTVYlnjjit6xJHHuTIvIvgeh8odSCZixZyOpqwEiXnu17nYDJ61hWkXSp6Jelg==","shasum":"5b2a377d07ae6e0f48dea1e8044cdd53804df866","tarball":"https://registry.npmjs.org/@carlosvpi/flux/-/flux-0.0.2.tgz","fileCount":8,"unpackedSize":25252,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGsMbyFVQtDwkvbD4pCFVtkAvBNFhXeDMMvcd6Cc9s7CAiEAt4YvdNqLsJoBYf0CysJxRkzMLfV1Q7xDMn37IaXeNw8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjzHSwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/0Q/8DfvIh+GjcDGcvdOSgqQvLy6fjcfGIPGnsckEfGq1vHZM9ZUU\r\n3XdMi3BrRWuNJOW6GEyKsgcCTHtvpmPAe3frM7/T6q6tbftXzw3JMr+KdIWa\r\nADNFrL9zMsl60oINrHFet/2qRbnpfRTJs7Mo0mLdzCkt7B+aEfqHb412nfqf\r\nFxdpmL4LshzjIAowsSeuFDDBLSwUhavR176kopxTbWVVOQR2xCJo0fTcrb5k\r\nZuYZbzRirJokjcc1HToiSznV0QPsMCsU9b/Bxz+6t+XDVf51ZSyeDlOo4fTw\r\n9ZgCzhIvnden0nGVLeO1b8DqHUtsFE4/qLEnbrAw81RyDDfsDQWtsdAgBjFa\r\n+VFCQ5eWX87BxEIuW9z276jB8cUFtvVOr/5tOu5syoaMO/bs5UhS3Eszb5rv\r\nZp9C9Y8KeuPWXMD0ziUOus58UV2bQEep7QCsS7RP2CT36Ep6PUdL51D/O54H\r\nqHj1/bJZPytcIv7gICxWg8/wd+JVH8kKb1UNy/vvIghcE0qyKCxHOXgxOxaN\r\nNIfoec6wSJfqj5yavno1Z5kpWDyMLEBVPNL4hwG0MAjqTGs3NIOlGhdCuYMP\r\neV01CUihuLnGJBPStWvBXWEmFSulLP7XMP+Zn2XUJqNtXWW/0LG4dghb1tcy\r\nZdoX801riub983I4ig9LvV2fA8/3ydcEfb8=\r\n=HtNY\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"},"directories":{},"maintainers":[{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flux_0.0.2_1674343599971_0.7771582697555564"},"_hasShrinkwrap":false},"0.0.3":{"name":"@carlosvpi/flux","version":"0.0.3","description":"Reactive programming made easy","main":"flux.js","repository":{"type":"git","url":"git+https://github.com/carlosvpi/flux.git"},"author":{"name":"CarlosVazPI","email":"carlos.vazpi@gmail.com"},"license":"MIT","devDependencies":{"mocha":"^9.0.3"},"scripts":{"build":"browserify flux.js --standalone Flux > _temp.js && minify _temp.js > dist/flux.min.js && rm _temp.js","test":"mocha test/flux.test.js"},"gitHead":"f6e54d03ce372a4220aa024767c7f561758bfb0d","bugs":{"url":"https://github.com/carlosvpi/flux/issues"},"homepage":"https://github.com/carlosvpi/flux#readme","_id":"@carlosvpi/flux@0.0.3","_nodeVersion":"16.17.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-iu01eqdUw7ke5Fui760T1k36ZCTuGoYWOpomPVn2fELxhcsKds50xObsbBP6iYkXHx7bhPKWC6TnEIIvABuQNA==","shasum":"d131ede336031bc363f5a92b94270fe3ae001808","tarball":"https://registry.npmjs.org/@carlosvpi/flux/-/flux-0.0.3.tgz","fileCount":8,"unpackedSize":25636,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAULhmSC/4JVhHbcJgp+nA2WU83A/Z1hi9y2qucSUp6ZAiAXgDycqVPyTGti00HdVT59bTs9YDJdZO2FefLMglhxXw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+3pxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpp4Q//R8YeuJby7np+gj0nCH6/OUPDuKVqiZeWp+2gtCrBW8hWuT+8\r\norLm3XbrPtvbRTrCqSLHf/hpt5wuPdX/EhxjlEB5BeWi6kl+IdtCcQf23I31\r\n6cSeDN+el5LIM3fUSewBPMSSjUy0rTwYUDN1FqXO8j5MVMxwywSeLy/2eZvL\r\nf2GxUfHIlWgUIgLpK4fIK5utY0WmYFyPoKEJoZlXcqoQQvi2fWoxpUpF9Kgn\r\nY/POT3UiUurquNk4hWTA2s39aolFCIQPFDws4sNEQY93AfAYYE9yzXTAfxM1\r\n2rlS4Qj6Jmk9T0+OZBDhXordT7gV4Sywneoj7JEZUnuSqBlyDJl5h97hG71D\r\nwjbeLMhXQw1+qKtyoN9nT+ukcdll3vr4EZEkRZfIADfj86e0rFrsNGyK/WVt\r\n7ED4fyQyI8z4TQz4GyP7aqqGDVreuE7eLshjPQHj7zS2ZOn97vZ3WN/163yy\r\nYFCscj+sf/csY370rAxsJTpJf9i26n+8H7NTK3NMqn2MuFI794h1GebMERTY\r\nunIzbtZezi2lQz7R+oSjO8QNiau0WomO7hLcVC4Kw+Dl7qr93y5jXaGVbUsK\r\njh00Ro3IMXo8GW0w815BPWTBJ4w8slTuHRX34PdEy8ZBATYZYyGNLr43FIZk\r\n7AX17Axu32TSKtZL8iFZ19AH5T0ecCLkMDE=\r\n=j5KR\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"},"directories":{},"maintainers":[{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flux_0.0.3_1677425265688_0.3908656544331841"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-21T21:16:16.240Z","0.0.0":"2023-01-21T21:16:16.519Z","modified":"2023-02-26T15:27:45.974Z","0.0.1":"2023-01-21T23:23:56.096Z","0.0.2":"2023-01-21T23:26:40.139Z","0.0.3":"2023-02-26T15:27:45.874Z"},"maintainers":[{"name":"carlosvpi","email":"carlos.vazpi@gmail.com"}],"description":"Reactive programming made easy","homepage":"https://github.com/carlosvpi/flux#readme","repository":{"type":"git","url":"git+https://github.com/carlosvpi/flux.git"},"author":{"name":"CarlosVazPI","email":"carlos.vazpi@gmail.com"},"bugs":{"url":"https://github.com/carlosvpi/flux/issues"},"license":"MIT","readme":"# flux\nReactive programming made easy\n\nA flux is an asynchronous stream if values. A flux is created open. While a flux is open, new values can be pushed to it. The flux can be terminated.\n\n# Install\n\n```\nyarn add @carlosvpi/flux\n```\n\n# How to use\n\n```javascript\nconst { Flux } = require('@carlosvpi/flux')\n```\n\n# Creating a flux\n\nThe constructor of the class `Flux` accepts two parameters:\n\n* builder: `(push: (value) => any, end: () => any, value: () => any) => any`: the builder calls `push` whenever a value is to be pushed into the flux. To terminate the flux, the method `end` is called. The method `value` returns the value of the flux at any given moment. The value returned by the builder will be passed as a parameter to the second parameter in the constructor, the cleaner. Functions `push` and `end` return the created flux.\n* cleaner: `(cleanData: any) => any`: the cleaner takes as an argument the value returned by the builder. The cleaner is called when the flux is terminated. It can perform a last operation to clean memory or other processes (like clearing intervales).\n\n```javascript\nconst flux = new Flux(push => push(42))\n```\n\nThe above code creates a flux with value 42.\n\n```javascript\nconst flux = new Flux((push, end, value) => push(0) && setInterval(() => value() > 10 ? end() : push(value()+1), 1000), clearInterval)\n```\n\nThe above code creates a flux that increments its value, starting from 0, every second, and clears the interval one second after reaching 10.\n\n# Flux methods\n\n### push\n\n`flux.push` pushes a value into the flux.\n\n```javascript\nflux.push(1)\n```\n\nThe above call changes the internal value of the flux to 1.\n\nA call to push triggers all the flux's subscriptions. If the flux is terminated, `flux.push` wont have any effect. The call to push returns the flux itself.\n\n### end\n\n`flux.end` terminates flux.\n\n```javascript\nflux.end()\n```\n\nThe above call terminates the flux.\n\nA call to end triggers all the flux's subscriptions. If the flux is terminated, `flux.end` wont have any effect. The call to end returns the flux itself.\n\n### subscribe\n\n`flux.subscribe` subscribes a method, called subscription, to the flux. A subscription is a function that receives parameters `value` and `done`, and is called every time a value is pushed to the flux, or it is terminated. When the flux is updated via `push`, `value` is given the current value of the flux, and `done = false`. When the flux is terminated, `value` has the last value of the flux and `done = true`.\n\n```javascript\nflux.subscribe(console.log)\n```\n\nThe above code logs each value of the flux, and whether it is terminated or not.\n\nThis call returns the flux.\n\n### unsubscribe\n\n`flux.unsubscribe(subscription)` removes a subscription from the flux, so it won't be triggered on `push` or `end`.\n\nThis call returns the flux.\n\n### pop\n\n`flux.pop(...subscriptions)` both call the subscriptions and subscribe them to the flux.\n\nThis call returns the flux.\n\n# Flux transformations\n### map\n\n`flux.map(f)` returns a flux whose values are those of `flux` operated by `f`. It ends at the same time as `flux`.\n\n### reduce\n\n`flux.reduce((acc, value) => f(acc, value), initial)` returns a flux _reductor_ whose values are the result of operating `f` with the current value of the _reductor_ and the current value of the `flux`. The initial value of the _reductor_ is `initial`. It ends at the same time as `flux`.\n\n### filter\n\n`flux.filter(p)` returns a flux whose values are those of `flux` that return `true` when operated by `p`. It ends at the same time as `flux`.\n\n### reject\n\n`flux.reject(p)` returns a flux whose values are those of `flux` that return `false` when operated by `p`. It ends at the same time as `flux`.\n\n### compact\n\n`flux.compact(p)` returns a flux whose values are those of `flux` that are truthy. It ends at the same time as `flux`.\n\n### last\n\n`flux.last(n: number)` returns a flux whose values are an array of the `n` last values produced by `flux`. It ends at the same time as `flux`.\n\n### toPromise\n\n`flux.toPromise()` returns a promise that is resolved with the next value pushed to the flux. If the flux is terminated before getting a new value, the promise is rejected.\n\n### mergeRace\n\n`flux.mergeRace(...fluxes)` returns a flux whose value is the value of the last of the fluxes (from its parameters and also flux) that was updated. It ends at the same time as the first flux ends.\n\n### mergeAll\n\n`flux.mergeAll(...fluxes)` returns a flux whose value is the value of the last of the fluxes (from its parameters and also flux) that was updated. It ends at the same time as the last flux ends.\n\n### debounce\n\n`flux.debounce(ms)` returns a flux whose value is the debounced (by ms milliseconds) value of flux. This is, upon a value is pushed to `flux`, that value is pushed to the debounced flux after ms milliseconds unless another value is pushed to `flux` in the meantime. It ends at the same time as the last flux ends.\n\n### throttle\n\n`flux.throttle(ms)` returns a flux whose value is the throttled (by ms milliseconds) value of flux. This is, upon a value is pushed to `flux`, _throttled_ pushes said value and sets a timer for ms milliseconds. While the timer is running no new pushes to `flux` are pushed to _throttled_. It ends at the same time as the last flux ends.\n\n# Static methods from Flux\n\n### fromTimeout\n\n`Flux.fromTimeout(ms)` creates a flux. After ms milliseconds an `undefined` value is pushed, and then the flux is terminated. It is possible to terminate the flux before the timeout with `flux.end()`.\n\n### fromInterval\n\n`Flux.fromInterval(ms)` creates a flux. It sets an internval of ms milliseconds, and on each interval an `undefined` value is pushed. It is possible to terminate the flux with `flux.end()`.\n\n### fromPromiseFactory\n\n`Flux.fromPromiseFactory(getPromise)` creates a flux _fromPromise_. The parameter `getPromise` is a function that takes a `{clear:()=>any}` object and returns a promise. When `getPromise` is resolved when a value, that value is pushed to _fromPromise_ and a new promise from `getPromise` is awaited. It is possible to terminate the flux with `flux.end()`.\n\n### fromEvent\n\n`Flux.fromEvent(DOMNode, eventName, useCapture)` creates a _fromEvent_ flux and attaches an eventListener to a DOM node. Every time the specified event type is triggered in the DOM node, the event is pushed to _fromEvent_. It is possible to detach the eventListener from the DOM node by terminating _fromEvent_.\n","readmeFilename":"README.md"}