{"id":16760511,"url":"https://github.com/ryanve/flish","last_synced_at":"2025-03-16T09:22:16.677Z","repository":{"id":66123059,"uuid":"68262399","full_name":"ryanve/flish","owner":"ryanve","description":"JavaScript flash message module","archived":false,"fork":false,"pushed_at":"2017-03-17T22:22:18.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T21:51:21.749Z","etag":null,"topics":["flash-messages","javascript","module","notifications"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/flish","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/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-15T03:04:07.000Z","updated_at":"2023-08-08T21:06:51.000Z","dependencies_parsed_at":"2023-07-03T02:22:43.774Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/flish","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"d6d866b958e7cf5d1d10f86625a2e1a2ce03db4d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fflish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fflish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fflish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fflish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/flish/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243848177,"owners_count":20357503,"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":["flash-messages","javascript","module","notifications"],"created_at":"2024-10-13T04:23:44.833Z","updated_at":"2025-03-16T09:22:16.654Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flish\nFlash messages made simple\n\n```sh\nnpm install flish --save\n```\n\n```js\nvar flish = require('flish')\n```\n\n## API\n- flish methods are chainable\n- flish is designed for flash messages or notifications, but it can be used for generic tasks too\n\n### `flish()`\n- Get a flish instance\n- \u003cb\u003e@return\u003c/b\u003e object\n\n### `.use(handler)`\n- Set the flash handler that gets invoked with the outgoing flashes array whenever `.send()` is called\n- \u003cb\u003e@return\u003c/b\u003e this\n\n### `.add(flash)`\n- Enqueue flash string, object, or function\n- \u003cb\u003e@return\u003c/b\u003e this\n\n### `.send()`\n- Flush and dispatch the flash queue\n- \u003cb\u003e@return\u003c/b\u003e this\n\n## Examples\n\n### Log flash messages\n```js\nvar flish = require('flish')\n\n// Create a flash instance and define its handler\nvar flash = flish().use(function(flashes) {\n  flashes.forEach(function(text) {\n    console.log(text)\n  })\n})\n\n// Add some flashes and then send them\nflash.add('You rock!')\nflash.add('You roll!')\nflash.send() // logs 'You rock!' and 'You roll!'\nflash.add('You stole!')\nflash.send() // logs 'You stole!'\nflash.send() // logs nothing because no new flashes were added\n```\n\n### Flash message objects\n```js\nvar flish = require('flish')\n\nvar flash = flish().use(function(flashes) {\n  flashes.forEach(function(flash) {\n    console[flash.level](flash.text)\n  })\n})\n\nflash.add({\n  text: 'You rock!',\n  level: 'info'\n}).add({\n  text: 'You roll!',\n  level: 'warn'\n}).add({\n  text: 'You stole!',\n  level: 'error'\n}).send()\n```\n\n### HTML flash messages\n```html\n\u003csection id=\"flashes\" role=\"status\"\u003e\u003c/section\u003e\n```\n\n```css\n#flashes:empty {\n  display: none;\n}\n```\n\n```js\nvar flish = require('flish')\n\nvar flash = flish().use(function(flashes) {\n  $('#flashes').html(flashes.map(function(flash) {\n    var tag = flash.isError ? ['\u003cp\u003e\u003cstrong\u003e', '\u003c/strong\u003e\u003c/p\u003e'] : ['\u003cp\u003e', '\u003c/p\u003e']\n    return tag.join(flash.message)\n  }).join(''))\n})\n\nflash.add({\n  message: 'You rock!'\n}).add({\n  message: 'You roll!'\n}).add({\n  message: 'You stole!',\n  isError: true\n}).send()\n```\n\n### Flish instances are like arrays\n```js\nvar flish = require('flish')\nvar flash = flish()\n\nif (flash.length) {\n  flash.send()\n}\n\nif (flash.some(function(o) { return o.isError })) {\n  flash.send()\n}\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fflish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Fflish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fflish/lists"}