{"id":16339018,"url":"https://github.com/phadej/menrva","last_synced_at":"2025-03-20T23:31:10.845Z","repository":{"id":18257330,"uuid":"21413596","full_name":"phadej/menrva","owner":"phadej","description":"Ambitious data-flow library","archived":false,"fork":false,"pushed_at":"2017-01-02T14:10:06.000Z","size":409,"stargazers_count":36,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T00:55:50.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phadej.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T06:21:56.000Z","updated_at":"2021-05-07T14:08:15.000Z","dependencies_parsed_at":"2022-07-26T21:32:12.653Z","dependency_job_id":null,"html_url":"https://github.com/phadej/menrva","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Fmenrva","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Fmenrva/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Fmenrva/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phadej%2Fmenrva/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phadej","download_url":"https://codeload.github.com/phadej/menrva/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244090813,"owners_count":20396491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T23:53:19.563Z","updated_at":"2025-03-20T23:31:10.521Z","avatar_url":"https://github.com/phadej.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# menrva\n\n\u003c!-- README.md is autogenerated --\u003e\n\n[![Build Status](https://secure.travis-ci.org/phadej/menrva.svg?branch=master)](http://travis-ci.org/phadej/menrva)\n[![NPM version](http://img.shields.io/npm/v/menrva.svg)](https://www.npmjs.org/package/menrva)\n[![Dependency Status](https://david-dm.org/phadej/menrva.svg)](https://david-dm.org/phadej/menrva)\n[![devDependency Status](https://david-dm.org/phadej/menrva/dev-status.svg)](https://david-dm.org/phadej/menrva#info=devDependencies)\n[![Coverage Status](https://img.shields.io/coveralls/phadej/menrva.svg)](https://coveralls.io/r/phadej/menrva?branch=master)\n[![Code Climate](http://img.shields.io/codeclimate/github/phadej/menrva.svg)](https://codeclimate.com/github/phadej/menrva)\n\nAmbitious data-flow library.\n\n## Getting Started\nInstall the module with: `npm install menrva`\n\n```js\nvar menrva = require('menrva');\nmenrva.some('awe'); // some, as in awesome?\n```\n\n## API\n\n\n### Signal\n\nThe core type of menrva. `Signal` is abstract class, and cannot be created explicitly.\n\nSimilar concepts are: *Behaviours* in FRP, *Properties* in bacon.js.\n\nYou can add methods to `Signal`'s prototype. They will be available on all signals.\n\n\n#### signal.map\n\n\u003e map (@ : Signal a, f : a -\u003e b, eq = egal : b -\u003e b -\u003e boolean) : Signal b\n\n\n#### signal.onValue\n\n\u003e onValue (@ : Signal a, callback : a -\u003e void) -\u003e Unsubscriber\n\nAdd value callback. `callback` is immediately executed with the current value of signal.\nAfter than `callback` will be called, each time signal's value changes.\n\nThe return value is a function, which will remove the callback if executed.\n\n\n#### signal.value()\n\n\u003e value (@ : Signal a): Signal a\n\nReturns the current value of signal.\n\n\n### Source\n\nA signal which value you can set.\n\nSimilar concepts are: *Bacon.Model* in bacon.js, *BehaviourSubject* in Rx.\n\n\n#### source\n\n\u003e source (initialValue : a, eq = egal : a -\u003e a -\u003e boolean) : Source a\n\n\n#### source.set\n\n\u003e set (@ : Source a, tx : Transaction, value : a) : void\n\n\n#### source.modify\n\n\u003e modify (@ : Source a, tx : Transaction, f : a -\u003e a) : void\n\nMofify source value. `f` will be called with current value of signal inside the transaction.\n\n\n### Signal combinators\n\n\n#### combine\n\n\u003e combine (Signal a..., f : a... -\u003e b) : Signal b\n\nApplicative n-ary lift. Lift pure function to operate on signals:\n```js\nvar $sum = menrva.combine($a, $b, function (a, b) {\n  return a + b;\n});\n```\n\n\n\n### Transaction\n\nOne gathers atomic updates into single transaction (to avoid glitches).\n\n```js\nvar tx = menrva.transaction();\nsourceA.set(tx, 42);\nsourceB.modify(tx, function (x) { return x + x; });\ntx.commit(); // not necessary, transactions are auto-commited\n```\n\nThere are also optional syntaxes for simple transactions:\n```js\nmenrva.transaction()\n  .set(sourceA, 42)\n  .modify(sourceB, function (x) { return x + x; })\n  .commit();\n```\nor even\n```js\nmenrva.transaction([sourceA, 42, sourceB, function(x) { return x + x; }]).commit();\n```\n\n\n#### transaction\n\n\u003e transaction (facts) : Transaction\n\nCreate transaction.\n\nShorthand syntax:\n\n\u003e transaction ([sourceA, valueA, sourceB, valueB ...]) : Transaction\n\nIf `value` is function, `source.modify(tx, value)` is called; otherwise `source.set(tx, value)`.\n\n\n#### transaction.commit\n\nCommit the transaction, forcing synchronous data propagation.\n\n\n#### transaction.rollback\n\nRollback the transaction. Maybe be called multiple times (consecutives calls are no-op).\n\n*Note: for now `rollback` only resets the pending actions in transactions. Transaction is still valid, and more actions can be added*\n\n\n\n### Lens\n\nLenses are composable functional references.\nThey allow you to *access* and *modify* data potentially very deep within a structure!\n\n\n#### source.zoom\n\n\u003e zoom (@ : Source a, path : Path a b, eq = egal : b -\u003e b -\u003e boolean) : Source b\n\nZoom (or focus) into part specified by `path` of the original signal.\nOne can `set` and `modify` zoomed signals, they act as sources.\n\n```js\nvar quux = source.zoom(\"foo.bar.quux\");\n```\n\n\n\n### Convenience methods\n\n#### signal.log\n\n\u003e signal.log (@ : Signal a, args...) : Unsubscriber\n\nEssentially `signal.onValue(console.log.bind(console, args...))\n\n\n#### signal.onSpread\n\n\u003e signal.onSpread (@ : Signal [a, b...], callback : a -\u003e b ... -\u003e void) : Unsubscriber\n\n`onValue` with signal's tuple arguments spread.\n\n\n#### tuple\n\n\u003e tuple (x : Signal a, y : Signal b...) : Signal [a, b...]\n\nCombine signals into tuple.\n\n\n#### sequence\n\n\u003e sequence [Signal a, Signal b, ..] : Signal [a, b...]\n\nIn promise libraries this might be called `all`.\n\n\n#### record\n\n\u003e record {k: Signal a, l: Signal b...} : Signal {k: a, l: b...}\n\nLike `sequence` but for records i.e. objects.\n\n\n\n### Equalities\n\n#### egal\n\n\u003e egal (a, b) : boolean\n\nIdentity check. `Object.is`. http://wiki.ecmascript.org/doku.php?id=harmony:egal\n\n\n\n### Option\n\nAlso known as `Maybe`.\n\n\n#### option.equals\n\n\u003e equals (@ : option a, other : *, eq = eqal : a -\u003e a -\u003e boolean) : boolean\n\nEquality check.\n\n\n#### option.map\n\n\u003e map (@ : option a, f : a -\u003e b) : option b\n\n\n#### option.elim\n\n\u003e elim (@ : option a, x : b, f : a -\u003e b) : b\n\n\n\n#### option.orElse\n\n\u003e orElse (@ : option a, x : a) : a\n\n\n\n## Contributing\n\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style.\n\nAdd tests for any new or changed functionality. 100% coverage isn't hard. Semantic coverage is important too though.\n\nNote: `README.md` is autogenerated file.\n\n## Release History\n\n\n- **0.0.7** `sequence` and `record`\n- **0.0.6** Convenience methods\n- **0.0.5** Lens\n- **0.0.4** Internal improvements\n- **0.0.3** Slight changes in API\n- **0.0.2** Basic data-flow functionality\n- **0.0.1** Name reservation\n\n## License\n\nCopyright (c) 2014 Oleg Grenrus.\nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphadej%2Fmenrva","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphadej%2Fmenrva","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphadej%2Fmenrva/lists"}