{"id":23366733,"url":"https://github.com/d8corp/innet-for","last_synced_at":"2025-04-07T23:15:44.118Z","repository":{"id":57118758,"uuid":"327013416","full_name":"d8corp/innet-for","owner":"d8corp","description":"innet plugin for effective rendering of iterable objects","archived":false,"fork":false,"pushed_at":"2021-06-16T22:49:28.000Z","size":200,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T09:03:58.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/d8corp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-05T13:51:51.000Z","updated_at":"2021-06-16T22:49:31.000Z","dependencies_parsed_at":"2022-08-23T05:41:02.951Z","dependency_job_id":null,"html_url":"https://github.com/d8corp/innet-for","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Finnet-for","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Finnet-for/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Finnet-for/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Finnet-for/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d8corp","download_url":"https://codeload.github.com/d8corp/innet-for/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744328,"owners_count":20988783,"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-12-21T14:17:28.842Z","updated_at":"2025-04-07T23:15:44.083Z","avatar_url":"https://github.com/d8corp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/d8corp/innet/main/logo.svg\" align=\"left\" width=\"90\" height=\"90\" alt=\"InnetJs logo by Mikhail Lysikov\"\u003e\n\n# \u0026nbsp; @innet/for\n\n\u0026nbsp;\n\n[![NPM](https://img.shields.io/npm/v/@innet/for.svg)](https://github.com/d8corp/innet-for/blob/main/CHANGELOG.md)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/@innet/for)](https://bundlephobia.com/result?p=@innet/for)\n[![downloads](https://img.shields.io/npm/dm/@innet/for.svg)](https://www.npmjs.com/package/@innet/for)\n[![license](https://img.shields.io/npm/l/@innet/for)](https://github.com/d8corp/innet-for/blob/main/LICENSE)  \n\nThis plugin helps if you need to loop over lists of data based on an array, Set, Map, etc.\n\n[![stars](https://img.shields.io/github/stars/d8corp/innet-for?style=social)](https://github.com/d8corp/innet-for/stargazers)\n[![watchers](https://img.shields.io/github/watchers/d8corp/innet-for?style=social)](https://github.com/d8corp/innet-for/watchers)\n\n### Installation\nnpm\n```bash\nnpm i @innet/for\n```\nyarn\n```bash\nyarn add @innet/for\n```\n\nOr just download a minified js file\n[here](https://github.com/d8corp/innet-for/blob/main/lib/innet-for.min.js)\n\n### Using\nProvide the plugin into the third argument of [innet](https://www.npmjs.com/package/innet)\n```typescript\nimport innet from 'innet'\nimport For from '@innet/for'\nimport App from './App.tsx'\n\ninnet({type: App}, undefined, {for: For})\n```\nThen just use it anywhere in the app.\n```typescript jsx\n\u003cfor of={['foo', 'bar', 'baz']}\u003e\n  {value =\u003e \u003cdiv\u003e{value}\u003c/div\u003e}\n\u003c/for\u003e\n```\n\n##### Index\nYou can get index of an element by the second argument.\n```typescript jsx\n\u003cfor of={['foo', 'bar', 'baz']}\u003e\n  {(value, index) =\u003e \u003cdiv\u003e#{index}: {value}\u003c/div\u003e}\n\u003c/for\u003e\n```\n\n##### Key\nYou can use `key` attribute to bind HTML element with the list item.\n```typescript jsx\n\u003cfor of={[{_id: 1}, {_id: 2}]} key='_id'\u003e\n  {(item, i) =\u003e \u003cdiv\u003e{i}: {item._id}\u003c/div\u003e}\n\u003c/for\u003e\n```\n\nOr you can use a function to identify the item.\n```typescript jsx\n\u003cfor of={[{_id: 1}, {_id: 2}]} key={item =\u003e item._id}\u003e\n  {(item, i) =\u003e \u003cdiv\u003e{i}: {item._id}\u003c/div\u003e}\n\u003c/for\u003e\n```\n##### Else\nYou can show something when the list is empty.\n```typescript jsx\n\u003cfor of={[]}\u003e\n  {() =\u003e \u003cdiv\u003eThe function will not run\u003c/div\u003e}\n  This text is shown 'cause of the array is empty.\n  \u003cp\u003e\n    Any children after the first function is shown!\n  \u003c/p\u003e\n\u003c/for\u003e\n```\n##### Size\nYou can limit the list by `size` property.\n```typescript jsx\n\u003cfor of={['foo', 'bar', 'baz']} size={2}\u003e\n  {item =\u003e \u003cdiv\u003e{item}\u003c/div\u003e}\n\u003c/for\u003e\n```\n*The property can be a function to react on a state changes.*\n##### State\nYou can use state of list to react on the changes.\n```typescript jsx\nconst data = new State(['foo'])\n\ninnet((\n  \u003cfor of={() =\u003e data.value}\u003e\n    {(item, i) =\u003e \u003cdiv\u003e{i}: {item}\u003c/div\u003e}\n  \u003c/for\u003e\n), undefined, {for: For})\n\ndata.value.push('bar')\ndata.update()\n```\n### Issues\nIf you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innet-for/issues).  \n[![issues](https://img.shields.io/github/issues-raw/d8corp/innet-for)](https://github.com/d8corp/innet-for/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd8corp%2Finnet-for","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd8corp%2Finnet-for","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd8corp%2Finnet-for/lists"}