{"id":19354640,"url":"https://github.com/omer73364/toggle-item-in-array","last_synced_at":"2026-05-02T03:02:14.612Z","repository":{"id":57173318,"uuid":"354795710","full_name":"omer73364/toggle-item-in-array","owner":"omer73364","description":"A JavaScript package to toggle a value in an array with an optional validation function","archived":false,"fork":false,"pushed_at":"2022-02-16T13:33:37.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-30T02:08:50.402Z","etag":null,"topics":["add","array","javascript","method","npm","package","remove","toggle"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omer73364.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-05T10:23:33.000Z","updated_at":"2022-02-16T13:34:52.000Z","dependencies_parsed_at":"2022-08-24T14:41:12.819Z","dependency_job_id":null,"html_url":"https://github.com/omer73364/toggle-item-in-array","commit_stats":null,"previous_names":["omer73364/addremove-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omer73364%2Ftoggle-item-in-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omer73364%2Ftoggle-item-in-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omer73364%2Ftoggle-item-in-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omer73364%2Ftoggle-item-in-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omer73364","download_url":"https://codeload.github.com/omer73364/toggle-item-in-array/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240466792,"owners_count":19805862,"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":["add","array","javascript","method","npm","package","remove","toggle"],"created_at":"2024-11-10T05:02:55.462Z","updated_at":"2026-05-02T03:02:09.564Z","avatar_url":"https://github.com/omer73364.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# toggle-item-in-array\n\nA JavaScript package to toggle a value in an array with an optional validation function\n\n# toggle function adds or removes a value from an array\n\n## it accepts three parameters:\n \n   1) an array\n   2) a value\n   3) a funcion to validate the value (optional parameter)\n \n if the array actually includes the value then it removes the value from the array\n if not then it adds the value to the array\n \n##  usage:\n\n  ### NPM:\n  \n      download this library:\n      \n        npm i toggle-item-in-array --save\n        \n        \n      then import it:\n      \n        import { toggle } from 'toggle-item-in-array';\n        \n        \n      then you can use it as a function by \"toggle\" name\n        \n### HTML:\n\n      include the library in your html page\n      \n        \u003cscript src=\"https://unpkg.com/toggle-item-in-array@1.0.1/toggle-item-in-array.js\"\u003e\u003c/script\u003e\n        \n        \n      then you can use it as a function by \"toggle\" name\n        \n##  example:\n\n      let arr = [12]\n      \n      toggle(arr,5) // will add 5 to arr\n      console.log(arr) // [12,5]\n      \n      toggle(arr,12) // will remove 12 from arr\n      console.log(arr) // [5]\n      \n      toggle(arr,'bad',(v)=\u003ev!=='bad') // will not add because the value is not valid\n      console.log(arr) // [5]\n      \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomer73364%2Ftoggle-item-in-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomer73364%2Ftoggle-item-in-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomer73364%2Ftoggle-item-in-array/lists"}